void analysisClass::Loop() { std::cout << "analysisClass::Loop() begins" <<std::endl; if (fChain == 0) return; //////////book histos here //////////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_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; ////// 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++) { 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 every event Int_t no_jets_ak4=jetPtAK4->size(); Int_t no_jets_ak8=jetPtAK8->size(); vector<TLorentzVector> widejets; TLorentzVector currentJet, wj1_tmp, wj1, wj2_tmp, wj2, v_jet_ak4,wdijet,wj1math,wj2math; ////cone size wide 1.1 double wideJetDeltaR_ = 1.1; resetCuts(); //Eirini wide jet // if(no_jets_ak4>=2){ // if( fabs(jetEtaAK4->at(0)) < getPreCutValue1("jetFidRegion") && idTAK4->at(0) == getPreCutValue1("tightJetID")){ // if( fabs(jetEtaAK4->at(1)) < getPreCutValue1("jetFidRegion") && idTAK4->at(1) == getPreCutValue1("tightJetID")){ // TLorentzVector jet1, jet2; // jet1.SetPtEtaPhiM(jetPtAK4->at(0),jetEtaAK4->at(0),jetPhiAK4->at(0),jetMassAK4->at(0)); // jet2.SetPtEtaPhiM(jetPtAK4->at(1),jetEtaAK4->at(1),jetPhiAK4->at(1),jetMassAK4->at(1)); // for(Long64_t ijet=0; ijet<no_jets_ak4; ijet++){ //jet loop for ak4 // TLorentzVector currentJet; // if( fabs(jetEtaAK4->at(ijet)) < getPreCutValue1("jetFidRegion") && idTAK4->at(ijet) == getPreCutValue1("tightJetID")){ // TLorentzVector currentJet; // currentJet.SetPtEtaPhiM(jetPtAK4->at(ijet),jetEtaAK4->at(ijet),jetPhiAK4->at(ijet),jetMassAK4->at(ijet)); // double DeltaR1 = currentJet.DeltaR(jet1); // double DeltaR2 = currentJet.DeltaR(jet2); // if(DeltaR1 < DeltaR2 && DeltaR1 < wideJetDeltaR_){ // wj1_tmp += currentJet; // } // else if(DeltaR2 < wideJetDeltaR_){ // wj2_tmp += currentJet; // } // } // if AK4 jet passes fid and jetid. // } //end of ak4 jet loop // if(wj1_tmp.Pt()==0 && wj2_tmp.Pt() ==0) // std::cout << " wj1_tmp.Pt() IN " <<wj1_tmp.Pt() << " wj2_tmp.Pt() " << wj2_tmp.Pt() << std::endl; // } //fid and jet id // } //fid and jet id // } // end of two jets. // -------- Start Giulia Wide jet --------------------- /////////////giulia //use only jets pt>30, fiducial region and looseId if(no_jets_ak4>=2){ if(!(jetPtAK4->at(0)>getPreCutValue1("jetPtCut") && fabs(jetEtaAK4->at(0)) < getPreCutValue1("jetFidRegion") && idLAK4->at(0) == getPreCutValue1("looseJetID"))){ std::cout << " JET 0 FAIL " << jetEtaAK4->at(0) << " JET 0 ID " << idLAK4->at(0) << std::endl; } if(!(jetPtAK4->at(1)>getPreCutValue1("jetPtCut") && fabs(jetEtaAK4->at(1)) < getPreCutValue1("jetFidRegion") && idLAK4->at(1) == getPreCutValue1("looseJetID"))){ std::cout << " JET 1 FAIL " << jetEtaAK4->at(1) << " JET 1 ID " << idTAK4->at(1) << std::endl; } } ////////////////////////// //code to create wide jets : use ak4 passing loose ID if(no_jets_ak4>=2){ if( fabs(jetEtaAK4->at(0)) < getPreCutValue1("jetFidRegion") && idLAK4->at(0) == getPreCutValue1("looseJetID") && jetPtAK4->at(0)>getPreCutValue1("jetPtCut")){ if( fabs(jetEtaAK4->at(1)) < getPreCutValue1("jetFidRegion") && idLAK4->at(1) == getPreCutValue1("looseJetID") && jetPtAK4->at(1)>getPreCutValue1("jetPtCut")){ TLorentzVector jet1, jet2; jet1.SetPtEtaPhiM(jetPtAK4->at(0),jetEtaAK4->at(0),jetPhiAK4->at(0),jetMassAK4->at(0)); jet2.SetPtEtaPhiM(jetPtAK4->at(1),jetEtaAK4->at(1),jetPhiAK4->at(1),jetMassAK4->at(1)); for(Long64_t ijet=0; ijet<no_jets_ak4; ijet++){ //jet loop for ak4 TLorentzVector currentJet; if( fabs(jetEtaAK4->at(ijet)) < getPreCutValue1("jetFidRegion") && idLAK4->at(ijet) == 1){ TLorentzVector currentJet; currentJet.SetPtEtaPhiM(jetPtAK4->at(ijet),jetEtaAK4->at(ijet),jetPhiAK4->at(ijet),jetMassAK4->at(ijet)); double DeltaR1 = currentJet.DeltaR(jet1); double DeltaR2 = currentJet.DeltaR(jet2); if(DeltaR1 < DeltaR2 && DeltaR1 < wideJetDeltaR_){ wj1_tmp += currentJet; } else if(DeltaR2 < wideJetDeltaR_){ wj2_tmp += currentJet; } } // if AK4 jet passes fid and jetid. } //end of ak4 jet loop if(wj1_tmp.Pt()==0 && wj2_tmp.Pt() ==0) std::cout << " wj1_tmp.Pt() IN " <<wj1_tmp.Pt() << " wj2_tmp.Pt() " << wj2_tmp.Pt() << std::endl; } //fid and jet id j2 } //fid and jet id j1 } // end of two jets. //-------------- end Giulia Wide jet -------------------------- // if(wj1_tmp.Pt()==0 && wj2_tmp.Pt() ==0) std::cout << " wj1_tmp.Pt() " <<wj1_tmp.Pt() << " wj2_tmp.Pt() " << wj2_tmp.Pt() << " no_jets_ak4 " << no_jets_ak4 << std::endl; // double MJJWide,DeltaEtaJJWide,DeltaPhiJJWide; if( wj1_tmp.Pt()>0 && wj2_tmp.Pt() >0 ){ // Re-order the wide jets in pt if( wj1_tmp.Pt() > wj2_tmp.Pt()){ wj1 = wj1_tmp; wj2 = wj2_tmp; } else{ wj1 = wj2_tmp; wj2 = wj1_tmp; } // Create dijet system wdijet = wj1 + wj2; MJJWide = wdijet.M(); DeltaEtaJJWide = fabs(wj1.Eta()-wj2.Eta()); DeltaPhiJJWide = fabs(wj1.DeltaPhi(wj2)); // Put widejets in the container wj1math.SetPtEtaPhiM(wj1.Pt(), wj1.Eta(), wj1.Phi(), wj1.M()); wj2math.SetPtEtaPhiM(wj2.Pt(), wj2.Eta(), wj2.Phi(), wj2.M()); widejets.push_back( wj1math ); widejets.push_back( wj2math ); } fillVariableWithValue("nJetFinal",widejets.size()) ; fillVariableWithValue("nVtx",nvtx) ; fillVariableWithValue("ptHat", ptHat); fillVariableWithValue("neutralHadronEnergyFraction_j1", jetNhfAK4->at(0)); fillVariableWithValue("photonEnergyFraction_j1", jetPhfAK4->at(0)); fillVariableWithValue("electronEnergyFraction_j1", jetElfAK4->at(0)); fillVariableWithValue("muonEnergyFraction_j1", jetMufAK4->at(0)); fillVariableWithValue("chargedHadronMultiplicity_j1", jetChfAK4->at(0)); fillVariableWithValue("neutralHadronEnergyFraction_j2", jetNhfAK4->at(1)); fillVariableWithValue("photonEnergyFraction_j2", jetPhfAK4->at(1)); fillVariableWithValue("electronEnergyFraction_j2", jetElfAK4->at(1)); fillVariableWithValue("muonEnergyFraction_j2", jetMufAK4->at(1)); fillVariableWithValue("chargedHadronMultiplicity_j2", jetChfAK4->at(1)); fillVariableWithValue("jetIdT1",idTAK4->at(0)) ; fillVariableWithValue("jetIdT2",idTAK4->at(1)) ; if( widejets.size() >= 1 ) { fillVariableWithValue( "pT1stJet", widejets[0].Pt() ); fillVariableWithValue( "eta1stJet", widejets[0].Eta()); } if( widejets.size() >= 2 ) { fillVariableWithValue( "pT2ndJet", widejets[1].Pt() ); fillVariableWithValue( "eta2ndJet", widejets[1].Eta()); // Calculate deltaETAjj //giulia fillVariableWithValue( "deltaETAjj", DeltaEtaJJWide ) ; // Calculate Mjj fillVariableWithValue( "Dijet_MassW", wdijet.M() ) ; fillVariableWithValue( "Dijet_MassAK8", mjjAK8 ) ; fillVariableWithValue( "Dijet_MassAK4", mjjAK4 ) ; //giulia - test //fillVariableWithValue( "Dijet_MassC", mjjCA8 ) ; if(wdijet.M()<1){ std::cout << " INV MASS IS " << wdijet.M() << std::endl; std::cout << " Delta Eta IS " << DeltaEtaJJWide << " n is " << widejets.size() << std::endl; std::cout << " INV MASS FROM NTUPLE AK8 " << mjjAK8 << std::endl; //std::cout << " INV MASS FROM NTUPLE CA8 " << mjjCA8 << std::endl; } } // Evaluate cuts (but do not apply them) evaluateCuts(); // 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( passedCut("nJetFinal") ) fillReducedSkimTree(); // 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[0].Eta()); } ////////////////////// User's code ends here /////////////////////// } // End loop over events //////////write histos h_nVtx->Write(); h_nJetFinal->Write(); h_pT1stJet->Write(); h_pT2ndJet->Write(); h_DijetMass->Write(); h_DeltaETAjj->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; }
void analysisClass::Loop() { std::cout << "analysisClass::Loop() begins" <<std::endl; if (fChain == 0) return; //////////book histos here TH2F *h_RelDeltaP_vs_trkP_top = new TH2F ("h_RelDeltaP_vs_trkP_top","h_RelDeltaP_vs_trkP_top",500,0,500,500,-10,10); TH2F *h_RelDeltaP_vs_trkP_bottom = new TH2F ("h_RelDeltaP_vs_trkP_bottom","h_RelDeltaP_vs_trkP_bottom",500,0,500,500,-10,10); TH2F *h_muonDTP_vs_trkP_top = new TH2F ("h_muonDTP_vs_trkP_top","h_muonDTP_vs_trkP_top",500,0,500,500,0,500); TH2F *h_muonDTP_vs_trkP_bottom = new TH2F ("h_muonDTP_vs_trkP_bottom","h_muonDTP_vs_trkP_bottom",500,0,500,500,0,500); #ifdef USE_EXAMPLE STDOUT("WARNING: using example code. In order NOT to use it, comment line that defines USE_EXAMPLE flag in Makefile."); // number of electrons TH1F *h_nEleFinal = new TH1F ("h_nEleFinal","",11,-0.5,10.5); h_nEleFinal->Sumw2(); //pT 1st ele TH1F *h_pT1stEle = new TH1F ("h_pT1stEle","",100,0,1000); h_pT1stEle->Sumw2(); //pT 2nd ele TH1F *h_pT2ndEle = new TH1F ("h_pT2ndEle","",100,0,1000); h_pT2ndEle->Sumw2(); #endif //end of USE_EXAMPLE /////////initialize variables Long64_t nentries = fChain->GetEntriesFast(); std::cout << "analysisClass::Loop(): nentries = " << nentries << std::endl; ////// 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++) { 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 every event #ifdef USE_EXAMPLE // Electrons vector<int> v_idx_ele_final; for(int iele=0;iele<eleCount;iele++) { // ECAL barrel fiducial region bool pass_ECAL_FR=false; if( fabs(eleEta[iele]) < getPreCutValue1("eleFidRegion") ) v_idx_ele_final.push_back(iele); } // Set the evaluation of the cuts to false and clear the variable values and filled status resetCuts(); // Set the value of the variableNames listed in the cutFile to their current value fillVariableWithValue("nEleFinal", v_idx_ele_final.size()) ; if( v_idx_ele_final.size() >= 1 ) { fillVariableWithValue( "pT1stEle", elePt[v_idx_ele_final[0]] ); } if( v_idx_ele_final.size() >= 2 ) { fillVariableWithValue( "pT2ndEle", elePt[v_idx_ele_final[1]] ); // Calculate Mee TLorentzVector v_ee, ele1, ele2; ele1.SetPtEtaPhiM(elePt[v_idx_ele_final[0]],eleEta[v_idx_ele_final[0]],elePhi[v_idx_ele_final[0]],0); ele2.SetPtEtaPhiM(elePt[v_idx_ele_final[1]],eleEta[v_idx_ele_final[1]],elePhi[v_idx_ele_final[1]],0); v_ee = ele1 + ele2; fillVariableWithValue( "invMass_ee", v_ee.M() ) ; } // Evaluate cuts (but do not apply them) evaluateCuts(); // Fill histograms and do analysis based on cut evaluation h_nEleFinal->Fill(v_idx_ele_final.size()); //if( v_idx_ele_final.size()>=1 ) h_pT1stEle->Fill(elePt[v_idx_ele_final[0]]); //if( v_idx_ele_final.size()>=2 && (elePt[v_idx_ele_final[0]])>85 ) h_pT2ndEle->Fill(elePt[v_idx_ele_final[1]]); if( passedCut("pT1stEle") ) h_pT1stEle->Fill(elePt[v_idx_ele_final[0]]); if( passedCut("pT2ndEle") ) h_pT2ndEle->Fill(elePt[v_idx_ele_final[1]]); // 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; // ...... #endif // end of USE_EXAMPLE //########### My code here ############# // Set the evaluation of the cuts to false and clear the variable values and filled status resetCuts(); double LenghtHB = getPreCutValue2("radiusHB") - getPreCutValue1("radiusHB"); int n_DTtracksT=0; int n_DTtracksB=0; int n_DTtracksValidProp=0; for(int muon=0; muon<muonDTCount; muon++) { if(muonDTYin[muon]>0 && muonDTYout[muon]>0) n_DTtracksT++; if(muonDTYin[muon]<0 && muonDTYout[muon]<0) n_DTtracksB++; if(muonDTisValidProp[muon]==1) n_DTtracksValidProp++; } fillVariableWithValue( "N_DTtracks", muonDTCount ); fillVariableWithValue( "N_DTtracksProp", n_DTtracksValidProp ); fillVariableWithValue( "N_DTtracksT", n_DTtracksT ); fillVariableWithValue( "N_DTtracksB", n_DTtracksB ); fillVariableWithValue( "N_TRKtracks", trackCount ); if( muonDTCount >=2 ) { int indexTOP=-1; int indexBOTTOM=-1; if(muonDTYin[0]>0 && muonDTYout[0]>0) { indexTOP = 0; } else if(muonDTYin[0]<0 && muonDTYout[0]<0) { indexBOTTOM = 0; } if(muonDTYin[1]>0 && muonDTYout[1]>0) { indexTOP = 1; } else if(muonDTYin[1]<0 && muonDTYout[1]<0) { indexBOTTOM = 1; } if(indexTOP >= 0 && indexBOTTOM >= 0) { //top fillVariableWithValue( "muonTDXY_DT_TRK", muonDTnrstTrkDXY[indexTOP] ); fillVariableWithValue( "muonTDZ_DT_TRK", muonDTnrstTrkDZ[indexTOP] ); fillVariableWithValue( "muonTDTNHits", muonDTNumRecHits[indexTOP] ); fillVariableWithValue( "muonTDTNValidHits", muonDTNumValidRecHits[indexTOP] ); fillVariableWithValue( "muonTDTEtaAtHB", max(muonDTEtaAtInHB[indexTOP],muonDTEtaAtOutHB[indexTOP]) ); fillVariableWithValue( "muonTDTPhiAtHB", max(muonDTPhiAtInHB[indexTOP],muonDTPhiAtOutHB[indexTOP]) ); fillVariableWithValue( "muonTDTLenghtHB", muonDTLengthInHB[indexTOP] ); fillVariableWithValue( "muonTDTdRHitMuInHB", muonDTdeltaRatInHB[indexTOP] ); fillVariableWithValue( "muonTDTdRHitMuOutHB", muonDTdeltaRatOutHB[indexTOP] ); fillVariableWithValue( "muonTDTEnergy", muonDTTotEnergy[indexTOP] ); double normEnergyTOP = (muonDTTotEnergy[indexTOP] / muonDTLengthInHB[indexTOP]) * LenghtHB; fillVariableWithValue( "muonTDTEnergyNorm", normEnergyTOP ); fillVariableWithValue( "muonTDTNCells", muonDTNumCells[indexTOP] ); fillVariableWithValue( "muonTDTCellSameEta", muonDTHaveCellsSameEta[indexTOP] ); fillVariableWithValue( "muonTDTCellSamePhi", muonDTHaveCellsSamePhi[indexTOP] ); if(muonDTHaveCellsSameEta[indexTOP] || muonDTHaveCellsSamePhi[indexTOP]) fillVariableWithValue( "muonTDTCellSmEtaOrPhi", 1 ); fillVariableWithValue( "muonTDTP", muonDTP[indexTOP] ); fillVariableWithValue( "muonTDTPt", muonDTPt[indexTOP] ); if(muonDTnrstTrkIdx[indexTOP]>=0) { fillVariableWithValue( "muonTDTtrkChi2", trackChi2[muonDTnrstTrkIdx[indexTOP]] ); fillVariableWithValue( "muonTDTtrkNdof", trackNdof[muonDTnrstTrkIdx[indexTOP]] ); fillVariableWithValue( "muonTDTtrkNrmChi2", trackChi2[muonDTnrstTrkIdx[indexTOP]]/trackNdof[muonDTnrstTrkIdx[indexTOP]] ); fillVariableWithValue( "muonTDTtrkP", trackP[muonDTnrstTrkIdx[indexTOP]] ); fillVariableWithValue( "muonTDTtrkPt", trackPt[muonDTnrstTrkIdx[indexTOP]] ); double relDeltaP = ( muonDTP[indexTOP] - trackP[muonDTnrstTrkIdx[indexTOP]] ) / trackP[muonDTnrstTrkIdx[indexTOP]]; double relDeltaPt = ( muonDTPt[indexTOP] - trackPt[muonDTnrstTrkIdx[indexTOP]] ) / trackPt[muonDTnrstTrkIdx[indexTOP]]; fillVariableWithValue( "muonTDTtrkRelDeltaP", relDeltaP ); fillVariableWithValue( "muonTDTtrkRelDeltaPt", relDeltaPt ); } //bottom fillVariableWithValue( "muonBDXY_DT_TRK", muonDTnrstTrkDXY[indexBOTTOM] ); fillVariableWithValue( "muonBDZ_DT_TRK", muonDTnrstTrkDZ[indexBOTTOM] ); fillVariableWithValue( "muonBDTNHits", muonDTNumRecHits[indexBOTTOM] ); fillVariableWithValue( "muonBDTNValidHits", muonDTNumValidRecHits[indexBOTTOM] ); fillVariableWithValue( "muonBDTEtaAtHB", max(muonDTEtaAtInHB[indexBOTTOM],muonDTEtaAtOutHB[indexBOTTOM]) ); fillVariableWithValue( "muonBDTPhiAtHB", max(muonDTPhiAtInHB[indexBOTTOM],muonDTPhiAtOutHB[indexBOTTOM]) ); fillVariableWithValue( "muonBDTLenghtHB", muonDTLengthInHB[indexBOTTOM] ); fillVariableWithValue( "muonBDTdRHitMuInHB", muonDTdeltaRatInHB[indexBOTTOM] ); fillVariableWithValue( "muonBDTdRHitMuOutHB", muonDTdeltaRatOutHB[indexBOTTOM] ); fillVariableWithValue( "muonBDTEnergy", muonDTTotEnergy[indexBOTTOM] ); double normEnergyBOTTOM = (muonDTTotEnergy[indexBOTTOM] / muonDTLengthInHB[indexBOTTOM]) * LenghtHB; fillVariableWithValue( "muonBDTEnergyNorm", normEnergyBOTTOM ); fillVariableWithValue( "muonBDTNCells", muonDTNumCells[indexBOTTOM] ); fillVariableWithValue( "muonBDTCellSameEta", muonDTHaveCellsSameEta[indexBOTTOM] ); fillVariableWithValue( "muonBDTCellSamePhi", muonDTHaveCellsSamePhi[indexBOTTOM] ); if(muonDTHaveCellsSameEta[indexBOTTOM] || muonDTHaveCellsSamePhi[indexBOTTOM]) fillVariableWithValue( "muonBDTCellSmEtaOrPhi", 1 ); fillVariableWithValue( "muonBDTP", muonDTP[indexBOTTOM] ); fillVariableWithValue( "muonBDTPt", muonDTPt[indexBOTTOM] ); if(muonDTnrstTrkIdx[indexBOTTOM]>=0) { fillVariableWithValue( "muonBDTtrkChi2", trackChi2[muonDTnrstTrkIdx[indexBOTTOM]] ); fillVariableWithValue( "muonBDTtrkNdof", trackNdof[muonDTnrstTrkIdx[indexBOTTOM]] ); fillVariableWithValue( "muonBDTtrkNrmChi2", trackChi2[muonDTnrstTrkIdx[indexBOTTOM]]/trackNdof[muonDTnrstTrkIdx[indexBOTTOM]] ); fillVariableWithValue( "muonBDTtrkP", trackP[muonDTnrstTrkIdx[indexBOTTOM]] ); fillVariableWithValue( "muonBDTtrkPt", trackPt[muonDTnrstTrkIdx[indexBOTTOM]] ); double relDeltaP = ( muonDTP[indexBOTTOM] - trackP[muonDTnrstTrkIdx[indexBOTTOM]] ) / trackP[muonDTnrstTrkIdx[indexBOTTOM]]; double relDeltaPt = ( muonDTPt[indexBOTTOM] - trackPt[muonDTnrstTrkIdx[indexBOTTOM]] ) / trackPt[muonDTnrstTrkIdx[indexBOTTOM]]; fillVariableWithValue( "muonBDTtrkRelDeltaP", relDeltaP ); fillVariableWithValue( "muonBDTtrkRelDeltaPt", relDeltaPt ); } } } // Evaluate cuts (but do not apply them) evaluateCuts(); if( passedCut("0") && passedCut("1") && passedCut("2") && passedCut("3") && passedCut("4") ) { if( muonDTCount >=2 ) { int indexTOP=-1; int indexBOTTOM=-1; if(muonDTYin[0]>0 && muonDTYout[0]>0) indexTOP = 0; else if(muonDTYin[0]<0 && muonDTYout[0]<0) indexBOTTOM = 0; if(muonDTYin[1]>0 && muonDTYout[1]>0) indexTOP = 1; else if(muonDTYin[1]<0 && muonDTYout[1]<0) indexBOTTOM = 1; if(indexTOP >= 0 && indexBOTTOM >= 0) { if(muonDTnrstTrkIdx[indexTOP]>=0) { double relDeltaP = ( muonDTP[indexTOP] - trackP[muonDTnrstTrkIdx[indexTOP]] ) / trackP[muonDTnrstTrkIdx[indexTOP]]; h_RelDeltaP_vs_trkP_top->Fill(trackP[muonDTnrstTrkIdx[indexTOP]] , relDeltaP); h_muonDTP_vs_trkP_top->Fill(trackP[muonDTnrstTrkIdx[indexTOP]] , muonDTP[indexTOP]); } if(muonDTnrstTrkIdx[indexBOTTOM]>=0) { double relDeltaP = ( muonDTP[indexBOTTOM] - trackP[muonDTnrstTrkIdx[indexBOTTOM]] ) / trackP[muonDTnrstTrkIdx[indexBOTTOM]]; h_RelDeltaP_vs_trkP_bottom->Fill(trackP[muonDTnrstTrkIdx[indexBOTTOM]] , relDeltaP); h_muonDTP_vs_trkP_bottom->Fill(trackP[muonDTnrstTrkIdx[indexBOTTOM]] , muonDTP[indexBOTTOM]); } } } } ////////////////////// User's code ends here /////////////////////// } // End loop over events //////////write histos #ifdef USE_EXAMPLE STDOUT("WARNING: using example code. In order NOT to use it, comment line that defines USE_EXAMPLE flag in Makefile."); h_nEleFinal->Write(); h_pT1stEle->Write(); h_pT2ndEle->Write(); //pT of both electrons, to be built using the histograms produced automatically by baseClass TH1F * h_pTElectrons = new TH1F ("h_pTElectrons","", getHistoNBins("pT1stEle"), getHistoMin("pT1stEle"), getHistoMax("pT1stEle")); h_pTElectrons->Add( & getHisto_noCuts_or_skim("pT1stEle") ); // all histos can be retrieved, see other getHisto_xxxx methods in baseClass.h h_pTElectrons->Add( & getHisto_noCuts_or_skim("pT2ndEle") ); //one could also do: *h_pTElectrons = getHisto_noCuts_or_skim("pT1stEle") + getHisto_noCuts_or_skim("pT2ndEle"); h_pTElectrons->Write(); //one could also do: const TH1F& h = getHisto_noCuts_or_skim// and use h #endif // end of USE_EXAMPLE h_RelDeltaP_vs_trkP_top->Write(); h_RelDeltaP_vs_trkP_bottom->Write(); h_muonDTP_vs_trkP_top->Write(); h_muonDTP_vs_trkP_bottom->Write(); std::cout << "analysisClass::Loop() ends" <<std::endl; }
void analysisClass::Loop() { std::cout << "analysisClass::Loop() begins" <<std::endl; if (fChain == 0) return; //////////book histos here #ifdef USE_EXAMPLE STDOUT("WARNING: using example code. In order NOT to use it, comment line that defines USE_EXAMPLE flag in Makefile."); // number of electrons TH1F *h_nEleFinal = new TH1F ("h_nEleFinal","",11,-0.5,10.5); h_nEleFinal->Sumw2(); //pT 1st ele TH1F *h_pT1stEle = new TH1F ("h_pT1stEle","",100,0,1000); h_pT1stEle->Sumw2(); //pT 2nd ele TH1F *h_pT2ndEle = new TH1F ("h_pT2ndEle","",100,0,1000); h_pT2ndEle->Sumw2(); #endif //end of USE_EXAMPLE /////////initialize variables Long64_t nentries = fChain->GetEntriesFast(); std::cout << "analysisClass::Loop(): nentries = " << nentries << std::endl; ////// 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++) { 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 every event #ifdef USE_EXAMPLE // Electrons vector<int> v_idx_ele_final; for(int iele=0;iele<eleCount;iele++) { // ECAL barrel fiducial region bool pass_ECAL_FR=false; if( fabs(eleEta[iele]) < getPreCutValue1("eleFidRegion") ) v_idx_ele_final.push_back(iele); } // Set the evaluation of the cuts to false and clear the variable values and filled status resetCuts(); // Set the value of the variableNames listed in the cutFile to their current value fillVariableWithValue("nEleFinal", v_idx_ele_final.size()) ; if( v_idx_ele_final.size() >= 1 ) { fillVariableWithValue( "pT1stEle", elePt[v_idx_ele_final[0]] ); } if( v_idx_ele_final.size() >= 2 ) { fillVariableWithValue( "pT2ndEle", elePt[v_idx_ele_final[1]] ); // Calculate Mee TLorentzVector v_ee, ele1, ele2; ele1.SetPtEtaPhiM(elePt[v_idx_ele_final[0]],eleEta[v_idx_ele_final[0]],elePhi[v_idx_ele_final[0]],0); ele2.SetPtEtaPhiM(elePt[v_idx_ele_final[1]],eleEta[v_idx_ele_final[1]],elePhi[v_idx_ele_final[1]],0); v_ee = ele1 + ele2; fillVariableWithValue( "invMass_ee", v_ee.M() ) ; } // Evaluate cuts (but do not apply them) evaluateCuts(); // Fill histograms and do analysis based on cut evaluation h_nEleFinal->Fill(v_idx_ele_final.size()); //if( v_idx_ele_final.size()>=1 ) h_pT1stEle->Fill(elePt[v_idx_ele_final[0]]); //if( v_idx_ele_final.size()>=2 && (elePt[v_idx_ele_final[0]])>85 ) h_pT2ndEle->Fill(elePt[v_idx_ele_final[1]]); if( passedCut("pT1stEle") ) h_pT1stEle->Fill(elePt[v_idx_ele_final[0]]); if( passedCut("pT2ndEle") ) h_pT2ndEle->Fill(elePt[v_idx_ele_final[1]]); // retrieve value of previously filled variables (after making sure that they were filled) double totpTEle; if ( variableIsFilled("pT1stEle") && variableIsFilled("pT2ndEle") ) totpTEle = getVariableValue("pT1stEle")+getVariableValue("pT2ndEle"); // 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; // ...... #endif // end of USE_EXAMPLE ////////////////////// User's code ends here /////////////////////// } // End loop over events //////////write histos #ifdef USE_EXAMPLE STDOUT("WARNING: using example code. In order NOT to use it, comment line that defines USE_EXAMPLE flag in Makefile."); h_nEleFinal->Write(); h_pT1stEle->Write(); h_pT2ndEle->Write(); //pT of both electrons, to be built using the histograms produced automatically by baseClass TH1F * h_pTElectrons = new TH1F ("h_pTElectrons","", getHistoNBins("pT1stEle"), getHistoMin("pT1stEle"), getHistoMax("pT1stEle")); h_pTElectrons->Add( & getHisto_noCuts_or_skim("pT1stEle") ); // all histos can be retrieved, see other getHisto_xxxx methods in baseClass.h h_pTElectrons->Add( & getHisto_noCuts_or_skim("pT2ndEle") ); //one could also do: *h_pTElectrons = getHisto_noCuts_or_skim("pT1stEle") + getHisto_noCuts_or_skim("pT2ndEle"); h_pTElectrons->Write(); //one could also do: const TH1F& h = getHisto_noCuts_or_skim// and use h #endif // end of USE_EXAMPLE std::cout << "analysisClass::Loop() ends" <<std::endl; }