e 14 Quick Start Guide

30
E14 Analysis Quick Start Guide Tejin Cai March 20, 2014

description

Some useful info for the KOTO E14 library

Transcript of e 14 Quick Start Guide

Page 1: e 14 Quick Start Guide

E14 Analysis Quick Start Guide

Tejin Cai

March 20, 2014

Page 2: e 14 Quick Start Guide

Contents

1 Getting Started 21.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2 Installing E14 Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2.1 Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.2.2 Setting PATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2.3 Make and Install E14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Using ROOTS 52.1 Writing and Accessing Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

2.1.1 Structure of TTree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.2 Accessing Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.1.3 Know your variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1.4 Accessing the Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2 Plots and Cuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 Useful Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 E14 Library Overview 93.1 ANALYSIS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.1.1 csimap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1.2 cluster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.3 gamma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.1.4 pi0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.5 klong . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.6 rec2g . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113.1.7 gnana . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.2 SIMULATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.2.1 GsimData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4 E14 Using Examples 154.1 What’s in examples/? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.2 Compiling an Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154.3 e14gnana . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

4.3.1 e14clustering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164.3.2 e14g6ana . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

5 Simulation 255.1 Creating MC using /example/gsim4test . . . . . . . . . . . . . . . . . . . . . . . . 255.2 Access MC output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

1

Page 3: e 14 Quick Start Guide

Chapter 1

Getting Started

1.1 Introduction

The K0TO collaboration aims at finding the rare CP-violaing KL → π0νν̄ , of which the branchingratio is directly proportional to the η element of the CKM matrix.

In order to analyze the given data, the E14 analysis library has been written and is being developedby colleagues in Japan. Due to the lack of official documentation it might present some difficultiesin getting started on the analysis especially for newcomers. This documentation aims to alleviatethe issue by giving a brief overview of the E14 Library as well as ROOT

1.2 Installing E14 Library

1.2.1 Prerequisites

The E14 library is built around 3 packages: ROOT, CLHEP and GEANT4. The ROOT is the defaultHEP analysis package developed by CERN. CLHEP provides some useful utilities to make relativisticcomputations. GEANT4 is used for Monte Carlo (MC) simulated data.

The latest development version of E14 can be found on KEKCC atkekcc:/sw/koto/e14lib/dev

The production versions are found at

kekcc:/sw/koto/e14lib/201305v* folders

The most important thing, however, is setting up the correct path for the various packages/libraries.The procedure

There are a few copies available on Uchicago local cluster. An older copy is found at

doewah:/cpv/code/e14 bakcup.

Inside these folders you should see e14/, setup.sh and setup.csh. Copy them to the directoryof your choice.

2

Page 4: e 14 Quick Start Guide

1.2.2 Setting PATH

Before compiling the E14 Library we must set the appropriate path (ROOT, GEANT4, CLHEP andE14).

On UChicago Machines

Navigate to doewah:/cpv/code/e14 bakcup and copy mye14.sh to your directory.

Open mye14.sh using a text editor, modify the last line:

source /cpv/code/e14/dev/setup.sh

To

source /your/directory/setup.sh

This should take care the path to ROOT, GEANT4 and CLHEP.

Next, open setup.sh and change

export E14 TOP DIR=/blah/blah/blah/e14

to export E14 TOP DIR=/your/directory/e14

Everytime you open an terminal, you have to type

source mye14.sh

You can also add the path to .bashrc to save the trouble of doing it everytime.

NOTE: The above instruction only works for the version in doewah:/cpv/code/e14 bakcup.If you downloaded the latest version from KEK server, you can follow a similar approach as detailed inthe next section. However you must change the path for GEANT4, ROOT and CLHEP in env.shaccordingly. I have not tried it myself but it should in principal work.

On KEK Clusters

An useful document to refer to is athttp://kds.kek.jp/conferenceDisplay.py?confId=685under technote. It details the procedure to install the pro version on KEK cluster. It uses svn toimport the packages from an svn server.

To set up the E14 library manually, go to kekcc:/sw/koto/e14lib/. Here you will find variousfolders ./201305v* and ./dev. To use the development version, for example,

1. copy the content of ./dev to a folder of your choice. i.e. /path/to/my/folder/dev.

2. copy env.sh from any of the 201305* folder, i.e.

/sw/koto/e14lib/201305v2.29/env.sh to

3

Page 5: e 14 Quick Start Guide

/path/to/my/folder/dev

3. open env.sh with a text editor, i.e. vi

4. go to the last line, change

source blah/blah/blah/setup.sh to

source /path/to/my/folder/dev/setup.sh

Once completed,

source env.sh

You should see

Successfully configured!

If path is set correctly.

1.2.3 Make and Install E14

Go to e14/:cd e14/make clean %This will remove everything except the source codesmake install-headers

Once done, typemake %To compile

The entire process can take quite a long time, you’ll have to be patient.

4

Page 6: e 14 Quick Start Guide

Chapter 2

Using ROOTS

2.1 Writing and Accessing Tree

Most of the times, data taken in experiments are stored in a tree data structure with type TTree.For detailed information about TTree please visit the official tutorial:http://root.cern.ch/download/doc/ROOTUsersGuideChapters/Trees.pdfFor the purpose of this guide I will just show you how to write and access a tree quickly.

2.1.1 Structure of TTree

Under each TTree object there will be branches that contain the actual data.

2.1.2 Accessing Tree

Suppose you have a file named “output.root” and that it contains a TTree object named “Tree”.There are two ways to access the TTree object.

1. In ROOT, type

TFile *inputFile=new TFile("output.root");TTree *inputTree=(TTree*) inputFile ->Get("Tree");

Now the pointer variable inputTree will point to the address of the TTree in the file.

2. The second method uses TChain class, which is a derived class from TTree. It can uses allthe functions associated with TTree and plus some more functions:

