int main(int argc, char** argv) { int nEvents = atoi(argv[1]); //-----Pythia setup----- Pythia pythia; //---general setup pythia.readString("Random:seed = 0"); pythia.readString("Random:setSeed = on"); pythia.readString("Beams:idA = 2212"); pythia.readString("Beams:idB = 2212"); pythia.readString("Beams:eA = 7000."); pythia.readString("Beams:eB = 7000."); pythia.readString("Beams:eCM = 14000."); pythia.readString("HadronLevel:Hadronize = on"); //---CMS tuned min bias pythia.readString("SoftQCD:nonDiffractive = on"); pythia.readString("SoftQCD:singleDiffractive = on"); pythia.readString("SoftQCD:doubleDiffractive = on"); pythia.readString("Tune:ee = 3"); pythia.readString("Tune:pp = 15"); //---Pythia initialization pythia.init(); string outFile = "/afs/cern.ch/user/s/spigazzi/work/VBS4TP/MC_data/minBias/minBias_14TeV_"; outFile += argv[1]; outFile += "_"; outFile += argv[2]; outFile += ".hepmc"; HepMC::IO_GenEvent hepmc_file_out(outFile, std::ios::out); HepMC::Pythia8ToHepMC ToHepMC; for (int iEvent = 0; iEvent < nEvents; ++iEvent) { if(iEvent%(nEvents/10) == 0) { cout << "Events: " << iEvent << endl; } if(!pythia.next()) { cout << "CRASH! ---> skip" << endl; continue; } // construct new HepMC event setting units. HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM); // fill the event including PDF infos ToHepMC.fill_next_event( pythia, hepmcevt ); hepmc_file_out << hepmcevt; delete hepmcevt; } // Done. return 0; }
int main(int argc, char* argv[]) { char tune[25]; char seed[25]; //tune = "5"; //seed = "1370"; strncpy(tune,"5",25); strncpy(seed,"1370",25); //TODO this has gotten big enough to require real command line //options, setup and option parser and do it right. Someone's going //to get headaches over this very soon //TODO add seeds back as an option, required for running on condor! if(argc < 3) { cerr<<"Usage: "<<argv[0]<<" [config file] [out file] [conf lines ...]"<<endl; return 1; } ifstream is(argv[1]); if (!is) { cerr << " Command-line file " << argv[1] << " was not found. \n" << " Program stopped! " << endl; return 1; } cout<<"Configuring PYTHIA from "<<argv[1]<<endl; cout<<"Writing output to "<<argv[2]<<endl; vector<std::string> commandStrings; for(int i=3; i < argc; i++){ commandStrings.push_back(string(argv[i])); cout <<" Got Pythia command: "<<commandStrings.back()<<endl; } cout <<"Warning, command line arguments aren't type-checked, don't be stupid." <<endl; HepMC::Pythia8ToHepMC ToHepMC; HepMC::IO_GenEvent ascii_io(argv[2], std::ios::out); char processline[128]; Pythia pythia; pythia.readFile(argv[1]); int nRequested = 100; nRequested = pythia.mode("Main:numberOfEvents"); int nAbort = pythia.mode("Main:timesAllowErrors"); // Set the seed pythia.readString("Random:setSeed = on"); sprintf(processline,"Random:seed = %s",seed); pythia.readString(processline); // Set the tune sprintf(processline,"Tune:pp = %s",tune); pythia.readString(processline); for(std::vector<std::string>::const_iterator cmd = commandStrings.begin(); cmd != commandStrings.end(); ++cmd){ pythia.readString(*cmd); } pythia.init(); int iAbort = 0; int nGenerated=0; std::vector<int> requestedPdgId;//(3,0); int pid=0; bool keep=false; while(nGenerated < nRequested) { pid=0; keep=false; // requestedPdgId.clear(); if (!pythia.next()) { if (pythia.info.atEndOfFile()) { cout << " Aborted since reached end of Les Houches Event File\n"; break; } if (++iAbort < nAbort) continue; cout << " Event generation aborted prematurely, owing to error!\n"; break; } for(int i=0; i < pythia.event.size(); i++){ pid=abs(pythia.event[i].id()); if(pid == 443 || // J\psi pid == 10441 || //Chi_0 pid == 20443 || //Chi_1 pid == 445 || //Chi_2 pid == 100443 /*pid ==13 */){ keep=true; break; } } if(!keep){ continue; } HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(HepMC::Units::GEV, HepMC::Units::MM); ToHepMC.fill_next_event( pythia, hepmcevt ); ascii_io << hepmcevt ; delete hepmcevt; nGenerated++; } pythia.stat(); return 0; }
int main(int argc, char **argv) { TROOT root("pythia","run pythia"); // CONSTANT if( argc < 3 ){ std::cout<<Form("usage : ./%s <output> <random_seed>",argv[0])<<std::endl; exit(1); } char *outFile = argv[1]; Int_t random_seed = atoi(argv[2]); TFile *fout = new TFile(outFile,"recreate"); // Generator. Pythia pythia; // Shorthand for some public members of pythia (also static ones). Event& event = pythia.event; //ParticleDataTable& pdt = pythia.particleData; Info& info = pythia.info; // Read in commands from external file. pythia.readFile("main03.cmnd"); // Extract settings to be used in the main program. int nEvent = pythia.mode("Main:numberOfEvents"); int nList = pythia.mode("Main:numberToList"); int nShow = pythia.mode("Main:timesToShow"); bool showCS = pythia.flag("Main:showChangedSettings"); //bool showCPD = pythia.flag("Main:showChangedParticleData"); pythia.readString(Form("Random:seed=%d",random_seed)); // Initialize. Beam parameters set in .cmnd file. pythia.init(); // List changed data. if (showCS) pythia.settings.listChanged(); //if (showCPD) pdt.listChanged(); // Book histograms. TH1D *pThard = new TH1D("pThard","process pT scale", 100, 0., 200.); pThard->Sumw2(); TH1D *mult = new TH1D("mult","charged particle multiplicity", 100, -0.5, 799.5);mult->Sumw2(); TH1D *dndy = new TH1D("dndy","dn/dy for charged particles", 100, -10., 10.);dndy->Sumw2(); TH1D *dndpT_hadron = new TH1D("dndpT_hadron","dn/dpT for charged particles", 500, 0., 50.);dndpT_hadron->Sumw2(); TH1D *dndpT_pion = new TH1D("dndpT_pion","dn/dpT for pions", 500, 0., 50.);dndpT_pion->Sumw2(); TH1D *dndpT_kaon = new TH1D("dndpT_kaon","dn/dpT for kaons", 500, 0., 50.);dndpT_kaon->Sumw2(); TH1D *dndpT_proton = new TH1D("dndpT_proton","dn/dpT for protons", 500, 0., 50.);dndpT_proton->Sumw2(); TH1D *dndpT_antiproton = new TH1D("dndpT_antiproton","dn/dpT for antiprotons", 500, 0., 50.);dndpT_antiproton->Sumw2(); TH1D *dndpT_k0s = new TH1D("dndpT_k0s","dn/dpT for k0s", 500, 0., 50.);dndpT_k0s->Sumw2(); TH1D *dndpT_infly_hadron = new TH1D("dndpT_infly_hadron","dn/dpT for charged particles", 500, 0., 50.);dndpT_infly_hadron->Sumw2(); TH1D *dndpT_infly_pion = new TH1D("dndpT_infly_pion","dn/dpT for pions", 500, 0., 50.);dndpT_infly_pion->Sumw2(); TH1D *dndpT_infly_kaon = new TH1D("dndpT_infly_kaon","dn/dpT for kaons", 500, 0., 50.);dndpT_infly_kaon->Sumw2(); TH1D *dndpT_infly_proton = new TH1D("dndpT_infly_proton","dn/dpT for protons", 500, 0., 50.);dndpT_infly_proton->Sumw2(); TH1D *dndpT_infly_antiproton = new TH1D("dndpT_infly_antiproton","dn/dpT for antiprotons", 500, 0., 50.);dndpT_infly_antiproton->Sumw2(); TH1D *dndpT_hadron_mid = new TH1D("dndpT_hadron_mid","dn/dpT for charged particles |eta|<0.35", 500, 0., 50.);dndpT_hadron_mid->Sumw2(); TH1D *dndpT_pion_mid = new TH1D("dndpT_pion_mid","dn/dpT for pions |eta|<0.35", 500, 0., 50.);dndpT_pion_mid->Sumw2(); TH1D *dndpT_kaon_mid = new TH1D("dndpT_kaon_mid","dn/dpT for kaon |eta|<0.35", 500, 0., 50.);dndpT_kaon_mid->Sumw2(); TH1D *dndpT_proton_mid = new TH1D("dndpT_proton_mid","dn/dpT for proton |eta|<0.35", 500, 0., 50.);dndpT_proton_mid->Sumw2(); TH1D *dndpT_antiproton_mid = new TH1D("dndpT_antiproton_mid","dn/dpT for antiproton |eta|<0.35", 500, 0., 50.);dndpT_antiproton_mid->Sumw2(); TH1D *dndpT_infly_hadron_mid = new TH1D("dndpT_infly_hadron_mid","dn/dpT for charged particles |eta|<0.35", 500, 0., 50.);dndpT_infly_hadron_mid->Sumw2(); TH1D *dndpT_infly_pion_mid = new TH1D("dndpT_infly_pion_mid","dn/dpT for pions |eta|<0.35", 500, 0., 50.);dndpT_infly_pion_mid->Sumw2(); TH1D *dndpT_infly_kaon_mid = new TH1D("dndpT_infly_kaon_mid","dn/dpT for kaon |eta|<0.35", 500, 0., 50.);dndpT_infly_kaon_mid->Sumw2(); TH1D *dndpT_infly_proton_mid = new TH1D("dndpT_infly_proton_mid","dn/dpT for proton |eta|<0.35", 500, 0., 50.);dndpT_infly_proton_mid->Sumw2(); TH1D *dndpT_infly_antiproton_mid = new TH1D("dndpT_infly_antiproton_mid","dn/dpT for antiproton |eta|<0.35", 500, 0., 50.);dndpT_infly_antiproton_mid->Sumw2(); TH1D *dndpT_k0s_mid = new TH1D("dndpT_k0s_mid","dn/dpT for k0s |eta|<0.35", 500, 0., 50.);dndpT_k0s_mid->Sumw2(); TStopwatch timer; timer.Start(); // Begin event loop. int nPace = max(1, nEvent / max(1, nShow) ); for (int iEvent = 0; iEvent < nEvent; ++iEvent) { if (nShow > 0 && iEvent%nPace == 0) cout << " Now begin event " << iEvent << endl; // Generate events. Quit if failure. if (!pythia.next()) { cout << " Event generation aborted prematurely, owing to error!\n"; break; } // List first few events, both info, hard process and complete events. if (iEvent < nList) { info.list(); pythia.process.list(); event.list(); } // Fill hard scale of event. pThard->Fill( info. pTHat() ); // Loop over final charged particles in the event. int nCharged = 0; for (int i = 0; i < event.size(); ++i) { // for k0s if (event[i].id()==310 ) dndpT_k0s->Fill(event[i].pT()); if(event[i].eta()>-0.35&&event[i].eta()<0.35) { if (event[i].id()==310 ) dndpT_k0s_mid->Fill(event[i].pT()); } // Infly decay dndpT_infly_hadron->Fill( event[i].pT() ); if (event[i].id()==211 || event[i].id()==-211 ) dndpT_infly_pion->Fill(event[i].pT()); if (event[i].id()==321 || event[i].id()==-321 ) dndpT_infly_kaon->Fill(event[i].pT()); if (event[i].id()==2212) dndpT_infly_proton->Fill(event[i].pT()); if (event[i].id()==-2212 ) dndpT_infly_antiproton->Fill(event[i].pT()); if(event[i].eta()>-0.35&&event[i].eta()<0.35) { dndpT_infly_hadron_mid->Fill( event[i].pT() ); if (event[i].id()==211 || event[i].id()==-211 ) dndpT_infly_pion_mid->Fill(event[i].pT()); if (event[i].id()==321 || event[i].id()==-321 ) dndpT_infly_kaon_mid->Fill(event[i].pT()); if (event[i].id()==2212) dndpT_infly_proton_mid->Fill(event[i].pT()); if (event[i].id()==-2212) dndpT_infly_antiproton_mid->Fill(event[i].pT()); } // hadron in final state if (event[i].isFinal()&&event[i].isCharged()) { dndpT_hadron->Fill( event[i].pT() ); if (event[i].id()==211 || event[i].id()==-211 ) dndpT_pion->Fill(event[i].pT()); if (event[i].id()==321 || event[i].id()==-321 ) dndpT_kaon->Fill(event[i].pT()); if (event[i].id()==2212) dndpT_proton->Fill(event[i].pT()); if (event[i].id()==-2212 ) dndpT_antiproton->Fill(event[i].pT()); } if(event[i].isFinal()&&event[i].isCharged()&&event[i].eta()>-0.35&&event[i].eta()<0.35) { dndpT_hadron_mid->Fill( event[i].pT() ); if (event[i].id()==211 || event[i].id()==-211 ) dndpT_pion_mid->Fill(event[i].pT()); if (event[i].id()==321 || event[i].id()==-321 ) dndpT_kaon_mid->Fill(event[i].pT()); if (event[i].id()==2212) dndpT_proton_mid->Fill(event[i].pT()); if (event[i].id()==-2212) dndpT_antiproton_mid->Fill(event[i].pT()); } // Analyze charged particles and fill histograms. if(event[i].isFinal()&&event[i].isCharged()) { ++nCharged; dndy->Fill( event[i].y() ); } // End of particle and event loops. Fill charged multiplicity. } mult->Fill( nCharged ); } // Final statistics. Normalize and output histograms. pythia.statistics(); timer.Stop(); timer.Print(); fout->cd(); pThard->Write(); mult->Write(); dndy->Write(); dndpT_hadron->Write(); dndpT_pion->Write(); dndpT_kaon->Write(); dndpT_proton->Write(); dndpT_antiproton->Write(); dndpT_infly_hadron->Write(); dndpT_infly_pion->Write(); dndpT_infly_kaon->Write(); dndpT_infly_proton->Write(); dndpT_infly_antiproton->Write(); dndpT_k0s->Write(); dndpT_hadron_mid->Write(); dndpT_pion_mid->Write(); dndpT_kaon_mid->Write(); dndpT_proton_mid->Write(); dndpT_antiproton_mid->Write(); dndpT_infly_hadron_mid->Write(); dndpT_infly_pion_mid->Write(); dndpT_infly_kaon_mid->Write(); dndpT_infly_proton_mid->Write(); dndpT_infly_antiproton_mid->Write(); dndpT_k0s_mid->Write(); fout->Write(); fout->Close(); // Done. return 0; }
int main() { Pythia pythia; pythia.readString("ParticleDecays:limitTau0 = on"); // Particle lifetime cutoff pythia.readString("ParticleDecays:tauMax = 10"); pythia.readString("42:0:products = 5 16"); // Force decay to b nu_tau pythia.readString("42:m0 = 800"); // LQ mass set to 800 GeV/c^2 pythia.readString("LeptoQuark:gg2LQLQbar = on"); // production mechanism: gg pythia.readString("LeptoQuark:qqbar2LQLQbar = on"); // production mechanism: qqbar pythia.readString("Tune:pp 2"); // Tune? What?? pythia.readString("Tune:ee 3"); // I see this in CMS production settings..... pythia.readString("Random:setSeed = on"); pythia.readString("Random:seed = 0"); pythia.init(2212, 2212, 7000); pythia.next(); pythia.event.list(); double Gamma = 3500 / 0.938272046; double BetaGamma = sqrt(Gamma * Gamma - 1); Gamma = 1; BetaGamma = 0; vector<GenParticle> particles(pythia.event.size()); for(int j = 0; j < pythia.event.size(); j++) { particles[j].P[0] = pythia.event[j].e() * Gamma - pythia.event[j].pz() * BetaGamma; particles[j].P[1] = pythia.event[j].px(); particles[j].P[2] = pythia.event[j].py(); particles[j].P[3] = pythia.event[j].pz() * Gamma - pythia.event[j].e() * BetaGamma; particles[j].V[0] = pythia.event[j].tProd() * Gamma - pythia.event[j].zProd() * BetaGamma; particles[j].V[1] = pythia.event[j].xProd(); particles[j].V[2] = pythia.event[j].yProd(); particles[j].V[3] = pythia.event[j].zProd() * Gamma - pythia.event[j].tProd() * BetaGamma; particles[j].PDGID = pythia.event[j].id(); particles[j].StatusCode = pythia.event.statusHepMC(j); particles[j].Mothers = pythia.event.motherList(j); particles[j].Daughters = pythia.event.daughterList(j); } GenParticleTree Event(particles, 0, 0); cout << "function InitializeParticles()" << endl; cout << "{" << endl; cout << " ParticleList.length = 0;" << endl; cout << endl; cout << " var NewParticle = new Object();" << endl; cout << " NewParticle.P = new Array(4);" << endl; cout << " NewParticle.V0 = new Array(4);" << endl; cout << endl; for(int i = 0; i < Event.ParticleCount(); i++) { bool WriteOut = false; if(Event[i].StatusCode == 1) WriteOut = true; if(Event[i].Daughters.size() == 0) WriteOut = true; if(Event[i].Daughters.size() > 0 && Event[Event[i].Daughters[0]].V[0] > Event[i].V[0]) WriteOut = true; if(WriteOut == false) continue; cout << setprecision(10); cout << " NewParticle.P[0] = " << Event[i].P[0] << endl; cout << " NewParticle.P[1] = " << Event[i].P[1] << endl; cout << " NewParticle.P[2] = " << Event[i].P[2] << endl; cout << " NewParticle.P[3] = " << Event[i].P[3] << endl; cout << " NewParticle.V0[0] = " << Event[i].V[0] << endl; cout << " NewParticle.V0[1] = " << Event[i].V[1] << endl; cout << " NewParticle.V0[2] = " << Event[i].V[2] << endl; cout << " NewParticle.V0[3] = " << Event[i].V[3] << endl; cout << " NewParticle.PDGID = " << Event[i].PDGID << endl; if(Event[i].Daughters.size() == 0) cout << " NewParticle.Time = 999999" << endl; else cout << " NewParticle.Time = " << Event[Event[i].Daughters[0]].V[0] << endl; cout << " ParticleList[ParticleList.length] = NewParticle.clone()" << endl; cout << endl; } cout << "}" << endl; cout << endl; return 0; }
int main(int argc, char **argv) { //initial arguments int seed = -1; char seedString[32]; char inputFile[1000]; char outputFile[1000]; sprintf(inputFile, "pythia_inclusive.cmnd"); sprintf(outputFile, "pythiatree.root"); for (int i = 1; i < argc; i=i+2){ if(!strcmp(argv[i], "-t")) strcpy(inputFile, argv[i + 1]); if(!strcmp(argv[i], "-s")) seed = atoi(argv[i+1]); if(!strcmp(argv[i], "-o")) strcpy(outputFile, argv[i + 1]); } // Generator. Pythia pythia; // Shorthand for the event record in pythia. Event& event = pythia.event; // Read in commands from external file. pythia.readString("Random:setSeed = on"); sprintf(seedString, "Random:seed = %d", seed); pythia.readString(seedString); pythia.readFile(inputFile); // Extract settings to be used in the main program. int nEvent = pythia.mode("Main:numberOfEvents"); int nAbort = pythia.mode("Main:timesAllowErrors"); // Initialize. pythia.init(); // Book histograms. TH1F *Hdummy = new TH1F("dummy histo", "dummy histo",10, 0, 1); TVector3 *getMomentum = new TVector3(); TVector3 *getPosition = new TVector3(); int eventID = 0; int nParticles; int particleID[10000]; int parentID[10000]; TClonesArray *fMomentum = new TClonesArray("TVector3"); fMomentum -> BypassStreamer(); TClonesArray& Momentum = *fMomentum; TClonesArray *fPosition = new TClonesArray("TVector3"); fPosition -> BypassStreamer(); TClonesArray& Position = *fPosition; //Make TTree TTree *pythiatree = new TTree("save", "save"); pythiatree -> Branch("eventID", &eventID, "eventID/I"); pythiatree -> Branch("n", &nParticles, "n/I"); pythiatree -> Branch("pdg", particleID, "pdg[n]/I"); pythiatree -> Branch("parent", parentID, "parent[n]/I"); pythiatree -> Branch("pos", &fPosition, 256000, 99); pythiatree -> Branch("mom", &fMomentum, 256000, 99); // Begin event loop. int iAbort = 0; int nMuons = 0; int nPions = 0; int nKaons = 0; for (int iEvent = 0; iEvent < nEvent; ++iEvent) { // Generate events. Quit if many failures. if (!pythia.next()) { if (++iAbort < nAbort) continue; cout << " Event generation aborted prematurely, owing to error!\n"; break; } // Loop over final particles in the event. for (int i = 0; i < event.size(); ++i){ //if (event[i].id() == 2212) { //cout << iEvent << " We got a proton! Energy: " << event[i].e() << " zProd: " << event[i].zDec()/1000 << " Mother1: " << event[event[i].mother1()].id() << endl; //} if(event[i].e() > minEnergy){ if (abs(event[i].id()) == 13) { if(event[i].zProd()/1000 < minZvtxDecay){ nMuons++; //cout << iEvent << " We got a muon! Energy: " << event[i].e() << " zProd: " << event[i].zProd()/1000 << " Mother1: " << event[event[i].mother1()].id() << endl; getMomentum -> SetXYZ(event[i].px(), event[i].py(), event[i].pz()); getPosition -> SetXYZ(event[i].xProd()*cm, event[i].yProd()*cm, event[i].zProd()*cm); nParticles++; particleID[nParticles-1] = event[i].id(); parentID[nParticles-1] = event[event[i].mother1()].id(); new(Momentum[nParticles-1]) TVector3(*getMomentum); new(Position[nParticles-1]) TVector3(*getPosition); //pythiatree -> Fill(); } } /* if (abs(event[i].id()) == 211){ if(event[i].zProd()/1000 < minZvtxDecay && event[i].zDec()/1000 > minZvtxDecay){ //if(event[i].zDec()/1000 > minZvtxDecay){ nPions++; //cout << iEvent << " We got a pion! Energy: " << event[i].e() << " zDec: " << event[i].zDec()/1000 << " zDec: " << event[i].zDec()/1000 << " Mother1: " << event[event[i].mother1()].id() << endl; getMomentum -> SetXYZ(event[i].px(), event[i].py(), event[i].pz()); getPosition -> SetXYZ(event[i].xProd()*cm, event[i].yProd()*cm, event[i].zProd()*cm); nParticles++; particleID[nParticles-1] = event[i].id(); parentID[nParticles-1] = event[event[i].mother1()].id(); new(Momentum[nParticles-1]) TVector3(*getMomentum); new(Position[nParticles-1]) TVector3(*getPosition); //pythiatree -> Fill(); } } if (abs(event[i].id()) == 321){ if(event[i].zProd()/1000 < minZvtxDecay && event[i].zDec()/1000 > minZvtxDecay){ //if(event[i].zDec()/1000 > minZvtxDecay){ nKaons++; //cout << iEvent << " We got a kaon! Energy: " << event[i].e() << " zDec: " << event[i].zDec()/1000 << " Mother1: " << event[event[i].mother1()].id() << endl; getMomentum -> SetXYZ(event[i].px(), event[i].py(), event[i].pz()); getPosition -> SetXYZ(event[i].xProd()*cm, event[i].yProd()*cm, event[i].zProd()*cm); nParticles++; particleID[nParticles-1] = event[i].id(); parentID[nParticles-1] = event[event[i].mother1()].id(); new(Momentum[nParticles-1]) TVector3(*getMomentum); new(Position[nParticles-1]) TVector3(*getPosition); //pythiatree -> Fill(); } } */ } } //fill tree, reset counters if(nParticles>0)pythiatree -> Fill(); eventID++; nParticles = 0.; fMomentum->Clear(); fPosition->Clear(); // End of event loop. } cout << "The total number of muons before dump is " << nMuons << endl; cout << "The total number of pions is " << nPions << endl; cout << "The total number of kaons is " << nKaons << endl; // Final statistics. Normalize and output histograms. pythia.stat(); // Create file on which histogram(s) can be saved. TFile* outFile = new TFile(outputFile, "RECREATE"); // Save histogram on file and close file. pythiatree -> Write(); outFile -> Close(); delete outFile; delete pythiatree; // Done. return 0; }
int main() { Pythia pythia; pythia.readString("Top:all = on"); pythia.readString("Random:setSeed = on"); pythia.readString("Random:seed = 0"); pythia.init(2212, 2212, 7000); pythia.next(); pythia.event.list(); vector<GenParticle> particles(pythia.event.size()); for(int j = 0; j < pythia.event.size(); j++) { particles[j].P[0] = pythia.event[j].e(); particles[j].P[1] = pythia.event[j].px(); particles[j].P[2] = pythia.event[j].py(); particles[j].P[3] = pythia.event[j].pz(); particles[j].V[0] = pythia.event[j].tProd(); particles[j].V[1] = pythia.event[j].xProd(); particles[j].V[2] = pythia.event[j].yProd(); particles[j].V[3] = pythia.event[j].zProd(); particles[j].PDGID = pythia.event[j].id(); particles[j].StatusCode = pythia.event.statusHepMC(j); particles[j].Mothers = pythia.event.motherList(j); particles[j].Daughters = pythia.event.daughterList(j); } GenParticleTree Event(particles, 0, 0); cout << "function InitializeParticles()" << endl; cout << "{" << endl; cout << " ParticleList.length = 0;" << endl; cout << endl; cout << " var NewParticle = new Object();" << endl; cout << " NewParticle.P = new Array(4);" << endl; cout << " NewParticle.V0 = new Array(4);" << endl; cout << endl; for(int i = 0; i < Event.ParticleCount(); i++) { bool WriteOut = false; if(Event[i].StatusCode == 1) WriteOut = true; if(Event[i].Daughters.size() == 0) WriteOut = true; if(Event[i].Daughters.size() > 0 && Event[Event[i].Daughters[0]].V[0] > Event[i].V[0]) WriteOut = true; if(WriteOut == false) continue; cout << setprecision(10); cout << " NewParticle.P[0] = " << Event[i].P[0] << endl; cout << " NewParticle.P[1] = " << Event[i].P[1] << endl; cout << " NewParticle.P[2] = " << Event[i].P[2] << endl; cout << " NewParticle.P[3] = " << Event[i].P[3] << endl; cout << " NewParticle.V0[0] = " << Event[i].V[0] << endl; cout << " NewParticle.V0[1] = " << Event[i].V[1] << endl; cout << " NewParticle.V0[2] = " << Event[i].V[2] << endl; cout << " NewParticle.V0[3] = " << Event[i].V[3] << endl; cout << " NewParticle.PDGID = " << Event[i].PDGID << endl; if(Event[i].Daughters.size() == 0) cout << " NewParticle.Time = 999999" << endl; else cout << " NewParticle.Time = " << Event[Event[i].Daughters[0]].V[0] << endl; cout << " ParticleList[ParticleList.length] = NewParticle.clone()" << endl; cout << endl; } cout << "}" << endl; cout << endl; return 0; }
int main(int argc, char* argv[]) { if (argc < 3) { cerr << " Unexpected number of command-line arguments. \n You are" << " expected to provide a number of events and an output file. \n" << "By default, this executable generates events wil 800<m(ff)<100" << " and no Z'." << "To generate a Z', pass a positive value of Z' mass:" << " -massZp=MASSVALUE" << "To extend the mass range:" << " -mMin=MinMass" << " -mMax=MaxMass" << " Program stopped! " << endl; return 1; } int Nevents = 0; sscanf(argv[1],"%i",&Nevents); string hepmcout(string(argv[2])+".hepmc"); float energy = 14000.; float mMin = 80.; float mMax = 100; float massZp = -99.; for (int i=1;i<argc;i++){ if (strncmp(argv[i],"-setEnergy=",11)==0) sscanf(argv[i],"-setEnergy=%f",&energy); if (strncmp(argv[i],"-massZp=",8)==0) { sscanf(argv[i],"-massZp=%f",&massZp); cout << "WARNING: gamma*/Z/Z' (with Z'mass " << massZp << ") will be generated" << endl; } else { cout << "WARNING: gamma*/Z will be generated" << endl; } if (strncmp(argv[i],"-mMin=",5)==0) sscanf(argv[i],"-mMin=%f",&mMin); if (strncmp(argv[i],"-mMax=",5)==0) sscanf(argv[i],"-mMax=%f",&mMax); } // Interface for conversion from Pythia8::Event to HepMC one. HepMC::I_Pythia8 ToHepMC; // Specify file where HepMC events will be stored. HepMC::IO_GenEvent ascii_io(hepmcout.c_str(), std::ios::out); // Generator. Pythia pythia; char command[512]; if(massZp<0.) { pythia.readString("WeakSingleBoson:ffbar2gmZ = on"); sprintf(command, "PhaseSpace:mHatMin = %f", mMin); pythia.readString(command); sprintf(command, "PhaseSpace:mHatMax = %f", mMax); pythia.readString(command); } else { pythia.readString("NewGaugeBoson:ffbar2gmZZprime = on ! full gamma*/Z^0/Z'^0 production"); sprintf(command, "32:m0 = 1000. ! Z' mass", massZp); pythia.readString(command); sprintf(command, "32:mMin = %f ", mMin); pythia.readString(command); sprintf(command, "32:mMax = %f ", mMax); pythia.readString(command); } // setup energy pythia.init(2212, 2212, energy); // List settings. pythia.settings.listChanged(); // List particle data. pythia.particleData.listChanged(); for (int iEvent = 0; iEvent < Nevents; ++iEvent) { if (!pythia.next()) continue; // Construct new empty HepMC event. HepMC::GenEvent* hepmcevt = new HepMC::GenEvent(); // Fill HepMC event, including PDF info. ToHepMC.fill_next_event( pythia, hepmcevt ); // Write the HepMC event to file. Done with it. ascii_io << hepmcevt; delete hepmcevt; // End of event loop. } // Give statistics. pythia.statistics(); // run Delphes string OUTPUT_ATLAS = string(argv[2])+"_DelphesATLAS.root"; string OUTPUT_CMS = string(argv[2])+"_DelphesCMS.root"; system(string(string("echo ")+string(hepmcout)+string(" >> ")+string(hepmcout)+string(".list")).c_str()); system(string(string("cd Delphes; ./Delphes ")+string(hepmcout)+string(".list ")+OUTPUT_ATLAS+string(" data/DetectorCard_ATLAS.dat data/TriggerCard_ATLAS.dat")).c_str()); system(string(string("cd Delphes; ./Delphes ")+string(hepmcout)+string(".list ")+OUTPUT_CMS+string(" data/DetectorCard_CMS.dat data/TriggerCard_CMS.dat")).c_str()); system(string(string("rm ")+string(hepmcout)+string(".list")).c_str()); // Done. return 0; }