void skimTree(char *infname = "../JetSample/hiForest_Jet80or95_GR_R_53_LV6_12Mar2014_0000CET_Track8_Jet21_0.root") { // Define the input file and HiForest HiForest *c = new HiForest(infname); c->hasHltTree=0; c->hasPFTree=0; c->hasPhotonTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasAk5CaloJetTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->hasAkPu5CaloJetTree=0; c->hasAkPu2JetTree=0; c->hasAkPu3JetTree=0; c->hasAkPu4JetTree=0; c->hasAkPu5JetTree=0; c->hasAkVs2PFJetTree=0; c->hasAkVs3PFJetTree=0; c->hasAkVs4PFJetTree=0; c->hasAkVs5PFJetTree=0; c->SetOutputFile("skim_jet.root"); int filtered=0; // Main loop for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); if (i%1000==0) cout <<filtered<<" "<<i<<" / "<<c->GetEntries()<<endl; //if (c->evt.hiBin>=20) continue; int flag=0; int flag2=0; for (int j=0;j<c->akVs3Calo.nref;j++) { if (fabs(c->akVs3Calo.jteta[j])>2) continue; if (c->akVs3Calo.jtpt[j]>120) flag=1; if (c->akVs3Calo.jtpt[j]>50) flag2++; if (flag>=1&&flag2>=2) break; } if (flag>=1&&flag2>=2) { c->FillOutput(); // Write output forest filtered++; } } delete c; }
void correlateEvent(char *infname = "0.root", char *mbname = "mb.root", char *outfname = "matched_Jet.root",int startEntry=0,int endEntry=0) { // Define the input file and HiForest HiForest *d = new HiForest(mbname); turnOffBranches(d); d->SetOutputFile(outfname); cout <<"good good"<<endl; HiForest *c = new HiForest(infname); turnOffBranches(c); int filtered=0; int idx=0; // Main loop if (endEntry==0) endEntry=c->GetEntries(); for (int i=startEntry;i<=endEntry;i++) { c->GetEntry(i); if (i%100==0) cout <<filtered<<" "<<i<<" / "<<c->GetEntries()<<endl; int nMatched=0; while (nMatched<20) { idx++; cout <<i<<" / " << c->GetEntries() << " / "<<idx<<" / "<<nMatched<<"\r"; if (idx>=d->GetEntries()) idx=0; if (idx==i) continue; d->evtTree->GetEntry(idx); if ((fabs(c->evt.hiBin-d->evt.hiBin)/(double)c->evt.hiBin)>0.05) continue; if ((fabs(c->evt.vz-d->evt.vz)>1)) continue; d->skimTree->GetEntry(idx); if (!(d->skim.pcollisionEventSelection && d->skim.pHBHENoiseFilter )) continue; nMatched++; d->GetEntry(idx); d->FillOutput(); // Write output forest } cout <<std::endl; } delete c; delete d; }
void stdsort(int startline = 0, string flist = "") { //! Define the input and output file and HiForest string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile(flist.data()); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } cout<<" here"<<endl; HiForest *c = new HiForest(listoffiles[startline].data(),0,0,0,0,true); TFile * outf = new TFile(Form("sortedHiForest_%d.root",startline),"recreate"); c->outf = outf; c->SetOutputFile("null",true); c->LoadNoTrees(); c->hasEvtTree = true; //! loop through all the events once to construct the cent,vz pair array we'll be sorting over cout << "Constructing the cent:vz pair array..." << endl; for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); pair<int,double> centvz; centvz.first = c->evt->hiBin; centvz.second = c->evt->vz; evtCentVz.push_back(centvz); if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl; } c->ResetBooleans(); //! Make the index array which will get sorted on first centrality int evtindecies[c->GetEntries()]; for (int i=0;i<c->GetEntries();i++) { evtindecies[i] = i; } cout << "Sorting the cent:vz pair array..." << " "<<c->setupOutput<<endl; //! Sort the index array first on the centrality bin, then on the vz of the entry at that index qsort (evtindecies, c->GetEntries(), sizeof(int), comparecentvz); //! Now fill the tree in the new order cout << "Filling the tree in the sorted order..." << " "<<c->setupOutput<<endl; for (int i=0;i<c->GetEntries();i++) { c->GetEntry(evtindecies[i]); c->FillOutput(); if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl; } delete c; }
void noiseSkim(char *infname = "/d100/yjlee/hiForest/PromptReco2011/HIHighPt/skim_Photon35/merged_HIData2011_HIHighPt_highPtExercise_photonSkim35GeVEB.root") { // Define the input file and HiForest HiForest *c = new HiForest(infname); c->SetOutputFile("skim_jet.root"); // Main loop for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<endl; if (c->akPu3PF.jtpt[0]>=98||c->akPu2PF.jtpt[0]>=98&&c->akPu4PF.jtpt[0]>98){ c->FillOutput(); // Write output forest } } delete c; }
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; }
void test(char * tag= "0", char *infName = "/d102/yjlee/hiForest2MC/Pythia80_HydjetDrum_mix01_HiForest2_v22_simTrack05.root") { // Define the input file and HiForest HiForest *c = new HiForest(infName,"",cPPb); c->hasPFTree=0; c->hasPhotonTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; // c->doTrackCorrections=1; // c->InitTree(); // Output file TFile *output = new TFile(Form("output-%s.root",tag),"recreate"); // Output TTree * t = new TTree("t","gammajet"); JetData data(t,1); HistoData histos_MergedGeneralCalo("MergedGeneral"); HistoData histos2_MergedGeneral("MergedGeneral2"); // phi dependent corr TH1D *hWeight = new TH1D("hWeight","",1000,0,100); TH1D *hWeight2 = new TH1D("hWeight2","",1000,0,100); TH1D *hPt = new TH1D("hPt","",100,0,100); TH1D *hNoWPt = new TH1D("hNoWPt","",100,0,100); TNtuple *nt = new TNtuple("nt","","m:eta:phi:pt:pt1:pt2:ch1:ch2:phi1:phi2:dxy1:dxy2:hiBin:N"); TNtuple *ntEvt = new TNtuple("ntEvt","","N"); nt->SetAutoFlush(30000); cout <<nt->GetAutoFlush()<<endl; TCanvas *cc = new TCanvas("cc","",600,600); // nt->SetCircular(1000); // Main loop TLorentzVector *v2 = new TLorentzVector; TLorentzVector *v = new TLorentzVector; TLorentzVector phi; for (int i=0;i<c->GetEntries()/1.;i++) { c->GetEntry(i); if (!c->selectEvent()) continue; if (i%1000==0){ cout <<i<<" / "<<c->GetEntries()<<endl; } int N=0; for (int j=0;j<c->track.nTrk;j++) { if (!c->selectTrack(j)) continue; if (fabs(c->track.trkEta[j])>2.4) continue; if (fabs(c->track.trkPt[j])<0.4) continue; N++; } ntEvt->Fill(N); for (int j=0;j<c->track.nTrk;j++) { if (!c->selectTrack(j)) continue; if (fabs(c->track.trkPt[j])<1) continue; // if (fabs(c->track.trkDxy1[j]/c->track.trkDxyError1[j])<1) continue; for (int k=j+1;k<c->track.nTrk;k++) { if (j==k) continue; if (!c->selectTrack(k)) continue; // if (c->track.trkCharge[k]==c->track.trkCharge[j]) continue; if (fabs(c->track.trkPt[k])<1) continue; v->SetPtEtaPhiM(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],0.493677); v2->SetPtEtaPhiM(c->track.trkPt[k],c->track.trkEta[k],c->track.trkPhi[k],0.493677); // v2->SetPtEtaPhiM(c->track.trkPt[k],c->track.trkEta[k],c->track.trkPhi[k],0.13957); // v->SetPtEtaPhiM(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],0.938272); // v->SetPtEtaPhiM(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],0.13957); // v2->SetPtEtaPhiM(c->track.trkPt[k],c->track.trkEta[k],c->track.trkPhi[k],0.13957); phi = (*v) + (*v2); // if ((phi.M())>5) { if ((phi.M())>1.2||phi.M()<0.0) { // phi.Delete(); continue; } nt->Fill(phi.M(),phi.Eta(),phi.Phi(),phi.Pt(),v->Pt(),v2->Pt(),c->track.trkCharge[j],c->track.trkCharge[k],v->Phi(),v2->Phi(),c->track.trkDxy1[j],c->track.trkDxy1[k],c->evt.hiBin,N); // phi.Delete(); } } //cout <<data.mpt<<endl; t->Fill(); } // t->Write(); histos_MergedGeneralCalo.calcEff(); histos2_MergedGeneral.calcEff(); output->Write(); output->Close(); }
void anaJetTrackRpA() { std::cout << "start working\n"; TFile *fcrel3 ; TH1D *C_rel ; //for ak3PF jets, applied for pPb data only // TFile* fcrel3 = TFile::Open("/afs/cern.ch/user/d/dgulhan/public/Corrections/Casym_pPb_double_hcalbins_algo_ak3PF_pt100_140_jet80_alphahigh_20_phicut250.root", "readonly"); //for akPu3PF jets and pPb data if(coll=="PPb") fcrel3 = TFile::Open(Form("/afs/cern.ch/user/d/dgulhan/public/Corrections/Casym_pPb_double_hcalbins_algo_%s_pt100_140_jet80_alphahigh_20_phicut250.root", algo.Data()), "readonly"); if(coll=="PbP") fcrel3 = TFile::Open(Form("/afs/cern.ch/user/d/dgulhan/public/Corrections/Casym_Pbp_double_hcalbins_algo_%s_pt100_140_jet80_alphahigh_20_phicut250.root", algo.Data()), "readonly"); if(fcrel3) C_rel=(TH1D*)fcrel3->Get("C_asym"); // fcrel3->Close(); TrigName=getenv("TRIG"); hist_class *my_hists = new hist_class("pfjet"); cout <<my_hists->IsMC<<endl ; cout <<"analysis trig = " <<TrigName <<endl ; //this function is to correct for UE subtraction (we are using akPu3PF algorithm) TF1 * fUE ; TF1 * fgaus ; fgaus=new TF1("fgaus","gaus(0)",-20,20); 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 if(algo=="akPu3PF") fUE->SetParameters(1.052,0.5261); else fUE->SetParameters(0.4183,0.4244); //for gauss smearing 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 if(algo=="akPu3PF") fUE->SetParameters(0.3015,0.8913); else fUE->SetParameters(0.8648,0.8167); } 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 ; } 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 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 } } 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" ; 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_JSonPbp_JECdb_forestv84.root" ; else // intputFile="PA2013_HiForest_PromptReco_KrisztianMB_JSonPPb_forestv84.root" ; intputFile="mergedMB_pPb_SingleTrack_Full_UsingKKForest_v1.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); } */ TrackCorrector2D corr("/afs/cern.ch/work/y/ymao/analysis/AsymmetryPA/Corrections/trackCorrections_HIN12017v5_XSecWeighted.root"); if(doTrackCorrections) corr.load("trkCorr_HIN12017"); Evts * offSel = &(c->evt); Skims * my_skim = &(c->skim); Hlts * trigSel = &(c->hlt); //jet tree // if(coll=="HI") Jets * my_ct = &(c->akPu4PF); // Jets * my_ct = &(c->akPu4Calo); // 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 ; //for 0-90% selection using HF sum energy at |eta|>4 // if(HFbin<2.87) continue ; //for 0-90% selection using HF sum energy at eta>4 // if(HFbin<2.66) 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(evi%10000==1)cout <<" coll = " <<coll <<" weight = " <<weight <<" evt = " <<evi <<endl ; 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_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); //Tracks for event weights; eta-pt cut removed int trackMult = 0; for(int j=0;j<my_tr->nTrk;j++) { if(!((my_tr->highPurity[j]) && (fabs(my_tr->trkDz1[j]/my_tr->trkDzError1[j])<3) && (fabs(my_tr->trkDxy1[j]/my_tr->trkDxyError1[j])<3) && (my_tr->trkPtError[j]/my_tr->trkPt[j]<0.1) )) continue; trackMult++; } // Don't analyze 0 multiplicity events; correction added later if(trackMult==0) continue; // double evtWeight = 1.; // evtWeight = corr.getEventWeight(trackMult); weight*=corr.getEventWeight(trackMult); my_hists->NEvents[curr_bin]->Fill(1, weight); //Jets for event classification int jetMult = 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(TMath::Abs(my_ct->jteta[j4i])>3.) continue ; jetMult++; if (my_ct->rawpt[j4i]<15) continue; 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]++ ; else if(jetAbove40 && !jetAbove60) Nevt_40_60[curr_bin]++; else if(jetAbove60 && !jetAbove75) Nevt_60_75[curr_bin]++; else if(jetAbove75 && !jetAbove95) Nevt_75_95[curr_bin]++; else if(jetAbove95 && !jetAbove120) Nevt_95_120[curr_bin]++; // if(jetAbove120) Nevt_120[curr_bin]++; else 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 raw_pt= my_ct->rawpt[j4i]; double jet_eta = my_ct->jteta[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.){ my_hists->jetptJES[curr_bin]->Fill(jet_pt, raw_pt/jet_pt, weight); 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(coll=="PbP"){ if(TMath::Abs(jet_eta-0.465)<=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+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); } }// for jet kinematics cuts } //! 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+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); trkweight = corr.getWeight(tr_pt,tr_eta,0.); } 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); } 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 TVector3 jet_vec; TVector3 track_vec; for(int j4i = 0; j4i < my_ct->nref ; j4i++) { 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); trkweight = corr.getWeight(tr_pt,tr_eta,0.); } my_hists->jettrkpt[curr_bin]->Fill(jet_pt*jetweight, tr_pt, weight*trkweight); if(coll=="PPb" && TMath::Abs(tr_eta+0.465)<=1.) my_hists->jettrkptM1P1[curr_bin]->Fill(tr_pt, weight*trkweight); if(coll=="PbP" && 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 my_hists->NevtCounter[curr_bin]->SetBinContent(1, Nevents[curr_bin]*weight); my_hists->JetAbove40[curr_bin]->SetBinContent(1, Nevt_40_60[curr_bin]*weight); my_hists->JetAbove60[curr_bin]->SetBinContent(1, Nevt_60_75[curr_bin]*weight); my_hists->JetAbove75[curr_bin]->SetBinContent(1, Nevt_75_95[curr_bin]*weight); my_hists->JetAbove95[curr_bin]->SetBinContent(1, Nevt_95_120[curr_bin]*weight); my_hists->JetAbove120[curr_bin]->SetBinContent(1, Nevt_120[curr_bin]*weight); } ///event loop my_hists->Write(); // my_hists->Delete(); // delete my_hists; std::cout << "working done\n"; }
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; }
void partonFlavorTree(double tag=0, char *infName = "/mnt/hadoop/cms/store/user/dgulhan/HIMC/Jet80/Track8_Jet21_STARTHI53_LV1/merged3/HiForest_Pythia_Hydjet_Jet80_Track8_Jet21_STARTHI53_LV1_merged_forest_0.root",collisionType cType = cPbPb) { // Define the input file and HiForest HiForest *c = new HiForest(infName,"",cType); c->hasHltTree=0; c->hasPFTree=0; c->hasPhotonTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasAk5CaloJetTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->hasAkPu5CaloJetTree=0; c->hasAkPu2JetTree=0; c->hasAkPu3JetTree=0; c->hasAkPu4JetTree=0; c->hasAkPu5JetTree=0; c->hasAkVs2PFJetTree=0; c->hasAkVs3PFJetTree=0; c->hasAkVs4PFJetTree=0; c->hasAkVs5PFJetTree=0; // c->doTrackCorrections=1; // c->InitTree(); // Output file TFile *output = new TFile(Form("output-%.0f.root",tag),"recreate"); // Output TTree * t = new TTree("t","gammajet"); JetData data(t,1); TH1D *hWeight = new TH1D("hWeight","",1000,0,100); TH1D *hWeight2 = new TH1D("hWeight2","",1000,0,100); TH1D *hPt = new TH1D("hPt","",150,0,150); TH1D *hGenPt = new TH1D("hGenPt","",150,0,150); TH1D *hNoWPt = new TH1D("hNoWPt","",150,0,150); TH1D *hRmin = new TH1D("hRmin","",100,0,10); // Main loop for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); data.hiBin = c->evt.hiBin; if (i % 1000 == 0) cout <<i<<" / "<<c->GetEntries()<<endl; // Event selection // if (fabs(c->evt.vz)>15) continue; // if (!c->selectEvent()) continue; // Select leading and subleading jet data.nJet=0; for (int j=0;j<c->akVs3Calo.nref;j++) { if (fabs(c->akVs3Calo.jteta[j])>2) continue; if (c->akVs3Calo.jtpt[j]<100) continue; data.jetPt[data.nJet]=c->akVs3Calo.jtpt[j]; data.jetEta[data.nJet]=c->akVs3Calo.jteta[j]; data.jetPhi[data.nJet]=c->akVs3Calo.jtphi[j]; data.jetFlavor[data.nJet]=c->akVs3Calo.refparton_flavor[j]; data.refPt[data.nJet]=c->akVs3Calo.refpt[j]; // cout <<data.nJet<<endl; data.jetTrkMult1[data.nJet]=0; data.jetTrkMult2[data.nJet]=0; data.jetTrkMult3[data.nJet]=0; data.jetTrkMult4[data.nJet]=0; data.jetTrkMult5[data.nJet]=0; data.jetTrkMult6[data.nJet]=0; data.jetTrkMult7[data.nJet]=0; data.jetTrkMult8[data.nJet]=0; data.jetTrkSum1[data.nJet]=0; data.jetTrkSum2[data.nJet]=0; data.jetTrkSum3[data.nJet]=0; data.jetTrkSum4[data.nJet]=0; data.jetTrkSum5[data.nJet]=0; data.jetTrkSum6[data.nJet]=0; data.jetTrkSum7[data.nJet]=0; data.jetTrkSum8[data.nJet]=0; data.jetTrkW1[data.nJet]=0; data.jetTrkW2[data.nJet]=0; data.jetTrkW3[data.nJet]=0; data.jetTrkW4[data.nJet]=0; data.jetTrkW5[data.nJet]=0; data.jetTrkW6[data.nJet]=0; data.jetTrkW7[data.nJet]=0; data.jetTrkW8[data.nJet]=0; for (int k=0;k<c->track.nTrk;k++) { if (fabs(c->track.trkEta[k])>2.4) continue; if ((c->track.trkPt[k])<4) continue; if (!(c->track.highPurity[k] && fabs(c->track.trkDxy1[k]/c->track.trkDxyError1[k])<3.0 && fabs(c->track.trkDz1[k]/c->track.trkDzError1[k])<3.0 && (c->track.trkPtError[k]/c->track.trkPt[k])<0.1)) continue; double dR = c->getDR( c->track.trkEta[k], c->track.trkPhi[k], data.jetEta[data.nJet], data.jetPhi[data.nJet]); double dR2 = c->getDR( c->track.trkEta[k], c->track.trkPhi[k], -data.jetEta[data.nJet], data.jetPhi[data.nJet]); if (dR<0.1) data.jetTrkMult1[data.nJet]++; if (dR<0.2) data.jetTrkMult2[data.nJet]++; if (dR<0.3) data.jetTrkMult3[data.nJet]++; if (dR<0.4) data.jetTrkMult4[data.nJet]++; if (dR<0.5) data.jetTrkMult5[data.nJet]++; if (dR<0.6) data.jetTrkMult6[data.nJet]++; if (dR<0.7) data.jetTrkMult7[data.nJet]++; if (dR<0.8) data.jetTrkMult8[data.nJet]++; if (dR2<0.1) data.jetTrkMult1[data.nJet]--; if (dR2<0.2) data.jetTrkMult2[data.nJet]--; if (dR2<0.3) data.jetTrkMult3[data.nJet]--; if (dR2<0.4) data.jetTrkMult4[data.nJet]--; if (dR2<0.5) data.jetTrkMult5[data.nJet]--; if (dR2<0.6) data.jetTrkMult6[data.nJet]--; if (dR2<0.7) data.jetTrkMult7[data.nJet]--; if (dR2<0.8) data.jetTrkMult8[data.nJet]--; if (dR<0.1) data.jetTrkW1[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.2) data.jetTrkW2[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.3) data.jetTrkW3[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.4) data.jetTrkW4[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.5) data.jetTrkW5[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.6) data.jetTrkW6[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.7) data.jetTrkW7[data.nJet]+=c->track.trkPt[k]*dR; if (dR<0.8) data.jetTrkW8[data.nJet]+=c->track.trkPt[k]*dR; /* if (dR2<0.1) data.jetTrkW1[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.2) data.jetTrkW2[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.3) data.jetTrkW3[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.4) data.jetTrkW4[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.5) data.jetTrkW5[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.6) data.jetTrkW6[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.7) data.jetTrkW7[data.nJet]-=c->track.trkPt[k]*dR; if (dR2<0.8) data.jetTrkW8[data.nJet]-=c->track.trkPt[k]*dR; */ if (dR<0.1) data.jetTrkSum1[data.nJet]+=c->track.trkPt[k]; if (dR<0.2) data.jetTrkSum2[data.nJet]+=c->track.trkPt[k]; if (dR<0.3) data.jetTrkSum3[data.nJet]+=c->track.trkPt[k]; if (dR<0.4) data.jetTrkSum4[data.nJet]+=c->track.trkPt[k]; if (dR<0.5) data.jetTrkSum5[data.nJet]+=c->track.trkPt[k]; if (dR<0.6) data.jetTrkSum6[data.nJet]+=c->track.trkPt[k]; if (dR<0.7) data.jetTrkSum7[data.nJet]+=c->track.trkPt[k]; if (dR<0.8) data.jetTrkSum8[data.nJet]+=c->track.trkPt[k]; /* if (dR2<0.1) data.jetTrkSum1[data.nJet]-=c->track.trkPt[k]; if (dR2<0.2) data.jetTrkSum2[data.nJet]-=c->track.trkPt[k]; if (dR2<0.3) data.jetTrkSum3[data.nJet]-=c->track.trkPt[k]; if (dR2<0.4) data.jetTrkSum4[data.nJet]-=c->track.trkPt[k]; if (dR2<0.5) data.jetTrkSum5[data.nJet]-=c->track.trkPt[k]; if (dR2<0.6) data.jetTrkSum6[data.nJet]-=c->track.trkPt[k]; if (dR2<0.7) data.jetTrkSum7[data.nJet]-=c->track.trkPt[k]; if (dR2<0.8) data.jetTrkSum8[data.nJet]-=c->track.trkPt[k]; */ } if (data.jetTrkSum1[data.nJet]!=0) data.jetTrkW1[data.nJet]/=data.jetTrkSum1[data.nJet]; if (data.jetTrkSum2[data.nJet]!=0) data.jetTrkW2[data.nJet]/=data.jetTrkSum2[data.nJet]; if (data.jetTrkSum3[data.nJet]!=0) data.jetTrkW3[data.nJet]/=data.jetTrkSum3[data.nJet]; if (data.jetTrkSum4[data.nJet]!=0) data.jetTrkW4[data.nJet]/=data.jetTrkSum4[data.nJet]; if (data.jetTrkSum5[data.nJet]!=0) data.jetTrkW5[data.nJet]/=data.jetTrkSum5[data.nJet]; if (data.jetTrkSum6[data.nJet]!=0) data.jetTrkW6[data.nJet]/=data.jetTrkSum6[data.nJet]; if (data.jetTrkSum7[data.nJet]!=0) data.jetTrkW7[data.nJet]/=data.jetTrkSum7[data.nJet]; if (data.jetTrkSum8[data.nJet]!=0) data.jetTrkW8[data.nJet]/=data.jetTrkSum8[data.nJet]; data.nJet++; } /* // Select generator level leading and subleading jet for (int j=0;j<c->akVs3Calo.ngen;j++) { if (fabs(c->akVs3Calo.geneta[j])>2) continue; } data.nTrk=0; for (int j=0;j<c->track.nTrk;j++) { if (fabs(c->track.trkEta[j])>2.4) continue; if ((c->track.trkPt[j])<0.5) continue; if (!(c->track.highPurity[j] && fabs(c->track.trkDxy1[j]/c->track.trkDxyError1[j])<3.0 && fabs(c->track.trkDz1[j]/c->track.trkDzError1[j])<3.0 && (c->track.trkPtError[j]/c->track.trkPt[j])<0.1)) continue; data.trkWt[data.nTrk]=c->getTrackCorrection(j); data.trkPt[data.nTrk]=c->track.trkPt[j]; data.trkEta[data.nTrk]=c->track.trkEta[j]; data.trkPhi[data.nTrk]=c->track.trkPhi[j]; //data.trkRmin[data.nTrk]=c->getTrkRMin(c->track.trkPhi[j],c->track.trkEta[j],c->akVs3Calo); //hPt->Fill(data.trkPt[data.nTrk],data.trkWt[data.nTrk]); //hRmin->Fill(data.trkRmin[data.nTrk]); data.nTrk++; } data.nP=0; for (int j=0;j<c->track.nParticle;j++) { if (fabs(c->track.pEta[j])>2.4) continue; if (fabs(c->track.pPt[j])<0.5) continue; data.pPt[data.nP]=c->track.pPt[j]; data.pEta[data.nP]=c->track.pEta[j]; data.pPhi[data.nP]=c->track.pPhi[j]; data.nP++; } */ //cout <<data.mpt<<endl; t->Fill(); } output->Write(); output->Close(); }
void dijetTrack(double tag=0, char *infName = "/d102/yjlee/hiForest2MC/Pythia80_HydjetDrum_mix01_HiForest2_v22_simTrack05.root") { // Define the input file and HiForest HiForest *c = new HiForest(infName); // Turn off the non-necessary trees c->hasPFTree=0; c->hasPhotonTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->doTrackCorrections=1; c->InitTree(); // Output file TFile *output = new TFile(Form("output-%.0f.root",tag),"recreate"); // Book a output tree TTree * t = new TTree("t","gammajet"); // My tree data format JetData data(t,1); // Book histograms TH1F *hJetTrackDphi = new TH1F("hJetTrackDphi" , ";#Delta #phi;Weighted Entries", 100, 0, TMath::Pi()); TH1F *hJetTrackDeta = new TH1F("hJetTrackDeta" , ";#Delta #eta;Weighted Entries", 100, -2, 2); TH2F *hJetTrack2D = new TH2F("hJetTrack2D" , ";#Delta #eta; #Delta #phi" , 100, -2, 2,100,0, TMath::Pi()); TH1F *hGenJetTrackDphi = new TH1F("hGenJetTrackDphi", ";#Delta #phi;Weighted Entries", 100, 0, TMath::Pi()); TH1F *hGenJetTrackDeta = new TH1F("hGenJetTrackDeta", ";#Delta #eta;Weighted Entries", 100, -2, 2); TH2F *hGenJetTrack2D = new TH2F("hGenJetTrack2D" , ";#Delta #eta; #Delta #phi" , 100, -2, 2,100,0, TMath::Pi()); // Main loop for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); data.hiBin = c->evt.hiBin; if (i % 1000 == 0) cout <<i<<" / "<<c->GetEntries()<<endl; data.leadingJetPt = -1; data.subleadingJetPt = -1; data.leadingJetIt = -1; data.subleadingJetIt = -1; data.genleadingJetPt = -1; data.gensubleadingJetPt = -1; // ================================= // Select leading and subleading jet // ================================= for (int j=0;j<c->icPu5.nref;j++) { if (fabs(c->icPu5.jteta[j])>2) continue; if (c->icPu5.jtpt[j]>data.leadingJetPt) { data.leadingJetPt = c->icPu5.jtpt[j]; data.leadingJetEta = c->icPu5.jteta[j]; data.leadingJetPhi = c->icPu5.jtphi[j]; data.leadingJetIt = j; } if (c->icPu5.jtpt[j]>data.subleadingJetPt && c->icPu5.jtpt[j] < data.leadingJetPt) { data.subleadingJetPt = c->icPu5.jtpt[j]; data.subleadingJetEta = c->icPu5.jteta[j]; data.subleadingJetPhi = c->icPu5.jtphi[j]; data.subleadingJetIt = j; } if (c->icPu5.jtpt[j]<data.subleadingJetPt) break; } // ================================================= // Select generator level leading and subleading jet // ================================================= for (int j=0;j<c->icPu5.ngen;j++) { if (fabs(c->icPu5.geneta[j])>2) continue; if (c->icPu5.genpt[j]>data.genleadingJetPt) { data.genleadingJetPt = c->icPu5.genpt[j]; data.genleadingJetEta = c->icPu5.geneta[j]; data.genleadingJetPhi = c->icPu5.genphi[j]; } if (c->icPu5.genpt[j]>data.gensubleadingJetPt && c->icPu5.genpt[j] < data.genleadingJetPt) { data.gensubleadingJetPt = c->icPu5.genpt[j]; data.gensubleadingJetEta = c->icPu5.geneta[j]; data.gensubleadingJetPhi = c->icPu5.genphi[j]; } if (c->icPu5.genpt[j]<data.gensubleadingJetPt) break; } // ==================================================================== // Now we have leading and subleading jet from generator and reco level // Loop over tracks in reco level // ==================================================================== for (int j=0;j<c->track.nTrk;j++) { if (fabs(c->track.trkEta[j])>2.4) continue; if (fabs(c->track.trkPt[j]) <0.5) continue; double dphi1 = acos(cos(c->track.trkPhi[j]-data.leadingJetPhi)); double deta1 = (c->track.trkEta[j]-data.leadingJetEta); // Fill the histogram, with track pT as the weight of the entry. hJetTrackDphi->Fill(dphi1 , c->track.trkPt[j]); hJetTrackDeta->Fill(deta1 , c->track.trkPt[j]); hJetTrack2D ->Fill(deta1, dphi1, c->track.trkPt[j]); } // ============================= // Loop over tracks in gen level // ============================= for (int j=0;j<c->track.nParticle;j++) { if (fabs(c->track.pEta[j])>2.4) continue; if (fabs(c->track.pPt[j]) <0.5) continue; double dphi1 = acos(cos(c->track.pPhi[j]-data.genleadingJetPhi)); double deta1 = (c->track.pEta[j]-data.genleadingJetEta); double dr1 = sqrt(dphi1*dphi1+deta1*deta1); // Fill the histogram, with simtrack pT as the weight of the entry. hGenJetTrackDphi->Fill(dphi1 , c->track.pPt[j]); hGenJetTrackDeta->Fill(deta1 , c->track.pPt[j]); hGenJetTrack2D ->Fill(deta1, dphi1, c->track.pPt[j]); } t->Fill(); } output->Write(); output->Close(); }
void randomcone(int condor_iter, string flist, string tag, int centmin, int centmax) { using namespace std; string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile(flist.data()); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } HiForest * c = new HiForest(listoffiles[condor_iter].data(),"forest",cPPb,0); // TH2D * etaphi = new TH2D(); int nevents = c->GetEntries(); const int netabins = 48; TRandom3 r; float rConeEta = 0; float rConePhi = 0; float dR = 0.3; float thisdR = 0; float pfPtSum; float pfVsPtSum; float pfVsPtInitialSum; TFile * outf = new TFile(Form("randcone_%s_centmin%d_centmax%d_%d.root",tag.data(),centmin,centmax,condor_iter),"recreate"); TH1D * hpfPtSum = new TH1D("hpfPtSum","pfPtSum;#Sigma p_{T}",240,0,120); TH1D * hpfVsPtSum = new TH1D("hpfVsPtSum","pfVsPtSum;#Sigma p_{T}",200,-50,50); TH1D * hpfVsPtInitialSum = new TH1D("hpfVsPtInitialSum","hpfVsPtInitialSum;#Sigma p_{T}",200,-50,50); TH1D * hpfPtSumEta[netabins]; TH1D * hpfVsPtSumEta[netabins]; TH1D * hpfVsPtInitialSumEta[netabins]; for(int i = 0 ; i < netabins ; ++i) { hpfPtSumEta[i] = new TH1D(Form("hpfPtSumEta_%d",i),Form("pfPtSum_%d;#Sigma p_{T}",i),200,-100,100); hpfVsPtSumEta[i] = new TH1D(Form("hpfVsPtSumEta_%d",i),Form("pfVsPtSum_%d;#Sigma p_{T}",i),200,-100,100); hpfVsPtInitialSumEta[i] = new TH1D(Form("hpfVsPtInitialSumEta_%d",i),Form("hpfVsPtInitialSum_%d;#Sigma p_{T}",i),200,-100,100); } TH1D * hConeEta = new TH1D("hConeEta","hConeEta;#eta",netabins,-2.4,2.4); for(int i = 0 ; i < nevents ; ++i) { if(i%1000==0) cout<<i<<"/"<<nevents<<endl; c->GetEntry(i); if(c->evt.hiBin < centmin || c->evt.hiBin >= centmax) continue; rConeEta = 4.8*(r.Rndm()-0.5); // uniform dist. +- 2.4 eta rConePhi = 2*TMath::Pi()*(r.Rndm()-0.5); // uniform dist. +- pi hConeEta->Fill(rConeEta); int whichbin = hConeEta->FindBin(rConeEta); pfPtSum = 0.0; pfVsPtSum = 0.0; pfVsPtInitialSum = 0.0; for(int j = 0 ; j < c->pf.nPFpart ; ++j) { thisdR = getdR(rConeEta,c->pf.pfEta[j],rConePhi,c->pf.pfPhi[j]); if(thisdR < dR) { pfPtSum+=c->pf.pfPt[j]; pfVsPtSum+=c->pf.pfVsPt[j]; pfVsPtInitialSum+=c->pf.pfVsPtInitial[j]; } } hpfPtSum->Fill(pfPtSum); hpfVsPtSum->Fill(pfVsPtSum); hpfVsPtInitialSum->Fill(pfVsPtInitialSum); hpfPtSumEta[whichbin-1]->Fill(pfPtSum); hpfVsPtSumEta[whichbin-1]->Fill(pfVsPtSum); hpfVsPtInitialSumEta[whichbin-1]->Fill(pfVsPtInitialSum); } TH1D * hmeanpfPtSumEta = new TH1D("hmeanpfPtSumEta","hmeanpfPtSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); TH1D * hmeanpfVsPtSumEta = new TH1D("hmeanpfVsPtSumEta","hmeanpfVsPtSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); TH1D * hmeanpfVsPtInitialSumEta = new TH1D("hmeanpfVsPtInitialSumEta","hmeanpfVsPtInitialSumEta;#eta;mean #Sigma p_{T}",netabins,-2.4,2.4); for(int i = 1 ; i <= netabins ; ++i) { hmeanpfPtSumEta->SetBinContent(i,hpfPtSumEta[i-1]->GetMean()); hmeanpfPtSumEta->SetBinError(i,hpfPtSumEta[i-1]->GetMeanError()); hmeanpfVsPtSumEta->SetBinContent(i,hpfVsPtSumEta[i-1]->GetMean()); hmeanpfVsPtSumEta->SetBinError(i,hpfVsPtSumEta[i-1]->GetMeanError()); hmeanpfVsPtInitialSumEta->SetBinContent(i,hpfVsPtInitialSumEta[i-1]->GetMean()); hmeanpfVsPtInitialSumEta->SetBinError(i,hpfVsPtInitialSumEta[i-1]->GetMeanError()); } TH1D * one = new TH1D("one","",1,0,1); one->Fill(0.5); outf->Write(); outf->Close(); }
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; }
void photon_JEC() { TH1::SetDefaultSumw2(); Double_t alphabins[] = {0.075, 0.125, 0.175, .25, .35}; TH1D *RdRmcalpha[nptbins]; TProfile *Ratio[2][nptbins]; for(int i = 0; i < nptbins; i++) { TString name; name = "RdRmcalpha_"; name += ptbins[i]; RdRmcalpha[i] = new TH1D(name,name+";#alpha;R_{data}/R_{MC}",4,alphabins); name = "Rd_"; name += ptbins[i]; Ratio[0][i] = new TProfile(name,"",4,alphabins); name = "Rmc_"; name += ptbins[i]; Ratio[1][i] = new TProfile(name,"",4,alphabins); } TH1D *alphas = new TH1D("alphas",";#alpha = p_{T}^{Jet3}/p_{T}^{#gamma}",100,0,0.8); TH1D *hPhotonPt[2]; hPhotonPt[0] = new TH1D("hPhotonPt_data",";photon p_{T}",200,0,400); hPhotonPt[1] = (TH1D*)hPhotonPt[0]->Clone("hPhotonPt_mc"); TH1D *hPhotonEta[2]; hPhotonEta[0] = new TH1D("hPhotonEta_data",";photon #eta",26,-3,3); hPhotonEta[1] = (TH1D*)hPhotonEta[0]->Clone("hPhotonEta_mc"); TH1D *hJet2Pt[2]; hJet2Pt[0] = new TH1D("hJet2Pt_data",";jet 2 p_{T}",200,0,400); hJet2Pt[1] = (TH1D*)hJet2Pt[0]->Clone("hJet2Pt_mc"); TH1D *hJet2Eta[2]; hJet2Eta[0] = new TH1D("hJet2Eta_data",";jet 2 #eta",26,-3,3); hJet2Eta[1] = (TH1D*)hJet2Eta[0]->Clone("hJet2Eta_mc"); TH1D *hJet3Pt[2]; hJet3Pt[0] = new TH1D("hJet3Pt_data",";jet 3 p_{T}",200,0,400); hJet3Pt[1] = (TH1D*)hJet3Pt[0]->Clone("hJet3Pt_mc"); TH1D *hJet3Eta[2]; hJet3Eta[0] = new TH1D("hJet3Eta_data",";jet 3 #eta",26,-3,3); hJet3Eta[1] = (TH1D*)hJet3Eta[0]->Clone("hJet3Eta_mc"); TString files[2]; files[0] = "/mnt/hadoop/cms/store/user/luck/pA2013_forests/PA2013_HiForest_PromptReco_HLT_Photon40.root"; files[1] = "/mnt/hadoop/cms/store/user/luck/pA2013_MC/HiForest2_QCDPhoton30_5020GeV_100k.root"; bool montecarlo[2] = {false, true}; //loop over files //do the smaller MC file first, for some reason I have segfaults when I process the MC second. for(int ii = 1; ii > -1; ii--) { HiForest *c = new HiForest(files[ii], "Forest", cPPb, montecarlo[ii]); c->InitTree(); //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); //collision selection if( !((montecarlo[ii] || c->skim.pHBHENoiseFilter) && 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 = 40; //minPt is 40GeV 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) // no photons above minPt continue; if ( TMath::Abs(c->photon.eta[leadingIndex]) > 1.3 ) // barrel photons only continue; if(c->photon.ecalRecHitSumEtConeDR04[leadingIndex] > TMath::Min(3., 0.05*c->photon.energy[leadingIndex]) ) continue; if(c->photon.hcalTowerSumEtConeDR04[leadingIndex] > TMath::Min(2.4, 0.05*c->photon.energy[leadingIndex]) ) continue; //if(c->photon.trkSumPtHollowConeDR04[leadingIndex] > 0.10*leadingPt ) //continue; //if ( (c->photon.sigmaIetaIeta[leadingIndex] < 0.15) || (c->photon.sigmaIetaIeta[leadingIndex] > 0.35) ) //continue; //if ( (c->photon.sigmaIphiIphi[leadingIndex] < 0.15) || (c->photon.sigmaIphiIphi[leadingIndex] > 0.30) ) //continue; if ( c->photon.sigmaIetaIeta[leadingIndex] > 0.01 ) continue; //loop over 'away' jets int jet2index = -1; double jet2pt = 0; int jet3index = -1; double jet3pt = 0; for(int i = 0; i<c->akPu3PF.nref; i++) { if( TMath::Abs(c->akPu3PF.jteta[i]) > 3.0) continue; Double_t dphi = TMath::ACos(TMath::Cos(c->photon.phi[leadingIndex] - c->akPu3PF.jtphi[i])); if(dphi < TMath::Pi()/2) continue; if(c->akPu3PF.jtpt[i] > jet2pt) { jet3pt = jet2pt; jet3index = jet2index; jet2pt = c->akPu3PF.jtpt[i]; jet2index = i; } else if(c->akPu3PF.jtpt[i] > jet3pt) { jet3pt = c->akPu3PF.jtpt[i]; jet3index = i; } } if(jet3index == -1) //no 3rd jet means alpha = 0, we don't care continue; if( TMath::Abs(c->akPu3PF.jteta[jet2index]) > 1.3 ) continue; Double_t dphi = TMath::ACos(TMath::Cos(c->photon.phi[leadingIndex] - c->akPu3PF.jtphi[jet2index])); if( dphi < 2.7 ) continue; Double_t alpha = jet3pt/leadingPt; Double_t ratio = jet2pt/leadingPt; int ptbin = returnPtBin(leadingPt); if(ptbin != -1) Ratio[ii][ptbin]->Fill(alpha,ratio); alphas->Fill(alpha); hPhotonPt[ii]->Fill(leadingPt); hPhotonEta[ii]->Fill( c->photon.eta[leadingIndex] ); hJet2Pt[ii]->Fill(jet2pt); hJet2Eta[ii]->Fill( c->akPu3PF.jteta[jet2index] ); hJet3Pt[ii]->Fill(jet3pt); hJet3Eta[ii]->Fill( c->akPu3PF.jteta[jet3index] ); } } TCanvas *canvas[nptbins]; for(int i = 0; i < nptbins; i++) { TH1D *hRatiod = Ratio[0][i]->ProjectionX(); TH1D *hRatiomc = Ratio[1][i]->ProjectionX(); RdRmcalpha[i]->Divide(hRatiod,hRatiomc,1,1); canvas[i] = new TCanvas(); RdRmcalpha[i]->Draw(); } TCanvas *danvas = new TCanvas(); alphas->Draw(); danvas->SaveAs("alpha_counts.gif"); hPhotonPt[0]->Scale( 1./hPhotonPt[0]->GetEntries() ); hPhotonPt[1]->Scale( 1./hPhotonPt[1]->GetEntries() ); TCanvas *d1 = new TCanvas(); hPhotonPt[0]->Draw(); hPhotonPt[1]->SetMarkerColor(kRed); hPhotonPt[1]->Draw("same"); d1->SetLogy(); TLegend *leg = new TLegend(0.75,0.75,0.9,0.9); leg->SetFillColor(0); leg->AddEntry(hPhotonPt[0], "Data","P"); leg->AddEntry(hPhotonPt[1], "MC", "P"); leg->DrawClone(); d1->SaveAs("photon_pt.gif"); hPhotonEta[0]->Scale( 1./hPhotonEta[0]->GetEntries() ); hPhotonEta[1]->Scale( 1./hPhotonEta[1]->GetEntries() ); TCanvas *d2 = new TCanvas(); hPhotonEta[0]->Draw(); hPhotonEta[1]->SetMarkerColor(kRed); hPhotonEta[1]->Draw("same"); leg->DrawClone(); d2->SaveAs("photon_eta.gif"); hJet2Pt[0]->Scale( 1./hJet2Pt[0]->GetEntries() ); hJet2Pt[1]->Scale( 1./hJet2Pt[1]->GetEntries() ); TCanvas *d3 = new TCanvas(); hJet2Pt[0]->Draw(); hJet2Pt[1]->SetMarkerColor(kRed); hJet2Pt[1]->Draw("same"); d3->SetLogy(); leg->DrawClone(); d3->SaveAs("jet2_pt.gif"); hJet2Eta[0]->Scale( 1./hJet2Eta[0]->GetEntries() ); hJet2Eta[1]->Scale( 1./hJet2Eta[1]->GetEntries() ); TCanvas *d4 = new TCanvas(); hJet2Eta[0]->Draw(); hJet2Eta[1]->SetMarkerColor(kRed); hJet2Eta[1]->Draw("same"); leg->DrawClone(); d4->SaveAs("jet2_eta.gif"); hJet3Pt[0]->Scale( 1./hJet3Pt[0]->GetEntries() ); hJet3Pt[1]->Scale( 1./hJet3Pt[1]->GetEntries() ); TCanvas *d5 = new TCanvas(); hJet3Pt[0]->Draw(); hJet3Pt[1]->SetMarkerColor(kRed); hJet3Pt[1]->Draw("same"); d5->SetLogy(); leg->DrawClone(); d5->SaveAs("jet3_pt.gif"); hJet3Eta[0]->Scale( 1./hJet3Eta[0]->GetEntries() ); hJet3Eta[1]->Scale( 1./hJet3Eta[1]->GetEntries() ); TCanvas *d6 = new TCanvas(); hJet3Eta[0]->Draw(); hJet3Eta[1]->SetMarkerColor(kRed); hJet3Eta[1]->Draw("same"); leg->DrawClone(); d6->SaveAs("jet3_eta.gif"); }
void ffStudy(double tag=0, char *infName = "/d102/yjlee/hiForest2MC/Pythia80_HydjetDrum_mix01_HiForest2_v22_simTrack05.root") { // Define the input file and HiForest HiForest *c = new HiForest(infName); c->hasPFTree=0; c->hasPhotonTree=0; c->hasTowerTree=0; c->hasHbheTree=0; c->hasEbTree=0; c->hasGenpTree=0; c->hasGenParticleTree=0; c->hasAkPu2CaloJetTree=0; c->hasAkPu3CaloJetTree=0; c->hasAkPu4CaloJetTree=0; c->doTrackCorrections=1; c->InitTree(); // Output file TFile *output = new TFile(Form("output-%.0f.root",tag),"recreate"); // Output TTree * t = new TTree("t","gammajet"); JetData data(t,1); HistoData histos_MergedGeneralCalo("MergedGeneral"); HistoData histos2_MergedGeneral("MergedGeneral2"); // phi dependent corr TH1D *hWeight = new TH1D("hWeight","",1000,0,100); TH1D *hWeight2 = new TH1D("hWeight2","",1000,0,100); TH1D *hPt = new TH1D("hPt","",100,0,100); TH1D *hNoWPt = new TH1D("hNoWPt","",100,0,100); // Main loop for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); data.hiBin = c->evt.hiBin; if (i % 1000 == 0) cout <<i<<" / "<<c->GetEntries()<<endl; data.leadingJetPt = -1; data.subleadingJetPt = -1; data.leadingJetIt = -1; data.subleadingJetIt = -1; data.genleadingJetPt = -1; data.gensubleadingJetPt = -1; // Event selection // Select leading and subleading jet for (int j=0;j<c->icPu5.nref;j++) { if (fabs(c->icPu5.jteta[j])>2) continue; if (c->icPu5.jtpt[j]>data.leadingJetPt) { data.leadingJetPt = c->icPu5.jtpt[j]; data.leadingJetEta = c->icPu5.jteta[j]; data.leadingJetPhi = c->icPu5.jtphi[j]; data.leadingJetIt = j; } if (c->icPu5.jtpt[j]>data.subleadingJetPt && c->icPu5.jtpt[j] < data.leadingJetPt) { data.subleadingJetPt = c->icPu5.jtpt[j]; data.subleadingJetEta = c->icPu5.jteta[j]; data.subleadingJetPhi = c->icPu5.jtphi[j]; data.subleadingJetIt = j; } if (c->icPu5.jtpt[j]<data.subleadingJetPt) break; } // Select generator level leading and subleading jet for (int j=0;j<c->icPu5.ngen;j++) { if (fabs(c->icPu5.geneta[j])>2) continue; if (c->icPu5.genpt[j]>data.genleadingJetPt) { data.genleadingJetPt = c->icPu5.genpt[j]; data.genleadingJetEta = c->icPu5.geneta[j]; data.genleadingJetPhi = c->icPu5.genphi[j]; } if (c->icPu5.genpt[j]>data.gensubleadingJetPt && c->icPu5.genpt[j] < data.genleadingJetPt) { data.gensubleadingJetPt = c->icPu5.genpt[j]; data.gensubleadingJetEta = c->icPu5.geneta[j]; data.gensubleadingJetPhi = c->icPu5.genphi[j]; } if (c->icPu5.genpt[j]<data.gensubleadingJetPt) break; } //if (data.subleadingJetPt<50||data.subleadingJetPt>80) continue; // MPT calculation data.mpt = 0; data.cormpt = 0; data.cormpt2 = 0; data.genMpt = 0; data.genPMpt = 0; for (int j=0;j<c->track.nTrk;j++) { if (fabs(c->track.trkEta[j])>2.4) continue; if (fabs(c->track.trkPt[j])<0.5) continue; double mptTrk = -c->track.trkPt[j]*cos(c->track.trkPhi[j]-data.leadingJetPhi); data.mpt+=mptTrk; } for (int j=0;j<c->track.nTrk;j++) { if (fabs(c->track.trkEta[j])>2.4) continue; if ((c->track.trkPt[j])<0.5) continue; if (c->track.trkAlgo[j]>=4&&!(c->track.highPurity[j])) continue; double dphi1 = acos(cos(c->track.trkPhi[j]-data.leadingJetPhi)); double deta1 = fabs(c->track.trkEta[j]-data.leadingJetEta); double dphi2 = acos(cos(c->track.trkPhi[j]-data.subleadingJetPhi)); double deta2 = fabs(c->track.trkEta[j]-data.subleadingJetEta); double dr1 = sqrt(dphi1*dphi1+deta1*deta1); double dr2 = sqrt(dphi2*dphi2+deta2*deta2); double trkWt=1; double trkWt2=0; //cout <<trkWt<<endl; double mptTrk = -c->track.trkPt[j]*cos(c->track.trkPhi[j]-data.leadingJetPhi)*trkWt; data.cormpt+=mptTrk; if (data.leadingJetPt>100&&dr1<0.5) trkWt = 0.5; if (data.subleadingJetPt>100&&dr2<0.5) trkWt = 0.5; double ptWeight = 1;//c->track.trkPt[j]; histos_MergedGeneralCalo.hRecoPt->Fill(c->track.trkPt[j],ptWeight); histos_MergedGeneralCalo.hCorrectedPt->Fill(c->track.trkPt[j],ptWeight*trkWt); histos_MergedGeneralCalo.hRecoEta->Fill(c->track.trkEta[j],ptWeight); histos_MergedGeneralCalo.hCorrectedEta->Fill(c->track.trkEta[j],ptWeight*trkWt); histos_MergedGeneralCalo.hRecoPhi->Fill(c->track.trkPhi[j],ptWeight); histos_MergedGeneralCalo.hCorrectedPhi->Fill(c->track.trkPhi[j],ptWeight*trkWt); histos_MergedGeneralCalo.hRecoDR->Fill(dr1,ptWeight); histos_MergedGeneralCalo.hCorrectedDR->Fill(dr1,ptWeight*trkWt); if (data.leadingJetPt>=50&&dr1<0.5) { if (data.leadingJetPt>200) trkWt2 = c->trackCorrections[1]->GetCorr(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],c->evt.hiBin); else trkWt2 = c->trackCorrections[2]->GetCorr(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],c->evt.hiBin); } else if (data.subleadingJetPt>=50&&dr2<0.5) { if (data.subleadingJetPt>120) trkWt2 = c->trackCorrections[1]->GetCorr(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],c->evt.hiBin); else trkWt2 = c->trackCorrections[2]->GetCorr(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],c->evt.hiBin); } else { trkWt2 = c->trackCorrections[0]->GetCorr(c->track.trkPt[j],c->track.trkEta[j],c->track.trkPhi[j],c->evt.hiBin); } trkWt2 = c->getTrackCorrectionPara(j); histos2_MergedGeneral.hRecoPt->Fill(c->track.trkPt[j],ptWeight); histos2_MergedGeneral.hCorrectedPt->Fill(c->track.trkPt[j],ptWeight*trkWt2); histos2_MergedGeneral.hRecoEta->Fill(c->track.trkEta[j],ptWeight); histos2_MergedGeneral.hCorrectedEta->Fill(c->track.trkEta[j],ptWeight*trkWt2); histos2_MergedGeneral.hRecoPhi->Fill(c->track.trkPhi[j],ptWeight); histos2_MergedGeneral.hCorrectedPhi->Fill(c->track.trkPhi[j],ptWeight*trkWt2); histos2_MergedGeneral.hRecoDR->Fill(dr1,ptWeight); histos2_MergedGeneral.hCorrectedDR->Fill(dr1,ptWeight*trkWt2); double mptTrk2 = -c->track.trkPt[j]*cos(c->track.trkPhi[j]-data.leadingJetPhi)*trkWt2; data.cormpt2+=mptTrk2; hWeight->Fill(trkWt); hWeight2->Fill(trkWt2); if (trkWt2>0.001) { hPt->Fill(c->track.trkPt[j]); } else { hPt->Fill(c->track.trkPt[j]); hNoWPt->Fill(c->track.trkPt[j]); } } for (int j=0;j<c->track.nParticle;j++) { if (fabs(c->track.pEta[j])>2.4) continue; if (fabs(c->track.pPt[j])<0.5) continue; double mptPTrk = -c->track.pPt[j]*cos(c->track.pPhi[j]-data.leadingJetPhi); data.genPMpt+=mptPTrk; double dphi1 = acos(cos(c->track.pPhi[j]-data.leadingJetPhi)); double deta1 = fabs(c->track.pEta[j]-data.leadingJetEta); double dr1 = sqrt(dphi1*dphi1+deta1*deta1); double ptWeight = 1;//c->track.pPt[j]; histos_MergedGeneralCalo.hGenPt->Fill(c->track.pPt[j],ptWeight); histos_MergedGeneralCalo.hGenEta->Fill(c->track.pEta[j],ptWeight); histos_MergedGeneralCalo.hGenPhi->Fill(c->track.pPhi[j],ptWeight); histos_MergedGeneralCalo.hGenDR->Fill(dr1,ptWeight); histos2_MergedGeneral.hGenPt->Fill(c->track.pPt[j],ptWeight); histos2_MergedGeneral.hGenEta->Fill(c->track.pEta[j],ptWeight); histos2_MergedGeneral.hGenPhi->Fill(c->track.pPhi[j],ptWeight); histos2_MergedGeneral.hGenDR->Fill(dr1,ptWeight); double mptTrk = -c->track.pPt[j]*cos(c->track.pPhi[j]-data.genleadingJetPhi); data.genMpt+=mptTrk; } //cout <<data.mpt<<endl; t->Fill(); } // t->Write(); histos_MergedGeneralCalo.calcEff(); histos2_MergedGeneral.calcEff(); output->Write(); output->Close(); }
void analyzeDiJetMPT( TString jetAlgo = "akPu3PF", TString trkCol = "anaTrack", TString inname="/mnt/hadoop/cms/store/user/yenjie/HiForest_v27/Dijet${pthat}_HydjetDrum_v27_mergedV1.root", TString outname="output.root", bool isPP=false, int dataSrcType = 1, // 0 mc, 1 hi, 2 pp 2.76 TeV, 3 pp 7TeV double samplePtHat=0, double ptHatMax=9999, double sampleWeight = 1, // data: 1, mc: s = 0.62, b = 0.38 double vzMax = 15, int maxEntries = -1, double leadingJetPtMin=-1, double subleadingJetPtMin=-1, double sigDPhi=-1, bool genJetMode=false, int smearCentBin = 0, bool doCentReWeight=false, TString mcfname="", TString datafname="output-data-Photon-v7_v30.root" ) { /////////////////////////////////////////////////// // Setup Analysis /////////////////////////////////////////////////// int saveTracks = 1; // 0=none, 1=all, 10=cone double cutjetPt = 10; double cutjetEta = 2; double cutPtTrk=1.; double cutEtaTrk = 2.4; double trkJetAssoR=0.3; TString tag=Form("%s_%.0f_%.0f_%.0f_saveTrk%d_jmin%.0f_tmin%.0f_genj%d_sm%d",jetAlgo.Data(),leadingJetPtMin,subleadingJetPtMin,sigDPhi*1000,saveTracks,cutjetPt,cutPtTrk,genJetMode,smearCentBin); outname.ReplaceAll(".root",Form("_%s.root",tag.Data())); cout << "Input: " << inname << " isPP: " << isPP << endl; cout << "Sample pthat = " << samplePtHat << " ptHatMax = " << ptHatMax << endl; cout << "Track pt min = " << cutPtTrk << endl; cout << "skim: leading Jet > " << leadingJetPtMin << " subleading > " << subleadingJetPtMin << " dphi > " << sigDPhi << endl; cout << "Genjet mode: " << genJetMode << endl; cout << "SmearCentBin = " << smearCentBin << endl; cout << "Output: " << outname << endl; // Centrality reweiting CentralityReWeight cw(datafname,mcfname,"offlSel&&pt1>100&&pt2>0&&acos(cos(phi2-phi1))>2./3*3.14159"); // Define the input file and HiForest HiForest * c = new HiForest(inname,jetAlgo.Data(),isPP); c->doTrackCorrections = true; c->doTrackingSeparateLeadingSubleading = false; c->InitTree(); // intialize jet variables Jets* anajet = &(c->akPu3PF) ; // Output file cout << "Output: " << outname << endl; TFile *output = new TFile(outname,"recreate"); if (doCentReWeight&&mcfname!="") { cw.Init(); //cw.hCentData->Draw(); cw.hCentMc->Draw("same"); } // basics output->cd(); TH1D * hCent = new TH1D("hCent","",40,0,40); TH1D * hVz = new TH1D("hVz","",60,-30,30); TH1D * hPtHatBeforeSel = new TH1D("hPtHatBeforeSel","",200,0,1000); TH1D * hPtHat = new TH1D("hPtHat","",200,0,1000); TH2D * hJetPt2D = new TH2D("hJetPt2D","",100,0,500,100,0,500); TH1D * hJDPhi = new TH1D("hJDPhi","",40,0,Pi()); TH1D * hAj = new TH1D("hAj","",32,0,0.8); TH1D * hTrkPt = new TH1D("hTrkPt",";p_{T} (GeV/c)",200,0,200); TH1D * hTrkCorrPt = new TH1D("hTrkCorrPt",";p_{T} (GeV/c)",200,0,200); TH1D * hGenpPt = new TH1D("hGenpPt",";p_{T} (GeV/c)",200,0,200); TH1D* smearingHist=0; if ( smearCentBin > 0 ) { smearingHist = new TH1D("smearingH","",100,-2,2); } EvtSel evt; DiJet gj; TTree * tgj = new TTree("tgj","dijet jet tree"); BookGJBranches(tgj,evt,gj); // pp triggers int HLT_Jet40_v1=0; if (dataSrcType==2) { c->hltTree->SetBranchAddress("HLT_Jet40_v1",&HLT_Jet40_v1); } else if (dataSrcType==3) { c->hltTree->SetBranchAddress("HLT_Jet40_v1",&HLT_Jet40_v1); } //////////////////////// // Smearing Setup //////////////////////// if (smearCentBin>0) { LoadParameters(); } /////////////////////////////////////////////////// // Main loop /////////////////////////////////////////////////// if (maxEntries<0||maxEntries > c->GetEntries()) maxEntries = c->GetEntries(); for (int i=0;i<maxEntries;i++) { c->GetEntry(i); // Event Info evt.run = c->hlt.Run; evt.evt = c->hlt.Event; evt.cBin = c->evt.hiBin; if (isPP) evt.cBin = 39; evt.evtPlane = c->evt.hiEvtPlanes[21]; evt.nJ = anajet->nref; evt.nT = c->track.nTrk; evt.trig = (c->hlt.HLT_HIJet80_v1 > 0); evt.offlSel = (c->skim.pcollisionEventSelection > 0); if (!c->hasSkimTree) evt.offlSel = (c->evt.hiNtracks>0 && c->evt.hiHFplus>=4 && c->evt.hiHFminus>=4); evt.noiseFilt = (c->skim.pHBHENoiseFilter > 0); if (dataSrcType>1) { if (dataSrcType==2) { evt.trig = (HLT_Jet40_v1>0); } else if (dataSrcType==3) { evt.trig = (HLT_Jet40_v1>0); } // evt.offlSel = (c->skim.phfCoincFilter && c->skim.ppurityFractionFilter); } if (!c->hasHltTree) evt.trig = true; evt.anaEvtSel = evt.offlSel; if (dataSrcType>0) evt.anaEvtSel = evt.anaEvtSel && evt.trig && evt.noiseFilt; evt.vz = c->track.vz[1]; // Get Centrality Weight if (doCentReWeight) evt.weight = cw.GetWeight(evt.cBin); else evt.weight = 1; evt.npart = getNpart(evt.cBin); evt.ncoll = getNcoll(evt.cBin); evt.sampleWeight = sampleWeight/maxEntries; // for different mc sample, 1 for data evt.pthat = anajet->pthat; evt.samplePtHat = samplePtHat; if (i%1000==0) cout <<i<<" / "<<maxEntries << " run: " << evt.run << " evt: " << evt.evt << " bin: " << evt.cBin << " nT: " << evt.nT << " trig: " << evt.trig << " anaEvtSel: " << evt.anaEvtSel <<endl; // initialize int leadingIndex=-1,genLeadingIndex=-1; int awayIndex=-1,genAwayIndex=-1; gj.clear(); // smearing for pp gj.nUnSmJet=0; if (smearCentBin>0) { for (int j=0;j<anajet->nref;j++) { if (anajet->jtpt[j]<cutjetPt) continue; if (fabs(anajet->jteta[j])>cutjetEta) continue; if ((anajet->trackMax[j]/anajet->jtpt[j])<0.01) continue; //if (anajet->jtpt[j]>200) cout << "Before smearing: " << anajet->jtpt[j] << endl; int smCentBin = GetCBin( centBin[smearCentBin] ); //cout << "smCentBin: " << smCentBin << endl; gj.inclJetUnSmPt[gj.nUnSmJet] = anajet->jtpt[j]; anajet->jtpt[j] = GetSmearedPtData(2,smCentBin,anajet->jtpt[j],0,""); gj.inclJetSm[gj.nUnSmJet] = anajet->jtpt[j]/gj.inclJetUnSmPt[gj.nUnSmJet]; //if (anajet->jtpt[j]>200) cout << "After smearing: " << anajet->jtpt[j] << endl; if ( (gj.inclJetUnSmPt[gj.nUnSmJet] > 100) && (fabs(anajet->jteta[j])<2.0)) smearingHist->Fill( (anajet->jtpt[j] - gj.inclJetUnSmPt[gj.nUnSmJet] )/gj.inclJetUnSmPt[gj.nUnSmJet] ); ++gj.nUnSmJet; } } /////////////////////////////////////////////////////// // Find Leading jets /////////////////////////////////////////////////////// for (int j=0;j<anajet->nref;j++) { if (anajet->jtpt[j]<cutjetPt) continue; if (fabs(anajet->jteta[j])>cutjetEta) continue; if ((anajet->trackMax[j]/anajet->jtpt[j])<0.01) continue; if (anajet->jtpt[j] > gj.pt1) { gj.pt1 = anajet->jtpt[j]; leadingIndex = j; } } // Found a leading jet which passed basic quality cut! if (leadingIndex!=-1) { // set leading jet gj.pt1raw=anajet->rawpt[leadingIndex]; gj.eta1=anajet->jteta[leadingIndex]; gj.phi1=anajet->jtphi[leadingIndex]; gj.ref1pt = anajet->refpt[leadingIndex]; gj.ref1eta = anajet->refeta[leadingIndex]; gj.ref1phi = anajet->refphi[leadingIndex]; gj.ref1partonpt = anajet->refparton_pt[leadingIndex]; gj.ref1partonflavor = anajet->refparton_flavor[leadingIndex]; // Loop over jet tree to find a away side leading jet gj.nJet=0; for (int j=0;j<anajet->nref;j++) { if (anajet->jtpt[j]<cutjetPt) continue; if (fabs(anajet->jteta[j])>cutjetEta) continue; if ((anajet->trackMax[j]/anajet->jtpt[j])<0.01) continue; gj.inclJetPt[gj.nJet] = anajet->jtpt[j]; gj.inclJetEta[gj.nJet] = anajet->jteta[j]; gj.inclJetPhi[gj.nJet] = anajet->jtphi[j]; gj.inclJetRefPt[gj.nJet] = anajet->refpt[j]; gj.inclJetRefPartonPt[gj.nJet] = anajet->refparton_pt[j]; if (j!=leadingIndex&&anajet->jtpt[j] > gj.pt2) { gj.pt2 = anajet->jtpt[j]; awayIndex = j; } ++gj.nJet; } if (awayIndex !=-1) { // Found an away jet! gj.pt2raw = anajet->rawpt[awayIndex]; gj.eta2 = anajet->jteta[awayIndex]; gj.phi2 = anajet->jtphi[awayIndex]; gj.deta = gj.eta2 - gj.eta1; gj.dphi = deltaPhi(gj.phi2,gj.phi1); gj.Aj = (gj.pt1-gj.pt2)/(gj.pt1+gj.pt2); gj.ref2pt = anajet->refpt[awayIndex]; gj.ref2eta = anajet->refeta[awayIndex]; gj.ref2phi = anajet->refphi[awayIndex]; gj.ref2partonpt = anajet->refparton_pt[awayIndex]; gj.ref2partonflavor = anajet->refparton_flavor[awayIndex]; } } // end of if leadingIndex //////////////////////////////////////// // Find Leading Genjets //////////////////////////////////////// // Loop over genjets to look for leading genjet candidate in the event for (int j=0;j<anajet->ngen;j++) { if (anajet->genpt[j]<cutjetPt) continue; if (fabs(anajet->geneta[j])>cutjetEta) continue; if (anajet->genpt[j] > gj.genjetpt1) { gj.genjetpt1=anajet->genpt[j]; genLeadingIndex=j; } } if (genLeadingIndex!=-1) { gj.genjeteta1=anajet->geneta[genLeadingIndex]; gj.genjetphi1=anajet->genphi[genLeadingIndex]; } // subleading gj.nGenJet=0; for (int j=0;j<anajet->ngen;j++) { if (anajet->genpt[j]<cutjetPt) continue; if (fabs(anajet->geneta[j])>cutjetEta) continue; gj.inclGenJetPt[gj.nGenJet] = anajet->genpt[j]; gj.inclGenJetEta[gj.nGenJet] = anajet->geneta[j]; gj.inclGenJetPhi[gj.nGenJet] = anajet->genphi[j]; if (j!=genLeadingIndex && anajet->genpt[j]>gj.genjetpt2) { gj.genjetpt2=anajet->genpt[j]; gj.genjeteta2=anajet->geneta[j]; gj.genjetphi2=anajet->genphi[j]; } ++gj.nGenJet; } if (genJetMode) { gj.pt1 = gj.genjetpt1; gj.eta1 = gj.genjeteta1; gj.phi1 = gj.genjetphi1; gj.pt2 = gj.genjetpt2; gj.eta2 = gj.genjeteta2; gj.phi2 = gj.genjetphi2; gj.dphi = deltaPhi(gj.phi2,gj.phi1); } /////////////////////////////////////////////////////// // Skim /////////////////////////////////////////////////////// if (!evt.anaEvtSel) continue; if (samplePtHat>0 && evt.pthat>=ptHatMax) continue; if (vzMax>0 && fabs(evt.vz)>vzMax) continue; hPtHatBeforeSel->Fill(evt.pthat); // ensure jet distribution unbiased by pthat turn on if (leadingJetPtMin>0&&gj.pt1<leadingJetPtMin) continue; if (subleadingJetPtMin>0&&gj.pt2<subleadingJetPtMin) continue; if (sigDPhi>0&&fabs(gj.dphi)<sigDPhi) continue; // Fill Baisc Event info hCent->Fill(evt.cBin); hVz->Fill(evt.vz); hPtHat->Fill(evt.pthat); hJetPt2D->Fill(gj.pt1,gj.pt2); hJDPhi->Fill(fabs(gj.dphi)); hAj->Fill(gj.Aj); /////////////////////////////////////////////////////// // Tracks /////////////////////////////////////////////////////// bool doTracks = false; if (doTracks) { double trkcorr[4]; gj.nTrk=0; const int nTrkSet=1; Tracks * anaTrks[nTrkSet] = {&(c->track)}; // Full Tracks, Pixel Tracks for (int iset=0; iset<nTrkSet; ++iset) { for (int it=0; it<anaTrks[iset]->nTrk; ++it) { // Kinematic Selection if (anaTrks[iset]->trkPt[it] < cutPtTrk) continue; if (fabs(anaTrks[iset]->trkEta[it]) > cutEtaTrk) continue; if (!anaTrks[iset]->highPurity[it]) continue; float trkPt = anaTrks[iset]->trkPt[it]; float trkEta = anaTrks[iset]->trkEta[it]; float trkPhi = anaTrks[iset]->trkPhi[it]; float trkPtErrorNorm = anaTrks[iset]->trkPtError[it]/anaTrks[iset]->trkPt[it]; float trkNHit = anaTrks[iset]->trkNHit[it]; float trkChi2Norm = anaTrks[iset]->trkChi2[it]/anaTrks[iset]->trkNlayer[it]/anaTrks[iset]->trkNdof[it]; float trkDzNorm = anaTrks[iset]->trkDz1[it]/anaTrks[iset]->trkDzError1[it]; float trkDxyNorm = anaTrks[iset]->trkDxy1[it]/anaTrks[iset]->trkDxyError1[it]; int trkAlgo = anaTrks[iset]->trkAlgo[it]; bool trkHP = (trkPtErrorNorm<0.06&&trkNHit>=13&&trkChi2Norm<0.15&&trkDzNorm<3&&trkDxyNorm<3); gj.trkPt[gj.nTrk] = trkPt; gj.trkEta[gj.nTrk] = trkEta; gj.trkPhi[gj.nTrk] = trkPhi; gj.trkWt[gj.nTrk] = c->getTrackCorrection(it); float dr1 = deltaR(trkEta,trkPhi,gj.eta1,gj.phi1); float dr2 = deltaR(trkEta,trkPhi,gj.eta2,gj.phi2); float dr1bkg = deltaR(trkEta,trkPhi,-gj.eta1,gj.phi1); float dr2bkg = deltaR(trkEta,trkPhi,-gj.eta2,gj.phi2); gj.trkAsso[gj.nTrk] = 0; if (dr1<trkJetAssoR) gj.trkAsso[gj.nTrk] = 1; else if (dr1bkg<trkJetAssoR) gj.trkAsso[gj.nTrk] = 11; else if (dr2<trkJetAssoR) gj.trkAsso[gj.nTrk] = 2; else if (dr2bkg<trkJetAssoR) gj.trkAsso[gj.nTrk] = 12; // Histogram hTrkPt->Fill(trkPt); hTrkCorrPt->Fill(trkPt,gj.trkWt[gj.nTrk]); // Select what to save if (saveTracks==0) continue; if (saveTracks==10&&gj.trkAsso[gj.nTrk]==0) continue; // Fill gj.trkNHit[gj.nTrk] = trkNHit; gj.trkChi2Norm[gj.nTrk] = trkChi2Norm; gj.trkAlgo[gj.nTrk] = trkAlgo; gj.trkHP[gj.nTrk] = trkHP; gj.trkIsFake[gj.nTrk] = anaTrks[iset]->trkFake[it]; ++gj.nTrk; } } gj.nSim=0; for (int ip=0; ip<anaTrks[0]->nParticle; ++ip) { if (anaTrks[0]->pPt[ip] < cutPtTrk) continue; if (fabs(anaTrks[0]->pEta[ip]) > cutEtaTrk) continue; float simPt = anaTrks[0]->pPt[ip]; float simEta = anaTrks[0]->pEta[ip]; float simPhi = anaTrks[0]->pPhi[ip]; float dr1 = deltaR(simEta,simPhi,gj.eta1,gj.phi1); float dr2 = deltaR(simEta,simPhi,gj.eta2,gj.phi2); float dr1bkg = deltaR(simEta,simPhi,-gj.eta1,gj.phi1); float dr2bkg = deltaR(simEta,simPhi,-gj.eta2,gj.phi2); gj.simAsso[gj.nSim] = 0; if (dr1<trkJetAssoR) gj.simAsso[gj.nSim] = 1; else if (dr1bkg<trkJetAssoR) gj.simAsso[gj.nSim] = 11; else if (dr2<trkJetAssoR) gj.simAsso[gj.nSim] = 2; else if (dr2bkg<trkJetAssoR) gj.simAsso[gj.nSim] = 12; // Select what to save if (saveTracks==0) continue; if (saveTracks==10&&gj.simAsso[gj.nSim]==0) continue; // Fill gj.simPt[gj.nSim] = simPt; gj.simEta[gj.nSim] = simEta; gj.simPhi[gj.nSim] = simPhi; gj.simHasRec[gj.nSim] = (anaTrks[0]->pNRec[ip]==1&&(anaTrks[0]->mtrkAlgo[ip]<4||anaTrks[0]->mtrkQual[ip]>0)); ++gj.nSim; } } // All done tgj->Fill(); } output->Write(); output->Close(); delete c; }
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; }
void forest2yskim_jetSkim_forestV3_noEleRejection(TString inputFile_="forestFiles/pA/pA_photonSkimForest_v85_skimPhotonPt50_eta1.5.root", std::string MinbiasFname = "skim_trackJet_minbiasTrackJet_mc.root", float cutphotonPt = 35, // default value dropped to 35GeV for later photon energy smearing/scaling std::string outname = "testPhotonSkim.root", sampleType colli=kPADATA, bool doMix = false, bool doJetResCorrection = 1, // = L2L3 * MC nonclosure correction jet energy correction is done by default from Oct 19th (YS) int smearingCentBin = -1, //0=0-10%, 1=10-30%, 2=30-50%, 3=50-100%, 4=0-30%, 5=30-100% : Jet pT and phi smearing! float jetEnergyScale = 1.0, float addFlatJetEnergyRes = 0.0, bool useGenJetColl = 0 ) { bool isMC=true; if ((colli==kPPDATA)||(colli==kPADATA)||(colli==kHIDATA)) isMC=false; int seconds = time(NULL); cout << " time = " <<seconds%10000<< endl; TRandom3 rand(seconds%10000); TString datafname = ""; float cutphotonEta = 1.44; float preCutPhotonEt = 30; const int nMaxPho = 100; HiForest *c; if((colli==kPADATA)||(colli==kPAMC)) { c = new HiForest(inputFile_.Data(), "forest", cPPb, isMC ); } else if ((colli==kPPDATA)||(colli==kPPMC)) { c = new HiForest(inputFile_.Data(), "forest", cPP, isMC ); } else if ((colli==kHIDATA)||(colli==kHIMC)) { c = new HiForest(inputFile_.Data(), "forest", cPbPb, isMC ); c->GetEnergyScaleTable("../photonEnergyScaleTable_lowPt_v6.root"); } else { cout << " Error! No such collision type" << endl; return; } c->InitTree(); // vertex and centrality vtxCentWeighting TFile* fWeight = new TFile("../vertexReweightingHistogram_pthatweighted.root"); TH1D* hWeight_vtx_data_pp = (TH1D*)fWeight->Get("vertexHistoData_pp"); TH1D* hWeight_vtx_mc_pp = (TH1D*)fWeight->Get("vertexHistoMC_pp"); TH1D* hWeight_vtx_data_ppb = (TH1D*)fWeight->Get("vertexHistoData_ppb"); TH1D* hWeight_vtx_mc_ppb = (TH1D*)fWeight->Get("vertexHistoMC_ppb"); TH1D* hWeight_vtx_data_pbpb = (TH1D*)fWeight->Get("vertexHistoData_pbpb"); TH1D* hWeight_vtx_mc_pbpb = (TH1D*)fWeight->Get("vertexHistoMC_pbpb"); TH1D* hWeight_cent_data_pbpb = (TH1D*)fWeight->Get("centBinHistoData_pbpb"); TH1D* hWeight_cent_mc_pbpb = (TH1D*)fWeight->Get("centBinHistoMC_pbpb"); // L2L3 correction TFile* fL2L3pp = new TFile("../corrL2L3/Casym_pp_double_hcalbins_algo_ak3PF_pt100_140_jet80_alphahigh_20_phicut250.root"); TH1D * c_etapp=(TH1D*)fL2L3pp->Get("C_asym"); TF1* fptpp = new TF1("fptpp","1-[0]/pow(x,[1])",20,300); fptpp->SetParameters(0.06971,0.8167); TFile* fL2L3pA = new TFile("../corrL2L3/Casym_pPb_double_hcalbins_algo_akPu3PF_pt100_140_jet80_alphahigh_20_phicut250.root"); TH1D * c_etapA=(TH1D*)fL2L3pA->Get("C_asym"); TF1* fptpA = new TF1("fptpA","1-[0]/pow(x,[1])",20,300); fptpA->SetParameters(0.3015, 0.8913); TFile* fL2L3Ap = new TFile("../corrL2L3/Casym_Pbp_double_hcalbins_algo_akPu3PF_pt100_140_jet80_alphahigh_20_phicut250.root"); TH1D * c_etaAp=(TH1D*)fL2L3Ap->Get("C_asym"); TF1* fptAp = new TF1("fptAp","1-[0]/pow(x,[1])",20,300); fptAp->SetParameters(0.3015, 0.8913); // pA MC TF1 * fgaus=new TF1("fgaus_pA","gaus(0)",-20,20); fgaus->SetParameters(1,0,1); TF1 * fsmear_pA = new TF1("fsmear_pA","[0]/pow(x,[1])",50,300); fsmear_pA->SetParameters(1.052,0.5261); /* TCanvas* c11 = new TCanvas("c11","",1200,400); // valiation of smearing factors c11->Divide(3,1); c11->cd(1); c_etapp->Draw(); c11->cd(2); c_etaAp->Draw(); c11->cd(3); c_etapA->Draw(); c11->SaveAs("f1.gif"); */ // Create a new root file TFile* newfile_data = new TFile(outname.data(),"recreate"); TTree* newtreePhoton; float newPt[nMaxPho]; // <<= temporary space int order[nMaxPho]; float corrPt[nMaxPho]; newtreePhoton = c->photonTree->CloneTree(0); newtreePhoton->SetName("yPhotonTree"); newtreePhoton->SetMaxTreeSize(MAXTREESIZE); newtreePhoton->Branch("order", order, "order[nPhotons]/I"); newtreePhoton->Branch("corrPt", corrPt,"corrPt[nPhotons]/F"); TTree* treeFullJet; if ( (colli==kPPDATA) || (colli==kPPMC) ) { //treeFullJet = c->ak3jetTree->CloneTree(0); treeFullJet = c->ak3PFJetTree->CloneTree(0); cout << "pp collision. Using ak3PF Jet Algo" << endl<<endl; } else { //treeFullJet = c->akPu3jetTree->CloneTree(0); treeFullJet = c->akPu3PFJetTree->CloneTree(0); cout << "PbPb or pPb collision. Using akPu3PF Jet Algo" << endl<<endl; } treeFullJet->SetName("fullJet"); treeFullJet->SetMaxTreeSize(MAXTREESIZE); #if 1 TTree* treeGenp; if ( (colli==kHIMC ) || (colli==kPPMC) || (colli==kPAMC) ) { treeGenp = c->genParticleTree->CloneTree(0); treeGenp->SetName("genparTree"); //treeGenp = c->genpTree->CloneTree(0); //treeGenp->SetName("genparTree"); treeGenp->SetMaxTreeSize(MAXTREESIZE); } #endif // jet tree! int nJet; const int MAXJET = 50000; // to accomodate 100 smeared jets, need to be careful with ram float jetPt[MAXJET]; float jetEta[MAXJET]; float jetPhi[MAXJET]; float jetDphi[MAXJET]; int jetSubid[MAXJET]; float jetRefPt[MAXJET]; float jetRefEta[MAXJET]; float jetRefPhi[MAXJET]; float jetRefDphi[MAXJET]; float jetRefPartonPt[MAXJET]; int jetRefPartonFlv[MAXJET]; TTree *newtreeJet = new TTree("yJet","jets"); newtreeJet->SetMaxTreeSize(MAXTREESIZE); newtreeJet->Branch("nJet",&nJet,"nJet/I"); newtreeJet->Branch("pt",jetPt,"pt[nJet]/F"); newtreeJet->Branch("eta",jetEta,"eta[nJet]/F"); newtreeJet->Branch("phi",jetPhi,"phi[nJet]/F"); newtreeJet->Branch("dphi",jetDphi,"dphi[nJet]/F"); if ( isMC ) { newtreeJet->Branch("subid",jetSubid,"subid[nJet]/I"); newtreeJet->Branch("refPt",jetRefPt,"refPt[nJet]/F"); newtreeJet->Branch("refEta",jetRefEta,"refEta[nJet]/F"); newtreeJet->Branch("refPhi",jetRefPhi,"refPhi[nJet]/F"); newtreeJet->Branch("refDphi",jetRefDphi,"refDphi[nJet]/F"); newtreeJet->Branch("refPartonPt",jetRefPartonPt,"refPartonPt[nJet]/F"); newtreeJet->Branch("refPartonFlv",jetRefPartonFlv,"refPartonFlv[nJet]/I"); } int nMjet; float mJetPt[MAXMJET]; float mJetEta[MAXMJET]; float mJetPhi[MAXMJET]; float mJetDphi[MAXMJET]; TTree * tmixJet = new TTree("mJet","Jet from minbias events"); tmixJet->SetMaxTreeSize(MAXTREESIZE); tmixJet->Branch("nJet",&nMjet,"nJet/I"); tmixJet->Branch("pt",mJetPt,"pt[nJet]/F"); tmixJet->Branch("eta",mJetEta,"eta[nJet]/F"); tmixJet->Branch("phi",mJetPhi,"phi[nJet]/F"); tmixJet->Branch("dphi", mJetDphi, "dphi[nJet]/F"); // Imb = Input MinBias events EvtSel evtImb; Int_t nJetImb; Float_t jetPtImb[100]; Float_t jetEtaImb[100]; Float_t jetPhiImb[100]; TBranch *b_evt; TBranch *b_nJetImb; TBranch *b_jetPtImb; TBranch *b_jetEtaImb; TBranch *b_jetPhiImb; int nCentBins = nCentBinSkim; if ((colli==kPADATA)||(colli==kPAMC)) { nCentBins = nCentBinSkimPA; } TChain *tjmb[100][nVtxBin+1]; int nMB[100][nVtxBin+1] ; //= 199109; int mbItr[100][nVtxBin+1]; if ( doMix ) { cout <<" Tree initialization for MinBias mixing" << endl; for( int icent = 0 ; icent< nCentBins ; icent++) { for( int ivz = 1 ; ivz<=nVtxBin ; ivz++) { tjmb[icent][ivz] = new TChain(Form("trkAndJets_first_cBin2icent%d_ivz%d",icent,ivz)); tjmb[icent][ivz]->Add(MinbiasFname.data()); tjmb[icent][ivz]->SetBranchAddress("evt", &evtImb,&b_evt); tjmb[icent][ivz]->SetBranchAddress("nJet", &nJetImb, &b_nJetImb); tjmb[icent][ivz]->SetBranchAddress("jetPt", &jetPtImb, &b_jetPtImb); tjmb[icent][ivz]->SetBranchAddress("jetEta", &jetEtaImb, &b_jetEtaImb); tjmb[icent][ivz]->SetBranchAddress("jetPhi", &jetPhiImb, &b_jetPhiImb); nMB[icent][ivz] = tjmb[icent][ivz]->GetEntries(); cout << "number of evetns in (icent = " << icent << ", ivtxZ = "<< ivz << ") = " << nMB[icent][ivz] << endl; int primeSeed = rand.Integer(37324); mbItr[icent][ivz] = primeSeed%(nMB[icent][ivz]); cout <<" initial itr = " << mbItr[icent][ivz] << endl; } } } else cout << endl << endl << " Mixing process is skipped" << endl << endl << endl ; // reweighting factor should go here int eTot(0), eSel(0); EvtSel evt; GammaJet gj; Isolation isol; TTree *tgj; tgj = new TTree("tgj","gamma jet tree"); tgj->SetMaxTreeSize(MAXTREESIZE); tgj->Branch("evt",&evt.run,"run/I:evt:cBin:pBin:trig/O:offlSel:noiseFilt:anaEvtSel:vz/F:vtxCentWeight/F:hf4Pos:hf4Neg:hf4Sum:ptHat:ptHatWeight"); tgj->Branch("lpho",&gj.photonEt,"photonEt/F:photonRawEt:photonEta:photonPhi:hovere:r9:sigmaIetaIeta:sumIso:genIso:genPhotonEt:genMomId/I:lJetPt/F:lJetEta:lJetPhi:lJetDphi:lJetSubid/I"); tgj->Branch("isolation",&isol.cc1,"cc1:cc2:cc3:cc4:cc5:cr1:cr2:cr3:cr4:cr5:ct1PtCut20:ct2PtCut20:ct3PtCut20:ct4PtCut20:ct5PtCut20:ecalIso:hcalIso:trackIso"); // ecalIso,hcalIso,trackIso are the pp style isolation float vzCut = vtxCutPhotonAna; TH1F* hvz = new TH1F("hvz","",nVtxBin,-vzCut,vzCut); // event plane hitogram TH1F* hEvtPlnBin = new TH1F("hEvtPlnBin", "", nPlnBin, -PI/2., PI/2.); // jet algos Jets* theJet; Jets* genJetTree; if ( (colli==kPPDATA) || (colli==kPPMC) ) { theJet = &(c->ak3PF) ; cout << "pp collision. Using ak3PF Jet Algo" << endl<<endl; } else { theJet = &(c->akPu3PF) ; cout << "PbPb or pPb collision. Using akPu3PF Jet Algo" << endl<<endl; } genJetTree = &(c->akPu3PF); //////// Kaya's modificiation //////// EventMatchingCMS* eventMatcher=new EventMatchingCMS(); bool eventAdded; Long64_t duplicateEvents = 0; //////// Kaya's modificiation - END //////// // Loop starts. int nentries = c->GetEntries(); cout << "number of entries = " << nentries << endl; for (Long64_t jentry = 0 ; jentry < nentries; jentry++) { eTot++; if (jentry% 2000 == 0) { cout <<jentry<<" / "<<nentries<<" "<<setprecision(2)<<(double)jentry/nentries*100<<endl; } c->GetEntry(jentry); //////// Kaya's modificiation //////// eventAdded = eventMatcher->addEvent(c->evt.evt, c->evt.lumi, c->evt.run, jentry); if(!eventAdded) // this event is duplicate, skip this one. { duplicateEvents++; continue; } //////// Kaya's modificiation - END //////// // Select events with a generated photon in mid-rapidity bool genPhotonFlag=false; if ( !isMC ) // fixed the most stupid error genPhotonFlag = true; else { #if 0 // there is no genp tree, but is higentree for ( int g=0 ; g< c->genp.nPar ; g++) if ( c->genp.id[g] != 22 ) continue; if ( fabs( c->genp.momId[g] ) > 22 ) continue; if ( fabs( c->genp.status[g] ) != 1 ) continue; if ( fabs( c->genp.eta[g] ) > cutphotonEta ) continue; if ( c->genp.et[g] < 35 ) continue; #endif for ( int g=0 ; g< c->genparticle.mult ; g++) { if ( c->genparticle.pdg[g] != 22 ) continue; // if ( fabs( c->genparticle.momId[g] ) > 22 ) // continue; // if ( fabs( c->genparticle.status[g] ) != 1 ) // continue; if ( fabs( c->genparticle.eta[g] ) > cutphotonEta ) continue; if ( c->genparticle.pt[g] < cutphotonPt ) continue; genPhotonFlag = true; } } if ( !genPhotonFlag) continue; evt.clear(); evt.run = c->evt.run; evt.evt = c->evt.evt; evt.hf4Pos = c->evt.hiHFplusEta4; evt.hf4Neg = c->evt.hiHFminusEta4; evt.hf4Sum = evt.hf4Pos + evt.hf4Neg; evt.cBin = -99; evt.pBin = -99 ; if ((colli==kHIDATA)||(colli==kHIMC)) { evt.cBin = c->evt.hiBin; evt.pBin = hEvtPlnBin->FindBin( c->evt.hiEvtPlanes[theEvtPlNumber] ) ; } else if ((colli==kPADATA)||(colli==kPAMC)) { evt.cBin = getHfBin(evt.hf4Sum); // if ( ((evt.cBin) < 0) || (evt.cBin) > 18 ) // cout << " Check the pA centrality.. cbin = " << evt.cBin << endl; } evt.trig = 0; evt.offlSel = (c->skim.pcollisionEventSelection > 0); evt.noiseFilt = (c->skim.pHBHENoiseFilter > 0); evt.anaEvtSel = c->selectEvent() && evt.trig; evt.vz = c->evt.vz; int cBin = evt.cBin; int vzBin = hvz->FindBin(evt.vz) ; hvz->Fill(evt.vz) ; // this was the problem!!! all c->selectEvent() are 0 //if ( ( (colli==kHIDATA)||(colli==kHIMC)||(colli==kPADATA)||(colli==kPAMC) || (colli==kPPMC) ) && ( c->selectEvent() == 0 )) if ( ( (colli==kHIDATA)||(colli==kHIMC) ) && ( c->skim.pcollisionEventSelection == 0 )) continue; if ( ( (colli==kPADATA)||(colli==kPAMC)||(colli==kPPDATA)||(colli==kPPMC)) && ( c->skim.pPAcollisionEventSelectionPA == 0 )) // yeonju included pp data and pp mc continue; // if ( ( (colli==kPPMC) ) && ( c->skim.pcollisionEventSelection == 0 )) // continue; // if ( ( (colli==kPADATA)||(colli==kPPDATA) ) && ( c->skim.pVertexFilterCutGplus ==0 ) ) // No Pile up events // continue; if ( (vzBin<1) || ( vzBin > nVtxBin) ) continue; eSel++; // OK. This event is a collisional and no-noise event. // Reweight for vertex and centrality of MC evt.vtxCentWeight = 1; double wVtx=1; double wCent=1; if (colli ==kHIMC) { int vBin = hWeight_vtx_data_pbpb->FindBin(evt.vz); wVtx = hWeight_vtx_data_pbpb->GetBinContent(vBin) / hWeight_vtx_mc_pbpb->GetBinContent(vBin) ; wCent = hWeight_cent_data_pbpb->GetBinContent(evt.cBin+1) / hWeight_cent_mc_pbpb->GetBinContent(evt.cBin+1) ; } else if ( colli ==kPPMC) { int vBin = hWeight_vtx_data_pp->FindBin(evt.vz); wVtx = hWeight_vtx_data_pp->GetBinContent(vBin) / hWeight_vtx_mc_pp->GetBinContent(vBin) ; } else if ( colli ==kPAMC) { int vBin = hWeight_vtx_data_ppb->FindBin(evt.vz); wVtx = hWeight_vtx_data_ppb->GetBinContent(vBin) / hWeight_vtx_mc_ppb->GetBinContent(vBin) ; } evt.vtxCentWeight = wVtx * wCent; evt.ptHat = -1; evt.ptHatWeight = 1; evt.ptHat = c->photon.ptHat; // if( colli == kPAMC && evt.ptHat > maxpthat ) // pA samples don't use ptHatCutter.C. // continue; if (colli ==kHIMC) { if ( evt.ptHat < 50 ) evt.ptHatWeight = 9008/16237. ; else if ( evt.ptHat < 80 ) evt.ptHatWeight = 3750/85438. ; else evt.ptHatWeight = 1191/140432. ; } else if ( colli == kPPMC) { // pp has only 4 pthat samples if ( evt.ptHat > 30 && evt.ptHat < 50 ) evt.ptHatWeight = 156861/156861. ; else if ( evt.ptHat > 50 && evt.ptHat < 80 ) evt.ptHatWeight = 33610/193462. ; else if ( evt.ptHat > 80 && evt.ptHat < 120 ) evt.ptHatWeight = 5757/195174. ; else evt.ptHatWeight = 1272/236703. ; // if ( evt.ptHat < 50 ) evt.ptHatWeight = 9008/9008. ; // else if ( evt.ptHat < 80 ) evt.ptHatWeight = 3750/40109. ; // else evt.ptHatWeight = 1191/66934. ; } else if ( colli == kPAMC) { if ( evt.ptHat > 30 && evt.ptHat < 50 ) evt.ptHatWeight = 62744/62744. ; else if ( evt.ptHat > 50 && evt.ptHat < 80 ) evt.ptHatWeight = 29499/107309. ; else if ( evt.ptHat > 80 && evt.ptHat < 120 ) evt.ptHatWeight = 7640/106817. ; else if ( evt.ptHat > 120 && evt.ptHat < 170 ) evt.ptHatWeight = 1868/104443. ; else evt.ptHatWeight = 649/139647. ; } for (int j=0;j< c->photon.nPhotons;j++) { if ( ( c->photon.pt[j] > preCutPhotonEt ) && ( fabs( c->photon.eta[j] ) < cutphotonEta ) ) { newPt[j] = c->getCorrEt(j); } else newPt[j] = c->photon.pt[j] - 10000; // if ( (c->isSpike(j)) || (c->photon.hadronicOverEm[j]>0.2) || (c->photon.isEle[j])) // Electron Rejection should be default. if ( (c->isSpike(j)) || (c->photon.hadronicOverEm[j]>0.2) ) //|| (c->photon.isEle[j]) // This is for no Electron Rejection case. newPt[j] = newPt[j] - 20000; if (c->photon.seedTime[j] ==0 ) // clustering bug newPt[j] = newPt[j] - 30000; corrPt[j] = newPt[j]; } TMath::Sort(c->photon.nPhotons, newPt, order); // Select the leading photon gj.clear(); int leadingIndex=-1; for (int j=0;j<c->photon.nPhotons;j++) { if ( c->photon.pt[j] < preCutPhotonEt ) continue; if ( fabs(c->photon.eta[j]) > cutphotonEta ) continue; if (c->isSpike(j)) continue; // if (!(c->isLoosePhoton(j))) continue; if (c->photon.hadronicOverEm[j]>0.1) continue; if ((c->photon.rawEnergy[j]/c->photon.energy[j])<0.5) continue; // sort using corrected photon pt float theCorrPt= corrPt[j]; if ( theCorrPt > gj.photonEt) { gj.photonEt = theCorrPt; leadingIndex = j; } } // if ( (gj.photonEt < cutphotonPt) ) <== This cut ruins the ptHat weighting factor // continue; /// Save leading photons if (leadingIndex!=-1) { gj.photonRawEt=c->photon.pt[leadingIndex]; gj.photonEta=c->photon.eta[leadingIndex]; gj.photonPhi=c->photon.phi[leadingIndex]; gj.hovere=c->photon.hadronicOverEm[leadingIndex]; gj.r9=c->photon.r9[leadingIndex]; gj.sigmaIetaIeta=c->photon.sigmaIetaIeta[leadingIndex]; gj.sumIsol = (c->photon.cr4[leadingIndex]+c->photon.cc4[leadingIndex]+c->photon.ct4PtCut20[leadingIndex]) / 0.9; gj.genIso = c->photon.genCalIsoDR04[leadingIndex]; gj.genPhotonEt = c->photon.genMatchedPt[leadingIndex]; gj.genMomId = c->photon.genMomId[leadingIndex]; isol.Set(c,leadingIndex); } else { gj.clear(); } if ( (colli==kPADATA) && ( evt.run > 211256 ) ) { gj.photonEta = - gj.photonEta; } ///////////////////// Skimmed Jet tree /////////////////////////////////// nJet = 0 ; int jetEntries = 0; if (useGenJetColl ) jetEntries = theJet->ngen; else jetEntries = theJet->nref; int nSmear = 1; if(smearingCentBin != -1) nSmear = 100; for(int iSmear =0; iSmear < nSmear; iSmear++){ // iSmear loop have to be here, before Jet loop. mis-ordered for loops ruins jetrefpt values. for (int ij=0; ij< jetEntries ; ij++) { if ( gj.photonEt < 0 ) continue ; // If there is no photon in this event if ( useGenJetColl ) { jetPt[nJet] = theJet->genpt[ij]; jetEta[nJet] = theJet->geneta[ij]; jetPhi[nJet] = theJet->genphi[ij]; } else { jetPt[nJet] = theJet->jtpt[ij]; jetEta[nJet] = theJet->jteta[ij]; jetPhi[nJet] = theJet->jtphi[ij]; } // Smear phi Double_t newPhi = jetPhi[nJet] ; if( smearingCentBin != -1 ) { Double_t phiSmear = TMath::Sqrt((cphi_pbpb[smearingCentBin]*cphi_pbpb[smearingCentBin] - cphi_pp*cphi_pp) + (sphi_pbpb[smearingCentBin]*sphi_pbpb[smearingCentBin] - sphi_pp*sphi_pp)/jetPt[nJet] + (nphi_pbpb[smearingCentBin]*nphi_pbpb[smearingCentBin] - nphi_pp*nphi_pp)/(jetPt[nJet]*jetPt[nJet])); newPhi = jetPhi[nJet] + rand.Gaus(0, phiSmear); while ( fabs(newPhi) > PI ) { if ( newPhi > PI ) newPhi = newPhi - 2*PI; if ( newPhi < -PI ) newPhi = newPhi + 2*PI; } } jetPhi[nJet] = newPhi; // smear the jet pT //float smeared = jetPt[nJet] * rand.Gaus(1,addJetEnergyRes/jetPt[nJet]) * rand.Gaus(1, addFlatJetEnergyRes) ; Double_t smeared = jetPt[nJet] * rand.Gaus(1, addFlatJetEnergyRes); if( smearingCentBin != -1 ) { Double_t smearSigma = TMath::Sqrt((c_pbpb[smearingCentBin]*c_pbpb[smearingCentBin] - c_pp*c_pp) + (s_pbpb[smearingCentBin]*s_pbpb[smearingCentBin] - s_pp*s_pp)/jetPt[nJet] + (n_pbpb[smearingCentBin]*n_pbpb[smearingCentBin] - n_pp*n_pp)/(jetPt[nJet]*jetPt[nJet])); smeared = jetPt[nJet] * rand.Gaus(1, smearSigma); } // then multiply jet energy sclae // resCorrection float resCorrection =1. ; float l2l3Corr =1 ; if (doJetResCorrection) { // L2L3 correction! if ( colli == kPPDATA) { l2l3Corr = c_etapp->GetBinContent(c_etapp->FindBin(jetEta[nJet])) * fptpp->Eval( jetPt[nJet]); } else if ( colli == kPADATA) { if ( evt.run > 211256 ) l2l3Corr = c_etapA->GetBinContent(c_etapA->FindBin(jetEta[nJet])) * fptpA->Eval( jetPt[nJet]); else l2l3Corr = c_etaAp->GetBinContent(c_etaAp->FindBin(jetEta[nJet])) * fptAp->Eval( jetPt[nJet]); } else if ( colli == kPAMC) l2l3Corr = 1 + (fsmear_pA->Eval( jetPt[nJet] )) * fgaus->GetRandom() ; // do the residual correction if ((colli==kHIDATA)||(colli==kHIMC)) { if ( evt.cBin < 12 ) // central resCorrection = 1.04503 -1.6122 /(sqrt(jetPt[nJet])) + 9.27212 / (jetPt[nJet]); //1.04503 -1.6122 9.27212 else // peripheral resCorrection = 1.00596 -0.653191/(sqrt(jetPt[nJet])) + 4.35373 / (jetPt[nJet]); //1.00596 -0.653191 4.35373 } else if ((colli==kPPDATA)||(colli==kPPMC)){ // do the residual correction resCorrection = 0.993609 +0.158418/(sqrt(jetPt[nJet])) + 0.335479 / (jetPt[nJet]);// 0.993609 0.158418 0.335479 } else if ((colli==kPADATA)||(colli==kPAMC)){ resCorrection = 0.997738 + 0.0221806/(sqrt(jetPt[nJet])) - 0.877999/ (jetPt[nJet]); //C : 0.997738, S : 0.0221806, N : -0.877999 //function derived as a function of gen pt //resCorrection = 0.981365 + 0.342746/(sqrt(jetPt[nJet])) - 2.63018 / (jetPt[nJet]); //C : 0.981365, S : 0.342746, N : -2.63018 //function derived as a function of gen pt //derived from l2l3 corrected sample. //resCorrection = 0.745753 + 6.91646/(sqrt(jetPt[nJet])) - 33.0167 / (jetPt[nJet]); //C : 0.745753, S : 6.91646, N : -33.0167 //function derived as a function of reco pt } } // doJetResCorrection // reflect eta! if ( (colli==kPADATA) && ( evt.run > 211256 ) ) { jetEta[nJet] = -jetEta[nJet]; } jetPt[nJet] = smeared * l2l3Corr /resCorrection *jetEnergyScale; if ( jetPt[nJet] < cutjetPtSkim) // double cutjetPtSkim = 15; Oct 19th continue; if ( fabs( jetEta[nJet] ) > cutjetEtaSkim ) // double cutjetEtaSkim = 3.0; Oct 19th continue; if ( getDR( jetEta[nJet], jetPhi[nJet], gj.photonEta, gj.photonPhi) < 0.5 ) continue; if (jetPt[nJet] >0) jetDphi[nJet] = getAbsDphi( jetPhi[nJet], gj.photonPhi) ; else jetDphi[nJet] = -1; if ( useGenJetColl ) { jetSubid[nJet] = -9999; jetRefPt[nJet] = -9999; jetRefEta[nJet] = -9999; jetRefPhi[nJet] = -9999; jetRefPt[nJet] = -9999; jetRefPartonPt[nJet] = -9999; jetRefPartonFlv[nJet] = -9999; } else { jetRefPt[nJet] = theJet->refpt[ij]; jetRefEta[nJet] = theJet->refeta[ij]; jetRefPhi[nJet] = theJet->refphi[ij]; if (jetRefPt[nJet] >0) jetRefDphi[nJet] = getAbsDphi( jetRefPhi[nJet] , gj.photonPhi) ; else jetRefDphi[nJet] = -1; jetRefPartonPt[nJet] = theJet->refparton_pt[ij]; jetRefPartonFlv[nJet] = theJet->refparton_flavor[ij]; jetSubid[nJet] = -9999; if (jetRefPt[nJet] >0) { // Find the collisional subid of this gen jet!! for ( int igen=0; igen < genJetTree->ngen ; igen++) { if ( jetRefPt[nJet] == genJetTree->genpt[igen] ) jetSubid[nJet] = genJetTree->gensubid[igen] ; } if ( jetSubid[nJet] == -9999 ) // No genJet matched! cout << " WARNING! This reco jet was not matched to anyone in the gen jet collection!!! " << endl; } } nJet++ ; }// ij for loop }// iSmear for loop //////// Leading jet kinematics in dphi>7pi/8 float maxJpt = 0; int jetLeadingIndex = -1; for (int ij=0; ij< nJet ; ij++) { if ( jetDphi[ij] < awayRange ) // const float awayRange= PI * 7./8.; continue; if ( fabs( jetEta[ij] ) > cutjetEta ) // double cutjetEta = 1.6; continue; if ( jetPt[ij] > maxJpt) { maxJpt = jetPt[ij] ; jetLeadingIndex = ij; } } if ( jetLeadingIndex > -1 ) { gj.lJetPt = jetPt[jetLeadingIndex]; gj.lJetEta = jetEta[jetLeadingIndex]; gj.lJetPhi = jetPhi[jetLeadingIndex]; gj.lJetDphi = jetDphi[jetLeadingIndex]; gj.lJetSubid= jetSubid[jetLeadingIndex]; } else { gj.lJetPt = -1; gj.lJetEta = 999; gj.lJetPhi = 999; gj.lJetDphi = 0; gj.lJetSubid= -99; } int nMixing = nMixing1; nMjet = 0; bool noSuchEvent = false; int iMix=0; int loopCounter=0; if ( !doMix ) iMix = nMixing+1; // Mixing step will be skipped while (iMix<nMixing) { loopCounter++; if ( loopCounter > nMB[cBin][vzBin]+1) { iMix = 999999 ; noSuchEvent = true; cout << " no such event!! : icent = " << cBin << ", vzBin = " << vzBin << ", pBin = " << evt.pBin << endl; continue; } mbItr[cBin][vzBin] = mbItr[cBin][vzBin] + 1; if ( mbItr[cBin][vzBin] == nMB[cBin][vzBin] ) mbItr[cBin][vzBin] = mbItr[cBin][vzBin] - nMB[cBin][vzBin]; /// Load the minbias tracks!! tjmb[cBin][vzBin]->GetEntry(mbItr[cBin][vzBin]); // ok found the event!! /////////// loopCounter =0; // Re-initiate loopCounter // Jet mixing for (int it = 0 ; it < nJetImb ; it++) { if ( gj.photonEt < 0 ) continue; // Smear phi Double_t newPhi = jetPhiImb[it]; if( smearingCentBin != -1 ) { Double_t phiSmear = TMath::Sqrt((cphi_pbpb[smearingCentBin]*cphi_pbpb[smearingCentBin] - cphi_pp*cphi_pp) + (sphi_pbpb[smearingCentBin]*sphi_pbpb[smearingCentBin] - sphi_pp*sphi_pp)/jetPtImb[it] + (nphi_pbpb[smearingCentBin]*nphi_pbpb[smearingCentBin] - nphi_pp*nphi_pp)/(jetPtImb[it]*jetPtImb[it])); newPhi = jetPhiImb[it] + rand.Gaus(0, phiSmear); while ( fabs(newPhi) > PI ) { if ( newPhi > PI ) newPhi = newPhi - 2*PI; if ( newPhi < -PI ) newPhi = newPhi + 2*PI; } } jetPhiImb[it] = newPhi; // smear the jet pT //float smeared = jetPtImb[it] * rand.Gaus(1,addJetEnergyRes/jetPtImb[it]) * rand.Gaus(1, addFlatJetEnergyRes) ; Double_t smeared = jetPtImb[it] * rand.Gaus(1, addFlatJetEnergyRes); if( smearingCentBin != -1 ) { Double_t smearSigma = TMath::Sqrt((c_pbpb[smearingCentBin]*c_pbpb[smearingCentBin] - c_pp*c_pp) + (s_pbpb[smearingCentBin]*s_pbpb[smearingCentBin] - s_pp*s_pp)/jetPtImb[it] + (n_pbpb[smearingCentBin]*n_pbpb[smearingCentBin] - n_pp*n_pp)/(jetPtImb[it]*jetPtImb[it])); smeared = jetPtImb[it] * rand.Gaus(1, smearSigma); } float resCorrection =1. ; float l2l3Corr =1 ; if (doJetResCorrection) { // L2L3 if ( colli == kPPDATA) { l2l3Corr = c_etapp->GetBinContent(c_etapp->FindBin(jetEtaImb[it])) * fptpp->Eval( jetPtImb[it]); } else if ( colli == kPADATA) { if ( evt.run > 211256 ) l2l3Corr = c_etapA->GetBinContent(c_etapA->FindBin(jetEtaImb[it])) * fptpA->Eval( jetPtImb[it]); else l2l3Corr = c_etaAp->GetBinContent(c_etaAp->FindBin(jetEtaImb[it])) * fptAp->Eval( jetPtImb[it]); } else if ( colli == kPAMC) l2l3Corr = 1 + (fsmear_pA->Eval( jetPtImb[it] )) * fgaus->GetRandom() ; // Correction from MC closure if ((colli==kHIDATA)||(colli==kHIMC)) { // do the residual correction if ( evt.cBin < 12 ) // central resCorrection = 1.04503 -1.6122 /(sqrt(jetPtImb[it])) + 9.27212 / (jetPtImb[it]); //1.04503 -1.6122 9.27212 else // peripheral resCorrection = 1.00596 -0.653191/(sqrt(jetPtImb[it])) + 4.35373 / (jetPtImb[it]); //1.00596 -0.653191 4.35373 } else if ((colli==kPPDATA)||(colli==kPPMC)){ // do the residual correction resCorrection = 0.993609 +0.158418/(sqrt(jetPtImb[it])) + 0.335479 / (jetPtImb[it]);// 0.993609 0.158418 0.335479 } else if ((colli==kPADATA)||(colli==kPAMC)){ resCorrection = 0.997738 + 0.0221806/(sqrt(jetPtImb[it])) - 0.877999 / (jetPtImb[it]); //C : 0.997738, S : 0.0221806, N : -0.877999 //function derived as a function of gen pt //resCorrection = 0.981365 + 0.342746/(sqrt(jetPtImb[it])) - 2.63018 / (jetPtImb[it]); //C : 0.981365, S : 0.342746, N : -2.63018 //function derived as a function of gen pt//derived from l2l3 corrected sample. //resCorrection = 0.745753 + 6.91646/(sqrt(jetPtImb[it])) - 33.0167 / (jetPtImb[it]); //C : 0.745753, S : 6.91646, N : -33.0167//function derived as a function of reco pt } } float smearedCorrected = smeared *l2l3Corr / resCorrection *jetEnergyScale; // residual correction if ( smearedCorrected < cutjetPtSkim ) // double cutjetPtSkim = 15; Oct 19th continue; if ( fabs( jetEtaImb[it] ) > cutjetEtaSkim ) // double cutjetEtaSkim = 3.0; Oct 19th continue; if ( getDR( jetEtaImb[it], jetPhiImb[it], gj.photonEta, gj.photonPhi) < 0.5 ) // This cut added for consistency ; Oct 19th continue; mJetPt[nMjet] = smearedCorrected; mJetEta[nMjet] = jetEtaImb[it]; mJetPhi[nMjet] = jetPhiImb[it]; if ( mJetPt[nMjet]>0 ) mJetDphi[nMjet] = getAbsDphi(mJetPhi[nMjet], gj.photonPhi) ; else mJetDphi[nMjet]=-1; nMjet++; // < == Important! } iMix++; } if ( noSuchEvent ) continue; tgj->Fill(); newtreeJet->Fill(); tmixJet->Fill(); newtreePhoton->Fill(); treeFullJet->Fill(); if ( (colli==kHIMC ) || (colli==kPPMC) || (colli==kPAMC) ) treeGenp->Fill(); } newfile_data->Write(); // newfile_data->Close(); // <<=== If there is close() function. writing stucks in the middle of looping.. I don't know why!! cout << " Done! "<< endl; cout << " " << eSel<<" out of total "<<eTot<<" events were analyzed."<<endl; cout << "Duplicate events = " << duplicateEvents << endl; }
void analyzeTrackingCorrection( TString jetAlgo = "ak3PF", TString trkCol = "ppTrack", // TString trkCol = "anaTrack", // TString inname="/mnt/hadoop/cms/store/user/yenjie/HiForest_v27/Dijet${pthat}_HydjetDrum_v27_mergedV1.root", // TString inname="/mnt/hadoop/cms/store/user/yenjie/HiForest_v27/Dijet80_HydjetDrum_v27_mergedV1.root", // TString outname="trkcorr/test/TrkCorrtest_hy18dj100.root", TString coll = "PbP", // double samplePtHat=0, // double ptHatMax=9999, // double sampleWeight = 1, double cutPtTrk=0.5, double vzMax = 15, int maxEntries = -1, double leadingJetPtMin=100, double subleadingJetPtMin=-1, double sigDPhi=-1, bool genJetMode=false ) { samplePtHat = atoi(getenv("PTHAT")) ; cout <<"PTHAT =" <<samplePtHat<<endl ; // samplePtHat = pthat ; double xsection=0; double xup=0; double xsub=0; TString COM = "5TeV" ; if(coll=="PP" || coll=="PbPb"){ if(samplePtHat==15){ ptHatMax=30; xup =2.034E-01; xsub=1.075E-02; } else if(samplePtHat==30){ ptHatMax=50; xup =1.075E-02; xsub=1.025E-03; } else if(samplePtHat==50){ ptHatMax=80; xup =1.025E-03; xsub=9.865E-05; } else if(samplePtHat==80){ ptHatMax=120; xup =9.865E-05; xsub=1.129E-05; } else if(samplePtHat==120){ ptHatMax=170; xup=1.129E-05; xsub=1.465E-06; }else if(samplePtHat==170){ ptHatMax=200; xup=1.465E-06; xsub=5.310E-07; }else if(samplePtHat==200){ ptHatMax=250; xup =5.310E-07; xsub=1.192E-07; }else if(samplePtHat==250){ ptHatMax=300; xup =1.192E-07; xsub=3.176E-08; }else if(samplePtHat==300){ ptHatMax=9999; xup =3.176E-08; xsub=0; } } else { //for pPb at 5 TeV cross section if(samplePtHat==15){ ptHatMax=30; xup =5.335E-01; xsub=3.378E-02; } else if(samplePtHat==30){ ptHatMax=50; xup =3.378E-02; xsub=3.778E-03; } else if(samplePtHat==50){ ptHatMax=80; xup =3.778E-03; xsub=4.412E-04; } else if(samplePtHat==80){ ptHatMax=120; xup =4.412E-04; xsub=6.147E-05; } else if(samplePtHat==120){ ptHatMax=170; xup=6.147E-05; xsub=1.018E-05; }else if(samplePtHat==170){ ptHatMax=220; xup=1.018E-05; xsub=2.477E-06; }else if(samplePtHat==220){ ptHatMax=280; xup =2.477E-06; xsub=6.160E-07; }else if(samplePtHat==280){ // ptHatMax=9999; ptHatMax=370; xup =6.160E-07; xsub=1.088E-07; // xsub=0; }else if(samplePtHat==370){ ptHatMax=9999; xup=1.088E-07; xsub=0; } } xsection = xup-xsub; std::cout<<std::endl; std::cout<<std::endl; if(coll=="PP"){ // dataPath= Form("/net/hisrv0001/home/zhukova/scratch/HIHighPt/forest/pthat%d", samplePtHat); //2012 pp MC with HI tracking // dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/ppHiIterativeTrack/P01/prod24/Signal_Pythia_pt%d/HiForest_v84_merged01", samplePtHat); //MIT path for 2013 pp 2.76 TeV with HI tracking dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Signal_Pythia_pt%d/HiForest_v77_v2_merged01", samplePtHat); //MIT path for 2013 pp 5 TeV with pp tracking // dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/pp2013/P01/prod22/Signal_Pythia_pt%d/HiForest_v81_merged01", samplePtHat); //lxplus path for 2013 pp with pp tracking // intputFile=Form("mergedFile.root"); //! 2012 pp MC with HI tracking // intputFile=Form("pt%d_JEC_ppHiIterativeTrack_P01_prod24_v84_merged_forest_0.root", samplePtHat); //! 2013 pp 2.76 TeV with HI tracking intputFile=Form("pt%d_HP04_hiforest77_hiSignal.root", samplePtHat); //! 2013 pp 5 TeV with pp tracking // intputFile=Form("pt%d_pp2013_P01_prod22_v81_merged_forest_0.root", samplePtHat); //pp tracking } else if(coll=="PbPb"){ if(samplePtHat==50||samplePtHat==80||samplePtHat==100||samplePtHat==170){ dataPath= Form("/mnt/hadoop/cms/store/user/yenjie/HiForest_v27/"); //MIT MC normial intputFile=Form("Dijet%d_HydjetDrum_v27_mergedV1.root", samplePtHat); } else { dataPath= Form("/mnt/hadoop/cms/store/user/yenjie/HiForest_v28/"); //MIT MC normial intputFile=Form("Dijet%d_HydjetDrum_v28_mergedV1.root", samplePtHat); } } else { // dataPath= Form("/mnt/hadoop/cms/store/user/dgulhan/pPb/HP04/prod16/Hijing_Pythia_pt%d/HiForest_v77_merged01", samplePtHat); //MC pPb sample // intputFile=Form("pt%d_HP04_prod16_v77_merged_forest_0.root",samplePtHat); //for Pbp MC input dataPath=Form("/mnt/hadoop/cms/store/user/dgulhan/Pbp/HP05/prod24/Hijing_Pythia_pt%d/HiForest_v84_merged02", samplePtHat); //! MC Pbp sample intputFile=Form("pt%d_HP05_prod24_v84_merged_forest_0.root",samplePtHat); } TString inname=Form("%s/%s", dataPath.Data(),intputFile.Data()); // TString outname=Form("TrkCorrtest_pp2013HITracking_Sigdj%d.root",samplePtHat); // TString outname=Form("TrkCorr_pythia5TeV_Sigdj%d.root",samplePtHat); TString outname=Form("TrkCorr_%s%s%sEff_dj%d.root",COM.Data(), coll.Data(),trkCol.Data(),samplePtHat); TH1::SetDefaultSumw2(); TString tag=Form("%s_%.0f_%.0f_%.0f_genJetMode%d",jetAlgo.Data(),leadingJetPtMin,subleadingJetPtMin,sigDPhi*1000,genJetMode); outname.ReplaceAll(".root",Form("_%s.root",tag.Data())); cout << "Input: " << inname << endl; cout << "Sample pthat = " << samplePtHat << " ptHatMax = " << ptHatMax << endl; cout << "Track pt min = " << cutPtTrk << endl; cout << "skim: leading Jet > " << leadingJetPtMin << " subleading > " << subleadingJetPtMin << " dphi > " << sigDPhi << endl; cout << "Genjet mode: " << genJetMode << endl; cout << "Output: " << outname << endl; /////////////////////////////////////////////////// // Setup Analysis /////////////////////////////////////////////////// double cutjetPt = 40; double cutjetEta = 2; double cutEtaTrk = 2.4; // Define the input file and HiForest // HiForest * c = new HiForest(inname,"mergedTrack"); // HiForest * c = new HiForest(inname,trkCol.Data()); HiForest * c ; if(COM=="5TeV") c = new HiForest(inname.Data(),trkCol.Data(),cPPb); else if(coll=="PP") c = new HiForest(inname.Data(),trkCol.Data(),cPP); else c = new HiForest(inname.Data(),trkCol.Data(),cPbPb); c->doTrackCorrections = false; c->InitTree(); // intialize jet variables Jets * anajet = 0; if (jetAlgo=="akPu3PF") anajet = &(c->akPu3PF); else if (jetAlgo=="ak3PF") anajet = &(c->ak3PF); else { cout << "Fatal Error: jetalgo " << jetAlgo << " not defined" << endl; exit(1); } // Output file cout << "Output: " << outname << endl; TFile *output = new TFile(outname,"recreate"); EvtSel evt; DiJet gj; // TrkReso trkRes1(1.6); /////////////////////////////////////////////////// // Book Histograms /////////////////////////////////////////////////// // Tracking Corrections TrkCorrHisAna effMergedGeneral("Forest2_MergedGeneral",output,40,coll.Data()); effMergedGeneral.DeclareHistograms(); TrkCorrHisAna effMergedGeneral_j1("Forest2_MergedGeneral_j1",output,40,coll.Data()); effMergedGeneral_j1.DeclareHistograms(); TrkCorrHisAna effMergedGeneral_j2("Forest2_MergedGeneral_j2",output,40,coll.Data()); effMergedGeneral_j2.DeclareHistograms(); TrkCorrHisAna effMergedGeneral_jetfine("Forest2_MergedGeneral_jetfine",output,40,coll.Data()); effMergedGeneral_jetfine.jetBins.clear(); // float fineJetBins[10] = {0,40,80,100,120,160,200,250,500,1000}; float fineJetBins[] = {0,40, 60, 80,100, 120, 160, 200, 300, 500, 1000}; effMergedGeneral_jetfine.jetBins.insert(effMergedGeneral_jetfine.jetBins.begin(),fineJetBins,fineJetBins+9); effMergedGeneral_jetfine.DeclareHistograms(); // basics output->cd(); TH1D * hCent = new TH1D("hCent","",100,0,100); TH1D * hVz = new TH1D("hVz","",60,-30,30); TH1D * hPtHatBeforeSel = new TH1D("hPtHatBeforeSel","",200,0,1000); TH1D * hPtHat = new TH1D("hPtHat","",200,0,1000); TH2D * hJetPt2D = new TH2D("hJetPt2D","",100,0,500,100,0,500); TH1D * hJDPhi = new TH1D("hJDPhi","",40,0,Pi()); TH1D * hAj = new TH1D("hAj","",32,0,0.8); // In separate centrality bins vector<TH1D*> vhCent; vector<TH1D*> vhPtHat; vector<TH1D*> vhPtHatBeforeSel; vector<TH2D*> vhJetPt2D; for (int ib=0; ib<(Int_t)effMergedGeneral.centBins.size()-1; ++ib) { vhCent.push_back(new TH1D(Form("hCent_c%d",ib), // Form("cbin%dto%d;Centrality Bin;",effMergedGeneral.centBins[ib],effMergedGeneral.centBins[ib+1]),40,0,40)); Form("cbin%dto%d;Centrality Bin;",effMergedGeneral.centBins[ib],effMergedGeneral.centBins[ib+1]),100,0,100)); vhPtHat.push_back(new TH1D(Form("hPtHat_c%d",ib),"",200,0,1000)); vhPtHatBeforeSel.push_back(new TH1D(Form("hPtHatBeforeSel_c%d",ib),"",200,0,1000)); vhJetPt2D.push_back(new TH2D(Form("hJetPt2D_c%d",ib),"",100,0,500,100,0,500)); } /////////////////////////////////////////////////// // Main loop /////////////////////////////////////////////////// if (maxEntries<0) maxEntries = c->GetEntries(); for (int i=0;i<maxEntries;i++) { c->GetEntry(i); evt.cBin = c->evt.hiBin; evt.evtPlane = c->evt.hiEvtPlanes[21]; evt.nJ = anajet->nref; evt.nT = c->track.nTrk; evt.offlSel = (c->skim.pcollisionEventSelection > 0); if (!c->hasSkimTree) evt.offlSel = (c->evt.hiNtracks>0 && c->evt.hiHFplus>=4 && c->evt.hiHFminus>=4); evt.vz = c->track.vz[1]; // evt.sampleWeight = sampleWeight/maxEntries; // for different mc sample, 1 for data sampleWeight = xsection/(maxEntries/100000.); evt.sampleWeight = sampleWeight; // for different mc sample, 1 for data evt.pthat = anajet->pthat; evt.samplePtHat = samplePtHat; if (i%1000==0) cout <<i<<" / "<< maxEntries << " pthat: " << evt.pthat << " cBin: " << evt.cBin << " nT: " << evt.nT <<endl; // initialize int leadingIndex=-1,genLeadingIndex=-1; int awayIndex=-1,genAwayIndex=-1; gj.clear(); /////////////////////////////////////////////////////// // Find Leading jets /////////////////////////////////////////////////////// for (int j=0;j<anajet->nref;j++) { if (anajet->jtpt[j]<cutjetPt) continue; if (fabs(anajet->jteta[j])>cutjetEta) continue; if(anajet->trackMax[j]/anajet->jtpt[j] <=0.01) continue ; if (anajet->jtpt[j] > gj.pt1) { gj.pt1 = anajet->jtpt[j]; leadingIndex = j; } } // Found a leading jet which passed basic quality cut! if (leadingIndex!=-1) { // set leading jet gj.pt1raw=anajet->rawpt[leadingIndex]; gj.eta1=anajet->jteta[leadingIndex]; gj.phi1=anajet->jtphi[leadingIndex]; gj.ref1pt = anajet->refpt[leadingIndex]; gj.ref1eta = anajet->refeta[leadingIndex]; gj.ref1phi = anajet->refphi[leadingIndex]; gj.ref1partonpt = anajet->refparton_pt[leadingIndex]; gj.ref1partonflavor = anajet->refparton_flavor[leadingIndex]; // Loop over jet tree to find a away side leading jet gj.nJet=0; for (int j=0;j<anajet->nref;j++) { if (anajet->jtpt[j]<cutjetPt) continue; if (fabs(anajet->jteta[j])>cutjetEta) continue; if(anajet->trackMax[j]/anajet->jtpt[j] <=0.01) continue ; gj.inclJetPt[gj.nJet] = anajet->jtpt[j]; gj.inclJetEta[gj.nJet] = anajet->jteta[j]; gj.inclJetPhi[gj.nJet] = anajet->jtphi[j]; gj.inclJetRefPt[gj.nJet] = anajet->refpt[j]; gj.inclJetRefPartonPt[gj.nJet] = anajet->refparton_pt[j]; if (j!=leadingIndex&&anajet->jtpt[j] > gj.pt2) { gj.pt2 = anajet->jtpt[j]; awayIndex = j; } ++gj.nJet; } if (awayIndex !=-1) { // Found an away jet! gj.pt2raw = anajet->rawpt[awayIndex]; gj.eta2 = anajet->jteta[awayIndex]; gj.phi2 = anajet->jtphi[awayIndex]; gj.deta = gj.eta2 - gj.eta1; gj.dphi = deltaPhi(gj.phi2,gj.phi1); gj.Aj = (gj.pt1-gj.pt2)/(gj.pt1+gj.pt2); gj.ref2pt = anajet->refpt[awayIndex]; gj.ref2eta = anajet->refeta[awayIndex]; gj.ref2phi = anajet->refphi[awayIndex]; gj.ref2partonpt = anajet->refparton_pt[awayIndex]; gj.ref2partonflavor = anajet->refparton_flavor[awayIndex]; } } // end of if leadingIndex //////////////////////////////////////// // Find Leading Genjets //////////////////////////////////////// // Loop over genjets to look for leading genjet candidate in the event for (int j=0;j<anajet->ngen;j++) { if (anajet->genpt[j]<cutjetPt) continue; if (fabs(anajet->geneta[j])>cutjetEta) continue; if (anajet->genpt[j] > gj.genjetpt1) { gj.genjetpt1=anajet->genpt[j]; genLeadingIndex=j; } } if (genLeadingIndex!=-1) { gj.genjeteta1=anajet->geneta[genLeadingIndex]; gj.genjetphi1=anajet->genphi[genLeadingIndex]; } // subleading gj.nGenJet=0; for (int j=0;j<anajet->ngen;j++) { if (anajet->genpt[j]<cutjetPt) continue; if (fabs(anajet->geneta[j])>cutjetEta) continue; gj.inclGenJetPt[gj.nGenJet] = anajet->genpt[j]; gj.inclGenJetEta[gj.nGenJet] = anajet->geneta[j]; gj.inclGenJetPhi[gj.nGenJet] = anajet->genphi[j]; if (j!=genLeadingIndex && anajet->genpt[j]>gj.genjetpt2) { gj.genjetpt2=anajet->genpt[j]; gj.genjeteta2=anajet->geneta[j]; gj.genjetphi2=anajet->genphi[j]; } ++gj.nGenJet; } if (genJetMode) { gj.pt1 = gj.genjetpt1; gj.eta1 = gj.genjeteta1; gj.phi1 = gj.genjetphi1; gj.pt2 = gj.genjetpt2; gj.eta2 = gj.genjeteta2; gj.phi2 = gj.genjetphi2; gj.dphi = deltaPhi(gj.phi2,gj.phi1); } /////////////////////////////////////////////////////// // Skim /////////////////////////////////////////////////////// if (!evt.offlSel) continue; // if (samplePtHat>0 && evt.pthat>=ptHatMax) continue; if (evt.pthat>=ptHatMax) continue; if (vzMax>0 && fabs(evt.vz)>vzMax) continue; // protection against high pt jet from background event if (leadingIndex>=0&&anajet->subid[leadingIndex]>0) continue; hPtHatBeforeSel->Fill(evt.pthat); for (int ib=0; ib<(Int_t)effMergedGeneral.centBins.size(); ++ib) { if(evt.cBin>=effMergedGeneral.centBins[ib] && evt.cBin<effMergedGeneral.centBins[ib+1]){ vhPtHatBeforeSel[ib]->Fill(evt.pthat); } } // ensure jet distribution unbiased by pthat turn on if (leadingJetPtMin>0&&gj.pt1<leadingJetPtMin) continue; if (subleadingJetPtMin>0&&gj.pt2<subleadingJetPtMin) continue; if (sigDPhi>0&&fabs(gj.dphi)<sigDPhi) continue; // Fill Baisc Event info hCent->Fill(evt.cBin); hVz->Fill(evt.vz); hPtHat->Fill(evt.pthat); hJetPt2D->Fill(gj.pt1,gj.pt2); hJDPhi->Fill(fabs(gj.dphi)); hAj->Fill(gj.Aj); for (int ib=0; ib<(Int_t)effMergedGeneral.centBins.size(); ++ib) { if(evt.cBin>=effMergedGeneral.centBins[ib] && evt.cBin<effMergedGeneral.centBins[ib+1]){ vhCent[ib]->Fill(evt.cBin); vhPtHat[ib]->Fill(evt.pthat); vhJetPt2D[ib]->Fill(gj.pt1,gj.pt2); } } /////////////////////////////////////////////////////// // Tracks /////////////////////////////////////////////////////// // Full Tracks, Pixel Tracks Tracks * anaTrks[1] = {&(c->track)}; for (int it=0; it<anaTrks[0]->nTrk; ++it) { // Kinematic Selection if (anaTrks[0]->trkPt[it] < cutPtTrk) continue; if (fabs(anaTrks[0]->trkEta[it]) > cutEtaTrk) continue; // if (anaTrks[0]->trkAlgo[it]>=4&&!anaTrks[0]->highPurity[it]) continue; // quality selection if (!anaTrks[0]->highPurity[it]) continue; // quality selection if(anaTrks[0]->trkPtError[it]/anaTrks[0]->trkPt[it]>=0.1 || TMath::Abs(anaTrks[0]->trkDz1[it]/anaTrks[0]->trkDzError1[it])>=3.0 || TMath::Abs(anaTrks[0]->trkDxy1[it]/anaTrks[0]->trkDxyError1[it])>=3.0) continue ; //ridge cut for tracks RecTrack_t r; r.ptr = anaTrks[0]->trkPt[it]; r.etar = anaTrks[0]->trkEta[it]; r.phir = anaTrks[0]->trkPhi[it]; r.algo = anaTrks[0]->trkAlgo[it]; r.nsim = !anaTrks[0]->trkFake[it]; r.status = 1; // for now correct all tracks float dr1 = deltaR(r.etar,r.phir,gj.eta1,gj.phi1); float dr2 = deltaR(r.etar,r.phir,gj.eta2,gj.phi2); r.jet = 0; r.jeta = -99; r.jdr = -99; if (samplePtHat>0) { if (dr1<0.5&&gj.pt1>=40) { r.jet = gj.pt1; r.jeta = gj.eta1; r.jdr = dr1; effMergedGeneral_j1.FillRecHistograms(evt,gj,r); } else if (dr2<0.5&&gj.pt2>=40) { r.jet = gj.pt2; r.jeta = gj.eta2; r.jdr = dr2; effMergedGeneral_j2.FillRecHistograms(evt,gj,r); } } // Fill effMergedGeneral.FillRecHistograms(evt,gj,r); effMergedGeneral_jetfine.FillRecHistograms(evt,gj,r); // effMergedGeneral_trkPhi.FillRecHistograms(evt,gj,r); // if (r.jet>=120) effMergedGeneral_trkPhi_jet_120to999.FillRecHistograms(evt,gj,r); // else if (r.jet>=cutjetPt) effMergedGeneral_trkPhi_jet_50to120.FillRecHistograms(evt,gj,r); // else effMergedGeneral_trkPhi_noJet.FillRecHistograms(evt,gj,r); // effMergedGeneral_SimSmear.FillRecHistograms(evt,gj,r); } /////////////////////////////////////////////////////// // SimTracks /////////////////////////////////////////////////////// for (int ip=0; ip<anaTrks[0]->nParticle; ++ip) { if (anaTrks[0]->pPt[ip] < cutPtTrk) continue; if (fabs(anaTrks[0]->pEta[ip]) > cutEtaTrk) continue; SimTrack_t s; s.pts = anaTrks[0]->pPt[ip]; s.etas = anaTrks[0]->pEta[ip]; s.phis = anaTrks[0]->pPhi[ip]; s.status = 1; // for now assume all simtracks as signal tracks // s.nrec = (anaTrks[0]->pNRec[ip])*(int)(anaTrks[0]->mtrkAlgo[ip]<4||anaTrks[0]->mtrkQual[ip]>0); // s.nrec = (anaTrks[0]->pNRec[ip])*(int)(anaTrks[0]->mtrkAlgo[ip]<4||anaTrks[0]->mtrkQual[ip]>0)*(anaTrks[0]->mtrkPtError[ip]/anaTrks[0]->mtrkPt[ip]<0.1 && anaTrks[0]->mtrkDz1[ip]/anaTrks[0]->mtrkDzError1[ip]<3.0 && anaTrks[0]->mtrkDxy1[ip]/anaTrks[0]->mtrkDxyError1[ip]<3.0); s.nrec = (anaTrks[0]->pNRec[ip])*(int)(anaTrks[0]->mtrkQual[ip]>0)*(anaTrks[0]->mtrkPtError[ip]/anaTrks[0]->mtrkPt[ip]<0.1 && TMath::Abs(anaTrks[0]->mtrkDz1[ip]/anaTrks[0]->mtrkDzError1[ip])<3.0 && TMath::Abs(anaTrks[0]->mtrkDxy1[ip]/anaTrks[0]->mtrkDxyError1[ip])<3.0); // s.nrec = (int)(anaTrks[0]->mtrkAlgo[ip]<4||anaTrks[0]->mtrkQual[ip]>0)*(anaTrks[0]->mtrkPtError[ip]/anaTrks[0]->mtrkPt[ip]<0.1 && TMath::Abs(anaTrks[0]->mtrkDz1[ip]/anaTrks[0]->mtrkDzError1[ip])<3.0 && TMath::Abs(anaTrks[0]->mtrkDxy1[ip]/anaTrks[0]->mtrkDxyError1[ip])<3.0); // if (s.pts<1.5) s.nrec = anaTrks[0]->pNRec[ip]; // else s.nrec = (anaTrks[0]->pNRec[ip])*(anaTrks[0]->mtrkQual[ip]); s.acc = anaTrks[0]->pAcc[ip]; s.jet = gj.pt1; s.jeta = gj.eta1; float dr1 = deltaR(s.etas,s.phis,gj.eta1,gj.phi1); float dr2 = deltaR(s.etas,s.phis,gj.eta2,gj.phi2); s.jet = 0; s.jeta = -99; s.jdr = -99; if (samplePtHat>0) { if (dr1<0.5&&gj.pt1>=40) { s.jet = gj.pt1; s.jeta = gj.eta1; s.jdr = dr1; effMergedGeneral_j1.FillSimHistograms(evt,gj,s); } else if (dr2<0.5&&gj.pt2>=40) { s.jet = gj.pt2; s.jeta = gj.eta2; s.jdr = dr2; effMergedGeneral_j2.FillSimHistograms(evt,gj,s); } } // Fill effMergedGeneral.FillSimHistograms(evt,gj,s); effMergedGeneral_jetfine.FillSimHistograms(evt,gj,s); // effMergedGeneral_trkPhi.FillSimHistograms(evt,gj,s); // if (s.jet>=120) effMergedGeneral_trkPhi_jet_120to999.FillSimHistograms(evt,gj,s); // else if (s.jet>=cutjetPt) effMergedGeneral_trkPhi_jet_50to120.FillSimHistograms(evt,gj,s); // else effMergedGeneral_trkPhi_noJet.FillSimHistograms(evt,gj,s); // Sim Smearing // if (s.pts>=1&&s.pts<2) { // float trksm = trkRes1.GetSmear(s.pts); // s.pts*=trksm; // } // effMergedGeneral_SimSmear.FillSimHistograms(evt,gj,s); } // All done } // effMergedGeneral.WriteHistograms(); output->Write(); output->Close(); delete c; }
// void sortforestCentVz(double etCut=40, char *infname = "/mnt/hadoop/cms/store/user/velicanu/forest/HiForestTrack_v3.root") // void sortforestCentVz(double etCut=40, char *infname = "/mnt/hadoop/cms/store/user/velicanu/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_998_1_rJ1.root") // void sortforestCentVz(double etCut=40, char *infname = "/net/hisrv0001/home/dav2105/hdir/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_1000_1_8wo.root") // void sortforestCentVz(double etCut=40, char *infname = "/net/hisrv0001/home/dav2105/hdir/HIHighPt/HIRun2011_hiHighPtTrack_PromptSkim_forest_v0/9902eec616cc8b0649a7a8bb69754615/HiForest_1001_1_TRm.root") void frankforestsort(int startline = 0) { //! Define the input and output file and HiForest string buffer; vector<string> listoffiles; int nlines = 0; // ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/jet80sortlist.txt"); ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/frankjet80sortlist.txt"); // ifstream infile("/net/hidsk0001/d00/scratch/dav2105/forest/jobsort/sortlist.txt"); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } cout<<" here"<<endl; HiForest *c = new HiForest(listoffiles[startline].data(),0,0,0,0,true); // c->SetOutputFile(Form("sortedHiForest_%d.root",startline)); TFile * outf = new TFile(Form("sortedHiForest_%d.root",startline),"recreate"); c->outf = outf; c->SetOutputFile("null",true); //! loop through all the events once to construct the cent,vz pair array we'll be sorting over cout << "Constructing the cent:vz pair array..." << endl; for (int i=0;i<c->GetEntries();i++) { c->GetEntry(i); pair<int,double> centvz; centvz.first = c->evt->hiBin; centvz.second = c->evt->vz; evtCentVz.push_back(centvz); if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl; // if (i > 1000) break; } //! Make the index array which will get sorted on first centrality int evtindecies[c->GetEntries()]; for (int i=0;i<c->GetEntries();i++) { evtindecies[i] = i; // if (i > 1000) break; // cout << "In original loop | " << evtindecies[i] << " : (" << evtCentVz[evtindecies[i]].first <<" , "<<evtCentVz[evtindecies[i]].second << endl; } cout << "Sorting the cent:vz pair array..." << " "<<c->setupOutput<<endl; //! Sort the index array first on the centrality bin, then on the vz of the entry at that index qsort (evtindecies, c->GetEntries(), sizeof(int), comparecentvz); // qsort (evtindecies, 1000, sizeof(int), comparecentvz); //! Now fill the tree in the new order cout << "Filling the tree in the sorted order..." << " "<<c->setupOutput<<endl; for (int i=0;i<c->GetEntries();i++) { c->GetEntry(evtindecies[i]); c->FillOutput(); // cout << "In fill loop | " << evtindecies[i] << " : (" << evtCentVz[evtindecies[i]].first <<" , "<<evtCentVz[evtindecies[i]].second << endl; if (i%1000==0) cout <<i<<" / "<<c->GetEntries()<<" "<<c->setupOutput<<endl; // if (i > 1000) break; } delete c; }
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); }