TChain *inputChain=new TChain("Tree");inputChain ->Add(‘‘output.root");

The name of the TTree is set as an input paramter in the declaration of TChain. The TChainthen add the file that contains the particular TTree. This has the advantage that if you havemultiple files containing data using the same TTree structure, you can keep adding thesefiles to accumulate the events:

5

Page 7: e 14 Quick Start Guide

inputChain ->Add("output1.root");inputChain ->Add("output2.root");...inputChain ->Add("outputn.root");

2.1.3 Know your variables

Once the inputTree has been defined, we need to map the branches to appropriate variables.

For example, a data of type int can only be assigned to a variable of type int.

You can visually look at the TTree and its branches by opening a browser in ROOT:

TBrowser br;

This will open a browser window as such:

Figure 2.1: TBrowser window

If your right-click on one variable (the one with green leaf sign to the left), and select “Inspect”, youwill open a new window that shows the variable type information. Here I selected GamClusCsiTimeas an example:

6

Page 8: e 14 Quick Start Guide

Figure 2.2: TBrowser window with variable property

On the top row, from left to right are “TBranch”, “GamClusCsiTime” and“GamClusCsiTime[GamClusNumber][120]/D” respectively. The variable values are stored in a“TBranch” data structure, “GamClusCsiTime” is the name of the variable. But most importantlyis the third expression. “GamClusCsiTime[GamClusNumber][120]/D” tells us what kind of variableis stored, in this case it is a 2-dimensional array of type double.

Here is a list of most used types for E14, you can find a full list in the official user guide.

• I → int

• i→ unsigned int

• S → short

• s→ unsigned short

• F → float

• D → double

The value of GamClusNumber is actually stored in the variable of the same name inside the tree inthis case. The size of GamClusNumber, when it comes to KL → 3π0, is 6 because each π0 decaysto 2 γ

2.1.4 Accessing the Variable

To retrieve the values stored in one branch, we first define a variable of the same type as shown inthe TBranch property window:

7

Page 9: e 14 Quick Start Guide

double Variable[6][120];

inputTree ->SetBranchAddress(”GamClusCsiTime”, Variable);

The first string is the name of the TBranch, the second string gives the address of to store thevalues to. If the data is not an array type, for example GamClusNumber, which on the PropertyWindow will show up as “GamClusNumber/I”, we can map it by:

int Variable2;

inputTree ->SetBranchAddress(“GamClusNumber”, &Variable2);

Note the “&” sign in front of Variable2.

Accessing the data will be very easy:

inputTree ->GetEntries();

will return total number of events in the TTree and

inputTree ->GetEntry(i);

will return the ith entry. If you do so Variable and Variable2 will take on the values for that particularentry.

2.2 Plots and Cuts

It is very easy to make plots and cuts in ROOT, essentially all you have to do is using Draw(), forexample:

inputTree -> Draw(“KlongMass[0]:KlongPos[0][2]”, “abs(KlongChisqZ[0]-KlongChisqZ[1])>20”);

The first string tells us we want to plot KlongMass[0] against KlongPos[0][2], ie the first recon-structed Klong Mass against its z-position, and the second string provides the cut conditions.

We do not need to define the variable address as done in the previous sections, all we have to do isto use the appropriate names shown in the Property Window.

2.3 Useful Functions

ROOT has some useful string manipulation functions

• Form(”string%i%i...%i”, a1,a2,a3,..,an);Each %i represents an integer that you can set using ai

8

Page 10: e 14 Quick Start Guide

Chapter 3

E14 Library Overview

In the E14 top directory, under sources/ there are ana/ and rec, which stands for ANALYSISand SIMULATION. Here is a list of frequently used packages.

1. ana/rec

(a) cluster

(b) csimap

(c) gamma

(d) gnana

(e) klong

(f) pi0

(g) rec2g

2. sim/gsim4

(a) GsimData

(b) GsimDetector

(c) GsimE14Detector

Here I will give an overview of their contents.

3.1 ANALYSIS

3.1.1 csimap

CsiMap.h

CsiMap is the class that will give you the CsI mapping information.

void getXYW(int const&ID, double &x, double &y, double &w) const;

will assign the relevant values to variables of your choice. Similarly

9

Page 11: e 14 Quick Start Guide

void getXYWarray(int const&nDigi,int const *ID,double *x,double *y,double *w)const;

will assign all the CsI block information to relevant arrays.

3.1.2 cluster

Cluster.h

Cluster class has data structure that stores cluster information. When a particle deposits energyinto the CsI calorimeter, the energy is not contained within one crystal but also in the surroundingcrystals forming a cluster. Cluster stores cluster information using a set of private data, suchas total energy, cluster id. It also contains individual CsI crystal data using 3 vectors: m cidVec,m eVec and m timeVec.

ClusterFinder.h

ClusterFinder class finds clusters from the data input of the 2716 CsI crystals and supply theresults to Cluster. The method that performs this task is

list⟨Cluster⟩& findCluster( int nDigi, int *ID,double *E,double *time);

Where:

• nDigi→ Total number of crystal blocks involved in cluster finding

• *ID→ An array containing block IDs

• *E→ An array containing block energies

• *time→ An array containing block times

This function should find all clusters on the detector and return the results to a list of Cluster.

3.1.3 gamma

Gamma.h

Gamma is a data storage structure much like Cluster.

GammaFinder.h

GammaFinder will take in a list of Cluster and correct for the energy loss through a functionobtained using Artifiial Neural Network during previous calibration work. At this stage the clusterwill be passed as a photon as long as its energy exceeds 20 MeV. Look at the headers and sourcecodes for more details.

10

Page 12: e 14 Quick Start Guide

3.1.4 pi0

Pi0.h

Pi0 class contains information about π0 reconstructed from 2 photons. This class usesCLHEP/Vector/ThreeVector.h. CLHEP contains useful classes and functions to store andcalculate using position, velocity and energy.

const CLHEP::Hep3Vector& v() const{return m v;} will return vertice position stored inHep3Vector.

Similarly vx(), vy() and vz() return the vertice position of the π0.

Pi0 also defines 2 Gamma to store data about the 2 photons produced through π0 → γγ

3.1.5 klong

Klong.h

Klong is very similar to Pi0. It contains the data members and methods to access those members.It defines a vector of Pi0 to store π0 data, since a KL can produce 1, 2 or 3 π0s, and a vectorsupports variable number of such Pi0.

RecKlong.h

RecKlong provides the computational functions to reconstruct KL from π0 data or from γdata.

3.1.6 rec2g

Rec2g.h

Rec2g is the main class used for reconstructing π0 from 2γ.

void recVtxWithConstM(const Gamma& g1, const Gamma& g2,double Mass, double *recZ, double recZsig2);

will calculate the vertical decay vertice of a particle decaying to 2 photons by assuming a fixed Mass.During π0 reconstruction this mass is set to 0.1349764 GeV for π0.

11

Page 13: e 14 Quick Start Guide

3.1.7 gnana

DigiReader.h

The DigiReader class is primary interesting for simulated events, it functions to read values fromvarious detectors in the experiments. For example, vetos like CBAR, CV, etc, as well as informationpertaining to the main CsI detector.

Each detector is assigned a detector ID through

enum{CC01=0, CC02, CC03, CC04, CC05, CC06,CBAR, FBAR, CSI, BHPV, CV, BCV, BHCV, NCC, OEV};

While there is a set of functions general to all detectors, the CsI detector has its own set of methodstoo.

Examples of methods:int getDigiSize(int const detID) const; will return the number of individual modules/blocksdouble getDigiId(int const detID, int const i) const; will return the id number for theith block and so on. The suffix “Ene” pertains to energy and “Time” pertains to time.

E14GNAnaDataContainer.h

The E14GNAnaDataContainer class is an important class. It reads and creates necessaryTTrees for data input and output.

The void branchOf... methods creates branches for appropriate data.

The bool getData will read data into variables of your choice, void setData serves to supplythe data to variables linked to a TTree

E14GNAnaFunction.h

The E14GNAnaFunction class contains many methods used to correct the energy and positionof a cluster as well as functions that calculates χ2 values to determine if a cluster is of photonorigin. Its usage will be seen later when I go through the commonly used codes under example/folder.

3.2 SIMULATION

3.2.1 GsimData

The GsimData set of codes are the main tools used to access MC data generated through theGEANT4 based simulation.

12

Page 14: e 14 Quick Start Guide

GsimEventData.h

This is a data class to store the simulated run information of the MC tree. Here is the list of thevariables

UShort_t expMC; // exp=1,MC=2UInt_t run_number; //UShort_t spill_number; //UInt_t event_number; //UInt_t trigger; // trigger bit patternUInt_t time_stamp; // localtimeUInt_t status; // general statusUShort_t version;

GsimTrackData.h

This class stores the track information of a decay which could be written to an output tree, whichincludes:

The track ID, parent track ID, parent brief track ID, particle ID (PDG), initial momentum, initialposition, initial energy, initial creation process ID, brief detector ID history (maximum is 8) arestored.

UInt_t track; //Track IDInt_t mother; //ID of the parent trackInt_t pid; //particle ID from PDGTVector3 p; //initial momentumFloat_t ek; //Initial energyFloat_t mass; //MassFloat_t time; //Initial timeTVector3 v; //Initial positionTVector3 end_p; //Final momentumFloat_t end_ek; //Final energyFloat_t end_time; //Final timeTVector3 end_v; //Final positionShort_t mech; //Initial creation process IDUShort_t status; //0: stable, 1: decayUInt_t thisID; //Index of array in which it is storedULong64_t history;/*** @brief The brief IDs of the detectors the track passed through.

** The briefDetectorIDs are 0-30(0-9,a,b,..,u),

* while 31(v) is blank symbol.

* ULong64_t = unsigned long long=64bit=2ˆ(5*12+4)

* is used as a buffer whose depth is 12

* For example, 012cdev means the track passed the detectors

* with brief IDs, 0(start)->1->2->c->d->e(stop).

* If the number of

* brief detectors reaches 12,

* no more brief detector ID is filled in

* the briefDetectorIDHistory.

*/

13

Page 15: e 14 Quick Start Guide

GsimGenParticleData.h

This class will store an array of tracks using TCloneArray

GsimDetectorHitData.h

This class stores hit data (on detector) for output, it contains data members similar to GsimTrackData.

GsimDetectorEventData.h

“This class stores detector event data for output to a ROOT file. The number of hits, the totalenergy deposited, the time of the first hit, the time of the last hit, and an array of the hits arestored.”

14

Page 16: e 14 Quick Start Guide

Chapter 4

E14 Using Examples

4.1 What’s in examples/?

The examples/ folder contains the utilities written with the E14 packages to create MC, to processfiles and compute various parameters. For example, e14clustering/ will operate on MC datato output files containing clusters. This output can then be further processed by e14g2ana,e14g4ana or e14g6ana to reconstruct KL for various decay modes.

4.2 Compiling an Example

To compile e14clustering, for example, let’s go to the e14clustering/ directory:

cd examples/e14gnana/e14clustering

Inside there are bin/, tmp/, e14clustering.cc, Makefile and REQUIREMENTS. Type

make

You should see something similar to the following

Making dependency for file e14clustering.cc ...installing libs for e14clusteringCompiling e14clustering.cc ...e14clustering.cc: In function Int t main(Int t, char**):e14clustering.cc:41: warning: unused variable outerDetIDUsing global libraries ...Linking e14clustering... Done!installing bins for e14clustering

The make command will compile e14clustering.cc and install the executable in bin/ folder.The Makefile contains instructions for make to work:

# -*- Makefile -*-MAINS = e14clustering %The name of the source file and the executable

15

Page 17: e 14 Quick Start Guide

PACKAGE = $(shell basename ‘pwd‘)INSTALL LIBS = noINSTALL BINS = yesinclude $(E14 CONFIG DIR)/Makefile.g4

You can add

CFLAGS += -gLDFLAGS += -g

to Makefile to create debugging symbol during compilation.

The REQUIREMENTS tells make what packages to include for compiling:

#configgnanacsimapclustergammapi0klongrec2gE14FsimGsimDataGsimPersistency

During compilation make will search e14/include/ for the appropriate headers

4.3 e14gnana

e14gnana/ utilizes the various packages described previously to process the data for analysis

4.3.1 e14clustering

The original e14clustering works on MC files to produce cluster files for later analysis. Pleaseopen /home/cpv/tejinc/e14/examples/e14gnana/

e14clustering/e14clustering.cc

which is slightly modified from the original e14clustering.cc by adding in commands to includetotal energy from veto detectors.

1 #inc lude <TF i l e . h>2 #inc lude <TTree . h>3 #inc lude <gnana/D ig iReade r . h>4 #inc lude <gnana/E14GNAnaDataContainer . h>5 #inc lude <c l u s t e r / C l u s t e r F i n d e r . h>6

16

Page 18: e 14 Quick Start Guide

78 #inc lude <c s t d l i b >9 #inc lude <c s t d i o>

1011 #inc lude <f s t r eam>12 #inc lude <ss t ream>13 #inc lude <iomanip>14 #inc lude <i o s t r eam>15 #inc lude <c s t d l i b >16 #inc lude <cmath>171819 I n t t main ( I n t t argc , char ∗∗ argv )20 {21 // read argument22 i n t n loop = −1;23 i f ( a rgc==4){24 n loop = a t o i ( a rgv [ 3 ] ) ;25 s td : : cout<<” nRequest== ”<<nloop<<” e v en t s . ”<<s t d : : e nd l ;26 } e l s e i f ( a rgc !=3){27 s td : : c e r r << ”Argument e r r o r . ”<<s t d : : e nd l28 <<” usege : b i n / e 1 4 c l u s t e r i n g i npu t output [ nRequest ] ”29 <<s t d : : e nd l ;30 return 1 ;31 }3233 s td : : s t r i n g i fname = argv [ 1 ] ;34 s td : : s t r i n g ofname = argv [ 2 ] ;35 s td : : cout<<” i npu t f i l e : ”<<i fname<<s t d : : e nd l ;36 s td : : cout<<” output f i l e : ”<<ofname<<s t d : : e nd l ;3738 // s e t i n pu t f i l e39 TChain ∗ t r i n = new TChain ( ” eventTree00 ” ) ;40 t r i n−>Add( i fname . c s t r ( ) ) ;41 D ig iReade r d i g i R e ad e r ( t r i n ) ;4243 i n t oute rDet ID = d i g iR e a d e r . addDetec to r ( ” os . ” ) ;44 i n t CBARDetID=d i g iR e ad e r . getDet ID ( ”CBAR. ” ) ;45 i n t FBARDetID=d i g iR e a d e r . getDet ID ( ”FBAR. ” ) ;46 i n t CVDetID=d i g iR e ad e r . getDet ID ( ”CV. ” ) ;47 i n t OEVDetID=d i g iR e ad e r . getDet ID ( ”OEV. ” ) ;48 i n t NCCDetID=d i g iR e a d e r . getDet ID ( ”NCC. ” ) ;49 i n t CC03DetID=d i g iR e ad e r . getDet ID ( ”CC03 . ” ) ;50 i n t CC04DetID=d i g iR e ad e r . getDet ID ( ”CC04 . ” ) ;51 i n t CC05DetID=d i g iR e ad e r . getDet ID ( ”CC05 . ” ) ;52 i n t CC06DetID=d i g iR e ad e r . getDet ID ( ”CC06 . ” ) ;53 i n t BHCVDetID=d i g iR e a d e r . getDet ID ( ”BHCV. ” ) ;54 i n t BHPVDetID=d i g iR e a d e r . getDet ID ( ”BHPV. ” ) ;55 i n t BCVDetID=d i g iR e a d e r . getDet ID ( ”BCV. ” ) ;56 // s e t output f i l e57 TF i l e ∗ f o u t = new TF i l e ( ofname . c s t r ( ) , ”RECREATE” ) ;58 TTree ∗ t r o u t = new TTree ( ” t r o ” , ” output from e 1 4 c l u s t e r i n g ” ) ;59 E14GNAnaDataContainer data ;60 data . b r a n c hO fC l u s t e r L i s t ( t r o u t ) ;61 data . b ranchOfD ig i ( t r o u t ) ;626364 // d e c l a r e C l u s t e r F i n d e r and v a r i a b l e s65 i n t nCSID ig i =0;

17

Page 19: e 14 Quick Start Guide

66 i n t CSID ig i ID [3000 ]={0} ;67 double CSIDig iE [3000]={0} , CSIDig iTime [3000 ]={0} ;68 C l u s t e r F i n d e r c l u s t e r F i n d e r ( 3 , 0 ) ;69 double FBAREneTotal , CBAREneTotal , CVEneTotal , OEVEneTotal ;70 double NCCEneTotal , CC03EneTotal , CC04EneTotal , CC05EneTotal ;71 double CC06EneTotal , BHCVEneTotal , BHPVEneTotal , BCVEneTotal ;7273 t rou t−>Branch ( ”CSIDig iE ” , CSIDigiE , ” CSIDig iE [ 3000 ] /D” ) ;74 t rou t−>Branch ( ”FBAREneTotal” ,&FBAREneTotal , ”FBAREneTotal/D” ) ;75 t rou t−>Branch ( ”CBAREneTotal” ,&CBAREneTotal , ”CBAREneTotal/D” ) ;76 t rou t−>Branch ( ”CVEneTotal ” ,&CVEneTotal , ”CVEneTotal /D” ) ;77 t rou t−>Branch ( ”OEVEneTotal” ,&OEVEneTotal , ”OEVEneTotal/D” ) ;78 t rou t−>Branch ( ”NCCEneTotal” ,&NCCEneTotal , ”NCCEneTotal/D” ) ;79 t rou t−>Branch ( ”CC03EneTotal ” ,&CC03EneTotal , ”CC03EneTotal /D” ) ;80 t rou t−>Branch ( ”CC04EneTotal ” ,&CC04EneTotal , ”CC04EneTotal /D” ) ;81 t rou t−>Branch ( ”CC05EneTotal ” ,&CC05EneTotal , ”CC05EneTotal /D” ) ;82 t rou t−>Branch ( ”CC06EneTotal ” ,&CC06EneTotal , ”CC06EneTotal /D” ) ;83 t rou t−>Branch ( ”BHCVEneTotal” ,&BHCVEneTotal , ”BHCVEneTotal/D” ) ;84 t rou t−>Branch ( ”BHPVEneTotal” ,&BHPVEneTotal , ”BHPVEneTotal/D” ) ;85 t rou t−>Branch ( ”BCVEneTotal” ,&BHCVEneTotal , ”BCVEneTotal/D” ) ;8687 // loop a n a l y s i s88 i n t nen t r y = t r i n−>Ge tEn t r i e s ( ) ;89 s td : : cout<<”# of e n t r y i n i npu t t r e e ==”<<nent ry<<s t d : : e nd l ;90 i f ( nloop<0 | | nloop>nen t r y ) n loop = nen t r y ;9192 s td : : cout<<”\n s t a r t l oop a n a l y s i s f o r ”93 <<nloop<<” e v en t s . . . ”<<s t d : : e nd l ;9495 f o r ( i n t i e v t =0; i e v t<n loop ; i e v t++){96 i f ( nloop>100&& i e v t%(n loop /100)==0)97 s td : : cout<< i e v t /( n loop/100)<<”%”<<s t d : : e nd l ;9899 t r i n−>GetEntry ( i e v t ) ;100101 // C l u s t e r i n g102 d i g i R e ad e r . g e t C s iD i g i ( nCSIDig i , CSIDig i ID , CSIDigiE , CSIDig iTime ) ;103 FBAREneTotal=d i g iR e ad e r . g e tTota lEne rgy (FBARDetID ) ;104 CBAREneTotal=d i g i R e a d e r . g e tTota lEne rgy (CBARDetID ) ;105 CVEneTotal=d i g iR e ad e r . g e tTota lEne rgy (CVDetID ) ;106 OEVEneTotal=d i g i R e a d e r . g e tTota lEne rgy (OEVDetID ) ;107 NCCEneTotal=d i g i R e a d e r . g e tTota lEne rgy (NCCDetID ) ;108 CC03EneTotal=d i g i R e ad e r . g e tTota lEne rgy ( CC03DetID ) ;109 CC04EneTotal=d i g i R e ad e r . g e tTota lEne rgy ( CC04DetID ) ;110 CC05EneTotal=d i g i R e ad e r . g e tTota lEne rgy ( CC05DetID ) ;111 CC06EneTotal=d i g i R e ad e r . g e tTota lEne rgy ( CC06DetID ) ;112 BHCVEneTotal=d i g iR e ad e r . g e tTota lEne rgy (BHCVDetID ) ;113 BHPVEneTotal=d i g iR e ad e r . g e tTota lEne rgy (BHPVDetID ) ;114 BCVEneTotal=d i g iR e ad e r . g e tTota lEne rgy (BCVDetID ) ;115116 s td : : l i s t <C lu s t e r> c l i s t =117 c l u s t e r F i n d e r . f i n d C l u s t e r ( nCSIDig i ,118 CSIDig i ID , CSIDigiE , CSIDig iTime ) ;119120 // f i l l i n g d i g i−data and C l u s t e r i n f oma t i on i n TTree121 data . se tData ( d i g i R e ad e r ) ;122 data . se tData ( c l i s t ) ;123 t rou t−>F i l l ( ) ;124 data . event ID++;

18

Page 20: e 14 Quick Start Guide

125 }126127128 // end o f a n a l y s i s129 t rou t−>Write ( ) ;130 fout−>C lo s e ( ) ;131 s td : : cout<<” f i n i s h ! ”<<s t d : : e nd l ;132133 return 0 ;134 }

