void EventCollection::Loop() { // In a ROOT session, you can do: // root> .L EventCollection.C // root> EventCollection t // root> t.GetEntry(12); // Fill t data members with entry number 12 // root> t.Show(); // Show values of entry 12 // root> t.Show(16); // Read and show values of entry 16 // root> t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; } }
void AnalysisBase::getTDC(){ TProfile *hb = new TProfile("hb","Cluster Charge vs TDC time",12,0,12,100,1000); Long64_t nentries = fChain->GetEntriesFast(); float lo = 0, hi = 0; int istrip; Long64_t nbytes = 0, nb = 0; std::cout << "============================================" << std::endl; std::cout << "getTDC(): Determining Optimal TDC time range" << std::endl; std::cout << "============================================" << std::endl; for (Long64_t jentry=0; jentry<max(50000,(int)nentries);jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; for(int j=0; j<min((int)clusterNumberPerEvent,10); j++){ //std::cout << "j: " << ", clustersTDC: " << clustersTDC << ", clustersCharge[j]: " << clustersCharge[j] << ", clustersPosition[j]: " << clustersPosition[j] << std::endl; istrip = clustersSeedPosition[j]; if(badStrips[istrip]==0) continue; // exclude bad strips if(clustersPosition[j] < 0.1) continue; if(polarity*clustersCharge[j] < kClusterChargeMin) continue; if(clustersPosition[j]>=iLo && clustersPosition[j]<=iHi && clustersTDC>1.0 && polarity*clustersCharge[j]>150 && polarity*clustersCharge[j]<500) hb->Fill(clustersTDC+0.1,polarity*clustersCharge[j]); } } getTDCBins(hb,lo,hi); tdcLo = lo; tdcHi = hi; std::cout << "====> TDC Range determined to be from " << tdcLo << " -- " << tdcHi << std::endl; hb->Draw(); //delete hb; return; }
void H_bb::Loop() { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TH1F *pt_pt = new TH1F("shist10724" , "BJet: pTbjet/pTbquark HP", 100, 0, 2 ); TH1F *rec_mass = new TH1F("shist12751" , "BJet: Higgs mass from bjets", 100, 0, 200 ); TH1F *gen_mass = new TH1F("shist12761" , "BJet: Higgs mass from bquarks HP", 100, 122, 128 ); vector<float> pt_1; vector<float> pt_2; vector<float> eta_1; vector<float> eta_2; vector<float> phi_1; vector<float> phi_2; vector<float> r; float m = 0, E_sum = 0, px_sum = 0, py_sum = 0, pz_sum = 0, pt_0 = 0, pt_a = 0, pt_b = 0, eta_a = 0, eta_b = 0, phi_a = 0, r_a = 0, factor = 0, qualified = 0, b1 = 0, b2 = 0, b3 = 0, x1 = 0, x2 = 0; Long64_t gen_pho_event = 0, gen_pho = 0, rec_pho = 0, selected = 0; for (Long64_t jentry = 0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; GetEntry(jentry); m = 0; E_sum = 0; px_sum = 0; py_sum = 0; pz_sum = 0; gen_pho_event = 0; pt_1.clear(); pt_2.clear(); eta_1.clear(); eta_2.clear(); phi_1.clear(); phi_2.clear(); r.clear(); phi_a = 0; eta_1 = 0; pt_a = 0; for (Long64_t kentry = 0; kentry < part_pdgId->size(); kentry++){ if( (part_pdgId->at(kentry) == 5 || part_pdgId->at(kentry) == -5) && part_mother_pdgId->at(kentry) == 25 ){ factor = 1.0; E_sum += part_E->at(kentry); px_sum += part_px->at(kentry); py_sum += part_py->at(kentry); pz_sum += part_pz->at(kentry); pt_a = sqrt(pow(part_px->at(kentry),2)+pow(part_py->at(kentry),2)); if ( part_pz->at(kentry) < 0 ) factor = -1.0; eta_a = log( (sqrt(pow(pt_a,2)+pow(part_pz->at(kentry),2)) + (factor * part_pz->at(kentry))) / pt_a) * factor; phi_a = TMath::ASinH( (part_py->at(kentry)) / pt_a ); pt_1.push_back(pt_a); eta_1.push_back(eta_a); phi_1.push_back(phi_a); gen_pho_event++; } } if (gen_pho_event == 2) { m = sqrt(E_sum*E_sum - px_sum*px_sum - py_sum*py_sum - pz_sum*pz_sum); pt_0 = sqrt(pow(px_sum,2)+pow(py_sum,2)); gen_mass->Fill(m); } gen_pho += gen_pho_event; rec_pho += pho_n; E_sum = 0; px_sum = 0; py_sum = 0; pz_sum = 0; qualified = 0; for( Long64_t zentry = 0; zentry < jet_n; zentry++ ){ if (jet_pdgId->at(zentry) == 5 || jet_pdgId->at(zentry)== -5){ qualified++; factor = 1; E_sum += jet_E->at(zentry); px_sum += jet_px->at(zentry); py_sum += jet_py->at(zentry); pz_sum += jet_pz->at(zentry); pt_a = sqrt(pow(jet_px->at(zentry),2)+pow(jet_py->at(zentry),2)); if ( jet_pz->at(zentry) < 0 ) factor = -1.0; eta_a = log( (sqrt(pow(pt_a,2)+pow(jet_pz->at(zentry),2)) + (factor * jet_pz->at(zentry))) / pt_a) * factor; phi_a = TMath::ASinH( (jet_py->at(zentry)) / pt_a ); pt_2.push_back(pt_a); eta_2.push_back(eta_a); phi_2.push_back(phi_a); } } if ( qualified == 2 ){ m = sqrt(E_sum*E_sum - px_sum*px_sum - py_sum*py_sum - pz_sum*pz_sum); rec_mass->Fill(m); } b1 = 0; b2 = 0; b3 = 0; if( eta_1.size() == 2 && eta_2.size() == 2 ){ for ( Long64_t count1 = 0; count1<2; count1++ ){ for ( Long64_t count2 = 0; count2<2; count2++ ){ r_a = sqrt(pow(phi_1.at(count1)-phi_2.at(count2),2)+pow(eta_1.at(count1)-eta_2.at(count2),2)); r.push_back(r_a); } } if ( r.at(0) > r.at(1) ) b1 = 1; if ( r.at(2) > r.at(3) ) b2 = 1; if ( r.at(b1) > r.at(2+b2) ) b3 = 1; x2 = b3; x1 = (b3 * b2) + ((1-b3)*b1); if ( r.at( 2*x2 + x1 ) < 0.4 ){ pt_pt->Fill ( pt_2.at(x1)/pt_1.at(x2) ); } if ( r.at( 2*(1-x2) + (1-x1) ) < 0.4 ){ pt_pt->Fill ( pt_2.at(1-x1)/pt_1.at(1-x2) ); } } } }
void debugCount::Loop() { cout << "here version 2" << endl; if (fChain == 0) return; cout << "there" << endl; Long64_t nentries = fChain->GetEntriesFast(); cout << "There are " << nentries << " entries" << endl; // declare and define histograms TH1F* h_dec = new TH1F("h_dec","",2,fEtaBin); TH1F* h_dR = new TH1F("h_dR","",100,0,5); // pt distribution TH1F* h_pt_template = new TH1F("h_pt_template","",500,0,500); TH1F* h_pt_dirgamma = (TH1F*) h_pt_template->Clone("h_pt_dirgamma"); TH1F* h_pt_1stjet = (TH1F*) h_pt_template->Clone("h_pt_1stjet"); TH1F* h_pt_2ndjet = (TH1F*) h_pt_template->Clone("h_pt_2ndjet"); // rapidity distribution TH1F* h_y_template = new TH1F("h_y_template","",100,-5,5); TH1F* h_y_dirgamma = (TH1F*) h_y_template->Clone("h_y_dirgamma"); TH1F* h_y_1stjet = (TH1F*) h_y_template->Clone("h_y_1stjet"); TH1F* h_y_2ndjet = (TH1F*) h_y_template->Clone("h_y_2ndjet"); Long64_t nPass[30]={0}; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; // if(jentry>50000)break; nPass[0] ++; Int_t TriggerHLT75 = HLTIndex[30]; if(TriggerHLT75 > 0 && HLT[TriggerHLT75]>0) nPass[1]++; else continue; Int_t ngood_vtx=IsVtxGood; if(ngood_vtx==0)continue; nPass[2] ++; bool findLeadingPhoton = false; int leadingPhotonIndex = -1; Float_t phoMaxPt = -9999.; // now find a good leading photon for(int ipho=0; ipho < nPho; ipho++){ if(!isGoodPho(ientry,ipho))continue; h_pt_dirgamma->Fill(phoEt[ipho]); h_y_dirgamma ->Fill(phoSCEta[ipho]); if(phoEt[ipho] > phoMaxPt) { phoMaxPt = phoEt[ipho]; leadingPhotonIndex= ipho; findLeadingPhoton = true; } } // end of leading photon search if(!findLeadingPhoton)continue; nPass[3]++; TLorentzVector l4_pho(0,0,0,0); l4_pho.SetPtEtaPhiE( phoEt[leadingPhotonIndex], phoEta[leadingPhotonIndex], phoPhi[leadingPhotonIndex], phoE[leadingPhotonIndex] ); Float_t leadingPhotonEt = phoEt[leadingPhotonIndex]; // first check which reco jet is the one from the highest and // second et gen jet bool findLeadingJet = false; Int_t leadingJetIndex=-1; Float_t jetMaxPt=-9999.; bool findSecondLeadingJet = false; Int_t secondLeadingJetIndex=-1; Float_t secondJetMaxPt=-9999.; for(int ijet=0; ijet < nJet; ijet++){ TLorentzVector l4_tempjet(0,0,0,0); l4_tempjet.SetPtEtaPhiE( jetPt[ijet], jetEta[ijet], jetPhi[ijet], jetEn[ijet] ); Float_t dR = l4_tempjet.DeltaR(l4_pho); h_dR->Fill(dR); if(dR<0.5)continue; if(!isGoodLooseJet(ientry,ijet))continue; if(jetPt[ijet] > jetMaxPt) { secondJetMaxPt = jetMaxPt; secondLeadingJetIndex = leadingJetIndex; jetMaxPt = jetPt[ijet]; leadingJetIndex= ijet; } else if(jetPt[ijet] > secondJetMaxPt) { secondJetMaxPt = jetPt[ijet]; secondLeadingJetIndex = ijet; } } // end of loop over jets // only study if(leadingJetIndex >=0 ) findLeadingJet = true; if(secondLeadingJetIndex >=0 ) findSecondLeadingJet = true; TLorentzVector l4_1stjet(0,0,0,0); if(findLeadingJet) { nPass[4]++; l4_1stjet.SetPtEtaPhiE( jetPt[leadingJetIndex], jetEta[leadingJetIndex], jetPhi[leadingJetIndex], jetEn[leadingJetIndex] ); h_y_1stjet->Fill(l4_1stjet.Rapidity()); h_pt_1stjet->Fill(l4_1stjet.Pt()); } TLorentzVector l4_2ndjet(0,0,0,0); if(findSecondLeadingJet) { l4_2ndjet.SetPtEtaPhiE( jetPt[secondLeadingJetIndex], jetEta[secondLeadingJetIndex], jetPhi[secondLeadingJetIndex], jetEn[secondLeadingJetIndex] ); h_y_2ndjet->Fill(l4_2ndjet.Rapidity()); h_pt_2ndjet->Fill(l4_2ndjet.Pt()); } if(!findLeadingPhoton || !findLeadingJet)continue; nPass[5]++; if(leadingPhotonEt >= 85 && leadingPhotonEt < 95)nPass[7]++; if(leadingPhotonEt >= 95 && leadingPhotonEt < 110)nPass[8]++; if(leadingPhotonEt >= 110 && leadingPhotonEt < 130)nPass[9]++; if(leadingPhotonEt >= 130 && leadingPhotonEt < 160)nPass[10]++; if(leadingPhotonEt >= 160 && leadingPhotonEt < 200)nPass[11]++; } // end of loop over entries for(int i=0; i<30; i++) if(nPass[i]>0) cout << "nPass["<< i << "]=" << nPass[i] << endl; TFile* outFile = new TFile("/home/syu/CVSCode/test.root", "recreate"); h_y_dirgamma -> Write(); h_y_1stjet -> Write(); h_y_2ndjet -> Write(); h_pt_dirgamma -> Write(); h_pt_1stjet -> Write(); h_pt_2ndjet -> Write(); h_dR -> Write(); outFile->Close(); }
void ks_efficiency::Loop(int weight_choice) { // In a ROOT session, you can do: // Root > .L ks_efficiency.C // Root > ks_efficiency t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch const Double_t ksMassConst = 0.497614; const Double_t ksMassConst2 = ksMassConst * ksMassConst; int trk_weight_choice, kin_weight_choice; if ( weight_choice >= 100 ) { trk_weight_choice = weight_choice - 100; kin_weight_choice = trk_weight_choice; } else { trk_weight_choice = weight_choice; kin_weight_choice = 0; } if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); // HARDCODE to test //Long64_t nentries = 500000; double p, pt, y, life, mass, p2, pz, energy; // cout << "Check incoming values: " << ksEtaXmin << ", " << ksEtaBinWidth << ", " << ksptNbins << endl; cout << "nentries = " << nentries << endl; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; int ncand = (*ksv0MatchStatus).size(); veematch->Fill(ncand); double wgt = ntrk_wgt(nLooseTracks, trk_weight_choice); for ( int i = 0; i<ncand; i++ ) { if ( (*ksgenMass)[i] < 0.49763 ) continue; // Switching to rapidity //eta = fabs((*ksgenEta)[i]); //if (eta > 2.5) continue; p2 = ((*ksgenp)[i]) * ((*ksgenp)[i]); pt = (*ksgenpT)[i]; pz = sqrt( p2 - pt*pt ); energy = sqrt( p2 + ksMassConst2 ); y = 0.5*log((energy + pz) / (energy - pz)); if ( y > 2.3 ) continue; life = (*ksgenCtau)[i]; double y_wgt = kspt_wgt( pt, kin_weight_choice ); double pt_wgt = ksy_wgt( y, kin_weight_choice ); if (processType != 103 && processType != 104 ) { ks_dNdy_gen->Fill(y,wgt*y_wgt); ks_dNdpT_gen->Fill(pt,wgt*pt_wgt); ks_dNdlife_gen->Fill(life,wgt*y_wgt); } if ( (*ksv0MatchStatus)[i] != 1 ) continue; if ( !kstrigTech34 || !kstrigScraping || !kstrigTech40_41 || !kstrigTech36_39 || !trigHLTminBias || priVtxIsFake) continue; if ( fabs((*ks3dIpWrtPrimarySig)[i]) >= 3.0 ) continue; if ( fabs((*ksrecoOtherCandMass)[i]-1.115683)<0.0075 ) continue; if ( (*ksrecoVtxSig)[i] <= 10.0 ) continue; if ( (*ksrecoNegDauNormChi2)[i] < 0.0 || (*ksrecoPosDauNormChi2)[i] < 0.0 ) continue; //if ( fabs((*ksrecoEta)[i]) > 2.5 ) continue; p2 = ((*ksrecop)[i]) * ((*ksrecop)[i]); pt = (*ksrecopT)[i]; pz = (*ksrecopZ)[i]; energy = sqrt( p2 + ksMassConst2 ); y = fabs(0.5*log((energy + pz) / (energy - pz))); if( y > 2.3 ) continue; //eta = fabs((*ksrecoEta)[i]); life = (*ksrecoCtau)[i]; ks_dNdy_rec->Fill(y,wgt*y_wgt); ks_dNdpT_rec->Fill(pt,wgt*pt_wgt); ks_dNdlife_rec->Fill(life,wgt*y_wgt); } } }
void VHanalysis::Loop() { // In a ROOT session, you can do: // root> .L VHanalysis.C // root> VHanalysis t // root> t.GetEntry(12); // Fill t data members with entry number 12 // root> t.Show(); // Show values of entry 12 // root> t.Show(16); // Read and show values of entry 16 // root> t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; float px_0 = -2.104; float px_1 = -0.07336; float py_0 = 0.5667; float py_1 = -0.0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; float oldPx = pfMET_corPt*cos(pfMET_corPhi); float oldPy = pfMET_corPt*sin(pfMET_corPhi); //pxfit: //Chi2 = 2195.7 //NDf = 29 //p0 = -1.15382 +/- 0.476161 //p1 = -0.0613663 +/- 0.0037346 //pyfit //Chi2 = 22.2401 //NDf = 21 //p0 = 0.906762 +/- 0.688286 //p1 = -0.040754 +/- 0.0395147 pxOLD->Fill(pfMET_corSumEt,oldPx,weight); pyOLD->Fill(pfMET_corSumEt,oldPy,weight); float newPx = oldPx - (px_0 +px_1*pfMET_corSumEt); float newPy = oldPy - (py_0 +py_1*pfMET_corSumEt); //float newPy = oldPy - (1.71741 -0.0062300*pfMET_corSumEt); float newPhi=pfMET_corPhi; newPhi = atan(newPy/newPx); //px>0 if(newPx<0&&newPy<0) newPhi = -3.14159 + newPhi; else if(newPx<0&&newPy>=0) newPhi = 3.14159 + newPhi; px->Fill(pfMET_corSumEt, newPx,weight); py->Fill(pfMET_corSumEt, newPy,weight); phiOLD->Fill(pfMET_corPhi,weight); phiNEW->Fill(newPhi,weight); if(hasZ&&VhasNeutrinos) { pfCorrSig->Fill(pfMET_corPt,weight); DphiSig->Fill(fabs(pfMET_corPhi-phi),weight); } else { pfCorrBkg->Fill(pfMET_corPt,weight); DphiBkg->Fill(fabs(pfMET_corPhi-phi),weight); } // if (Cut(ientry) < 0) continue; } }
void L1Ntuple::prefiringHCAL() { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; //unsigned int nevents =0; std::cout << nentries << " events to process"<<std::endl; TFile *total=new TFile("total.root","RECREATE"); TDirectory *dir = total->mkdir("l1ExtraJets","Histograms for l1Extra Jet candidates; timing studies"); // Central Jets TH1D *ptJet_early=new TH1D("ptJet_early","",200,0.,400.); TH1D *ptJet_central=new TH1D("ptJet_central","",200,0.,400.); TH1D *ptJet_late=new TH1D("ptJet_late","",200,0.,400.); TH1D *etaJet_early=new TH1D("etaJet_early","",30,-3.,3.); TH1D *etaJet_central=new TH1D("etaJet_central","",30,-3.,3.); TH1D *etaJet_late=new TH1D("etaJet_late","",30,-3.,3.); // TH1D *etaJet_early=new TH1D("etaJet_early","",3000,-3.,3.); // TH1D *etaJet_central=new TH1D("etaJet_central","",3000,-3.,3.); // TH1D *etaJet_late=new TH1D("etaJet_late","",3000,-3.,3.); TH1D *phiJet_early=new TH1D("phiJet_early","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJet_central=new TH1D("phiJet_central","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJet_late=new TH1D("phiJet_late","",30,-TMath::Pi(),TMath::Pi()); // TH1D *phiJet_early=new TH1D("phiJet_early","",3000,-TMath::Pi(),TMath::Pi()); // TH1D *phiJet_central=new TH1D("phiJet_central","",3000,-TMath::Pi(),TMath::Pi()); // TH1D *phiJet_late=new TH1D("phiJet_late","",3000,-TMath::Pi(),TMath::Pi()); // Debugging plots TH1D *etaJet_early_H=new TH1D("etaJet_early_H","",30,-3.,3.); TH1D *etaJet_central_H=new TH1D("etaJet_central_H","",30,-3.,3.); TH1D *phiJet_early_H=new TH1D("phiJet_early_H","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJet_central_H=new TH1D("phiJet_central_H","",30,-TMath::Pi(),TMath::Pi()); // HCAL TPs TH1D *ietaTP_H=new TH1D("ietaTP_H","",69,-34.5,34.5); TH1D *iphiTP_H=new TH1D("iphiTP_H","",77,-0.5,76.5); TH2D *ietaTP_iphiTP_H=new TH2D("ietaTP_iphiTP_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_H=new TH2D("ietaJet_iphiJet_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_central_H=new TH2D("ietaJet_iphiJet_central_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaTP_iphiTP_H_2=new TH2D("ietaTP_iphiTP_H_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *ietaTP_iphiTP_etTP_H=new TH3D("ietaTP_iphiTP_etTP_H","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *etTP_H=new TH1D("etTP_H","",500,0.,50.); TH1D *compEtTP_H=new TH1D("compEtTP_H","",1500,0.,150.); // ECAL TPs TH1D *e_ietaTP_H=new TH1D("e_ietaTP_H","",69,-34.5,34.5); TH1D *e_iphiTP_H=new TH1D("e_iphiTP_H","",77,-0.5,76.5); TH2D *e_ietaTP_iphiTP_H=new TH2D("e_ietaTP_iphiTP_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaJet_iphiJet_H=new TH2D("e_ietaJet_iphiJet_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaJet_iphiJet_central_H=new TH2D("e_ietaJet_iphiJet_central_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaTP_iphiTP_H_2=new TH2D("e_ietaTP_iphiTP_H_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *e_ietaTP_iphiTP_etTP_H=new TH3D("e_ietaTP_iphiTP_etTP_H","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *e_etTP_H=new TH1D("e_etTP_H","",500,0.,50.); TH1D *e_compEtTP_H=new TH1D("e_compEtTP_H","",1500,0.,150.); TH2D *ietaJet_iphiJet=new TH2D("ietaJet_iphiJet","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_central=new TH2D("ietaJet_iphiJet_central","",69,-34.5,34.5,77,-0.5,76.5); // HCAL TPs TH1D *ietaTP_Hs=new TH1D("ietaTP_Hs","",69,-34.5,34.5); TH1D *iphiTP_Hs=new TH1D("iphiTP_Hs","",77,-0.5,76.5); TH2D *ietaTP_iphiTP_Hs=new TH2D("ietaTP_iphiTP_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_Hs=new TH2D("ietaJet_iphiJet_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_central_Hs=new TH2D("ietaJet_iphiJet_central_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaTP_iphiTP_Hs_2=new TH2D("ietaTP_iphiTP_Hs_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *ietaTP_iphiTP_etTP_Hs=new TH3D("ietaTP_iphiTP_etTP_Hs","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *etTP_Hs=new TH1D("etTP_Hs","",500,0.,50.); TH1D *compEtTP_Hs=new TH1D("compEtTP_Hs","",1500,0.,150.); // ECAL TPs TH1D *e_ietaTP_Hs=new TH1D("e_ietaTP_Hs","",69,-34.5,34.5); TH1D *e_iphiTP_Hs=new TH1D("e_iphiTP_Hs","",77,-0.5,76.5); TH2D *e_ietaTP_iphiTP_Hs=new TH2D("e_ietaTP_iphiTP_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaJet_iphiJet_Hs=new TH2D("e_ietaJet_iphiJet_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaJet_iphiJet_central_Hs=new TH2D("e_ietaJet_iphiJet_central_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaTP_iphiTP_Hs_2=new TH2D("e_ietaTP_iphiTP_Hs_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *e_ietaTP_iphiTP_etTP_Hs=new TH3D("e_ietaTP_iphiTP_etTP_Hs","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *e_etTP_Hs=new TH1D("e_etTP_Hs","",500,0.,50.); TH1D *e_compEtTP_Hs=new TH1D("e_compEtTP_Hs","",1500,0.,150.); // HCAL TPs TH1D *ietaTP=new TH1D("ietaTP","",69,-34.5,34.5); TH1D *iphiTP=new TH1D("iphiTP","",77,-0.5,76.5); TH2D *ietaTP_iphiTP=new TH2D("ietaTP_iphiTP","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaTP_iphiTP_2=new TH2D("ietaTP_iphiTP_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *ietaTP_iphiTP_etTP=new TH3D("ietaTP_iphiTP_etTP","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *etTP=new TH1D("etTP","",500,0.,50.); TH1D *compEtTP=new TH1D("compEtTP","",1500,0.,150.); // ECAL TPs TH1D *e_ietaTP=new TH1D("e_ietaTP","",69,-34.5,34.5); TH1D *e_iphiTP=new TH1D("e_iphiTP","",77,-0.5,76.5); TH2D *e_ietaTP_iphiTP=new TH2D("e_ietaTP_iphiTP","",69,-34.5,34.5,77,-0.5,76.5); TH2D *e_ietaTP_iphiTP_2=new TH2D("e_ietaTP_iphiTP_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *e_ietaTP_iphiTP_etTP=new TH3D("e_ietaTP_iphiTP_etTP","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *e_etTP=new TH1D("e_etTP","",500,0.,50.); TH1D *e_compEtTP=new TH1D("e_compEtTP","",1500,0.,150.); // HFJets TH1D *ptJetHF_early=new TH1D("ptJetHF_early","",200,0.,400.); TH1D *ptJetHF_central=new TH1D("ptJetHF_central","",200,0.,400.); TH1D *ptJetHF_late=new TH1D("ptJetHF_late","",200,0.,400.); TH1D *etaJetHF_early=new TH1D("etaJetHF_early","",50,-5.,5.); TH1D *etaJetHF_central=new TH1D("etaJetHF_central","",50,-5.,5.); TH1D *etaJetHF_late=new TH1D("etaJetHF_late","",50,-5.,5.); TH1D *phiJetHF_early=new TH1D("phiJetHF_early","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJetHF_central=new TH1D("phiJetHF_central","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJetHF_late=new TH1D("phiJetHF_late","",30,-TMath::Pi(),TMath::Pi()); // Debugging plots TH1D *etaJetHF_early_H=new TH1D("etaJetHF_early_H","",50,-5.,5.); TH1D *etaJetHF_central_H=new TH1D("etaJetHF_central_H","",50,-5.,5.); TH1D *phiJetHF_early_H=new TH1D("phiJetHF_early_H","",30,-TMath::Pi(),TMath::Pi()); TH1D *phiJetHF_central_H=new TH1D("phiJetHF_central_H","",30,-TMath::Pi(),TMath::Pi()); // HCAL TPs TH1D *ietaTP_hf_H=new TH1D("ietaTP_hf_H","",69,-34.5,34.5); TH1D *iphiTP_hf_H=new TH1D("iphiTP_hf_H","",77,-0.5,76.5); TH2D *ietaTP_iphiTP_hf_H=new TH2D("ietaTP_iphiTP_hf_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_hf_H=new TH2D("ietaJet_iphiJet_hf_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_hf_central_H=new TH2D("ietaJet_iphiJet_hf_central_H","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaTP_iphiTP_hf_H_2=new TH2D("ietaTP_iphiTP_hf_H_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *ietaTP_iphiTP_etTP_hf_H=new TH3D("ietaTP_iphiTP_etTP_hf_H","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *etTP_hf_H=new TH1D("etTP_hf_H","",500,0.,50.); TH1D *compEtTP_hf_H=new TH1D("compEtTP_hf_H","",1500,0.,150.); TH2D *ietaJet_iphiJet_hf=new TH2D("ietaJet_iphiJet_hf","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_hf_central=new TH2D("ietaJet_iphiJet_hf_central","",69,-34.5,34.5,77,-0.5,76.5); TH1D *ietaTP_hf_Hs=new TH1D("ietaTP_hf_Hs","",69,-34.5,34.5); TH1D *iphiTP_hf_Hs=new TH1D("iphiTP_hf_Hs","",77,-0.5,76.5); TH2D *ietaTP_iphiTP_hf_Hs=new TH2D("ietaTP_iphiTP_hf_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_hf_Hs=new TH2D("ietaJet_iphiJet_hf_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaJet_iphiJet_hf_central_Hs=new TH2D("ietaJet_iphiJet_hf_central_Hs","",69,-34.5,34.5,77,-0.5,76.5); TH2D *ietaTP_iphiTP_hf_Hs_2=new TH2D("ietaTP_iphiTP_hf_Hs_2","",69,-34.5,34.5,77,-0.5,76.5); TH3D *ietaTP_iphiTP_etTP_hf_Hs=new TH3D("ietaTP_iphiTP_etTP_hf_Hs","",69,-34.5,34.5,77,-0.5,76.5,500,0.,50.); TH1D *etTP_hf_Hs=new TH1D("etTP_hf_Hs","",500,0.,50.); TH1D *compEtTP_hf_Hs=new TH1D("compEtTP_hf_Hs","",1500,0.,150.); Int_t runPeak=0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(!(ientry%100000) && ientry) { std::cout << "processing event " << ientry << "\r" << std::endl; } // if (jentry!=2492259 && event_->run!=205666) continue; Int_t ie,ic,il; ie=ic=il=0; Int_t ie1,ic1,il1; ie1=ic1=il1=-1; // Write your code here // Loop over central Jets in l1extra for (Int_t i=0; i<l1extra_->nCenJets; i++) { // eaarly candidates if (l1extra_->cenJetBx[i]==-1 ) { ie++; if(ie>1) continue; ie1=i; } // central cadndidates if (l1extra_->cenJetBx[i]==0) { ic++; if (ic>1) continue; ic1=i; } // eaarly candidates if (l1extra_->cenJetBx[i]==1 ) { il++; if (il>1) continue; il1=i; } } // Run Analysis for L1Jets only that fall into the new PMTs detIds. // Double_t isUpgraded=-1.; Double_t yHBHE_early, yHBHE_central; yHBHE_early=yHBHE_central=-1.; // For debugging Double_t idH_early, idH_central; idH_early=idH_central=-1.; Double_t etaj_early, phij_early; Double_t etaj_central, phij_central; etaj_early=etaj_central=9999.; phij_early=phij_central=9999.; // Loop over tau Jets in l1extra ie=ic=il=0; for (Int_t i=0; i<l1extra_->nTauJets; i++) { // early candidates if (l1extra_->tauJetBx[i]==-1 ) { ie++; if (ie>1) continue; yHBHE_early=999.; if (ie1>=0) { if (l1extra_->tauJetEt[i]>=l1extra_->cenJetEt[ie1]) { ptJet_early->Fill(l1extra_->tauJetEt[i]); etaJet_early->Fill(l1extra_->tauJetEta[i]); phiJet_early->Fill(l1extra_->tauJetPhi[i]); etaj_early=l1extra_->tauJetEta[i]; phij_early=l1extra_->tauJetPhi[i]; // Debugging if (l1extra_->tauJetEt[i]>=240.) { etaJet_early_H->Fill(l1extra_->tauJetEta[i]); phiJet_early_H->Fill(l1extra_->tauJetPhi[i]); idH_early=999.; } } else { ptJet_early->Fill(l1extra_->cenJetEt[ie1]); etaJet_early->Fill(l1extra_->cenJetEta[ie1]); phiJet_early->Fill(l1extra_->cenJetPhi[ie1]); etaj_early=l1extra_->cenJetEta[ie1]; phij_early=l1extra_->cenJetPhi[ie1]; if (l1extra_->cenJetEt[ie1]>=240.) { etaJet_early_H->Fill(l1extra_->cenJetEta[ie1]); phiJet_early_H->Fill(l1extra_->cenJetPhi[ie1]); idH_early=999.; } } } else { ptJet_early->Fill(l1extra_->tauJetEt[i]); etaJet_early->Fill(l1extra_->tauJetEta[i]); phiJet_early->Fill(l1extra_->tauJetPhi[i]); etaj_early=l1extra_->tauJetEta[i]; phij_early=l1extra_->tauJetPhi[i]; if (l1extra_->tauJetEt[i]>=240.) { etaJet_early_H->Fill(l1extra_->tauJetEta[i]); phiJet_early_H->Fill(l1extra_->tauJetPhi[i]); idH_early=999.; } } } // central candidates if (l1extra_->tauJetBx[i]==0) { ic++; if (ic>1) continue; yHBHE_central=999.; if (ic1>=0) { if (l1extra_->tauJetEt[i]>=l1extra_->cenJetEt[ic1]) { ptJet_central->Fill(l1extra_->tauJetEt[i]); etaJet_central->Fill(l1extra_->tauJetEta[i]); phiJet_central->Fill(l1extra_->tauJetPhi[i]); etaj_central=l1extra_->tauJetEta[i]; phij_central=l1extra_->tauJetPhi[i]; if (l1extra_->tauJetEt[i]>=240.) { etaJet_central_H->Fill(l1extra_->tauJetEta[i]); phiJet_central_H->Fill(l1extra_->tauJetPhi[i]); idH_central=999.; } } else { ptJet_central->Fill(l1extra_->cenJetEt[ic1]); etaJet_central->Fill(l1extra_->cenJetEta[ic1]); phiJet_central->Fill(l1extra_->cenJetPhi[ic1]); etaj_central=l1extra_->cenJetEta[ic1]; phij_central=l1extra_->cenJetPhi[ic1]; if (l1extra_->cenJetEt[ie1]>=240.) { etaJet_central_H->Fill(l1extra_->cenJetEta[ie1]); phiJet_central_H->Fill(l1extra_->cenJetPhi[ie1]); idH_central=999.; } } } else { ptJet_central->Fill(l1extra_->tauJetEt[i]); etaJet_central->Fill(l1extra_->tauJetEta[i]); phiJet_central->Fill(l1extra_->tauJetPhi[i]); etaj_central=l1extra_->tauJetEta[i]; phij_central=l1extra_->tauJetPhi[i]; if (l1extra_->tauJetEt[i]>=240.) { etaJet_central_H->Fill(l1extra_->tauJetEta[i]); phiJet_central_H->Fill(l1extra_->tauJetPhi[i]); idH_central=999.; } } } // late candidates if (l1extra_->tauJetBx[i]==1 ) { il++; if (il>1) continue; if (il1>=0) { if (l1extra_->tauJetEt[i]>=l1extra_->cenJetEt[il1]) { ptJet_late->Fill(l1extra_->tauJetEt[i]); etaJet_late->Fill(l1extra_->tauJetEta[i]); phiJet_late->Fill(l1extra_->tauJetPhi[i]); } else { ptJet_late->Fill(l1extra_->cenJetEt[il1]); etaJet_late->Fill(l1extra_->cenJetEta[il1]); phiJet_late->Fill(l1extra_->cenJetPhi[il1]); } } else { ptJet_late->Fill(l1extra_->tauJetEt[i]); etaJet_late->Fill(l1extra_->tauJetEta[i]); phiJet_late->Fill(l1extra_->tauJetPhi[i]); } } } // All TP info for (Int_t j=0; j<caloTP_->nHCALTP; j++) { ietaTP->Fill(caloTP_->hcalTPieta[j]); iphiTP->Fill(caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_2->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); ietaTP_iphiTP_etTP->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); etTP->Fill(caloTP_->hcalTPet[j]); compEtTP->Fill(caloTP_->hcalTPcompEt[j]); } for (Int_t j=0; j<caloTP_->nECALTP; j++) { e_ietaTP->Fill(caloTP_->ecalTPieta[j]); e_iphiTP->Fill(caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP_2->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_ietaTP_iphiTP_etTP->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_etTP->Fill(caloTP_->ecalTPet[j]); e_compEtTP->Fill(caloTP_->ecalTPcompEt[j]); } // ieta/iphi of BX=-1 and BX=0 L1Jets if (etaj_early<9999.) { ietaJet_iphiJet->Fill(ietaBin(etaj_early),iphiBin(phij_early)); } if (etaj_central<9999.) { ietaJet_iphiJet_central->Fill(ietaBin(etaj_central),iphiBin(phij_central)); } // If L1Jet BX=-1 and saturated ET if (idH_early>0) { /* std::cout << " " << std::endl; std::cout << "Found event with early Jet of saturated Et!!! " << std::endl; std::cout << "--------------------- Event "<<jentry<<" ---------------------"<<std::endl; std::cout << "L1Tree : event_->run = "<<event_->run<<std::endl; */ if (etaj_early<9999.) ietaJet_iphiJet_Hs->Fill(ietaBin(etaj_early),iphiBin(phij_early)); if (etaj_central<9999.) ietaJet_iphiJet_central_Hs->Fill(ietaBin(etaj_central),iphiBin(phij_central)); for (Int_t j=0; j<caloTP_->nHCALTP; j++) { ietaTP_Hs->Fill(caloTP_->hcalTPieta[j]); iphiTP_Hs->Fill(caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_Hs->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_Hs_2->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); ietaTP_iphiTP_etTP_Hs->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); etTP_Hs->Fill(caloTP_->hcalTPet[j]); compEtTP_Hs->Fill(caloTP_->hcalTPcompEt[j]); } for (Int_t j=0; j<caloTP_->nECALTP; j++) { e_ietaTP_Hs->Fill(caloTP_->ecalTPieta[j]); e_iphiTP_Hs->Fill(caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP_Hs->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP_Hs_2->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_ietaTP_iphiTP_etTP_Hs->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_etTP_Hs->Fill(caloTP_->ecalTPet[j]); e_compEtTP_Hs->Fill(caloTP_->ecalTPcompEt[j]); } } if (idH_central>0) { // ET of central Jet is saturated /* std::cout << " " << std::endl; std::cout << "Found event with early Jet of saturated Et!!! " << std::endl; std::cout << "--------------------- Event "<<jentry<<" ---------------------"<<std::endl; std::cout << "L1Tree : event_->run = "<<event_->run<<std::endl; */ runPeak++; //=999; // ieta, iphi of the Jet if (etaj_early<9999.) ietaJet_iphiJet_H->Fill(ietaBin(etaj_early),iphiBin(phij_early)); if (etaj_central<9999.) ietaJet_iphiJet_central_H->Fill(ietaBin(etaj_central),iphiBin(phij_central)); // TP info for (Int_t j=0; j<caloTP_->nHCALTP; j++) { ietaTP_H->Fill(caloTP_->hcalTPieta[j]); iphiTP_H->Fill(caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_H->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_H_2->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); ietaTP_iphiTP_etTP_H->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); etTP_H->Fill(caloTP_->hcalTPet[j]); compEtTP_H->Fill(caloTP_->hcalTPcompEt[j]); } for (Int_t j=0; j<caloTP_->nECALTP; j++) { e_ietaTP_H->Fill(caloTP_->ecalTPieta[j]); e_iphiTP_H->Fill(caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP_H->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j]); e_ietaTP_iphiTP_H_2->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_ietaTP_iphiTP_etTP_H->Fill(caloTP_->ecalTPieta[j],caloTP_->ecalTPCaliphi[j],caloTP_->ecalTPet[j]); e_etTP_H->Fill(caloTP_->ecalTPet[j]); e_compEtTP_H->Fill(caloTP_->ecalTPcompEt[j]); } } // HFjets Double_t etaj_hf_early, phij_hf_early; Double_t etaj_hf_central, phij_hf_central; etaj_hf_early=etaj_hf_central=9999.; phij_hf_early=phij_hf_central=9999.; // For debuggig Double_t idHf_early, idHf_central; // if HF jet at ET->250 GeV idHf_early=idHf_central=-1.; Double_t yHF_early, yHF_central; // if HF jet yHF_early=yHF_central=-1.; // Int_t ie,ic,il; ie=ic=il=0; for (Int_t i=0; i<l1extra_->nFwdJets; i++) { // eaarly candidates if (l1extra_->fwdJetBx[i]==-1 ) { // if (matchUpgradedJet(l1extra_->fwdJetEta[i],l1extra_->fwdJetPhi[i])<0) continue; ie++; if (ie>1) continue; yHF_early=999.; ptJetHF_early->Fill(l1extra_->fwdJetEt[i]); etaJetHF_early->Fill(l1extra_->fwdJetEta[i]); phiJetHF_early->Fill(l1extra_->fwdJetPhi[i]); etaj_hf_early=l1extra_->fwdJetEta[i]; phij_hf_early=l1extra_->fwdJetPhi[i]; if (l1extra_->fwdJetEt[i]>=240.) { etaJetHF_early_H->Fill(l1extra_->fwdJetEta[i]); phiJetHF_early_H->Fill(l1extra_->fwdJetPhi[i]); idHf_early=999.; } } // fwdtral cadndidates if (l1extra_->fwdJetBx[i]==0) { // if (matchUpgradedJet(l1extra_->fwdJetEta[i],l1extra_->fwdJetPhi[i])<0) continue; ic++; if (ic>1) continue; yHF_central=999.; ptJetHF_central->Fill(l1extra_->fwdJetEt[i]); etaJetHF_central->Fill(l1extra_->fwdJetEta[i]); phiJetHF_central->Fill(l1extra_->fwdJetPhi[i]); etaj_hf_central=l1extra_->fwdJetEta[i]; phij_hf_central=l1extra_->fwdJetPhi[i]; if (l1extra_->fwdJetEt[i]>=240.) { etaJetHF_central_H->Fill(l1extra_->fwdJetEta[i]); phiJetHF_central_H->Fill(l1extra_->fwdJetPhi[i]); idHf_central=999.; } } // late candidates if (l1extra_->fwdJetBx[i]==1 ) { il++; if (il>1) continue; ptJetHF_late->Fill(l1extra_->fwdJetEt[i]); etaJetHF_late->Fill(l1extra_->fwdJetEta[i]); phiJetHF_late->Fill(l1extra_->fwdJetPhi[i]); } } // ieta/iphi of BX=-1 and BX=0 L1Jets if (etaj_hf_early<9999.) { ietaJet_iphiJet_hf->Fill(ietaBin(etaj_hf_early),iphiBin(phij_hf_early)); } if (etaj_hf_central<9999.) { ietaJet_iphiJet_hf_central->Fill(ietaBin(etaj_hf_central),iphiBin(phij_hf_central)); } //If found a central forward Jet // if (yHF_central<0) continue; if (idHf_early>0) { if (etaj_hf_early<9999.) ietaJet_iphiJet_hf_Hs->Fill(ietaBin(etaj_hf_early),iphiBin(phij_hf_early)); if (etaj_hf_central<9999.) ietaJet_iphiJet_hf_central_Hs->Fill(ietaBin(etaj_hf_central),iphiBin(phij_hf_central)); for (Int_t j=0; j<caloTP_->nHCALTP; j++) { ietaTP_hf_Hs->Fill(caloTP_->hcalTPieta[j]); iphiTP_hf_Hs->Fill(caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_hf_Hs->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_hf_Hs_2->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); ietaTP_iphiTP_etTP_hf_Hs->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); etTP_hf_Hs->Fill(caloTP_->hcalTPet[j]); compEtTP_hf_Hs->Fill(caloTP_->hcalTPcompEt[j]); } } if (idHf_central>0) { // ieta, iphi of the Jet if (etaj_hf_early<9999.) ietaJet_iphiJet_hf_H->Fill(ietaBin(etaj_hf_early),iphiBin(phij_hf_early)); if (etaj_hf_central<9999.) ietaJet_iphiJet_hf_central_H->Fill(ietaBin(etaj_hf_central),iphiBin(phij_hf_central)); // TP info for (Int_t j=0; j<caloTP_->nHCALTP; j++) { ietaTP_hf_H->Fill(caloTP_->hcalTPieta[j]); iphiTP_hf_H->Fill(caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_hf_H->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j]); ietaTP_iphiTP_hf_H_2->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); ietaTP_iphiTP_etTP_hf_H->Fill(caloTP_->hcalTPieta[j],caloTP_->hcalTPCaliphi[j],caloTP_->hcalTPet[j]); etTP_hf_H->Fill(caloTP_->hcalTPet[j]); compEtTP_hf_H->Fill(caloTP_->hcalTPcompEt[j]); } } // if (runPeak>0) break; } // End loop over all Events ptJet_early->Sumw2(); ptJet_early->SetDirectory(dir); ptJet_central->Sumw2(); ptJet_central->SetDirectory(dir); ptJet_late->Sumw2(); ptJet_late->SetDirectory(dir); etaJet_early->Sumw2(); etaJet_early->SetDirectory(dir); etaJet_central->Sumw2(); etaJet_central->SetDirectory(dir); etaJet_late->Sumw2(); etaJet_late->SetDirectory(dir); phiJet_early->Sumw2(); phiJet_early->SetDirectory(dir); phiJet_central->Sumw2(); phiJet_central->SetDirectory(dir); phiJet_late->Sumw2(); phiJet_late->SetDirectory(dir); etaJet_early_H->Sumw2(); etaJet_early_H->SetDirectory(dir); etaJet_central_H->Sumw2(); etaJet_central_H->SetDirectory(dir); phiJet_early_H->Sumw2(); phiJet_early_H->SetDirectory(dir); phiJet_central_H->Sumw2(); phiJet_central_H->SetDirectory(dir); // HF jets ptJetHF_early->Sumw2(); ptJetHF_early->SetDirectory(dir); ptJetHF_central->Sumw2(); ptJetHF_central->SetDirectory(dir); ptJetHF_late->Sumw2(); ptJetHF_late->SetDirectory(dir); etaJetHF_early->Sumw2(); etaJetHF_early->SetDirectory(dir); etaJetHF_central->Sumw2(); etaJetHF_central->SetDirectory(dir); etaJetHF_late->Sumw2(); etaJetHF_late->SetDirectory(dir); phiJetHF_early->Sumw2(); phiJetHF_early->SetDirectory(dir); phiJetHF_central->Sumw2(); phiJetHF_central->SetDirectory(dir); phiJetHF_late->Sumw2(); phiJetHF_late->SetDirectory(dir); etaJetHF_early_H->Sumw2(); etaJetHF_early_H->SetDirectory(dir); etaJetHF_central_H->Sumw2(); etaJetHF_central_H->SetDirectory(dir); phiJetHF_early_H->Sumw2(); phiJetHF_early_H->SetDirectory(dir); phiJetHF_central_H->Sumw2(); phiJetHF_central_H->SetDirectory(dir); // TP info ietaTP_H->Sumw2(); ietaTP_H->SetDirectory(dir); iphiTP_H->Sumw2(); iphiTP_H->SetDirectory(dir); ietaTP_iphiTP_H->Sumw2(); ietaTP_iphiTP_H->SetDirectory(dir); ietaJet_iphiJet_H->Sumw2(); ietaJet_iphiJet_H->SetDirectory(dir); ietaJet_iphiJet_central_H->Sumw2(); ietaJet_iphiJet_central_H->SetDirectory(dir); e_ietaTP_H->Sumw2(); e_ietaTP_H->SetDirectory(dir); e_iphiTP_H->Sumw2(); e_iphiTP_H->SetDirectory(dir); e_ietaTP_iphiTP_H->Sumw2(); e_ietaTP_iphiTP_H->SetDirectory(dir); e_ietaJet_iphiJet_H->Sumw2(); e_ietaJet_iphiJet_H->SetDirectory(dir); e_ietaJet_iphiJet_central_H->Sumw2(); e_ietaJet_iphiJet_central_H->SetDirectory(dir); ietaJet_iphiJet->Sumw2(); ietaJet_iphiJet->SetDirectory(dir); ietaJet_iphiJet_central->Sumw2(); ietaJet_iphiJet_central->SetDirectory(dir); ietaTP_iphiTP_H_2->Sumw2(); ietaTP_iphiTP_H_2->SetDirectory(dir); ietaTP_iphiTP_etTP_H->Sumw2(); ietaTP_iphiTP_etTP_H->SetDirectory(dir); etTP_H->Sumw2(); etTP_H->SetDirectory(dir); compEtTP_H->Sumw2(); compEtTP_H->SetDirectory(dir); ietaTP_Hs->Sumw2(); ietaTP_Hs->SetDirectory(dir); iphiTP_Hs->Sumw2(); iphiTP_Hs->SetDirectory(dir); ietaTP_iphiTP_Hs->Sumw2(); ietaTP_iphiTP_Hs->SetDirectory(dir); e_ietaTP_iphiTP_H_2->Sumw2(); e_ietaTP_iphiTP_H_2->SetDirectory(dir); e_ietaTP_iphiTP_etTP_H->Sumw2(); e_ietaTP_iphiTP_etTP_H->SetDirectory(dir); e_etTP_H->Sumw2(); e_etTP_H->SetDirectory(dir); e_compEtTP_H->Sumw2(); e_compEtTP_H->SetDirectory(dir); e_ietaTP_Hs->Sumw2(); e_ietaTP_Hs->SetDirectory(dir); e_iphiTP_Hs->Sumw2(); e_iphiTP_Hs->SetDirectory(dir); e_ietaTP_iphiTP_Hs->Sumw2(); e_ietaTP_iphiTP_Hs->SetDirectory(dir); ietaJet_iphiJet_Hs->Sumw2(); ietaJet_iphiJet_Hs->SetDirectory(dir); ietaJet_iphiJet_central_Hs->Sumw2(); ietaJet_iphiJet_central_Hs->SetDirectory(dir); ietaTP_iphiTP_Hs_2->Sumw2(); ietaTP_iphiTP_Hs_2->SetDirectory(dir); ietaTP_iphiTP_etTP_Hs->Sumw2(); ietaTP_iphiTP_etTP_Hs->SetDirectory(dir); etTP_Hs->Sumw2(); etTP_Hs->SetDirectory(dir); compEtTP_Hs->Sumw2(); compEtTP_Hs->SetDirectory(dir); ietaTP->Sumw2(); ietaTP->SetDirectory(dir); iphiTP->Sumw2(); iphiTP->SetDirectory(dir); ietaTP_iphiTP->Sumw2(); ietaTP_iphiTP->SetDirectory(dir); ietaTP_iphiTP_2->Sumw2(); ietaTP_iphiTP_2->SetDirectory(dir); ietaTP_iphiTP_etTP->Sumw2(); ietaTP_iphiTP_etTP->SetDirectory(dir); etTP->Sumw2(); etTP->SetDirectory(dir); compEtTP->Sumw2(); compEtTP->SetDirectory(dir); e_ietaTP_iphiTP_Hs_2->Sumw2(); e_ietaTP_iphiTP_Hs_2->SetDirectory(dir); e_ietaTP_iphiTP_etTP_Hs->Sumw2(); e_ietaTP_iphiTP_etTP_Hs->SetDirectory(dir); e_etTP_Hs->Sumw2(); e_etTP_Hs->SetDirectory(dir); e_compEtTP_Hs->Sumw2(); e_compEtTP_Hs->SetDirectory(dir); e_ietaTP->Sumw2(); e_ietaTP->SetDirectory(dir); e_iphiTP->Sumw2(); e_iphiTP->SetDirectory(dir); e_ietaTP_iphiTP->Sumw2(); e_ietaTP_iphiTP->SetDirectory(dir); e_ietaTP_iphiTP_2->Sumw2(); e_ietaTP_iphiTP_2->SetDirectory(dir); e_ietaTP_iphiTP_etTP->Sumw2(); e_ietaTP_iphiTP_etTP->SetDirectory(dir); e_etTP->Sumw2(); e_etTP->SetDirectory(dir); e_compEtTP->Sumw2(); e_compEtTP->SetDirectory(dir); ietaTP_hf_H->Sumw2(); ietaTP_hf_H->SetDirectory(dir); iphiTP_hf_H->Sumw2(); iphiTP_hf_H->SetDirectory(dir); ietaTP_iphiTP_hf_H->Sumw2(); ietaTP_iphiTP_hf_H->SetDirectory(dir); ietaJet_iphiJet_hf_H->Sumw2(); ietaJet_iphiJet_hf_H->SetDirectory(dir); ietaJet_iphiJet_hf_central_H->Sumw2(); ietaJet_iphiJet_hf_central_H->SetDirectory(dir); ietaTP_iphiTP_hf_H_2->Sumw2(); ietaTP_iphiTP_hf_H_2->SetDirectory(dir); ietaTP_iphiTP_etTP_hf_H->Sumw2(); ietaTP_iphiTP_etTP_hf_H->SetDirectory(dir); etTP_hf_H->Sumw2(); etTP_hf_H->SetDirectory(dir); compEtTP_hf_H->Sumw2(); compEtTP_hf_H->SetDirectory(dir); ietaTP_hf_Hs->Sumw2(); ietaTP_hf_Hs->SetDirectory(dir); iphiTP_hf_Hs->Sumw2(); iphiTP_hf_Hs->SetDirectory(dir); ietaTP_iphiTP_hf_Hs->Sumw2(); ietaTP_iphiTP_hf_Hs->SetDirectory(dir); ietaJet_iphiJet_hf_Hs->Sumw2(); ietaJet_iphiJet_hf_Hs->SetDirectory(dir); ietaJet_iphiJet_hf_central_Hs->Sumw2(); ietaJet_iphiJet_hf_central_Hs->SetDirectory(dir); ietaTP_iphiTP_hf_Hs_2->Sumw2(); ietaTP_iphiTP_hf_Hs_2->SetDirectory(dir); ietaTP_iphiTP_etTP_hf_Hs->Sumw2(); ietaTP_iphiTP_etTP_hf_Hs->SetDirectory(dir); etTP_hf_Hs->Sumw2(); etTP_hf_Hs->SetDirectory(dir); compEtTP_hf_Hs->Sumw2(); compEtTP_hf_Hs->SetDirectory(dir); ietaJet_iphiJet_hf->Sumw2(); ietaJet_iphiJet_hf->SetDirectory(dir); ietaJet_iphiJet_hf_central->Sumw2(); ietaJet_iphiJet_hf_central->SetDirectory(dir); total->Write(); total->Close(); }
vector<TH1*> PlotsFeeder::Loop(int NumOfVtx) { // In a ROOT session, you can do: // Root > .L PlotsFeeder.C // Root > PlotsFeeder t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch vector<TH1 *> vHistograms; //DS! PER IL MOMENTO LI LASCIO TUTTI, SE POI DECIDIAMO EFFETTIVAMENTE DI TENERE SOLO LE 3 ISO, //QUESTA MACRO È MEGLIO INTEGRARLA CON LA PlotsFeeder.C //(e modificare di conseguenza anche la DataMCValidation.C per far sparire la DataMCValidationPUR.C //EB Reweight TH1D * h_IsoTrk_EBR_PUR; TH1D * h_IsoEcal_EBR_PUR; TH1D * h_IsoHcal_EBR_PUR; TH1D * h_HE_EBR; TH1F * h_DeltaPhiTkClu_EBR; TH1F * h_DeltaEtaTkClu_EBR; TH1F * h_sigmaIeIe_EBR; //EB Reweight h_IsoTrk_EBR_PUR = new TH1D("h_IsoTrk_EBR_PUR","IsoTrk_PUR",36,0.,0.09); h_IsoEcal_EBR_PUR = new TH1D("h_IsoEcal_EBR_PUR","IsoEcal_PUR",28,0.,0.07); h_IsoHcal_EBR_PUR = new TH1D("h_IsoHcal_EBR_PUR","IsoHcal_PUR",40,0.,0.10); /*h_IsoTrk_EBR_PUR = new TH1D("h_IsoTrk_EBR_PUR","IsoTrk_PUR",20,0.,0.20); h_IsoEcal_EBR_PUR = new TH1D("h_IsoEcal_EBR_PUR","IsoEcal_PUR",20,0.,0.20); h_IsoHcal_EBR_PUR = new TH1D("h_IsoHcal_EBR_PUR","IsoHcal_PUR",20,0.,0.20);*/ h_HE_EBR = new TH1D("h_HE_EBR","H/E",20,0.,0.20); h_DeltaPhiTkClu_EBR = new TH1F("h_DeltaPhiTkClu_EBR","DeltaPhiTkClu",20,0.,0.2); h_DeltaEtaTkClu_EBR = new TH1F("h_DeltaEtaTkClu_EBR","DeltaEtaTkClu",20,0.,.05); h_sigmaIeIe_EBR = new TH1F("h_sigmaIeIe_EBR","sigmaIeIe",20,0.,0.1); /*=========================*/ //EE Reweight TH1D * h_IsoTrk_EER_PUR; TH1D * h_IsoEcal_EER_PUR; TH1D * h_IsoHcal_EER_PUR; TH1D * h_HE_EER; TH1F * h_DeltaPhiTkClu_EER; TH1F * h_DeltaEtaTkClu_EER; TH1F * h_sigmaIeIe_EER; //EE Reweight h_IsoTrk_EER_PUR = new TH1D("h_IsoTrk_EER_PUR","IsoTrk",16,0.,0.04); h_IsoEcal_EER_PUR = new TH1D("h_IsoEcal_EER_PUR","IsoEcal",20,0.,0.05); h_IsoHcal_EER_PUR = new TH1D("h_IsoHcal_EER_PUR","IsoHcal",10,0.,0.025); /*h_IsoTrk_EER_PUR = new TH1D("h_IsoTrk_EER_PUR","IsoTrk",20,0.,0.20); h_IsoEcal_EER_PUR = new TH1D("h_IsoEcal_EER_PUR","IsoEcal",20,0.,0.20); h_IsoHcal_EER_PUR = new TH1D("h_IsoHcal_EER_PUR","IsoHcal",20,0.,0.20);*/ h_HE_EER = new TH1D("h_HE_EER","H/E",20,0.,0.20); h_DeltaPhiTkClu_EER = new TH1F("h_DeltaPhiTkClu_EER","DeltaPhiTkClu",20,0.,0.2); h_DeltaEtaTkClu_EER = new TH1F("h_DeltaEtaTkClu_EER","DeltaEtaTkClu",20,0.,.05); h_sigmaIeIe_EER = new TH1F("h_sigmaIeIe_EER","sigmaIeIe",20,0.,0.1); /*=========================*/ if (fChain == 0){ cout << " something went wrong in PlotsFeeder "; return vHistograms;} Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; if(numberOfVertices==NumOfVtx){ if (IsoTrkEB_PUR->size()>0) { for (unsigned int i=0; i<IsoTrkEB_PUR->size();i++){ float var=IsoTrkEB_PUR->at(i); h_IsoTrk_EBR_PUR->Fill(var,Weight); } } if (IsoEcalEB_PUR->size()>0) { for (unsigned int i=0; i<IsoEcalEB_PUR->size();i++){ float var=IsoEcalEB_PUR->at(i); h_IsoEcal_EBR_PUR->Fill(var,Weight); } } if (IsoHcalEB_PUR->size()>0) { for (unsigned int i=0; i<IsoEcalEB_PUR->size();i++){ float var=IsoHcalEB_PUR->at(i); h_IsoHcal_EBR_PUR->Fill(var,Weight); } } if (HEEB->size()>0) { for (unsigned int i=0; i<HEEB->size();i++){ float var=HEEB->at(i); h_HE_EBR->Fill(var,Weight); } } if (DeltaPhiTkCluEB->size()>0) { for (unsigned int i=0; i<DeltaPhiTkCluEB->size();i++){ float var=DeltaPhiTkCluEB->at(i); h_DeltaPhiTkClu_EBR->Fill(var,Weight); } } if (DeltaEtaTkCluEB->size()>0) { for (unsigned int i=0; i<DeltaEtaTkCluEB->size();i++){ float var=DeltaEtaTkCluEB->at(i); h_DeltaEtaTkClu_EBR->Fill(var,Weight); } } if (sigmaIeIeEB->size()>0) { for (unsigned int i=0; i<sigmaIeIeEB->size();i++){ float var=sigmaIeIeEB->at(i); h_sigmaIeIe_EBR->Fill(var,Weight); } } //==== EE ====// if (IsoTrkEE_PUR->size()>0) { for (unsigned int i=0; i<IsoTrkEE_PUR->size();i++){ float var=IsoTrkEE_PUR->at(i); h_IsoTrk_EER_PUR->Fill(var,Weight); } } if (IsoEcalEE_PUR->size()>0) { for (unsigned int i=0; i<IsoEcalEE_PUR->size();i++){ float var=IsoEcalEE_PUR->at(i); h_IsoEcal_EER_PUR->Fill(var,Weight); } } if (IsoHcalEE_PUR->size()>0) { for (unsigned int i=0; i<IsoHcalEE_PUR->size();i++){ float var=IsoHcalEE_PUR->at(i); h_IsoHcal_EER_PUR->Fill(var,Weight); } } if (HEEE->size()>0) { for (unsigned int i=0; i<HEEE->size();i++){ float var=HEEE->at(i); h_HE_EER->Fill(var,Weight); } } if (DeltaPhiTkCluEE->size()>0) { for (unsigned int i=0; i<DeltaPhiTkCluEE->size();i++){ float var=DeltaPhiTkCluEE->at(i); h_DeltaPhiTkClu_EER->Fill(var,Weight); } } if (DeltaEtaTkCluEE->size()>0) { for (unsigned int i=0; i<DeltaEtaTkCluEE->size();i++){ float var=DeltaEtaTkCluEE->at(i); h_DeltaEtaTkClu_EER->Fill(var,Weight); } } if (sigmaIeIeEE->size()>0) { for (unsigned int i=0; i<sigmaIeIeEE->size();i++){ float var=sigmaIeIeEE->at(i); h_sigmaIeIe_EER->Fill(var,Weight); } } } } vHistograms.push_back(h_IsoTrk_EBR_PUR); vHistograms.push_back(h_IsoEcal_EBR_PUR); vHistograms.push_back(h_IsoHcal_EBR_PUR); vHistograms.push_back(h_HE_EBR); vHistograms.push_back(h_DeltaPhiTkClu_EBR); vHistograms.push_back(h_DeltaEtaTkClu_EBR); vHistograms.push_back(h_sigmaIeIe_EBR); vHistograms.push_back(h_IsoTrk_EER_PUR); vHistograms.push_back(h_IsoEcal_EER_PUR); vHistograms.push_back(h_IsoHcal_EER_PUR); vHistograms.push_back(h_HE_EER); vHistograms.push_back(h_DeltaPhiTkClu_EER); vHistograms.push_back(h_DeltaEtaTkClu_EER); vHistograms.push_back(h_sigmaIeIe_EER); //===================================// //=========== DEBUG AREA ============// //===================================// bool debug=0; if(debug==1){ TCanvas * EB_plots; TCanvas * EE_plots; //EB - Create a Canvas and divide it in Pads EB_plots = new TCanvas("EB_plots","EB",400,20,1200,800); EB_plots->Divide(4,2); //First histogram EB_plots->cd(1); h_IsoTrk_EBR_PUR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_IsoTrk_EBR_PUR->SetLineColor(1); h_IsoTrk_EBR_PUR->Draw(); //WP Lines and Legend TLegend *leg = new TLegend(0.4,0.55,0.8,0.9); leg->SetBorderSize(0); leg->SetEntrySeparation(0.01); leg->SetFillColor(0); leg->AddEntry(h_IsoTrk_EBR_PUR,"MC Reweighted and PUR","l"); TLine *Line80 = new TLine(0.09,0.,0.09,h_IsoTrk_EBR_PUR->GetMaximum()); Line80->SetLineColor(kBlue); Line80->SetLineStyle(2); Line80->Draw(); leg->AddEntry(Line80,"WP 80","l"); TLine *Line90 = new TLine(0.12,0.,0.12,h_IsoTrk_EBR_PUR->GetMaximum()); Line90->SetLineColor(kBlack); Line90->SetLineStyle(2); Line90->Draw(); leg->AddEntry(Line90,"WP 90","l"); leg->Draw(); //Second histogram EB_plots->cd(2); h_IsoEcal_EBR_PUR->GetYaxis()->SetTitle("Number of Events"); h_IsoEcal_EBR_PUR->Draw(); BLine(0.07,0.,0.07,h_IsoEcal_EBR_PUR->GetMaximum()); MLine(0.09,0.,0.09,h_IsoEcal_EBR_PUR->GetMaximum()); EB_plots->cd(3); h_IsoHcal_EBR_PUR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_IsoHcal_EBR_PUR->SetLineColor(1); h_IsoHcal_EBR_PUR->Draw(); BLine(0.10,0.,0.10,h_IsoHcal_EBR_PUR->GetMaximum()); MLine(0.10,0.,0.10,h_IsoHcal_EBR_PUR->GetMaximum()); EB_plots->cd(4); h_HE_EBR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_HE_EBR->SetLineColor(1); h_HE_EBR->Draw(); BLine(0.04,0.,0.04,h_HE_EBR->GetMaximum()); MLine(0.12,0.,0.12,h_HE_EBR->GetMaximum()); EB_plots->cd(5); h_DeltaPhiTkClu_EBR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_DeltaPhiTkClu_EBR->SetLineColor(1); h_DeltaPhiTkClu_EBR->Draw(); BLine(0.06,0.,0.06,h_DeltaPhiTkClu_EBR->GetMaximum()); MLine(0.8,0.,0.8,h_DeltaPhiTkClu_EBR->GetMaximum()); EB_plots->cd(6); h_DeltaEtaTkClu_EBR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_DeltaEtaTkClu_EBR->SetLineColor(1); h_DeltaEtaTkClu_EBR->Draw(); BLine(0.004,0.,0.004,h_DeltaEtaTkClu_EBR->GetMaximum()); MLine(0.007,0.,0.007,h_DeltaEtaTkClu_EBR->GetMaximum()); EB_plots->cd(7); h_sigmaIeIe_EBR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_sigmaIeIe_EBR->SetLineColor(1); h_sigmaIeIe_EBR->Draw(); BLine(0.004,0.,0.004,h_sigmaIeIe_EBR->GetMaximum()); MLine(0.007,0.,0.007,h_sigmaIeIe_EBR->GetMaximum()); /*============================*/ // qua dei draw copi diretto da all plots //EE - Create a Canvas and divide it in Pads EE_plots = new TCanvas("EE_plots","EE",400,20,1200,800); EE_plots->Divide(4,2); //First histogram EE_plots->cd(1); h_IsoTrk_EER_PUR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_IsoTrk_EER_PUR->SetLineColor(1); h_IsoTrk_EER_PUR->Draw(); //WP Lines and Legend TLegend *leg2 = new TLegend(0.4,0.55,0.8,0.9); leg2->SetBorderSize(0); leg2->SetEntrySeparation(0.01); leg2->SetFillColor(0); leg2->AddEntry(h_IsoTrk_EER_PUR,"MC Reweighted and PUR","l"); Line80->SetLineColor(kBlue); Line80->SetLineStyle(2); Line80->Draw(); leg2->AddEntry(Line80,"WP 80","l"); Line90->SetLineColor(kBlack); Line90->SetLineStyle(2); Line90->Draw(); leg2->AddEntry(Line90,"WP 90","l"); leg2->Draw(); //Second histogram EE_plots->cd(2); h_IsoEcal_EER_PUR->GetYaxis()->SetTitle("Number of Events"); h_IsoEcal_EER_PUR->SetLineColor(1); h_IsoEcal_EER_PUR->Draw(); BLine(0.07,0.,0.07,h_IsoEcal_EER_PUR->GetMaximum()); MLine(0.09,0.,0.09,h_IsoEcal_EER_PUR->GetMaximum()); EE_plots->cd(3); h_IsoHcal_EER_PUR->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_IsoHcal_EER_PUR->SetLineColor(1); h_IsoHcal_EER_PUR->Draw(); BLine(0.10,0.,0.10,h_IsoHcal_EER_PUR->GetMaximum()); MLine(0.10,0.,0.10,h_IsoHcal_EER_PUR->GetMaximum()); EE_plots->cd(4); h_HE_EER->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_HE_EER->SetLineColor(1); h_HE_EER->Draw(); BLine(0.04,0.,0.04,h_HE_EER->GetMaximum()); MLine(0.12,0.,0.12,h_HE_EER->GetMaximum()); EE_plots->cd(5); h_DeltaPhiTkClu_EER->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_DeltaPhiTkClu_EER->SetLineColor(1); h_DeltaPhiTkClu_EER->Draw(); BLine(0.06,0.,0.06,h_DeltaPhiTkClu_EER->GetMaximum()); MLine(0.8,0.,0.8,h_DeltaPhiTkClu_EER->GetMaximum()); EE_plots->cd(6); h_DeltaEtaTkClu_EER->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_DeltaEtaTkClu_EER->SetLineColor(1); h_DeltaEtaTkClu_EER->Draw(); BLine(0.004,0.,0.004,h_DeltaEtaTkClu_EER->GetMaximum()); MLine(0.007,0.,0.007,h_DeltaEtaTkClu_EER->GetMaximum()); EE_plots->cd(7); h_sigmaIeIe_EER->GetYaxis()->SetTitle("Number of Events"); gPad->SetLogy(1); h_sigmaIeIe_EER->SetLineColor(1); h_sigmaIeIe_EER->Draw(); BLine(0.004,0.,0.004,h_sigmaIeIe_EER->GetMaximum()); MLine(0.007,0.,0.007,h_sigmaIeIe_EER->GetMaximum()); } return vHistograms; }
void analysisClass::Loop() { std::cout << "analysisClass::Loop() begins" <<std::endl; TStopwatch time; frame("Starting the analysis"); time.Start(true); setTDRStyle(); if (fChain == 0) return; //////////book histos here // TH1F *h_nJetFinal = new TH1F ("h_nJetFinal","",10,0,10); // h_nJetFinal->Sumw2(); // TH1F *h_nVtx = new TH1F ("h_nVtx","",30,0,30); // h_nVtx->Sumw2(); // TH1F *h_trueVtx = new TH1F ("h_trueVtx","",40,0,40); // h_trueVtx->Sumw2(); // TH1F *h_pT1stJet = new TH1F ("h_pT1stJet","",100,0,3000); // h_pT1stJet->Sumw2(); // TH1F *h_pT2ndJet = new TH1F ("h_pT2ndJet","",100,0,3000); // h_pT2ndJet->Sumw2(); // TH1F *h_eta1stJet = new TH1F ("h_eta1stJet","",5,-2.5,2.5); // h_eta1stJet->Sumw2(); // TH1F *h_eta2ndJet = new TH1F ("h_eta2ndJet","",5,-2.5,2.5); // h_eta2ndJet->Sumw2(); // TH1F *h_DijetMass = new TH1F ("h_DijetMass","",600,0,6000); // h_DijetMass->Sumw2(); // TH1F *h_DeltaETAjj = new TH1F ("h_DeltaETAjj","",120,0,3.); // h_DeltaETAjj->Sumw2(); /////////initialize variables Long64_t nentries = fChain->GetEntriesFast(); std::cout << "analysisClass::Loop(): nentries = " << nentries << std::endl; double lepton_mass; std::vector <int> goodLepton, looseLepton, goodAK08, goodAK04, goodAK08_lep, goodAK04_lep, goodAK08Pruned, goodEle, goodMuon, looseEle, looseMuon; TLorentzVector genW, ak04, ak08, ak08Pruned, lepton, leptonLoose, W, MET, wGenQ1, wGenQ2, wGenSumi, subjet1, subjet2, subjetSum, wGenSum, bGen1, bGen2; int btag_ak04_loose, btag_ak04_medium, btag_ak04_tight; int subjet_index1, subjet_index2; ////// The following ~7 lines have been taken from rootNtupleClass->Loop() ///// ////// If the root version is updated and rootNtupleClass regenerated, ///// ////// these lines may need to be updated. ///// Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { //for (Long64_t jentry=0; jentry<1000;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(jentry < 10 || jentry%1000 == 0) std::cout << "analysisClass::Loop(): jentry = " << jentry << std::endl; // if (Cut(ientry) < 0) continue; ////////////////////// User's code starts here /////////////////////// ///Stuff to be done for every event btag_ak04_loose=0; btag_ak04_medium=0; btag_ak04_tight=0; goodLepton.clear(); looseLepton.clear(); goodAK04.clear(); goodAK08.clear(); goodAK08_lep.clear(); goodAK04_lep.clear(); goodAK08Pruned.clear(); goodEle.clear(); goodMuon.clear(); looseEle.clear(); looseMuon.clear(); resetCuts(); //=== Forse da inserire === /* fillVariableWithValue("run",runNo); fillVariableWithValue("event",evtNo); fillVariableWithValue("lumi",lumi); fillVariableWithValue("nVtx",nvtx); fillVariableWithValue("nJet",widejets.size()); */ for(int i=0; i<nselLeptons; ++i){ if((abs(selLeptons_pdgId[i])==11 && selLeptons_isMyGoodElectron[i]==1 && selLeptons_pt[i]>30 && (abs(selLeptons_eta[i])<1.442 || (abs(selLeptons_eta[i])>1.56 && abs(selLeptons_eta[i])<2.5))) || (abs(selLeptons_pdgId[i])==13 && selLeptons_isMyGoodMuon[i]==1 && selLeptons_pt[i]>30 && abs(selLeptons_eta[i])<2.1)){// && selLeptons_relIso03[0]<0.1)){ goodLepton.push_back(i); //std::cout<<"Passing tight selection"<<std::endl; CreateAndFillUserTH1D("goodEleTightSelection", 2,-.5,1.5, 1); }//end if 'good' lepton cuts else if(((abs(selLeptons_pdgId[i])==11 && selLeptons_isMyGoodElectron[i]==1 && selLeptons_pt[i]>35 && (abs(selLeptons_eta[i])<1.442 || (abs(selLeptons_eta[i])>1.56 && abs(selLeptons_eta[i])<2.5))) || (abs(selLeptons_pdgId[i])==13 && selLeptons_isMyGoodMuon[i]==1 && selLeptons_pt[i]>20 && abs(selLeptons_eta[i])<2.1))){// && selLeptons_relIso03[i]<0.1))){ looseLepton.push_back(i); //if(abs(selLeptons_pdgId[i])==11) lepton_mass=e_mass; //if(abs(selLeptons_pdgId[i])==13) lepton_mass=mu_mass; //leptonLoose.SetPtEtaPhiM(selLeptons_pt[i],selLeptons_eta[i],selLeptons_phi[i], lepton_mass); }//end if loose lepton if(abs(selLeptons_pdgId[i])==13 && selLeptons_isMyGoodMuon[i]==1 && selLeptons_pt[i]>53 && abs(selLeptons_eta[i])<2.1 && (selLeptons_muTrackIso[i]/selLeptons_pt[i])<0.1){ goodMuon.push_back(i); } else if(abs(selLeptons_pdgId[i])==13 && selLeptons_isMyGoodMuon[i]==1 && selLeptons_pt[i]>20 && abs(selLeptons_eta[i])<2.4 && (selLeptons_muTrackIso[i]/selLeptons_pt[i])<0.1){ // if(abs(selLeptons_pdgId[i])==13 && selLeptons_isMyGoodMuon[i]==1 && selLeptons_pt[i]>53 && abs(selLeptons_eta[i])<2.1 && (selLeptons_muTrackIso[i]/selLeptons_pt[i])<0.1){ looseMuon.push_back(i); } if(abs(selLeptons_pdgId[i])==11 && selLeptons_isMyGoodElectron[i]==1 && selLeptons_pt[i]>120 && abs(selLeptons_eta[i])<2.1){ goodEle.push_back(i); }else if((abs(selLeptons_pdgId[i])==11 && selLeptons_isMyGoodElectron[i]==1 && selLeptons_pt[i]>35 && abs(selLeptons_eta[i])<2.4)){ looseEle.push_back(i); } }//end if nselLeptons for(int i=0; i<nFatjetAK08ungroomed;++i){ if((((FatjetAK08ungroomed_neHEFrac[i]<0.99 && FatjetAK08ungroomed_neEmEFrac[i]<0.99 && (FatjetAK08ungroomed_chMult[i]+FatjetAK08ungroomed_neMult[i])>1) && ((abs(FatjetAK08ungroomed_eta[i])<=2.4 && FatjetAK08ungroomed_chHEFrac[i]>0 && FatjetAK08ungroomed_chMult[i]>0 && FatjetAK08ungroomed_chEmEFrac[i]<0.99) || abs(FatjetAK08ungroomed_eta[i])>2.4) && abs(FatjetAK08ungroomed_eta[i])<=3.0)||((FatjetAK08ungroomed_neEmEFrac[i]<0.90 && FatjetAK08ungroomed_neMult[i]>10 && abs(FatjetAK08ungroomed_eta[i])>3.0 ))) && FatjetAK08ungroomed_pt[i]>100 && abs(FatjetAK08ungroomed_eta[i])<2.4){ goodAK08.push_back(i); }//end if good AK08 }//end loop over nFatjetAK08ungroomed for(int i=0; i<nJet; ++i){ if((((Jet_neHEF[i]<0.99 && Jet_neEmEF[i]<0.99 && (Jet_chMult[i]+Jet_neMult[i])>1) && ((abs(Jet_eta[i])<=2.4 && Jet_chHEF[i]>0 && Jet_chMult[i]>0 && Jet_chEmEF[i]<0.99) || abs(Jet_eta[i])>2.4) && abs(Jet_eta[i])<=3.0)||((Jet_neEmEF[i]<0.90 && Jet_neMult[i]>10 && abs(Jet_eta[i])>3.0 ))) && Jet_pt[i]>30 && abs(Jet_eta[i])<2.4){ CreateAndFillUserTH1D("goodAk04LooseSelection", 2,-.5,1.5, 1); goodAK04.push_back(i); } }//end loop over nJet fillVariableWithValue("lepton_goodNumber", goodLepton.size()); fillVariableWithValue("lepton_looseNumber", looseLepton.size()); fillVariableWithValue("ak08_goodNumber", goodAK08.size()); fillVariableWithValue("nLepton",nselLeptons); fillVariableWithValue("nGoodEle", goodEle.size()); fillVariableWithValue("nLooseEle", looseEle.size()); fillVariableWithValue("nGoodMuon", goodMuon.size()); fillVariableWithValue("nLooseMuon", looseMuon.size()); if(goodAK08.size()>=1){ fillVariableWithValue("ak08Ungroomed_1_pt", FatjetAK08ungroomed_pt[goodAK08[0]]); fillVariableWithValue("ak08Ungroomed_1_eta", FatjetAK08ungroomed_eta[goodAK08[0]]); fillVariableWithValue("ak08Ungroomed_1_phi", FatjetAK08ungroomed_phi[goodAK08[0]]); fillVariableWithValue("ak08Ungroomed_1_mass", FatjetAK08ungroomed_mass[goodAK08[0]]); fillVariableWithValue("ak08Ungroomed_1_tau21", FatjetAK08ungroomed_tau2[goodAK08[0]]/FatjetAK08ungroomed_tau1[goodAK08[0]]); ak08.SetPtEtaPhiM(FatjetAK08ungroomed_pt[goodAK08[0]], FatjetAK08ungroomed_eta[goodAK08[0]], FatjetAK08ungroomed_phi[goodAK08[0]], FatjetAK08ungroomed_mass[goodAK08[0]]); double minDR_subjetJet=999.; subjet_index1=subjet_index2=0; for(int s=0; s<nSubjetAK08pruned; ++s){ subjet1.SetPtEtaPhiM(SubjetAK08pruned_pt[s], SubjetAK08pruned_eta[s], SubjetAK08pruned_phi[s], SubjetAK08pruned_mass[s]); for(int ss=0; ss<nSubjetAK08pruned; ++ss){ if(ss!=s){ subjet2.SetPtEtaPhiM(SubjetAK08pruned_pt[ss], SubjetAK08pruned_eta[ss], SubjetAK08pruned_phi[ss], SubjetAK08pruned_mass[ss]); subjetSum=subjet1+subjet2; if(subjetSum.DeltaR(ak08)){ minDR_subjetJet=subjetSum.DeltaR(ak08); subjet_index1=s; subjet_index2=ss; } } } }//end loop over subjets fillVariableWithValue("ak08_subjetDR", minDR_subjetJet); if(nSubjetAK08pruned>0){ subjet1.SetPtEtaPhiM(SubjetAK08pruned_pt[subjet_index1], SubjetAK08pruned_eta[subjet_index1], SubjetAK08pruned_phi[subjet_index1], SubjetAK08pruned_mass[subjet_index1]); subjet2.SetPtEtaPhiM(SubjetAK08pruned_pt[subjet_index2], SubjetAK08pruned_eta[subjet_index2], SubjetAK08pruned_phi[subjet_index2], SubjetAK08pruned_mass[subjet_index2]); if(SubjetAK08pruned_btag[subjet_index1]>0.605) fillVariableWithValue("subjet1_btagLoose", 1); if(SubjetAK08pruned_btag[subjet_index1]>0.89) fillVariableWithValue("subjet1_btagMedium", 1); if(SubjetAK08pruned_btag[subjet_index1]>0.97) fillVariableWithValue("subjet1_btagTight", 1); if(SubjetAK08pruned_btag[subjet_index2]>0.605) fillVariableWithValue("subjet2_btagLoose", 1); if(SubjetAK08pruned_btag[subjet_index2]>0.89) fillVariableWithValue("subjet2_btagMedium", 1); if(SubjetAK08pruned_btag[subjet_index2]>0.97) fillVariableWithValue("subjet2_btagTight", 1); fillVariableWithValue("subjetDR", subjet1.DeltaR(subjet2)); fillVariableWithValue("subjet1_pt", SubjetAK08pruned_pt[subjet_index1]); fillVariableWithValue("subjet1_eta", SubjetAK08pruned_eta[subjet_index1]); fillVariableWithValue("subjet1_phi", SubjetAK08pruned_phi[subjet_index1]); fillVariableWithValue("subjet2_pt", SubjetAK08pruned_pt[subjet_index2]); fillVariableWithValue("subjet2_eta", SubjetAK08pruned_eta[subjet_index2]); fillVariableWithValue("subjet2_phi", SubjetAK08pruned_phi[subjet_index2]); } double minDR_W=999; int w_counter=0; if(isData==0){ if(nGenWZQuark==2){ wGenQ1.SetPtEtaPhiM(GenWZQuark_pt[0], GenWZQuark_eta[0], GenWZQuark_phi[0], GenWZQuark_mass[0]); wGenQ2.SetPtEtaPhiM(GenWZQuark_pt[1], GenWZQuark_eta[1], GenWZQuark_phi[1], GenWZQuark_mass[1]); fillVariableWithValue("genQ1_pt", GenWZQuark_pt[0]); fillVariableWithValue("genQ1_eta", GenWZQuark_eta[0]); fillVariableWithValue("genQ1_phi", GenWZQuark_phi[0]); fillVariableWithValue("genQ2_pt", GenWZQuark_pt[1]); fillVariableWithValue("genQ2_eta", GenWZQuark_eta[1]); fillVariableWithValue("genQ2_phi", GenWZQuark_phi[1]); fillVariableWithValue("genQ_DR", wGenQ1.DeltaR(wGenQ2)); if(nSubjetAK08pruned>0){ fillVariableWithValue("subjet1_qGen1_DR", TMath::Min(wGenQ1.DeltaR(subjet1), wGenQ2.DeltaR(subjet1))); fillVariableWithValue("subjet2_qGen2_DR", TMath::Min(wGenQ1.DeltaR(subjet2), wGenQ2.DeltaR(subjet2))); //std::cout<<"1. "<<TMath::Min(wGenQ1.DeltaR(subjet1), wGenQ2.DeltaR(subjet1))<<std::endl; //std::cout<<"2. "<<TMath::Min(wGenQ1.DeltaR(subjet2), wGenQ2.DeltaR(subjet2))<<std::endl; }else{ fillVariableWithValue("subjet1_qGen1_DR", -1); fillVariableWithValue("subjet2_qGen2_DR", -1); } wGenSum=wGenQ1+wGenQ2; for (int w=0; w<nGenVbosons; ++w){ if(abs(GenVbosons_pdgId[w])==24){ genW.SetPtEtaPhiM(GenVbosons_pt[w], GenVbosons_eta[w], GenVbosons_phi[w], W_mass); if(goodLepton.size()>=1){ if(abs(selLeptons_pdgId[goodLepton[0]])==11) lepton_mass=e_mass; if(abs(selLeptons_pdgId[goodLepton[0]])==13) lepton_mass=mu_mass; lepton.SetPtEtaPhiM(selLeptons_pt[goodLepton[0]],selLeptons_eta[goodLepton[0]],selLeptons_phi[goodLepton[0]], lepton_mass); } if(wGenSum.DeltaR(genW)<minDR_W){ minDR_W=wGenSum.DeltaR(genW); w_counter=w; } }//if gen Boson==W } genW.SetPtEtaPhiM(GenVbosons_pt[w_counter], GenVbosons_eta[w_counter], GenVbosons_phi[w_counter], W_mass); fillVariableWithValue("ak08Ungroomed_WGen_DR",ak08.DeltaR(genW)); fillVariableWithValue("WGen_quark_DR", minDR_W); fillVariableWithValue("W_Gen_pt", GenVbosons_pt[w_counter]); fillVariableWithValue("W_Gen_eta", GenVbosons_eta[w_counter]); fillVariableWithValue("W_Gen_phi", GenVbosons_phi[w_counter]); fillVariableWithValue("lepton_WGen_DR", lepton.DeltaR(genW)); bGen1.SetPtEtaPhiM(GenBQuarkFromTop_pt[0],GenBQuarkFromTop_eta[0],GenBQuarkFromTop_phi[0],GenBQuarkFromTop_mass[0]); bGen2.SetPtEtaPhiM(GenBQuarkFromTop_pt[1],GenBQuarkFromTop_eta[1],GenBQuarkFromTop_phi[1],GenBQuarkFromTop_mass[1]); fillVariableWithValue("genW_genBquark1_DR", genW.DeltaR(bGen1)); fillVariableWithValue("genW_genBquarkMin_DR", TMath::Min(genW.DeltaR(bGen1), genW.DeltaR(bGen2))); fillVariableWithValue("genW_genBquarkMax_DR", TMath::Max(genW.DeltaR(bGen1), genW.DeltaR(bGen2))); //std::cout<<"1. "<<genW.DeltaR(bGen1)<<std::endl; fillVariableWithValue("genW_genBquark2_DR", genW.DeltaR(bGen2)); // std::cout<<"2. "<<genW.DeltaR(bGen2)<<std::endl; }else{//end if 2 quarks from VBosons fillVariableWithValue("subjet1_qGen1_DR", -1); fillVariableWithValue("subjet2_qGen2_DR", -1); } }//end if isData else{ fillVariableWithValue("ak08Ungroomed_WGen_DR",minDR_W); fillVariableWithValue("lepton_WGen_DR", minDR_W); } double dr_tmp=99; int index=0; for(int ii=0; ii<nFatjetAK08pruned; ++ii){ ak08Pruned.SetPtEtaPhiM(FatjetAK08pruned_pt[ii],FatjetAK08pruned_eta[ii], FatjetAK08pruned_phi[ii], FatjetAK08pruned_mass[ii]); if(ak08.DeltaR(ak08Pruned)<dr_tmp){ dr_tmp=ak08.DeltaR(ak08Pruned); index=ii; }//matched good pruned AK08 goodAK08Pruned.push_back(index); }//end loop over nFatjetAK08pruned }//end if ak08GoodUngroomed jet else{ fillVariableWithValue("ak08Ungroomed_WGen_DR",999); } if(goodLepton.size()>=1){ if(abs(selLeptons_pdgId[goodLepton[0]])==11) lepton_mass=e_mass; if(abs(selLeptons_pdgId[goodLepton[0]])==13) lepton_mass=mu_mass; lepton.SetPtEtaPhiM(selLeptons_pt[goodLepton[0]],selLeptons_eta[goodLepton[0]],selLeptons_phi[goodLepton[0]], lepton_mass); fillVariableWithValue("lepton_pt", selLeptons_pt[goodLepton[0]]); fillVariableWithValue("lepton_eta", selLeptons_eta[goodLepton[0]]); fillVariableWithValue("lepton_phi", selLeptons_phi[goodLepton[0]]); fillVariableWithValue("lepton_pdgID", selLeptons_pdgId[goodLepton[0]]); fillVariableWithValue("muonRelIso03", selLeptons_relIso03[0]); fillVariableWithValue("muontrkIso", selLeptons_muTrackIso[0]); MET.SetPtEtaPhiM(met_pt, met_eta, met_phi, 0); W=lepton+MET; fillVariableWithValue("W_pt", W.Pt()); fillVariableWithValue("W_eta",W.Eta()); fillVariableWithValue("W_phi",W.Phi()); fillVariableWithValue("W_mT", 2*abs(MET.Pt())*abs(lepton.Pt())*(1-cos(lepton.DeltaPhi(MET)))); //fillVariableWithValue("W_mT",W.Mt()); MET.SetPtEtaPhiM(metType1p2_pt, met_eta, met_phi, 0); W=lepton+MET; fillVariableWithValue("WType1_pt", W.Pt()); fillVariableWithValue("WType1_eta",W.Eta()); fillVariableWithValue("WType1_phi",W.Phi()); fillVariableWithValue("W_mT", 2*abs(MET.Pt())*abs(lepton.Pt())*(1-cos(lepton.DeltaPhi(MET)))); //fillVariableWithValue("WType1_mT",W.Mt()); //MET.SetPtEtaPhiM(metPuppi_pt, met_eta, met_phi, 0); //W=lepton+MET; //fillVariableWithValue("WPuppi_pt", W.Pt()); //fillVariableWithValue("WPuppi_eta",W.Eta()); //fillVariableWithValue("WPuppi_phi",W.Phi()); //fillVariableWithValue("W_mT", 2*abs(MET.Pt())*abs(lepton.Pt())*(1-cos(lepton.DeltaPhi(MET)))); //fillVariableWithValue("WPuppi_mT",W.Mt()); if(goodAK08.size()>1) fillVariableWithValue("ak08Ungroomed_lepton_DR", lepton.DeltaR(ak08)); fillVariableWithValue("nAK04", goodAK04.size()); for(int j=0; j<goodAK04.size(); ++j){ ak04.SetPtEtaPhiM(Jet_pt[goodAK04[j]], Jet_eta[goodAK04[j]], Jet_phi[goodAK04[j]], Jet_mass[goodAK04[j]]); if(ak04.DeltaR(ak08)>.8 && ak04.DeltaR(lepton)>.3){ CreateAndFillUserTH1D("Ak04_lepton&AK08_DRCut", 2,-.5,1.5, 1); goodAK04_lep.push_back(goodAK04[j]); if(Jet_btagCSV[goodAK04[j]]>0.605){ ++btag_ak04_loose; } if(Jet_btagCSV[goodAK04[j]]>0.890){ ++btag_ak04_medium; } if(Jet_btagCSV[goodAK04[j]]>0.97){ ++btag_ak04_tight; }//end if for CSV medium working point }//end if ak04 without leptons and ak08 nearby }//end loop over goodAK04.size() }//end loop over goodLepton.size() if(goodLepton.size()>=2){ fillVariableWithValue("lepton2_pt", selLeptons_pt[goodLepton[1]]); fillVariableWithValue("lepton2_eta", selLeptons_eta[goodLepton[1]]); fillVariableWithValue("lepton2_phi", selLeptons_phi[goodLepton[1]]); fillVariableWithValue("lepton2_pdgID", selLeptons_pdgId[goodLepton[1]]); } fillVariableWithValue("btag_loose",btag_ak04_loose); fillVariableWithValue("btag_medium",btag_ak04_medium); fillVariableWithValue("btag_tight",btag_ak04_tight); if(goodAK08Pruned.size()>=1){ fillVariableWithValue("ak08Pruned_1_pt", FatjetAK08pruned_pt[goodAK08Pruned[0]]); fillVariableWithValue("ak08Pruned_1_eta", FatjetAK08pruned_eta[goodAK08Pruned[0]]); fillVariableWithValue("ak08Pruned_1_phi", FatjetAK08pruned_phi[goodAK08Pruned[0]]); fillVariableWithValue("ak08Pruned_1_mass", FatjetAK08pruned_mass[goodAK08Pruned[0]]); } if(goodAK08Pruned.size()>=2){ fillVariableWithValue("ak08Pruned_2_pt", FatjetAK08pruned_pt[goodAK08Pruned[1]]); fillVariableWithValue("ak08Pruned_2_eta", FatjetAK08pruned_eta[goodAK08Pruned[1]]); fillVariableWithValue("ak08Pruned_2_phi", FatjetAK08pruned_phi[goodAK08Pruned[1]]); fillVariableWithValue("ak08Pruned_2_mass", FatjetAK08pruned_mass[goodAK08Pruned[1]]); } if(goodAK04_lep.size()>=1){ fillVariableWithValue("ak04_1_pt", Jet_pt[goodAK04_lep[0]]); fillVariableWithValue("ak04_1_eta", Jet_eta[goodAK04_lep[0]]); fillVariableWithValue("ak04_1_phi", Jet_phi[goodAK04_lep[0]]); fillVariableWithValue("ak04_1_mass", Jet_mass[goodAK04_lep[0]]); //=== TH1D to check the fillReduceSkim procedure === CreateAndFillUserTH1D("ak04_first_pt", 1000,0,500, Jet_pt[goodAK04_lep[0]]); } if(goodAK04_lep.size()>=2){ fillVariableWithValue("ak04_2_pt", Jet_pt[goodAK04_lep[1]]); fillVariableWithValue("ak04_2_eta", Jet_eta[goodAK04_lep[1]]); fillVariableWithValue("ak04_2_phi", Jet_phi[goodAK04_lep[1]]); fillVariableWithValue("ak04_2_mass", Jet_mass[goodAK04_lep[1]]); } //fillVariableWithValue("metPuppi",metPuppi_pt); fillVariableWithValue("metType1", metType1p2_pt); fillVariableWithValue("met",met_pt); fillVariableWithValue("nPrimaryVertexes", nPVs); fillVariableWithValue("Mu45_TRG", HLT_HLT_Mu45_eta2p1); fillVariableWithValue("Mu50_TRG", HLT_HLT_Mu50); fillVariableWithValue("HBHE", Flag_HBHENoiseFilter); fillVariableWithValue("HBHE_IsoFilter", Flag_hbheIsoFilter); fillVariableWithValue("CSC_filter",Flag_CSCTightHaloFilter); fillVariableWithValue("eeBADFilter", Flag_eeBadScFilter); fillVariableWithValue("run", run); fillVariableWithValue("nBtag_gen",nGenBQuarkFromTop); // Evaluate cuts (but do not apply them) evaluateCuts(); //fillReducedSkimTree(); // optional call to fill a skim with the full content of the input roottuple //if( passedCut("nJetFinal") ) fillSkimTree(); // optional call to fill a skim with a subset of the variables defined in the cutFile (use flag SAVE) //if( passedAllPreviousCuts("mjj") && passedCut("mjj") ) if( passedCut("met"))//passedAllPreviousCuts("eeBADFilter") && passedCut("eeBADFilter")) { //frame("Beware! This part can be set outside the if -Passed cuts-"); fillReducedSkimTree(); // ===== Take a look at this ===== // //Example on how to investigate quickly the data // if(getVariableValue("mjj")>4000) // { // //fast creation and filling of histograms // CreateAndFillUserTH1D("h_dphijj_mjjgt4000", 100, 0, 3.15, getVariableValue("deltaPHIjj")); // CreateAndFillUserTH1D("h_htak4_mjjgt4000", 1000, 0, 10000, getVariableValue("HTAK4")); // CreateAndFillUserTH1D("h_nvtx_mjjgt4000", 31, -0.5, 30.5, getVariableValue("nVtx")); // } } // ===== Example of mjj spectrum after HLT selection ===== // if( passedAllPreviousCuts("mjj") ) // { // if(getVariableValue("passHLT")>0) // { // //fast creation and filling of histograms // CreateAndFillUserTH1D("h_mjj_passHLT", getHistoNBins("mjj"), getHistoMin("mjj"), getHistoMax("mjj"), getVariableValue("mjj")); // } // } // reject events that did not pass level 0 cuts //if( !passedCut("0") ) continue; // ...... // reject events that did not pass level 1 cuts //if( !passedCut("1") ) continue; // ...... // reject events that did not pass the full cut list //if( !passedCut("all") ) continue; // ...... // if( widejets.size() >= 2) { // h_nJetFinal->Fill(widejets.size()); // h_DijetMass->Fill(wdijet.M()); // h_pT1stJet->Fill(widejets[0].Pt()); // h_pT2ndJet->Fill(widejets[1].Pt()); // h_eta1stJet->Fill(widejets[0].Eta()); // h_eta2ndJet->Fill(widejets[1].Eta()); // } ////////////////////// User's code ends here /////////////////////// } // End loop over events //////////write histos // h_nVtx->Write(); // h_trueVtx->Write(); // h_nJetFinal->Write(); // h_pT1stJet->Write(); // h_pT2ndJet->Write(); // h_DijetMass->Write(); // h_eta1stJet->Write(); // h_eta2ndJet->Write(); // //pT of both jets, to be built using the histograms produced automatically by baseClass // TH1F * h_pTJets = new TH1F ("h_pTJets","", getHistoNBins("pT1stJet"), getHistoMin("pT1stJet"), getHistoMax("pT1stJet")); // h_pTJets->Add( & getHisto_noCuts_or_skim("pT1stJet") ); // all histos can be retrieved, see other getHisto_xxxx methods in baseClass.h // h_pTJets->Add( & getHisto_noCuts_or_skim("pT2ndJet") ); // //one could also do: *h_pTJets = getHisto_noCuts_or_skim("pT1stJet") + getHisto_noCuts_or_skim("pT2ndJet"); // h_pTJets->Write(); // //one could also do: const TH1F& h = getHisto_noCuts_or_skim// and use h std::cout << "analysisClass::Loop() ends" <<std::endl; std::cout<<""<<std::endl; std::cout << "------ TIME ELAPSED DURING ANALYSIS ----- " << time.RealTime() << " s" <<std::endl; std::cout<<""<<std::endl; }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisControl::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); // Define histograms //---------------------------------------------------------------------------- root_output->cd(); for (int j=0; j<ncut; j++) { for (int k=0; k<=njetbin; k++) { TString sbin = (k < njetbin) ? Form("/%djet", k) : ""; TString directory = scut[j] + sbin; root_output->cd(); if (k < njetbin) gDirectory->mkdir(directory); root_output->cd(directory); for (int i=ee; i<=ll; i++) { TString suffix = "_" + schannel[i]; DefineHistograms(i, j, k, suffix); } } } root_output->cd(); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); // Analysis //-------------------------------------------------------------------------- _nelectron = 0; if (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (abs(Lepton2.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (_nelectron == 2) _channel = ee; else if (_nelectron == 1) _channel = em; else if (_nelectron == 0) _channel = mm; _m2l = mll; // Needs l2Sel _pt2l = ptll; // Needs l2Sel bool pass_2l = (Lepton1.flavour * Lepton2.flavour < 0); pass_2l &= (Lepton1.v.Pt() > 25.); pass_2l &= (Lepton2.v.Pt() > 20.); pass_2l &= (std_vector_lepton_pt->at(2) < 10.); pass_2l &= (_m2l > 20.); bool pass; // No cuts //-------------------------------------------------------------------------- pass = true; FillLevelHistograms(Control_00_NoCuts, pass); // Has 2 tight leptons //-------------------------------------------------------------------------- pass = pass_2l; FillLevelHistograms(Control_01_TwoLeptons, pass); if (_saveminitree && pass) minitree->Fill(); // R out/in //-------------------------------------------------------------------------- pass = pass_2l; pass &= (_nbjet30csvv2m > 0); FillLevelHistograms(Control_02_Routin, pass); // WW // https://github.com/latinos/PlotsConfigurations/blob/master/Configurations/ControlRegions/WW/Full2016/cuts.py //-------------------------------------------------------------------------- pass = mll > 80 && std_vector_lepton_pt->at(0) > 25 && std_vector_lepton_pt->at(1) > 13 && std_vector_lepton_pt->at(2) < 10 && metPfType1 > 20 && ptll > 30 && mth >= 60 && (std_vector_jet_pt->at(0) < 20 || std_vector_jet_cmvav2->at(0) < -0.5884) && (std_vector_jet_pt->at(1) < 20 || std_vector_jet_cmvav2->at(1) < -0.5884) && (std_vector_jet_pt->at(2) < 20 || std_vector_jet_cmvav2->at(2) < -0.5884) && (std_vector_jet_pt->at(3) < 20 || std_vector_jet_cmvav2->at(3) < -0.5884) && (std_vector_jet_pt->at(4) < 20 || std_vector_jet_cmvav2->at(4) < -0.5884) && (std_vector_jet_pt->at(5) < 20 || std_vector_jet_cmvav2->at(5) < -0.5884) && (std_vector_jet_pt->at(6) < 20 || std_vector_jet_cmvav2->at(6) < -0.5884) && (std_vector_jet_pt->at(7) < 20 || std_vector_jet_cmvav2->at(7) < -0.5884) && (std_vector_jet_pt->at(8) < 20 || std_vector_jet_cmvav2->at(8) < -0.5884) && (std_vector_jet_pt->at(9) < 20 || std_vector_jet_cmvav2->at(9) < -0.5884); FillLevelHistograms(Control_03_WW, pass); if (pass) EventDump(); // Top //-------------------------------------------------------------------------- pass = pass_2l; pass &= (_njet > 1); pass &= (_nbjet30csvv2m > 0); pass &= (_channel == em || fabs(_m2l - Z_MASS) > 15.); pass &= (MET.Et() > 45.); FillLevelHistograms(Control_04_Top, pass); } EndJob(); }
void sigeff1::Loop() { if (fChain == 0) return; TH1F* h_lowestcsv_csv = new TH1F("h_lowestcsv_csv", "Lowest CSV jet, CVS output", 40, 0., 1. ) ; TH1F* h_lowestcsv_pt = new TH1F("h_lowestcsv_pt", "Lowest CSV jet, pt", 40, 0., 200. ) ; TH1F* h_lowestcsv_csv_4b = new TH1F("h_lowestcsv_csv_4b", "Lowest CSV jet, CVS output, 4b", 40, 0., 1. ) ; TH1F* h_lowestcsv_pt_4b = new TH1F("h_lowestcsv_pt_4b", "Lowest CSV jet, pt, 4b", 40, 0., 200. ) ; Long64_t nentries = fChain->GetEntries(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; //-- find the lowest CSV jet float lowestcsv(9.) ; float lowestcsvpt(0.) ; if ( higgs1CSV1 < lowestcsv ) { lowestcsv = higgs1CSV1 ; lowestcsvpt = higgs1jetpt1 ; } if ( higgs1CSV2 < lowestcsv ) { lowestcsv = higgs1CSV2 ; lowestcsvpt = higgs1jetpt2 ; } if ( higgs2CSV1 < lowestcsv ) { lowestcsv = higgs2CSV1 ; lowestcsvpt = higgs2jetpt1 ; } if ( higgs2CSV2 < lowestcsv ) { lowestcsv = higgs2CSV2 ; lowestcsvpt = higgs2jetpt2 ; } //--- lepton veto if ( ! (nMuons==0&&nElectrons==0&&nIsoTracks15_005_03==0&&nIsoTracks5_005_03<2&&nTausLoose==0 ) ) continue ; //--- two tight b tags if ( ! (CSVbest2>0.898) ) continue ; //--- max Dr cut if ( ! (deltaRmax_hh<2.2) ) continue ; //--- METsig>30 if ( ! (METsig>30) ) continue ; ///////////////////if ( ! (METsig>100) ) continue ; bool pass2b(false) ; if ( CSVbest2>0.898&&CSVbest3<0.244 ) { pass2b = true ; } bool pass4b(false) ; if ( CSVbest2>0.898&&CSVbest3>0.679&&CSVbest4>0.244 ) { pass4b = true ; } h_lowestcsv_csv -> Fill( lowestcsv ) ; h_lowestcsv_pt -> Fill( lowestcsvpt ) ; if ( pass4b ) { h_lowestcsv_csv_4b -> Fill( lowestcsv ) ; h_lowestcsv_pt_4b -> Fill( lowestcsvpt ) ; } } // jentry. addoverflow( h_lowestcsv_pt_4b ) ; addoverflow( h_lowestcsv_csv_4b ) ; addoverflow( h_lowestcsv_pt ) ; addoverflow( h_lowestcsv_csv ) ; }
void testlor::Loop() { // In a ROOT session, you can do: // Root > .L testlor.C // Root > testlor t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch //Set-up Code if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; int pions=0,kaons=0,ksTOpi=0,i=0,j=0; int ipart1,ipart2,a,b; Double_t ppion[kMaxentry]; Double_t npion[kMaxentry]; Double_t p[kMaxentry]; double prop=0; Double_t pp,E,KSmass; TLorentzVector q[kMaxentry];//pinakas tupou tlorentz TLorentzVector w,v; TVector3 l; TH1D *pzhist=new TH1D("pz","pz histogram",120,-12,12); TH1D *pthist=new TH1D("pt","pt histogram",50,0,1.5); TH1D *kshist=new TH1D("KSmass","KSmasss",120,0.2,0.8); TH1D *kshist2=new TH1D("KSmass","KSmasss",120,0.,5); TH1D *pseudohist=new TH1D("Pseudorapidity","Pseudorapidity",120,-15,15); cout << "Number of events = " << nentries << endl; //event loop for (Long64_t jentry=0; jentry<nentries;jentry++) {//nentries Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; cout << " event # " << jentry << ", #particles " << entry_ << endl; // if (Cut(ientry) < 0) continue; //particle loop for (int ipart = 0; ipart < entry_ ; ipart++) { w.SetPx(entry_pSave_xx[ipart]); w.SetPy(entry_pSave_yy[ipart]); w.SetPz(entry_pSave_zz[ipart]); w.SetE(entry_pSave_tt[ipart]); q[ipart]=w; l=q[ipart].Vect(); //~ cout<<"pseudorapidity="<<l.PseudoRapidity()<<endl; p[ipart]=l.Mag(); cout<<"p="<<l.Mag()<<endl;//P! //~ cout<<"m="<<q[ipart].M()<<endl;//m?not right //~ cout<<"pt="<<q[ipart].Perp()<<endl;//PT! //~ cout <<"i="<<ipart<< "\tpdgID = " << entry_idSave[ipart]<<",\t Daughter1="<<entry_idSave[entry_daughter1Save[ipart]]<<",\tDaughter2="<<entry_idSave[entry_daughter2Save[ipart]]<<"\tEnergy="<<entry_pSave_tt[ipart]<<endl; //pions vs kaons if(((TMath::Abs(entry_idSave[ipart]))==(211))||(entry_idSave[ipart]==(111))) { pions++; } else if((entry_idSave[ipart]==130)|| ((TMath::Abs(entry_idSave[ipart]))==(321))||(entry_idSave[ipart]==310) ||((TMath::Abs(entry_idSave[ipart]))==(311))||((TMath::Abs(entry_idSave[ipart]))==(323)) ||((TMath::Abs(entry_idSave[ipart]))==(313)) ) { kaons++; } //Ks->pions if((entry_idSave[ipart]==310)&&(((entry_idSave[entry_daughter1Save[ipart]]==(211))&&(entry_idSave[entry_daughter2Save[ipart]]==(-1)*(211))) ||((entry_idSave[entry_daughter1Save[ipart]]==(-1)*(211))&&(entry_idSave[entry_daughter2Save[ipart]]==(211))) )){ ipart1[ksTOpi]=entry_daughter1Save[ipart]; ipart2[ksTOpi]=entry_daughter2Save[ipart]; cout<<"ipart1="<<ipart1<<"\t ipart2="<<ipart2<<endl; ksTOpi++; cout<<"ksTOpi="<<ksTOpi<<endl; }//end of ks->pions if if(entry_idSave[ipart]==211){ ppion[i]=ipart; i++;} if(entry_idSave[ipart]==(-1)*(211)){ npion[j]=ipart; j++;} //Fill Histograms pzhist->Fill(entry_pSave_zz[ipart]); pthist->Fill(q[ipart].Perp()); pseudohist->Fill(l.PseudoRapidity()); }//end of particle loop //Ksmass for(int n=0;n<i;n++){ a=ppion[n]; for(int m=0;m<j;m++){ b=npion[m]; v=q[a]+q[b]; //~ TVector3 y=v.Vect(); //~ pp=y.Mag(); //~ E=v.E(); KSmass=v.M(); kshist2->Fill(KSmass); }//end of npion loop }//end of ppion loop //KStoPI for(int count=0;count<ksTOpi;count++){ v=q[ipart1[ksTOpi]]+q[ipart2[ksTOpi]]; //~ l=v.Vect(); //~ pp=l.Mag(); //~ E=v.E(); KSmass=v.M(); kshist->Fill(KSmass); }//end of ksTOpi loop i=0; j=0; ksTOpi=0; if(kaons!=0){ prop=prop+((double)kaons)/((double)pions); } }//end of event loop //Wrap-up code TCanvas* k1 = new TCanvas("c1","Pythia8Ana",800,800); k1->Divide(1, 3); k1->cd(1); kshist->Draw(); kshist->GetXaxis()->SetTitle("mass [GeV/c^2]"); kshist->GetYaxis()->SetTitle("Number of events"); k1->cd(2); kshist2->Draw(); kshist2->GetXaxis()->SetTitle("mass [GeV/c^2]"); kshist2->GetYaxis()->SetTitle("Number of events"); //~ //~ k1->cd(2); //~ pseudohist->Draw(); //~ pseudohist->GetXaxis()->SetTitle("pseudorapidity"); //~ pseudohist->GetYaxis()->SetTitle("Number of events"); k1->cd(3); pthist->Draw(); pthist->GetXaxis()->SetTitle("pt [GeV/c]"); pthist->GetYaxis()->SetTitle("Number of events"); cout<<"Ebeam1="<<entry_pSave_tt[1]<<"[GeV], Ebeam2="<<entry_pSave_tt[2]<<"[GeV]"<<endl; cout<<"Mass1= "<<entry_mSave[1]<<" Mass2="<<entry_mSave[2]<<endl; cout<<"Kaons="<<prop/nentries<<"Pions"<<endl; cout<<"kaons="<<kaons<<", Pions="<<pions<<endl; cout<<"event found, ipart1="<<ipart1<<"\t ipart2="<<ipart2<<endl; cout<<"ipart1="<<ipart1<<endl; cout<<"p["<<ipart1<<"]="<<p[ipart1]<<endl; }//End of Loop method
void anatree::Loop() { // To execute this code you will do this: // > root -l // Root > .L anatree.C // (or to compile : Root > .L anatree.C+) // Root > anatree t // Root > t.Loop(); // Loop on all entries TH1F* StartPointOffset = new TH1F("startpointoffset",";X-aXis title; Y-Axis title", 50, 0, 1000); if (fChain == 0) return; /// Define how many entries are in the tree: /// Start Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; ///End /// Here we START to loop over all entries in the TTree /// these are events, so be careful how you think of these events /// Start for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; /// End std::cout << "\n ########################### \n Looking at Event == " << jentry << std::endl; /* List of useful variables that you might want to look at: event -- this is what you call event number subrun -- this is what you call subrun RECONSTRUCTION INFORMATION: nshowers -- The number of reconstruted showers (N) showerID[N] -- A unique shower ID, just a number (int) shwr_bestplane[N] -- The plane that has the largest (spatial) projection of hits, this is the P you should use typically shwr_length[N] -- The length of the shower in blah dimensions shwr_startdcosx[N] -- the "i" component of the unit vector describing the direction shwr_startdcosy[N] -- the "j" component of the unit vector describing the direction shwr_startdcosz[N] -- the "k" component of the unit vector describing the direction shwr_startx[N] -- the "x" posistion start point shwr_starty[N] -- the "y" posistion start point shwr_startz[N] -- the "z" posistion start point shwr_totEng[N][P] -- The total energy of the shower in plane P (focus on P == 2 for now) shwr_mipEng[N][P] -- The total energy of the shower in plane P (focus on P == 2 for now) shwr_dedx[N][P] -- The total energy deposited at the start of the shower MC TRUTH INFORMATION: geant_list_size -- The number of particles (N), you will usually only be intrested in the first particle pdg[N] -- The pdg of the n-th particle in the list Eng[N] -- The TRUE energy of the n-th particle Px[N] -- X-projection of the n-th particle momentum Py[N] -- Y-projection of the n-th particle momentum Pz[N] -- Z-projection of the n-th particle momentum P[N] -- n-th particle momentum StartPointx[N] -- X-projection of the n-th start point StartPointy[N] -- Y-projection of the n-th start point StartPointz[N] -- X-projection of the n-th start point theta[N] -- The theta of the n-th particle phi[N] -- the phi of the n-th paritlce */ //Here you will build your code, build whatever you want! MUHAHAHAHAHAHAHAHAHAHAHAHA@ //// EXAMPLE loop through all reco showers in event if(nshowers == 1){ // look it up, this is wrong. double dist = sqrt( pow((shwr_startx[0] - StartPointx[0]),2) + pow((shwr_starty[0] - StartPointx[0]),2) + pow((shwr_startz[0] -StartPointx[0]),2)); // Histogram (TH1F) -> Fill(var) [function, var] StartPointOffset->Fill(dist); std::cout << "Start Point Reco : " << shwr_startx[0] << std::endl; std::cout << "Start Point MC : " << StartPointx[0] << std::endl; } /* double max_eng = 0; int max_N = 0; for(int n = 0; n < nshowers; n++){ double temp_eng = shwr_totEng[n][2]; if(max_eng < temp_eng) {max_eng = temp_eng; max_N = n;} } */ ////// END /// Here is the end of the loop /// Start } /// End StartPointOffset->Draw(); }
void MFVFlatNtupleReader::genHists(std::string target) { // In a ROOT session, you can do: // Root > .L MFVFlatNtupleReader.C // Root > MFVFlatNtupleReader t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; //set up the program for a specific target std::vector<unsigned char> *loc; loc = 0; if (target == "vtx_ntracks") fChain->SetBranchAddress("vtx_ntracks", &loc, &b_vtx_ntracks); else if (target == "vtx_ntracksptgt3") fChain->SetBranchAddress("vtx_ntracksptgt3",&loc,&b_vtx_ntracksptgt3); else if (target == "vtx_ntracksptgt5") fChain->SetBranchAddress("vtx_ntracksptgt5",&loc,&b_vtx_ntracksptgt5); else if (target == "vtx_ntracksptgt10") fChain->SetBranchAddress("vtx_ntracksptgt10",&loc,&b_vtx_ntracksptgt10); else if (target == "vtx_sumnhitsbehind") fChain->SetBranchAddress("vtx_sumnhitsbehind",&loc,&b_vtx_sumnhitsbehind); else if (target == "vtx_njets") fChain->SetBranchAddress("vtx_njets",&loc,&b_vtx_njets); else if (target == "vtx_nmu") fChain->SetBranchAddress("vtx_nmu",&loc,&b_vtx_nmu); else if (target == "vtx_nel") fChain->SetBranchAddress("vtx_nel",&loc,&b_vtx_nel); else if (target == "vtx_maxnhitsbehind") fChain->SetBranchAddress("vtx_maxnhitsbehind",&loc,&b_vtx_sumnhitsbehind); //set up the histograms to desired specifications int nbins = 26; h_tot = new TH1F("h_tot"," After Cut (Total)",nbins,-0.5,nbins-0.5); h_back = new TH1F("h_back"," After Cut (Background)",nbins,-0.5,nbins-0.5); h_sig = new TH1F("h_sig"," After Cut (Signal)",nbins,-0.5,nbins-0.5); enum { s_start = -3, s_mfv_neutralino_tau0100um_M0400 = -3, s_mfv_neutralino_tau1000um_M0400, s_mfv_neutralino_tau0300um_M0400, s_mfv_neutralino_tau9900um_M0400, s_ttbarhadronic, s_ttbarsemilep, s_ttbardilep, s_qcdht0100, s_qcdht0250, s_qcdht0500, s_qcdht1000, s_end }; std::map<int, std::string> sample_names; sample_names[s_mfv_neutralino_tau0100um_M0400] = "mfv_neutralino_tau0100um_M0400"; sample_names[s_mfv_neutralino_tau0300um_M0400] = "mfv_neutralino_tau0300um_M0400"; sample_names[s_mfv_neutralino_tau1000um_M0400] = "mfv_neutralino_tau1000um_M0400"; sample_names[s_mfv_neutralino_tau9900um_M0400] = "mfv_neutralino_tau9900um_M0400"; sample_names[s_ttbarhadronic] = "ttbarhadronic"; sample_names[s_ttbarsemilep] = "ttbarsemilep"; sample_names[s_ttbardilep] = "ttbardilep"; sample_names[s_qcdht0100] = "qcdht0100"; sample_names[s_qcdht0250] = "qcdht0250"; sample_names[s_qcdht0500] = "qcdht0500"; sample_names[s_qcdht1000] = "qcdht1000"; std::map<int, int> sample_nevents_read; Long64_t nentries = fChain->GetEntries(); for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); if (jentry % 1000 == 0) { printf("\r%lli/%lli events read", jentry, nentries); fflush(stdout); } //std::cout << std::endl << b_vtx_sumnhitsbehind->GetEntry(jentry) << std::endl; int numverts = nvertices; int numgoodverts = 0; //std::cout << "numverts = " << numverts << std::endl; for (int i = 0; i < numverts; ++i) { if (MFVFlatNtupleReader::goodVertex(i)) { ++(numgoodverts); //std::cout << "good vertex detected" << std::endl; } } //std::cout << numgoodverts << std::endl; if (numgoodverts >= 1) { ++sample_nevents_read[sample]; for (int i = 0; i < nvertices; ++i) { //fill with everything h_tot->Fill((int)(*loc)[i]); } if (sample >= 0) { //fill with background for (int i = 0; i < nvertices; ++i) { h_back->Fill((int)(*loc)[i]); } //ERRORS TO BE FIXED HERE: MAP STRINGS AND POINTERS!!! } else { //fill with signal for (int i = 0; i < nvertices; ++i) { h_sig->Fill((int)(*loc)[i]); } } } } printf("\r%80s\rdone!\n", ""); for (int s = s_start; s < s_end; ++s) printf("sample %30s events read: %10i\n", sample_names[s].c_str(), sample_nevents_read[s]); gStyle->SetCanvasPreferGL(1); //now we set up the canvas and histogram details so we can draw them string title_str = target + " of Lepton-Producing Events"; const char * title = new char[sizeof title_str]; title = title_str.c_str(); const char * xaxis = target.c_str(); TCanvas *c1 = new TCanvas("c1",title,900,600); c1->SetBorderMode(0); c1->SetFillColor(kWhite); //c1->SetLogy(); THStack *hs = new THStack("hs",title); h_tot->SetLineColor(kGreen); h_tot->SetFillStyle(4050); h_tot->SetLineWidth(2); hs->Add(h_tot); h_back->SetLineColor(kBlue); h_back->SetFillStyle(4050); h_back->SetLineWidth(2); hs->Add(h_back); h_sig->SetLineColor(kRed); h_sig->SetFillStyle(4010); h_sig->SetLineWidth(2); hs->Add(h_sig); //h_tot->Draw(); //h_back->Draw("same"); //h_sig->Draw("same"); hs->Draw("nostack"); hs->GetXaxis()->SetTitle(xaxis); hs->GetYaxis()->SetTitle("number of vertices"); hs->GetYaxis()->SetTitleOffset(1.4); TLegend *leg = new TLegend(0.7,0.7,0.9,0.9); leg->SetHeader("Type of Data"); leg->AddEntry(h_tot,"Total"); leg->AddEntry(h_back,"Background"); leg->AddEntry(h_sig,"Signal"); leg->Draw(); c1->Modified(); //data to be printed to the command line vector<int> entries_in_bins_tot; vector<int> entries_in_bins_back; vector<int> entries_in_bins_sig; for (int i = 1; i <= nbins; ++i) { entries_in_bins_tot.push_back(h_tot->GetBinContent(i)); entries_in_bins_back.push_back(h_back->GetBinContent(i)); entries_in_bins_sig.push_back(h_sig->GetBinContent(i)); } std::cout << std::endl << "Total: " << std::endl; for (int i = 0; i < nbins; ++i) { std::cout << "bin " << i+1 << ": " << entries_in_bins_tot[i] << " entries" << std::endl; } std::cout << std::endl << "Background: " << std::endl; for (int i = 0; i < nbins; ++i) { std::cout << "bin " << i+1 << ": " << entries_in_bins_back[i] << " entries" << std::endl; } std::cout << std::endl << "Signal: " << std::endl; for (int i = 0; i < nbins; ++i) { std::cout << "bin " << i+1 << ": " << entries_in_bins_sig[i] << " entries" << std::endl; } std::cout << std::endl; }
void MFVFlatNtupleReader::loopDisplaySigBack() { // In a ROOT session, you can do: // Root > .L MFVFlatNtupleReader.C // Root > MFVFlatNtupleReader t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; enum { s_start = -3, s_mfv_neutralino_tau0100um_M0400 = -3, s_mfv_neutralino_tau1000um_M0400, s_mfv_neutralino_tau0300um_M0400, s_mfv_neutralino_tau9900um_M0400, s_ttbarhadronic, s_ttbarsemilep, s_ttbardilep, s_qcdht0100, s_qcdht0250, s_qcdht0500, s_qcdht1000, s_end }; std::map<int, std::string> sample_names; sample_names[s_mfv_neutralino_tau0100um_M0400] = "mfv_neutralino_tau0100um_M0400"; sample_names[s_mfv_neutralino_tau0300um_M0400] = "mfv_neutralino_tau0300um_M0400"; sample_names[s_mfv_neutralino_tau1000um_M0400] = "mfv_neutralino_tau1000um_M0400"; sample_names[s_mfv_neutralino_tau9900um_M0400] = "mfv_neutralino_tau9900um_M0400"; sample_names[s_ttbarhadronic] = "ttbarhadronic"; sample_names[s_ttbarsemilep] = "ttbarsemilep"; sample_names[s_ttbardilep] = "ttbardilep"; sample_names[s_qcdht0100] = "qcdht0100"; sample_names[s_qcdht0250] = "qcdht0250"; sample_names[s_qcdht0500] = "qcdht0500"; sample_names[s_qcdht1000] = "qcdht1000"; std::map<int, int> sample_nevents_read; //variables to check signal to background before and after cuts int ngoodrsigevents = 0; int ngoodrbackevents = 0; int ngoodocsigevents = 0; int ngoodocbackevents = 0; int ngoodncsigevents = 0; int ngoodncbackevents = 0; Long64_t nentries = fChain->GetEntries(); for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); if (jentry % 1000 == 0) { printf("\r%lli/%lli events read", jentry, nentries); fflush(stdout); } //std::cout << std::endl << b_vtx_sumnhitsbehind->GetEntry(jentry) << std::endl; int numverts = nvertices; int numgoodncverts = 0; int numgoodocverts = 0; //std::cout << "numverts = " << numverts << std::endl; for (int i = 0; i < numverts; ++i) { if (MFVFlatNtupleReader::goodVertex(i)) { ++(numgoodncverts); //std::cout << "good vertex detected" << std::endl; } if (MFVFlatNtupleReader::goodVertex_old(i)) { ++(numgoodocverts); } } //std::cout << numgoodverts << std::endl; if (numgoodncverts >= 1) { ++sample_nevents_read[sample]; if (sample < 0) ++ngoodncsigevents; else ++ngoodncbackevents; } if (numgoodocverts >= 1) { if (sample < 0) ++ngoodocsigevents; else ++ngoodocbackevents; } if (sample < 0) ++ngoodrsigevents; else ++ngoodrbackevents; } printf("\r%80s\rdone!\n", ""); for (int s = s_start; s < s_end; ++s) printf("sample %30s events read: %10i\n", sample_names[s].c_str(), sample_nevents_read[s]); //signal vs background std::cout << std::endl << "new cuts: " << std::endl << "good signal events: " << ngoodncsigevents << std::endl; std::cout << "good background events: " << ngoodncbackevents << std::endl << "ratio: " << (float)ngoodncsigevents/(float)ngoodncbackevents; std::cout << std::endl << std::endl; std::cout << std::endl << "old cuts: " << std::endl << "good signal events: " << ngoodocsigevents << std::endl; std::cout << "good background events: " << ngoodocbackevents << std::endl << "ratio: " << (float)ngoodocsigevents/(float)ngoodocbackevents; std::cout << std::endl << std::endl; std::cout << std::endl << "no cuts: " << std::endl << "good signal events: " << ngoodrsigevents << std::endl; std::cout << "good background events: " << ngoodrbackevents << std::endl << "ratio: " << (float)ngoodrsigevents/(float)ngoodrbackevents; std::cout << std::endl << std::endl; }
void mjj_match::Loop(int DEBUG) { if (fChain == 0) return; // book histograms TH1D* h_mh_template = new TH1D("h_mh_template","",280,100,1500); h_mh_template->Sumw2(); h_mh_template->SetXTitle("M_{lljj} [GeV/c^{2}]"); h_mh_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mh_template->GetBinWidth(1))); TH1D* h_mll_template = new TH1D("h_mll_template","",35,60,130); h_mll_template->Sumw2(); h_mll_template->SetXTitle("M_{ll} [GeV/c^{2}]"); h_mll_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mll_template->GetBinWidth(1))); TH1D* h_mjj_template = new TH1D("h_mjj_template","",14,60,130); h_mjj_template->Sumw2(); h_mjj_template->SetXTitle("M_{jj} [GeV/c^{2}]"); h_mjj_template->SetYTitle(Form("Candidates per %d GeV/c^{2}", (int)h_mjj_template->GetBinWidth(1))); TH1D* h_jec_template = new TH1D("h_jec_template","",20,0.5,1.5); h_jec_template->Sumw2(); h_jec_template->SetXTitle("p_{T}^{REC}(jet)/p_{T}^{GEN}(jet)"); h_jec_template->SetYTitle(Form("Candidates per %.1f", h_jec_template->GetBinWidth(1))); TH1D* h_dR_template = new TH1D("h_dR_template","",50,0,5.0); h_dR_template->Sumw2(); h_dR_template->SetXTitle("#Delta R"); h_dR_template->SetYTitle(Form("Candidates per %.1f", h_dR_template->GetBinWidth(1))); // status=3 level TH1D* h_mh_parton = (TH1D*)h_mh_template->Clone("h_mh_parton"); h_mh_parton->SetTitle("status=3"); TH1D* h_mll_parton = (TH1D*)h_mll_template->Clone("h_mll_parton"); h_mll_parton->SetTitle("status=3"); TH1D* h_mjj_parton = (TH1D*)h_mjj_template->Clone("h_mjj_parton"); h_mjj_parton->SetTitle("status=3"); // status=1 level TH1D* h_mh_stable = (TH1D*)h_mh_template->Clone("h_mh_stable"); h_mh_stable->SetTitle("status=1"); TH1D* h_mll_stable = (TH1D*)h_mll_template->Clone("h_mll_stable"); h_mll_stable->SetTitle("status=1"); TH1D* h_mjj_stable = (TH1D*)h_mjj_template->Clone("h_mjj_stable"); h_mjj_stable->SetTitle("status=1"); // reconstruction level TH1D* h_mh_rec = (TH1D*)h_mh_template->Clone("h_mh_rec"); h_mh_rec->SetTitle("reconstructed, all"); TH1D* h_mll_rec = (TH1D*)h_mll_template->Clone("h_mll_rec"); h_mll_rec->SetTitle("reconstructed, all"); TH1D* h_mjj_rec = (TH1D*)h_mjj_template->Clone("h_mjj_rec"); h_mjj_rec->SetTitle("reconstructed, all"); TH1D* h_jec[2]; std::string jetName[2]={"leading","subleading"}; for(int i=0; i<2; i++) { h_jec[i] = (TH1D*)h_jec_template->Clone(Form("h_jec_%s",jetName[i].data())); } // separated in dR // const double dRArray[]={0.5,1.0,1.5,2.0,2.5,3.0,3.5}; const double dRArray[]={0.0,1.0,2.0,3.5}; const int NBINS = sizeof(dRArray)/sizeof(dRArray[0])-1; TH1D* h_dR = new TH1D("h_dR","",NBINS,dRArray); TH1D* h_dR_ll = (TH1D*)h_dR_template->Clone("h_dR_ll"); h_dR_ll->SetXTitle("#DeltaR_{ll}"); TH1D* h_dR_jj = (TH1D*)h_dR_template->Clone("h_dR_jj"); h_dR_jj->SetXTitle("#DeltaR_{jj}"); TH1D* h_mll_recdR[NBINS]; TH1D* h_mjj_recdR[NBINS]; TH1D* h_jec_dR[NBINS][2]; for(int i=0; i<NBINS; i++){ h_mll_recdR[i] = (TH1D*)h_mll_template->Clone( Form("h_mll_recdR%d",i)); h_mll_recdR[i]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{ll} < %.1f", dRArray[i],dRArray[i+1])); h_mjj_recdR[i] = (TH1D*)h_mjj_template->Clone( Form("h_mjj_recdR%d",i)); h_mjj_recdR[i]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{jj} < %.1f", dRArray[i],dRArray[i+1])); for(int j=0; j<2; j++){ h_jec_dR[i][j] = (TH1D*)h_jec_template->Clone( Form("h_jec_dR%d_%s", i,jetName[j].data())); h_jec_dR[i][j]->SetTitle(Form("reconstructed, %.1f < #DeltaR_{jj} < %.1f", dRArray[i],dRArray[i+1])); } } Long64_t nentries = fChain->GetEntriesFast(); standalone_LumiReWeighting LumiWeights_central(2012,0); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; double PU_weight = LumiWeights_central.weight(PU_nTrueInt); //================================================================ // STATUS=3 LEVEL //================================================================ TLorentzVector lep1(0,0,0,0); TLorentzVector lep2(0,0,0,0); int lep1Index=-1; int lep2Index=-1; TLorentzVector lep1_post(0,0,0,0); TLorentzVector lep2_post(0,0,0,0); int lep1PostIndex=-1; int lep2PostIndex=-1; TLorentzVector q1(0,0,0,0); TLorentzVector q2(0,0,0,0); int q1Index=-1; int q2Index=-1; const int ZPID=23; int LEPTYPE = -1; for(unsigned int igen=0; igen < genParId_->size(); igen++) { int status = genParSt_->at(igen); int PID = genParId_->at(igen); int momPID = genMomParId_->at(igen); // first status=3 lepton from Z if(status==3 && lep1.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && momPID == ZPID ) { lep1.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); LEPTYPE = abs(PID); lep1Index = igen; } // second status=3 lepton from Z else if (status==3 && lep2.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && momPID== ZPID ) { lep2.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep2Index = igen; } // first status =1 lepton from Z else if(status==1 && lep1_post.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && abs(momPID) == LEPTYPE ) { lep1_post.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep1PostIndex = igen; } // second status=1 lepton from Z else if (status==1 && lep2_post.E() < 1e-6 && (abs(PID) == 11 || abs(PID) == 13) && abs(momPID) == LEPTYPE ) { lep2_post.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); lep2PostIndex = igen; } // first parton from Z else if(status==3 && q1.E() < 1e-6 && abs(PID) < 6 && momPID == ZPID) { q1.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); q1Index = igen; } // second parton from Z else if(status==3 && q2.E() < 1e-6 && abs(PID) < 6 && momPID == ZPID) { q2.SetPtEtaPhiM( genParPt_->at(igen), genParEta_->at(igen), genParPhi_->at(igen), genParM_->at(igen) ); q2Index = igen; } } // end of loop over gen particles /* if(DEBUG==1){ cout << "LEPTYPE = " << LEPTYPE << endl; cout << "lep1 = " << lep1Index << "\t lep2 = " << lep2Index << endl; cout << "lep1Post =" << lep1PostIndex << "\t lep2Post = " << lep2PostIndex << endl; cout << "q1 =" << q1Index << "\t q2Index = " << q2Index << endl; // cout << "jet1 = " << jet1Index << "\t jet2Index = " << jet2Index << endl; } */ if(LEPTYPE==-1)continue; if(lep1Index<0 || lep2Index<0)continue; if(lep1PostIndex<0 || lep2PostIndex<0)continue; if(q1Index<0 || q2Index<0)continue; double mH_parton = (lep1+lep2+q1+q2).M(); double mZll_parton = (lep1+lep2).M(); double mZjj_parton = (q1+q2).M(); h_mh_parton->Fill(mH_parton); h_mll_parton->Fill(mZll_parton); h_mjj_parton->Fill(mZjj_parton); // now look for gen jets //================================================================ // STATUS =1 LEVEL //================================================================ TLorentzVector jet1(0,0,0,0); TLorentzVector jet2(0,0,0,0); int jet1Index=-1, jet2Index=-1; for(unsigned int ijet =0; ijet < genJetPt_->size(); ijet++) { if(matchGenToParton(q1Index,ijet) && jet1.E()<1e-6) { jet1.SetPtEtaPhiE( genJetPt_->at(ijet), genJetEta_->at(ijet), genJetPhi_->at(ijet), genJetE_->at(ijet)); jet1Index = ijet; } else if(matchGenToParton(q2Index,ijet) && jet2.E()<1e-6) { jet2.SetPtEtaPhiE( genJetPt_->at(ijet), genJetEta_->at(ijet), genJetPhi_->at(ijet), genJetE_->at(ijet)); jet2Index = ijet; } } if(jet1Index>=0 && jet2Index>=0){ double mH_particle = (jet1+jet2+lep1_post+lep2_post).M(); double mZll_particle = (lep1_post + lep2_post).M(); double mZjj_particle = (jet1+jet2).M(); h_mh_stable->Fill(mH_particle); h_mll_stable->Fill(mZll_particle); h_mjj_stable->Fill(mZjj_particle); } //================================================================ // RECONSTRUCTION LEVEL //================================================================ int nHiggs=0; int best= -1; // check for MC Truth for(int ih=0; ih<higgsM->size(); ih++){ int nMatched=0; for(int ijet=0; ijet<jetPartonPt->size(); ijet++){ if(jetHiggsIndex->at(ijet)!=ih)continue; int jet_index = jetIndex->at(ijet); // if(DEBUG) // cout << "jet index = " << jet_index << endl; if(jet_index<0)continue; if(jet_index>1)continue; if(jetPartonPt->at(ijet)<1e-6)continue; nMatched++; } // end of loop over jets if(nMatched==2){ nHiggs++; best = ih; } } // end of loop over higgs candidate if(DEBUG && nHiggs>1)cout << "nHiggs=" << nHiggs << endl; if(nHiggs!=1)continue; if(best<0)continue; double mh_rec = higgsM->at(best); double mll_rec = zllM->at(best); double mjj_rec = zjjM->at(best); h_mh_rec->Fill(mh_rec, PU_weight); h_mll_rec->Fill(mll_rec, PU_weight); h_mjj_rec->Fill(mjj_rec, PU_weight); double dr_ll = zlldR->at(best); h_dR_ll->Fill(dr_ll, PU_weight); int dRLL_index = h_dR->FindBin(dr_ll)-1; if(dRLL_index>=0 && dRLL_index < NBINS) h_mll_recdR[dRLL_index]->Fill(mll_rec, PU_weight); double dr_jj = zjjdR->at(best); h_dR_jj->Fill(dr_jj, PU_weight); int dRJJ_index = h_dR->FindBin(dr_jj)-1; if(dRJJ_index>=0 && dRJJ_index < NBINS) h_mjj_recdR[dRJJ_index]->Fill(mjj_rec, PU_weight); for(int ijet=0; ijet < jetIndex->size(); ijet++){ int jet_index = jetIndex->at(ijet); if(jet_index < 0 ) continue; if(jet_index > 1 ) continue; if(jetHiggsIndex->at(ijet)!=best)continue; if(jetGenPt->at(ijet)<1e-6) continue; double ratio = jetPt->at(ijet)/jetGenPt->at(ijet); h_jec[jet_index]->Fill(ratio, PU_weight); if(dRJJ_index>=0 && dRJJ_index <NBINS) { h_jec_dR[dRJJ_index][jet_index]->Fill(ratio, PU_weight); } } // end of loop over jets } TFile* outFile = new TFile(Form("partonmatched_mjj_%s",_inputFileName.data()), "recreate"); h_mh_parton->Write(); h_mll_parton->Write(); h_mjj_parton->Write(); h_mh_stable->Write(); h_mll_stable->Write(); h_mjj_stable->Write(); h_mh_rec->Write(); h_mll_rec->Write(); h_mjj_rec->Write(); h_dR_ll->Write(); h_dR_jj->Write(); for(int j=0; j<2; j++) { h_jec[j]->Write(); for(int i=0; i<NBINS; i++){ h_mll_recdR[i]->Write(); h_mjj_recdR[i]->Write(); h_jec_dR[i][j]->Write(); } } outFile->Close(); }
void ariel_aa::Loop() { TFile plotz("cuts-testing.root","recreate"); // My variables float minMass = 4.75; float maxMass = 6.0; float div = 0.04; int nBins = (maxMass - minMass)/div; float acoll = 0.00; float asig = 0.00; float apt = 0.00; float asmt = 0.00; // ------------ HISTOGRAMS FOR MASS < 1 GeV ------------------------------------------ // dl_sig varied histograms, low mass TH1F* m_1_dlsig_3_0 = new TH1F("m_1_dlsig_3_0", "low mass, dlsig 3_0", 40,minMass,maxMass); TH1F* m_1_dlsig_3_2 = new TH1F("m_1_dlsig_3_2", "low mass, dlsig 3_2", 40,minMass,maxMass); TH1F* m_1_dlsig_3_4 = new TH1F("m_1_dlsig_3_4", "low mass, dlsig 3_4", 40,minMass,maxMass); TH1F* m_1_dlsig_3_6 = new TH1F("m_1_dlsig_3_6", "low mass, dlsig 3_6", 40,minMass,maxMass); TH1F* m_1_dlsig_3_8 = new TH1F("m_1_dlsig_3_8", "low mass, dlsig 3_8", 40,minMass,maxMass); TH1F* m_1_dlsig_4_0 = new TH1F("m_1_dlsig_4_0", "low mass, dlsig 4_0", 40,minMass,maxMass); TH1F* m_1_dlsig_4_2 = new TH1F("m_1_dlsig_4_2", "low mass, dlsig 4_2", 40,minMass,maxMass); TH1F* m_1_dlsig_4_4 = new TH1F("m_1_dlsig_4_4", "low mass, dlsig 4_4", 40,minMass,maxMass); TH1F* m_1_dlsig_4_6 = new TH1F("m_1_dlsig_4_6", "low mass, dlsig 4_6", 40,minMass,maxMass); TH1F* m_1_dlsig_4_8 = new TH1F("m_1_dlsig_4_8", "low mass, dlsig 4_8", 40,minMass,maxMass); TH1F* m_1_dlsig_5_0 = new TH1F("m_1_dlsig_5_0", "low mass, dlsig 5_0", 40,minMass,maxMass); TH1F* m_1_dlsig_5_2 = new TH1F("m_1_dlsig_5_2", "low mass, dlsig 5_2", 40,minMass,maxMass); TH1F* m_1_dlsig_5_4 = new TH1F("m_1_dlsig_5_4", "low mass, dlsig 5_4", 40,minMass,maxMass); TH1F* m_1_dlsig_5_6 = new TH1F("m_1_dlsig_5_6", "low mass, dlsig 5_6", 40,minMass,maxMass); TH1F* m_1_dlsig_5_8 = new TH1F("m_1_dlsig_5_8", "low mass, dlsig 5_8", 40,minMass,maxMass); TH1F* m_1_dlsig_6_0 = new TH1F("m_1_dlsig_6_0", "low mass, dlsig 6_0", 40,minMass,maxMass); if (fChain == 0) return; int aa = 5000; int nn = 0; Int_t nentries = Int_t(fChain->GetEntries()); cout <<"Number of entries " << nentries << endl; Int_t nbytes = 0, nb = 0; Int_t iCountF = 0; Int_t flag = 0; Float_t dm[10]; Int_t count_m = 0; //for (Int_t jentry=0; jentry<10000;jentry++) { for (Int_t jentry=0; jentry<nentries;jentry++) { // cout << "now at event # "<< jentry << endl; Int_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(jentry/aa>nn) cout << "Event #" << jentry << endl; nn = jentry/aa; Int_t iFound = 0; if(PV_npv<1 || PV_ntrk[0]<2) continue; // Fill histograms with vertex info count_m = 0; for(int j=0; j<BPSIK_nvtx; j++) { int jpsi_id = BPSIK_id[j]; //require JPSI if( (PSI_q1[jpsi_id]+PSI_q2[jpsi_id])==0 && PSI_chi2[jpsi_id]<10.0 && PSI_pt1[jpsi_id]>=1.5 && PSI_pt2[jpsi_id]>=1.5 && PSI_smt1[jpsi_id]>=1 && PSI_smt2[jpsi_id]>=1 && PSI_mass[jpsi_id]>2.8 && PSI_mass[jpsi_id]<3.3 && PSI_pt[jpsi_id]>3.) { float mass = BPSIK_mass[j]; float massc1 = BPSIK_massc1[j]; float massc2 = BPSIK_massc2[j]; float chi2 = BPSIK_chi2[j]; float dl = BPSIK_dl[j]; float coll = BPSIK_collinearity[j]; float dl_sig = dl/BPSIK_dlError[j]; float Kch2 = BPSIK_kchi2vtx[j]; float Kpt = BPSIK_kpt[j]; int Ksmt = BPSIK_khits[j]; int flag =0; // Keep kch2, chi2, Ksmt, Kpt, coll constant, vary dl_sig: if(Kch2<=10 && chi2<20 && Ksmt>=0 && Kpt>1.0 && coll>0.95){ if (dl_sig>=3.0){m_1_dlsig_3_0->Fill(massc1);} if (dl_sig>=3.2){m_1_dlsig_3_2->Fill(massc1);} if (dl_sig>=3.4){m_1_dlsig_3_4->Fill(massc1);} if (dl_sig>=3.6){m_1_dlsig_3_6->Fill(massc1);} if (dl_sig>=3.8){m_1_dlsig_3_8->Fill(massc1);} if (dl_sig>=4.0){m_1_dlsig_4_0->Fill(massc1);} if (dl_sig>=4.2){m_1_dlsig_4_2->Fill(massc1);} if (dl_sig>=4.4){m_1_dlsig_4_4->Fill(massc1);} if (dl_sig>=4.6){m_1_dlsig_4_6->Fill(massc1);} if (dl_sig>=4.8){m_1_dlsig_4_8->Fill(massc1);} if (dl_sig>=5.0){m_1_dlsig_5_0->Fill(massc1);} if (dl_sig>=5.2){m_1_dlsig_5_2->Fill(massc1);} if (dl_sig>=5.4){m_1_dlsig_5_4->Fill(massc1);} if (dl_sig>=5.6){m_1_dlsig_5_6->Fill(massc1);} if (dl_sig>=5.8){m_1_dlsig_5_8->Fill(massc1);} if (dl_sig>=6.0){m_1_dlsig_6_0->Fill(massc1);} } } } } plotz->Write(); cout << "COMPLETE!"; }
void plotMsingle_qlike::Loop() { TH1F * h_mass_lik = new TH1F("h_mass_lik","h_mass_lik", 100, 0, 200); TH1F * h_mass_ref = new TH1F("h_mass_ref","h_mass_ref", 100, 0, 200); TH1F * h_mass_csv = new TH1F("h_mass_csv","h_mass_csv", 100, 0, 200); TH1F * h_mass_lik_pt100 = new TH1F("h_mass_lik_pt100","h_mass_lik_pt100", 100, 0, 200); TH1F * h_mass_ref_pt100 = new TH1F("h_mass_ref_pt100","h_mass_ref_pt100", 100, 0, 200); TH1F * h_mass_csv_pt100 = new TH1F("h_mass_csv_pt100","h_mass_csv_pt100", 100, 0, 200); TH1F * h_blik = new TH1F("h_blik","h_blik",100, -1, 1); TH1F * h_blik_match = new TH1F("h_blik_match","h_blik_match",100, -1, 1); Float_t presel = 0.; Float_t bb_efficiency_find = 0; Int_t loopJet_max; if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); float cont_1m=0,cont_2m=0, cont_1m_=0, cont_2m_=0, nevent=0; float cont_1q=0,cont_2q=0, cont_1q_=0, cont_2q_=0; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; JetList jetList_CSV, jetList_bl, jetList_ql; float jet_isMatched2=0, jet_isMatched=0; float jet_isMatched2Q=0, jet_isMatchedQ=0; if (!((Jet_pt[0]>92.)&&(Jet_pt[1]>76.)&&(Jet_pt[2]>64.)&&(Jet_pt[3]>30.))) continue; int loopJet_min = 4; if (nJet<4) loopJet_min=nJet; Double_t btag_max = 0.7; int btag_max1_number = -1; int btag_max2_number = -1; for (int i=0;i<loopJet_min;i++){ if ((Jet_btagCSV[i]>btag_max)&&(Jet_id[i]>0)){ btag_max=Jet_btagCSV[i]; btag_max1_number=i; } } if (!((btag_max1_number>=0))) continue; TLorentzVector Bjet1; Bjet1.SetPtEtaPhiM(Jet_pt[btag_max1_number],Jet_eta[btag_max1_number],Jet_phi[btag_max1_number],Jet_mass[btag_max1_number]); int pt_max1_number = -1; int pt_max2_number = -1; TLorentzVector js[3]; int jcount = 0; int j_num[3] = {}; for (int i=0;i<4;i++){ if ((i!=btag_max1_number)&&(Jet_id[i]>0)) { js[jcount].SetPtEtaPhiM(Jet_pt[jcount], Jet_eta[jcount], Jet_phi[jcount], Jet_mass[jcount]); j_num[jcount] = i; jcount++; } } Float_t deltaEtaJets[3] = {TMath::Abs(js[0].Eta()-js[1].Eta()),TMath::Abs(js[1].Eta()-js[2].Eta()), TMath::Abs(js[0].Eta()-js[2].Eta())}; int eta_num[3][2] = {{0,1}, {1,2} ,{0,2}}; Float_t max_deltaEta = 0.; int max_deltaEta_num = -1; for (int i=0;i<3;i++){ if (deltaEtaJets[i]>max_deltaEta) { max_deltaEta = deltaEtaJets[i]; max_deltaEta_num = i; } } pt_max1_number = j_num[ eta_num[max_deltaEta_num][0]]; pt_max2_number = j_num[ eta_num[max_deltaEta_num][1]]; if (!((pt_max1_number>=0)&&(pt_max2_number>=0))) continue; TLorentzVector Qjet1; Qjet1.SetPtEtaPhiM(Jet_pt[pt_max1_number] ,Jet_eta[pt_max1_number],Jet_phi[pt_max1_number],Jet_mass[pt_max1_number]); TLorentzVector Qjet2; Qjet2.SetPtEtaPhiM(Jet_pt[pt_max2_number],Jet_eta[pt_max2_number],Jet_phi[pt_max2_number],Jet_mass[pt_max2_number]); for (int i=0;i<4;i++){ if ( (i!=btag_max1_number)&&(i!=pt_max1_number)&&(i!=pt_max2_number)&&(Jet_id[i]>0)) btag_max2_number=i; } if (!((btag_max2_number>=0))) continue; TLorentzVector Bjet2; Bjet2.SetPtEtaPhiM(Jet_pt[btag_max2_number],Jet_eta[btag_max2_number],Jet_phi[btag_max2_number],Jet_mass[btag_max2_number]); TLorentzVector qq; qq = Qjet1+Qjet2; Double_t Mqq = qq.M(); Double_t bbDeltaPhi = TMath::Abs(Bjet1.DeltaPhi(Bjet2)); Double_t qqDeltaEta = TMath::Abs(Qjet1.Eta()-Qjet2.Eta()); if (!((Mqq>460)&&(qqDeltaEta>4.1)&&(bbDeltaPhi<1.6))) continue; if (HLT_BIT_HLT_QuadPFJet_SingleBTagCSV_VBF_Mqq460_v!=1) continue; presel+=TMath::Sign(1.,genWeight); int loopJet_max; if (nJet<5) loopJet_max = nJet; else loopJet_max = 5; for(int i=0; i<loopJet_max; i++){ if(Jet_pt[i]<20 || Jet_id[i] <0) continue; jetList_CSV[Jet_btagCSV[i]]=i; jetList_bl[Jet_blikelihood_b[i]]=i; jetList_ql[Jet_blikelihood_q[i]]=i; h_blik->Fill(Jet_blikelihood_b[i]); } int found_array[15] = {}; int found_idx=0; Float_t bb_found = 0; for(int i=0; i<loopJet_max; i++){ if(Jet_pt[i]<20 || Jet_id[i] <0) continue; TLorentzVector hJall; hJall.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); for(int j =0; j<2; j++){ if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5){ TLorentzVector hJet; hJet.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]); if(hJet.DeltaR(hJall)<0.8) {found_array[found_idx] = i; found_idx++; bb_found++;}; } } } int cont=0; TLorentzVector hJ0, hJ1; JetList::reverse_iterator iJet=jetList_bl.rbegin(); do{ int i = iJet->second; if(cont==0) hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if(cont==1) hJ1.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); cont++; iJet++; h_blik->Fill(iJet->first); }while (cont<2); cont=0; TLorentzVector hQ0, hQ1; JetList::reverse_iterator iJet0=jetList_ql.rbegin(); do{ int i = iJet0->second; if(cont==0) hQ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if(cont==1) hQ1.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); cont++; iJet0++; }while (cont<2); for(int j =0; j<2; j++){ if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5) { TLorentzVector hQ; hQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]); if((hQ.DeltaR(hJ1)<0.8 || hQ.DeltaR(hJ0)<0.8)) jet_isMatched++; } } if (bb_found>=2) bb_efficiency_find+=TMath::Sign(1.,genWeight); for(int j =0; j<2; j++){ TLorentzVector hQ; hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]); if((hQ.DeltaR(hQ0)<0.8)||(hQ.DeltaR(hQ1)<0.8)) jet_isMatchedQ++; } int cont1=0; TLorentzVector hJ00, hJ11; for (JetList::reverse_iterator iJet=jetList_CSV.rbegin(); iJet!=jetList_CSV.rend(); ++iJet) { int i = iJet->second; if(cont1==0) hJ00.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if(cont1==1) hJ11.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if (cont1>1) continue; cont1++; } for(int j =0; j<2; j++){ if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5) { TLorentzVector hQ; hQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]); if(hQ.DeltaR(hJ00)<0.8 || hQ.DeltaR(hJ11)<0.8) jet_isMatched2++; } } TLorentzVector hQ00, hQ11; hQ00.SetPtEtaPhiM(Jet_pt[pt_max1_number],Jet_eta[pt_max1_number],Jet_phi[pt_max1_number],Jet_mass[pt_max1_number]); hQ11.SetPtEtaPhiM(Jet_pt[pt_max2_number],Jet_eta[pt_max2_number],Jet_phi[pt_max2_number],Jet_mass[pt_max2_number]); for(int j =0; j<2; j++){ TLorentzVector hQ; hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]); if((hQ.DeltaR(hQ00)<0.8)||(hQ.DeltaR(hQ11)<0.8)) jet_isMatched2Q++; } if(jet_isMatched==1) cont_1m+=TMath::Sign(1.,genWeight); if(jet_isMatched==2) cont_2m+=TMath::Sign(1.,genWeight); if (jet_isMatched2!=2) { for (int k=0;k<found_idx;k++){ // cout<<"event number = "<< jentry<< " not matched = " <<found_array[k]<<" , "; } // cout<<endl; } if(jet_isMatched2==1) cont_1m_+=TMath::Sign(1.,genWeight); if(jet_isMatched2==2) cont_2m_+=TMath::Sign(1.,genWeight); if(jet_isMatchedQ==1) cont_1q+=TMath::Sign(1.,genWeight); if(jet_isMatchedQ==2) cont_2q+=TMath::Sign(1.,genWeight); if(jet_isMatched2Q==1) cont_1q_+=TMath::Sign(1.,genWeight); if(jet_isMatched2Q==2) cont_2q_+=TMath::Sign(1.,genWeight); nevent++; h_mass_lik->Fill((hJ0+hJ1).M()); h_mass_csv->Fill((hJ00+hJ11).M()); h_mass_ref->Fill(H_mass); if(V_pt>100) {h_mass_lik_pt100->Fill((hJ0+hJ1).M()); h_mass_csv_pt100->Fill((hJ00+hJ11).M()); h_mass_ref_pt100->Fill(H_mass); } } // std::cout<<" purity b-lik "<<cont_1m/nevent<< " 1/2 "<<cont_2m/nevent <<std::endl; // std::cout<<" purity csv "<<cont_1m_/nevent<< " 1/2 "<<cont_2m_/nevent <<std::endl; std::cout<<" preselection purity b-lik "<<cont_1m/presel<< " 1/2 "<<cont_2m/presel <<std::endl; std::cout<<" preselection purity csv "<<cont_1m_/presel<< " 1/2 "<<cont_2m_/presel << " , presel = "<< presel<<std::endl; std::cout<<" preselection purity q-lik "<<cont_1q/presel<< " 1/2 "<<cont_2q/presel <<std::endl; std::cout<<" preselection purity q_pt "<<cont_1q_/presel<< " 1/2 "<<cont_2q_/presel << " , presel = "<< presel<<std::endl; std::cout<<"bb efficiency to find = " << bb_efficiency_find/presel<<endl; gStyle->SetOptStat(0); TCanvas *c = new TCanvas("c","c",700,700); c->cd(); h_mass_lik->SetLineColor(4); h_mass_lik->GetXaxis()->SetTitle("m_{H} (GeV)"); h_mass_lik->SetTitle("b-likelihood order"); h_mass_lik->Draw(""); h_mass_csv->SetLineColor(2); h_mass_csv->SetTitle("csv order"); h_mass_csv->Draw("same"); h_mass_ref->SetTitle("highest dijet"); h_mass_ref->Draw("same"); c->Print("c.png"); TCanvas *c1 = new TCanvas("c1","c1",700,700); c1->cd(); h_mass_ref_pt100->GetXaxis()->SetTitle("m_{H} (GeV)"); h_mass_lik_pt100->SetTitle("b-likelihood order"); h_mass_csv_pt100->SetTitle("csv order"); h_mass_ref_pt100->SetTitle("csv order"); h_mass_lik_pt100->SetLineColor(4); h_mass_lik_pt100->Draw(""); h_mass_ref_pt100->Draw("same"); h_mass_csv_pt100->SetLineColor(2); h_mass_csv_pt100->Draw("same"); c1->Print("c1.png"); TCanvas *d = new TCanvas("d","d"); d->cd(); d->SetLogy(); h_blik->Draw(); d->Print("d.png"); }
void myana::Loop() { // In a ROOT session, you can do: if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; cout << "Booking pTmax histograms..." << endl; BookHistos(); // Booking pTmax histograms // Making only the desired branches visible // fChain->SetBranchStatus("*", 0); fChain->SetBranchStatus("njets", 1); fChain->SetBranchStatus("jgood", 1); fChain->SetBranchStatus("evtgood", 1); fChain->SetBranchStatus("jy", 1); fChain->SetBranchStatus("jpt", 1); fChain->SetBranchStatus("jphi", 1); fChain->SetBranchStatus("jt15", 1); fChain->SetBranchStatus("jt25", 1); fChain->SetBranchStatus("jt45", 1); fChain->SetBranchStatus("jt65", 1); fChain->SetBranchStatus("jt95", 1); fChain->SetBranchStatus("jt125", 1); //events processing for p17data for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); if (jentry > 0 && jentry%100000 == 0) cout << jentry << " events processed." << endl; Float_t JET_PT_CUT =30.0; // PT CUT 30 GEV //applying jet cuts if (evtgood && njets >=2 && (jgood[0] && jgood[1]) && (jpt[0] >= JET_PT_CUT && jpt[1] >= JET_PT_CUT)) { // pT1 > pT2 always => pT2 > 40 GeV is enough. double pTmax, absY1 = fabs(jy[0]), absY2 = fabs(jy[1]); if (jpt[0] >= jpt[1]) pTmax = jpt[0]; // pTmax is always the first jet. else pTmax = jpt[1]; // This is never encountered. if (absY1 < 0.5 && absY2 < 0.5) { // Both jets are in central region if (jt15) trigJT015y1->Fill(pTmax); if (jt25) trigJT025y1->Fill(pTmax); if (jt45) trigJT045y1->Fill(pTmax); if (jt65) trigJT065y1->Fill(pTmax); if (jt95) trigJT095y1->Fill(pTmax); if (jt125) trigJT125y1->Fill(pTmax); } else if ((absY1 > 0.5 && absY1 < 1.5) && (absY2 > 0.5 && absY2 < 1.5) && (jy[0]*jy[1] < 0)) { // Both jets are in ICR and on opposite sides if (jt15) trigJT015y2->Fill(pTmax); if (jt25) trigJT025y2->Fill(pTmax); if (jt65) trigJT065y2->Fill(pTmax); if (jt95) trigJT095y2->Fill(pTmax); if (jt125) trigJT125y2->Fill(pTmax); } else if ((absY1 > 1.5 && absY1 < 2.5) && (absY2 > 1.5 && absY2 < 2.5) && (jy[0]*jy[1] < 0)) { // Both jets are in forward region and on opposite sides if (jt15) trigJT015y3->Fill(pTmax); if (jt25) trigJT025y3->Fill(pTmax); if (jt45) trigJT045y3->Fill(pTmax); if (jt65) trigJT065y3->Fill(pTmax); if (jt95) trigJT095y3->Fill(pTmax); if (jt125) trigJT125y3->Fill(pTmax); } } } cout << "Writing all histograms..." << endl; WriteHistos(); cout << "Histograms written to file. Cleaning up now..." << endl; // Cleaning up all pointers // Cleanup(); }
void CreateTree::Loop() { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; TFile file("spring15_vbf_powheg_new_blike_125_08.root","recreate"); TTree *tree0 = new TTree("Jet_tree_b","Jet_tree_b"); TreeJets TreeJet; tree0->Branch("Jet_pt",&TreeJet.pt,"Jet_pt/F"); tree0->Branch("Jet_eta",&TreeJet.eta,"Jet_eta/F"); tree0->Branch("Jet_btagCSV",&TreeJet.btagCSV,"Jet_btagCSV/F"); tree0->Branch("Jet_pt_idx",&TreeJet.pt_idx,"Jet_pt_idx/I"); tree0->Branch("Jet_eta_idx",&TreeJet.eta_idx,"Jet_eta_idx/I"); tree0->Branch("Jet_btagCSV_idx",&TreeJet.btagCSV_idx,"Jet_btagCSV_idx/I"); tree0->Branch("Jet_btag_idx",&TreeJet.btag_idx,"Jet_btag_idx/I"); tree0->Branch("Jet_chMult",&TreeJet.ch_mult,"Jet_chMult/I"); tree0->Branch("Jet_ptd",&TreeJet.ptd,"Jet_ptd/F"); tree0->Branch("Jet_leadTrackPt",&TreeJet.leadTrPt,"Jet_leadTrPt"); tree0->Branch("Jet_axis2",&TreeJet.axis2, "Jet_axis2"); tree0->Branch("Jet_b_matched",&TreeJet.b_matched,"Jet_b_matched/I"); tree0->Branch("Jet_q_matched",&TreeJet.q_matched,"Jet_q_matched/I"); tree0->Branch("Jet_n_matched",&TreeJet.n_matched,"Jet_n_matched/I"); Float_t bb_efficiency_find=0.; Float_t bb_efficiency=0.; Float_t qq_efficiency_find=0.; Float_t qq_efficiency=0.; Float_t presel =0.; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; JetList jetList_CSV, jetList_pt, jetList_eta; Float_t jet_isMatched2 = 0; Float_t jet_isMatchedQ = 0; if (genWeight<0) continue; if (!((Jet_pt[0]>92.)&&(Jet_pt[1]>76.)&&(Jet_pt[2]>64.)&&(Jet_pt[3]>30.))) continue; int loopJet_min = 6; if (nJet<6) loopJet_min=nJet; Double_t btag_max = 0.4; int btag_max1_number = -1; int btag_max2_number = -1; for (int i=0;i<loopJet_min;i++){ if ((Jet_btagCSV[i]>btag_max)&&(Jet_id[i]>0)){ btag_max=Jet_btagCSV[i]; btag_max1_number=i; } } btag_max = 0.4; for (int i=0;i<loopJet_min;i++){ if ((Jet_btagCSV[i]>btag_max)&&(i!=btag_max1_number)&&(Jet_id[i]>0)) { btag_max=Jet_btagCSV[i]; btag_max2_number=i; } } if (!((btag_max1_number>=0)&&(btag_max2_number>=0))) continue; TLorentzVector Bjet1; Bjet1.SetPtEtaPhiM(Jet_pt[btag_max1_number],Jet_eta[btag_max1_number],Jet_phi[btag_max1_number],Jet_mass[btag_max1_number]); TLorentzVector Bjet2; Bjet2.SetPtEtaPhiM(Jet_pt[btag_max2_number],Jet_eta[btag_max2_number],Jet_phi[btag_max2_number],Jet_mass[btag_max2_number]); Double_t pt_max = 20.; int pt_max1_number = -1; int pt_max2_number = -1; for (int i=0;i<loopJet_min;i++){ if ((Jet_pt[i]>pt_max)&&(i!=btag_max1_number)&&(i!=btag_max2_number)&&(Jet_id[i]>0)) { pt_max=Jet_pt[i]; pt_max1_number=i; } } pt_max = 20.; for (int i=0;i<loopJet_min;i++){ if ((Jet_pt[i]>pt_max)&&(i!=btag_max1_number)&&(i!=btag_max2_number)&&(i!=pt_max1_number)&&(Jet_id[i]>0)) { pt_max=Jet_pt[i]; pt_max2_number=i; } } if (!((pt_max1_number>=0)&&(pt_max2_number>=0))) continue; TLorentzVector Qjet1; Qjet1.SetPtEtaPhiM(Jet_pt[pt_max1_number],Jet_eta[pt_max1_number],Jet_phi[pt_max1_number],Jet_mass[pt_max1_number]); TLorentzVector Qjet2; Qjet2.SetPtEtaPhiM(Jet_pt[pt_max2_number],Jet_eta[pt_max2_number],Jet_phi[pt_max2_number],Jet_mass[pt_max2_number]); TLorentzVector qq; qq = Qjet1+Qjet2; Double_t Mqq = qq.M(); Double_t bbDeltaPhi = TMath::Abs(Bjet1.DeltaPhi(Bjet2)); Double_t qqDeltaEta = TMath::Abs(Qjet1.Eta()-Qjet2.Eta()); if (!((Mqq>200)&&(qqDeltaEta>1.2)&&(bbDeltaPhi<2.4))) continue; if (HLT_BIT_HLT_QuadPFJet_DoubleBTagCSV_VBF_Mqq200_v!=1) continue; int loopJet_max = 7; if (nJet<7) loopJet_max = nJet; for(int i=0; i<loopJet_max; i++){ if(Jet_pt[i]<20 || Jet_id[i] <0) continue; if (Jet_btagCSV[i]==-10) Jet_btagCSV[i]=0; if (Jet_btagCSV[i]>1) Jet_btagCSV[i]=1.; jetList_CSV[Jet_btagCSV[i]]=i; jetList_pt[Jet_pt[i]]=i; jetList_eta[TMath::Abs(Jet_eta[i])]=i; } Float_t bb_found = 0.; Float_t qq_found = 0.; Float_t eta_sort[30]; Float_t btag_sort[30]; for (int i=0;i<loopJet_max;i++){ if ((Jet_pt[i]>20)&&(Jet_id[i]>0)) { TreeJet.eta = TMath::Abs(Jet_eta[i]); eta_sort[i] = TMath::Abs(Jet_eta[i]); TreeJet.btagCSV=Jet_btagCSV[i]; btag_sort[i] = Jet_btagCSV[i]; } } bubblesort(eta_sort,loopJet_max); bubblesort2(btag_sort,loopJet_max); /* for (int i=0;i<loopJet_max;i++){ cout<<btag_sort[i]<<" "<<i<<endl; }*/ int btag_0_num = 0; for(int i=0; i<loopJet_max; i++){ if(Jet_pt[i]<20 || Jet_id[i] <0) continue; TreeJet.b_matched=0; TreeJet.q_matched=0; TreeJet.n_matched=0; TLorentzVector hJ0; TreeJet.pt=Jet_pt[i]; TreeJet.eta=TMath::Abs(Jet_eta[i]); TreeJet.btagCSV=Jet_btagCSV[i]; TreeJet.ptd=Jet_ptd[i]; TreeJet.ch_mult=Jet_chMult[i]; TreeJet.axis2=Jet_axis2[i]; TreeJet.leadTrPt=Jet_leadTrackPt[i]; TreeJet.pt_idx = i; TreeJet.eta_idx = find(eta_sort,TreeJet.eta,loopJet_max); TreeJet.btagCSV_idx = find(btag_sort,TreeJet.btagCSV,loopJet_max); if ((TreeJet.btagCSV==0)&&(btag_0_num==0)) { btag_0_num = find(btag_sort,TreeJet.btagCSV,loopJet_max); TreeJet.btagCSV_idx = btag_0_num; } else if ((TreeJet.btagCSV==0)&&(btag_0_num!=0)) { btag_0_num++; TreeJet.btagCSV_idx = btag_0_num; } TreeJet.btag_idx = Jet_btagIdx[i]; hJ0.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); for(int j =0; j<2; j++){ if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5){ TLorentzVector hQQ; hQQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]); if(hQQ.DeltaR(hJ0)<0.8){ TreeJet.b_matched =1; bb_found++; } } } for(int j =0; j<2; j++){ TLorentzVector hQ; hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]); if(hQ.DeltaR(hJ0)<0.8) {TreeJet.q_matched = 1; qq_found++;} } if ((TreeJet.b_matched==0)&&(TreeJet.q_matched==0)) TreeJet.n_matched=1; tree0->Fill(); } int cont1=0; TLorentzVector hJ00, hJ11; for (JetList::reverse_iterator iJet=jetList_CSV.rbegin(); iJet!=jetList_CSV.rend(); ++iJet) { int i = iJet->second; if(cont1==0) hJ00.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if(cont1==1) hJ11.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); if (cont1>1) continue; cont1++; } for(int j =0; j<2; j++){ if(TMath::Abs(GenBQuarkFromH_pdgId[j])==5) { TLorentzVector hQ; hQ.SetPtEtaPhiM(GenBQuarkFromH_pt[j],GenBQuarkFromH_eta[j],GenBQuarkFromH_phi[j],GenBQuarkFromH_mass[j]); if(hQ.DeltaR(hJ00)<0.8 || hQ.DeltaR(hJ11)<0.8) jet_isMatched2++; } } TLorentzVector hQ00, hQ11; hQ00.SetPtEtaPhiM(Jet_pt[pt_max1_number],Jet_eta[pt_max1_number],Jet_phi[pt_max1_number],Jet_mass[pt_max1_number]); hQ11.SetPtEtaPhiM(Jet_pt[pt_max2_number],Jet_eta[pt_max2_number],Jet_phi[pt_max2_number],Jet_mass[pt_max2_number]); for(int j =0; j<2; j++){ TLorentzVector hQ; hQ.SetPtEtaPhiM(GenHiggsSisters_pt[j],GenHiggsSisters_eta[j],GenHiggsSisters_phi[j],GenHiggsSisters_mass[j]); if((hQ.DeltaR(hQ00)<0.8)||(hQ.DeltaR(hQ11)<0.8)) jet_isMatchedQ++; } if (jet_isMatched2==2) bb_efficiency+=TMath::Sign(1.,genWeight); if (jet_isMatchedQ==2) qq_efficiency+=TMath::Sign(1.,genWeight); if (bb_found>=2) bb_efficiency_find+=TMath::Sign(1.,genWeight); if (qq_found>=2) qq_efficiency_find+=TMath::Sign(1.,genWeight); presel+=TMath::Sign(1.,genWeight); } ofstream out("spring15_powheg_125_08.txt"); out<<"bb efficiency to find b-jets = "<<bb_efficiency_find/presel<<endl; out<<"bb efficiency to match b-jets = "<<bb_efficiency/presel<<endl; out<<"qq efficiency to find q-jets = "<<qq_efficiency_find/presel<<endl; out<<"qq efficiency to match q-jets = "<<qq_efficiency/presel<<endl; cout<<"bb efficiency to find b-jets = "<<bb_efficiency_find/presel<<endl; cout<<"bb efficiency to match b-jets = "<<bb_efficiency/presel<<endl; cout<<"qq efficiency to find q-jets = "<<qq_efficiency_find/presel<<endl; cout<<"qq efficiency to match q-jets = "<<qq_efficiency/presel<<endl; file.Write(); file.Close(); }
void ztree::ffgammajet(std::string outfname, int centmin, int centmax, float phoetmin, float phoetmax, std::string gen) { string tag = outfname; string s_alpha = gen; if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TFile * fout = new TFile(Form("%s_%s_%s_%d_%d.root",outfname.data(),tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),"recreate"); TH2D * hsubept = new TH2D(Form("hsubept_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100); TH2D * hsubept_refcone = new TH2D(Form("hsubept_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100); TH1D * hjetpt = new TH1D(Form("hjetpt_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";jet p_{T};"),20,0,500); TH1D * hjetgendphi = new TH1D(Form("hjetgendphi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#DeltaR_{gen,reco};"),20,0,0.1); TH1D * hgammaff = new TH1D(Form("hgammaff_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";z;"),20,0,1); TH1D * hgammaffxi = new TH1D(Form("hgammaffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaffxi_refcone = new TH1D(Form("hgammaffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaphoffxi = new TH1D(Form("hgammaphoffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaphoffxi_refcone = new TH1D(Form("hgammaphoffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); Long64_t nbytes = 0, nb = 0; cout<<phoetmin<<" "<<phoetmax<<endl; for (Long64_t jentry=0; jentry<nentries;jentry++) { if(jentry%10000==0) { cout<<jentry<<"/"<<nentries<<endl; } Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; // cout<<njet<<endl; // if(jentry > 10000) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(hiBin < centmin || hiBin >= centmax) continue; //centrality cut if(nPho!=1) continue; // if(phoEt[0]<phoetmin || phoEt[0]>phoetmax) continue; if(weight==0) weight=1; // cout<<njet<<endl; if(gen.compare("gen")==0) { for (int ijet = 0; ijet < njet; ijet++) { if(mcEt[pho_genMatchedIndex[0]]<phoetmin || mcEt[pho_genMatchedIndex[0]]>phoetmax) continue; if( nPho==2 ) continue; if( jetpt[ijet]<40 ) continue; //jet pt Cut if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone if( jetID[ijet]==0 ) continue; //redundant in this skim (all true) if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue; hjetpt->Fill(jetpt[ijet]); float denrecodphi = acos(cos(jetphi[ijet] - gjetphi[ijet])); hjetgendphi->Fill(denrecodphi); TLorentzVector vjet; vjet.SetPtEtaPhiM(gjetpt[ijet],gjeteta[ijet],gjetphi[ijet],0); for(int igen = 0 ; igen < mult ; ++igen) { if(!(abs(pdg[igen])==11 || abs(pdg[igen])==13 || abs(pdg[igen])==211 || abs(pdg[igen])==2212 || abs(pdg[igen])==321)) continue; if(sube[igen] != 0) continue; float dr = genjettrk_dr(igen,ijet); float dr_refcone = genrefconetrk_dr(igen,ijet); if(dr<0.3) { TLorentzVector vtrack; vtrack.SetPtEtaPhiM(pt[igen],eta[igen],phi[igen],0); float angle = vjet.Angle(vtrack.Vect()); float z = pt[igen]*cos(angle)/gjetpt[ijet]; float zpho = pt[igen]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaff->Fill(z); hgammaffxi->Fill(xi); hgammaphoffxi->Fill(xipho); hsubept->Fill(sube[igen],pt[igen]); // cout<<jetpt[ijet]<<endl; } if(dr_refcone<0.3) { float z = pt[igen]/gjetpt[ijet]; float zpho = pt[igen]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaffxi_refcone->Fill(xi); hgammaphoffxi_refcone->Fill(xipho); hsubept_refcone->Fill(sube[igen],pt[igen]); } } } } else { for (int ijet = 0; ijet < njet; ijet++) { if( nPho==2 ) continue; if( phoEt[0]*phoCorr[0]<phoetmin || phoEt[0]*phoCorr[0]>phoetmax) continue; if( jetpt[ijet]<40 ) continue; //jet pt Cut if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone if( jetID[ijet]==0 ) continue; //redundant in this skim (all true) if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue; hjetpt->Fill(jetpt[ijet]); TLorentzVector vjet; vjet.SetPtEtaPhiM(jetpt[ijet],jeteta[ijet],jetphi[ijet],0); for (int itrk = 0; itrk < nTrk; itrk++) { float dr = jettrk_dr(itrk,ijet); // float dr = genjetrecotrk_dr(itrk,ijet); float dr_refcone = refconetrk_dr(itrk,ijet); // float dr_refcone = genrefconerecotrk_dr(itrk,ijet); if(dr<0.3) { TLorentzVector vtrack; vtrack.SetPtEtaPhiM(trkPt[itrk],trkEta[itrk],trkPhi[itrk],0); float angle = vjet.Angle(vtrack.Vect()); float z = trkPt[itrk]*cos(angle)/jetpt[ijet]; float zpho = trkPt[itrk]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaff->Fill(z,trkWeight[itrk]); hgammaffxi->Fill(xi,trkWeight[itrk]); hgammaphoffxi->Fill(xipho,trkWeight[itrk]); // hgammaff->Fill(z); // hgammaffxi->Fill(xi); // hgammaphoffxi->Fill(xipho); // cout<<jetpt[ijet]<<endl; } if(dr_refcone<0.3) { float z = trkPt[itrk]/jetpt[ijet]; float zpho = trkPt[itrk]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaffxi_refcone->Fill(xi,trkWeight[itrk]); hgammaphoffxi_refcone->Fill(xipho,trkWeight[itrk]); // hgammaffxi_refcone->Fill(xi); // hgammaphoffxi_refcone->Fill(xipho); } } // photons: normal mode power mode // pho 40 trigger // photon spike cuts etc // phoet > 35 // phoet > 40 after correction // haven't made it yet // phoeta < 1.44 // sumiso < 1 GeV // h/em < 0.1 // sigmaetaeta < 0.01 // jets: // some pt // jeteta < 1.6 // some id cuts // none yet but we'll add some // ak3pupf jets // delphi > 7 pi / 8 } } /* */ } fout->Write(); fout->Close(); }
void angular::Loop() { if (fChain == 0) return; TH1F *Hin_cosThetaStarLead = new TH1F("Hin_cosThetaStarLead","Hin_cosThetaStarLead",100,-1,1); TH1F *Hin_cosThetaStarSublead = new TH1F("Hin_cosThetaStarSublead","Hin_cosThetaStarSublead",100,-1,1); TH1F *Hin_deltaEta = new TH1F("Hin_deltaEta","Hin_deltaEta",100,-5,5); TH1F *Hin_deltaPhi = new TH1F("Hin_deltaPhi","Hin_deltaPhi",50,-1,1); TH1F *Hout_cosThetaStarLead = new TH1F("Hout_cosThetaStarLead","Hout_cosThetaStarLead",100,-1,1); TH1F *Hout_cosThetaStarSublead = new TH1F("Hout_cosThetaStarSublead","Hout_cosThetaStarSublead",100,-1,1); TH1F *Hout_deltaEta = new TH1F("Hout_deltaEta","Hout_deltaEta",100,-5,5); TH1F *Hout_deltaPhi = new TH1F("Hout_deltaPhi","Hout_deltaPhi",50,-1,1); Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; TLorentzVector myLeadGamma(0,0,0,0); myLeadGamma.SetPtEtaPhiM(leadPt, leadEta, leadPhi, 0.); TLorentzVector mySubleadGamma(0,0,0,0); mySubleadGamma.SetPtEtaPhiM(subleadPt, subleadEta, subleadPhi, 0.); TLorentzVector grav = myLeadGamma + mySubleadGamma; TLorentzVector lead_Gstar(myLeadGamma); lead_Gstar.Boost(-grav.BoostVector()); TLorentzVector sublead_Gstar(mySubleadGamma); sublead_Gstar.Boost(-grav.BoostVector()); float leadCosThStar = lead_Gstar.CosTheta(); float subleadCosThStar = sublead_Gstar.CosTheta(); float deltaEta = leadEta-subleadEta; float deltaPhi = myLeadGamma.DeltaPhi(mySubleadGamma); float cosDPhi = cos(deltaPhi); // for data if (puweight==0) puweight=1; if (fabs(mass-755)<20){ Hin_cosThetaStarLead -> Fill(leadCosThStar,puweight); Hin_cosThetaStarSublead -> Fill(subleadCosThStar,puweight); Hin_deltaEta->Fill(deltaEta,puweight); Hin_deltaPhi->Fill(cosDPhi,puweight); } else { Hout_cosThetaStarLead -> Fill(leadCosThStar,puweight); Hout_cosThetaStarSublead -> Fill(subleadCosThStar,puweight); Hout_deltaEta->Fill(deltaEta,puweight); Hout_deltaPhi->Fill(cosDPhi,puweight); } } TFile outfile("outfile.root","RECREATE"); Hout_cosThetaStarLead->Write(); Hout_cosThetaStarSublead->Write(); Hout_deltaEta->Write(); Hout_deltaPhi->Write(); Hin_cosThetaStarLead->Write(); Hin_cosThetaStarSublead->Write(); Hin_deltaEta->Write(); Hin_deltaPhi->Write(); }
void makeControlPlots::Loop() { // In a ROOT session, you can do: // Root > .L makeControlPlots.C // Root > makeControlPlots t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METAHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (!intervals) return; if (fChain == 0) return; Long64_t nentries = fChain->GetEntries(); std::vector<variablesToControl> controls; int kIntervals=intervals->numberOfIntervals(); controls.reserve(kIntervals); cout<<"creating variables"<<endl; for(int iinterval=0;iinterval<kIntervals;iinterval++){ controls[iinterval].reset(); } Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; controls[time_interval-1].counter++; int tt=iTT(ieta,iphi,sign); int xtal=iXtal(ieta,iphi,sign); RMSet=RMSet*errEtCorr_factor; RMSetNoCorr=RMSetNoCorr*errEtCorr_factor; //Histories by eta ring controls[time_interval-1].nhitMean[ieta-1][sign]+=nHits; controls[time_interval-1].etSumMean[ieta-1][sign]+=et; controls[time_interval-1].etMean[ieta-1][sign]+=et/(float)nHits; controls[time_interval-1].etMeanRMS[ieta-1][sign]+=nHits*pow(RMSet,2); controls[time_interval-1].etABRatio[ieta-1][sign]+=etB/etA; controls[time_interval-1].etABRatioRMS[ieta-1][sign]+=0.05*0.05*(etB/etA)*(etB/etA); //provisional value controls[time_interval-1].etMeanNoCorr[ieta-1][sign]+=etNoCorr/(float)nHits; controls[time_interval-1].etMeanNoCorrRMS[ieta-1][sign]+=nHits*pow(RMSetNoCorr,2); controls[time_interval-1].lcMean[ieta-1][sign]+=lc; controls[time_interval-1].lcMeanRMS[ieta-1][sign]+=nHits*pow(RMSlc,2); controls[time_interval-1].tlMean[ieta-1][sign]+=TMath::Exp(-1*TMath::Log(lc)/alphaDB(sign,ieta,iphi)); controls[time_interval-1].tlMeanRMS[ieta-1][sign]+=nHits*pow(RMSlc*alphaDB(sign,ieta,iphi),2); //approximation controls[time_interval-1].counterEta[ieta-1][sign]++; //Histories by tt controls[time_interval-1].nhitTowerMean[tt-1]+=nHits; controls[time_interval-1].etSumTowerMeanVsEtRef[tt-1]+=et; controls[time_interval-1].etTowerMean[tt-1]+=et/(float)nHits; controls[time_interval-1].etTowerMeanRMS[tt-1]+=nHits*pow(RMSet,2); controls[time_interval-1].etTowerMeanNoCorr[tt-1]+=etNoCorr/float(nHits); controls[time_interval-1].etTowerMeanNoCorrRMS[tt-1]+=nHits*pow(RMSetNoCorr,2); controls[time_interval-1].lcTowerMean[tt-1]+=lc; controls[time_interval-1].lcTowerMeanRMS[tt-1]+=nHits*pow(RMSlc,2); controls[time_interval-1].tlTowerMean[tt-1]+=TMath::Exp(-1*TMath::Log(lc)/alphaDB(sign,ieta,iphi)); controls[time_interval-1].tlTowerMeanRMS[tt-1]+=nHits*pow(RMSlc*alphaDB(sign,ieta,iphi),2); controls[time_interval-1].counterTower[tt-1]++; //Histories by xtal controls[time_interval-1].nhitXtalMean[xtal-1]+=nHits; controls[time_interval-1].etSumXtalMeanVsEtRef[xtal-1]+=et; controls[time_interval-1].etXtalMean[xtal-1]+=et/(float)nHits; controls[time_interval-1].etXtalMeanRMS[xtal-1]+=nHits*pow(RMSet,2); controls[time_interval-1].etXtalMeanNoCorr[xtal-1]+=etNoCorr/(float)nHits; controls[time_interval-1].etXtalMeanNoCorrRMS[xtal-1]+=nHits*pow(RMSetNoCorr,2); controls[time_interval-1].lcXtalMean[xtal-1]+=lc; controls[time_interval-1].lcXtalMeanRMS[xtal-1]+=nHits*pow(RMSlc,2); controls[time_interval-1].tlXtalMean[xtal-1]+=TMath::Exp(-1*TMath::Log(lc)/alphaDB(sign,ieta,iphi)); controls[time_interval-1].tlXtalMeanRMS[xtal-1]+=nHits*pow(RMSlc*alphaDB(sign,ieta,iphi),2); controls[time_interval-1].counterXtal[xtal-1]++; } int counterTotal=0; float nInterval[kIntervals]; float nIntervalError[kIntervals]; // float nIntervalError[kInterval]; float etTotal=0; float etTotalNoCorr=0; cout<<"loop ended"<<endl; for(int iinterval=0;iinterval<kIntervals;iinterval++){ if(controls[iinterval].counter!=0){ for (int i=0;i<kBarlRings;++i) { for(int j=0;j<kSides;++j){ controls[iinterval].etSumMean[i][j]=controls[iinterval].etSumMean[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].etMean[i][j]=controls[iinterval].etMean[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].etMeanRMS[i][j]=sqrt(controls[iinterval].etMeanRMS[i][j])/(controls[iinterval].nhitMean[i][j]);// i want eerror on mean std::cout << "i " << i << " j " << j << " etMean " << controls[iinterval].etMean[i][j] << " etMeanErr " << controls[iinterval].etMeanRMS[i][j] << std::endl; controls[iinterval].etMeanNoCorr[i][j]= controls[iinterval].etMeanNoCorr[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].etMeanNoCorrRMS[i][j]= sqrt(controls[iinterval].etMeanNoCorrRMS[i][j])/(controls[iinterval].nhitMean[i][j]);// i want eerror on mean controls[iinterval].etABRatio[i][j]=controls[iinterval].etABRatio[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].etABRatioRMS[i][j]=sqrt(controls[iinterval].etABRatioRMS[i][j])/sqrt(controls[iinterval].counterEta[i][j]);// i want eerror on mean controls[iinterval].lcMeanRMS[i][j]= sqrt(controls[iinterval].lcMeanRMS[i][j])/(controls[iinterval].nhitMean[i][j]);// i want eerror on mean controls[iinterval].lcMean[i][j]=controls[iinterval].lcMean[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].tlMeanRMS[i][j]= sqrt(controls[iinterval].tlMeanRMS[i][j])/(controls[iinterval].nhitMean[i][j]);// i want eerror on mean controls[iinterval].tlMean[i][j]=controls[iinterval].tlMean[i][j]/controls[iinterval].counterEta[i][j]; controls[iinterval].nhitMean[i][j]=controls[iinterval].nhitMean[i][j]/controls[iinterval].counterEta[i][j]; } } for (int i=0;i<kSM*kTowerPerSM;++i) { controls[iinterval].etSumTowerMeanVsEtRef[i]=controls[iinterval].etSumTowerMeanVsEtRef[i]/controls[iinterval].counterTower[i]; controls[iinterval].etTowerMean[i]=controls[iinterval].etTowerMean[i]/controls[iinterval].counterTower[i]; controls[iinterval].etTowerMeanRMS[i]=sqrt(controls[iinterval].etTowerMeanRMS[i])/(controls[iinterval].nhitTowerMean[i]);// i want eerror on mean controls[iinterval].etTowerMeanNoCorr[i]= controls[iinterval].etTowerMeanNoCorr[i]/controls[iinterval].counterTower[i]; controls[iinterval].etTowerMeanNoCorrRMS[i]= sqrt(controls[iinterval].etTowerMeanNoCorrRMS[i])/(controls[iinterval].nhitTowerMean[i]);// i want eerror on mean controls[iinterval].lcTowerMean[i]=controls[iinterval].lcTowerMean[i]/controls[iinterval].counterTower[i]; controls[iinterval].lcTowerMeanRMS[i]= sqrt(controls[iinterval].lcTowerMeanRMS[i])/(controls[iinterval].nhitTowerMean[i]);// i want eerror on mean controls[iinterval].tlTowerMean[i]=controls[iinterval].tlTowerMean[i]/controls[iinterval].counterTower[i]; controls[iinterval].tlTowerMeanRMS[i]= sqrt(controls[iinterval].tlTowerMeanRMS[i])/(controls[iinterval].nhitTowerMean[i]);// i want eerror on mean controls[iinterval].nhitTowerMean[i]=controls[iinterval].nhitTowerMean[i]/controls[iinterval].counterTower[i]; } for (int i=0;i<kSM*kXtalPerSM;++i) { controls[iinterval].etSumXtalMeanVsEtRef[i]=controls[iinterval].etSumXtalMeanVsEtRef[i]/controls[iinterval].counterXtal[i]; controls[iinterval].etXtalMean[i]=controls[iinterval].etXtalMean[i]/controls[iinterval].counterXtal[i]; controls[iinterval].etXtalMeanRMS[i]=sqrt(controls[iinterval].etXtalMeanRMS[i])/(controls[iinterval].nhitXtalMean[i]);// i want eerror on mean controls[iinterval].etXtalMeanNoCorr[i]= controls[iinterval].etXtalMeanNoCorr[i]/controls[iinterval].counterXtal[i]; controls[iinterval].etXtalMeanNoCorrRMS[i]= sqrt(controls[iinterval].etXtalMeanNoCorrRMS[i])/(controls[iinterval].nhitXtalMean[i]);// i want eerror on mean controls[iinterval].lcXtalMean[i]=controls[iinterval].lcXtalMean[i]/controls[iinterval].counterXtal[i]; controls[iinterval].lcXtalMeanRMS[i]= sqrt(controls[iinterval].lcXtalMeanRMS[i])/(controls[iinterval].nhitXtalMean[i]);// i want eerror on mean controls[iinterval].tlXtalMean[i]=controls[iinterval].tlXtalMean[i]/controls[iinterval].counterXtal[i]; controls[iinterval].tlXtalMeanRMS[i]= sqrt(controls[iinterval].tlXtalMeanRMS[i])/(controls[iinterval].nhitXtalMean[i]);// i want eerror on mean controls[iinterval].nhitXtalMean[i]=controls[iinterval].nhitXtalMean[i]/controls[iinterval].counterXtal[i]; } nInterval[iinterval]=intervals->intervalTime(iinterval); nIntervalError[iinterval]=0.; // nIntervalError[iinterval]=0; } } //Arrays to be used in the graph float etSumMeanVsRefArray[kIntervals]; float etSumMeanVsRefRMSArray[kIntervals]; float etMeanArray[kIntervals]; float etMeanRMSArray[kIntervals]; float etMeanNoCorrArray[kIntervals]; float etMeanNoCorrRMSArray[kIntervals]; float etABRatioArray[kIntervals]; float etABRatioRMSArray[kIntervals]; float lcMeanArray[kIntervals]; float lcMeanRMSArray[kIntervals]; float tlMeanArray[kIntervals]; float tlMeanRMSArray[kIntervals]; float nhitMeanArray[kIntervals]; float etSumTowerMeanVsRefArray[kIntervals]; float etSumTowerMeanVsRefRMSArray[kIntervals]; float etTowerMeanArray[kIntervals]; float etTowerMeanRMSArray[kIntervals]; float etTowerMeanNoCorrArray[kIntervals]; float etTowerMeanNoCorrRMSArray[kIntervals]; float lcTowerMeanArray[kIntervals]; float lcTowerMeanRMSArray[kIntervals]; float tlTowerMeanArray[kIntervals]; float tlTowerMeanRMSArray[kIntervals]; float nhitTowerMeanArray[kIntervals]; float etSumXtalMeanVsRefArray[kIntervals]; float etSumXtalMeanVsRefRMSArray[kIntervals]; float etXtalMeanArray[kIntervals]; float etXtalMeanRMSArray[kIntervals]; float etXtalMeanNoCorrArray[kIntervals]; float etXtalMeanNoCorrRMSArray[kIntervals]; float lcXtalMeanArray[kIntervals]; float lcXtalMeanRMSArray[kIntervals]; float tlXtalMeanArray[kIntervals]; float tlXtalMeanRMSArray[kIntervals]; float nhitXtalMeanArray[kIntervals]; int historyNormalizationInterval=20; // kIntervals=487; TFile *outFile=TFile::Open(outFileName+"_etaRing.root","recreate"); for (int i=0;i<kBarlRings;++i) { for(int j=0;j<kSides;++j){ std::cout << "Creating history for iring " << i+1 << "/85" << " side "<<j+1<<"/2"<<std::endl; float etref=0; float etSumOverRef=0; float etABRatioref=0; float etNoCorrref=0; float lcref=0; float tlref=0; float nhitref=0; int nref=0; for (int iref=-5;iref<6;++iref) { nref++; etSumOverRef+=controls[historyNormalizationInterval+iref].etSumMean[i][j]/((controls[historyNormalizationInterval+iref].etSumMean[2][0]+controls[historyNormalizationInterval+iref].etSumMean[2][1])/2.); etref+=controls[historyNormalizationInterval+iref].etMean[i][j]; etNoCorrref+=controls[historyNormalizationInterval+iref].etMeanNoCorr[i][j]; etABRatioref+=controls[historyNormalizationInterval+iref].etABRatio[i][j]; lcref+=controls[historyNormalizationInterval+iref].lcMean[i][j]; tlref+=controls[historyNormalizationInterval+iref].tlMean[i][j]; nhitref+=controls[historyNormalizationInterval+iref].nhitMean[i][j]; } etSumOverRef=etSumOverRef/nref; etref=etref/nref; etABRatioref=etABRatioref/nref; etNoCorrref=etNoCorrref/nref; lcref=lcref/nref; tlref=tlref/nref; nhitref=nhitref/nref; for(int iinterval=0;iinterval<kIntervals;iinterval++){ // cout<<controls[iinterval].etMeanNoCorr[i][j]<<" "<<controls[iinterval].etMeanNoCorrRMS[i][j]<<" "<<controls[iinterval].lcMean[i][j]<<" "<<controls[iinterval].lcMeanRMS[i][j]<<endl; //Normalizing to time reference interval float nXtalRing=controls[iinterval].counterEta[i][j]; float kFactor=1.; float kFactorAB=1.; // if (kfactorCorr) // kFactor=(1+(controls[iinterval].etMean[i][j]/etref-1.)*kfactor_alpha)/(controls[iinterval].etMean[i][j]/etref); // if (kfactorABCorr) // kFactorAB=(1+(controls[iinterval].etABRatio[i][j]/etABRatioref-1.)*kfactorAB_alpha)/(controls[iinterval].etABRatio[i][j]/etABRatioref); etSumMeanVsRefArray[iinterval]=1 + (((controls[iinterval].etSumMean[i][j]/((controls[iinterval].etSumMean[2][0]+controls[iinterval].etSumMean[2][1])/2.))/etSumOverRef)-1.)/2.; etSumMeanVsRefRMSArray[iinterval]=0.; etMeanArray[iinterval]=(controls[iinterval].etMean[i][j]/etref)*kFactor; etMeanRMSArray[iinterval]=(controls[iinterval].etMeanRMS[i][j]/etref)*kFactor; etMeanNoCorrArray[iinterval]=(controls[iinterval].etMeanNoCorr[i][j]/etNoCorrref)*kFactor; etMeanNoCorrRMSArray[iinterval]=(controls[iinterval].etMeanNoCorrRMS[i][j]/(etNoCorrref))*kFactor; etABRatioArray[iinterval]=(controls[iinterval].etABRatio[i][j]/etABRatioref)*kFactorAB; etABRatioRMSArray[iinterval]=(controls[iinterval].etABRatioRMS[i][j]/etABRatioref)*kFactorAB; nhitMeanArray[iinterval]=controls[iinterval].nhitMean[i][j]/nhitref; lcMeanArray[iinterval]=1/(controls[iinterval].lcMean[i][j]/lcref); lcMeanRMSArray[iinterval]=pow(lcref/controls[iinterval].lcMean[i][j],2)*controls[iinterval].lcMeanRMS[i][j]; tlMeanArray[iinterval]=controls[iinterval].tlMean[i][j]/tlref; tlMeanRMSArray[iinterval]=controls[iinterval].tlMeanRMS[i][j]/(tlref); //Now normalizing other regions to reference region // if (i!=0) // { // etMeanArray[iinterval]=etMeanArray[i][j][iinterval]/etMeanArray[0][iinterval]; // etMeanNoCorrArray[i][j][iinterval]=etMeanNoCorrArray[i][j][iinterval]/etMeanNoCorrArray[0][iinterval]; // nhitMeanArray[i][j][iinterval]=nhitMeanArray[i][j][iinterval]/nhitMeanArray[0][iinterval]; // lcMeanArray[i][j][iinterval]=lcMeanArray[i][j][iinterval]/lcMeanArray[0][iinterval]; // } } TGraph* nhitGraph=new TGraph(kIntervals,nInterval,&nhitMeanArray[0]); TString etaLabel="ieta_"; TString sideLabel="_side_"; etaLabel+=(i+1); sideLabel+=j; nhitGraph->SetName("nHit_"+etaLabel+sideLabel); nhitGraph->SetTitle("nHit_"+etaLabel+sideLabel); nhitGraph->GetYaxis()->SetTitle("nhit"); nhitGraph->GetXaxis()->SetTitle("interval"); nhitGraph->Write(); delete nhitGraph; TGraphErrors* etSumOverRefGraph=new TGraphErrors(kIntervals,nInterval,&etSumMeanVsRefArray[0],nIntervalError,&etSumMeanVsRefRMSArray[0]); etSumOverRefGraph->SetName("etSumOverRef_"+etaLabel+sideLabel); etSumOverRefGraph->SetTitle("etSumOverRef_"+etaLabel+sideLabel); etSumOverRefGraph->GetYaxis()->SetTitle("<et>"); etSumOverRefGraph->GetXaxis()->SetTitle("interval"); etSumOverRefGraph->Write(); delete etSumOverRefGraph; TGraphErrors* etGraph=new TGraphErrors(kIntervals,nInterval,&etMeanArray[0],nIntervalError,&etMeanRMSArray[0]); etGraph->SetName("et_"+etaLabel+sideLabel); etGraph->SetTitle("et_"+etaLabel+sideLabel); etGraph->GetYaxis()->SetTitle("<et>"); etGraph->GetXaxis()->SetTitle("interval"); etGraph->Write(); delete etGraph; TGraphErrors* etNoCorrGraph=new TGraphErrors(kIntervals,nInterval,&etMeanNoCorrArray[0],nIntervalError,&etMeanNoCorrRMSArray[0]); etNoCorrGraph->SetName("etNoCorr_"+etaLabel+sideLabel); etNoCorrGraph->SetTitle("etNoCorr_"+etaLabel+sideLabel); etNoCorrGraph->GetYaxis()->SetTitle("<etNoCorr>"); etNoCorrGraph->GetXaxis()->SetTitle("interval"); etNoCorrGraph->Write(); delete etNoCorrGraph; TGraphErrors* etABRatioGraph=new TGraphErrors(kIntervals,nInterval,&etABRatioArray[0],nIntervalError,&etABRatioRMSArray[0]); etABRatioGraph->SetName("etABRatio_"+etaLabel+sideLabel); etABRatioGraph->SetTitle("etABRatio_"+etaLabel+sideLabel); etABRatioGraph->GetYaxis()->SetTitle("<etABRatio>"); etABRatioGraph->GetXaxis()->SetTitle("interval"); etABRatioGraph->Write(); delete etABRatioGraph; TGraphErrors* lcGraph=new TGraphErrors(kIntervals,nInterval,&lcMeanArray[0],nIntervalError,&lcMeanRMSArray[0]); lcGraph->SetName("lc_"+etaLabel+sideLabel); lcGraph->SetTitle("lc_"+etaLabel+sideLabel); lcGraph->GetYaxis()->SetTitle("<tl>"); lcGraph->GetXaxis()->SetTitle("interval"); lcGraph->Write(); delete lcGraph; TGraphErrors* EtNoCorrvsTLGraph=new TGraphErrors((kIntervals-200),&tlMeanArray[200],&etMeanNoCorrArray[200],&tlMeanRMSArray[200],&etMeanNoCorrRMSArray[200]); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel+sideLabel); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel+sideLabel); EtNoCorrvsTLGraph->GetYaxis()->SetTitle("<etNoCorr>"); EtNoCorrvsTLGraph->GetXaxis()->SetTitle("<lc>"); EtNoCorrvsTLGraph->Write(); delete EtNoCorrvsTLGraph; } } outFile->Write(); outFile->Close(); outFile=TFile::Open(outFileName+"_itt.root","recreate"); for (int i=0;i<kSM*kTowerPerSM;++i) { std::cout << "Creating history for itt " << i+1 << "/" << kSM*kTowerPerSM << std::endl; float etref=0; float etNoCorrref=0; float lcref=0; float tlref=0; float nhitref=0; int nref=0; for (int iref=-5;iref<6;++iref) { nref++; etref+=controls[historyNormalizationInterval+iref].etTowerMean[i]; etNoCorrref+=controls[historyNormalizationInterval+iref].etTowerMeanNoCorr[i]; lcref+=controls[historyNormalizationInterval+iref].lcTowerMean[i]; tlref+=controls[historyNormalizationInterval+iref].tlTowerMean[i]; nhitref+=controls[historyNormalizationInterval+iref].nhitTowerMean[i]; } etref=etref/nref; etNoCorrref=etNoCorrref/nref; lcref=lcref/nref; tlref=tlref/nref; nhitref=nhitref/nref; for(int iinterval=0;iinterval<kIntervals;iinterval++){ //Normalizing to time reference interval float kFactor=1.; if (kfactorCorr) kFactor=(1+(controls[iinterval].etTowerMean[i]/etref-1.)*kfactor_alpha)/(controls[iinterval].etTowerMean[i]/etref); etTowerMeanArray[iinterval]=(controls[iinterval].etTowerMean[i]/etref)*kFactor; etTowerMeanRMSArray[iinterval]=(controls[iinterval].etTowerMeanRMS[i]/etref)*kFactor; etTowerMeanNoCorrArray[iinterval]=(controls[iinterval].etTowerMeanNoCorr[i]/etNoCorrref)*kFactor; etTowerMeanNoCorrRMSArray[iinterval]=(controls[iinterval].etTowerMeanNoCorrRMS[i]/etNoCorrref)*kFactor; nhitTowerMeanArray[iinterval]=controls[iinterval].nhitTowerMean[i]/nhitref; lcTowerMeanArray[iinterval]=1/(controls[iinterval].lcTowerMean[i]/lcref); lcTowerMeanRMSArray[iinterval]=pow(lcref/controls[iinterval].lcTowerMean[i],2)*controls[iinterval].lcTowerMeanRMS[i]; tlTowerMeanArray[iinterval]=controls[iinterval].tlTowerMean[i]/tlref; tlTowerMeanRMSArray[iinterval]=controls[iinterval].tlTowerMeanRMS[i]/(tlref); //Now normalizing other regions to reference region // if (i!=0) // { // etMeanArray[iinterval]=etMeanArray[iinterval]/etMeanArray[0][iinterval]; // etMeanNoCorrArray[iinterval]=etMeanNoCorrArray[iinterval]/etMeanNoCorrArray[0][iinterval]; // nhitMeanArray[iinterval]=nhitMeanArray[iinterval]/nhitMeanArray[0][iinterval]; // lcMeanArray[iinterval]=lcMeanArray[iinterval]/lcMeanArray[0][iinterval]; // } } TGraph* nhitGraph=new TGraph(kIntervals,nInterval,&nhitTowerMeanArray[0]); TString etaLabel="itt_"; etaLabel+=(i+1); nhitGraph->SetName("nHit_"+etaLabel); nhitGraph->SetTitle("nHit_"+etaLabel); nhitGraph->GetYaxis()->SetTitle("nhit"); nhitGraph->GetXaxis()->SetTitle("interval"); nhitGraph->Write(); delete nhitGraph; TGraphErrors* etGraph=new TGraphErrors(kIntervals,nInterval,&etTowerMeanArray[0],nIntervalError,&etTowerMeanRMSArray[0]); etGraph->SetName("et_"+etaLabel); etGraph->SetTitle("et_"+etaLabel); etGraph->GetYaxis()->SetTitle("<et>/<et ieta=1>"); etGraph->GetXaxis()->SetTitle("interval"); etGraph->Write(); delete etGraph; TGraphErrors* etNoCorrGraph=new TGraphErrors(kIntervals,nInterval,&etTowerMeanNoCorrArray[0],nIntervalError,&etTowerMeanNoCorrRMSArray[0]); etNoCorrGraph->SetName("etNoCorr_"+etaLabel); etNoCorrGraph->SetTitle("etNoCorr_"+etaLabel); etNoCorrGraph->GetYaxis()->SetTitle("<etNoCorr>"); etNoCorrGraph->GetXaxis()->SetTitle("interval"); etNoCorrGraph->Write(); delete etNoCorrGraph; TGraphErrors* lcGraph=new TGraphErrors(kIntervals,nInterval,&lcTowerMeanArray[0],nIntervalError,&lcTowerMeanRMSArray[0]); lcGraph->SetName("lc_"+etaLabel); lcGraph->SetTitle("lc_"+etaLabel); lcGraph->GetYaxis()->SetTitle("<tl>"); lcGraph->GetXaxis()->SetTitle("interval"); lcGraph->Write(); delete lcGraph; TGraphErrors* EtNoCorrvsTLGraph=new TGraphErrors((kIntervals-200),&tlTowerMeanArray[200],&etTowerMeanNoCorrArray[200],&tlTowerMeanRMSArray[200],&etTowerMeanNoCorrRMSArray[200]); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel); EtNoCorrvsTLGraph->GetYaxis()->SetTitle("<etNoCorr>"); EtNoCorrvsTLGraph->GetXaxis()->SetTitle("<lc>"); EtNoCorrvsTLGraph->Write(); delete EtNoCorrvsTLGraph; } outFile->Write(); outFile->Close(); outFile=TFile::Open(outFileName+"_ixtal.root","recreate"); for (int i=0;i<kSM*kXtalPerSM;++i) { std::cout << "Creating history for ixtal " << i+1 << "/" << kSM*kXtalPerSM << std::endl; float etref=0; float etNoCorrref=0; float lcref=0; float tlref=0; float nhitref=0; int nref=0; for (int iref=-5;iref<6;++iref) { nref++; etref+=controls[historyNormalizationInterval+iref].etXtalMean[i]; etNoCorrref+=controls[historyNormalizationInterval+iref].etXtalMeanNoCorr[i]; lcref+=controls[historyNormalizationInterval+iref].lcXtalMean[i]; tlref+=controls[historyNormalizationInterval+iref].tlXtalMean[i]; nhitref+=controls[historyNormalizationInterval+iref].nhitXtalMean[i]; } etref=etref/nref; etNoCorrref=etNoCorrref/nref; lcref=lcref/nref; tlref=tlref/nref; nhitref=nhitref/nref; for(int iinterval=0;iinterval<kIntervals;iinterval++){ //Normalizing to time reference interval float kFactor=1.; if (kfactorCorr) kFactor=(1+(controls[iinterval].etXtalMean[i]/etref-1.)*kfactor_alpha)/(controls[iinterval].etXtalMean[i]/etref); etXtalMeanArray[iinterval]=(controls[iinterval].etXtalMean[i]/etref)*kFactor; etXtalMeanRMSArray[iinterval]=(controls[iinterval].etXtalMeanRMS[i]/etref)*kFactor; etXtalMeanNoCorrArray[iinterval]=(controls[iinterval].etXtalMeanNoCorr[i]/etNoCorrref)*kFactor; etXtalMeanNoCorrRMSArray[iinterval]=(controls[iinterval].etXtalMeanNoCorrRMS[i]/etNoCorrref)*kFactor; nhitXtalMeanArray[iinterval]=controls[iinterval].nhitXtalMean[i]/nhitref; lcXtalMeanArray[iinterval]=1/(controls[iinterval].lcXtalMean[i]/lcref); lcXtalMeanRMSArray[iinterval]=pow(lcref/controls[iinterval].lcXtalMean[i],2)*controls[iinterval].lcXtalMeanRMS[i]; tlXtalMeanArray[iinterval]=controls[iinterval].tlXtalMean[i]/tlref; tlXtalMeanRMSArray[iinterval]=controls[iinterval].tlXtalMeanRMS[i]/(tlref); //Now normalizing other regions to reference region // if (i!=0) // { // etMeanArray[iinterval]=etMeanArray[iinterval]/etMeanArray[0][iinterval]; // etMeanNoCorrArray[iinterval]=etMeanNoCorrArray[iinterval]/etMeanNoCorrArray[0][iinterval]; // nhitMeanArray[iinterval]=nhitMeanArray[iinterval]/nhitMeanArray[0][iinterval]; // lcMeanArray[iinterval]=lcMeanArray[iinterval]/lcMeanArray[0][iinterval]; // } } TGraph* nhitGraph=new TGraph(kIntervals,nInterval,&nhitXtalMeanArray[0]); TString etaLabel="ixtal_"; etaLabel+=(i+1); nhitGraph->SetName("nHit_"+etaLabel); nhitGraph->SetTitle("nHit_"+etaLabel); nhitGraph->GetYaxis()->SetTitle("nhit"); nhitGraph->GetXaxis()->SetTitle("interval"); nhitGraph->Write(); delete nhitGraph; TGraphErrors* etGraph=new TGraphErrors(kIntervals,nInterval,&etXtalMeanArray[0],nIntervalError,&etXtalMeanRMSArray[0]); etGraph->SetName("et_"+etaLabel); etGraph->SetTitle("et_"+etaLabel); etGraph->GetYaxis()->SetTitle("<et>/<et ieta=1>"); etGraph->GetXaxis()->SetTitle("interval"); etGraph->Write(); delete etGraph; TGraphErrors* etNoCorrGraph=new TGraphErrors(kIntervals,nInterval,&etXtalMeanNoCorrArray[0],nIntervalError,&etXtalMeanNoCorrRMSArray[0]); etNoCorrGraph->SetName("etNoCorr_"+etaLabel); etNoCorrGraph->SetTitle("etNoCorr_"+etaLabel); etNoCorrGraph->GetYaxis()->SetTitle("<etNoCorr>"); etNoCorrGraph->GetXaxis()->SetTitle("interval"); etNoCorrGraph->Write(); delete etNoCorrGraph; TGraphErrors* lcGraph=new TGraphErrors(kIntervals,nInterval,&lcXtalMeanArray[0],nIntervalError,&lcXtalMeanRMSArray[0]); lcGraph->SetName("lc_"+etaLabel); lcGraph->SetTitle("lc_"+etaLabel); lcGraph->GetYaxis()->SetTitle("<tl>"); lcGraph->GetXaxis()->SetTitle("interval"); lcGraph->Write(); delete lcGraph; TGraphErrors* EtNoCorrvsTLGraph=new TGraphErrors((kIntervals-200),&tlXtalMeanArray[200],&etXtalMeanNoCorrArray[200],&tlXtalMeanRMSArray[200],&etXtalMeanNoCorrRMSArray[200]); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel); EtNoCorrvsTLGraph->SetName("EtNoCorrvsTL_"+etaLabel); EtNoCorrvsTLGraph->GetYaxis()->SetTitle("<etNoCorr>"); EtNoCorrvsTLGraph->GetXaxis()->SetTitle("<lc>"); EtNoCorrvsTLGraph->Write(); delete EtNoCorrvsTLGraph; } outFile->Write(); outFile->Close(); }
Double_t CalibTree::Loop(int loop) { char name[500]; bool debug=false; if (fChain == 0) return 0; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; std::map<unsigned int, std::pair<double,double> >SumW; std::map<unsigned int, unsigned int >nTrks; unsigned int mask(0xFF80), ntrkMax(0); for (Long64_t jentry=0; jentry<nentries;jentry++) { // for (Long64_t jentry=0; jentry<1000;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(debug) std::cout << "***Entry (Track) Number : " << ientry << " p/eHCal/eMipDR/nDets : " << t_p << "/" << t_eHcal << "/" << t_eMipDR << "/" << (*t_DetIds).size() << std::endl; if (goodTrack()) { if (loop == 0) hprof_ndets->Fill(t_ieta, (*t_DetIds).size()); double Etot=0.0; for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { double hitEn=0.0; unsigned int detid = (*t_DetIds)[idet] & mask; if (Cprev.find(detid) != Cprev.end()) hitEn = Cprev[detid] * (*t_HitEnergies)[idet]; else hitEn = (*t_HitEnergies)[idet]; Etot += hitEn; } for (unsigned int idet=0; idet<(*t_DetIds).size(); idet++) { unsigned int detid = (*t_DetIds)[idet] & mask; double hitEn=0.0; if (debug) std::cout << "idet " << idet << " detid/hitenergy : " << std::hex << (*t_DetIds)[idet] << ":" << detid << "/" << (*t_HitEnergies)[idet] << std::endl; if (Cprev.find(detid) != Cprev.end()) hitEn = Cprev[detid] * (*t_HitEnergies)[idet]; else hitEn = (*t_HitEnergies)[idet]; double Wi = hitEn/Etot; double Fac = (Wi* t_p) / Etot; if( SumW.find(detid) != SumW.end() ) { Wi += SumW[detid].first; Fac += SumW[detid].second; SumW[detid] = std::pair<double,double>(Wi,Fac); nTrks[detid]++; } else { SumW.insert( std::pair<unsigned int, std::pair<double,double> >(detid,std::pair<double,double>(Wi,Fac))); nTrks.insert(std::pair<unsigned int,unsigned int>(detid, 1)); } if (nTrks[detid] > ntrkMax) ntrkMax = nTrks[detid]; } } } std::map<unsigned int, std::pair<double,double> >::iterator SumWItr = SumW.begin(); unsigned int kount(0), mkount(0); double sumfactor(0); double dets[150], cfacs[150], wfacs[150], nTrk[150]; unsigned int ntrkCut = ntrkMax/10; for (; SumWItr != SumW.end(); SumWItr++) { if (debug) std::cout<< "Detid/SumWi/SumFac : " << SumWItr->first << " / " << (SumWItr->second).first << " / " << (SumWItr->second).second << std::endl; unsigned int detid = SumWItr->first; double factor = (SumWItr->second).second / (SumWItr->second).first; if(nTrks[detid]>ntrkCut) { if (factor > 1) sumfactor += (1-1/factor); else sumfactor += (1-factor); mkount++; } if (Cprev.find(detid) != Cprev.end()) { Cprev[detid] *= factor; cfacs[kount] = Cprev[detid]; } else { Cprev.insert( std::pair<unsigned int, double>(detid, factor) ); cfacs[kount] = factor; } int ieta = (detid>>7) & 0x3f; int zside= (detid&0x2000) ? 1 : -1; int depth= (detid>>14)&0x1F; wfacs[kount]= factor; dets[kount] = zside*(ieta+0.1*(depth-1)); nTrk[kount] = nTrks[detid]; kount++; } TGraph *g_fac, *g_fac2, *g_nTrk; g_fac = new TGraph(kount, dets, cfacs); sprintf(name, "Cfacs_detid_it%d", loop); fout->WriteTObject(g_fac, name); g_fac2 = new TGraph(kount, dets, wfacs); sprintf(name, "Wfacs_detid_it%d", loop); fout->WriteTObject(g_fac2, name); g_nTrk = new TGraph(kount, dets, nTrk); if (loop==0) fout->WriteTObject(g_nTrk, "nTrk_detid"); std::cout << "The new factors are :" << std::endl; std::map<unsigned int, double>::iterator CprevItr = Cprev.begin(); unsigned int indx(0); for (CprevItr=Cprev.begin(); CprevItr != Cprev.end(); CprevItr++, indx++){ unsigned int detid = CprevItr->first; int ieta = (detid>>7) & 0x3f; int zside= (detid&0x2000) ? 1 : -1; int depth= (detid>>14)&0x1F; std::cout << "DetId[" << indx << "] " << std::hex << detid << std::dec << "(" << ieta*zside << "," << depth << ") ( nTrks:" << nTrks[detid] << ") : " << CprevItr->second << std::endl; } double mean = (mkount > 0) ? (sumfactor/mkount) : 0; std::cout << "Mean deviation " << mean << " from 1 for " << mkount << ":" << kount << " DetIds" << std::endl; return mean; }
//------------------------------------------------------------------------------ // Loop //------------------------------------------------------------------------------ void AnalysisMonoH::Loop(TString analysis, TString filename, float luminosity) { if (fChain == 0) return; Setup(analysis, filename, luminosity); // Define histograms //---------------------------------------------------------------------------- for (int j=0; j<ncut; j++) { for (int k=0; k<=njetbin; k++) { TString sbin = (k < njetbin) ? Form("/%djet", k) : ""; TString directory = scut[j] + sbin; root_output->cd(); if (k < njetbin) gDirectory->mkdir(directory); root_output->cd(directory); for (int i=ee; i<=ll; i++) { TString suffix = "_" + schannel[i]; DefineHistograms(i, j, k, suffix); h_fullpmet [i][j][k] = new TH1D("h_fullpmet" + suffix, "", 1000, 0., 1000); h_trkpmet [i][j][k] = new TH1D("h_trkpmet" + suffix, "", 1000, 0., 1000); h_deltarl1met [i][j][k] = new TH1D("h_deltarl1met" + suffix, "", 100, 0., 5); h_deltarl2met [i][j][k] = new TH1D("h_deltarl2met" + suffix, "", 100, 0., 5); h_deltarllmet [i][j][k] = new TH1D("h_deltarllmet" + suffix, "", 100, 0., 5); h_deltarjet1met [i][j][k] = new TH1D("h_deltarjet1met" + suffix, "", 100, 0., 5); h_deltarjet2met [i][j][k] = new TH1D("h_deltarjet2met" + suffix, "", 100, 0., 5); h_deltarjj [i][j][k] = new TH1D("h_deltarjj" + suffix, "", 100, 0., 5); h_deltarjjmet [i][j][k] = new TH1D("h_deltarjjmet" + suffix, "", 100, 0., 5); h_deltarlep1jet1 [i][j][k] = new TH1D("h_deltarlep1jet1" + suffix, "", 100, 0., 5); h_deltarlep1jet2 [i][j][k] = new TH1D("h_deltarlep1jet2" + suffix, "", 100, 0., 5); h_deltarlep2jet1 [i][j][k] = new TH1D("h_deltarlep2jet1" + suffix, "", 100, 0., 5); h_deltarlep2jet2 [i][j][k] = new TH1D("h_deltarlep2jet2" + suffix, "", 100, 0., 5); h_mllstar [i][j][k] = new TH1D("h_mllstar" + suffix, "", 3000, 0., 3000); //h_mnunu [i][j][k] = new TH1D("h_mnunu" + suffix, "", 10, 0., 10); h_mr [i][j][k] = new TH1D("h_mr" + suffix, "", 2000, 0., 2000); //h_met_m2l [i][j][k] = new TH2D("h_met_m2l" + suffix, "", 200, 0, 2000, 100, 0, 200); //h_met_deltaphill [i][j][k] = new TH2D("h_met_deltaphill" + suffix, "", 200, 0, 2000, 100, 0, 5); } } } root_output->cd(); // Loop over events //---------------------------------------------------------------------------- for (Long64_t jentry=0; jentry<_nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; fChain->GetEntry(jentry); PrintProgress(jentry, _nentries); EventSetup(); // Analysis //-------------------------------------------------------------------------- //if (Lepton1.flavour * Lepton2.flavour > 0) continue; //if (Lepton1.v.Pt() < 20.) continue; //if (Lepton2.v.Pt() < 20.) continue; // Let's trust our ntuples //-------------------------------------------------------------------------- if (std_vector_lepton_flavour->at(0)*std_vector_lepton_flavour->at(1) > 0) continue; if (std_vector_lepton_pt->at(0) < 20.) continue; if (std_vector_lepton_pt->at(1) < 20.) continue; if (std_vector_lepton_pt->at(2) > 10.) continue; _nelectron = 0; if (abs(Lepton1.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (abs(Lepton2.flavour) == ELECTRON_FLAVOUR) _nelectron++; if (_nelectron == 2) _channel = ee; else if (_nelectron == 1) _channel = em; else if (_nelectron == 0) _channel = mm; _m2l = mll; _pt2l = ptll; // Fill histograms //-------------------------------------------------------------------------- bool pass = true; // WW cuts FillLevelHistograms(MonoH_00_Has2Leptons, pass); pass &= (mll > 12.); FillLevelHistograms(MonoH_01_Mll, pass); pass &= (MET.Et() > 20.); FillLevelHistograms(MonoH_02_PfMet, pass); bool pass_zveto = (_nelectron == 1 || fabs(mll - Z_MASS) > 15.); FillLevelHistograms(MonoH_03_ZVeto, pass && pass_zveto); pass &= (mpmet > 45. || (_nelectron == 1 && mpmet > 45.)); FillLevelHistograms(MonoH_04_MpMet, pass && pass_zveto); pass &= (_passdphiveto); FillLevelHistograms(MonoH_05_DPhiVeto, pass && pass_zveto); pass &= (_nelectron == 1 && ptll > 30. || _nelectron != 1 && ptll > 45.); FillLevelHistograms(MonoH_06_Ptll, pass && pass_zveto); bool passTopCR = pass && _nbjet20cmvav2l == 1; pass &= (_nbjet20cmvav2l == 0); FillLevelHistograms(MonoH_07_BVeto, pass && pass_zveto); if (_saveminitree && pass && pass_zveto) minitree->Fill(); //ZH->4l Control Region if (AnalysisLeptons[2].v.Pt() > 0 || AnalysisLeptons[3].v.Pt() > 0 ){ //cout<<"I passed! :)"<<endl; bool passZHCR = ( (fabs(_mll13 - Z_MASS) < 15. || fabs(_mll23 - Z_MASS) < 15. || fabs(_mll14 - Z_MASS) < 15. || fabs(_mll24 - Z_MASS) < 15. || fabs(_mll34 - Z_MASS) < 15.) && AnalysisLeptons[2].v.Pt() > 20. && AnalysisLeptons[3].v.Pt() > 20.); FillLevelHistograms(MonoH_08_ZHCR, passZHCR); // cout<<"Lepton 3 pT = "<<std_vector_lepton_pt->at(2)<<endl; // cout<<"Lepton 4 pT = "<<std_vector_lepton_pt->at(3)<<endl; // cout<<"-------------------------------------------"<<endl; } FillLevelHistograms(MonoH_09_TopCR, passTopCR && pass_zveto); // pass &= (!_foundsoftmuon); // FillLevelHistograms(MonoH_08_SoftMu, pass && pass_zveto); // monoH cuts // bool pass_monoh = (pass && pass_zveto); // bool pass_drll = (Lepton1.v.DeltaR(Lepton2.v) < 1.5); // FillLevelHistograms(MonoH_103_CR, pass_monoh && !pass_drll); // pass_monoh &= (_mc < 100.); // FillLevelHistograms(MonoH_100_Mc, pass_monoh); // pass_monoh &= pass_drll; // FillLevelHistograms(MonoH_101_DRll, pass_monoh); // pass_monoh &= (mpmet > 60.); // FillLevelHistograms(MonoH_102_MpMet, pass_monoh); // pass_monoh &= (mpmet > 100.); // FillLevelHistograms(MonoH_09_mpmet100, pass_monoh); // pass_monoh &= (mth > 200.); // FillLevelHistograms(MonoH_10_mth200, pass_monoh); // pass_monoh &= (Lepton1.v.DeltaPhi(MET) > 2.6); // FillLevelHistograms(MonoH_11_dphil1met, pass_monoh); // pass_monoh &= (Lepton2.v.DeltaPhi(MET) > 2.6); // FillLevelHistograms(MonoH_12_dphil2met, pass_monoh); // pass_monoh &= (drll < 0.8); // FillLevelHistograms(MonoH_13_deltarll, pass_monoh); // pass_monoh &= (mtw1 > 160.); // FillLevelHistograms(MonoH_14_mtw1, pass_monoh); // pass_monoh &= (mtw2 > 100.); // FillLevelHistograms(MonoH_15_mtw2, pass_monoh); // pass_monoh &= (metTtrk > 100.); // FillLevelHistograms(MonoH_16_trkmet, pass_monoh); } EndJob(); }
void TimeSlice_fCWeight::Loop() { // CHANGE THAT VARIABLE IdentifyString // String to identify file: this will be used in pdf file naming and output plot file naming string IdentifyString="Collisions"; string InRun="263005"; // In a ROOT session, you can do: // Root > .L TimeSlice_fCWeight.C // Root > TimeSlice_fCWeight t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch TChain *chain=new TChain("ZDCDigiTree",""); TFile *OutFile=new TFile(Form("ForwardAnalyzerplots_%s.root",IdentifyString.c_str()),"RECREATE"); TH1F* histogram_1D_PosHAD1 = new TH1F("PHAD1signal_TS_fC", "PHAD1signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosHAD2 = new TH1F("PHAD2signal_TS_fC", "PHAD2signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosHAD3 = new TH1F("PHAD3signal_TS_fC", "PHAD3signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosHAD4 = new TH1F("PHAD4signal_TS_fC", "PHAD4signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegHAD1 = new TH1F("NHAD1signal_TS_fC", "NHAD1signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegHAD2 = new TH1F("NHAD2signal_TS_fC", "NHAD2signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegHAD3 = new TH1F("NHAD3signal_TS_fC", "NHAD3signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegHAD4 = new TH1F("NHAD4signal_TS_fC", "NHAD4signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosEM1 = new TH1F("PEM1signal_TS_fC", "PEM1signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosEM2 = new TH1F("PEM2signal_TS_fC", "PEM2signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosEM3 = new TH1F("PEM3signal_TS_fC", "PEM3signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosEM4 = new TH1F("PEM4signal_TS_fC", "PEM4signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_PosEM5 = new TH1F("PEM5signal_TS_fC", "PEM5signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegEM1 = new TH1F("NEM1signal_TS_fC", "NEM1signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegEM2 = new TH1F("NEM2signal_TS_fC", "NEM2signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegEM3 = new TH1F("NEM3signal_TS_fC", "NEM3signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegEM4 = new TH1F("NEM4signal_TS_fC", "NEM4signal_fC_TS", 10, 0, 10); TH1F* histogram_1D_NegEM5 = new TH1F("NEM5signal_TS_fC", "NEM5signal_fC_TS", 10, 0, 10); // TH2F* histogram_2D = new TH2F("TimeSlice_fCWeight", "negHD4fCvsTS", 10, 0, 10, 200, 100, 30000); if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; for(int iTS=0;iTS<10;iTS++){ // if(posHD1fC[iTS]<0) // { // posHD1fC[iTS]=0; // } // if(posHD1fC[iTS]>0 ) // { histogram_1D_PosHAD1->Fill(iTS,posHD1fC[iTS]); // } // if(posHD2fC[iTS]<0) // { // posHD2fC[iTS]=0; // } // if(posHD2fC[iTS]>0 ) // { histogram_1D_PosHAD2->Fill(iTS,posHD2fC[iTS]); // } // if(posHD3fC[iTS]<0) // { // posHD3fC[iTS]=0; // } // if(posHD3fC[iTS]>0 ) // { histogram_1D_PosHAD3->Fill(iTS,posHD3fC[iTS]); // } // if(posHD4fC[iTS]<0) // { // posHD4fC[iTS]=0; // } // if(posHD4fC[iTS]>0 ) // { histogram_1D_PosHAD4->Fill(iTS,posHD4fC[iTS]); // } // if(negHD1fC[iTS]<0) // { // negHD1fC[iTS]=0; // } // if(negHD1fC[iTS]>0 ) // { histogram_1D_NegHAD1->Fill(iTS,negHD1fC[iTS]); // } // if(negHD2fC[iTS]<0) // { // negHD2fC[iTS]=0; // } // if(negHD2fC[iTS]>0 ) // { histogram_1D_NegHAD2->Fill(iTS,negHD2fC[iTS]); // } // if(negHD3fC[iTS]<0) // { // negHD3fC[iTS]=0; // } // if(negHD3fC[iTS]>0 ) // { histogram_1D_NegHAD3->Fill(iTS,negHD3fC[iTS]); // } // if(negHD4fC[iTS]<0) // { // negHD4fC[iTS]=0; // } // if(negHD4fC[iTS]>0 ) // { histogram_1D_NegHAD4->Fill(iTS,negHD4fC[iTS]); // } // EM // if(posEM1fC[iTS]<0) // { // posEM1fC[iTS]=0; // } // if(posEM1fC[iTS]>0 ) // { histogram_1D_PosEM1->Fill(iTS,posEM1fC[iTS]); // } // if(posEM2fC[iTS]<0) // { // posEM2fC[iTS]=0; // } // if(posEM2fC[iTS]>0 ) // { histogram_1D_PosEM2->Fill(iTS,posEM2fC[iTS]); // } // if(posEM3fC[iTS]<0) // { // posEM3fC[iTS]=0; // } // if(posEM3fC[iTS]>0 ) // { histogram_1D_PosEM3->Fill(iTS,posEM3fC[iTS]); // } // if(posEM4fC[iTS]<0) // { // posEM4fC[iTS]=0; // } // if(posEM4fC[iTS]>0 ) // { histogram_1D_PosEM4->Fill(iTS,posEM4fC[iTS]); // } // if(posEM5fC[iTS]<0) // { // posEM5fC[iTS]=0; // } // if(posEM5fC[iTS]>0 ) // { histogram_1D_PosEM5->Fill(iTS,posEM5fC[iTS]); // } // if(negEM1fC[iTS]<0) // { // negEM1fC[iTS]=0; // } // if(negEM1fC[iTS]>0 ) // { histogram_1D_NegEM1->Fill(iTS,negEM1fC[iTS]); // } // if(negEM2fC[iTS]<0) // { // negEM2fC[iTS]=0; // } // if(negEM2fC[iTS]>0 ) // { histogram_1D_NegEM2->Fill(iTS,negEM2fC[iTS]); // } // if(negEM3fC[iTS]<0) // { // negEM3fC[iTS]=0; // } // if(negEM3fC[iTS]>0 ) // { histogram_1D_NegEM3->Fill(iTS,negEM3fC[iTS]); // } // if(negEM4fC[iTS]<0) // { // negEM4fC[iTS]=0; // } // if(negEM4fC[iTS]>0 ) // { histogram_1D_NegEM4->Fill(iTS,negEM4fC[iTS]); // } // if(negEM5fC[iTS]<0) // { // negEM5fC[iTS]=0; // } // if(negEM5fC[iTS]>0 ) // { histogram_1D_NegEM5->Fill(iTS,negEM5fC[iTS]); // } } // && negHD4ADC[iTS]>126 } // histogram_2D->Draw("COLZ"); histogram_1D_PosHAD1->Write(); histogram_1D_PosHAD2->Write(); histogram_1D_PosHAD3->Write(); histogram_1D_PosHAD4->Write(); histogram_1D_NegHAD1->Write(); histogram_1D_NegHAD2->Write(); histogram_1D_NegHAD3->Write(); histogram_1D_NegHAD4->Write(); histogram_1D_PosEM1->Write(); histogram_1D_PosEM2->Write(); histogram_1D_PosEM3->Write(); histogram_1D_PosEM4->Write(); histogram_1D_PosEM5->Write(); histogram_1D_NegEM1->Write(); histogram_1D_NegEM2->Write(); histogram_1D_NegEM3->Write(); histogram_1D_NegEM4->Write(); histogram_1D_NegEM5->Write(); c1 = new TCanvas(); histogram_1D_PosHAD1->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosHAD1signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosHAD2->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosHAD2signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosHAD3->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosHAD3signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosHAD4->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosHAD4signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegHAD1->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegHAD1signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegHAD2->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegHAD2signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegHAD3->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegHAD3signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegHAD4->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegHAD4signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosEM1->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosEM1signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosEM2->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosEM2signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosEM3->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosEM3signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosEM4->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosEM4signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_PosEM5->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/PosEM5signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegEM1->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegEM1signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegEM2->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegEM2signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegEM3->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegEM3signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegEM4->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegEM4signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); histogram_1D_NegEM5->Draw(); drawText(Form("Run: %s",InRun.c_str()), 0.6, 0.8, 18); c1->Print(Form("plots/NegEM5signal_TS_fCWeight_%s.pdf",IdentifyString.c_str())); }
void gen_distribution::Loop(int lepID, bool applyWeight, bool exclusive, int DEBUG) { if (fChain == 0) return; bool isSherpa=false; size_t pos_sherpa = _inputFileName.find("sherpa"); if(pos_sherpa!= std::string::npos) isSherpa=true; if(isSherpa)cout << "This is a sherpa MC sample" << endl; const double fBinsPt01[]= {30,40,55,75,105,150,210,315,500}; const double fBinsPt02[]= {30,40,55,75,105,150,210,315,450}; const double fBinsPt03[]= {30,40,55,75,105,150,300}; const double fBinsPt04[]= {30,40,55,75,105,200}; int nPtBins01 = sizeof(fBinsPt01)/sizeof(fBinsPt01[0])-1; cout << "There are " << nPtBins01 << " bins in 1st leading jet" << endl; int nPtBins02 = sizeof(fBinsPt02)/sizeof(fBinsPt02[0])-1; cout << "There are " << nPtBins02 << " bins in 2nd leading jet" << endl; int nPtBins03 = sizeof(fBinsPt03)/sizeof(fBinsPt03[0])-1; cout << "There are " << nPtBins03 << " bins in 3rd leading jet" << endl; int nPtBins04 = sizeof(fBinsPt04)/sizeof(fBinsPt04[0])-1; cout << "There are " << nPtBins04 << " bins in 4th leading jet" << endl; const double fBinsY[]={0.0,0.3,0.6,0.9,1.2,1.5,1.8,2.1,2.4}; const int nYBins = sizeof(fBinsY)/sizeof(fBinsY[0])-1; cout << "There are " << nYBins << " bins." << endl; TH1D* h_nvtx = new TH1D("h_nvtx","",41.5,-0.5,40.5); h_nvtx->SetXTitle("Number of good vertices"); h_nvtx->Sumw2(); TH1D* h_njet = new TH1D("h_njet","",6,-0.5,5.5); h_njet->SetXTitle("#geq n jet"); h_njet->Sumw2(); const int nMAXJETS=4; TH1D* h_jetpt_power_template = new TH1D("h_jetpt_power_template","",500,30,530); h_jetpt_power_template->SetXTitle("p_{T}(jet)^{gen} [GeV]"); h_jetpt_power_template->Sumw2(); TH1D* h_jetpt_power[nMAXJETS+1]; TH1D* h_jetp_power[nMAXJETS+1]; TH1D* h_mc_jetpt[nMAXJETS]; TH1D* h_mc_jety[nMAXJETS]; TH1D* h_predict_jetpt_template = new TH1D("h_predict_jetpt_template","",nPtBins01,fBinsPt01); h_predict_jetpt_template->Sumw2(); TH1D* h_leadingjet_pt = (TH1D*)h_predict_jetpt_template->Clone("h_leadingjet_pt"); h_leadingjet_pt->Sumw2(); h_mc_jetpt[0] = new TH1D(Form("h_mc_jetpt%02i",1),"1st leading jet",nPtBins01,fBinsPt01); h_mc_jetpt[1] = new TH1D(Form("h_mc_jetpt%02i",2),"2nd leading jet",nPtBins02,fBinsPt02); h_mc_jetpt[2] = new TH1D(Form("h_mc_jetpt%02i",3),"3rd leading jet",nPtBins03,fBinsPt03); h_mc_jetpt[3] = new TH1D(Form("h_mc_jetpt%02i",4),"4th leading jet",nPtBins04,fBinsPt04); TH1D* h_predict_jety_template = new TH1D("h_predict_jety_template","",nYBins,fBinsY); h_predict_jety_template->Sumw2(); TH1D* h_leadingjet_y = (TH1D*)h_predict_jety_template->Clone("h_leadingjet_y"); h_leadingjet_y->Sumw2(); for(int ij=0; ij<nMAXJETS; ij++){ h_jetpt_power[ij] = (TH1D*)h_jetpt_power_template->Clone(Form("h_jetpt_power%02i",ij+1)); h_jetp_power[ij] = (TH1D*)h_jetpt_power_template->Clone(Form("h_jetp_power%02i",ij+1)); h_jetp_power[ij] -> SetXTitle("p(jet) [GeV]"); h_mc_jetpt[ij]->SetXTitle("p_{T}(jet) [GeV]"); h_mc_jetpt[ij]->Sumw2(); h_mc_jety[ij] = (TH1D*)h_predict_jety_template->Clone(Form("h_mc_jety%02i",ij+1)); h_mc_jety[ij]->SetXTitle("Rapidity(jet)"); h_mc_jety[ij]->Sumw2(); } h_jetpt_power[4] = (TH1D*)h_jetpt_power_template->Clone("h_jetpt_power_inclusive"); h_jetpt_power[4]->Sumw2(); h_jetp_power[4] = (TH1D*)h_jetpt_power_template->Clone("h_jetp_power_inclusive"); h_jetp_power[4]->Sumw2(); h_jetp_power[4]->SetXTitle("p(jet) [GeV]"); TH1D* h_zpt_template = new TH1D("h_zpt_template","",100,0,100); h_zpt_template->Sumw2(); TH1D* h_zpt = (TH1D*)h_zpt_template->Clone("h_zpt"); h_zpt->SetXTitle("p_{T}(Z) [GeV]"); h_zpt->Sumw2(); TH1D* h_jetpt_template = new TH1D("h_jetpt_template","",80,0,400); TH1D* h_jetpt = (TH1D*)h_jetpt_template->Clone("h_jetpt"); h_jetpt->SetXTitle("p_{T}(jet) [GeV]"); h_jetpt->Sumw2(); TH1D* h_ypart_template = new TH1D("h_ypart_template","",60,-3.0,3.0); TH1D* h_zy = (TH1D*)h_ypart_template->Clone("h_zy"); h_zy->SetXTitle("y_{Z}"); h_zy->Sumw2(); TH1D* h_jety = (TH1D*)h_ypart_template->Clone("h_jety"); h_jety->SetXTitle("y_{jet}"); h_jety->Sumw2(); TH1D* h_y_template = new TH1D("h_y_template","",25,-2.5,2.5); TH1D* h_yB = (TH1D*)h_y_template->Clone("h_yB"); h_yB->SetXTitle("0.5(y_{Z}+y_{jet})"); h_yB->Sumw2(); TH1D* h_ystar = (TH1D*)h_y_template->Clone("h_ystar"); h_ystar->SetXTitle("0.5(y_{Z}-y_{jet})"); h_ystar->Sumw2(); Long64_t nentries = fChain->GetEntriesFast(); cout << _inputFileName << " has " << nentries << " entries." << endl; std::string leptonName; if(abs(lepID)==13)leptonName = "muon"; else if(abs(lepID)==11)leptonName = "electron"; cout << "studying " << leptonName << endl; // dummy proof, in case someone put a negative number int leptonPID = abs(lepID); int nPass[30]; typedef map<double, int, std::greater<double> > myMap; myMap sorted_genJetEtMap; typedef myMap::iterator mapIter; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { sorted_genJetEtMap.clear(); // if(jentry > 1000) break; Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; nPass[0]++; int lepPlusIndex = -1; int lepMinusIndex = -1; double eventWeight = 1; if(applyWeight && PU_weight >= 0.0)eventWeight *= PU_weight; if(applyWeight && mcWeight_>0)eventWeight *= mcWeight_; if(DEBUG==1){ cout << "PU_weight = " << PU_weight << "\t nvertex = " << EvtInfo_NumVtx << endl; cout << "MCweight = " << mcWeight_ << endl; cout << "eventWeight = " << eventWeight << endl; } h_nvtx->Fill(EvtInfo_NumVtx, eventWeight); for(unsigned int igen=0; igen < genParId_->size(); igen++){ if(lepPlusIndex < 0 && fabs(genParId_->at(igen)-(-leptonPID))<1e-6 && fabs(genParSt_->at(igen)-1) < 1e-6) lepPlusIndex = igen; if(lepMinusIndex < 0 && fabs(genParId_->at(igen)-(leptonPID))<1e-6 && fabs(genParSt_->at(igen)-1) < 1e-6) lepMinusIndex = igen; // need to add a line and see if this is a daughter of Z-> tau tau if(lepPlusIndex >= 0 && lepMinusIndex >=0) break; } // do not find m+ or lep- if(lepPlusIndex < 0 || lepMinusIndex < 0)continue; nPass[1]++; if(DEBUG==1){ cout << "lepPlusIndex = " << lepPlusIndex << "\t pt=" << genParPt_->at(lepPlusIndex) << "\t eta=" << genParEta_->at(lepPlusIndex) << endl; cout << "lepMinusIndex = " << lepMinusIndex << "\t pt=" << genParPt_->at(lepMinusIndex) << "\t eta=" << genParEta_->at(lepMinusIndex) << endl; } int nPt20=0; int nPt10=0; int indexNumbers[2] = {lepPlusIndex, lepMinusIndex}; for(int ip=0; ip < 2; ip++){ double pt = genParPt_->at(indexNumbers[ip]); double eta = genParEta_->at(indexNumbers[ip]); // muon if(leptonPID==13 && pt > 20.0 && fabs(eta) < 2.4)nPt20++; if(leptonPID==11 && pt > 20.0 && ( (fabs(eta) > 1.566 && fabs(eta) < 2.4) || (fabs(eta) > 0.0 && fabs(eta) < 1.442 ) ))nPt20++; // if(exclusive && leptonPID==11 && pt > 20.0 && fabs(eta) > 1.566 && // fabs(eta) < 2.4)nPt20++; // if(exclusive && leptonPID==11 && pt > 20.0 && fabs(eta) > 0.0 && // fabs(eta) < 1.442)nPt20++; // if(!exclusive && leptonPID==11 && pt > 20.0 && fabs(eta) < 2.4)nPt20++; } if(DEBUG==1) cout << "nPt20 = " << nPt20 << "\t nPt10 = " << nPt10 << endl; if(leptonPID==13 && (nPt20 < 2))continue; if(leptonPID==11 && (nPt20 < 2))continue; nPass[2]++; TLorentzVector l4_lepp(0,0,0,0); l4_lepp.SetPtEtaPhiE(genParPt_->at(lepPlusIndex), genParEta_->at(lepPlusIndex), genParPhi_->at(lepPlusIndex), genParE_->at(lepPlusIndex)); TLorentzVector l4_lepm(0,0,0,0); l4_lepm.SetPtEtaPhiE(genParPt_->at(lepMinusIndex), genParEta_->at(lepMinusIndex), genParPhi_->at(lepMinusIndex), genParE_->at(lepMinusIndex)); TLorentzVector l4_z = l4_lepp + l4_lepm; double mll = l4_z.M(); if(leptonPID==13 && (mll < 70 || mll > 110))continue; if(leptonPID==11 && (mll < 70 || mll > 110))continue; if(DEBUG==1) cout << "dilepton mass = " << mll << endl; nPass[3]++; // now look for jets double maxGenJetPt = -9999; int maxGenJetIndex = -1; unsigned int nGenJets = 0; for(unsigned int ij = 0; ij < genJetPt_->size(); ij ++){ double thisGenJetPt = genJetPt_->at(ij); double thisGenJetEta = genJetEta_->at(ij); if(thisGenJetPt < 30.0)continue; if(fabs(thisGenJetEta) > 2.4)continue; TLorentzVector thisGenJet_l4(0,0,0,0); thisGenJet_l4.SetPtEtaPhiE(genJetPt_->at(ij), genJetEta_->at(ij), genJetPhi_->at(ij), genJetE_->at(ij)); double dr_ep = l4_lepp.DeltaR(thisGenJet_l4); double dr_em = l4_lepm.DeltaR(thisGenJet_l4); if(dr_ep < 0.3)continue; if(dr_em < 0.3)continue; nGenJets++; sorted_genJetEtMap.insert(std::pair<double, int>(thisGenJetPt,ij)); if(thisGenJetPt > maxGenJetPt) { maxGenJetPt = thisGenJetPt; maxGenJetIndex = ij; } h_jetpt_power[4]->Fill(thisGenJetPt,eventWeight); h_jetp_power[4]->Fill(thisGenJet_l4.P(),eventWeight); } // end of loop over jets if(nGenJets!= sorted_genJetEtMap.size()) { cout << "errors in map size" << endl; continue; } if(DEBUG==1) cout << "max gen jet index = " << maxGenJetIndex << endl; for(unsigned int ik=0; ik<h_njet->GetNbinsX(); ik++) if(nGenJets>= ik) h_njet->Fill(ik,eventWeight); if(maxGenJetIndex < 0)continue; nPass[4]++; if(exclusive && nGenJets!=1)continue; nPass[5]++; TLorentzVector l4_j(0,0,0,0); l4_j.SetPtEtaPhiE(genJetPt_->at(maxGenJetIndex), genJetEta_->at(maxGenJetIndex), genJetPhi_->at(maxGenJetIndex), genJetE_->at(maxGenJetIndex)); double ptz = l4_z.Pt(); double ptjet = l4_j.Pt(); double yz = l4_z.Rapidity(); double yj = l4_j.Rapidity(); double yB = 0.5*(yz + yj); double ystar = 0.5*(yz-yj); h_leadingjet_pt->Fill(ptjet,eventWeight); h_leadingjet_y->Fill(fabs(yj),eventWeight); if(DEBUG==1) cout << "Now ordered jets" << endl; int countGenJet=0; for (mapIter it_part= sorted_genJetEtMap.begin(); it_part != sorted_genJetEtMap.end() && countGenJet< nMAXJETS; ++it_part) { double pt_mapthis = genJetPt_->at(it_part->second); int jet_index = it_part->second; TLorentzVector l4_jthis(0,0,0,0); l4_jthis.SetPtEtaPhiE(genJetPt_->at(jet_index), genJetEta_->at(jet_index), genJetPhi_->at(jet_index), genJetE_->at(jet_index)); double y_mapthis = l4_jthis.Rapidity(); if(DEBUG==1) cout << "pt = " << pt_mapthis << "\t y = " << y_mapthis << endl; h_mc_jetpt[countGenJet]->Fill(pt_mapthis,eventWeight); h_mc_jety[countGenJet]->Fill(fabs(y_mapthis),eventWeight); h_jetpt_power[countGenJet]->Fill(pt_mapthis,eventWeight); h_jetp_power[countGenJet] ->Fill(l4_jthis.P(),eventWeight); countGenJet++; } if(DEBUG==1)cout << "nGenJets = " << sorted_genJetEtMap.size() << "\t countGenJet = " << countGenJet << endl; h_zpt->Fill(ptz,eventWeight); h_jetpt->Fill(ptjet,eventWeight); h_zy->Fill(yz,eventWeight); h_jety->Fill(yj,eventWeight); h_yB->Fill(yB,eventWeight); h_ystar->Fill(ystar,eventWeight); if(DEBUG==1){ double dR1 = l4_lepp.DeltaR(l4_j); double dR2 = l4_lepm.DeltaR(l4_j); cout << "dR1 = " << dR1 << "\t dR2=" << dR2 << endl; } } // end of loop over entries std::string prefix = "weighted_genHisto"; if(!applyWeight)prefix = "raw_genHisto"; if(exclusive)prefix += "_exclusive1Jet"; std::string remword ="/data4/syu/Zjet_genNtuple/"; size_t pos = _inputFileName.find(remword); if(pos!= std::string::npos) _inputFileName.swap(_inputFileName.erase(pos,remword.length())); else _inputFileName = "test.root"; TFile* outFile = new TFile(Form("%s_%s_%s",prefix.data(), leptonName.data(), _inputFileName.data()),"recreate"); h_nvtx->Write(); h_njet->Write(); h_leadingjet_pt->Write(); h_leadingjet_y->Write(); h_yB->Write(); h_ystar->Write(); h_zy->Write(); h_zpt->Write(); h_jety->Write(); h_jetpt->Write(); for(int ij=0; ij < nMAXJETS; ij++){ h_mc_jetpt[ij]->Write(); h_mc_jety[ij]->Write(); } for(int ij=0; ij < nMAXJETS+1; ij++){ h_jetpt_power[ij]->Write(); h_jetp_power[ij]->Write(); } outFile->Close(); }
void Templates_from_ZanalysisOnDATA::Loop(int IS_MC_CLOSURE_TEST) { // In a ROOT session, you can do: // Root > .L Templates_from_ZanalysisOnDATA.C // Root > Templates_from_ZanalysisOnDATA t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch TFile*fin = new TFile(Form("%s/R_WdivZ_OnMC.root",outputdir.Data())); TFile*fout = new TFile("Templates_from_ZanalysisOnDATA.root","RECREATE"); TH1D *hWlikePos_PtScaled_RWeighted_Templates[WMass::etaMuonNSteps][2*WMass::WMassNSteps+1]; TH1D*hWlikePos_R_WdivZ[WMass::etaMuonNSteps][2*WMass::WMassNSteps+1]; static const int nbins=75; float bins[nbins]={0.}; float xmin=0.6,xmax=1.8, x=xmin; float binsize1=0.01,binsize2=0.04; float binsize=binsize1; for(int i=0;i<nbins;i++){ bins[i]=x; if(x>1.2-binsize) binsize=binsize2; x+=binsize; // cout << bins[i] << endl; } bins[nbins]=xmax; // cout << xmax << endl; for(int i=0; i<WMass::etaMuonNSteps; i++){ TString eta_str = Form("%.1f",WMass::etaMaxMuons[i]); eta_str.ReplaceAll(".","p"); for(int j=0; j<2*WMass::WMassNSteps+1; j++){ int jWmass = WMass::WMassCentral_MeV-(WMass::WMassNSteps-j)*WMass::WMassStep_MeV; hWlikePos_PtScaled_RWeighted_Templates[i][j]=new TH1D(Form("hWlikePos_PtScaled_RWeighted_Templates_eta%s_%d",eta_str.Data(),jWmass),Form("hWlikePos_PtScaled_RWeighted_Templates_eta%s_%d",eta_str.Data(),jWmass),nbins,bins); hWlikePos_PtScaled_RWeighted_Templates[i][j]->Sumw2(); cout << Form("hR_WdivZ_WlikePos_8_JetCut_eta%s_%d",eta_str.Data(),jWmass) << endl; hWlikePos_R_WdivZ[i][j]=(TH1D*)fin->Get(Form("hR_WdivZ_WlikePos_8_JetCut_eta%s_%d",eta_str.Data(),jWmass)); hWlikePos_R_WdivZ[i][j]->Print(); } } if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t first_entry = 0; if(IS_MC_CLOSURE_TEST==1) first_entry=nentries/2; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=first_entry; jentry<nentries;jentry++) { // for (Long64_t jentry=0; jentry<5e5;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; if(jentry%250000==0) cout <<"Analyzed entry "<<jentry<<"/"<<nentries<<endl; for(int i=0; i<WMass::etaMuonNSteps; i++){ for(int j=0; j<2*WMass::WMassNSteps+1; j++){ double iWmass = (WMass::WMassCentral_MeV-(WMass::WMassNSteps-j)*WMass::WMassStep_MeV)/1e3; // SELECT EVENT WITH Z/W SCALED CUTS // ORIGINAL CUTS: // muon pt > 30, // pfmetcut > 25, // Boson pt (recoilcut) < 20, if( evtHasGoodVtx && evtHasTrg){ double MuPos_pt_jacobian = 2*MuPos_pt/WMass::ZMass; if( Z_mass>50 && TMath::Abs(MuPos_eta)<WMass::etaMaxMuons[i] && MuPos_pt>30*WMass::ZMass/iWmass && MuPosIsTightAndIso && MuPosTrg && TMath::Abs(MuNeg_eta)<2.4 // && TMath::Abs(MuNeg_eta)<2.4 && MuNeg_pt>30*WMass::ZMass/iWmass // 2nd muon pt cut added ){ if(pfmetWlikePos>25*WMass::ZMass/iWmass){ if(WlikePos_pt<20*WMass::ZMass/iWmass){ if(Jet_leading_pt<30){ double weight=hWlikePos_R_WdivZ[i][j]->GetBinContent(hWlikePos_R_WdivZ[i][j]->GetXaxis()->FindBin(MuPos_pt_jacobian)); // cout << "etamax= " << WMass::etaMaxMuons[i] << " mass= " << iWmass << " MuPos_pt_jacobian= " << MuPos_pt_jacobian << " weight= " << weight << endl; hWlikePos_PtScaled_RWeighted_Templates[i][j]->Fill(MuPos_pt_jacobian,weight*lumi_scaling); } } } } } } } // cout << endl; } fout->cd(); for(int i=0; i<WMass::etaMuonNSteps; i++){ for(int j=0; j<2*WMass::WMassNSteps+1; j++){ hWlikePos_PtScaled_RWeighted_Templates[i][j]->Write(); } } fout->Write(); fout->Close(); }
//============================================== void MCTnPTriggerEff::Loop(Int_t effSample, Char_t *trigLabel) { if (fChain == 0) return; Long64_t nentries = fChain->GetEntries(); Long64_t nb = 0; Long64_t countRecEvent = 0; printf("number of entries = %d\n", (Int_t) nentries); Bool_t incrementTrig; Double_t epsL1L2Trig_Pos, epsL3Trig_Pos, epsL1L2Trig_Neg, epsL3Trig_Neg; Double_t eps1TMandHLT_Pos, eps1TMandHLT_Neg; Double_t eps2TMandHLT_Pos, eps2TMandHLT_Neg; Double_t epsTMandHLT_Pos, epsTMandHLT_Neg; Double_t trigEff = 0.; //loop over the events for (Long64_t jentry=0; jentry<nentries;jentry++) { // for (Long64_t jentry=0; jentry<500;jentry++) { if(jentry % 100000 == 0) printf("event %d\n", (Int_t) jentry); //printf("event %d\n", (Int_t) jentry); Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); //check that this is a RECO event if(onia->Pt() > 990.) continue; Double_t etaMuPos = muPos->PseudoRapidity(); Double_t etaMuNeg = muNeg->PseudoRapidity(); Double_t pTMuPos = muPos->Pt(); Double_t pTMuNeg = muNeg->Pt(); Double_t pMuPos = muPos->P(); Double_t pMuNeg = muNeg->P(); Double_t phiMuPos = muPos->Phi(); Double_t phiMuNeg = muNeg->Phi(); //take muons only within a certain eta range if((fabs(etaMuPos) < eff::etaPS[0] && pTMuPos < eff::pTMuMin[0]) || //mid-rapidity cut (fabs(etaMuPos) > eff::etaPS[0] && fabs(etaMuPos) < eff::etaPS[1] && pMuPos < eff::pMuMin[1]) || (fabs(etaMuPos) > eff::etaPS[1] && fabs(etaMuPos) < eff::etaPS[2] && pTMuPos < eff::pTMuMin[2])) continue; //(b) on the negative muon if((fabs(etaMuNeg) < eff::etaPS[0] && pTMuNeg < eff::pTMuMin[0]) || //mid-rapidity cut (fabs(etaMuNeg) > eff::etaPS[0] && fabs(etaMuNeg) < eff::etaPS[1] && pMuNeg < eff::pMuMin[1]) || (fabs(etaMuNeg) > eff::etaPS[1] && fabs(etaMuNeg) < eff::etaPS[2] && pTMuNeg < eff::pTMuMin[2])) continue; if(fabs(onia->Rapidity()) > eff::rapMax) continue; if(JpsiVprob > 0.01) continue; Double_t onia_mass = onia->M(); Double_t onia_pt = onia->Pt(); Double_t onia_P = onia->P(); Double_t onia_eta = onia->PseudoRapidity(); Double_t onia_rap = onia->Rapidity(); Double_t onia_phi = onia->Phi(); Double_t onia_mT = sqrt(onia_mass*onia_mass + onia_pt*onia_pt); Int_t rapIndex = -1; for(int iRap = 0; iRap < 2*eff::kNbRapBins; iRap++){ if(onia_rap > eff::rapRange[iRap] && onia_rap < eff::rapRange[iRap+1]){ rapIndex = iRap; break; } } Int_t rapForPTIndex = -1; for(int iRap = 0; iRap < eff::kNbRapForPTBins; iRap++){ if(TMath::Abs(onia_rap) > eff::rapForPTRange[iRap] && TMath::Abs(onia_rap) < eff::rapForPTRange[iRap+1]){ rapForPTIndex = iRap+1; break; } } Int_t pTIndex = -1; for(int iPT = 0; iPT < eff::kNbPTBins[rapForPTIndex]; iPT++){ if(onia_pt > eff::pTRange[rapForPTIndex][iPT] && onia_pt < eff::pTRange[rapForPTIndex][iPT+1]){ pTIndex = iPT+1; break; } } Int_t rapIntegratedPTIndex = -1; for(int iPT = 0; iPT < eff::kNbPTBins[0]; iPT++){ if(onia_pt > eff::pTRange[0][iPT] && onia_pt < eff::pTRange[0][iPT+1]){ rapIntegratedPTIndex = iPT+1; break; } } if(rapIndex < 0){ // printf("rapIndex %d, rap(onia) = %f\n", rapIndex, onia_rap); continue; } if(rapForPTIndex < 1){ // printf("rapForPTIndex %d, rap(onia) = %f\n", rapForPTIndex, onia_rap); continue; } if(pTIndex < 1){ // printf("pTIndex %d, pT(onia) = %f\n", pTIndex, onia_pt); continue; } //============================== calcPol(*muPos, *muNeg); //============================== Bool_t usePTFit = kTRUE; //alternative to the T&P histograms use fitted pT differential efficiency // ---> For the asymmetric triggers: // 0 : event not firing the corresponding trigger // 1 : event firing the corresponding trigger, 2 RECO muons matched to 2 HLT objects, POSITIVE-charge muon matched to the tighter HLT object (usually a L3 muon) // -1 : event firing the corresponding trigger, 2 RECO muons matched to 2 HLT objects, NEGATIVE-charge muon matched to the tighter HLT object (usually a L3 muon) // 2 : event firing the corresponding trigger, 2 RECO muons matched to 2 HLT objects, both matched to the tighter HLT object (usually a L3 muon) // 3 : event firing the corresponding trigger but at least one RECO muon is not matched to the HLT objects if(strncmp("HLT_DoubleMu0", trigLabel, 13) == 0){//DoubleMu0 trigger if(usePTFit){ epsL1L2Trig_Pos = GetEfficiency_FromParametrization(L1L2Eff, effSample, etaMuPos, pTMuPos); epsL3Trig_Pos = GetEfficiency_FromParametrization(L3Eff, effSample, etaMuPos, pTMuPos); epsL1L2Trig_Neg = GetEfficiency_FromParametrization(L1L2Eff, effSample, etaMuNeg, pTMuNeg); epsL3Trig_Neg = GetEfficiency_FromParametrization(L3Eff, effSample, etaMuNeg, pTMuNeg); } else{ epsL1L2Trig_Pos = GetEfficiency(L1L2Eff, effSample, etaMuPos, pTMuPos); epsL3Trig_Pos = GetEfficiency(L3Eff, effSample, etaMuPos, pTMuPos); epsL1L2Trig_Neg = GetEfficiency(L1L2Eff, effSample, etaMuNeg, pTMuNeg); epsL3Trig_Neg = GetEfficiency(L3Eff, effSample, etaMuNeg, pTMuNeg); } trigEff = epsL1L2Trig_Pos * epsL3Trig_Pos * epsL1L2Trig_Neg * epsL3Trig_Neg; } else if(strncmp("HLT_Mu0_TkMu0_OST_Jpsi", trigLabel, 22) == 0){//any of the "low pT J/psi triggers" --> steering via the input filename eps1TMandHLT_Pos = GetEfficiency(TMandHLT1Eff, effSample, etaMuPos, pTMuPos); eps1TMandHLT_Neg = GetEfficiency(TMandHLT1Eff, effSample, etaMuNeg, pTMuNeg); if(usePTFit){ epsL1L2Trig_Pos = GetEfficiency_FromParametrization(L1L2Eff, effSample, etaMuPos, pTMuPos); epsL3Trig_Pos = GetEfficiency_FromParametrization(L3Eff, effSample, etaMuPos, pTMuPos); epsL1L2Trig_Neg = GetEfficiency_FromParametrization(L1L2Eff, effSample, etaMuNeg, pTMuNeg); epsL3Trig_Neg = GetEfficiency_FromParametrization(L3Eff, effSample, etaMuNeg, pTMuNeg); eps2TMandHLT_Pos = GetEfficiency_FromParametrization(TMandHLT2Eff, effSample, etaMuPos, pTMuPos); eps2TMandHLT_Neg = GetEfficiency_FromParametrization(TMandHLT2Eff, effSample, etaMuNeg, pTMuNeg); } else{ epsL1L2Trig_Pos = GetEfficiency(L1L2Eff, effSample, etaMuPos, pTMuPos); epsL3Trig_Pos = GetEfficiency(L3Eff, effSample, etaMuPos, pTMuPos); epsL1L2Trig_Neg = GetEfficiency(L1L2Eff, effSample, etaMuNeg, pTMuNeg); epsL3Trig_Neg = GetEfficiency(L3Eff, effSample, etaMuNeg, pTMuNeg); eps2TMandHLT_Pos = GetEfficiency(TMandHLT2Eff, effSample, etaMuPos, pTMuPos); eps2TMandHLT_Neg = GetEfficiency(TMandHLT2Eff, effSample, etaMuNeg, pTMuNeg); } epsTMandHLT_Pos = eps1TMandHLT_Pos * eps2TMandHLT_Pos; epsTMandHLT_Neg = eps1TMandHLT_Neg * eps2TMandHLT_Neg; Double_t epsTM1_Neg = GetEfficiency(Trk_TkMu0, effSample, etaMuNeg, pTMuNeg); Double_t epsTM2_Neg = GetEfficiency(Mu_TkMu0, effSample, etaMuNeg, pTMuNeg); Double_t epsHLT_Pos = epsL1L2Trig_Pos * epsL3Trig_Pos; Double_t epsHLT_Neg = epsL1L2Trig_Neg * epsL3Trig_Neg; Double_t epsTM_Neg = epsTM1_Neg *epsTM2_Neg; Double_t epsTM1_Pos = GetEfficiency(Trk_TkMu0, effSample, etaMuPos, pTMuPos); Double_t epsTM2_Pos = GetEfficiency(Mu_TkMu0, effSample, etaMuPos, pTMuPos); Double_t epsTM_Pos = epsTM1_Pos *epsTM2_Pos; trigEff = epsHLT_Pos * (epsTM_Neg - epsTMandHLT_Neg) + TMath::Max(0., (epsHLT_Pos - epsTMandHLT_Pos)) * epsTMandHLT_Neg; //last version //unconditioned (pos.) HLT muon and exclusive (neg.) TM + exclusive (pos.) HLT and incluseve (neg.) HLT trigEff += epsHLT_Neg * (epsTM_Pos - epsTMandHLT_Pos) + TMath::Max(0., (epsHLT_Neg - epsTMandHLT_Neg)) * epsTMandHLT_Pos; //last version //mirror image of the above (exchanging the charge) trigEff += epsTMandHLT_Pos * epsTMandHLT_Neg; //combination of 2 inclusve HLT and TM // if((epsTM_Neg - epsTMandHLT_Neg) < 0.)//this component is always okay // printf("negative value for (epsTM_Neg - epsTMandHLT_Neg) = %1.3f - %1.3f = %f\n", epsTM_Neg, epsTMandHLT_Neg, epsTM_Neg - epsTMandHLT_Neg); // if((epsHLT_Pos - epsTMandHLT_Pos) < 0.) // printf("negative value for (epsHLT_Pos - epsTMandHLT_Pos) = %1.3f - %1.3f = %f\n", epsHLT_Pos, epsTMandHLT_Pos, epsHLT_Pos - epsTMandHLT_Pos); // if((epsTM_Pos - epsTMandHLT_Pos) < 0.)//this component is always okay // printf("negative value for (epsTM_Pos - epsTMandHLT_Pos) = %1.3f - %1.3f = %f\n", epsTM_Pos, epsTMandHLT_Pos, epsTM_Pos - epsTMandHLT_Pos); // if((epsHLT_Neg - epsTMandHLT_Neg) < 0.) // printf("negative value for (epsHLT_Neg - epsTMandHLT_Neg): %1.3f - %1.3f = %f\n", epsHLT_Neg, epsTMandHLT_Neg, epsHLT_Neg - epsTMandHLT_Neg); if(trigEff < 0.) trigEff = 0.; else if(trigEff > 1.) trigEff = 1.; }//end of low pT J/psi trigger efficiency //the indiv. histograms will be filled depending on the //assigned probability Double_t randNb = gRandom->Uniform(); if(trigEff > randNb) incrementTrig = kTRUE; else incrementTrig = kFALSE; // hGen_pT->Fill(onia_pt); // hGen_y->Fill(onia_rap); // hGen_phi->Fill(onia_phi); // hGen2D_pT_rapNP->Fill(onia_rap, onia_pt); // hGen2D_pT_rap->Fill(fabs(onia_rap), onia_pt); // if(incrementTrig){ // trigEff_pT->Fill(onia_pt); // trigEff_y->Fill(onia_rap); // trigEff_phi->Fill(onia_phi); // trigEff2D_pT_rapNP->Fill(onia_rap, onia_pt); // trigEff2D_pT_rap->Fill(fabs(onia_rap), onia_pt); // // } // } // } // if(incrementTot){ // totEff_pT->Fill(onia_pt); // totEff_y->Fill(onia_rap); // totEff_phi->Fill(onia_phi); // totEff2D_pT_rapNP->Fill(onia_rap, onia_pt); // totEff2D_pT_rap->Fill(fabs(onia_rap), onia_pt); // } trigEff_pT->Fill(incrementTrig, onia_pt); trigEff_y->Fill(incrementTrig, onia_rap); trigEff_phi->Fill(incrementTrig, onia_phi); trigEff2D_pT_rap->Fill(incrementTrig, fabs(onia_rap), onia_pt); trigEff2D_pT_rapNP->Fill(incrementTrig, onia_rap, onia_pt); //fill the eff. histos for all the different frames for(int iFrame = 0; iFrame < eff::kNbFrames; iFrame++){ //histos for neg. and pos. rapidity separately: if(rapIndex >= 0) trigEff2D_pol_pT_rapNP[iFrame][0][rapIndex]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); if(pTIndex > 0 && rapIndex >= 0) trigEff2D_pol_pT_rapNP[iFrame][pTIndex][rapIndex]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); //histos taking together +y and -y trigEff2D_pol_pT_rap[iFrame][0][0]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); trigEff2D_pol_pT_rap[iFrame][rapIntegratedPTIndex][0]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); if(rapForPTIndex > 0) trigEff2D_pol_pT_rap[iFrame][0][rapForPTIndex]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); if(pTIndex > 0 && rapForPTIndex > 0) trigEff2D_pol_pT_rap[iFrame][pTIndex][rapForPTIndex]->Fill(incrementTrig, thisCosTh[iFrame], thisPhi[iFrame]); //histos taking together +y and -y and phi 4-folding Double_t phiFolded = thisPhi[iFrame]; Double_t thetaAdjusted = thisCosTh[iFrame]; if(thisPhi[iFrame] > -90. && thisPhi[iFrame] < 0.) phiFolded *= -1; else if(thisPhi[iFrame] > 90 && thisPhi[iFrame] < 180){ phiFolded = 180. - thisPhi[iFrame]; thetaAdjusted *= -1; } else if(thisPhi[iFrame] > -180. && thisPhi[iFrame] < -90.){ phiFolded = 180. + thisPhi[iFrame]; thetaAdjusted *= -1; } trigEff2D_pol_pT_rap_phiFolded[iFrame][0][0]->Fill(incrementTrig, thetaAdjusted, phiFolded); if(rapIntegratedPTIndex > 0) trigEff2D_pol_pT_rap_phiFolded[iFrame][rapIntegratedPTIndex][0]->Fill(incrementTrig, thetaAdjusted, phiFolded); if(rapForPTIndex > 0) trigEff2D_pol_pT_rap_phiFolded[iFrame][0][rapForPTIndex]->Fill(incrementTrig, thetaAdjusted, phiFolded); if(pTIndex > 0 && rapForPTIndex > 0) trigEff2D_pol_pT_rap_phiFolded[iFrame][pTIndex][rapForPTIndex]->Fill(incrementTrig, thetaAdjusted, phiFolded); } // //fill the series of correlation histos for lab-frame // Double_t deltaEta = fabs(etaMuPos - etaMuNeg); // Double_t deltaPhi = phiMuPos - phiMuNeg; // if(deltaPhi < -TMath::Pi()) deltaPhi += 2.*TMath::Pi(); // else if(deltaPhi > TMath::Pi()) deltaPhi -= 2.*TMath::Pi(); // Double_t deltaPhiDeg = deltaPhi * 180./TMath::Pi(); // Double_t deltaR = sqrt(pow(deltaEta,2) + pow(deltaPhi,2)); // //convert the deltaPhi variable from the TTree from rad to deg: // Double_t JpsiDetaM2 = sqrt(pow(JpsiDrM2,2) - pow(JpsiDphiM2,2)); // JpsiDphiM2 *= 180./TMath::Pi(); // hGen_deltaR_pT_rap[0][0]->Fill(deltaR); // hGen_deltaRM2_pT_rap[0][0]->Fill(JpsiDrM2); // hGen_deltaPhiM2_pT_rap[0][0]->Fill(JpsiDphiM2); // hGen_deltaEtaM2_pT_rap[0][0]->Fill(JpsiDetaM2); // hGen_distM2_pT_rap[0][0]->Fill(JpsiDistM2); // if(incrementReco){ // recoEff_deltaR_pT_rap[0][0]->Fill(deltaR); // recoEff_deltaRM2_pT_rap[0][0]->Fill(JpsiDrM2); // recoEff_deltaPhiM2_pT_rap[0][0]->Fill(JpsiDphiM2); // recoEff_deltaEtaM2_pT_rap[0][0]->Fill(JpsiDetaM2); // recoEff_distM2_pT_rap[0][0]->Fill(JpsiDistM2); // // } // if(incrementTrig){ // trigEff_deltaR_pT_rap[0][0]->Fill(deltaR); // trigEff_deltaRM2_pT_rap[0][0]->Fill(JpsiDrM2); // trigEff_deltaPhiM2_pT_rap[0][0]->Fill(JpsiDphiM2); // trigEff_deltaEtaM2_pT_rap[0][0]->Fill(JpsiDetaM2); // trigEff_distM2_pT_rap[0][0]->Fill(JpsiDistM2); // } // } // if(incrementTot){ // totEff_deltaR_pT_rap[0][0]->Fill(deltaR); // totEff_deltaRM2_pT_rap[0][0]->Fill(JpsiDrM2); // totEff_deltaPhiM2_pT_rap[0][0]->Fill(JpsiDphiM2); // totEff_deltaEtaM2_pT_rap[0][0]->Fill(JpsiDetaM2); // totEff_distM2_pT_rap[0][0]->Fill(JpsiDistM2); // } // hGen2D_deltaPhiVsDeltaEta_pT_rap[0][0]->Fill(deltaEta, deltaPhiDeg); // if(incrementReco){ // recoEff2D_deltaPhiVsDeltaEta_pT_rap[0][0]->Fill(deltaEta, deltaPhiDeg); // if(incrementTrig) // trigEff2D_deltaPhiVsDeltaEta_pT_rap[0][0]->Fill(deltaEta, deltaPhiDeg); // } // if(incrementTot) // totEff2D_deltaPhiVsDeltaEta_pT_rap[0][0]->Fill(deltaEta, deltaPhiDeg); // if(rapIntegratedPTIndex > 0){ // hGen_deltaR_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaR); // hGen_deltaRM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDrM2); // hGen_deltaPhiM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDphiM2); // hGen_deltaEtaM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDetaM2); // hGen_distM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDistM2); // if(incrementReco){ // recoEff_deltaR_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaR); // recoEff_deltaRM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDrM2); // recoEff_deltaPhiM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDphiM2); // recoEff_deltaEtaM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDetaM2); // recoEff_distM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDistM2); // // } // if(incrementTrig){ // trigEff_deltaR_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaR); // trigEff_deltaRM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDrM2); // trigEff_deltaPhiM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDphiM2); // trigEff_deltaEtaM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDetaM2); // trigEff_distM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDistM2); // } // } // if(incrementTot){ // totEff_deltaR_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaR); // totEff_deltaRM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDrM2); // totEff_deltaPhiM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDphiM2); // totEff_deltaEtaM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDetaM2); // totEff_distM2_pT_rap[rapIntegratedPTIndex][0]->Fill(JpsiDistM2); // } // hGen2D_deltaPhiVsDeltaEta_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaEta, deltaPhiDeg); // if(incrementReco){ // recoEff2D_deltaPhiVsDeltaEta_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaEta, deltaPhiDeg); // if(incrementTrig) // trigEff2D_deltaPhiVsDeltaEta_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaEta, deltaPhiDeg); // } // if(incrementTot) // totEff2D_deltaPhiVsDeltaEta_pT_rap[rapIntegratedPTIndex][0]->Fill(deltaEta, deltaPhiDeg); // } // if(rapForPTIndex > 0){ // hGen_deltaR_pT_rap[0][rapForPTIndex]->Fill(deltaR); // hGen_deltaRM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDrM2); // hGen_deltaPhiM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDphiM2); // hGen_deltaEtaM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDetaM2); // hGen_distM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDistM2); // if(incrementReco){ // recoEff_deltaR_pT_rap[0][rapForPTIndex]->Fill(deltaR); // recoEff_deltaRM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDrM2); // recoEff_deltaPhiM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDphiM2); // recoEff_deltaEtaM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDetaM2); // recoEff_distM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDistM2); // // } // if(incrementTrig){ // trigEff_deltaR_pT_rap[0][rapForPTIndex]->Fill(deltaR); // trigEff_deltaRM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDrM2); // trigEff_deltaPhiM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDphiM2); // trigEff_deltaEtaM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDetaM2); // trigEff_distM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDistM2); // } // } // if(incrementTot){ // totEff_deltaR_pT_rap[0][rapForPTIndex]->Fill(deltaR); // totEff_deltaRM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDrM2); // totEff_deltaPhiM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDphiM2); // totEff_deltaEtaM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDetaM2); // totEff_distM2_pT_rap[0][rapForPTIndex]->Fill(JpsiDistM2); // } // hGen2D_deltaPhiVsDeltaEta_pT_rap[0][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // if(incrementReco){ // recoEff2D_deltaPhiVsDeltaEta_pT_rap[0][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // if(incrementTrig) // trigEff2D_deltaPhiVsDeltaEta_pT_rap[0][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // } // if(incrementTot) // totEff2D_deltaPhiVsDeltaEta_pT_rap[0][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // } // if(pTIndex > 0 && rapForPTIndex > 0){ // hGen_deltaR_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaR); // hGen_deltaRM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDrM2); // hGen_deltaPhiM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDphiM2); // hGen_deltaEtaM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDetaM2); // hGen_distM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDistM2); // if(incrementReco){ // recoEff_deltaR_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaR); // recoEff_deltaRM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDrM2); // recoEff_deltaPhiM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDphiM2); // recoEff_deltaEtaM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDetaM2); // recoEff_distM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDistM2); // //} // if(incrementTrig){ // trigEff_deltaR_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaR); // trigEff_deltaRM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDrM2); // trigEff_deltaPhiM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDphiM2); // trigEff_deltaEtaM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDetaM2); // trigEff_distM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDistM2); // } // } // if(incrementTot){ // totEff_deltaR_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaR); // totEff_deltaRM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDrM2); // totEff_deltaPhiM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDphiM2); // totEff_deltaEtaM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDetaM2); // totEff_distM2_pT_rap[pTIndex][rapForPTIndex]->Fill(JpsiDistM2); // } // hGen2D_deltaPhiVsDeltaEta_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // if(incrementReco){ // recoEff2D_deltaPhiVsDeltaEta_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // if(incrementTrig) // trigEff2D_deltaPhiVsDeltaEta_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // } // if(incrementTot) // totEff2D_deltaPhiVsDeltaEta_pT_rap[pTIndex][rapForPTIndex]->Fill(deltaEta, deltaPhiDeg); // } }//loop over entries printf("nb. of rec. events is %d of a total of %d events\n", (Int_t) countRecEvent, (Int_t) nentries); }
void JetPythiaAnalysis::Loop() { if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; //Definir el tipo de Algoritmo para reconstruir Jets y pasarle el parametro requerido double R = 0.7; fastjet::JetDefinition jet_def(fastjet::kt_algorithm, R); //Definir un histograma para el momento transversal de los Jets TH1F * h_JetPt = new TH1F("JetsPt","Momento transversal de Jets ",50, 0, 100); //Inicia el Ciclo sobre eventos simulados for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; int np = 0; int max_part = particles_; //Maximo numero de particulas // Definit un contenedor de Particulas para pasarle a FastJet std::vector<fastjet::PseudoJet> particles; //Implementar aqui el analisis while ( np < max_part ) { //llenar aqui con las particulas estables: estas particulas serian aquellas que no tienen hijas if ( (particles_fDaughter[np][0] == -1) && (particles_fDaughter[np][1] == -1) ) { bool isDetectable = true; // tenemos que saltarnos aquellas particulas que aun siendo estables, no serian detectables directables // 12 = nu_e ; 14 = nu_mu ; 16 = nu_tau ; 10000022 = SUSY LSP / neutrinalino if ( abs (particles_fPdgCode[np]) == 12 || abs (particles_fPdgCode[np]) == 14 || abs (particles_fPdgCode[np]) == 16 || abs (particles_fPdgCode[np]) == 10000022 ) isDetectable = false; // lenamos el contenedor con particulas estables if( isDetectable ) particles.push_back( fastjet::PseudoJet( particles_fPx[np], particles_fPy[np], particles_fPz[np], particles_fE[np] ) ); } ++np; } if ( particles.size() <= 0 ) continue; // Corremos ahora FastJet: hacer sobre las particulas la identificacion de Jets fastjet::ClusterSequence Cluster(particles, jet_def); // Objeto Cluster contiene los jets: podemos guardarlos en un contenedor de Jets std::vector<fastjet::PseudoJet> jets = Cluster.inclusive_jets(); // Ahora podemos hacer un ciclo sobre los jets reconstruidos y extraer el momento transversal // - llenar histograma for (unsigned i = 0; i < jets.size(); i++) { h_JetPt->Fill( jets[i].perp() ); } jets.clear(); //Limpiar el contenedor de jets y particulas en preparacion para el proximo evento particles.clear(); }//cierra loop sobre eventos // Dibujar la distribucion de momento transversal h_JetPt->Draw(); //termina Loop() limpiar memoria }