36 #include <Pythia8/Pythia.h>
41 #include "TLorentzVector.h"
43 #if PYTHIA_VERSION_INTEGER < 8304
70 std::map<int, TH1D*>
h_p;
71 std::map<int, TH1D*>
h_v;
104 pythia =
new Pythia8::Pythia();
119 for (
size_t i = 0;
i <
pids.size(); ++
i) {
123 if (!pdt.isParticle(pid)) {
124 std::cout <<
"ERROR: BAD PARTICLE, pythia is not aware of pid " << pid << std::endl;
130 double m0 = pd->m0();
131 double w = pd->mWidth();
134 mmin = m0 - m0 / 1000.;
135 mmax = m0 + m0 / 1000.;
140 std::stringstream strstr;
141 strstr <<
"mass_" << pid;
142 h_mass[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, mmin, mmax);
150 h_mass_ref[pid]->SetBinContent(
b, TMath::BreitWigner(_val, m0,
w));
156 strstr <<
"p_" << pid;
157 h_p[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 20);
161 strstr <<
"v_" << pid;
162 h_v[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 1.);
165 double ctau0 = pd->tau0() / 10.;
167 strstr <<
"plt_" << pid;
168 h_plt[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0,
std::min(5. * ctau0, 500.));
169 h_plt_ref[pid] = (TH1D*)(
h_plt[pid]->Clone(strstr.str().c_str()));
171 for (
int b = 1;
b <=
h_plt_ref[pid]->GetNbinsX(); ++
b) {
172 double _val =
h_plt_ref[pid]->GetBinCenter(
b);
173 h_plt_ref[pid]->SetBinContent(
b, TMath::Exp(-_val / ctau0));
178 strstr <<
"br_" << pid;
179 h_br[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 0, 0, 0);
180 h_br[pid]->SetCanExtend(TH1::kAllAxes);
181 h_br_ref[pid] = (TH1D*)(
h_br[pid]->Clone(strstr.str().c_str()));
184 for (
int d = 0;
d < pd->sizeChannels(); ++
d) {
185 Pythia8::DecayChannel& channel = pd->channel(
d);
186 std::vector<int>
prod;
187 for (
int p = 0;
p < channel.multiplicity(); ++
p) {
188 int pId =
abs(channel.product(
p));
191 (pId > 10 && pId != 12 && pId != 14 && pId != 16 && pId != 18 && pId != 21 && (pId < 23 || pId > 40) &&
192 (pId < 81 || pId > 100) && pId != 2101 && pId != 3101 && pId != 3201 && pId != 1103 && pId != 2103 &&
193 pId != 2203 && pId != 3103 && pId != 3203 && pId != 3303);
195 prod.push_back(
abs(channel.product(
p)));
199 for (
size_t p = 0;
p <
prod.size(); ++
p) {
200 strstr <<
"_" <<
prod[
p];
205 h_br[pid]->SetEntries(0);
211 strstr <<
"originVertexRho_" << pid;
212 h_originVertexRho[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
214 strstr <<
"originVertexZ_" << pid;
215 h_originVertexZ[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
217 strstr <<
"decayVertexRho_" << pid;
218 h_decayVertexRho[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
220 strstr <<
"decayVertexZ_" << pid;
221 h_decayVertexZ[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
228 TFile*
f = TFile::Open(
outputFile.c_str(),
"RECREATE");
230 f->mkdir(
"observed");
231 f->mkdir(
"prediction");
232 for (
size_t i = 0;
i <
pids.size(); ++
i) {
261 iEvent.getByLabel(
"famosSimHits", simtracks);
264 iEvent.getByLabel(
"famosSimHits", simvertices);
269 std::map<size_t, std::vector<size_t> > childMap;
270 std::map<size_t, int> parentMap;
271 for (
size_t j = 0;
j < simtracks->size();
j++) {
272 childMap[
j] = std::vector<size_t>();
277 for (
size_t j = 0;
j < simtracks->size();
j++) {
278 size_t childIndex =
j;
280 if (
child.noVertex())
285 size_t parentIndex =
vertex.parentIndex();
286 childMap[parentIndex].push_back(childIndex);
287 parentMap[childIndex] =
int(parentIndex);
290 for (
size_t j = 0;
j < simtracks->size();
j++) {
309 if (!childMap[
j].
empty()) {
311 const SimVertex& decayVertex = simvertices->at(
child.vertIndex());
317 for (
std::map<
size_t, std::vector<size_t> >::iterator it = childMap.begin(); it != childMap.end(); ++it) {
319 size_t parentIndex = it->first;
322 std::vector<size_t>& childIndices = it->second;
323 if (childIndices.empty())
330 const SimTrack& child0 = simtracks->at(childIndices[0]);
333 TLorentzVector lv_origin_vertex(origin_vertex.
position().X(),
337 TLorentzVector lv_decay_vertex(decay_vertex.
position().X(),
341 TLorentzVector lv_dist = lv_decay_vertex - lv_origin_vertex;
342 TLorentzVector lv_parent(
344 TVector3
boost = lv_parent.BoostVector();
345 lv_dist.Boost(-
boost);
347 double plt = lv_dist.T();
348 h_plt[pid]->Fill(plt);
351 std::vector<int>
prod;
352 for (
size_t d = 0;
d < childIndices.size(); ++
d) {
353 prod.push_back(
abs(simtracks->at(childIndices[
d]).type()));
356 std::stringstream strstr;
357 for (
size_t p = 0;
p <
prod.size(); ++
p) {
358 strstr <<
"_" <<
prod[
p];