Line 39: a TChain pointer trin is created that takes trees with name “eventTree00” (that’s thename in MC output).Line 41: DigiReader object created and initialized to read trin.Line 43-55: Get the detector ID for each detector by invoking the “getDetID” function. The inputstring is the name of the detector defined in the MC output, i.e “detectorname.”.Line 57-61: Define the output file and tree, setting up branches of trout using “’branchOf*”functions.Line 102-114: “getCsiDigi” and “getTotalEnergy” will fill up the desired variables.Line 116: clusterFinder find clusters and fill each cluster to the list.

4.3.2 e14g6ana

Once we have the raw data clustered, we can run analysis codes on them. For example, e14g6ana.ccreconstruct KL → 3π0 which most often decays to 6 photons. Here is a modified version of thee14g6ana.cc:

1 #inc lude ” TF i l e . h”2 #inc lude ”TChain . h”3 #inc lude ”gnana/E14GNAnaFunction . h”4 #inc lude ”gnana/E14GNAnaDataContainer . h”5 #inc lude ”gamma/GammaFinder . h”6 #inc lude ” rec2g /Rec2g . h”7 #inc lude ”CLHEP/Vecto r /ThreeVector . h”8 #inc lude ” k long /RecKlong . h”9 bool u s e r r e c ( s t d : : l i s t <Gamma> const &g l i s t , s t d : : v e c to r<Klong> &klVec ) ;

