#include #include using namespace std; #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TFrame.h" #include "TH1F.h" #include "TSystem.h" #include "Pythia8/Pythia.h" int main() { #ifdef GZIP bool useGzip = true; #else bool useGzip = false; #endif Int_t id , Id , el , pos; Float_t eng, m, pT, phi, eta , M, PT, Phi, Eta, Eng ; TFile *input = TFile::Open("tutorial13.root","RECREATE"); // if (!output) { return; } std::vector electron ; std::vector positron ; TTree *tree = new TTree("tree","tree"); TTree *tre = new TTree("tre" ,"tre" ); tree->Branch("id" , &id , "id/I" ); tree->Branch("m" , &m , "m/F" ); tree->Branch("pT" , &pT , "pT/F" ); tree->Branch("eta", &eta, "eta/F"); tree->Branch("phi", &phi, "phi/F"); tree->Branch("eng", &eng, "eng/F"); tree->Branch("el" , &el , "el/I" ); tre->Branch("Id" , &Id , "Id/I" ); tre->Branch("M" , &M , "M/F" ); tre->Branch("PT" , &PT , "PT/F" ); tre->Branch("Eta", &Eta, "Eta/F"); tre->Branch("Phi", &Phi, "Phi/F"); tre->Branch("Eng", &Eng, "Eng/F"); tre->Branch("pos", &pos, "pos/F"); Pythia8::Pythia pythia; pythia.readString("23:onMode = off"); pythia.readString("23:onIfMatch = 11 -11 "); pythia.readString("HadronLevel:Hadronize = on"); pythia.readString("Beams:frameType = 4"); if (useGzip) pythia.readString("Beams:LHEF = tutorial8.lhe.gz"); else pythia.readString("Beams:LHEF = tutorial8.lhe"); pythia.init(); Int_t nAbort = 10; Int_t iAbort = 0; for (Int_t iEvent = 0; ; ++iEvent) { if(!pythia.next()) { if (pythia.info.atEndOfFile()) break; if (++iAbort < nAbort) continue; break; } for(Int_t j = 0; j < pythia.event.size(); j++) { el = 0; electron.clear(); if(pythia.event[j].id() == 11) { el = j; id = pythia.event[el].id() ; m = pythia.event[el].m() ; eta = pythia.event[el].eta(); pT = pythia.event[el].pT() ; phi = pythia.event[el].phi(); eng = pythia.event[el].e() ; //electron.emplace_back(el) ; // electron.emplace_back(id) ; electron.emplace_back(eta); electron.emplace_back(pT) ; electron.emplace_back(phi); electron.emplace_back(eng); positron.emplace_back(m) ; tree->Fill(); } } for(Int_t p = 0; p < pythia.event.size(); p++) { pos = 0; positron.clear(); if(pythia.event[p].id() == -11) { pos = p; Id = pythia.event[pos].id() ; M = pythia.event[pos].m() ; Eta = pythia.event[pos].eta(); PT = pythia.event[pos].pT() ; Phi = pythia.event[pos].phi(); Eng = pythia.event[pos].e() ; //positron.emplace_back(pos); //positron.emplace_back(Id); positron.emplace_back(Eta); positron.emplace_back(PT); positron.emplace_back(Phi); positron.emplace_back(Eng); positron.emplace_back(m); /* cout << "Output of begin and end: " << endl; for (auto b = positron.begin(); b != positron.end(); ++b) cout << *b << " " << endl;*/ tre->Fill(); } } } input->Write(); delete input; } /* tree->Branch("id" , &id , "id/I" ); tree->Branch("m" , &m , "m/F" ); tree->Branch("pT" , &pT , "pT/F" ); tree->Branch("eta", &eta, "eta/F"); tree->Branch("phi", &phi, "phi/F"); tree->Branch("eng", &eng, "eng/F"); tree->Branch("el" , &el, "ele/I"); tre->Branch("Id" , &Id , "Id/I" ); tre->Branch("M" , &M , "M/F" ); tre->Branch("PT" , &PT , "PT/F" ); tre->Branch("Eta", &Eta, "Eta/F"); tre->Branch("Phi", &Phi, "Phi/F"); tre->Branch("Eng", &Eng, "Eng/F"); tre->Branch("pos",&pos, "pos/F"); tree->Branch("id" , &id , "id/I" ); tree->Branch("m" , &m , "m/D" ); tree->Branch("pT" , &pT , "pT/D" ); tree->Branch("eta", &eta, "eta/D"); tree->Branch("phi", &phi, "phi/D"); tree->Branch("eng", &eng, "eng/D"); tree->Branch("el" , &el , "el/I"); tre->Branch("Id" , &Id , "Id/I" ); tre->Branch("M" , &M , "M/D" ); tre->Branch("PT" , &PT , "PT/D" ); tre->Branch("Eta", &Eta, "Eta/D"); tre->Branch("Phi", &Phi, "Phi/D"); tre->Branch("Eng", &Eng, "Eng/D"); tre->Branch("pos", &pos, "pos/I");*/