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. Path for output histogram files" << 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);
79 pythia.settings.flag(
"Merging:doUMEPSTree",
true);
81 int njetcounterLO = nMaxLO;
82 string iPathTree = iPath +
"_tree";
85 vector<double> xsecLO;
86 vector<double> nAcceptLO;
88 cout << endl << endl << endl;
89 cout <<
"Start estimating umeps tree level cross section" << endl;
91 while(njetcounterLO >= 0) {
95 in <<
"_" << njetcounterLO <<
".lhe";
97 if(access( (iPathTree+in.str()+
".gz").c_str(), F_OK) != -1) in <<
".gz";
99 string LHEfile = iPathTree + in.str();
101 LHAupLHEF lhareader((
char*)(LHEfile).c_str());
102 pythia.settings.mode(
"Merging:nRequested", njetcounterLO);
103 pythia.settings.word(
"Beams:LHEF", LHEfile);
104 pythia.init(&lhareader);
107 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
109 if( !pythia.next() ) {
110 if( pythia.info.atEndOfFile() ){
120 xsecLO.push_back(pythia.info.sigmaGen());
121 nAcceptLO.push_back(pythia.info.nAccepted());
124 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;
144 vector<double> sampleXSsubtTree;
146 double sigmaTotal = 0.;
147 double errorTotal = 0.;
149 int sizeLO = int(xsecLO.size());
150 njetcounterLO = nMaxLO;
151 iPathTree = iPath +
"_tree";
153 while(njetcounterLO >= 0){
157 in <<
"_" << njetcounterLO <<
".lhe";
159 if(access( (iPathTree+in.str()+
".gz").c_str(), F_OK) != -1) in <<
".gz";
161 string LHEfile = iPathTree + in.str();
163 pythia.settings.flag(
"Merging:doUMEPSTree",
true);
164 pythia.settings.flag(
"Merging:doUMEPSSubt",
false);
165 pythia.settings.mode(
"Merging:nRecluster",0);
166 LHAupLHEF lhareader((
char*)(LHEfile).c_str());
168 cout << endl << endl << endl
169 <<
"Start tree level treatment for " << njetcounterLO <<
" jets"
172 pythia.settings.mode(
"Merging:nRequested", njetcounterLO);
173 pythia.settings.word(
"Beams:LHEF", LHEfile);
174 pythia.init(&lhareader);
177 int iNow = sizeLO-1-njetcounterLO;
180 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
183 if( !pythia.next() ) {
184 if( pythia.info.atEndOfFile() )
break;
189 double weight = pythia.info.mergingWeight();
190 double evtweight = pythia.info.weight();
193 if ( weight == 0. )
continue;
198 double normhepmc = xsecLO[iNow] / nAcceptLO[iNow];
200 hepmcevt->
weights().push_back(weight*normhepmc);
202 ToHepMC.fill_next_event( pythia, hepmcevt );
204 sigmaTotal += weight*normhepmc;
205 sigmaTemp += weight*normhepmc;
206 errorTotal += pow2(weight*normhepmc);
212 ascii_io << hepmcevt;
220 sampleXStree.push_back(sigmaTemp);
224 if( njetcounterLO > 0 )
231 cout << endl << endl << endl;
232 cout <<
"Do UMEPS subtraction" << endl;
234 int njetcounterLS = nMaxLO;
235 string iPathSubt = iPath +
"_tree";
237 while(njetcounterLS >= 1){
241 in <<
"_" << njetcounterLS <<
".lhe";
243 if(access( (iPathSubt+in.str()+
".gz").c_str(), F_OK) != -1) in <<
".gz";
245 string LHEfile = iPathSubt + in.str();
247 pythia.settings.flag(
"Merging:doUMEPSTree",
false);
248 pythia.settings.flag(
"Merging:doUMEPSSubt",
true);
249 pythia.settings.mode(
"Merging:nRecluster",1);
250 LHAupLHEF lhareader((
char*)(LHEfile).c_str());
252 cout << endl << endl << endl
253 <<
"Start subtractive treatment for " << njetcounterLS <<
" jets"
256 pythia.settings.mode(
"Merging:nRequested", njetcounterLS);
257 pythia.settings.word(
"Beams:LHEF", LHEfile);
258 pythia.init(&lhareader);
261 int iNow = sizeLO-1-njetcounterLS;
264 for(
int iEvent=0; iEvent<nEvent; ++iEvent ){
267 if( !pythia.next() ) {
268 if( pythia.info.atEndOfFile() )
break;
273 double weight = pythia.info.mergingWeight();
274 double evtweight = pythia.info.weight();
277 if ( weight == 0. )
continue;
282 double normhepmc = -1*xsecLO[iNow] / nAcceptLO[iNow];
284 hepmcevt->
weights().push_back(weight*normhepmc);
286 ToHepMC.fill_next_event( pythia, hepmcevt );
288 sigmaTotal += weight*normhepmc;
289 sigmaTemp += weight*normhepmc;
290 errorTotal += pow2(weight*normhepmc);
296 ascii_io << hepmcevt;
304 sampleXSsubtTree.push_back(sigmaTemp);
308 if( njetcounterLS > 1 )
315 cout << endl << endl;
316 cout <<
" *---------------------------------------------------*" << endl;
317 cout <<
" | |" << endl;
318 cout <<
" | Sample cross sections after UMEPS merging |" << endl;
319 cout <<
" | |" << endl;
320 cout <<
" | Leading order cross sections (mb): |" << endl;
321 for (
int i = 0; i < int(sampleXStree.size()); ++i)
322 cout <<
" | " << sampleXStree.size()-1-i <<
"-jet: "
323 << setw(17) << scientific << setprecision(6)
324 << sampleXStree[i] <<
" |" << endl;
325 cout <<
" | |" << endl;
326 cout <<
" | Leading-order subtractive cross sections (mb): |" << endl;
327 for (
int i = 0; i < int(sampleXSsubtTree.size()); ++i)
328 cout <<
" | " << sampleXSsubtTree.size()-1-i+1 <<
"-jet: "
329 << setw(17) << scientific << setprecision(6)
330 << sampleXSsubtTree[i] <<
" |" << endl;
331 cout <<
" | |" << endl;
332 cout <<
" |---------------------------------------------------|" << endl;
333 cout <<
" |---------------------------------------------------|" << endl;
334 cout <<
" | Inclusive cross sections: |" << endl;
335 cout <<
" | |" << endl;
336 cout <<
" | UMEPS merged inclusive cross section: |" << endl;
337 cout <<
" | " << setw(17) << scientific << setprecision(6)
338 << sigmaTotal <<
" +- " << setw(17) << sqrt(errorTotal) <<
" mb "
340 cout <<
" | |" << endl;
341 cout <<
" | LO inclusive cross section: |" << endl;
342 cout <<
" | " << setw(17) << scientific << setprecision(6)
343 << xsecLO.back() <<
" mb |" << endl;
344 cout <<
" | |" << endl;
345 cout <<
" *---------------------------------------------------*" << endl;
346 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