-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathGeneratorEMCocktail.C
More file actions
179 lines (175 loc) · 6.47 KB
/
GeneratorEMCocktail.C
File metadata and controls
179 lines (175 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
int External()
{
std::string path{"o2sim_Kine.root"};
TFile file(path.c_str(), "READ");
if (file.IsZombie()) {
std::cerr << "Cannot open ROOT file " << path << "\n";
return 1;
}
auto tree = (TTree*)file.Get("o2sim");
std::vector<o2::MCTrack>* tracks{};
tree->SetBranchAddress("MCTrack", &tracks);
int nElectrons = 0;
int nPositrons = 0;
int nPions = 0;
int nEtas = 0;
int nEtaPrimes = 0;
int nRhos = 0;
int nPhis = 0;
int nOmegas = 0;
int nJPsis = 0;
int nPhotons = 0;
int nElectronsFromPion = 0;
int nElectronsFromEta = 0;
int nElectronsFromEtaPrime = 0;
int nElectronsFromOmega = 0;
int nElectronsFromRho = 0;
int nElectronsFromPhi = 0;
int nElectronsFromJPsi = 0;
int nLeptonsToBeDone = 0;
auto nEvents = tree->GetEntries();
for (int i = 0; i < nEvents; i++) {
tree->GetEntry(i);
for (auto& track : *tracks) {
bool hasMother = track.getMotherTrackId()>-1;
auto pdg = track.GetPdgCode();
switch (pdg){
case 11:
nElectrons++;
if (track.getToBeDone()){
nLeptonsToBeDone++;
}
break;
case -11:
nPositrons++;
if (track.getToBeDone()){
nLeptonsToBeDone++;
}
break;
case 111:
if (!hasMother)
nPions++;
break;
case 221:
if (!hasMother)
nEtas++;
break;
case 331:
if (!hasMother)
nEtaPrimes++;
break;
case 113:
if (!hasMother)
nRhos++;
break;
case 223:
if (!hasMother)
nOmegas++;
break;
case 333:
if (!hasMother)
nPhis++;
break;
case 443:
if (!hasMother)
nJPsis++;
break;
case 22:
nPhotons++;
}
if (pdg == 11){
int imother = track.getMotherTrackId();
if (imother > -1) {
auto mother = (*tracks)[imother];
int mpdg = mother.GetPdgCode();
switch (mpdg){
case 111:
nElectronsFromPion++;
break;
case 221:
nElectronsFromEta++;
break;
case 331:
nElectronsFromEtaPrime++;
break;
case 113:
nElectronsFromRho++;
break;
case 223:
nElectronsFromOmega++;
break;
case 333:
nElectronsFromPhi++;
break;
case 443:
nElectronsFromJPsi++;
break;
default:
std::cout << "Found electron with mother pdg " << mpdg << "\n";
}
} else {
std::cerr << "Found electron with no mother" << "\n";
return 1;
}
}
}
}
int nMothers = nPions+nEtas+nEtaPrimes+nRhos+nOmegas+nPhis+nJPsis;
std::cout << "#Events: " << nEvents << "\n"
<< "#Electrons: " << nElectrons << "\n"
<< "#Positrons: " << nPositrons << "\n"
<< "#Leptons: " << nElectrons+nPositrons << ", #LeptonsToDone: " << nLeptonsToBeDone << "\n"
<< "#Photons: " << nPhotons << "\n"
<< "#Pions: " << nPions << ", #ElectronsFromPion: " << nElectronsFromPion << "\n"
<< "#Etas: " << nEtas << ", #ElectronsFromEta: " << nElectronsFromEta << "\n"
<< "#EtaPrimes: " << nEtaPrimes << ", #ElectronsFromEtaPrime: " << nElectronsFromEtaPrime << "\n"
<< "#Rhos: " << nRhos << ", #ElectronsFromRho: " << nElectronsFromRho << "\n"
<< "#Omegas: " << nOmegas << ", #ElectronsFromOmega: " << nElectronsFromOmega << "\n"
<< "#Phis: " << nPhis << ", #ElectronsFromPhi: " << nElectronsFromPhi << "\n"
<< "#JPsis: " << nJPsis << ", #ElectronsFromJPsi: " << nElectronsFromJPsi << "\n";
if (nElectrons == 0) {
std::cerr << "No electrons found\n";
return 1;
}
if (nElectrons != nPositrons) {
std::cerr << "Number of electrons should match number of positrons\n";
return 1;
}
if (nLeptonsToBeDone != nElectrons+nPositrons) {
std::cerr << "The number of leptons should be the same as the number of leptons which should be transported.\n";
return 1;
}
if (nMothers < nEvents) {
std::cerr << "The number of mother particles (pi0, eta, etaprime, rho, omega, phi, JPsi) must be at least the number of events\n";
return 1;
}
if (nElectronsFromPion < nPions) {
std::cerr << "Number of of electrons from pions has to be at least the number of pions\n";
return 1;
}
if (nElectronsFromEta < nEtas) {
std::cerr << "Number of of electrons from etas has to be at least the number of etas\n";
return 1;
}
if (nElectronsFromEtaPrime < nEtaPrimes) {
std::cerr << "Number of of electrons from etaprimes has to be at least the number of etaprimes\n";
return 1;
}
if (nElectronsFromRho < nRhos) {
std::cerr << "Number of of electrons from rhos has to be at least the number of rhos\n";
return 1;
}
if (nElectronsFromOmega < nOmegas) {
std::cerr << "Number of of electrons from omegas has to be at least the number of omegas\n";
return 1;
}
if (nElectronsFromPhi < nPhis) {
std::cerr << "Number of of electrons from phis has to be at least the number of phis\n";
return 1;
}
if (nElectronsFromJPsi < nJPsis) {
std::cerr << "Number of of electrons from JPsis has to be at least the number of JPsis\n";
return 1;
}
return 0;
}