GGS(GenericGEANT4Simulation)Software  2.6.0
 All Data Structures Namespaces Files Functions Variables Typedefs Macros
GGSTHadrIntReader.cpp
Go to the documentation of this file.
1 /*
2  * GGSTHadrIntReader.cpp
3  *
4  * Created on: 25 Aug 2011
5  * Author: Nicola Mori
6  */
7 
11 
12 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
13 
15  _inelastic(NULL), _quasiElastic(NULL), _hadrIntChain(NULL) {
16 
17 }
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
20 
22  delete _quasiElastic;
23  delete _inelastic;
24 }
25 
26 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
27 
28 bool GGSTHadrIntReader::SetChain(TChain *hadrIntChain) {
29 
30  _hadrIntChain = hadrIntChain;
31  if (_hadrIntChain->SetBranchAddress("inelastic", &_inelastic) == 0
32  && _hadrIntChain->SetBranchAddress("quasiElastic", &_quasiElastic) == 0) {
33  return true;
34  }
35  else
36  return false;
37 
38 }
39 
40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
41 
42 void GGSTHadrIntReader::GetEntry(Long64_t entry) {
43  if (entry != _hadrIntChain->GetEntries()) {
44  _hadrIntChain->GetEntry(entry);
45  }
46 }
47 
48 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
50 
51  GGSTHadrIntInfo* interaction;
52  for (int i = 0; i < _inelastic->GetEntries(); i++) {
53  interaction = (GGSTHadrIntInfo*) (_inelastic->At(i));
54  if (interaction->originalTrackID == trackID)
55  return interaction;
56  }
57 
58  return NULL;
59 }
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
62 
64 
65  Int_t nInt = 0;
66  for (int i = 0; i < _quasiElastic->GetEntries(); i++) {
67  if (((GGSTHadrIntInfo*) (_quasiElastic->At(i)))->originalTrackID == trackID)
68  nInt++;
69  }
70 
71  return nInt;
72 }
73 
74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
75 
77 
78  Int_t nInt = 0;
79  GGSTHadrIntInfo* interaction;
80  for (int i = 0; i < _quasiElastic->GetEntries(); i++) {
81  interaction = (GGSTHadrIntInfo*) (_quasiElastic->At(i));
82  if (interaction->originalTrackID == trackID) {
83  if (nInt == nQE)
84  return interaction;
85  else
86  nInt++;
87  }
88  }
89 
90  return NULL;
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
Int_t originalTrackID
Track ID of the original primary particle.
Int_t GetNQuasiElastic(Int_t trackID=1)
Retrieves the number of quasi-elastic interactions for the given primary.
GGSTHadrIntInfo * GetQuasiElastic(Int_t nQE, Int_t trackID=1)
Retrieves a quasi-elastic interaction for the given primary.
void GetEntry(Long64_t entry)
A simple class to carry informations about hadronic interactions.
bool SetChain(TChain *hadrIntChain)
Sets the chain.
GGSTHadrIntReader()
Constructor.
~GGSTHadrIntReader()
Destructor.
GGSTHadrIntInfo * GetInelastic(Int_t trackID=1)
Retrieves the inelastic interaction for the given primary.