#ifdef __CLING__ R__LOAD_LIBRARY(libDelphes) #include "classes/DelphesClasses.h" #include "external/ExRootAnalysis/ExRootTreeReader.h" #include "external/ExRootAnalysis/ExRootResult.h" #include "external/ExRootAnalysis/ExRootTreeBranch.h" #include "external/ExRootAnalysis/ExRootTreeWriter.h" #include "external/ExRootAnalysis/ExRootFilter.h" #else class ExRootTreeReader; class ExRootResult; class ExRootTreeBranch; class ExRootTreeWriter; class ExRootFilter; #endif #include #include #include #include #include #include #include "TH1.h" // for histrograming #include "TH2D.h" #include "TH1F.h" #include "TH2F.h" //#include "TVirtualPad.h" #include "TApplication.h" #include "TBranch.h" #include "TBranchElement.h" #include "TFile.h" // ROOT, for saving file. #include #include "TTree.h" //for Tree file #include "TROOT.h" //------------------------------------------------------------------------------ void WithoutVectorArray(const char *inputFile, const char *outputFile) { gSystem->Load("libDelphes"); // Create chain of root trees TChain chain("Delphes"); chain.Add(inputFile); // Creating the output file and tree TFile *outfile = new TFile(outputFile,"RECREATE"); TTree *outtree=new TTree("eventtree","Test"); // Create object of class ExRootTreeReader ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); cout << "** Chain contains " << numberOfEntries << " events **" << endl; //To see the total number of events ExRootResult *result = new ExRootResult(); // Get pointers to branches used in this analysis TClonesArray *branchPhoton = treeReader->UseBranch("Photon"); TClonesArray *branchMissingET = treeReader->UseBranch("MissingET"); //TH1 *histPhotonPT = new TH1F("photon_pt", "photon P_{T}", 100, 0.0, 500.0); Photon *photon; MissingET *misset; Double_t MET, ETAmiss, PHImiss, PTph, Eph, ETAph, PHIph; /* --------- Creating the DATA file ---------------*/ ofstream myfile; myfile.open ("/home/pdas/ExtractedData.dat"); /*-------------------------------------------------*/ //ofstream myfile1; //myfile1.open ("/home/pdas/Bhupal_TMVA/SignalSP_Photon.dat"); /*------------------ Creates the Branches ------------------------*/ outtree->Branch("PTph",&PTph); outtree->Branch("Eph",&Eph); outtree->Branch("ETAph",&ETAph); outtree->Branch("PHIph",&PHIph); outtree->Branch("MET",&MET); outtree->Branch("ETAmiss",&ETAmiss); outtree->Branch("PHImiss",&PHImiss); /*-----------------------------------------------------------------*/ //if(branchPhoton->GetEntriesFast()!=0){ // Loop over all events for(Int_t entry = 0; entry < numberOfEntries; ++entry) { // Load selected branches with data from specified event treeReader->ReadEntry(entry); // if(entry>10) break; cout<<""<GetEntriesFast() > 0) { for(Int_t i=0; i < branchPhoton->GetEntriesFast(); i++) { photon = (Photon*) branchPhoton->At(i); PTph = photon->PT; Eph = photon->E; ETAph = photon->Eta; PHIph = photon->Phi; cout<<"|| E: "<E<<" || PT: "<PT<<" || Eta: "<Eta<<" || Phi: "<Phi<<" || "<Fill(); myfile << photon->E <<"\t"<< photon->PT <<"\t"<< photon->Eta <<"\t"<Phi<<"\t"; } } else { myfile << "NaN" <<"\t"<< "NaN" <<"\t"<< "NaN" <<"\t"<< "NaN" <<"\t"; } // loop over all MissingETs in the event for(Int_t ii=0; ii < branchMissingET->GetEntriesFast(); ii++) { misset = (MissingET*) branchMissingET->At(ii); MET = misset->MET; ETAmiss = misset->Eta; PHImiss = misset->Phi; cout<<"|| MET: "<MET<<" || Eta: "<Eta<<" || Phi: "<Phi<<" || "<MET << "\t" << misset->Eta << "\t" << misset->Phi <<"\n"; //outtree->Fill(); } /* // If event contains at least 1 Photon if(branchPhoton->GetEntries() > 0) { photon = (Photon*) branchPhoton->At(0); PTph = photon->PT; Eph = photon->E; ETAph = photon->Eta; PHIph = photon->Phi; // Plot photon transverse momentum // histPhotonPT->Fill(photon->PT); //outtree->Fill(); // Print photon transverse momentum // myfile1 << photon->PT <<"\t"<< photon->E << endl; outtree->Fill(); }*/ outtree->Fill(); } //histPhotonPT->Draw(); outfile->Write(); delete outfile; }