#include "PublicScript.h" #include "TFile.h" #include "TTree.h" #include "TCanvas.h" #include "TROOT.h" #include "TH1F.h" #include "TH2F.h" #include #include "TString.h" #include "TVector3.h" using namespace std; void tree1r(TChain *chainB,TChain *chainV,TString output_filename) { //---------------------------------------------------------- //Initialize both Trees. Initialize functions defined in PublicScript.h //---------------------------------------------------------- InitializeB(chainB); InitializeV(chainV); //---------------------------------------------------------- //For variables used in analysis set branch status to 1. //---------------------------------------------------------- chainB->SetBranchStatus("*",0); chainB->SetBranchStatus("mus_pt",1); chainV->SetBranchStatus("*",0); chainV->SetBranchStatus("procIDSplit",1); TFile *file = new TFile(output_filename.Data(),"RECREATE"); file->cd(); //---------------------------------------------------------- //Histogram Declarations //---------------------------------------------------------- TH1F *h_CSA_id = new TH1F("h_CSA_id","",71,-0.5,70.5); TH1F *h_mu_pt = new TH1F("h_mu_pt","",200,0,200); //---------------------------------------------------------- //Number of events to loop over //---------------------------------------------------------- Int_t nentries = (Int_t)chainB->GetEntries(); cout<<"The number of entries is: "<GetEntry(ia); chainV->GetEntry(ia); if(process_id_min<=procIDSplit&&procIDSplit<=process_id_max) { h_CSA_id->Fill(procIDSplit); //loop over all the muons in one event to get the pt and fill a histogram for(int it = 0;itsize();it++){ h_mu_pt->Fill(mus_pt->at(it)); } } }//end over loop over all the events //--------------------------------------------------------- //Write out root file with histograms //--------------------------------------------------------- file->cd(); file->Write(); }