10 void u s e r c u t ( E14GNAnaDataContainer &data , s t d : : v e c to r<Klong> const &klVec ) ;1112 i n t main ( i n t argc , char ∗∗ argv ){13 // read argument14 i f ( a rgc < 3){15 s td : : cout<<” arg e r r :<< \n usage : b i n / e14g2ana i npu t output ”<<s t d : : e nd l16 <<” i npu t f i l e shou l d be the output o f e14gnana/ e 1 4 c l u s t e r i n g . ”17 <<s t d : : e nd l ;18 return 0 ;19 }202122 i n t n F i l e s=argc −2;2324 s td : : s t r i n g ∗ i fname = new s t d : : s t r i n g [ n F i l e s ] ;25 s td : : s t r i n g ofname = argv [ argc −1] ;26 f o r ( i n t i =0; i<n F i l e s ; i++) i fname [ i ]= argv [ i +1] ;

19

Page 21: e 14 Quick Start Guide

2728293031 E14GNAnaDataContainer data ;32 // s e t i n pu t f i l e33 TChain ∗ i npu tT r e e = new TChain ( ”T” ) ;34 // s e t v a r i a b l e s35 double BHPVEneTotal , CBAREneTotal , FBAREneTotal , CVEneTotal ;36 double BHCVEneTotal , LCVEneTotal , OEVEneTotal , BCVEneTotal ;37 double NCCEneTotal , CC03EneTotal , CC04EneTotal , CC05EneTotal , CC06EneTotal ;38 i n t DetNumber [ 1 3 ] ;39 double DetEne [ 1 3 ] [ 2 0 0 ] ;40 // s e t the a r r a y o f p o i n t e r s to po i n t to the add r e s s o f the t o t a l ene rgy v a r i a b l e s41 double ∗DetEneTotal [13]={&BHPVEneTotal , &CBAREneTotal ,42 &FBAREneTotal , &CVEneTotal , &BHCVEneTotal , &LCVEneTotal ,43 &OEVEneTotal , &BCVEneTotal , &NCCEneTotal , &CC03EneTotal ,44 &CC04EneTotal , &CC05EneTotal , &CC06EneTotal } ;45 double COER;46 short TrigTagMismatch ;47 unsigned i n t RawTrigBit , S c a l e dT r i gB i t ;4849 s td : : s t r i n g DetName [13]={ ”BHPV” , ”CBAR” , ”FBAR” , ”CV” , ”BHCV” ,50 ”LCV” , ”OEV” , ”BCV” , ”NCC” , ”CC03” ,51 ”CC04” , ”CC05” , ”CC06” } ;5253 f o r ( i n t i =0; i <13; i ++){54 inputTree−>55 SetBranchAddress ( Form( ”%sNumber” ,DetName [ i ] . c s t r ( ) ) , &DetNumber [ i ] ) ;5657 inputTree−>58 SetBranchAddress ( Form( ”%sEne” ,DetName [ i ] . c s t r ( ) ) , DetEne [ i ] ) ;59 }6061 inputTree−>SetBranchAddress ( ”TrigTagMismatch” ,&TrigTagMismatch ) ;62 inputTree−>SetBranchAddress ( ”RawTrigBit ” ,&RawTrigBit ) ;63 inputTree−>SetBranchAddress ( ” S c a l e dT r i gB i t ” ,& Sc a l e dT r i gB i t ) ;6465 o f s t r eam i n p u t F i l e L i s t ( ” e 1 4 g 2 I n p u t F i l e s . t x t ” , s t d : : i o s : : t r unc ) ;66 f o r ( i n t i =0; i<n F i l e s ; i ++){67 inputTree−>Add( i fname [ i ] . c s t r ( ) ) ;68 i n p u t F i l e L i s t <<i fname [ i ]<< s t d : : e nd l ;69 }70 i n p u t F i l e L i s t . c l o s e ( ) ;7172 data . s e tBranchAddre s s ( i npu tTr e e ) ;7374 // s e t output f i l e75 TF i l e ∗ o u t p u t F i l e = new TF i l e ( ofname . c s t r ( ) , ”RECREATE” ) ;76 TTree ∗ outputTree = new TTree ( ”Tree ” , ” output from e14g2ana” ) ;77 s td : : cout<<” output f i l e : ”<<ofname<<s t d : : e nd l ;78 data . branchOfKlong ( outputTree ) ;79808182 outputTree−>Branch ( ”TrigTagMismatch” ,&TrigTagMismatch , ”TrigTagMismatch/S” ) ;83 outputTree−>Branch ( ”RawTrigBit ” ,&RawTrigBit , ”RawTrigBit / i ” ) ;84 outputTree−>Branch ( ” S c a l e dT r i gB i t ” ,& Sca l e dT r i gB i t , ” S c a l e dT r i gB i t / i ” ) ;85

20

Page 22: e 14 Quick Start Guide

86 outputTree−>Branch ( ”FBAREneTotal” , &FBAREneTotal , ”FBAREneTotal/D” ) ;87 outputTree−>Branch ( ”CBAREneTotal” , &CBAREneTotal , ”CBAREneTotal/D” ) ;88 outputTree−>Branch ( ”CVEneTotal ” , &CVEneTotal , ”CVEneTotal /D” ) ;89 outputTree−>Branch ( ”BHPVEneTotal” , &BHPVEneTotal , ”BHPVEneTotal/D” ) ;90 outputTree−>Branch ( ”BHCVEneTotal” , &BHCVEneTotal , ”BHCVEneTotal/D” ) ;91 outputTree−>Branch ( ”LCVEneTotal ” , &LCVEneTotal , ”LCVEneTotal /D” ) ;92 outputTree−>Branch ( ”OEVEneTotal” , &OEVEneTotal , ”OEVEneTotal/D” ) ;93 outputTree−>Branch ( ”NCCEneTotal” , &NCCEneTotal , ”NCCEneTotal/D” ) ;94 outputTree−>Branch ( ”BCVEneTotal” , &BCVEneTotal , ”BCVEneTotal/D” ) ;95 outputTree−>Branch ( ”CC03EneTotal ” , &CC03EneTotal , ”CC03EneTotal /D” ) ;96 outputTree−>Branch ( ”CC04EneTotal ” , &CC04EneTotal , ”CC04EneTotal /D” ) ;97 outputTree−>Branch ( ”CC05EneTotal ” , &CC05EneTotal , ”CC05EneTotal /D” ) ;98 outputTree−>Branch ( ”CC06EneTotal ” , &CC06EneTotal , ”CC06EneTotal /D” ) ;99100 outputTree−>Branch ( ”COER” ,&COER, ”COER/D” ) ;101102 s td : : cout<<” t r e e S e t ”<<s t d : : e nd l ;103104105106107108109110 //111 GammaFinder gF i nde r ;112113 // loop a n a l y s i s114115 i n t n loop = inputTree−>Ge tEn t r i e s ( ) ;116 s td : : cout<<” s t a r t l oop a n a l y s i s ”<<s t d : : e nd l ;117 s td : : cout<<”# of e n t r y : ”<<nloop<<s t d : : e nd l ;118119 f o r ( i n t i e v t =0; i e v t<n loop ; i e v t++ ){120 i f ( i e v t%(n loop/1000)==0&&nloop >100)121 s td : : cout<<( f l o a t ) i e v t /( n loop /100.)<<”%”<<s t d : : e nd l ;122123 // read data124 inputTree−>GetEntry ( i e v t ) ;125 s td : : l i s t <C lu s t e r> c l i s t ;126 data . getData ( c l i s t ) ;127128 // F i l l v e to129 f o r ( i n t i =0; i <13; i ++){130 ∗DetEneTotal [ i ]=0;131 i n t N=DetNumber [ i ] ;132 f o r ( i n t j =0; j<N; j++){133 ∗DetEneTotal [ i ]+=DetEne [ i ] [ j ] ;134 }135 }136137138139 // gamma f i n d i n g140 s td : : l i s t <Gamma> g l i s t ;141 gF inde r . findGamma ( c l i s t , g l i s t ) ;142143 // k l r e c o n s t r u n c t i o n144 i f ( g l i s t . s i z e ( ) != 6 ) continue ;

21

Page 23: e 14 Quick Start Guide

145 s td : : v e c to r<Klong> k lVec ;146 i f ( ! u s e r r e c ( g l i s t , k lVec ) ) continue ; ;147 // cu t s148 u s e r c u t ( data , k lVec ) ;149150 //COER151 double coex=0, coey=0, e=0;152 f o r ( s t d : : l i s t <Gamma> : : i t e r a t o r i t=g l i s t . b eg i n ( ) ; i t != g l i s t . end ();++ i t ){153 coex+=(i t−>coex ( ) ) ∗ ( i t−>edep ( ) ) ;154 coey+=(i t−>coey ( ) ) ∗ ( i t−>edep ( ) ) ;155 e+=(i t−>edep ( ) ) ;156 }157 coex=coex /e ;158 coey=coey /e ;159160 COER=sq r t ( coex ∗ coex+coey ∗ coey ) ;161162163 data . se tData ( k lVec ) ;164 outputTree−>F i l l ( ) ;165 data . event ID++;166 }167168 outputTree−>Write ( ) ;169 ou t pu tF i l e−>C lo s e ( ) ;170 }

Line 1 to 8: The e14g6ana.cc is a more involved codes, with the inclusion of an arrayof analysis and container classes such as E14GNAnaDataContainer, E14GNAnaFunction,GammaFinder, Rec2g and RecKlong

Line 22 to 26 and Line 64 to 67: I modified the arguments so that the executable could analyzearbitrary number of input files by attaching them to TChain inputTree.

Line 31: Declaring E14GNAnaDataContainer data.

Line 33 to 49: Declaring variables to map the total energy data from veto detectors. Line 39creates an array of pointers to the address of the veto energy variables.

Line 53 to 59: Map those pointers to the correct branch address, automated through the for loopand the Form function.

Line 78: Creating the relevant TBranch objects for Klong in the outputTree.

Line 82 to 100: Here I set additional branches to outputTree.

Line 119: Starting analysis for each clustered event

1. L124: Get the ievt entry of the tree, fill data members of data mapped to the tree.

2. L125: Declare a list (clist) to hold Cluster objects

3. L126: The getData function from E14GNAnaDataContainer creates a Clusterinside its own scope and invokes getCluster to save cluster info to the Cluster, whichis then stored into the list.

4. L129-135: Modifies the veto variables pointed to by the pointers to reflect the total energyin each veto detector.

22

Page 24: e 14 Quick Start Guide

5. L140: Creates a list to hold Gamma

6. L141: findGamma of GammaFinder normally uses findGammaDefault which usesan iterator to cycle through objects in clist. It saves the entire cluster into a Clusterdata member in Gamma if the total energy of the cluster is greater than a threshold (20 MeVby default). It then uses

E14GNAnaFunction::getFunction()->correctEnergy(*gam);

to calculate the actual energy of the photon taking into account of shower leakage and CsIefficiency, etc.

7. L144: If the number of photons is less than 6, the event is discarded.

8. L145: Declaring a vector to hold Klong objects

9. L146: ./src/user rec.cc contains the instruction to reconstruct KLong from the 6Gamma.

12 #inc lude ” k long /RecKlong . h”3 #inc lude ”gnana/E14GNAnaFunction . h”4 #inc lude <i o s t r eam>5 #inc lude < l i s t >678 bool u s e r r e c ( s t d : : l i s t <Gamma> const &g l i s t , s t d : : v e c to r<Klong> &klVec ){9 s t a t i c RecKlong r e cK l ;

10 //// r e c o n s t r u c t i o n11 // k lVec = r e cK l . r ecK3p i0 ( g l i s t , VERTEX FIX XYZERO) ;12 k lVec = r e cK l . r ecK3p i0 ( g l i s t ) ;13 i f ( k lVec . s i z e ()==0) {14 return f a l s e ;15 }16 //// gamma p o s i t i o n & ene rgy c o r r e c t i o n f o r ang l e dependency17 E14GNAnaFunction : : g e tFunc t i on ()−> c o r r e c t P o s i t i o n ( k lVec [ 0 ] ) ;18 E14GNAnaFunction : : g e tFunc t i on ()−> co r r e c tEne rgyWi thAng l e ( k lVec [ 0 ] ) ;19 //// re−r e c o n s t r u c t i o n wi th c o r r e c t e d gamma20 s td : : l i s t <Gamma> g l i s t 2 ;21 f o r ( s t d : : v e c to r<Pi0 > : : i t e r a t o r i t=k lVec [ 0 ] . p i 0 ( ) . beg i n ( ) ;22 i t !=k lVec [ 0 ] . p i 0 ( ) . end ( ) ; i t ++){23 g l i s t 2 . push back ( i t−>g1 ( ) ) ;24 g l i s t 2 . push back ( i t−>g2 ( ) ) ;25 }26 k lVec = r e cK l . r ecK3p i0 ( g l i s t 2 ) ;27 i f ( k lVec . s i z e ()==0) return f a l s e ;28 //// shape ch i 2 e v a l u a t i o n29 E14GNAnaFunction : : g e tFunc t i on ()−> shapeCh i2 ( k lVec [ 0 ] ) ;3031 return true ;32 }

This script defines a function of boolean type, such that if the reconstruction is unsuccessfulit will go to the next event. The RecKlong recKl contains the instruction to reoconstructKlong. At Line 12,

klVec = recKl.recK3Pi0(glist);

23

Page 25: e 14 Quick Start Guide

RecKlong::recK3pi0( const std::list<Gamma>& glist,int vtxflag, double pi0sig2cut ){

Rec2g rec2g; // pi0 reconstructionstd::list<Pi0> pi0list = rec2g.recPi0withConstM( glist );

return( recK3pi0( pi0list,vtxflag,pi0sig2cut ) );}

rec2g.recPi0withConstM( glist ); .........(1)recK3pi0( pi0list,vtxflag,pi0sig2cut ).....(2)

(1) will cycle through all pairs (15 different combinations) of gamma in the list to reconstructPi0 Z position assuming Pi0 mass.

(2) will first identify Pi0s with distinctive photon composition and reconstruct Klong fromthem. Each reconstructed Klong will have a KlongChisqZ, χ2

z calcuated.

By default only the 2 Klongs with the lowest χ2z are recorded.

10. L148: ./src/user cut.cc contains the instruction to write different cut bit to thecutcondition branch in the tree.

The remaining codes are self-evident.

24

Page 26: e 14 Quick Start Guide

Chapter 5

Simulation

5.1 Creating MC using /example/gsim4test

This is a GEANT4 based simulation codes specific to the E14 experiment. To generate a MC, allyou have to do is type:

./bin/gsim4test macrofile.mac output.root Nevent S R

where Nevent is the number of events you want to generate,S is a number corresponding to the seed for random generation,R is the run number base.

For further details please review the original gsim4 manual gsim4.pdf

5.2 Access MC output

The folder under tutorial/ in the e14 directory contains codes that illustrate how to access theMC output. Here is a sample of the various trees and their branches under a single MC file:

25

Page 27: e 14 Quick Start Guide

Figure 5.1: Objects you can find in an MC file

26

Page 28: e 14 Quick Start Guide

And here is the tutorial codes in the tutorial folder:

1 #inc lude ”GsimData/GsimEventData . h”2 #inc lude ”GsimData/ Gs imGenPar t i c l eData . h”3 #inc lude ”GsimData/GsimTrackData . h”4 #inc lude ”GsimData/Gs imDetectorEventData . h”5 #inc lude ”GsimData/Gs imDetectorHi tData . h”67 #inc lude <TROOT. h>8 #inc lude <TF i l e . h>9 #inc lude <TTree . h>

1011 #inc lude <f s t r eam>12 #inc lude <i o s t r eam>13 #inc lude <c s t d l i b >14 #inc lude <cmath>151617 i n t main ( i n t argc , char ∗∗ argv )18 {1920 i f ( a rgc !=3) {21 s td : : c e r r << ”# of arguments e r r o r . ” << s t d : : e nd l ;22 return 1 ;23 }2425 char∗ i fname = argv [ 1 ] ;26 char∗ ofname = argv [ 2 ] ;2728 GsimEventData∗ ev = new GsimEventData ( ) ;29 Gs imGenPar t i c l eData ∗ gp = new Gs imGenPar t i c l eData ( ) ;30 Gs imDetectorEventData ∗ det = new GsimDetectorEventData ( ) ;3132 // f i l e o p e n33 TF i l e ∗ t f i = new TF i l e ( i fname ) ;3435 // s e t add r e s s36 TTree∗ t r = ( TTree ∗) t f i −>Get ( ” eventTree00 ” ) ;37 t r−>SetBranchAddress ( ”Event . ” ,&ev ) ;38 t r−>SetBranchAddress ( ” GenPa r t i c l e . ” ,&gp ) ;39 t r−>SetBranchAddress ( ” det . ” ,&det ) ; // r e p l a c e ” det . ” w i th any40 // d e t e c t o r name , i . e . ”CSI . ”414243 TF i l e ∗ t f o = new TF i l e ( ofname , ”RECREATE” ) ;44 i n t i r u n ;45 i n t i e v e n t ;46 i n t maxID ;47 double maxE ;48 TTree∗ t r o = new TTree ( ” t r o ” , ” t r o ” ) ;49 t ro−>Branch ( ” i r u n ” ,& i run , ” i r u n / I ” ) ;50 t ro−>Branch ( ” i e v e n t ” ,& i e v en t , ” i e v e n t / I ” ) ;51 t ro−>Branch ( ”maxID” ,&maxID , ”maxID/ I ” ) ;52 t ro−>Branch ( ”maxE” ,&maxE , ”maxE/D” ) ;5354 I n t t nevent = I n t t ( t r−>Ge tEn t r i e s ( ) ) ; // Number o f e v en t s5556 s td : : cout << ”N ev en t s : ” << nevent << s t d : : e nd l ;57 i n t i n=i n t ( nevent /100 ) ;

27

Page 29: e 14 Quick Start Guide

58 // even t l oop s t a r t59 f o r ( I n t t j e n t r y =0; j e n t r y<nevent ; j e n t r y++) {6061 i f ( j e n t r y%i n==0) {62 s td : : cout << ( j e n t r y / i n ) << ” % p ro c e s s e d . ” << s t d : : e nd l ;63 }6465 I n t t i e n t r y = t r−>LoadTree ( j e n t r y ) ;66 i f ( i e n t r y < 0) break ;67 t r−>GetEntry ( j e n t r y ) ;6869 UShor t t run number=ev−>run number ;70 UShor t t event number=ev−>event number ;7172 i r u n=run number ;73 i e v e n t=event number ;7475 // get n h i t and p r i n t i t76 TClonesArray ∗ GPArray = gp−>b r i e f T r a c k s ;77 TClonesArray ∗ DetD ig iA r ray = det−>d i g i ;7879 i n t nGP=GPArray−>Ge tEn t r i e s ( ) ;80 i n t nDetDig i=DetDig iAr ray−>Ge tEn t r i e s ( ) ;8182 i f (nGP>1) {83 gp−>dump ( ) ;84 }8586 f o r ( I n t t iGP=0; iGP<nGP ; iGP++){87 GsimTrackData∗ aTrack = ( GsimTrackData ∗) GPArray−>At ( iGP ) ;88 }8990 maxID=−1;91 maxE=0; ;92 f o r ( I n t t iD e tD i g i =0; iDe tD ig i<nDetDig i ; iD e tD i g i++){93 GsimDigiData ∗ aD ig i = ( GsimDigiData ∗) DetDig iAr ray−>At ( iD e tD i g i ) ;94 i f ( aDig i−>energy>maxE) {95 maxE=aDig i−>ene rgy ;96 maxID=aDig i−>modID ;97 }98 }99 t ro−>F i l l ( ) ;100 }101 t ro−>Write ( ) ;102 t fo−>C lo s e ( ) ;103 t f i −>C lo s e ( ) ;104105 return 0 ;106 }

L28-30: The code declares the previously mentioned Gsim classes. L37-39: The MC outputwas generated with the Gsim data container classes, therefore we have to use the same classes toaccess the data, comparing them with fig. 5.1

L76-77: A pointer of type TClonesArray was created to get the data stored in the brief-Tracks data member of GsimGenParticleData, this TClonesArray has the same structureas GsimTrackData

28

Page 30: e 14 Quick Start Guide

GsimDetectorEventData also contains a TClonesArray object called “digi” that storesdetector data.

L87: GsimTrackData* aTrack was created to read the iGPth entry stored in the TClonesArray,which is part of GsimGenParticleData. L93: A similar thing happens for GsimDigiDatathat is part of GsimDetectorEventData

29