10 #include "Pythia8/Pythia.h"
11 #include "Pythia8/Pythia8ToHepMC.h"
14 #include "HepMC/GenEvent.h"
15 #include "HepMC/IO_GenEvent.h"
17 #include "HepMC/Units.h"
19 using namespace Pythia8;
25 int main(
int argc,
char* argv[] ){
29 cerr <<
" Unexpected number of command-line arguments ("<<argc<<
"). \n"
30 <<
" You are expected to provide the arguments" << endl
31 <<
" 1. Input file for settings" << endl
32 <<
" 2. Name of the input LHE file (with path), up to the '_tree'"
33 <<
" identifier" << endl
34 <<
" 3. Output hepmc file name" << endl
35 <<
" Program stopped. " << endl;
42 pythia.readFile(argv[1]);
48 ToHepMC.set_print_inconsistency(
false);
49 ToHepMC.set_free_parton_warnings(
false);
51 ToHepMC.set_store_pdf(
false);
52 ToHepMC.set_store_proc(
false);
53 ToHepMC.set_store_xsec(
false);
56 string iPath = string(argv[2]);
59 int nEvent = pythia.mode(
"Main:numberOfEvents");
61 int nMaxLO = pythia.mode(
"Merging:nJetMax");
68 bool fsr = pythia.flag(
"PartonLevel:FSR");
69 bool isr = pythia.flag(
"PartonLevel:ISR");
70 bool mpi = pythia.flag(
"PartonLevel:MPI");
71 bool had = pythia.flag(
"HadronLevel:all");
72 pythia.settings.flag(
"PartonLevel:FSR",
false);
73 pythia.settings.flag(
"PartonLevel:ISR",
false);
74 pythia.settings.flag(
"HadronLevel:all",
false);
75 pythia.settings.flag(
"PartonLevel:MPI",
false);
78 pythia.settings.flag(
"Merging:doXSectionEstimate",
true);
80 int njetcounterLO = nMaxLO;
81 string iPathTree = iPath +
"_tree";
84 vector<double> xsecLO;
85 vector<double> nAcceptLO;
87 cout << endl << endl << endl;
88 cout <<
"Start estimating ckkwl tree level cross section" << endl;
90 while(njetcounterLO >= 0) {
94 in <<
"_" << njetcounterLO <<
".lhe";
96 if(access( (iPathTree+in.str()+
".gz").c_str(), F_OK) != -1) in <<
".gz";
98 string LHEfile = iPathTree + in.str();
99 LHAupLHEF lhareader((
char*)(LHEfile).c_str());
100 pythia.settings.mode(
"Merging:nRequested", njetcounterLO);
101 pythia.settings.word(
"Beams:LHEF", LHEfile);
102 pythia.init(&lhareader);
105 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
107 if( !pythia.next() ) {
108 if( pythia.info.atEndOfFile() ){
118 xsecLO.push_back(pythia.info.sigmaGen());
119 nAcceptLO.push_back(pythia.info.nAccepted());
122 if( njetcounterLO > 0 )
133 pythia.settings.flag(
"Merging:doXSectionEstimate",
false);
136 pythia.settings.flag(
"PartonLevel:FSR",fsr);
137 pythia.settings.flag(
"PartonLevel:ISR",isr);
138 pythia.settings.flag(
"HadronLevel:all",had);
139 pythia.settings.flag(
"PartonLevel:MPI",mpi);
142 double sigmaTemp = 0.;
143 vector<double> sampleXStree;
145 double sigmaTotal = 0.;
146 double errorTotal = 0.;
148 int sizeLO = int(xsecLO.size());
149 njetcounterLO = nMaxLO;
150 iPathTree = iPath +
"_tree";
152 while(njetcounterLO >= 0){
156 in <<
"_" << njetcounterLO <<
".lhe";
158 if(access( (iPathTree+in.str()+
".gz").c_str(), F_OK) != -1) in <<
".gz";
160 string LHEfile = iPathTree + in.str();
161 LHAupLHEF lhareader((
char*)(LHEfile).c_str());
163 cout << endl << endl << endl
164 <<
"Start tree level treatment for " << njetcounterLO <<
" jets"
167 pythia.settings.mode(
"Merging:nRequested", njetcounterLO);
168 pythia.settings.word(
"Beams:LHEF", LHEfile);
169 pythia.init(&lhareader);
172 int iNow = sizeLO-1-njetcounterLO;
175 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
178 if( !pythia.next() ) {
179 if( pythia.info.atEndOfFile() )
break;
184 double weight = pythia.info.mergingWeight();
185 double evtweight = pythia.info.weight();
189 if ( weight == 0. )
continue;
194 double normhepmc = xsecLO[iNow] / nAcceptLO[iNow];
196 hepmcevt->
weights().push_back(weight*normhepmc);
198 ToHepMC.fill_next_event( pythia, hepmcevt );
200 sigmaTotal += weight*normhepmc;
201 sigmaTemp += weight*normhepmc;
202 errorTotal += pow2(weight*normhepmc);
208 ascii_io << hepmcevt;
216 sampleXStree.push_back(sigmaTemp);
220 if( njetcounterLO > 0 )
228 cout << endl << endl;
229 cout <<
" *---------------------------------------------------*" << endl;
230 cout <<
" | |" << endl;
231 cout <<
" | Sample cross sections after CKKW-L merging |" << endl;
232 cout <<
" | |" << endl;
233 cout <<
" | Leading order cross sections (mb): |" << endl;
234 for (
int i = 0; i < int(sampleXStree.size()); ++i)
235 cout <<
" | " << sampleXStree.size()-1-i <<
"-jet: "
236 << setw(17) << scientific << setprecision(6)
237 << sampleXStree[i] <<
" |" << endl;
238 cout <<
" | |" << endl;
239 cout <<
" |---------------------------------------------------|" << endl;
240 cout <<
" |---------------------------------------------------|" << endl;
241 cout <<
" | Inclusive cross sections: |" << endl;
242 cout <<
" | |" << endl;
243 cout <<
" | CKKW-L merged inclusive cross section: |" << endl;
244 cout <<
" | " << setw(17) << scientific << setprecision(6)
245 << sigmaTotal <<
" +- " << setw(17) << sqrt(errorTotal) <<
" mb "
247 cout <<
" | |" << endl;
248 cout <<
" | LO inclusive cross section: |" << endl;
249 cout <<
" | " << setw(17) << scientific << setprecision(6)
250 << xsecLO.back() <<
" mb |" << endl;
251 cout <<
" | |" << endl;
252 cout <<
" *---------------------------------------------------*" << endl;
253 cout << endl << endl;
void set_cross_section(double xs, double xs_err)
Set cross section and error in pb.
The GenCrossSection class stores the generated cross section.
void set_cross_section(const GenCrossSection &)
provide a pointer to the GenCrossSection container
The GenEvent class is the core of HepMC.
IO_GenEvent also deals with HeavyIon and PdfInfo.
WeightContainer & weights()
direct access to WeightContainer