#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 DelphesAnalysis(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"); Photon *photon; MissingET *misset; Double_t met, etamiss, phimiss, ptph, eph, etaph, phiph; std::vector MET; std::vector ETAmiss; std::vector PHImiss; std::vector PTph; std::vector Eph; std::vector ETAph; std::vector PHIph; /* --------- Creating the DATA file ---------------/ ofstream myfile; myfile.open ("ExtractedData.dat"); ofstream myfile1; ofstream myfile2; myfile1.open ("/home/pdas/Bhupal_TMVA/SignalSP_Photon.dat"); myfile2.open ("/home/pdas/Bhupal_TMVA/SignalSP_MissEt.dat"); /-------------------------------------------------*/ /*------------------ Creates the Branches ------------------------*/ outtree->Branch("PTph", "vector",&PTph); outtree->Branch("Eph", "vector",&Eph); outtree->Branch("ETAph", "vector",&ETAph); outtree->Branch("PHIph", "vector",&PHIph); outtree->Branch("MET", "vector",&MET); outtree->Branch("ETAmiss", "vector",&ETAmiss); outtree->Branch("PHImiss", "vector",&PHImiss); /*-----------------------------------------------------------------*/ // 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 <<"--------- New Event ("<< entry << ") ---------" <GetEntriesFast(); ii++) { misset = (MissingET*) branchMissingET->At(ii); met = misset->MET; etamiss = misset->Eta; phimiss = misset->Phi; MET->push_back(met); ETAmiss->push_back(etamiss); PHImiss->push_back(phimiss); //cout<<"|| MET: "<MET<<" || Eta: "<Eta<<" || Phi: "<Phi<<" || "<MET << "\t" << misset->Eta << "\t" << misset->Phi <<"\n"; } 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; PTph.push_back(ptph); Eph.push_back(eph); ETAph.push_back(etaph); PHIph.push_back(phiph); //cout<<"|| E: "<E<<" || PT: "<PT<<" || Eta: "<Eta<<" || Phi: "<Phi<<" || "<E <<"\t"<< photon->PT <<"\t"<< photon->Eta <<"\t"<Phi<<"\n"; } outtree->Fill(); } outfile->Write(); delete outfile; }