本文整理汇总了C++中hepmc::GenEvent::particles_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ GenEvent::particles_begin方法的具体用法?C++ GenEvent::particles_begin怎么用?C++ GenEvent::particles_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hepmc::GenEvent
的用法示例。
在下文中一共展示了GenEvent::particles_begin方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fill
int
DirectPhotonPythia::process_event(PHCompositeNode *topNode)
{
_ievent ++;
PHHepMCGenEventMap * geneventmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
if (!geneventmap)
{
std::cout <<PHWHERE<<" - Fatal error - missing node PHHepMCGenEventMap"<<std::endl;
return Fun4AllReturnCodes::ABORTRUN;
}
PHHepMCGenEvent *genevt = geneventmap->get(_embedding_id);
if (!genevt)
{
std::cout <<PHWHERE<<" - Fatal error - node PHHepMCGenEventMap missing subevent with embedding ID "<<_embedding_id;
std::cout <<". Print PHHepMCGenEventMap:";
geneventmap->identify();
return Fun4AllReturnCodes::ABORTRUN;
}
HepMC::GenEvent* theEvent = genevt->getEvent();
for (HepMC::GenEvent::particle_const_iterator p = theEvent->particles_begin();
p != theEvent->particles_end(); ++p)
{
TParticlePDG * pdg_p = TDatabasePDG::Instance()->GetParticle(
(*p)->pdg_id());
if (pdg_p)
{
if (TString(pdg_p->GetName()) == "gamma")
{
// cout <<"Find gamma at eta = "<< (*p)->momentum().pseudoRapidity() <<endl;
if((*p)->momentum().perp()>5.) _h2->Fill((*p)->momentum().perp(), (*p)->momentum().pseudoRapidity());
if((*p)->momentum().perp()>5.) _h1->Fill((*p)->momentum().perp());
if((*p)->momentum().perp()>5.) {
const float px = (*p)->momentum().x(),
py = (*p)->momentum().y(),
pz = (*p)->momentum().z(),
pt = (*p)->momentum().perp(),
eta = (*p)->momentum().pseudoRapidity(),
phi = (*p)->momentum().phi();
float shower_data[70] = {(float)_ievent,px,py,pz,pt,eta,phi};
_ntp_gamma -> Fill(shower_data);
}
}
}
}
return 0;;
}
示例2: main
int main(int argc, char* argv[])
{
TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================
if (argc<5) return -1;
TString sPath = argv[1]; if (sPath.IsNull()) return -1;
TString sFile = argv[2]; if (sFile.IsNull()) return -1;
TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================
sPath.ReplaceAll("#", "/");
//=============================================================================
double dJetR = -1.;
if (sJetR=="JetR02") dJetR = 0.2;
if (sJetR=="JetR03") dJetR = 0.3;
if (sJetR=="JetR04") dJetR = 0.4;
if (sJetR=="JetR05") dJetR = 0.5;
if (dJetR<0.) return -1;
cout << "Jet R = " << dJetR << endl;
//=============================================================================
double dSjeR = -1.;
if (sSjeR=="SjeR01") dSjeR = 0.1;
if (sSjeR=="SjeR02") dSjeR = 0.2;
if (sSjeR=="SjeR03") dSjeR = 0.3;
if (sSjeR=="SjeR04") dSjeR = 0.4;
if (dSjeR<0.) return -1;
cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================
const int multiLHC = 3000;
const double dJetsPtMin = 0.001;
const double dCutEtaMax = 1.6;
const double dJetEtaMax = 1.;
const double dJetAreaRef = TMath::Pi() * dJetR * dJetR;
fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best);
//fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc);
fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc);
fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best);
fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc);
fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2);
fastjet::Selector selecHard = fastjet::SelectorNHardest(2);
fastjet::Selector selectBkg = selectRho * (!(selecHard));
fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef);
//fastjet::Subtractor bkgSubtractor(&bkgsEstimator);
fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best);
//=============================================================================
TRandom3 *r3 = new TRandom3(0);
TF1 *fBkg = BackgroundSpec();
//=============================================================================
std::vector<fastjet::PseudoJet> fjInputVac;
std::vector<fastjet::PseudoJet> fjInputHyd;
//=============================================================================
TList *list = new TList();
TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInputVac.resize(0);
fjInputHyd.resize(0);
double dXsect = evt->cross_section()->cross_section() / 1e9;
double dWeight = evt->weights().back();
double dNorm = dWeight * dXsect;
hWeightSum->Fill(0.5, dWeight);
int iCount = 0;
TLorentzVector vPseudo;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
vPseudo.SetPtEtaPhiM((*p)->momentum().perp(), (*p)->momentum().eta(), (*p)->momentum().phi(), 0.);
if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) {
fjInputVac.push_back(fastjet::PseudoJet(vPseudo.Px(), vPseudo.Py(), vPseudo.Pz(), vPseudo.E()));
fjInputVac.back().set_user_info(new UserInfoTrk(false));
fjInputVac.back().set_user_index(iCount); iCount+=1;
}
}
//=============================================================================
for (int i=0; i<=multiLHC; i++) {
//.........这里部分代码省略.........
示例3: main
int main(int argc, char* argv[])
{
TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================
if (argc<5) return -1;
TString sPath = argv[1]; if (sPath.IsNull()) return -1;
TString sFile = argv[2]; if (sFile.IsNull()) return -1;
TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================
sPath.ReplaceAll("#", "/");
//=============================================================================
double dJetR = -1.;
if (sJetR=="JetR02") dJetR = 0.2;
if (sJetR=="JetR03") dJetR = 0.3;
if (sJetR=="JetR04") dJetR = 0.4;
if (sJetR=="JetR05") dJetR = 0.5;
if (dJetR<0.) return -1;
cout << "Jet R = " << dJetR << endl;
//=============================================================================
double dSjeR = -1.;
if (sSjeR=="SjeR01") dSjeR = 0.1;
if (sSjeR=="SjeR02") dSjeR = 0.2;
if (sSjeR=="SjeR03") dSjeR = 0.3;
if (sSjeR=="SjeR04") dSjeR = 0.4;
if (dSjeR<0.) return -1;
cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================
const double dJetsPtMin = 0.001;
const double dCutEtaMax = 1.6;
const double dJetEtaMax = 1.;
const double dJetAreaRef = TMath::Pi() * dJetR * dJetR;
fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best);
fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc);
fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best);
//=============================================================================
std::vector<fastjet::PseudoJet> fjInput;
const Double_t dCut = TMath::TwoPi() / 3.;
//=============================================================================
enum { kWgt, kXsc, kLje, kLjr, kLtk, kLtr, kJet, kAje, kMje, k1sz, k1sA, k1sm, k1sr, k2sz, k2sA, k2sm, k2sr, kDsm, kDsr, kVar };
TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
TNtuple *nt = new TNtuple("nt", "", "fWgt:fXsc:fLje:fLjr:fLtk:fLtr:fJet:fAje:fMje:f1sj:f1sA:f1sm:f1sr:f2sj:f2sA:f2sm:f2sr:fDsm:fDsr");
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
double dLtk = -1.;
TVector3 vPar, vLtk;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
double dEta = (*p)->momentum().eta(); if (TMath::Abs(dEta)>dCutEtaMax) continue;
double dTrk = (*p)->momentum().perp();
double dPhi = (*p)->momentum().phi();
vPar.SetPtEtaPhi(dTrk, dEta, dPhi);
fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.Mag()));
if (dTrk>dLtk) { dLtk = dTrk; vLtk.SetPtEtaPhi(dTrk, dEta, dPhi); }
}
//=============================================================================
fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin);
std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets);
//=============================================================================
if (selectJets.size()>0) {
std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets);
TVector3 vLje; vLje.SetPtEtaPhi(sortedJets[0].pt(), sortedJets[0].eta(), sortedJets[0].phi());
TVector3 vJet;
int kJrl = -1; double dJrl = -1.;
int kTrl = -1; double dTrl = -1.;
for (int j=0; j<sortedJets.size(); j++) {
double dJet = sortedJets[j].pt();
sortedJets[j].set_user_index(-1);
vJet.SetPtEtaPhi(dJet, sortedJets[j].eta(), sortedJets[j].phi());
if (TMath::Abs(vJet.DeltaPhi(vLje))>dCut) { sortedJets[j].set_user_index(1); if (dJet>dJrl) { dJrl = dJet; kJrl = j; } }
if (TMath::Abs(vJet.DeltaPhi(vLtk))>dCut) { sortedJets[j].set_user_index(2); if (dJet>dTrl) { dTrl = dJet; kTrl = j; } }
}
//=============================================================================
TVector3 v1sj, v2sj;
for (int j=0; j<sortedJets.size(); j++) {
//.........这里部分代码省略.........
示例4: main
int main(int argc, char* argv[])
{
TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================
if (argc<5) return -1;
TString sPath = argv[1]; if (sPath.IsNull()) return -1;
TString sFile = argv[2]; if (sFile.IsNull()) return -1;
TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================
sPath.ReplaceAll("#", "/");
//=============================================================================
double dJetR = -1.;
if (sJetR=="JetR02") dJetR = 0.2;
if (sJetR=="JetR03") dJetR = 0.3;
if (sJetR=="JetR04") dJetR = 0.4;
if (sJetR=="JetR05") dJetR = 0.5;
if (dJetR<0.) return -1;
cout << "Jet R = " << dJetR << endl;
//=============================================================================
double dSjeR = -1.;
if (sSjeR=="SjeR01") dSjeR = 0.1;
if (sSjeR=="SjeR02") dSjeR = 0.2;
if (sSjeR=="SjeR03") dSjeR = 0.3;
if (sSjeR=="SjeR04") dSjeR = 0.4;
if (dSjeR<0.) return -1;
cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================
const double dJetsPtMin = 0.001;
const double dCutEtaMax = 1.6;
const double dJetEtaMax = 1.;
const double dJetAreaRef = TMath::Pi() * dJetR * dJetR;
fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::E_scheme, fastjet::Best);
//fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc);
fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc);
//fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best);
//fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc);
fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
//fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2);
//fastjet::Selector selecHard = fastjet::SelectorNHardest(2);
//fastjet::Selector selectBkg = selectRho * (!(selecHard));
//fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef);
//fastjet::Subtractor bkgSubtractor(&bkgsEstimator);
fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::E_scheme, fastjet::Best);
//=============================================================================
std::vector<fastjet::PseudoJet> fjInput;
const double dMass = TDatabasePDG::Instance()->GetParticle(211)->Mass();
//=============================================================================
TList *list = new TList();
TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet);
enum { kJet, kMje, kDsz, kIsm, kZsm, kDsr, kVar };
const TString sHist[] = { "aJet", "aMje", "aDsz", "aIsm", "aZsm", "aDsr" };
const Int_t nv[] = { 1000, 150, 120, 150, 150, 500 };
const Double_t dMin[] = { 0., 0., 0., 0., 0., 0. };
const Double_t dMax[] = { 1000., 150., 1.2, 150., 1.5, 5. };
THnSparseD *hs = new THnSparseD("hs", "", kVar, nv, dMin, dMax); hs->Sumw2();
for (Int_t i=0; i<kVar; i++) hs->GetAxis(i)->SetName(sHist[i].Data()); list->Add(hs);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
TLorentzVector vPar;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
vPar.SetPtEtaPhiM((*p)->momentum().perp(), (*p)->momentum().eta(), (*p)->momentum().phi(), dMass);
if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) {
fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.E()));
}
}
//=============================================================================
fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
std::vector<fastjet::PseudoJet> includJets = clustSeq.inclusive_jets(dJetsPtMin);
// std::vector<fastjet::PseudoJet> subtedJets = bkgSubtractor(includJets);
std::vector<fastjet::PseudoJet> selectJets = selectJet(includJets);
// std::vector<fastjet::PseudoJet> sortedJets = fastjet::sorted_by_pt(selectJets);
for (int j=0; j<selectJets.size(); j++) {
double dJet = selectJets[j].pt();
//.........这里部分代码省略.........
示例5: else
int
LeptoquarksReco::AddTrueTauTag( type_map_tcan& tauCandidateMap, PHHepMCGenEventMap *genevtmap )
{
/* Look for leptoquark and tau particle in the event */
TruthTrackerHepMC truth;
truth.set_hepmc_geneventmap( genevtmap );
int pdg_lq = 39; // leptoquark
int pdg_tau = 15; // tau lepton
int pdg_parton = 0;
int pdg_electron = 11; // electron
// Check if electron exists //
HepMC::GenParticle* particle_electron = NULL;
for (PHHepMCGenEventMap::ReverseIter iter = genevtmap->rbegin(); iter != genevtmap->rend(); ++iter)
{
PHHepMCGenEvent *genevt = iter->second;
HepMC::GenEvent *theEvent = genevt->getEvent();
// Loop over all truth particles in event generator collection
for ( HepMC::GenEvent::particle_iterator p = theEvent->particles_begin();
p != theEvent->particles_end(); ++p ) {
// If final state electron then tag it //
if((*p)->pdg_id() == pdg_electron && (*p)->status() == 1) particle_electron = (*p);
}
}
/* Search for leptoquark in event */
HepMC::GenParticle* particle_lq = truth.FindParticle( pdg_lq );
// Tag event as LQ event or not //
if (particle_lq) ( _map_event_branches.find( "is_lq_event" ) )->second = 1;
else ( _map_event_branches.find( "is_lq_event" ) )->second = 0;
/* Search for lq->tau decay in event */
HepMC::GenParticle* particle_tau = NULL;
// Find tau that comes from LQ or just any tau in event //
if(particle_lq) particle_tau = truth.FindDaughterParticle( pdg_tau, particle_lq );
else particle_tau = truth.FindParticle(pdg_tau);
/* Search for lq->quark decay in event.
* Loop over all quark PDG codes until finding a matching quark. */
HepMC::GenParticle* particle_quark = NULL;
for ( int pdg_quark = 1; pdg_quark < 7; pdg_quark++ )
{
/* try quark */
particle_quark = truth.FindDaughterParticle( pdg_quark, particle_lq );
if (particle_quark)
{
pdg_parton = pdg_quark;
break;
}
/* try anti-quark */
particle_quark = truth.FindDaughterParticle( -pdg_quark, particle_lq );
if (particle_quark)
{
pdg_parton = -pdg_quark;
break;
}
}
/* If TAU in event: Tag the tau candidate (i.e. jet) with smalles delta_R from this tau */
if( particle_tau )
{
PidCandidate* best_match = FindMinDeltaRCandidate( &tauCandidateMap,
particle_tau->momentum().eta(),
particle_tau->momentum().phi() );
/* set is_tau = TRUE for PidCandiate with smallest delta_R within reasonable range*/
if ( best_match )
{
/* Check: If PidCandidate::Evtgen_pid has already been set to a value != 0, exit function. */
if( best_match->get_property_int( PidCandidate::evtgen_pid ) != 0 )
{
cout << "ERROR: Try to set PidCandidate::evtgen_pid for PidCandidate with evtgen_pid != 0" << endl;
return -1;
}
/* Update PidCandidate entry */
best_match->set_property( PidCandidate::evtgen_pid, pdg_tau );
best_match->set_property( PidCandidate::evtgen_etotal, (float)particle_tau->momentum().e() );
best_match->set_property( PidCandidate::evtgen_eta, (float)particle_tau->momentum().eta() );
best_match->set_property( PidCandidate::evtgen_phi, (float)particle_tau->momentum().phi() );
/* Check particle decay if end-vertex found */
if ( particle_tau->end_vertex() )
{
/* Add information about tau decay */
uint tau_decay_prong = 0;
uint tau_decay_hcharged = 0;
uint tau_decay_lcharged = 0;
/* Count how many charged particles (hadrons and leptons) a given particle decays into. */
truth.FindDecayParticles( particle_tau, tau_decay_prong, tau_decay_hcharged, tau_decay_lcharged );
//.........这里部分代码省略.........
示例6: main
int main(int argc, char* argv[])
{
TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================
if (argc<5) return -1;
TString sPath = argv[1]; if (sPath.IsNull()) return -1;
TString sFile = argv[2]; if (sFile.IsNull()) return -1;
TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================
sPath.ReplaceAll("#", "/");
//=============================================================================
double dJetR = -1.;
if (sJetR=="JetR02") dJetR = 0.2;
if (sJetR=="JetR03") dJetR = 0.3;
if (sJetR=="JetR04") dJetR = 0.4;
if (sJetR=="JetR05") dJetR = 0.5;
if (dJetR<0.) return -1;
cout << "Jet R = " << dJetR << endl;
//=============================================================================
double dSjeR = -1.;
if (sSjeR=="SjeR01") dSjeR = 0.1;
if (sSjeR=="SjeR02") dSjeR = 0.2;
if (sSjeR=="SjeR03") dSjeR = 0.3;
if (sSjeR=="SjeR04") dSjeR = 0.4;
if (dSjeR<0.) return -1;
cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================
const double dJetsPtMin = 0.001;
const double dCutEtaMax = 1.6;
const double dJetEtaMax = 1.;
const double dJetAreaRef = TMath::Pi() * dJetR * dJetR;
fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best);
//fastjet::AreaDefinition areaDef(fastjet::active_area,areaSpc);
fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc);
//fastjet::JetDefinition bkgsDef(fastjet::kt_algorithm, 0.2, fastjet::BIpt_scheme, fastjet::Best);
//fastjet::AreaDefinition aBkgDef(fastjet::active_area_explicit_ghosts, areaSpc);
fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
//fastjet::Selector selectRho = fastjet::SelectorAbsEtaMax(dCutEtaMax-0.2);
//fastjet::Selector selecHard = fastjet::SelectorNHardest(2);
//fastjet::Selector selectBkg = selectRho * (!(selecHard));
//fastjet::JetMedianBackgroundEstimator bkgsEstimator(selectBkg, bkgsDef, aBkgDef);
//fastjet::Subtractor bkgSubtractor(&bkgsEstimator);
fastjet::JetDefinition subjDef(fastjet::antikt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best);
//=============================================================================
std::vector<fastjet::PseudoJet> fjInput;
//=============================================================================
TList *list = new TList();
TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum);
TH1D *hJet = new TH1D("hJet", "", 1000, 0., 1000.); hJet->Sumw2(); list->Add(hJet);
TH2D *hJetNsj = new TH2D("hJetNsj", "", 1000, 0., 1000., 101, -0.5, 100.5); hJetNsj->Sumw2(); list->Add(hJetNsj);
TH2D *hJetIsj = new TH2D("hJetIsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetIsj->Sumw2(); list->Add(hJetIsj);
TH2D *hJet1sj = new TH2D("hJet1sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet1sj->Sumw2(); list->Add(hJet1sj);
TH2D *hJet2sj = new TH2D("hJet2sj", "", 1000, 0., 1000., 1000, 0., 1000.); hJet2sj->Sumw2(); list->Add(hJet2sj);
TH2D *hJetDsj = new TH2D("hJetDsj", "", 1000, 0., 1000., 1000, 0., 1000.); hJetDsj->Sumw2(); list->Add(hJetDsj);
TH2D *hJetIsz = new TH2D("hJetIsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetIsz->Sumw2(); list->Add(hJetIsz);
TH2D *hJet1sz = new TH2D("hJet1sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet1sz->Sumw2(); list->Add(hJet1sz);
TH2D *hJet2sz = new TH2D("hJet2sz", "", 1000, 0., 1000., 120, 0., 1.2); hJet2sz->Sumw2(); list->Add(hJet2sz);
TH2D *hJetDsz = new TH2D("hJetDsz", "", 1000, 0., 1000., 120, 0., 1.2); hJetDsz->Sumw2(); list->Add(hJetDsz);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
double dXsect = evt->cross_section()->cross_section() / 1e9;
double dWeight = evt->weights().back();
double dNorm = dWeight * dXsect;
hWeightSum->Fill(0.5, dWeight);
TVector3 vPar;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
vPar.SetXYZ((*p)->momentum().px(), (*p)->momentum().py(), (*p)->momentum().pz());
if ((TMath::Abs(vPar.Eta())<dCutEtaMax)) {
fjInput.push_back(fastjet::PseudoJet(vPar.Px(), vPar.Py(), vPar.Pz(), vPar.Mag()));
}
}
//=============================================================================
fastjet::ClusterSequenceArea clustSeq(fjInput, jetsDef, areaDef);
//.........这里部分代码省略.........
示例7: main
int main(int argc, char* argv[])
{
TApplication theApp(srcName.Data(), &argc, argv);
//=============================================================================
if (argc<5) return -1;
TString sPath = argv[1]; if (sPath.IsNull()) return -1;
TString sFile = argv[2]; if (sFile.IsNull()) return -1;
TString sJetR = argv[3]; if (sJetR.IsNull()) return -1;
TString sSjeR = argv[4]; if (sSjeR.IsNull()) return -1;
//=============================================================================
sPath.ReplaceAll("#", "/");
//=============================================================================
double dJetR = -1.;
if (sJetR=="JetR02") dJetR = 0.2;
if (sJetR=="JetR03") dJetR = 0.3;
if (sJetR=="JetR04") dJetR = 0.4;
if (sJetR=="JetR05") dJetR = 0.5;
if (dJetR<0.) return -1;
cout << "Jet R = " << dJetR << endl;
//=============================================================================
double dSjeR = -1.;
if (sSjeR=="SjeR01") dSjeR = 0.1;
if (sSjeR=="SjeR02") dSjeR = 0.2;
if (sSjeR=="SjeR03") dSjeR = 0.3;
if (sSjeR=="SjeR04") dSjeR = 0.4;
if (dSjeR<0.) return -1;
cout << "Sub-jet R = " << dSjeR << endl;
//=============================================================================
const double dJetsPtMin = 0.1;
const double dJetEtaMax = 2.;
const double dCutEtaMax = 2.6;
fastjet::GhostedAreaSpec areaSpc(dCutEtaMax);
fastjet::JetDefinition jetsDef(fastjet::antikt_algorithm, dJetR, fastjet::BIpt_scheme, fastjet::Best);
fastjet::AreaDefinition areaDef(fastjet::active_area_explicit_ghosts,areaSpc);
fastjet::Selector selectJet = fastjet::SelectorAbsEtaMax(dJetEtaMax);
fastjet::JetDefinition subjDef(fastjet::kt_algorithm, dSjeR, fastjet::BIpt_scheme, fastjet::Best);
//=============================================================================
std::vector<fastjet::PseudoJet> fjInput;
//=============================================================================
TFile *file = TFile::Open(Form("%s.root",sFile.Data()), "NEW");
TList *list = new TList();
TH1D *hWeightSum = new TH1D("hWeightSum", "", 1, 0., 1.); list->Add(hWeightSum);
TH2D *hTrkPtEta = new TH2D("hTrkPtEta", "", 1000, 0., 500., 60, -3., 3.); hTrkPtEta->Sumw2(); list->Add(hTrkPtEta);
TH2D *hTrkPtPhi = new TH2D("hTrkPtPhi", "", 1000, 0., 500., 20, -1., 1.); hTrkPtPhi->Sumw2(); list->Add(hTrkPtPhi);
TH2D *hJetPtNsj = new TH2D("hJetPtNsj", "", 1000, 0., 1000., 100, -0.5, 99.5); hJetPtNsj->Sumw2(); list->Add(hJetPtNsj);
TH2D *hJetPtEta = new TH2D("hJetPtEta", "", 1000, 0., 1000., 60, -3., 3.); hJetPtEta->Sumw2(); list->Add(hJetPtEta);
TH2D *hJetPtPhi = new TH2D("hJetPtPhi", "", 1000, 0., 1000., 20, -1., 1.); hJetPtPhi->Sumw2(); list->Add(hJetPtPhi);
TH2D *hLjePtEta = new TH2D("hLjePtEta", "", 1000, 0., 1000., 60, -3., 3.); hLjePtEta->Sumw2(); list->Add(hLjePtEta);
TH2D *hLjePtPhi = new TH2D("hLjePtPhi", "", 1000, 0., 1000., 20, -1., 1.); hLjePtPhi->Sumw2(); list->Add(hLjePtPhi);
TH2D *hNjePtEta = new TH2D("hNjePtEta", "", 1000, 0., 1000., 60, -3., 3.); hNjePtEta->Sumw2(); list->Add(hNjePtEta);
TH2D *hNjePtPhi = new TH2D("hNjePtPhi", "", 1000, 0., 1000., 20, -1., 1.); hNjePtPhi->Sumw2(); list->Add(hNjePtPhi);
TH2D *hJe2PtEta = new TH2D("hJe2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hJe2PtEta->Sumw2(); list->Add(hJe2PtEta);
TH2D *hJe2PtPhi = new TH2D("hJe2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hJe2PtPhi->Sumw2(); list->Add(hJe2PtPhi);
TH2D *hLj2PtEta = new TH2D("hLj2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hLj2PtEta->Sumw2(); list->Add(hLj2PtEta);
TH2D *hLj2PtPhi = new TH2D("hLj2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hLj2PtPhi->Sumw2(); list->Add(hLj2PtPhi);
TH2D *hNj2PtEta = new TH2D("hNj2PtEta", "", 1000, 0., 1000., 60, -3., 3.); hNj2PtEta->Sumw2(); list->Add(hNj2PtEta);
TH2D *hNj2PtPhi = new TH2D("hNj2PtPhi", "", 1000, 0., 1000., 20, -1., 1.); hNj2PtPhi->Sumw2(); list->Add(hNj2PtPhi);
//=============================================================================
HepMC::IO_GenEvent ascii_in(Form("%s/%s.hepmc",sPath.Data(),sFile.Data()), std::ios::in);
HepMC::GenEvent *evt = ascii_in.read_next_event();
while (evt) {
fjInput.resize(0);
double dWeight = evt->weights().back();
double dXsect = evt->cross_section()->cross_section() / 1e9;
double dNorm = dWeight * dXsect;
hWeightSum->Fill(0.5, dWeight);
TVector3 vTrk;
for (HepMC::GenEvent::particle_const_iterator p=evt->particles_begin(); p!=evt->particles_end(); ++p) if ((*p)->status()==1) {
double dTrkPt = (*p)->momentum().perp(); if (dTrkPt<0.5) continue;
double dTrkEta = (*p)->momentum().eta(); if (TMath::Abs(dTrkEta)>dCutEtaMax) continue;
double dTrkPhi = (*p)->momentum().phi(); vTrk.SetPtEtaPhi(dTrkPt, dTrkEta, dTrkPhi);
double dTrkCos = TMath::Cos(dTrkPhi); if (dTrkCos==1.) dTrkCos = 1. - 1e-6;
fjInput.push_back(fastjet::PseudoJet(vTrk.Px(), vTrk.Py(), vTrk.Pz(), vTrk.Mag()));
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
if(verbose) {
std::cout << "Initializing PYTHIA" << std::endl;
}
// initializing PYTHIA
Pythia8::Pythia pythia; // creating PYTHIA generator object
pythia.readFile(pythia_cfgfile); // reading settings from file
pythia.init(); // initializing PYTHIA generator
// Interface for conversion from Pythia8::Event to HepMC event.
HepMC::Pythia8ToHepMC ToHepMC;
std::size_t counter = 0; // number of "interesting" (that satisfy all the requirements) events generated so far
std::size_t total = 0; // total number of events generated so far
if(verbose) {
std::cout << "Starting to generate events" << std::endl;
}
std::map<std::size_t, std::size_t> stable_ptcs_count;
while(counter < nevents) {
if(pythia.next()) {
++total;
// creating HepMC event storage
HepMC::GenEvent * hepmcevt = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM);
// converting generated event to HepMC format
ToHepMC.fill_next_event(pythia, hepmcevt);
auto nstable = std::count_if(hepmcevt->particles_begin(), hepmcevt->particles_end(), [](HepMC::GenParticle const * const ptc_ptr) {return ptc_ptr->status() == 1;});
if(nstable <= 7) {
stable_ptcs_count[nstable]++;
++counter;
if(verbose && counter % 100 == 0) {
std::cout << counter << " events with with 7 or less particles in the final state have been generated (" << total << " total). " << std::chrono::duration<double>(std::chrono::system_clock::now() - last_timestamp).count() / 100 << "events / sec" << std::endl;
last_timestamp = std::chrono::system_clock::now();
}
// filling event info
auto evinfo = fcc::EventInfo();
evinfo.Number(counter); // Number takes int as its parameter, so here's a narrowing conversion (std::size_t to int). Should be safe unless we get 2^32 events or more. Then undefined behaviour
evinfocoll.push_back(evinfo);
// filling vertices
std::unordered_map<HepMC::GenVertex *, fcc::GenVertex> vtx_map;
for(auto iv = hepmcevt->vertices_begin(), endv = hepmcevt->vertices_end(); iv != endv; ++iv) {
auto vtx = fcc::GenVertex();
vtx.Position().X = (*iv)->position().x();
vtx.Position().Y = (*iv)->position().y();
vtx.Position().Z = (*iv)->position().z();
vtx.Ctau((*iv)->position().t());
vtx_map.emplace(*iv, vtx);
vcoll.push_back(vtx);
}
// filling particles
for(auto ip = hepmcevt->particles_begin(), endp = hepmcevt->particles_end(); ip != endp; ++ip) {
auto ptc = fcc::MCParticle();
auto & core = ptc.Core();