#include "header.h" #include "external/ExRootAnalysis/ExRootTreeReader.h" #include "external/ExRootAnalysis/ExRootResult.h" #include "external/ExRootAnalysis/ExRootTreeWriter.h" //#include "ExRootAnalysis/ExRootClasses.h" //#ifdef __CLING__ //R__LOAD_LIBRARY(libDelphes) #include "classes/DelphesClasses.h" //#endif int main(int argc, char** argv) //int root_root_converter_new() { //main() starts if((argc >1 && argc <=3)) cout<<"Wow! Right number of arguments provided for execution ="<Load("libDelphes"); gSystem->Load("~/RESEARCH/EVENT_GENERATORS/MADGRAPH5/MG5_aMC_v2_6_1/ExRootAnalysis/libExRootAnalysis.so"); gSystem->Load("libPhysics"); gSystem->Load("libMathCore"); */ /* TString infile = "NP_pp2tj_infile.root"; TString outfile = "test_new.root"; */ TString infile = argv[1]; // input file name TString outfile = argv[2]; // output file name cout<<"Wow! Input file we have is = argv[1]= "<Add(infile); TRandom3 rnd; // Create object of class ExRootTreeReader ExRootTreeReader *treeReader1 = new ExRootTreeReader(chain1);//declare treeReader, the class to read the specific root file Long64_t numberOfEntries = chain1->GetEntries(); //cout<<" The total N events is "<UseBranch("Event"); //branch Event in the class TClonesArray *branchGenParticle = treeReader1->UseBranch("Particle"); //branch GenParticle( all particles) in the event TClonesArray *branchJet = treeReader1->UseBranch("Jet"); //Recon jet TClonesArray *branchElectron = treeReader1->UseBranch("Electron"); //Recon ele TClonesArray *branchMissingET = treeReader1->UseBranch("MissingET"); //Recon jet TClonesArray *branchMuon = treeReader1->UseBranch("Muon"); //Recon muon // fastjet::JetDefinition *antikt = new fastjet::JetDefinition(fastjet::antikt_algorithm, 0.4,fastjet::E_scheme,fastjet::Best);//declare the fast jet algorithm // std::vector fjInputs;//declare the fast jet vector TFile *file=new TFile(outfile,"recreate");//declare the out put file TTree * TreeS=new TTree("TreeS","TreeS");//out file trees //////Defining containers for output file double weight=0; std::vector ele_pos_pt; std::vector ele_pos_eta; std::vector ele_pos_phi; std::vector ele_pos_e; double ele_pos_charge=0; std::vector muon_pos_pt; std::vector muon_pos_eta; std::vector muon_pos_phi; std::vector muon_pos_e; double muon_pos_charge=0; double met_x=0; double met_y=0; double met_phi=0; double met_et=0; //just connect the variables above to the tree in the output file TreeS->Branch("weight",&weight); TreeS->Branch("ele_pos_pt", &ele_pos_pt); TreeS->Branch("ele_pos_eta",&ele_pos_eta); TreeS->Branch("ele_pos_phi",&ele_pos_phi); TreeS->Branch("ele_pos_e",&ele_pos_e); TreeS->Branch("ele_pos_charge",&ele_pos_charge); TreeS->Branch("muon_pos_pt", &muon_pos_pt); TreeS->Branch("muon_pos_eta",&muon_pos_eta); TreeS->Branch("muon_pos_phi",&muon_pos_phi); TreeS->Branch("muon_pos_e",&muon_pos_e); TreeS->Branch("muon_pos_charge",&muon_pos_charge); TreeS->Branch("met_x",&met_x); TreeS->Branch("met_y",&met_y); TreeS->Branch("met_phi",&met_phi); TreeS->Branch("met_et",&met_et); //now start the event loop Long64_t evt=0; for(evt=0; evtGetEntry(evt); //************************************************************** //Getting into Electron branch Electron *reconele; Int_t nnele=Int_t(chain1->GetLeaf("Electron_size")->GetValue()); double maxelpt=0; for(int j=0; jAt(j); if(!reconele)continue; // if(reconele->Charge==-1 || reconele->Charge==1) if(reconele->Charge==1) { ele_pos_charge=reconele->Charge; TLorentzVector tmpreconele; tmpreconele.SetPtEtaPhiM(reconele->PT,reconele->Eta,reconele->Phi,0.00051); if(tmpreconele.Pt()>maxelpt) { maxelpt=tmpreconele.Pt(); //cout<GetLeaf("Muon_size")->GetValue()); double maxmupt=0; for(int j=0; jAt(j); if(!reconmuon)continue; if(reconmuon->Charge==1) { muon_pos_charge=reconmuon->Charge; TLorentzVector tmpreconmuon; tmpreconmuon.SetPtEtaPhiM(reconmuon->PT,reconmuon->Eta,reconmuon->Phi,0.105); if(tmpreconmuon.Pt()>maxmupt) { maxmupt=tmpreconmuon.Pt(); muon_pos_pt.push_back(tmpreconmuon.Pt()); muon_pos_eta.push_back(tmpreconmuon.Eta()); muon_pos_phi.push_back(tmpreconmuon.Phi()); muon_pos_e.push_back(tmpreconmuon.E()); } } } //************************************************************** //Getting into MissingET branch MissingET *reconmet=(MissingET*) branchMissingET->At(0); TLorentzVector tmpreconmet; tmpreconmet.SetPtEtaPhiM(reconmet->MET,0,reconmet->Phi,reconmet->MET); met_x=tmpreconmet.Px(); met_y=tmpreconmet.Py(); met_phi=tmpreconmet.Phi(); met_et=tmpreconmet.Pt(); */ //************************************************************** TreeS->Fill();//important, in each event Fill the content above }//event loop ends TreeS->Write(); //write all the content to the file; file->Close(); //close file properly. // delete TreeS; // Result screen output: cout<<" The total N input events are = "<