void anaAsyJetTrig() { //for ak3PF jets, applied for pPb data only // TFile* fcrel3 = TFile::Open("/net/hidsk0001/d00/scratch/dgulhan/RelativeResponse/Corrections/Casym_pPb_double_hcalbins_algo_ak3PF_pt100_140_jet80_alphahigh_20_phicut250.root", "readonly"); //for akPu3PF jets and pPb data TFile* fcrel3 = TFile::Open("Casym_pPb_double_hcalbins_algo_akPu3PF_pt100_140_jet80_alphahigh_20_phicut250.root", "readonly"); TH1D * C_rel=(TH1D*)fcrel3->Get("C_asym"); // fcrel3->Close(); hist_class *my_hists = new hist_class("pfjet"); cout <<my_hists->IsMC<<endl ; //this function is to correct for UE subtraction (we are using akPu3PF algorithm) TF1 * fUE ; TF1 * fgaus ; if(my_hists->IsMC==kTRUE){ fUE = new TF1("fUE","[0]/pow(x,[1])"); // //for ak3PF jets // fUE->SetParameters(0.4183,0.4244); // //for akPu3PF jets fUE->SetParameters(1.052,0.5261); //for gauss smearing fgaus=new TF1("fgaus","gaus(0)",-20,20); fgaus->SetParameters(1,0,1); } else { fUE = new TF1("fUE","1-[0]/pow(x,[1])",20,300); // //for ak3PF jets // fUE->SetParameters(0.8648,0.8167); // //for akPu3PF jets fUE->SetParameters(0.3015,0.8913); } TF1 * fVz = new TF1("fVx","[0]+[1]*x+[2]*TMath::Power(x,2)+[3]*TMath::Power(x,3)+[4]*TMath::Power(x,4)", -15., 15.); fVz->SetParameters(1.60182e+00,1.08425e-03,-1.29156e-02,-7.24899e-06,2.80750e-05); if(my_hists->IsMC==kTRUE){ pthat=atoi(getenv("PTHAT")) ; ptmax=atoi(getenv("PTMAX")) ; cout <<"pthat = " <<pthat <<" pthatmax =" <<ptmax <<endl ; } std::cout << "start working\n"; if(my_hists->IsMC!=kTRUE){ if(coll=="HI") dataPath="/net/hidsk0001/d00/scratch/yjlee/merge/pbpbDijet_v20" ;//mit PbPb data path else { /* if(TrigName=="Jet20") dataPath="root://eoscms//eos/cms/store/group/phys_heavyions/krajczar/inbound/mnt/hadoop/cms/store/user/krajczar/pPb_Jet20_Full_v1" ; else if(TrigName=="Jet40" || TrigName=="Jet60") dataPath="root://eoscms//eos/cms/store/group/phys_heavyions/krajczar/inbound/mnt/hadoop/cms/store/user/krajczar/pPb_Jet40Jet60_Full_v1" ; else dataPath="root://eoscms//eos/cms/store/group/phys_heavyions/yjlee/pPb2013/promptReco"; */ if(TrigName=="Jet80" || TrigName=="Jet100") dataPath="root://eoscms//eos/cms/store/group/phys_heavyions/yjlee/pPb2013/promptReco"; else dataPath="root://eoscms//eos/cms/store/caf/user/ymao"; } } //data Path else { //MC analysis if(coll=="HI") { if(pthat==50||pthat==80||pthat==100||pthat==170) dataPath= Form("/mnt/hadoop/cms/store/user/yenjie/HiForest_v27/"); //MIT MC normial else dataPath= Form("/mnt/hadoop/cms/store/user/yenjie/HiForest_v28/"); //MIT MC normial } else if(coll=="PPb") dataPath=Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Hijing_Pythia_pt%d/HiForest_v77_merged01", pthat); // dataPath=Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Signal_Pythia_pt%d/HiForest_v77_v2_merged01", pthat); else if(coll=="PbP") dataPath=Form("/mnt/hadoop/cms/store/user/dgulhan/Pbp/HP05/prod24/Hijing_Pythia_pt%d/HiForest_v84_merged02", pthat); else if(coll=="PP2011") dataPath= Form("/net/hisrv0001/home/zhukova/scratch/HIHighPt/forest/pthat%d", pthat); //lxplus path for pp else { if(pthat==220) // dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Signal_Pythia_pt%d/HiForest_v77_v2_merged02", pthat); //2013 pp tracking for 5.02TeV dataPath=Form("/store/user/ymao/HiForest/MC/PYTHIA_Z2_5TeV/"); else // dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Signal_Pythia_pt%d/HiForest_v77_v2_merged01", pthat); //2013 pp tracking for 5.02TeV dataPath=Form("/store/user/ymao/HiForest/MC/PYTHIA_Z2_5TeV/"); } } if(my_hists->IsMC!=kTRUE){ //real data analysis if(coll=="HI") intputFile="promptskim-hihighpt-hltjet80-pt90-v20.root" ; //full dataset else if(coll=="PP2011") intputFile="hiForest2_pp_ppreco_415_90percent.root"; //! 2011 pp data rereco else if(coll=="PbPb") intputFile="PbPHiForest2_PbPbPAHighPtJet80_cent50-100_pprereco.root"; else if(coll=="PPb"){ if(TrigName=="Jet20") // intputFile="mergedJet20_KK.root" ; intputFile="mergedJet20_pPb_Jet20_Full_UsingKKForest_v1.root" ; else if(TrigName=="Jet40" || TrigName=="Jet60") // intputFile="mergedJet40Jet60_KK.root" ; intputFile="mergedJet40Jet60_pPb_Jet40Jet60_Full_UsingKKForest_v1.root" ; else if(TrigName=="Jet80" || TrigName=="Jet100") intputFile="PA2013_HiForest_PromptReco_JSonPPb_forestv77.root" ; else // intputFile="PA2013_HiForest_PromptReco_KrisztianMB_JSonPPb_forestv84.root" ; intputFile="mergedMB_pPb_SingleTrack_Full_UsingKKForest_v1.root" ; } else if(coll=="PbP"){ if(TrigName=="Jet20") intputFile="mergedJet20_KK.root" ; else if(TrigName=="Jet40" || TrigName=="Jet60") intputFile="mergedJet40Jet60_KK.root" ; else if(TrigName=="Jet80" || TrigName=="Jet100") intputFile="PA2013_HiForest_PromptReco_JSonPbp_JECdb_forestv84.root" ; else intputFile="PA2013_HiForest_PromptReco_KrisztianMB_JSonPPb_forestv84.root" ; } else // intputFile="PP2013_HiForest_PromptReco_JsonPP_Jet80_HIReco_forestv84_v2.root"; //! 2013 pp data with HI tracking intputFile="PP2013_HiForest_PromptReco_JsonPP_Jet80_PPReco_forestv82.root"; //! 2013 pp data with pp tracking } else { //MC sample if(coll=="HI"){ if(pthat==50||pthat==80||pthat==100||pthat==170) intputFile=Form("Dijet%d_HydjetDrum_v27_mergedV1.root", pthat); else intputFile=Form("Dijet%d_HydjetDrum_v28_mergedV1.root", pthat); } else if(coll=="PPb") intputFile=Form("pt%d_HP04_prod16_v77_merged_forest_0.root", pthat); // intputFile=Form("pt%d_HP04_hiforest77_hiSignal.root", pthat); else if(coll=="PbP") intputFile=Form("pt%d_HP05_prod24_v84_merged_forest_0.root", pthat); else if(coll=="PP2011") intputFile=Form("mergedFile.root"); // 2011 pp MC else intputFile=Form("pt%d_HP04_hiforest77_hiSignal.root", pthat); // ! 2013 pp 5.02TeV MC with pp tracking } TString inname=Form("%s/%s", dataPath.Data(),intputFile.Data()); // Define the input file and HiForest HiForest * c ; if(coll=="PP" || coll=="PP2011") c = new HiForest(inname,"forest",cPP); else if(coll=="PPb" || coll=="PbP") c = new HiForest(inname,"forest",cPPb); else c = new HiForest(inname,"forest",cPbPb); c->doTrackCorrections = false; c->doTrackingSeparateLeadingSubleading = false; c->InitTree(); // cout << "start working222222\n"; // TFile *my_file=TFile::Open(Form("%s/%s", dataPath.Data(),intputFile.Data())); cout <<"Input file" << inname<<endl ; TrackCorrector corr("trackCorrections_HIN12017v4_HijingCombined.root"); if(doTrackCorrections){ corr.load("trkCorr_HIN12017"); corr.setOption1(true); corr.setOption2(true); } Evts * offSel = &(c->evt); Skims * my_skim = &(c->skim); Hlts * trigSel = &(c->hlt); //jet tree // if(coll=="HI") // Jets * my_ct = &(c->akPu4Calo); Jets * my_ct = &(c->akPu3PF); // else // Jets * my_ct = &(c->ak3PF); // Jets * jetthres = &(c->icPu5); //track tree Tracks * my_tr = &(c->track); //GenParticle tree GenParticles * my_GenPart = &(c->genparticle); int curr_bin = nbin-1 ; int Nevents[nbin] = {0} ; Int_t Nevt_40_60[nbin] = {0} ; Int_t Nevt_60_75[nbin] = {0} ; Int_t Nevt_75_95[nbin] = {0} ; Int_t Nevt_95_120[nbin] = {0} ; Int_t Nevt_120[nbin] = {0} ; cout <<"Number of events ="<<c->GetEntries()<<endl ; for(int evi = 0; evi < c->GetEntries(); evi++) { c->GetEntry(evi); int noise_evt = my_skim->pHBHENoiseFilter ; // int ecal_noise = my_skim->phiEcalRecHitSpikeFilter ; // if(ecal_noise==0) continue ; double vz = offSel->vz ; int hiBin = offSel->hiBin ; weight = 1. ; int pileup_Gplus ; double HFbin ; HFbin = (offSel->hiHFplusEta4)+(offSel->hiHFminusEta4); /* if(coll=="PPb") HFbin = (offSel->hiHFplus); else HFbin = (offSel->hiHFminus); */ if(my_hists->IsMC!=kTRUE){ int evt_sel ; pileup_Gplus = my_skim->pVertexFilterCutGplus ; if(coll=="PbPb"|| coll=="HI"|| coll=="PP2011") evt_sel = my_skim->pcollisionEventSelection ; else evt_sel = my_skim->pPAcollisionEventSelectionPA; // if(evt_sel==0) continue ; if(!evt_sel) continue ; } if(my_hists->IsMC!=kTRUE){ // if(noise_evt==0) continue ; if(!noise_evt) continue ; int jetTr2 ; if(coll=="HI"|| coll=="PbPb") jetTr2 = trigSel->HLT_HIJet80_v1 ; else if (coll=="PP2011") jetTr2 = trigSel->HLT_Jet60_v1 ; else { // jetTr2 = trigSel->HLT_PAJet80_NoJetID_v1 ; if(TrigName=="Jet20") jetTr2 = trigSel->HLT_PAJet20_NoJetID_v1 ; else if(TrigName=="Jet40") jetTr2 = trigSel->HLT_PAJet40_NoJetID_v1 ; else if(TrigName=="Jet60") jetTr2 = trigSel->HLT_PAJet60_NoJetID_v1 ; else if(TrigName=="Jet80") jetTr2 = trigSel->HLT_PAJet80_NoJetID_v1 ; else if(TrigName=="Jet100") jetTr2 = trigSel->HLT_PAJet100_NoJetID_v1 ; else jetTr2 = trigSel->HLT_PAZeroBiasPixel_SingleTrack_v1 ; } if(!jetTr2) continue ; int run=offSel->run ; if( !(my_skim->phfPosFilter1 && my_skim->phfNegFilter1 && my_skim->pBeamScrapingFilter && my_skim->pprimaryvertexFilter)) continue ; if(coll=="PPb"){ // if( my_skim->phfPosFilter1==0 || my_skim->phfNegFilter1==0 ||my_skim->pBeamScrapingFilter==0 || my_skim->pprimaryvertexFilter==0) continue ; if(!pileup_Gplus) continue ; if(run>211256) continue ; if(run<210676) continue ; //remove the runs with old alignment } if(coll=="PbP"){ if(pileup_Gplus==0) continue ; if(run<=211256) continue ; } } if(TMath::Abs(vz)>15.) continue ; if(my_hists->IsMC==kTRUE) weight*=fVz->Eval(vz); //run selection if(my_hists->IsMC!=kTRUE && coll=="PPb") { if(offSel->run<210676 ||offSel->run>211256) //211256: last pPb run (Pb goes to +eta) continue; } bool event_accepted = true; /* if(!(my_skim->pPAcollisionEventSelectionPA && my_skim->phfPosFilter1 && my_skim->phfNegFilter1 && my_skim->pBeamScrapingFilter && my_skim->pprimaryvertexFilter && my_skim->pVertexFilterCutGplus && TMath::Abs(offSel->vz)<15. ) ) event_accepted = false; */ if(event_accepted == false) continue; /* //if there is no jets or no PF candidates, skip the event if(my_ct->nref==0) continue ; */ //put the higher pthat cut if(my_hists->IsMC==kTRUE && my_ct->pthat>ptmax ) continue ; if(my_hists->IsMC==kTRUE && my_ct->pthat<pthat) continue ; if(my_ct->pthat>ptmax) cout <<"pthat =" <<my_ct->pthat <<endl ; if(coll=="HI"|| coll=="PP2011") my_hists->CenBin->Fill(hiBin*2.5); else my_hists->CenBin->Fill(hiBin); my_hists->Vertex->Fill(vz); // cout <<"vz =" <<vz <<endl ; if(coll=="HI"){ double centrality = hiBin*2.5 ; // my_hists->CenBin->Fill(offSel->hiBin); for(int ibin = 0 ; ibin <nbin; ibin++){ if(centrality >=centr[ibin] && centrality<centr[ibin+1]) curr_bin = ibin ; } } else if(coll=="PPb" || coll=="PbP"){ double centrality = HFbin ; for(int ibin = 0 ; ibin <nbin; ibin++){ if(centrality <hfEta4[ibin] && centrality>=hfEta4[ibin+1]) curr_bin = ibin ; } } else { curr_bin=nbin-1 ; // weight = 1. ; } // weight = 1. ; // cout << " cent_bin:" <<curr_bin <<endl ; if(evi%10000==1)cout <<" coll = " <<coll <<" weight = " <<weight <<" evt = " <<evi <<endl ; //cout << "start working222222\n"; // cout << "still working222222\n"; if(my_hists->IsMC==kFALSE)my_hists->VertexWt->Fill(vz+0.4847, weight); else my_hists->VertexWt->Fill(vz, weight); if(coll=="HI"|| coll=="PP2011") my_hists->CenBinWt->Fill(offSel->hiBin*2.5,weight); else my_hists->CenBinWt->Fill(offSel->hiBin,weight); my_hists->NEvents[curr_bin]->Fill(1, weight); //Jets for event weights; eta-pt cut removed int trackMult = 0; double leadingJet = -999.; for(int j4i = 0; j4i < my_ct->nref ; j4i++) { if( my_hists->IsMC==kTRUE && my_ct->subid[j4i] != 0) continue; if (my_ct->rawpt[j4i]<15) continue; if(TMath::Abs(my_ct->jteta[j4i])>3.) continue ; trackMult++; if (my_ct->jtpt[j4i]>leadingJet) { leadingJet = my_ct->jtpt[j4i]; } } /* if(leadingJet<0.) continue ; // Don't analyze 0 multiplicity events; correction added later if(trackMult==0) continue; */ //Tracks for event classification: same as for analysis bool jetAbove = false ; bool jetAbove40 = false; bool jetAbove60 = false; bool jetAbove75 = false; bool jetAbove95 = false; bool jetAbove120 = false; if(leadingJet>40. ){ jetAbove40 = true ; } if(leadingJet>60. ){ jetAbove60 = true ; } if(leadingJet>75. ){ jetAbove75 = true ; } if(leadingJet>95. ){ jetAbove95 = true ; } if(leadingJet>120. ){ jetAbove120 = true ; } if(!jetAbove40) Nevents[curr_bin]++ ; if(jetAbove40 && !jetAbove60) Nevt_40_60[curr_bin]++; if(jetAbove60 && !jetAbove75) Nevt_60_75[curr_bin]++; if(jetAbove75 && !jetAbove95) Nevt_75_95[curr_bin]++; if(jetAbove95 && !jetAbove120) Nevt_95_120[curr_bin]++; if(jetAbove120) Nevt_120[curr_bin]++; if(TrigName=="Jet20") jetAbove = jetAbove40 && !jetAbove60 ; else if(TrigName=="Jet40") jetAbove = jetAbove60 && !jetAbove75 ; else if(TrigName=="Jet60") jetAbove = jetAbove75 && !jetAbove95 ; else if(TrigName=="Jet80") jetAbove = jetAbove95 && !jetAbove120 ; else if(TrigName=="Jet100") jetAbove = jetAbove120 ; else jetAbove = !jetAbove40 ; // if(!jetAbove) continue ; // for inclusive jet analysis for(int j4i = 0; j4i < my_ct->nref ; j4i++) { double jetweight = 1; double jet_pt= my_ct->jtpt[j4i]; double jet_eta = my_ct->jteta[j4i]; double ref_pt ; if(my_hists->IsMC==kTRUE) ref_pt = my_ct->refpt[j4i]; if (my_ct->rawpt[j4i]<15 || jet_pt<0.) continue; int dEtaBin = -1. ; if( my_hists->IsMC==kTRUE && my_ct->subid[j4i] != 0) continue; if(my_hists->IsMC==kTRUE && jet_pt>4*(pthat)) continue ; //for jet kinematcis cuts if(TMath::Abs(jet_eta)<=3.){ // if( my_hists->IsMC!=kTRUE ) jetweight*=(fUE->Eval(jet_pt))*C_rel->GetBinContent(C_rel->FindBin(jet_eta)); // else // jetweight*=((fUE->Eval(jet_pt))*fgaus->GetRandom()+1); my_hists->jetptEta[curr_bin]->Fill(jet_pt*jetweight, jet_eta, weight); if(coll=="PPb"){ if(TMath::Abs(jet_eta+0.465)<=1.) { my_hists->jetpt[curr_bin]->Fill(jet_pt*jetweight, weight); if(my_hists->IsMC==kTRUE) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } } else if(coll=="PbP"){ if(TMath::Abs(jet_eta-0.465)<=1.) { my_hists->jetpt[curr_bin]->Fill(jet_pt*jetweight, weight); if(my_hists->IsMC==kTRUE) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } } else { if(TMath::Abs(jet_eta+0.465)<=1.) { my_hists->jetpt[curr_bin]->Fill(jet_pt*jetweight, weight); if(my_hists->IsMC==kTRUE) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } } // if(coll=="PP" && TMath::Abs(jet_eta)<=1.) my_hists->jetpt[curr_bin]->Fill(jet_pt*jetweight, weight); if((jet_pt*jetweight)>100.) my_hists->jetEta[curr_bin]->Fill(jet_eta, weight); for(Int_t ieta = 0 ; ieta <netabin; ieta++){ if(coll=="PPb"){ if((jet_eta+0.465)>deta[ieta]&&(jet_eta+0.465)<=deta[ieta+1]) dEtaBin = ieta ; } else if(coll=="PbP"){ if((jet_eta-0.465)>deta[ieta]&&(jet_eta-0.465)<=deta[ieta+1]) dEtaBin = ieta ; } else { // if((jet_eta)>deta[ieta]&&(jet_eta)<=deta[ieta+1]) dEtaBin = ieta ; if((jet_eta+0.465)>deta[ieta]&&(jet_eta+0.465)<=deta[ieta+1]) dEtaBin = ieta ; } } //assign the eta bin for jets if(dEtaBin!=-1){ my_hists->jetptEtaBin[curr_bin][dEtaBin]->Fill(jet_pt*jetweight, weight); my_hists->NjetsEtaBin[curr_bin][dEtaBin]->Fill(1); if(my_hists->IsMC==kTRUE) my_hists->refjetptEtaBin[curr_bin][dEtaBin]->Fill(ref_pt, weight); } }// for jet kinematics cuts /* //MC histograms if(my_hists->IsMC==kTRUE&&DoGenAna){ double ref_pt= my_ct->refpt[j4i]; double ref_eta = my_ct->refeta[j4i]; Int_t GenEtaBin = -1 ; if(TMath::Abs(ref_eta)<=3.&& ref_pt>0.){ if(coll=="PPb" ){ if(TMath::Abs(ref_eta+0.465)<=1.) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } else if(coll=="PbP"){ if(TMath::Abs(ref_eta-0.465)<=1.) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } else { if(TMath::Abs(ref_eta+0.465)<=1.) my_hists->refjetpt[curr_bin]->Fill(ref_pt, weight); } for(Int_t ieta = 0 ; ieta <netabin; ieta++){ if(coll=="PPb"){ if((ref_eta+0.465)>deta[ieta]&&(ref_eta+0.465)<=deta[ieta+1]) GenEtaBin = ieta ; } else if(coll=="PbP"){ if((ref_eta-0.465)>deta[ieta]&&(ref_eta-0.465)<=deta[ieta+1]) GenEtaBin = ieta ; } else { if((ref_eta+0.465)>deta[ieta]&&(ref_eta+0.465)<=deta[ieta+1]) GenEtaBin = ieta ; } } //assign the eta bin for jets if(GenEtaBin!=-1){ my_hists->refjetptEtaBin[curr_bin][GenEtaBin]->Fill(ref_pt, weight); } } //ref jet kinematics cut } //MC histograms */ } //! jet loop //Leading Jets seach, for tracking efficiency double leadingJetPt = -1. ; Int_t leadingJetIndex = -1 ; for(int j = 0; j < my_ct->nref ; j++) { if (fabs(my_ct->jteta[j])>2.5) continue; if (my_ct->rawpt[j]<15) continue; if( my_hists->IsMC==kTRUE && my_ct->subid[j] != 0) continue; if (my_ct->jtpt[j]>leadingJetPt) { leadingJetPt = my_ct->jtpt[j]; leadingJetIndex = j; } } if(leadingJetPt==-1) //for corrections leadingJetPt=10.; //for inclusive track analysis, without jet selection and requirement for(int itr = 0 ; itr < my_tr->nTrk ; itr++){ double tr_pt = my_tr->trkPt[itr]; double tr_phi = my_tr->trkPhi[itr]; double tr_eta = my_tr->trkEta[itr]; if(TMath::Abs(tr_eta)>2.4) continue ; // if(my_tr->trkPtError[itr]/my_tr->trkPt[itr]>=0.1 || TMath::Abs(my_tr->trkDz1[itr]/my_tr->trkDzError1[itr])>=3.0 ||TMath::Abs(my_tr->trkDxy1[itr]/my_tr->trkDxyError1[itr])>=3.0) continue ; //ridge cut for tracks if(!((my_tr->highPurity[itr]) && (fabs(my_tr->trkDz1[itr]/my_tr->trkDzError1[itr])<3) && (fabs(my_tr->trkDxy1[itr]/my_tr->trkDxyError1[itr])<3) && (my_tr->trkPtError[itr]/my_tr->trkPt[itr]<0.1) )) continue; Int_t TrkEtaBin = -1 ; for(Int_t ieta = 0 ; ieta <ntrketabin; ieta++){ if(coll=="PPb"){ if((tr_eta+0.465)>dtrketa[ieta]&&(tr_eta+0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } else if(coll=="PbP"){ if((tr_eta-0.465)>dtrketa[ieta]&&(tr_eta-0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } else // if((tr_eta)>dtrketa[ieta]&&(tr_eta)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; if((tr_eta+0.465)>dtrketa[ieta]&&(tr_eta+0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } if((my_tr->highPurity[itr])){ // if(tr_pt<trackcut) continue ; double trkweight=1. ; if(doTrackCorrections){ // if(corrMet=="Hist")trkweight = c->getTrackCorrection(itr); // else trkweight = c->getTrackCorrectionPara(itr); trkweight = corr.getWeight(tr_pt,tr_eta,leadingJetPt); } my_hists->inctrkpt[curr_bin]->Fill(tr_pt, weight*trkweight); if(coll=="PPb"){ if(TMath::Abs(tr_eta+0.465)<=1.) my_hists->inctrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } else if(coll=="PbP"){ if( TMath::Abs(tr_eta-0.465)<=1.) my_hists->inctrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } else { if(TMath::Abs(tr_eta+0.465)<=1.) my_hists->inctrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } // if(coll=="PP" &&TMath::Abs(tr_eta)<=1.) my_hists->inctrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); my_hists->Ntrack[curr_bin]->Fill(1); if(TrkEtaBin!=-1) my_hists->inctrkptEtaBin[curr_bin][TrkEtaBin]->Fill(tr_pt, weight*trkweight); if(TrkEtaBin!=-1) my_hists->NtrkEtaBin[curr_bin][TrkEtaBin]->Fill(1); } //! high purity track cuts } //! inclusive track loop // for jet-track analysis for(int j4i = 0; j4i < my_ct->nref ; j4i++) { TVector3 jet_vec; TVector3 track_vec; jet_vec.SetPtEtaPhi(0, 0, 0); track_vec.SetPtEtaPhi(0, 0, 0); double jetweight = 1; double jet_pt= my_ct->jtpt[j4i]; double jet_eta = my_ct->jteta[j4i]; double jet_phi = my_ct->jtphi[j4i]; if (my_ct->rawpt[j4i]<15) continue; int dEtaBin = -1. ; if( my_hists->IsMC==kTRUE && my_ct->subid[j4i]!= 0) continue; //for jet kinematcis cuts if(TMath::Abs(jet_eta)<=3.){ // if( my_hists->IsMC!=kTRUE ) jetweight*=(fUE->Eval(jet_pt))*C_rel->GetBinContent(C_rel->FindBin(jet_eta)); // else // jetweight*=((fUE->Eval(jet_pt))*fgaus->GetRandom()+1); jet_vec.SetPtEtaPhi(jet_pt, jet_eta, jet_phi); // for track loop in each jet, do jet-track analysis for(int itr = 0 ; itr < my_tr->nTrk ; itr++){ double tr_pt = my_tr->trkPt[itr]; double tr_phi = my_tr->trkPhi[itr]; double tr_eta = my_tr->trkEta[itr]; if(TMath::Abs(tr_eta)>2.4) continue ; if(!((my_tr->highPurity[itr]) && (fabs(my_tr->trkDz1[itr]/my_tr->trkDzError1[itr])<3) && (fabs(my_tr->trkDxy1[itr]/my_tr->trkDxyError1[itr])<3) && (my_tr->trkPtError[itr]/my_tr->trkPt[itr]<0.1) )) continue; Int_t TrkEtaBin = -1 ; for(Int_t ieta = 0 ; ieta <ntrketabin; ieta++){ if(coll=="PPb"){ if((tr_eta+0.465)>dtrketa[ieta]&&(tr_eta+0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } else if(coll=="PbP"){ if((tr_eta-0.465)>dtrketa[ieta]&&(tr_eta-0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } else if((tr_eta+0.465)>dtrketa[ieta]&&(tr_eta+0.465)<=dtrketa[ieta+1]) TrkEtaBin = ieta ; } track_vec.SetPtEtaPhi(tr_pt, tr_eta, tr_phi); if((my_tr->highPurity[itr])){ // if(tr_pt<trackcut) continue ; double trkweight=1. ; double dr = jet_vec.DeltaR(track_vec); if(dr>conesize) continue ; if(doTrackCorrections){ // if(corrMet=="Hist")trkweight = c->getTrackCorrection(itr); // else trkweight = c->getTrackCorrectionPara(itr); trkweight = corr.getWeight(tr_pt,tr_eta,leadingJetPt); } my_hists->jettrkpt[curr_bin]->Fill(jet_pt*jetweight, tr_pt, weight*trkweight); if(coll=="PPb"){ if( TMath::Abs(tr_eta+0.465)<=1.) my_hists->jettrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } else if(coll=="PbP") { if(TMath::Abs(tr_eta-0.465)<=1.) my_hists->jettrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } else { if(TMath::Abs(tr_eta+0.465)<=1.) my_hists->jettrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); } if(TrkEtaBin!=-1) my_hists->jettrkPtEtaBin[curr_bin][TrkEtaBin]->Fill(tr_pt, weight*trkweight); } //! high purity track cuts } //end of track loop } //jet kinematics } //jet loop if(my_hists->IsMC==kTRUE&&DoGenAna){ //using the sim track to calculate the tracking efficiency for(int ipart = 0 ; ipart < my_tr->nParticle ; ipart++){ //sim track loop double gen_pt = my_tr->pPt[ipart]; double gen_phi = my_tr->pPhi[ipart]; double gen_eta = my_tr->pEta[ipart]; // if(gen_pt<trackcut)continue ; if(TMath::Abs(gen_eta)>2.4)continue ; if(my_tr->pNRec[ipart]>0&&((my_tr->mtrkQual[ipart]))) { if((my_tr->mtrkPtError[ipart]/my_tr->mtrkPt[ipart]<0.1 && TMath::Abs(my_tr->mtrkDz1[ipart]/my_tr->mtrkDzError1[ipart])<3.0 && TMath::Abs(my_tr->mtrkDxy1[ipart]/my_tr->mtrkDxyError1[ipart])<3.0)){ my_hists->incgenmatchpt[curr_bin]->Fill(gen_pt, weight); } //tracking cut } // matching hist my_hists->incgenpartpt[curr_bin]->Fill(gen_pt,weight); } //! sim track loop } //only runs on MC } ///event loop my_hists->NevtCounter[curr_bin]->SetBinContent(1, Nevents[curr_bin]); my_hists->JetAbove40[curr_bin]->SetBinContent(1, Nevt_40_60[curr_bin]); my_hists->JetAbove60[curr_bin]->SetBinContent(1, Nevt_60_75[curr_bin]); my_hists->JetAbove75[curr_bin]->SetBinContent(1, Nevt_75_95[curr_bin]); my_hists->JetAbove95[curr_bin]->SetBinContent(1, Nevt_95_120[curr_bin]); my_hists->JetAbove120[curr_bin]->SetBinContent(1, Nevt_120[curr_bin]); my_hists->Write(); // my_hists->Delete(); // delete my_hists; std::cout << "working done\n"; }
void gammaJetRapidity_energyClosure() { TH1::SetDefaultSumw2(); TString file; file = "/mnt/hadoop/cms/store/user/luck/pA2013_MC/HiForest2_QCDPhoton30_5020GeV_100k.root"; HiForest *c = new HiForest(file, "Forest", cPPb, true); c->InitTree(); TProfile *mcClosure = new TProfile("mcClosure",";p_{T}^{gen};<p_{T}^{reco}/p_{T}^{gen}>",40,0,300); Int_t notMatched = 0; //loop over events in each file int nentries = c->GetEntries(); for(int jentry = 0; jentry<nentries; jentry++) { if (jentry% 1000 == 0) { printf("%d / %d\n",jentry,nentries); } c->GetEntry(jentry); //event selection (mc only) if( !( c->skim.phfPosFilter1 && c->skim.phfNegFilter1 && c->skim.phltPixelClusterShapeFilter && c->skim.pprimaryvertexFilter) ) continue; if(c->photon.nPhotons == 0) continue; //loop over photons in the event Float_t leadingPt = 0; Int_t leadingIndex = -1; for(int i = 0; i<c->photon.nPhotons; i++) { if(c->photon.pt[i] > leadingPt) { leadingPt = c->photon.pt[i]; leadingIndex = i; } } if(leadingIndex == -1) continue; if(c->photon.isGenMatched[leadingIndex]) { Double_t genPt = c->photon.genMatchedPt[leadingIndex]; Double_t ratio = leadingPt/genPt; mcClosure->Fill(genPt,ratio); } else { notMatched++; } } mcClosure->Draw(); mcClosure->GetYaxis()->SetRangeUser(0.,2.); TLine *line = new TLine(0, 1, 300, 1); line->Draw(); drawText("Leading Photons",0.75,0.75); printf("Number of not matched leading photons: %d\n",notMatched); }