36 #include <Pythia8/Pythia.h> 41 #include "TLorentzVector.h" 65 std::map<int, TH1D*>
h_p;
66 std::map<int, TH1D*>
h_v;
99 pythia =
new Pythia8::Pythia();
114 for (
size_t i = 0;
i <
pids.size(); ++
i) {
118 if (!pdt.isParticle(pid)) {
119 std::cout <<
"ERROR: BAD PARTICLE, pythia is not aware of pid " << pid << std::endl;
122 Pythia8::ParticleDataEntry* pd = pdt.particleDataEntryPtr(pid);
125 double m0 = pd->m0();
126 double w = pd->mWidth();
129 mmin = m0 - m0 / 1000.;
130 mmax = m0 + m0 / 1000.;
135 std::stringstream strstr;
136 strstr <<
"mass_" << pid;
137 h_mass[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, mmin, mmax);
139 h_mass_ref[pid]->SetTitle(h_mass_ref[pid]->GetName());
141 h_mass_ref[pid]->Fill(m0);
143 for (
int b = 1;
b <= h_mass_ref[pid]->GetNbinsX(); ++
b) {
144 double _val = h_mass_ref[pid]->GetBinCenter(
b);
145 h_mass_ref[pid]->SetBinContent(
b, TMath::BreitWigner(_val, m0, w));
151 strstr <<
"p_" << pid;
152 h_p[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 20);
156 strstr <<
"v_" << pid;
157 h_v[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 1.);
160 double ctau0 = pd->tau0() / 10.;
162 strstr <<
"plt_" << pid;
163 h_plt[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0,
std::min(5. * ctau0, 500.));
164 h_plt_ref[pid] = (TH1D*)(
h_plt[pid]->Clone(strstr.str().c_str()));
165 h_plt_ref[pid]->SetTitle(h_plt_ref[pid]->GetName());
166 for (
int b = 1;
b <= h_plt_ref[pid]->GetNbinsX(); ++
b) {
167 double _val = h_plt_ref[pid]->GetBinCenter(
b);
168 h_plt_ref[pid]->SetBinContent(
b, TMath::Exp(-_val / ctau0));
173 strstr <<
"br_" << pid;
174 h_br[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 0, 0, 0);
175 h_br[pid]->SetCanExtend(TH1::kAllAxes);
176 h_br_ref[pid] = (TH1D*)(
h_br[pid]->Clone(strstr.str().c_str()));
179 for (
int d = 0;
d < pd->sizeChannels(); ++
d) {
180 Pythia8::DecayChannel& channel = pd->channel(
d);
181 std::vector<int>
prod;
182 for (
int p = 0;
p < channel.multiplicity(); ++
p) {
183 int pId =
abs(channel.product(
p));
186 (pId > 10 && pId != 12 && pId != 14 && pId != 16 && pId != 18 && pId != 21 && (pId < 23 || pId > 40) &&
187 (pId < 81 || pId > 100) && pId != 2101 && pId != 3101 && pId != 3201 && pId != 1103 && pId != 2103 &&
188 pId != 2203 && pId != 3103 && pId != 3203 && pId != 3303);
190 prod.push_back(
abs(channel.product(
p)));
192 std::sort(prod.begin(), prod.end());
194 for (
size_t p = 0;
p < prod.size(); ++
p) {
195 strstr <<
"_" << prod[
p];
198 h_br[pid]->Fill(label.c_str(), 0.);
199 h_br_ref[pid]->Fill(label.c_str(), channel.bRatio());
200 h_br[pid]->SetEntries(0);
206 strstr <<
"originVertexRho_" << pid;
207 h_originVertexRho[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
209 strstr <<
"originVertexZ_" << pid;
210 h_originVertexZ[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
212 strstr <<
"decayVertexRho_" << pid;
213 h_decayVertexRho[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 200);
215 strstr <<
"decayVertexZ_" << pid;
216 h_decayVertexZ[pid] =
new TH1D(strstr.str().c_str(), strstr.str().c_str(), 100, 0, 400);
223 TFile*
f = TFile::Open(
outputFile.c_str(),
"RECREATE");
225 f->mkdir(
"observed");
226 f->mkdir(
"prediction");
227 for (
size_t i = 0;
i <
pids.size(); ++
i) {
259 iEvent.
getByLabel(
"famosSimHits", simvertices);
264 std::map<size_t, std::vector<size_t> > childMap;
265 std::map<size_t, int> parentMap;
266 for (
size_t j = 0;
j < simtracks->size();
j++) {
267 childMap[
j] = std::vector<size_t>();
272 for (
size_t j = 0;
j < simtracks->size();
j++) {
273 size_t childIndex =
j;
281 childMap[parentIndex].push_back(childIndex);
282 parentMap[childIndex] =
int(parentIndex);
285 for (
size_t j = 0;
j < simtracks->size();
j++) {
304 if (!childMap[
j].
empty()) {
312 for (
std::map<
size_t, std::vector<size_t> >::iterator it = childMap.begin(); it != childMap.end(); ++it) {
314 size_t parentIndex = it->first;
317 std::vector<size_t>& childIndices = it->second;
318 if (childIndices.empty())
325 const SimTrack& child0 = simtracks->at(childIndices[0]);
328 TLorentzVector lv_origin_vertex(origin_vertex.
position().X(),
332 TLorentzVector lv_decay_vertex(decay_vertex.
position().X(),
336 TLorentzVector lv_dist = lv_decay_vertex - lv_origin_vertex;
337 TLorentzVector lv_parent(
339 TVector3
boost = lv_parent.BoostVector();
340 lv_dist.Boost(-boost);
341 h_v[pid]->Fill(boost.Mag());
342 double plt = lv_dist.T();
343 h_plt[pid]->Fill(plt);
346 std::vector<int>
prod;
347 for (
size_t d = 0;
d < childIndices.size(); ++
d) {
348 prod.push_back(
abs(simtracks->at(childIndices[
d]).type()));
350 std::sort(prod.begin(), prod.end());
351 std::stringstream strstr;
352 for (
size_t p = 0;
p < prod.size(); ++
p) {
353 strstr <<
"_" << prod[
p];
358 h_br[pid]->Fill(label.c_str(), 1.);
359 h_br_ref[pid]->Fill(label.c_str(), 0.);
T getParameter(std::string const &) const
std::map< int, TH1D * > h_plt
std::map< int, TH1D * > h_originVertexRho
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::map< int, TH1D * > h_plt_ref
std::map< int, TH1D * > h_br_ref
std::map< int, TH1D * > h_br
void analyze(const edm::Event &, const edm::EventSetup &) override
std::map< int, TH1D * > h_originVertexZ
std::map< int, TH1D * > h_p
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
std::map< int, TH1D * > h_mass
Abs< T >::type abs(const T &t)
const math::XYZTLorentzVectorD & position() const
HepPDT::ParticleData ParticleData
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::map< int, TH1D * > h_v
int vertIndex() const
index of the vertex in the Event container (-1 if no vertex)
std::map< int, std::vector< std::string > > knownDecayModes
std::map< int, TH1D * > h_decayVertexZ
TestPythiaDecays(const edm::ParameterSet &)
std::map< int, TH1D * > h_decayVertexRho
int type() const
particle type (HEP PDT convension)
~TestPythiaDecays() override
const math::XYZTLorentzVectorD & momentum() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::map< int, TH1D * > h_mass_ref