4 void SortEvent_DefaultHEPMC(HepMC::GenEvent *event,
HEP::Event &OutEvt,
int npileups, std::vector<HEP::PileupEvent*> &pileups,
double &Rjet, std::mt19937 &engine){
6 fastjet::JetDefinition jetDef(fastjet::antikt_algorithm, Rjet);
7 std::vector <HEP::Jet*> outjets;
9 std::vector <fastjet::PseudoJet> inclusiveJets, jets;
10 std::vector <fastjet::PseudoJet> pileupJets, pJInputs;
12 std::vector <fastjet::PseudoJet> fjInputs, bquark_momenta;
16 bquark_momenta.resize(0);
18 HepMC::GenEvent::particle_iterator p =
event->particles_begin();
22 while( p != event->particles_end())
25 int pid=(*p)->pdg_id();
31 HEP::Particle* newpart =
new HEP::Particle((*p)->momentum().px(),(*p)->momentum().py(),(*p)->momentum().pz(),(*p)->momentum().e(),pid);
34 if ( (*p)->production_vertex() )
37 HepMC::FourVector pos = (*p)->production_vertex()->position();
38 if (pos.rho() > 0.0001)
41 if((pos.perp() > 12e3) || (abs(pos.z()) > 23e3 )) { p++;
delete newpart;
continue;}
42 newpart->set_prod(
HEP::P4(pos.x(),pos.y(),pos.z(),pos.t()));
46 if(PDG::isHadron(pid))
49 int pcharge=PDG::get3Q(pid);
56 newpart->set_3Q(pcharge);
57 OutEvt.add_charged_hadron(newpart);
61 OutEvt.add_neutral_hadron((*p)->momentum().px(),(*p)->momentum().py(),(*p)->momentum().pz(),(*p)->momentum().e());
75 if((apid == 11) || (apid == 13))
101 newpart->set_3Q(PDG::get3Q(pid));
109 if( pid == 12 || pid == 14 || pid == 16 || pid == 18 )
122 if((pid > 1000000) && (pid < 9000000))
128 HepMC::FourVector v4((*p)->momentum());
132 fastjet::PseudoJet particleTemp(v4.px(),v4.py(),v4.pz(),v4.e());
135 fjInputs.push_back(particleTemp);
147 if(!((*p)->end_vertex())) { p++;
continue;}
152 HEP::Particle* newpart =
new HEP::Particle((*p)->momentum().px(),(*p)->momentum().py(),(*p)->momentum().pz(),(*p)->momentum().e(),pid);
153 HepMC::FourVector pos = (*p)->production_vertex()->position();
154 newpart->set_prod(
HEP::P4(pos.x(),pos.y(),pos.z(),pos.t()));
155 HepMC::FourVector dec = (*p)->end_vertex()->position();
156 newpart->set_decay(
HEP::P4(dec.x(),dec.y(),dec.z(),dec.t()));
157 newpart->set_3Q(PDG::get3Q(pid));
163 if(isMetaStableHadron(*p,event))
165 HEP::Particle* newpart =
new HEP::Particle((*p)->momentum().px(),(*p)->momentum().py(),(*p)->momentum().pz(),(*p)->momentum().e(),pid);
166 HepMC::FourVector pos = (*p)->production_vertex()->position();
167 newpart->set_prod(
HEP::P4(pos.x(),pos.y(),pos.z(),pos.t()));
168 HepMC::FourVector dec = (*p)->end_vertex()->position();
170 newpart->set_decay(
HEP::P4(dec.x(),dec.y(),dec.z(),dec.t()));
171 int ch = PDG::get3Q(pid);
177 OutEvt.add_charged_hadron(newpart);
246 fastjet::ClusterSequence clustSeq(fjInputs, jetDef);
247 inclusiveJets = clustSeq.inclusive_jets(1.0);
248 jets = sorted_by_pt(inclusiveJets);
250 std::uniform_int_distribution<> rd_el(0,pileups.size()-1);
252 static std::normal_distribution<double> zdist(0,53.0);
253 static std::normal_distribution<double> tdist(0,160e-12);
259 for(
int jp=0; jp< npileups; jp++)
261 int pileup_number=rd_el(engine);
267 double dz=zdist(engine);
268 double dt=tdist(engine);
269 OutEvt.
add_particles(pileups[pileup_number]->translate_particles(dz,dt));
270 OutEvt.add_neutral_hadrons(pileups[pileup_number]->get_neutral_hadrons());
272 OutEvt.add_charged_hadrons(pileups[pileup_number]->translate_charged_hadrons(dz,dt));
278 for(
auto const chad : OutEvt.get_charged_hadrons())
280 fastjet::PseudoJet particleTemp(chad->mom().px(),chad->mom().py(),chad->mom().pz(),chad->E());
283 pJInputs.push_back(particleTemp);
289 fastjet::PseudoJet particleTemp(neut->px(),neut->py(),neut->pz(),neut->E());
292 pJInputs.push_back(particleTemp);
298 fastjet::PseudoJet particleTemp(vis->mom().px(),vis->mom().py(),vis->mom().pz(),vis->mom().E());
301 pJInputs.push_back(particleTemp);
317 fastjet::GridMedianBackgroundEstimator bge(4.7,0.5);
319 bge.set_particles(pJInputs);
320 OutEvt.Average_rho=bge.rho();
363 outjets.push_back(tjet);
376 void filleventHEPMC(
HEP::Event &OutEvt, HepMC::GenEvent* evt,
int npileups, std::vector<HEP::PileupEvent*> &pileups, std::mt19937 &engine)
384 if(evt->weights().size() > 0)
387 OutEvt.set_weight(evt->weights()[0]);
391 OutEvt.set_weight(1.0);
405 SortEvent_DefaultHEPMC(evt,OutEvt,npileups,pileups,dR,engine);
414 anotherCalcMissingMomentum(evt, OutEvt);
445 void filleventHEPMC_FatJet(
HEP::Event &OutEvt, HepMC::GenEvent* evt,
int npileups, std::vector<HEP::PileupEvent*> &pileups, std::mt19937 &engine)
449 if(evt->weights().size() > 0)
452 OutEvt.set_weight(evt->weights()[0]);
456 OutEvt.set_weight(1.0);
460 SortEvent_DefaultHEPMC(evt,OutEvt,npileups,pileups,dR,engine);
461 anotherCalcMissingMomentum(evt, OutEvt);
Simple event class, separating particles into classes.
Definition: heputil.h:227
void add_particles(const std::vector< Particle * > &ps)
Definition: heputil.h:584
std::vector< Particle * > visible_particles() const
Definition: heputil.h:614
void add_particle(Particle *p)
Definition: heputil.h:523
const std::vector< P4 * > & get_neutral_hadrons() const
Get prompt electrons.
Definition: heputil.h:422
void set_jets(const std::vector< Jet * > &jets)
Set the jets collection.
Definition: heputil.h:709
A 4-momentum class for vectors.
Definition: Vectors.h:45
Definition: Particle.h:24
void set_prompt(bool isprompt=true)
Set promptness.
Definition: Particle.h:178