1 #include "Pythia8/Pythia.h"
2 #include "Pythia8Plugins/HepMC2.h"
10 string hepName = filename+
".dat";
11 HepMC::Pythia8ToHepMC ToHepMC;
16 pythiaengine.readString(
"Beams:eCM = 200.");
17 pythiaengine.readString(
"promptphoton:all = on");
18 pythiaengine.readString(
"HardQCD:all = on");
19 pythiaengine.readString(
"PhaseSpace:pTHatMin = 10.");
20 pythiaengine.readString(
"Random::setSeed = on");
21 pythiaengine.readString(
"Random::seed =0");
25 string tfilename = filename+
"_analysis.root";
26 TFile *outFile =
new TFile(tfilename.c_str(),
"RECREATE");
27 TTree *photonTree =
new TTree(
"photonTree",
"phat phirn tree");
28 photonTree->SetAutoSave(300);
29 vector<float> photon_pT;
30 photonTree->Branch(
"photon_pT",&photon_pT);
31 TTree *nophotonTree =
new TTree(
"nophotonTree",
"phat phirn tree");
32 unsigned long noPhotonEvents=0;
33 nophotonTree->Branch(
"n",&noPhotonEvents);
35 for (
int iEvent = 0; iEvent <
nEvents; ++iEvent)
37 if (!pythiaengine.next()){
38 cout<<
"pythia.next() failed"<<
"\n";
43 for(
unsigned ipart=0; ipart!=pythiaengine.event.size(); ipart++){
44 if(pythiaengine.event[ipart].id()==22&&pythiaengine.event[ipart].isFinal()&&pythiaengine.event[ipart].pT()>5
45 &&TMath::Abs(pythiaengine.event[ipart].eta()))photon_pT.push_back(pythiaengine.event[ipart].pT());
47 if (photon_pT.size()>0)photonTree->Fill();
51 if(!signalOnly||photon_pT.size()>0){
52 HepMC::GenEvent* hepmcevtfrag =
new HepMC::GenEvent();
53 ToHepMC.fill_next_event( pythiaengine, hepmcevtfrag );
54 ascii_io << hepmcevtfrag;
64 int main(
int argc,
char const *argv[] )
66 string fileOut =
string(argv[1]);
67 bool signalOnly=
false;
68 if(argv[2][0]==
'1'||argv[2][0]==
't')signalOnly=
true;
69 long nEvents =strtol(argv[2],NULL,10);
71 cout<<
"All done"<<endl;