int writetree_pp(char *ksp = "ppJet40"){ timer.Start(); LoadLib(); TString inname=""; if(strcmp(ksp,"ppJet40")==0)inname = "/hadoop/store/user/belt/hiForest2/PP2013_HiForest_PromptReco_JSon_Jet40Jet60_ppTrack_forestv84.root"; else if(strcmp(ksp,"ppJet80")==0)inname = "/hadoop/store/user/belt/hiForest2/PP2013_HiForest_PromptReco_JsonPP_Jet80_PPReco_forestv82.root"; //! Load Lib //gSystem->Load("/afs/cern.ch/user/p/pawan/scratch0/CMSSW_6_2_0/src/work/pPb/HiForest/V3/hiForest_h.so"); //! Define the input file and HiForest //! CMSSW_5_3_3 HiForest *c = new HiForest(inname,Form("Forest%s",ksp),cPP); cout<<"Loaded the hiforest tree : "<<c->GetName()<<endl; ShutoffBranches(c); TFile *fout = new TFile(Form("ntuple_2013_%s_v2.root",ksp),"RECREATE"); std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<Form("Running for %s ",ksp)<<std::endl; std::cout<<Form("pT cut for %0.3f ",kptrecocut)<<std::endl; std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl; std::cout<<"My hiForest Tree : " <<c->GetName()<<"\t Entries "<<c->GetEntries()<<std::endl; std::cout<<"Output file "<<fout->GetName()<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; //! shut off jet trees //c->hasAk2CaloJetTree=0; //c->hasAk4CaloJetTree=0; //c->hasAk3CaloJetTree=0; //c->hasAk5CaloJetTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->hasAkPu3CaloJetTree=0; //c->hasAkPu5CaloJetTree=0; //c->hasAk2PFJetTree=0; //c->hasAk4PFJetTree=0; //c->hasAk5PFJetTree=0; //c->hasAkPu2PFJetTree=0; //c->hasAkPu4PFJetTree=0; //c->hasAkPu5PFJetTree=0; c->hasTrackTree=0; //! For jets //Jets *mJets2 = 0; Jets *mJets3 = 0; Jets *mJets4 = 0; Long64_t nentries = c->GetEntries(); std::cout<<Form("# of entries in TTree for %s : ",ksp)<<nentries<<std::endl; //TTree *jetR2Tree = new TTree("jetR2","ak2PF"); TTree *jetR3Tree = new TTree("jetR3","ak3PF"); TTree *jetR4Tree = new TTree("jetR4","ak4PF"); TTree *evtTree = new TTree("evt","evt"); // declare the event variables. int evt; int run; float vx; float vy; float vz; int jet40; int jet60; int jet80; int jet100; int ntrk; // declare the jet variables /* int nrefe2; float pt2[1000]; float raw2[1000]; float eta2[1000]; float phi2[1000]; float chMax2[1000]; float trkMax2[1000]; float chSum2[1000]; float phSum2[1000]; float neSum2[1000]; float trkSum2[1000]; float phMax2[1000]; float neMax2[1000]; */ int nrefe3; float pt3[1000]; float raw3[1000]; float eta3[1000]; float phi3[1000]; float chMax3[1000]; float trkMax3[1000]; float chSum3[1000]; float phSum3[1000]; float neSum3[1000]; float trkSum3[1000]; float phMax3[1000]; float neMax3[1000]; int nrefe4; float pt4[1000]; float raw4[1000]; float eta4[1000]; float phi4[1000]; float chMax4[1000]; float trkMax4[1000]; float chSum4[1000]; float phSum4[1000]; float neSum4[1000]; float trkSum4[1000]; float phMax4[1000]; float neMax4[1000]; //set the branches in the trees. evtTree->Branch("evt",&evt,"evt/I"); evtTree->Branch("run",&run,"run/I"); evtTree->Branch("vx",&vx,"vx/F"); evtTree->Branch("vy",&vy,"vy/F"); evtTree->Branch("vz",&vz,"vz/F"); evtTree->Branch("jet40",&jet40,"jet40/I"); evtTree->Branch("jet60",&jet60,"jet60/I"); evtTree->Branch("jet80",&jet80,"jet80/I"); evtTree->Branch("jet100",&jet100,"jet100/I"); evtTree->Branch("ntrk",&ntrk,"ntrk/I"); /* jetR2Tree->Branch("nrefe",&nrefe2,"nrefe/I"); jetR2Tree->Branch("pt",&pt2,"pt[nrefe]/F"); jetR2Tree->Branch("raw",&raw2,"raw[nrefe]/F"); jetR2Tree->Branch("eta",&eta2,"eta[nrefe]/F"); jetR2Tree->Branch("phi",&phi2,"phi[nrefe]/F"); jetR2Tree->Branch("chMax",&chMax2,"chMax[nrefe]/F"); jetR2Tree->Branch("trkMax",&trkMax2,"trkMax[nrefe]/F"); jetR2Tree->Branch("phMax",&phMax2,"phMax[nrefe]/F"); jetR2Tree->Branch("neMax",&neMax2,"neMax[nrefe]/F"); jetR2Tree->Branch("chSum",&chSum2,"chSum[nrefe]/F"); jetR2Tree->Branch("phSum",&phSum2,"phSum[nrefe]/F"); jetR2Tree->Branch("neSum",&neSum2,"neSum[nrefe]/F"); jetR2Tree->Branch("trkSum",&trkSum2,"trkSum[nrefe]/F"); */ jetR3Tree->Branch("nrefe",&nrefe3,"nrefe/I"); jetR3Tree->Branch("pt",&pt3,"pt[nrefe]/F"); jetR3Tree->Branch("raw",&raw3,"raw[nrefe]/F"); jetR3Tree->Branch("eta",&eta3,"eta[nrefe]/F"); jetR3Tree->Branch("phi",&phi3,"phi[nrefe]/F"); jetR3Tree->Branch("chMax",&chMax3,"chMax[nrefe]/F"); jetR3Tree->Branch("trkMax",&trkMax3,"trkMax[nrefe]/F"); jetR3Tree->Branch("phMax",&phMax3,"phMax[nrefe]/F"); jetR3Tree->Branch("neMax",&neMax3,"neMax[nrefe]/F"); jetR3Tree->Branch("chSum",&chSum3,"chSum[nrefe]/F"); jetR3Tree->Branch("phSum",&phSum3,"phSum[nrefe]/F"); jetR3Tree->Branch("neSum",&neSum3,"neSum[nrefe]/F"); jetR3Tree->Branch("trkSum",&trkSum3,"trkSum[nrefe]/F"); jetR4Tree->Branch("nrefe",&nrefe4,"nrefe/I"); jetR4Tree->Branch("pt",&pt4,"pt[nrefe]/F"); jetR4Tree->Branch("raw",&raw4,"raw[nrefe]/F"); jetR4Tree->Branch("eta",&eta4,"eta[nrefe]/F"); jetR4Tree->Branch("phi",&phi4,"phi[nrefe]/F"); jetR4Tree->Branch("chMax",&chMax4,"chMax[nrefe]/F"); jetR4Tree->Branch("trkMax",&trkMax4,"trkMax[nrefe]/F"); jetR4Tree->Branch("phMax",&phMax4,"phMax[nrefe]/F"); jetR4Tree->Branch("neMax",&neMax4,"neMax[nrefe]/F"); jetR4Tree->Branch("chSum",&chSum4,"chSum[nrefe]/F"); jetR4Tree->Branch("phSum",&phSum4,"phSum[nrefe]/F"); jetR4Tree->Branch("neSum",&neSum4,"neSum[nrefe]/F"); jetR4Tree->Branch("trkSum",&trkSum4,"trkSum[nrefe]/F"); for (Long64_t ievt=0; ievt<nentries;ievt++) {//! event loop //for (Long64_t ievt=0; ievt<100;ievt++) {//! event loop //! load the hiForest event c->GetEntry(ievt); bool evSel = false; evSel = fabs(c->evt.vz)<15. && c->skim.pHBHENoiseFilter && c->skim.pPAcollisionEventSelectionPA && (c->hlt.HLT_PAJet40_NoJetID_v1 || c->hlt.HLT_PAJet60_NoJetID_v1 || c->hlt.HLT_PAJet80_NoJetID_v1 || c->hlt.HLT_PAJet100_NoJetID_v1); if(!evSel)continue; run = c->evt.run; evt = c->evt.evt; vx = c->evt.vx; vy = c->evt.vy; vz = c->evt.vz; jet40 = c->hlt.HLT_PAJet40_NoJetID_v1; jet60 = c->hlt.HLT_PAJet60_NoJetID_v1; jet80 = c->hlt.HLT_PAJet80_NoJetID_v1; jet100 = c->hlt.HLT_PAJet100_NoJetID_v1; ntrk = c->evt.hiNtracks; if(ievt%10000 == 0) cout<<" ******** Event # "<< ievt <<"\t Run " <<run<<endl; /* mJets2 = &(c->ak2PF); nrefe2 = mJets2->nref; for (int i = 0; i<nrefe2; i++) { pt2[i] = mJets2->jtpt[i]; eta2[i] = mJets2->jteta[i]; phi2[i] = mJets2->jtphi[i]; raw2[i] = mJets2->rawpt[i]; chMax2[i] = mJets2->chargedMax[i]; trkMax2[i] = mJets2->trackMax[i]; chSum2[i] = mJets2->chargedSum[i]; phSum2[i] = mJets2->photonSum[i]; neSum2[i] = mJets2->neutralSum[i]; trkSum2[i] = mJets2->trackSum[i]; phSum2[i] = mJets2->photonMax[i]; neMax2[i] = mJets2->neutralMax[i]; } */ mJets3 = &(c->ak3PF); nrefe3 = mJets3->nref; for (int i = 0; i<nrefe3; i++) { pt3[i] = mJets3->jtpt[i]; eta3[i] = mJets3->jteta[i]; phi3[i] = mJets3->jtphi[i]; raw3[i] = mJets3->rawpt[i]; chMax3[i] = mJets3->chargedMax[i]; trkMax3[i] = mJets3->trackMax[i]; chSum3[i] = mJets3->chargedSum[i]; phSum3[i] = mJets3->photonSum[i]; neSum3[i] = mJets3->neutralSum[i]; trkSum3[i] = mJets3->trackSum[i]; phSum3[i] = mJets3->photonMax[i]; neMax3[i] = mJets3->neutralMax[i]; } mJets4 = &(c->ak4PF); nrefe4 = mJets4->nref; for (int i = 0; i<nrefe4; i++) { pt4[i] = mJets4->jtpt[i]; eta4[i] = mJets4->jteta[i]; phi4[i] = mJets4->jtphi[i]; raw4[i] = mJets4->rawpt[i]; chMax4[i] = mJets4->chargedMax[i]; trkMax4[i] = mJets4->trackMax[i]; chSum4[i] = mJets4->chargedSum[i]; phSum4[i] = mJets4->photonSum[i]; neSum4[i] = mJets4->neutralSum[i]; trkSum4[i] = mJets4->trackSum[i]; phSum4[i] = mJets4->photonMax[i]; neMax4[i] = mJets4->neutralMax[i]; } evtTree->Fill(); //jetR2Tree->Fill(); jetR3Tree->Fill(); jetR4Tree->Fill(); } fout->cd(); fout->Write(); fout->Close(); // time out: timer.Stop(); float rtime = timer.RealTime(); float ctime = timer.CpuTime(); cout<<"\t"<<endl; cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<endl; cout<<"\t"<<endl; cout<<"Good bye : " <<"\t"<<endl; return 0; }
int IndResponse5TeVOnFlyForest(double kPt=30,const char *ksp="ppb",int ifile=0) { timer.Start(); //! Load Lib gSystem->Load("../HiForest_V3/hiForest_h.so"); //! Load the hiforest input root file HiForest *c = 0; //! Latest // if(strcmp(ksp,"ppb")==0)c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod13/Hijing_Pythia_pt%.f/HiForest_v72_v01_merged01/pt%.f_prod13_v72_merged_forest_%d.root",kPt,kPt,ifile),"PythiaHijing",cPPb); // if(strcmp(ksp,"ppb")==0)c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Hijing_Pythia_pt%.f/HiForest_v77_merged01/pt%.f_HP04_prod16_v77_merged_forest_%d.root",kPt,kPt,ifile),"PythiaHijing",cPPb); if(strcmp(ksp,"ppb")==0)c = new HiForest(Form("/mnt/hadoop/cms/store/user/kjung/pPb_Full_BTagForestMerged/pPb_Full_BTagForest%.f_Fix3output.root", kPt),"PythiaHijing",cPPb); // if(strcmp(ksp,"ppb")==0)c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod25/HiForest_v85_merged01/pt%.f_HP04_prod25_v85_merged_forest_%d.root", kPt,ifile),"PythiaHijing",cPPb); // else if(strcmp(ksp,"pbp")==0)c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/Pbp/HP05/prod24/Hijing_Pythia_pt%.f/HiForest_v84_merged02/pt%.f_HP05_prod24_v84_merged_forest_%d.root",kPt,kPt,ifile),"HijingPythia",cPPb); // else if(strcmp(ksp,"pbp")==0) c = new HiForest(Form("/mnt/hadoop/cms/store/user/kjung/PbpMC/HP06/mergedPthat%.f/PbpJEC_pthat%.f_outputMerged.root",kPt,kPt),"HijingPythia",cPPb); // else if(strcmp(ksp,"pbp")==0) c = new HiForest(Form("/mnt/hadoop/cms/store/user/kjung/PbpMC/HP08/MergedFiles/pthat%.foutputMerged.root",kPt),"HijingPythia",cPPb); else if(strcmp(ksp,"pbp")==0) c = new HiForest(Form("/net/hidsk0001/d00/scratch/maoyx/pPb/CMSSW_5_3_8_HI_patch2/src/MNguyen/combinePtHatBins/CorrPbpJet%.f.root",kPt),"HijingPythia",cPPb); else { c = new HiForest(Form("/mnt/hadoop/cms/store/user/kjung/pPbForest/Signal_Pythia_pt%.f/merged/pt%.f_HP04_prod16_v77_merged_forest_Sum.root",kPt,kPt),"Pythia",cPPb); // if(kPt==280)c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP03/prod10/Signal_Pythia_pt%0.0f/HiForest_v63_v02_merged03/pt%0.0f_HP03_prod09_merged_forest_%d.root",kPt,kPt,ifile),"Pythia",cPPb); // else c = new HiForest(Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP03/prod10/Signal_Pythia_pt%0.0f/HiForest_v63_merged03/pt%0.0f_HP03_prod09_merged_forest_%d.root",kPt,kPt,ifile),"Pythia",cPPb); } double xsection=0; double xup=0; double xsub=0; double maxpthat=9999; if(kPt==15){ maxpthat=30; xup =5.335e-01; xsub=3.378e-02; } else if(kPt==30){ maxpthat=50; xup =3.378e-02; xsub=3.778e-03; } else if(kPt==50){ maxpthat=80; // maxpthat=9999; xup =3.778e-03; // xsub=0; xsub=4.412e-04; } else if(kPt==80){ maxpthat=120; xup =4.412e-04; xsub=6.147e-05; } else if(kPt==120){ maxpthat=170; xup=6.147e-05; xsub=1.018e-05; }else if(kPt==170){ maxpthat=220; xup=1.018e-05; xsub=2.477e-06; }else if(kPt==220){ maxpthat=280; xup =2.477e-06; xsub=6.160e-07; }else if(kPt==280){ maxpthat=9999; xup =6.160e-07; xsub=0; } /* maxpthat=370; xup =6.160e-07; xsub=1.088e-07; }else if(kPt==370){ maxpthat=9999; xup=1.088e-07; xsub=0; } */ xsection = xup-xsub; std::cout<<std::endl; std::cout<<std::endl; /* const int knj = 25; const char *cjets[knj] = {"icPu5", "ak1PF","ak2PF","ak3PF","ak4PF","ak5PF","ak6PF", "akPu1PF","akPu2PF","akPu3PF","akPu4PF","akPu5PF","akPu6PF", "ak1Calo","ak2Calo","ak3Calo","ak4Calo","ak5Calo","ak6Calo", "akPu1Calo","akPu2Calo","akPu3Calo","akPu4Calo","akPu5Calo","akPu6Calo"}; const char *calgo[knj] = {"icPu5", "ak1PF","ak2PF","ak3PF","ak4PF","ak5PF","ak6PF", "akPu1PF","akPu2PF","akPu3PF","akPu4PF","akPu5PF","akPu6PF", "ak1Calo","ak2Calo","ak3Calo","ak4Calo","ak5Calo","ak6Calo", "akPu1Calo","akPu2Calo","akPu3Calo","akPu4Calo","akPu5Calo","akPu6Calo"}; */ const int knj = 12; const char *cjets[knj] = {"ak3PF","ak4PF","ak5PF", "akPu3PF","akPu4PF","akPu5PF", "ak3Calo","ak4Calo","ak5Calo", "akPu3Calo","akPu4Calo","akPu5Calo"}; const char *calgo[knj] = {"ak3PF","ak4PF","ak5PF", "akPu3PF","akPu4PF","akPu5PF", "ak3Calo","ak4Calo","ak5Calo", "akPu3Calo","akPu4Calo","akPu5Calo"}; c->hasIcPu5JetTree=0; c->hasAk1PFJetTree=0; c->hasAk6PFJetTree=0; c->hasAkPu1PFJetTree=0; c->hasAkPu6PFJetTree=0; c->hasAk1CaloJetTree=0; c->hasAk6CaloJetTree=0; c->hasAkPu1CaloJetTree=0; c->hasAkPu6CaloJetTree=0; /* c->hasMetTree=0; c->hasPFTree=0; c->hasIcPu5JetTree=0; c->hasAkPu2JetTree=0; c->hasAkPu3JetTree=0; c->hasAkPu4JetTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->hasHltTree=0; c->hasTrackTree=0; c->hasPixTrackTree=0; c->hasSkimTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasPhotonTree=0; */ //! To get the jet object from hiforest Jets *iJet=0; std::cout<<"Loaded all tree variables and # of jet algorithms : "<<knj<<std::endl; std::cout<<"\t"<<std::endl; //! Open a output file for histos // TFile *fout = new TFile(Form("Output/Response_%s_HP04_prod25_v85_pT%0.0fGeV_%d.root",ksp,kPt,ifile),"RECREATE"); TFile *fout = new TFile(Form("Output/Response_%s_HP08_OnFlyForest_JECv17_pT%0.0fGeV.root",ksp,kPt),"RECREATE"); std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<Form("Running for %s ",ksp)<<std::endl; std::cout<<Form("pT cut for %0.3f ",kptrecocut)<<std::endl; std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl; std::cout<<"My hiForest TTree : " <<c->GetName()<<std::endl; std::cout<<"Output file "<<fout->GetName()<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; //! //! Define histograms here TH1::SetDefaultSumw2(); TH2::SetDefaultSumw2(); TProfile::SetDefaultSumw2(); //////////////////////////////////////////////////////////////////////////////////////////////////////// TH1F *hEvt = new TH1F("hEvt","# of events ",4,0,4); TH1F *hVz = new TH1F("hVz","# of events ",80,-20,20); TH1F *hBin = new TH1F("hBin","Centrality bin",100,-0.5,100-0.5); TH1F *hTotEve = new TH1F("hTotEve","# of events in the skimmed files",4,0,4); TH1F *hHF = new TH1F("hHF","HF distribution",500,0,500); TH1F *hNTracks = new TH1F("hNTracks","hiNTracks",500,0,500); TH2F *hNTracksHF = new TH2F("hNTracksHF","Ntrack vs HF ",500,0,500,500,0,500); TH2F *hBinHF = new TH2F("hBinHF","HF vs hiBin",100,-0.5,100-0.5,500,0,500); TH2F *hBinNTracks = new TH2F("hBinNTracks","HF vs NTracks",100,-0.5,100-0.5,500,0,500); TH2F *hNTracksHFplusEta4 = new TH2F("hNTracksHFplusEta4","NTracks vs HFplusEta4",500,0,500, 500, 0., 500); TH1F *hgenpt_genm [knj][nmult], *hrecopt_genm[knj][nmult], *hrawpt_genm[knj][nmult]; TH1F *hjeteta [knj][nmult], *hjetphi[knj][nmult]; TH2F *hjetpteta[knj][nmult], *hjetptphi[knj][nmult], *hjetetaphi[knj][nmult]; //! Ratios of the pt distributions TProfile *hrecogen[knj][nmult], *hrecoraw[knj][nmult], *hrawgen[knj][nmult]; //! Resposnse TH2F *hrescrpt_genm[knj][nmult], *hresrrpt_genm[knj][nmult], *hresrcrpt_genm[knj][nmult]; TH2F *hrescreta_genm[knj][nmult], *hresrreta_genm[knj][nmult], *hresrcreta_genm[knj][nmult]; TH2F *hratiorawrefpt_eta[knj][nmult][2], *hratiocorrrefpt_eta[knj][nmult][2]; TH2F *hratiocorrrefpt_genm[knj][nmult]; TH2F *hratiocorrrefpt_lead[knj][nmult], *hratiocorrrefpt_slead[knj][nmult]; TH2F *hratiocorrrefpt_genhfb[knj][nhfbin]; TH2F *hratiocorrrefpt_etaptbin[knj][bins]; TH2F *hratiorawrefpt_etaptbin[knj][bins]; //! For comparison with data TH2F *hJetEnergyScale[knj][nmult]; TH2F *hpteta[knj][nmult][maxe] ; TH2F *hptphi[knj][nmult][maxph] ; TH2F *hgenjrecoj[knj][nmult]; TH1F *hNjets_genm[knj][nmult]; TH1F *hNevt [knj][nmult]; //! Background for jets //! (photonSum+neutralSum+chargedSum-rawpt) TH2F *hjetptpu_genm[knj][nmult]; //! centrality TH2F *hjetptpu_etab_genm[knj][nmult][ketar]; //! eta dependence TH1F *hjetbkgd_genm[knj][nmult]; TH2F *hjetptbkgd_genm[knj][nmult]; TH2F *hjetptbkgd_etab_genm[knj][nmult][ketar]; TH2F *hPFFraction_genm[knj][nmult][3]; //! Efficency histos TH1F *hPtAll [knj][nmult], *hPtSel[knj][nmult]; TH1F *hEtaAll[knj][nmult], *hEtaSel[knj][nmult]; TH1F *hPhiAll[knj][nmult], *hPhiSel[knj][nmult]; //! Response vs deltar TH1F *hRspVsDeltaR[knj][nmult][25]; //! DeltaR efficiency TH1F *hDeltaR[knj][nmult]; TH1F *hDeltaRAll[knj][nmult]; TH1F *hDeltaRSel[knj][nmult]; for(int nj=0;nj<knj;nj++){ for(int icen=0;icen<nmult;icen++){ hNevt [nj][icen] = new TH1F(Form("hNevt%d_%d",nj,icen),Form("# of events cent %d %s",icen,cjets[nj]),40,-40,40); hNjets_genm [nj][icen] = new TH1F(Form("hNjets_genm%d_%d",nj,icen),Form("# of jets cent %d jets %s",icen,cjets[nj]),200,30,630); hgenpt_genm [nj][icen] = new TH1F(Form("hgenpt_genm%d_%d",nj,icen),Form("Gen matched gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrecopt_genm[nj][icen] = new TH1F(Form("hrecopt_genm%d_%d",nj,icen),Form("Gen matched reco p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrawpt_genm [nj][icen] = new TH1F(Form("hrawpt_genm%d_%d",nj,icen),Form("Gen matched raw p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); //! Ratios hrecogen[nj][icen] = new TProfile(Form("hrecogen%d_%d",nj,icen),Form("reco/gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrecoraw[nj][icen] = new TProfile(Form("hrecoraw%d_%d",nj,icen),Form("reco/raw p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrawgen[nj][icen] = new TProfile(Form("hrawgen%d_%d",nj,icen),Form("raw/gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); //! Gen matched hrescrpt_genm[nj][icen]= new TH2F(Form("hrescrpt_genm%d_%d",nj,icen),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hresrrpt_genm[nj][icen]= new TH2F(Form("hresrrpt_genm%d_%d",nj,icen),Form("Gen jet:(Raw/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hresrcrpt_genm[nj][icen]= new TH2F(Form("hresrcrpt_genm%d_%d",nj,icen),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hrescreta_genm[nj][icen]= new TH2F(Form("hrescreta_genm%d_%d",nj,icen),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),100,-5.0,5.0,150,rbinl,rbinh); hresrreta_genm[nj][icen]= new TH2F(Form("hresrreta_genm%d_%d",nj,icen),Form("Gen jet:(Raw/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),100,-5.0,5.0,150,rbinl,rbinh); hresrcreta_genm[nj][icen]= new TH2F(Form("hresrcreta_genm%d_%d",nj,icen),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),100,-5.0,5.0,150,rbinl,rbinh); hjeteta[nj][icen] = new TH1F(Form("hjeteta%d_%d",nj,icen),Form("jet eta distribution jet centb %d %s",icen,calgo[nj]),100,-5.0,5.0); hjetphi[nj][icen] = new TH1F(Form("hjetphi%d_%d",nj,icen),Form("jet phi distribution jet centb %d %s",icen,calgo[nj]),72,-pi,pi); hjetetaphi[nj][icen] = new TH2F(Form("hjetetaphi%d_%d",nj,icen),Form("jet eta-phi distribution jet centb %d %s",icen,calgo[nj]),100,-5.0,5.0,72,-pi,pi); hjetpteta[nj][icen] = new TH2F(Form("hjetpteta%d_%d",nj,icen),Form("jet pt-eta distribution jet centb %d %s",icen,calgo[nj]),500,0,1000,100,-5.0,5.0); hjetptphi[nj][icen] = new TH2F(Form("hjetptphi%d_%d",nj,icen),Form("jet pt-phi distribution jet centb %d %s",icen,calgo[nj]),500,0,1000,72,-pi,pi); hratiocorrrefpt_lead[nj][icen]= new TH2F(Form("hratiocorrrefpt_lead%d_%d",nj,icen),Form("Leading jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), 500,0,1000,rbins,rbinl,rbinh); hratiocorrrefpt_slead[nj][icen]= new TH2F(Form("hratiocorrrefpt_slead%d_%d",nj,icen),Form("sub-Leading jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), 500,0,1000,rbins,rbinl,rbinh); hratiocorrrefpt_genm[nj][icen]= new TH2F(Form("hratiocorrrefpt_genm%d_%d",nj,icen),Form("Gen matched jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), 500,0,1000,rbins,rbinl,rbinh); hJetEnergyScale[nj][icen] = new TH2F(Form("hJetEnergyScale%d_%d",nj,icen),Form("hJetEnergyScale%d_%d",nj,icen),500,0,1000,50,-1.00,1.00); for(int ie=0;ie<2;ie++){ hratiorawrefpt_eta[nj][icen][ie]= new TH2F(Form("hratiorawrefpt_eta%d_%d_%d",nj,icen,ie), Form("Raw jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",icen,cjets[nj],ie), 500,0,1000,rbins,rbinl,rbinh); hratiocorrrefpt_eta[nj][icen][ie]= new TH2F(Form("hratiocorrrefpt_eta%d_%d_%d",nj,icen,ie), Form("Reco jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",icen,cjets[nj],ie), 500,0,1000,rbins,rbinl,rbinh); } //hjetptpu_genm[nj][icen] = new TH2F(Form("hjetptpu_genm%d_%d",nj,icen),Form("jet(pt:pu) distribution jet centb %d %s",icen,cjets[nj]),dbins,ptbins_data,100,0,300); //for(int ie=0;ie<ketar;ie++){ // hjetptpu_etab_genm[nj][icen][ie] = new TH2F(Form("hjetptpu_etab_genm%d_%d_%d",nj,icen,ie),Form("jet(pt:pu) distribution jet %s etabin %d cen %d",cjets[nj],icen,ie), /// dbins,ptbins_data,100,0,300); //} hjetptpu_genm[nj][icen] = new TH2F(Form("hjetptpu_genm%d_%d",nj,icen),Form("jet(pt:pu) distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,100,0,300); for(int ie=0;ie<ketar;ie++){ hjetptpu_etab_genm[nj][icen][ie] = new TH2F(Form("hjetptpu_etab_genm%d_%d_%d",nj,icen,ie),Form("jet(pt:pu) distribution jet %s etabin %d cen %d",cjets[nj],icen,ie), 500,0,1000,100,0,300); hjetptbkgd_etab_genm[nj][icen][ie] = new TH2F(Form("hjetptbkgd_etab_genm%d_%d_%d",nj,icen,ie),Form("jet(pt:bkgd) distribution jet etabin %d centb %d %s",ie,icen,calgo[nj]),500,0,1000,100,0,300); } hjetbkgd_genm [nj][icen] = new TH1F(Form("hjetbkgd_genm%d_%d",nj,icen),Form("jet(pu) p_{T} distribution jet centb %d %s",icen,calgo[nj]),100,0,300); //hjetptbkgd_genm[nj][icen] = new TH2F(Form("hjetptbkgd_genm%d_%d",nj,icen),Form("jet(pt:bkgd) distribution jet centb %d %s",icen,calgo[nj]),dbins,ptbins_data,100,0,300); hjetptbkgd_genm[nj][icen] = new TH2F(Form("hjetptbkgd_genm%d_%d",nj,icen),Form("jet(pt:bkgd) distribution jet centb %d %s",icen,calgo[nj]),500,0,1000,100,0,300); //! PF fractions for(int ipf=0;ipf<3;ipf++){ hPFFraction_genm[nj][icen][ipf] = new TH2F(Form("hPFFraction_genm%d_%d_%d",nj,icen,ipf),Form("PF fraction distribution jet centb %d %s %d",icen,calgo[nj],ipf),500,0,1000,15,0,1.5); } for(int m=0;m<maxe;m++){ hpteta[nj][icen][m] = new TH2F(Form("hpteta%d_%d_%d",nj,icen,m),Form("resolution pt(eta) distribution cent %d jet %s etabin%d",icen,cjets[nj],m), 500,0,1000,rbins,rbinl,rbinh); } for(int m=0;m<maxph;m++){ hptphi[nj][icen][m] = new TH2F(Form("hptphi%d_%d_%d",nj,icen,m),Form("resolution pt(phi) distribution cent %d jet %s phibin%d",icen,cjets[nj],m), 500,0,1000,rbins,rbinl,rbinh); } hgenjrecoj[nj][icen] =new TH2F(Form("hgenjrecoj%d_%d",nj,icen),Form("gen jet2 : reco jet2 %s cent %d",cjets[nj],icen),500,0.,1000.,500,0.,1000.); //! efficency histograms hPtAll [nj][icen] = new TH1F(Form("hPtAll%d_%d",nj,icen),Form("Denominator pT for algorithm %s cent %d",cjets[nj],icen),40,10,110); hEtaAll[nj][icen] = new TH1F(Form("hEtaAll%d_%d",nj,icen),Form("Denominator eta for algorithm %s cent %d",cjets[nj],icen),100,-5.0,5.0); hPhiAll[nj][icen] = new TH1F(Form("hPhiAll%d_%d",nj,icen),Form("Denominator phi for algorithm %s cent %d",cjets[nj],icen),20,-pi,pi); hPtSel [nj][icen] = new TH1F(Form("hPtSel%d_%d",nj,icen),Form("Numerator pT for algorithm %s cent %d",cjets[nj],icen),40,10,110); hEtaSel[nj][icen] = new TH1F(Form("hEtaSel%d_%d",nj,icen),Form("Numerator eta for algorithm %s cent %d",cjets[nj],icen),100,-5.0,5.0); hPhiSel[nj][icen] = new TH1F(Form("hPhiSel%d_%d",nj,icen),Form("Numerator phi for algorithm %s cent %d",cjets[nj],icen),20,-pi,pi); hDeltaR[nj][icen] = new TH1F(Form("hDeltaR%d_%d",nj,icen),Form("#DeltaR for algorithm %s cent %d",cjets[nj],icen),100,0,1); hDeltaRAll[nj][icen] = new TH1F(Form("hDeltaRAll%d_%d",nj,icen),Form("#DeltaR (all) for algorithm %s cent %d",cjets[nj],icen),100,0,1); hDeltaRSel[nj][icen] = new TH1F(Form("hDeltaRSel%d_%d",nj,icen),Form("#DeltaR (sel) for algorithm %s cent %d",cjets[nj],icen),100,0,1); for(int ir=0;ir<25;ir++){ //! Response vs DeltaR hRspVsDeltaR[nj][icen][ir] = new TH1F(Form("hRspVsDeltaR%d_%d_%d",nj,icen,ir),Form(" <recopt/refpt> vs. #DeltaR (%d) algorithm %s cent %d",ir,cjets[nj],icen),rbins,rbinl,rbinh); } }//! icen //for eta clsoure in different jet pt bins for(int ipt=0;ipt<bins;ipt++){ hratiocorrrefpt_etaptbin[nj][ipt]= new TH2F(Form("hratiocorrrefpt_etaptbin%d_%d",nj,ipt),Form("Gen matched jet Reco jet / Gen jet p_{T} (corr.) distribution jet vs eta in pt bin %d %s",ipt,cjets[nj]), 100,-5.0,5.0,rbins,rbinl,rbinh); hratiorawrefpt_etaptbin[nj][ipt]= new TH2F(Form("hratiorawrefpt_etaptbin%d_%d",nj,ipt),Form("Gen matched jet Reco jet RawPt/ Gen jet p_{T} (corr.) distribution jet vs eta in pt bin %d %s",ipt,cjets[nj]), 100,-5.0,5.0,rbins,rbinl,rbinh); } //for different HFplusEta4 bins for(int ihf=0;ihf<nhfbin;ihf++){ hratiocorrrefpt_genhfb[nj][ihf]= new TH2F(Form("hratiocorrrefpt_genhfbin%d_%d",nj,ihf),Form("Gen matched jet Reco jet / Gen jet p_{T} (corr.) distribution jet hiHF bin %d %s",ihf,cjets[nj]), 500,0,1000,rbins,rbinl,rbinh); } }//! nj std::cout<<"Initialized the histograms " <<std::endl; ///////////////////////////////////////////////////////////////////////////////////////// //! Centrality reweighting function //! vertex z reweighting Long64_t nentries = c->GetEntries(); std::cout<<Form("# of entries in TTree for %s : ",ksp)<<nentries<<std::endl; std::cout<<std::endl; hEvt->Fill(2,nentries); //! weight for the merging of the samples for different pT hat bins Float_t wxs = xsection/(nentries/100000.); Int_t iEvent=0; for (Long64_t ievt=0; ievt<nentries;ievt++) {//! event loop //for (Long64_t ievt=0; ievt<5000;ievt++) {//! event loop //! load the hiForest event c->GetEntry(ievt); /* int hiBin = c->evt.hiBin; float vz = c->evt.vz; float hiHF = c->evt.hiHF; int ntracks = c->evt.hiNtracks; float HFplusEta = c->evt.hiHFplusEta4; float HFminusEta = c->evt.hiHFminusEta4 ; float HFplusEta4 = HFplusEta+HFminusEta; //! testing //if(hiBin>4 && strcmp(ksp,"pbpb")==0)continue; //! apply vertex cut if(fabs(vz)>kVzcut)continue; //! Centrality bin if(hiBin<0 || hiBin>100)continue; int multb=GetMultBin(ntracks); int hiHFb=GetHFplusEta4Bin(HFplusEta4); */ double wcen=1; double wvz=1; int multb=0; int hiHFb=0; //wxs=1; if(strcmp(ksp,"pbp")==0)multb=0; if(ievt%10000==0)std::cout<<" ********** Event # " <<ievt<<std::endl; //std::cout<<" ********** Event # " <<ievt<<"\t vz : "<<vz<<"\t hiBin : "<<hiBin<<"\t wxs : "<<wxs<<std::endl; /* //! Centrality from 0-100% if(multb==-1 || multb==nmult)continue; if(hiHFb==-1 || hiHFb==nhfbin)continue; */ int istat=0; for(int nj=0;nj<knj;nj++){ //! loop over different jet algorithms if(nj==0)iJet = &(c->ak3PF); else if(nj==1)iJet = &(c->ak4PF); else if(nj==2)iJet = &(c->ak5PF); else if(nj==3)iJet = &(c->akPu3PF); else if(nj==4)iJet = &(c->akPu4PF); else if(nj==5)iJet = &(c->akPu5PF); else if(nj==6)iJet = &(c->ak3Calo); else if(nj==7)iJet = &(c->ak4Calo); else if(nj==8)iJet = &(c->ak5Calo); else if(nj==9)iJet = &(c->akPu3Calo); else if(nj==10)iJet = &(c->akPu4Calo); else if(nj==11)iJet = &(c->akPu5Calo); //! xsec-weight double pthat = iJet->pthat; if(pthat > maxpthat)continue; istat=1; //std::cout<<"\t Jet Algorithm : "<<cjets[nj]<<"\t # of Jets : "<<iJet->nref<<"\t pthat : "<<pthat<<std::endl; if(nj==0)hTotEve->Fill(1); //! akPu3PF /* int *ljet = new int[3]; FindLeadSubLeadJets(iJet,ljet); if(ljet[0]>=0){ hratiocorrrefpt_lead[nj][multb]->Fill(iJet->refpt[ljet[0]],iJet->jtpt[ljet[0]]/iJet->refpt[ljet[0]],wxs*wcen*wvz); hratiocorrrefpt_lead[nj][nmult-1]->Fill(iJet->refpt[ljet[0]],iJet->jtpt[ljet[0]]/iJet->refpt[ljet[0]],wxs*wcen*wvz); } if(ljet[1]>=0){ hratiocorrrefpt_slead[nj][multb]->Fill(iJet->refpt[ljet[1]],iJet->jtpt[ljet[1]]/iJet->refpt[ljet[1]],wxs*wcen*wvz); hratiocorrrefpt_slead[nj][nmult-1]->Fill(iJet->refpt[ljet[1]],iJet->jtpt[ljet[1]]/iJet->refpt[ljet[1]],wxs*wcen*wvz); } //! Jet energy scale comparison with data if(ljet[0]>=0 && ljet[1]>=0 && iJet->jtpt[ljet[0]]>50. && iJet->jtpt[ljet[1]]>50.){//! atleas a dijet int mstat=1; double ptdij = (iJet->jtpt[ljet[0]] + iJet->jtpt[ljet[1]])/2.; if(ljet[2]>=0){ //if(iJet->jtpt[ljet[2]]/ptdij > 0.2)mstat=0; mstat=0; } if(mstat){ double B=-9999; double rn1 = gRandom->Rndm(); double rn2 = gRandom->Rndm(); if(rn1 > rn2){ B = (iJet->jtpt[ljet[0]] - iJet->jtpt[ljet[1]])/(iJet->jtpt[ljet[0]] + iJet->jtpt[ljet[1]]); }else{ B = (iJet->jtpt[ljet[1]] - iJet->jtpt[ljet[0]])/(iJet->jtpt[ljet[1]] + iJet->jtpt[ljet[0]]); } hJetEnergyScale[nj][multb]->Fill(ptdij,B); hJetEnergyScale[nj][nmult-1]->Fill(ptdij,B); } } */ //! Gen matched jets for(int igen=0; igen<iJet->nref; igen++){ if( iJet->subid[igen] != 0) continue; int gj = igen; float rawpt = iJet->rawpt[gj]; float refpt = iJet->refpt[gj]; float refeta = iJet->refeta[gj]; float refphi = iJet->refphi[gj]; // float recopt = iJet->jtpt[gj]; float recopt = iJet->corrpt[gj]; float recoeta = iJet->jteta[gj]; float delr = iJet->refdrjt[gj]; if(rawpt <15.) continue ; // if(recopt<30.) continue ; if(fabs(refeta)<ketacut && refpt>10){ //! Denominator for matching efficiency hPtAll [nj][multb]->Fill(refpt,wxs*wcen*wvz); hEtaAll[nj][multb]->Fill(refeta,wxs*wcen*wvz); hPhiAll[nj][multb]->Fill(refphi,wxs*wcen*wvz); hPtAll [nj][nmult-1]->Fill(refpt,wxs*wcen*wvz); hEtaAll[nj][nmult-1]->Fill(refeta,wxs*wcen*wvz); hPhiAll[nj][nmult-1]->Fill(refphi,wxs*wcen*wvz); //! DeltaR efficiency hDeltaR[nj][multb]->Fill(delr,wxs*wcen*wvz); hDeltaR[nj][nmult-1]->Fill(delr,wxs*wcen*wvz); for (int idrmax=0;idrmax<100;idrmax++) { float drmax = idrmax*0.01+0.005; hDeltaRAll[nj][multb]->Fill(drmax,wxs*wcen*wvz); hDeltaRAll[nj][nmult-1]->Fill(drmax,wxs*wcen*wvz); if (delr<drmax){ hDeltaRSel[nj][multb]->Fill(drmax,wxs*wcen*wvz); hDeltaRSel[nj][nmult-1]->Fill(drmax,wxs*wcen*wvz); } } } if(recopt<kptrecocut || refpt<kptgencut || refpt==0 || fabs(recoeta)>ketacut || fabs(delr)>kdRcut)continue; if(fabs(refeta)<ketacut && refpt>10){ //! Numerator for matching efficiency hPtSel [nj][multb]->Fill(refpt,wxs*wcen*wvz); hEtaSel[nj][multb]->Fill(refeta,wxs*wcen*wvz); hPhiSel[nj][multb]->Fill(refphi,wxs*wcen*wvz); hPtSel [nj][nmult-1]->Fill(refpt,wxs*wcen*wvz); hEtaSel[nj][nmult-1]->Fill(refeta,wxs*wcen*wvz); hPhiSel[nj][nmult-1]->Fill(refphi,wxs*wcen*wvz); } //! Response for (int idr=0;idr<25;idr++) { double drcut = 0.0+idr*(0.25-0.00)/(25-1); if (delr>drcut) continue; hRspVsDeltaR[nj][multb][idr]->Fill(recopt/refpt,wxs*wcen*wvz); hRspVsDeltaR[nj][nmult-1][idr]->Fill(recopt/refpt,wxs*wcen*wvz); } hratiocorrrefpt_genm[nj][multb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiocorrrefpt_genhfb[nj][hiHFb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hrecogen[nj][multb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hrecoraw[nj][multb]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); hrawgen [nj][multb]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hgenjrecoj [nj][multb]->Fill(refpt,recopt,wxs*wcen*wvz); hratiocorrrefpt_genm[nj][nmult-1]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiocorrrefpt_genhfb[nj][nhfbin-1]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiocorrrefpt_genhfb[nj][nhfbin-2]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hrecogen[nj][nmult-1]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hrecoraw[nj][nmult-1]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); hrawgen [nj][nmult-1]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hgenjrecoj [nj][nmult-1]->Fill(refpt,recopt,wxs*wcen*wvz); int ieta=-1; if(fabs(recoeta)<1.3)ieta=0; //! barrel region else ieta=1; //! HCAL region int ptb=GetPtBin(refpt); hratiocorrrefpt_etaptbin[nj][ptb]->Fill(refeta,recopt/refpt,wxs*wcen*wvz); hratiorawrefpt_etaptbin[nj][ptb]->Fill(refeta,rawpt/refpt,wxs*wcen*wvz); //! Response in eta hratiocorrrefpt_eta[nj][multb][ieta]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiorawrefpt_eta [nj][multb][ieta]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hratiocorrrefpt_eta[nj][nmult-1][ieta]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiorawrefpt_eta [nj][nmult-1][ieta]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hjeteta [nj][multb]->Fill(iJet->jteta[gj]); hjetphi [nj][multb]->Fill(iJet->jtphi[gj]); hjetpteta [nj][multb]->Fill(iJet->jtpt[gj],iJet->jteta[gj]); hjetptphi [nj][multb]->Fill(iJet->jtpt[gj],iJet->jtphi[gj]); hjetetaphi[nj][multb]->Fill(iJet->jteta[gj],iJet->jtphi[gj]); hjeteta [nj][nmult-1]->Fill(iJet->jteta[gj]); hjetphi [nj][nmult-1]->Fill(iJet->jtphi[gj]); hjetpteta [nj][nmult-1]->Fill(iJet->jtpt[gj],iJet->jteta[gj]); hjetptphi [nj][nmult-1]->Fill(iJet->jtpt[gj],iJet->jtphi[gj]); hjetetaphi[nj][nmult-1]->Fill(iJet->jteta[gj],iJet->jtphi[gj]); //! Fill the background pT info for the signal matched jets only //! pileup study hjetptpu_genm[nj][multb]->Fill(recopt,iJet->jtpu[gj],wxs*wcen*wvz); hjetptpu_etab_genm[nj][multb][ieta]->Fill(recopt,iJet->jtpu[gj],wxs*wcen*wvz); hjetptpu_genm[nj][nmult-1]->Fill(recopt,iJet->jtpu[gj],wxs*wcen*wvz); hjetptpu_etab_genm[nj][nmult-1][ieta]->Fill(recopt,iJet->jtpu[gj],wxs*wcen*wvz); //! Jet bkgd estimation //! (photonSum+neutralSum+chargedSum-rawpt) double jbkgd = (iJet->photonSum[gj]+iJet->neutralSum[gj]+iJet->chargedSum[gj]) - rawpt; hjetbkgd_genm [nj][multb]->Fill(jbkgd,wxs*wcen*wvz); hjetptbkgd_genm[nj][multb]->Fill(recopt,jbkgd,wxs*wcen*wvz); hjetptbkgd_etab_genm[nj][multb][ieta]->Fill(recopt,jbkgd,wxs*wcen*wvz); hjetbkgd_genm [nj][nmult-1]->Fill(jbkgd,wxs*wcen*wvz); hjetptbkgd_genm[nj][nmult-1]->Fill(recopt,jbkgd,wxs*wcen*wvz); hjetptbkgd_etab_genm[nj][nmult-1][ieta]->Fill(recopt,jbkgd,wxs*wcen*wvz); hPFFraction_genm[nj][multb][0]->Fill(recopt,iJet->photonSum[gj]/rawpt); hPFFraction_genm[nj][multb][1]->Fill(recopt,iJet->neutralSum[gj]/rawpt); hPFFraction_genm[nj][multb][2]->Fill(recopt,iJet->chargedSum[gj]/rawpt); hPFFraction_genm[nj][nmult-1][0]->Fill(recopt,iJet->photonSum[gj]/rawpt); hPFFraction_genm[nj][nmult-1][1]->Fill(recopt,iJet->neutralSum[gj]/rawpt); hPFFraction_genm[nj][nmult-1][2]->Fill(recopt,iJet->chargedSum[gj]/rawpt); hNjets_genm [nj][multb]->Fill(refpt); hgenpt_genm [nj][multb]->Fill(refpt,wxs*wcen*wvz); hrecopt_genm[nj][multb]->Fill(recopt,wxs*wcen*wvz); hrawpt_genm [nj][multb]->Fill(rawpt,wxs*wcen*wvz); hNjets_genm [nj][nmult-1]->Fill(refpt); hgenpt_genm [nj][nmult-1]->Fill(refpt,wxs*wcen*wvz); hrecopt_genm[nj][nmult-1]->Fill(recopt,wxs*wcen*wvz); hrawpt_genm [nj][nmult-1]->Fill(rawpt,wxs*wcen*wvz); //! Very fine bin in ref pt hrescrpt_genm[nj][multb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hresrrpt_genm[nj][multb]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hresrcrpt_genm[nj][multb]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); hrescrpt_genm [nj][nmult-1]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hresrrpt_genm [nj][nmult-1]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hresrcrpt_genm[nj][nmult-1]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); //! Very fine bin in ref eta hrescreta_genm[nj][multb]->Fill(refeta,recopt/refpt,wxs*wcen*wvz); hresrreta_genm[nj][multb]->Fill(refeta,rawpt/refpt,wxs*wcen*wvz); hresrcreta_genm[nj][multb]->Fill(recoeta,recopt/rawpt,wxs*wcen*wvz); hrescreta_genm[nj][nmult-1]->Fill(refeta,recopt/refpt,wxs*wcen*wvz); hresrreta_genm[nj][nmult-1]->Fill(refeta,rawpt/refpt,wxs*wcen*wvz); hresrcreta_genm[nj][nmult-1]->Fill(recoeta,recopt/rawpt,wxs*wcen*wvz); //! Response in different eta and phi bins int etabin = GetEtaBin(fabs(refeta)); int phibin = GetPhiBin(refphi); //! Response in eta and phi bins if(etabin >= 0 && etabin<maxe){ hpteta[nj][multb][etabin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hpteta[nj][nmult-1][etabin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); } if(phibin >= 0 && phibin<maxph){ hptphi[nj][multb][phibin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hptphi[nj][nmult-1][phibin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); } }//! igen loop /* hNevt[nj][multb]->Fill(vz,wxs*wcen*wvz); hNevt[nj][nmult-1]->Fill(vz,wxs*wcen*wvz); */ // delete [] ljet; }//! nj jet loop /* if(istat){ hBin->Fill(hiBin,wxs*wcen*wvz); hVz->Fill(vz,wxs*wcen*wvz); hHF->Fill(hiHF,wxs*wcen*wvz); hNTracks->Fill(ntracks,wxs*wcen*wvz); hNTracksHF->Fill(ntracks,hiHF,wxs*wcen*wvz); hBinHF->Fill(hiBin,hiHF,wxs*wcen*wvz); hBinNTracks->Fill(hiBin,ntracks,wxs*wcen*wvz); hNTracksHFplusEta4->Fill(ntracks,HFplusEta4,wxs*wcen*wvz); iEvent++; } */ // std::cout<<"Completed event # "<<ievt<<std::endl; }//! event loop ends std::cout<<std::endl; std::cout<<std::endl; std::cout<<std::endl; // std::cout<<"Events which passed the pT hat cut : "<<hTotEve->Integral()<<" out of : "<<hEvt->Integral() // <<" efficiency of all the cuts : " <<hTotEve->Integral()/hEvt->Integral()<<std::endl; std::cout<<std::endl; for(int nj=0;nj<knj;nj++){ std::cout<<"# of Events for : "<<cjets[nj]<<"\t"<<hNevt[nj][nmult-1]->Integral()<<"\t # of Jets : "<<hNjets_genm[nj][nmult-1]->Integral()<<std::endl; } //! Write to output file fout->cd(); fout->Write(); fout->Close(); //! Check timer.Stop(); double rtime = timer.RealTime(); double ctime = timer.CpuTime(); std::cout<<std::endl; std::cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<std::endl; std::cout<<std::endl; std::cout<<"Good bye : " <<"\t"<<std::endl; return 1; }
int writentuple(char *ksp="ppJet40") { timer.Start(); LoadLib(); TString inname=""; if(strcmp(ksp,"ppJet40")==0)inname = "root://eoscms//eos/cms/store/group/phys_heavyions/yjlee/pp2013/promptReco/PP2013_HiForest_PromptReco_JSon_Jet40Jet60_ppTrack_forestv84.root"; else if(strcmp(ksp,"ppJet80")==0)inname = "root://eoscms//eos/cms/store/caf/user/yjlee/pp2013/promptReco/PP2013_HiForest_PromptReco_JsonPP_Jet80_PPReco_forestv82.root"; //! Load Lib //gSystem->Load("/afs/cern.ch/user/p/pawan/scratch0/CMSSW_6_2_0/src/work/pPb/HiForest/V3/hiForest_h.so"); //! Define the input file and HiForest //! CMSSW_5_3_3 HiForest *c = new HiForest(inname,Form("Forest%s",ksp),cPP); cout<<"Loaded the hiforest tree : "<<c->GetName()<<endl; ShutoffBranches(c); //! Output file //! HIHighPt TFile *fout = new TFile(Form("ntuple_2013_%s.root",ksp),"RECREATE"); std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<Form("Running for %s ",ksp)<<std::endl; std::cout<<Form("pT cut for %0.3f ",kptrecocut)<<std::endl; std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl; std::cout<<"My hiForest Tree : " <<c->GetName()<<"\t Entries "<<c->GetEntries()<<std::endl; std::cout<<"Output file "<<fout->GetName()<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; //! shut off jet trees c->hasAk2CaloJetTree=0; c->hasAk4CaloJetTree=0; c->hasAk3CaloJetTree=0; c->hasAk5CaloJetTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu5CaloJetTree=0; c->hasAk2PFJetTree=0; c->hasAk4PFJetTree=0; c->hasAk5PFJetTree=0; c->hasAkPu2PFJetTree=0; c->hasAkPu4PFJetTree=0; c->hasAkPu5PFJetTree=0; c->hasTrackTree=0; //! For jets Jets *mJets=0; Long64_t nentries = c->GetEntries(); std::cout<<Form("# of entries in TTree for %s : ",ksp)<<nentries<<std::endl; string jetVars = ""; jetVars += "evt:run:vz:trig:jet40:jet60:jet80:jet100:ntrk:pt1:raw1:eta1:phi1:chMax1:chSum1:phSum1:neSum1:pt2:raw2:eta2:phi2:chMax2:chSum2:phSum2:neSum2:pt3:raw3:eta3:phi3:chMax3:chSum3:phSum3:neSum3"; TNtuple *ntjet=0; ntjet = new TNtuple("ntjet","",jetVars.data()); for (Long64_t ievt=0; ievt<nentries;ievt++) {//! event loop //for (Long64_t ievt=0; ievt<100;ievt++) {//! event loop //! load the hiForest event c->GetEntry(ievt); //! events with Single vertex bool evSel = false; float trig=-9; if(strcmp(ksp,"ppJet40")==0){ evSel = fabs(c->evt.vz)<15. && c->skim.pHBHENoiseFilter && c->skim.pPAcollisionEventSelectionPA && (c->hlt.HLT_PAJet40_NoJetID_v1 || c->hlt.HLT_PAJet60_NoJetID_v1); trig=1; } else if(strcmp(ksp,"ppJet80")==0){ evSel = fabs(c->evt.vz)<15. && c->skim.pHBHENoiseFilter && c->skim.pPAcollisionEventSelectionPA && (c->hlt.HLT_PAJet80_NoJetID_v1 || c->hlt.HLT_PAJet100_NoJetID_v1); trig=2; } if(!evSel)continue; float pt1 = -9, pt2 = -9, pt3 = -9, raw1 = -9, raw2 = -9, raw3 = -9, eta1 = -9, eta2 = -9, eta3 = -9, phi1 = -9, phi2 = -9, phi3 = -9, chMax1 = -9, chMax2 = -9, chMax3 = -9, chSum1 = -9, chSum2 = -9, chSum3 = -9, phSum1 = -9, phSum2 = -9, phSum3 = -9, neSum1 = -9, neSum2 = -9, neSum3 = -9; float run = c->evt.run; float evt = c->evt.evt; float vz = c->evt.vz; float jet40 = c->hlt.HLT_PAJet40_NoJetID_v1; float jet60 = c->hlt.HLT_PAJet60_NoJetID_v1; float jet80 = c->hlt.HLT_PAJet80_NoJetID_v1; float jet100 = c->hlt.HLT_PAJet100_NoJetID_v1; float ntrk = c->evt.hiNtracks; if(ievt%10000==0)std::cout<<" ********** Event # " <<ievt<<"\t Run : "<<run<<std::endl; mJets = &(c->ak3PF); int *ljet = new int[3]; FindLeadSubLeadJets(mJets,ljet); int jtLead = -1, jtSubLead = -1, jtThird = -1; if(ljet[0] >=0 ) jtLead = ljet[0]; if(ljet[1] >=0 ) jtSubLead = ljet[1]; if(ljet[2] >=0 ) jtThird = ljet[2]; if(jtLead<0)continue; if(jtLead > -1){ pt1 = mJets->jtpt[jtLead]; eta1 = mJets->jteta[jtLead]; phi1 = mJets->jtphi[jtLead]; raw1 = mJets->rawpt[jtLead]; chMax1 = mJets->chargedMax[jtLead]; chSum1 = mJets->chargedSum[jtLead]; phSum1 = mJets->photonSum[jtLead]; neSum1 = mJets->neutralSum[jtLead]; } if(jtSubLead > -1){ pt2 = mJets->jtpt[jtSubLead]; eta2 = mJets->jteta[jtSubLead]; phi2 = mJets->jtphi[jtSubLead]; raw2 = mJets->rawpt[jtSubLead]; chMax2 = mJets->chargedMax[jtSubLead]; chSum2 = mJets->chargedSum[jtSubLead]; phSum2 = mJets->photonSum [jtSubLead]; neSum2 = mJets->neutralSum[jtSubLead]; } if(jtThird > -1){ pt3 = mJets->jtpt[jtThird]; eta3 = mJets->jteta[jtThird]; phi3 = mJets->jtphi[jtThird]; raw3 = mJets->rawpt[jtThird]; chMax3 = mJets->chargedMax[jtThird]; chSum3 = mJets->chargedSum[jtThird]; phSum3 = mJets->photonSum [jtThird]; neSum3 = mJets->neutralSum[jtThird]; } float jentry[] = {evt,run,vz,trig,jet40,jet60,jet80,jet100,ntrk, pt1,raw1,eta1,phi1,chMax1,chSum1,phSum1,neSum1, pt2,raw2,eta2,phi2,chMax2,chSum2,phSum2,neSum2, pt3,raw3,eta3,phi3,chMax3,chSum3,phSum3,neSum3 }; ntjet->Fill(jentry); delete [] ljet; }//! event loop ends //! Write to output file fout->cd(); fout->Write(); fout->Close(); //! Check timer.Stop(); float rtime = timer.RealTime(); float ctime = timer.CpuTime(); std::cout<<"\t"<<std::endl; std::cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"Good bye : " <<"\t"<<std::endl; return 0; }
int IndResponse(double kPt=80,const char *ksp="pbpb") { timer.Start(); //! Load Lib gSystem->Load("hiForest_h.so"); //! Load the hiforest input root file HiForest *c = 0; if(strcmp("pp",ksp)==0)c = new HiForest(Form("/net/hisrv0001/home/icali/hadoop/Pythia/Z2/ppDijet_merged/pp276Dijet%0.0f_merged.root",kPt),"pp2012",1,1); else { if(kPt==30)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia30_HydjetDrum_mix01_HiForest2_v19.root","pbpb2012",0,1); else if(kPt==50)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia50_HydjetDrum_mix01_HiForest2_v19.root","pbpb2012",0,1); else if(kPt==80)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia80_HydjetDrum_mix01_HiForest2_v20.root","pbpb2012",0,1); else if(kPt==120)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia120_HydjetDrum_mix01_HiForest2_v21_ivan.root","pbpb2012",0,1); else if(kPt==170)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia170_HydjetDrum_mix01_HiForest2_v19.root","pbpb2012",0,1); else if(kPt==200)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia200_HydjetDrum_mix01_HiForest2_v21_ivan.root","pbpb2012",0,1); else if(kPt==250)c = new HiForest("/d102/yjlee/hiForest2MC/Pythia250_HydjetDrum_mix01_HiForest2_v21_ivan.root","pbpb2012",0,1); //c = new HiForest(Form("/net/hisrv0001/home/icali/hadoop/Hydjet1.8/Z2/Dijet_merged/Dijet%0.0f_merged.root",kPt),"pbpb2012",0,1); } double xsection=0; double xup=0; double xsub=0; double maxpthat=9999; if(kPt==15){ maxpthat=30; xup=1.566e-01; xsub=1.079e-02; } else if(kPt==30){ maxpthat=50; xup=1.079e-02; xsub=1.021e-03; } else if(kPt==50){ maxpthat=80; xup=1.021e-03; xsub=9.913e-05; } else if(kPt==80){ maxpthat=120; xup=9.913e-05; xsub=1.128e-05; } else if(kPt==120){ maxpthat=170; xup=1.128e-05; xsub=1.470e-06; } else if(kPt==170){ maxpthat=200; xup=1.470e-06; xsub=5.310e-07; } else if(kPt==200){ maxpthat=250; xup=5.310e-07; xsub=1.192e-07; } else if(kPt==250){ maxpthat=300; xup=1.192e-07; xsub=3.176e-08; } else if(kPt==300){ maxpthat=9999; xup=3.176e-08; xsub=0; } xsection = xup-xsub; std::cout<<std::endl; std::cout<<std::endl; //! Don't want to loop over trees which is not used in the analysis //! event trees //c->hasEvtTree=0; //! jet trees //! Switch on only the jet trees which you require const char *cjets[7] = {"icPu5","ak2PF","ak3PF","ak4PF","akPu2PF","akPu3PF","akPu4PF"}; c->SelectJetAlgo(cjets,7); //! photon tree //c->hasPhotonTree=0; //! Select only the jet branches which you are going to use //! This increases the speed for running over trees with lot of branches. //! This is currently for only jet algos and evtTree uniformly applied to all the //! Event Tree const char *evlist[]={"hiBin","vz","hiHF"}; const int kevbr = sizeof(evlist)/sizeof(const char *); c->SelectBranches("evtTree",evlist,kevbr); //! jet Tree algorithms const char *jtlist[]={"nref","pthat","rawpt","jtpt","jteta","jtphi","jtpu","refpt","refeta","refphi","refdrjt","refparton_flavor", "ngen","gensubid","genmatchindex" }; const int kjtbr = sizeof(jtlist)/sizeof(const char *); c->SelectBranches("JetTree",jtlist,kjtbr); std::cout<<"Selected the branches of need from evtTree and JetTrees : "<<std::endl; //! To get the jet object from hiforest Jets *iJet=0; const int knj = 7;//c->GetNAlgo(); //! # of jet algorithms in this hiforest std::cout<<"Loaded all tree variables and # of jet algorithms : "<<knj<<std::endl; std::cout<<"\t"<<std::endl; //! Away-side jet definition const char *cdphi="2pi3"; double kdphicut = 7.*pi/8.; if(strcmp(cdphi,"2pi3")==0)kdphicut=2.*pi/3.; else if(strcmp(cdphi,"1pi4")==0)kdphicut=1.*pi/4.; //! Open a output file for histos TFile *fout = new TFile(Form("Output/%s/Response_newHiForest_DJ_%0.0fGeV_%s_%d.root",ksp,kPt,ksp,iYear),"RECREATE"); //TFile *fout = new TFile(Form("Output/%s/novtxcut/Response_newHiForest_DJ_%0.0fGeV_%s_%d.root",ksp,kPt,ksp,iYear),"RECREATE"); //TFile *fout = new TFile(Form("test_newHiForest_DJ_%0.0fGeV_%s_%d.root",kPt,ksp,iYear),"RECREATE"); std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<Form("Running for %s ",ksp)<<std::endl; std::cout<<Form("pT cut for %0.3f ",kptrecocut)<<std::endl; std::cout<<Form("eta cut for %0.3f ",ketacut)<<std::endl; std::cout<<"My hiForest TTree : " <<c->GetName()<<std::endl; std::cout<<"Output file "<<fout->GetName()<<std::endl; std::cout<<"**************************************************** "<<std::endl; std::cout<<"\t"<<std::endl; std::cout<<"\t"<<std::endl; //! //! Define histograms here TH1::SetDefaultSumw2(); TH2::SetDefaultSumw2(); TProfile::SetDefaultSumw2(); //////////////////////////////////////////////////////////////////////////////////////////////////////// TH1F *hEvt = new TH1F("hEvt","# of events ",4,0,4); TH1F *hVz = new TH1F("hVz","# of events ",80,-20,20); TH1F *hBin = new TH1F("hBin","Centrality bin",40,0,40); TH1F *hHF = new TH1F("hHF","Centrality variable from HF",600,0,6000); TH1F *hTotEve = new TH1F("hTotEve","# of events in the skimmed files",4,0,4); TH1F *hgenpt [knj][ncen], *hrecopt[knj][ncen], *hrawpt[knj][ncen]; TH1F *hgenptC [knj][ncen], *hrecoptC[knj][ncen], *hrawptC[knj][ncen]; TH1F *hgeneta[knj][ncen], *hrecoeta[knj][ncen]; TH1F *hgenphi[knj][ncen], *hrecophi[knj][ncen]; //! Ratios of the pt distributions TProfile *hrecogen[knj][ncen], *hrecoraw[knj][ncen], *hrawgen[knj][ncen], *hrecoraw_ref[knj][ncen]; //! Resposnse TH2F *hcorrptrefpt[knj][ncen], *hrawptrefpt[knj][ncen], *hcorrptrawpt[knj][ncen]; TH2F *hrescrpt[knj][ncen], *hresrrpt[knj][ncen], *hresrcrpt[knj][ncen]; TH2F *hratiorawrefpt[knj][ncen], *hratiocorrrefpt[knj][ncen], *hratiocorrrawpt[knj][ncen]; TH2F *hratiorawrefpt_eta[knj][ncen][2], *hratiocorrrefpt_eta[knj][ncen][2]; TH2F *hratiocorrrefpt_genm[knj][ncen]; TH2F *hratiocorrrefpt_lead[knj][ncen], *hratiocorrrefpt_slead[knj][ncen], *hratiocorrrefpt_remain[knj][ncen]; TH2F *hratiocorrrefpt_pthat[knj][ncen]; TH2F *hpteta[knj][ncen][maxe], *hptphi[knj][ncen][maxph]; TH2F *hgenjrecoj[knj][ncen]; TH2F *hgenjrecoj_pflavor[knj][ncen]; TH2F *hFracjets[knj][ncen]; TH2F *hAvjets[knj][ncen]; TH2F *hMeanPtjets[knj][ncen]; TH1F *hNjets[knj][ncen]; TH1F *hNevt [knj][ncen]; //! Pileup effect study TH2F *hjetptpu[knj][ncen]; //! centrality TH2F *hjetptpu_etab[knj][ncen][ketar]; //! eta dependence //! Efficency histos TH1F *hPtAll [knj][ncen], *hPtSel[knj][ncen]; TH1F *hEtaAll[knj][ncen], *hEtaSel[knj][ncen]; TH1F *hPhiAll[knj][ncen], *hPhiSel[knj][ncen]; //! Response vs deltar TH1F *hRspVsDeltaR[knj][ncen][25]; //! DeltaR efficiency TH1F *hDeltaR[knj][ncen]; TH1F *hDeltaRAll[knj][ncen]; TH1F *hDeltaRSel[knj][ncen]; for(int nj=0;nj<knj;nj++){ //const char *algoname = c->GetAlgoName(nj); //char *algoname = cjets[nj]; //strcpy(algoname,cjets[nj]); for(int icen=0;icen<ncen;icen++){ hFracjets[nj][icen] = new TH2F(Form("hFracjets%d_%d",nj,icen),Form("Fraction of jets in given pt hat cent %d %s",icen,cjets[nj]),500,0,1000,500,0.,1000.); hAvjets[nj][icen] = new TH2F(Form("hAvjets%d_%d",nj,icen),Form("<#> of jets cent %d %s",icen,cjets[nj]),500,0,1000,30,0,30); hMeanPtjets[nj][icen] = new TH2F(Form("hMeanPtjets%d_%d",nj,icen),Form("<pT> of jets cent %d %s",icen,cjets[nj]),500,0,1000,500,0,1000); hNjets[nj][icen] = new TH1F(Form("hNjets%d_%d",nj,icen),Form("# of jets cent %d jets %s",icen,cjets[nj]),3,0.0,3.0); hNevt [nj][icen] = new TH1F(Form("hNevt%d_%d",nj,icen),Form("# of events cent %d %s",icen,cjets[nj]),40,-40,40); hgeneta[nj][icen] = new TH1F(Form("hgeneta%d_%d",nj,icen),Form("gen eta distribution jet centb %d %s",icen,cjets[nj]),60,-3.0,3.0); hrecoeta[nj][icen] = new TH1F(Form("hrecoeta%d_%d",nj,icen),Form("reco eta distribution jet centb %d %s",icen,cjets[nj]),60,-3.0,3.0); hgenphi[nj][icen] = new TH1F(Form("hgenphi%d_%d",nj,icen),Form("gen phi distribution jet centb %d %s",icen,cjets[nj]),36,-pi,pi); hrecophi[nj][icen] = new TH1F(Form("hrecophi%d_%d",nj,icen),Form("reco phi distribution jet centb %d %s",icen,cjets[nj]),36,-pi,pi); hgenpt[nj][icen] = new TH1F(Form("hgenpt%d_%d",nj,icen),Form("gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrecopt[nj][icen] = new TH1F(Form("hrecopt%d_%d",nj,icen),Form("reco p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrawpt[nj][icen] = new TH1F(Form("hrawpt%d_%d",nj,icen),Form("raw p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); //! with pt bins hgenptC[nj][icen] = new TH1F(Form("hgenptC%d_%d",nj,icen),Form("gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),bins,ptbins); hrecoptC[nj][icen] = new TH1F(Form("hrecoptC%d_%d",nj,icen),Form("reco p_{T} distribution jet centb %d %s",icen,cjets[nj]),bins,ptbins); hrawptC[nj][icen] = new TH1F(Form("hrawptC%d_%d",nj,icen),Form("raw p_{T} distribution jet centb %d %s",icen,cjets[nj]),bins,ptbins); //! Ratios hrecogen[nj][icen] = new TProfile(Form("hrecogen%d_%d",nj,icen),Form("reco/gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrecoraw[nj][icen] = new TProfile(Form("hrecoraw%d_%d",nj,icen),Form("reco/raw p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrecoraw_ref[nj][icen] = new TProfile(Form("hrecoraw_ref%d_%d",nj,icen),Form("reco/raw : ref p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hrawgen[nj][icen] = new TProfile(Form("hrawgen%d_%d",nj,icen),Form("raw/gen p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000); hcorrptrefpt[nj][icen]= new TH2F(Form("hcorrptrefpt%d_%d",nj,icen),Form("Gen jet:Reco jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,500,0,1000); hrawptrefpt[nj][icen]= new TH2F(Form("hrawptrefpt%d_%d",nj,icen),Form("Gen jet:Raw jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,500,0,1000); hcorrptrawpt[nj][icen]= new TH2F(Form("hcorrptrawpt%d_%d",nj,icen),Form("Reco jet Corr:Raw jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,500,0,1000); hrescrpt[nj][icen]= new TH2F(Form("hrescrpt%d_%d",nj,icen),Form("Gen jet:(Reco/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hresrrpt[nj][icen]= new TH2F(Form("hresrrpt%d_%d",nj,icen),Form("Gen jet:(Raw/Gen) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hresrcrpt[nj][icen]= new TH2F(Form("hresrcrpt%d_%d",nj,icen),Form("Reco jet:(Reco/Raw) jet p_{T} distribution jet centb %d %s",icen,cjets[nj]),500,0,1000,150,rbinl,rbinh); hratiorawrefpt[nj][icen]= new TH2F(Form("hratiorawrefpt%d_%d",nj,icen),Form("Raw jet / Gen jet p_{T} (raw) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt[nj][icen]= new TH2F(Form("hratiocorrrefpt%d_%d",nj,icen),Form("Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrawpt[nj][icen]= new TH2F(Form("hratiocorrrawpt%d_%d",nj,icen),Form("Correc. jet / Raw jet jet p_{T} distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_lead[nj][icen]= new TH2F(Form("hratiocorrrefpt_lead%d_%d",nj,icen),Form("Leading jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_slead[nj][icen]= new TH2F(Form("hratiocorrrefpt_slead%d_%d",nj,icen),Form("sub-Leading jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_remain[nj][icen]= new TH2F(Form("hratiocorrrefpt_remain%d_%d",nj,icen),Form("Remaing jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_pthat[nj][icen]= new TH2F(Form("hratiocorrrefpt_pthat%d_%d",nj,icen),Form("pT hat jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_genm[nj][icen]= new TH2F(Form("hratiocorrrefpt_genm%d_%d",nj,icen),Form("Gen matched jet Reco jet / Gen jet p_{T} (corr.) distribution jet centb %d %s",icen,cjets[nj]), bins,ptbins,rbins,rbinl,rbinh); for(int ie=0;ie<2;ie++){ hratiorawrefpt_eta[nj][icen][ie]= new TH2F(Form("hratiorawrefpt_eta%d_%d_%d",nj,icen,ie), Form("Raw jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",icen,cjets[nj],ie), bins,ptbins,rbins,rbinl,rbinh); hratiocorrrefpt_eta[nj][icen][ie]= new TH2F(Form("hratiocorrrefpt_eta%d_%d_%d",nj,icen,ie), Form("Reco jet / Gen jet p_{T} (raw) distribution jet centb %d %s etabin%d",icen,cjets[nj],ie), bins,ptbins,rbins,rbinl,rbinh); } hjetptpu[nj][icen] = new TH2F(Form("hjetptpu%d_%d",nj,icen),Form("jet(pt:pu) distribution jet centb %d %s",icen,cjets[nj]),dbins,ptbins_data,100,0,300); for(int ie=0;ie<ketar;ie++){ hjetptpu_etab[nj][icen][ie] = new TH2F(Form("hjetptpu_etab%d_%d_%d",nj,icen,ie),Form("jet(pt:pu) distribution jet %s etabin %d cen %d",cjets[nj],icen,ie), dbins,ptbins_data,100,0,300); } for(int m=0;m<maxe;m++){ hpteta[nj][icen][m] = new TH2F(Form("hpteta%d_%d_%d",nj,icen,m),Form("resolution pt(eta) distribution cent %d jet %s etabin%d",icen,cjets[nj],m), bins,ptbins,rbins,rbinl,rbinh); } for(int m=0;m<maxph;m++){ hptphi[nj][icen][m] = new TH2F(Form("hptphi%d_%d_%d",nj,icen,m),Form("resolution pt(phi) distribution cent %d jet %s phibin%d",icen,cjets[nj],m), bins,ptbins,rbins,rbinl,rbinh); } hgenjrecoj[nj][icen] =new TH2F(Form("hgenjrecoj%d_%d",nj,icen),Form("gen jet2 : reco jet2 %s cent %d",cjets[nj],icen),500,0.,1000.,500,0.,1000.); hgenjrecoj_pflavor[nj][icen] =new TH2F(Form("hgenjrecoj_pflavor%d_%d",nj,icen),Form("gen jet : reco jet with parton flavor %s cent %d",cjets[nj],icen),500,0.,1000.,500,0.,1000.); //! efficency histograms hPtAll [nj][icen] = new TH1F(Form("hPtAll%d_%d",nj,icen),Form("Denominator pT for algorithm %s cent %d",cjets[nj],icen),40,30,430); hEtaAll[nj][icen] = new TH1F(Form("hEtaAll%d_%d",nj,icen),Form("Denominator eta for algorithm %s cent %d",cjets[nj],icen),20,-2.0,2.0); hPhiAll[nj][icen] = new TH1F(Form("hPhiAll%d_%d",nj,icen),Form("Denominator phi for algorithm %s cent %d",cjets[nj],icen),20,-pi,pi); hPtSel [nj][icen] = new TH1F(Form("hPtSel%d_%d",nj,icen),Form("Numerator pT for algorithm %s cent %d",cjets[nj],icen),40,30,430); hEtaSel[nj][icen] = new TH1F(Form("hEtaSel%d_%d",nj,icen),Form("Numerator eta for algorithm %s cent %d",cjets[nj],icen),20,-2.0,2.0); hPhiSel[nj][icen] = new TH1F(Form("hPhiSel%d_%d",nj,icen),Form("Numerator phi for algorithm %s cent %d",cjets[nj],icen),20,-pi,pi); hDeltaR[nj][icen] = new TH1F(Form("hDeltaR%d_%d",nj,icen),Form("#DeltaR for algorithm %s cent %d",cjets[nj],icen),100,0,1); hDeltaRAll[nj][icen] = new TH1F(Form("hDeltaRAll%d_%d",nj,icen),Form("#DeltaR (all) for algorithm %s cent %d",cjets[nj],icen),100,0,1); hDeltaRSel[nj][icen] = new TH1F(Form("hDeltaRSel%d_%d",nj,icen),Form("#DeltaR (sel) for algorithm %s cent %d",cjets[nj],icen),100,0,1); for(int ir=0;ir<25;ir++){ //! Response vs DeltaR hRspVsDeltaR[nj][icen][ir] = new TH1F(Form("hRspVsDeltaR%d_%d_%d",nj,icen,ir),Form(" <recopt/refpt> vs. #DeltaR (%d) algorithm %s cent %d",ir,cjets[nj],icen),rbins,rbinl,rbinh); } }//! icen }//! nj std::cout<<"Initialized the histograms " <<std::endl; ///////////////////////////////////////////////////////////////////////////////////////// //! Centrality reweighting function //TF1* fcen = new TF1("fcen","exp(-1.0*pow(x+1.11957e+01,2)/pow(1.34120e+01,2)/2)",0,40); TF1 *fcen = new TF1("fcen","[0]*exp([1]+[2]*x+[3]*x*x+[4]*x*x*x)",0,40); fcen->SetParameters(2.10653e-02,5.61607,-1.41493e-01,1.00586e-03,-1.32625e-04); //! vertex z reweighting TF1 *fVz = new TF1("fVz","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x"); if(strcmp(ksp,"pp")==0) fVz->SetParameters(8.41684e-01,-2.58609e-02,4.86550e-03,-3.10581e-04,2.07918e-05); else fVz->SetParameters(7.62788e-01,-1.13228e-02,5.85199e-03,-3.04550e-04,4.43440e-05); Long64_t nb = 0; Long64_t nentries = c->GetEntries(); std::cout<<Form("# of entries in TTree for %s : ",ksp)<<nentries<<std::endl; std::cout<<std::endl; hEvt->Fill(2,nentries); //! weight for the merging of the samples for different pT hat bins Float_t wxs = xsection/(nentries/100000.); Int_t iEvent=0; for (Long64_t ievt=0; ievt<nentries;ievt++) {//! event loop //for (Long64_t ievt=0; ievt<1;ievt++) {//! event loop //! load the hiForest event nb += c->GetEntry(ievt); int hiBin = c->evt.hiBin; float vz = c->evt.vz; float hiHF = c->evt.hiHF; //! testing //if(hiBin>4 && strcmp(ksp,"pbpb")==0)continue; //! apply vertex cut if(fabs(vz)>kVzcut)continue; //! Centrality bin if(hiBin<0 || hiBin>39)continue; int centb=-1; double wcen=1; double wvz=fVz->Eval(vz); if(strcmp(ksp,"pbpb")==0){ centb=GetCentBin(hiBin); wcen = fcen->Eval(hiBin); }else{ centb=ncen-1; //! pp wcen=1; } if(ievt%10000==0)std::cout<<" ********** Event # " <<ievt<<std::endl; //std::cout<<" ********** Event # " <<ievt<<"\t vz : "<<vz<<"\t hiBin : "<<hiBin<<"\t wxs : "<<wxs<<std::endl; //! Centrality from 0-90% if(centb==-1 || centb==ncen)continue; int istat=0; for(int nj=0;nj<knj;nj++){ //! loop over different jet algorithms //! Get the jet object //iJet = c->GetJet(nj); iJet = c->GetJetByAlgo(cjets[nj]); //! xsec-weight double pthat = iJet->pthat; if(pthat > maxpthat)continue; istat=1; //std::cout<<"\t Jet Algorithm : "<<c->GetCjets[Nj](nj)<<"\t # of Jets : "<<iJet->nref<<"\t pthat : "<<pthat<<std::endl; if(nj==0)hTotEve->Fill(1); //! akPu3PF float njets=0.; float meanpt=0.; int *ljet = new int[2]; FindLeadSubLeadJets(iJet,ljet); if(ljet[0]>=0){ hratiocorrrefpt_lead[nj][centb]->Fill(iJet->refpt[ljet[0]],iJet->jtpt[ljet[0]]/iJet->refpt[ljet[0]],wxs*wcen*wvz); } if(ljet[1]>=0){ hratiocorrrefpt_slead[nj][centb]->Fill(iJet->refpt[ljet[1]],iJet->jtpt[ljet[1]]/iJet->refpt[ljet[1]],wxs*wcen*wvz); } if(nj>3){ //! Gen matched jets for(int igen=0; igen<iJet->ngen; igen++){ if( iJet->gensubid[igen] != 0) continue; int gj = iJet->genmatchindex[igen]; float refpt = iJet->refpt[gj]; float recopt = iJet->jtpt[gj]; float recoeta = iJet->jteta[gj]; float delr = iJet->refdrjt[gj]; if(recopt<kptrecocut || refpt<kptgencut || refpt==0 || fabs(recoeta)>ketacut || fabs(delr)>kdRcut)continue; hratiocorrrefpt_genm[nj][centb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); } } for(int ij=0; ij<iJet->nref; ij++){ //if(!selecJet(iJet,ij))continue; float refpt = iJet->refpt[ij]; float recopt = iJet->jtpt[ij]; float rawpt = iJet->rawpt[ij]; float refeta = iJet->refeta[ij]; float recoeta = iJet->jteta[ij]; float refphi = iJet->refphi[ij]; float recophi = iJet->jtphi[ij]; int refparton_flavor = iJet->refparton_flavor[ij]; //! Matching criteria float delr = iJet->refdrjt[ij]; if(recopt<kptrecocut || refpt<kptgencut || refpt==0)continue; //std::cout<<"\t \t "<<ij<<"\t refpt : "<<refpt<<"\t recopt : "<<recopt<<"\t raw pT : "<<rawpt<<std::endl; if(fabs(refeta)<ketacut && refpt>80){ //! Denominator for matching efficiency hPtAll [nj][centb]->Fill(refpt,wxs*wcen*wvz); hEtaAll[nj][centb]->Fill(refeta,wxs*wcen*wvz); hPhiAll[nj][centb]->Fill(refphi,wxs*wcen*wvz); //! Response for (int idr=0;idr<25;idr++) { double drcut = 0.0+idr*(0.25-0.00)/(25-1); if (delr>drcut) continue; hRspVsDeltaR[nj][centb][idr]->Fill(recopt/refpt,wxs*wcen*wvz); } //! DeltaR efficiency hDeltaR[nj][centb]->Fill(delr,wxs*wcen*wvz); for (int idrmax=0;idrmax<100;idrmax++) { float drmax = idrmax*0.01+0.005; hDeltaRAll[nj][centb]->Fill(drmax,wxs*wcen*wvz); if (delr<drmax) hDeltaRSel[nj][centb]->Fill(drmax,wxs*wcen*wvz); } } //! Matching cut for gen-jet and reco-jet if(delr > kdRcut)continue; if(fabs(refeta)<ketacut && refpt>80){ //! Numerator for matching efficiency hPtSel [nj][centb]->Fill(refpt,wxs*wcen*wvz); hEtaSel[nj][centb]->Fill(refeta,wxs*wcen*wvz); hPhiSel[nj][centb]->Fill(refphi,wxs*wcen*wvz); } //! pile up eta dependence //int ebin = GetDetEtaBin(fabs(recoeta)); //! jet selction cut if(fabs(recoeta)>ketacut)continue; //istat=1; //! 1D distributions njets++; meanpt += refpt; hNjets [nj][centb]->Fill(1.); hgenpt [nj][centb]->Fill(refpt,wxs*wcen*wvz); hgeneta[nj][centb]->Fill(refeta,wxs*wcen*wvz); hgenphi[nj][centb]->Fill(refphi,wxs*wcen*wvz); hrecopt [nj][centb]->Fill(recopt,wxs*wcen*wvz); hrecoeta[nj][centb]->Fill(recoeta,wxs*wcen*wvz); hrecophi[nj][centb]->Fill(recophi,wxs*wcen*wvz); hrawpt [nj][centb]->Fill(rawpt,wxs*wcen*wvz); hgenptC [nj][centb]->Fill(refpt,wxs*wcen*wvz); hrecoptC [nj][centb]->Fill(recopt,wxs*wcen*wvz); hrawptC [nj][centb]->Fill(rawpt,wxs*wcen*wvz); hrecogen[nj][centb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hrawgen [nj][centb]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hrecoraw[nj][centb]->Fill(rawpt,recopt/rawpt,wxs*wcen*wvz); hrecoraw_ref [nj][centb]->Fill(refpt,recopt/rawpt,wxs*wcen*wvz); hFracjets[nj][centb]->Fill(pthat,refpt,wxs*wcen*wvz); //! Response (ratio of recopt/refpt) hratiocorrrefpt[nj][centb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiorawrefpt [nj][centb]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hratiocorrrawpt [nj][centb]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); //! remaing jets bool iRemain = ij!=ljet[0] || ij!=ljet[1]; if(iRemain)hratiocorrrefpt_remain[nj][centb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); //! pT hat hratiocorrrefpt_pthat[nj][centb]->Fill(pthat,recopt/refpt,wxs*wcen*wvz); //! 2D correlation between refpt and recopt hcorrptrefpt[nj][centb]->Fill(refpt,recopt,wxs*wcen*wvz); hrawptrefpt [nj][centb]->Fill(refpt,rawpt,wxs*wcen*wvz); hcorrptrawpt[nj][centb]->Fill(rawpt,recopt,wxs*wcen*wvz); //! Very fine bin in ref pt hrescrpt[nj][centb]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hresrrpt[nj][centb]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); hresrcrpt[nj][centb]->Fill(recopt,recopt/rawpt,wxs*wcen*wvz); int ieta=-1; if(fabs(recoeta)<1.3)ieta=0; //! barrel region else ieta=1; //! HCAL region if(ieta>=0){ hratiocorrrefpt_eta[nj][centb][ieta]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hratiorawrefpt_eta [nj][centb][ieta]->Fill(refpt,rawpt/refpt,wxs*wcen*wvz); } //! pileup study hjetptpu[nj][centb]->Fill(recopt,iJet->jtpu[ij],wxs*wcen*wvz); //! Response in different eta and phi bins int etabin = GetEtaBin(fabs(refeta)); int phibin = GetPhiBin(refphi); if(etabin < 0 || etabin>=maxe || phibin < 0 || phibin>=maxph)continue; //! Response in eta and phi bins hpteta[nj][centb][etabin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); hptphi[nj][centb][phibin]->Fill(refpt,recopt/refpt,wxs*wcen*wvz); //! Gen:Reco correlation plots hgenjrecoj [nj][centb]->Fill(refpt,recopt,wxs*wcen*wvz); if(fabs(refparton_flavor)<=21)hgenjrecoj_pflavor [nj][centb]->Fill(refpt,recopt,wxs*wcen*wvz); }//! ij loop hNevt[nj][centb]->Fill(vz); if(njets>0){ hAvjets[nj][centb]->Fill(pthat,njets,wxs*wcen*wvz); hMeanPtjets[nj][centb]->Fill(pthat,meanpt/njets,wxs*wcen*wvz); } delete [] ljet; }//! nj jet loop if(istat){ hBin->Fill(hiBin,wxs*wcen*wvz); hVz->Fill(vz,wxs*wcen*wvz); hHF->Fill(hiHF,wxs*wcen*wvz); iEvent++; } //std::cout<<"Completed event # "<<ievt<<std::endl; }//! event loop ends std::cout<<std::endl; std::cout<<std::endl; std::cout<<std::endl; std::cout<<"Events which passed the pT hat cut : "<<hTotEve->Integral()<<" out of : "<<hEvt->Integral() <<" efficiency of all the cuts : " <<hTotEve->Integral()/hEvt->Integral()<<std::endl; std::cout<<std::endl; if(strcmp(ksp,"pp")==0){ for(int nj=0;nj<knj;nj++){ //std::cout<<"# of Events for : "<<c->GetCjets[Nj](nj)<<"\t"<<hNevt[nj][0]->Integral()<<"\t # of Jets : "<<hNjets[nj][0]->Integral()<<std::endl; std::cout<<"# of Events for : "<<cjets[nj]<<"\t"<<hNevt[nj][0]->Integral()<<"\t # of Jets : "<<hNjets[nj][0]->Integral()<<std::endl; } }else{ for(int nj=0;nj<knj;nj++){ for(int icen=0;icen<ncen;icen++){ std::cout<<"# of Events for : "<<cjets[nj]<<"\t icen : "<<icen<<"\t"<<hNevt[nj][icen]->Integral()<<"\t # of Jets : "<<hNjets[nj][icen]->Integral()<<std::endl; } std::cout<<std::endl; } } //! Write to output file fout->cd(); fout->Write(); fout->Close(); //! Check timer.Stop(); float mbytes = 0.000001*nb; double rtime = timer.RealTime(); double ctime = timer.CpuTime(); std::cout<<std::endl; std::cout<<Form("RealTime=%f seconds, CpuTime=%f seconds",rtime,ctime)<<std::endl; std::cout<<Form("You read %f Mbytes/RealTime seconds",mbytes/rtime)<<std::endl; std::cout<<Form("You read %f Mbytes/CpuTime seconds",mbytes/ctime)<<std::endl; std::cout<<std::endl; std::cout<<"Good bye : " <<"\t"<<std::endl; return 1; }