GGS(GenericGEANT4Simulation)Software  2.7.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 
14 GGSTHadrIntReader::GGSTHadrIntReader() : _inelastic(NULL), _quasiElastic(NULL), _hadrIntChain(NULL) {}
15 
16 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
17 
19  delete _quasiElastic;
20  delete _inelastic;
21 }
22 
23 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
24 
25 bool GGSTHadrIntReader::SetChain(TChain *hadrIntChain) {
26 
27  _hadrIntChain = hadrIntChain;
28  if (_hadrIntChain->SetBranchAddress("inelastic", &_inelastic) == 0 &&
29  _hadrIntChain->SetBranchAddress("quasiElastic", &_quasiElastic) == 0) {
30  return true;
31  } else
32  return false;
33 }
34 
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
36 
37 void GGSTHadrIntReader::GetEntry(Long64_t entry) {
38  if (entry != _hadrIntChain->GetEntries()) {
39  _hadrIntChain->GetEntry(entry);
40  }
41 }
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
45 
46  GGSTHadrIntInfo *interaction;
47  for (int i = 0; i < _inelastic->GetEntries(); i++) {
48  interaction = (GGSTHadrIntInfo *)(_inelastic->At(i));
49  if (interaction->originalTrackID == trackID)
50  return interaction;
51  }
52 
53  return NULL;
54 }
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
57 
59 
60  Int_t nInt = 0;
61  for (int i = 0; i < _quasiElastic->GetEntries(); i++) {
62  if (((GGSTHadrIntInfo *)(_quasiElastic->At(i)))->originalTrackID == trackID)
63  nInt++;
64  }
65 
66  return nInt;
67 }
68 
69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
70 
72 
73  Int_t nInt = 0;
74  GGSTHadrIntInfo *interaction;
75  for (int i = 0; i < _quasiElastic->GetEntries(); i++) {
76  interaction = (GGSTHadrIntInfo *)(_quasiElastic->At(i));
77  if (interaction->originalTrackID == trackID) {
78  if (nInt == nQE)
79  return interaction;
80  else
81  nInt++;
82  }
83  }
84 
85  return NULL;
86 }
87 
88 //....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.