Double_t VBFHinvis::deltaR(Double_t eta1, Double_t phi1, Double_t eta2, Double_t phi2) { Double_t deta = deltaEta(eta1, eta2); Double_t dphi = deltaPhi(phi1, phi2); Double_t dr = sqrt(deta*deta + dphi*dphi); return dr; }
double getFluct(Jets jets, int j){ double pt = jets.jtpt[j]; double fluct = getFluct1(pt); double dphi0 = fabs(deltaPhi(jets.jtphi[j],phi0)); if(dphi0 >= pi/4. && dphi0 <= 3.*pi/4.) fluct = getFluct2(pt); return pt*fluct; }
Double_t nmssm_wh_4b::deltaR(Double_t eta1, Double_t phi1, Double_t eta2, Double_t phi2) { Double_t deta = deltaEta(eta1, eta2); Double_t dphi = deltaPhi(phi1, phi2); Double_t dr = sqrt(deta*deta + dphi*dphi); return dr; }
Double_t deltaR(Double_t eta1, Double_t phi1, Double_t eta2, Double_t phi2) { Double_t dEta = deltaEta(eta1, eta2); Double_t dPhi = deltaPhi(phi1, phi2); Double_t dr = sqrt(dEta*dEta + dPhi*dPhi); return dr; }
double deltaR(const double& eta1, const double& phi1,const double& eta2, const double& phi2) { double deltaphi = deltaPhi(phi1, phi2); double deltaeta = deltaEta(eta1, eta2); double deltar = sqrt(deltaphi*deltaphi + deltaeta*deltaeta); return deltar; }
double deltaR (double phi1, double eta1, double phi2, double eta2) { double deltaphi = deltaPhi (phi1,phi2) ; double deltaeta = deltaEta (eta1,eta2) ; double deltar = sqrt(deltaphi*deltaphi + deltaeta*deltaeta) ; return deltar ; }
void fwliteExample(bool debug=false){ // event cuts const unsigned int maxEvents = -1; const double hfEThreshold = 3.0; const int nTowerThreshold = 1; // track cuts const double normD0Cut = 5.0; const double normDZCut = 5.0; const double ptDebug = 3.0; // trigger names const int nTrigs = 4; const char *hltNames[nTrigs] = {"HLT_MinBiasBSC","HLT_L1Jet6U","HLT_Jet15U","HLT_Jet30U"}; //----- input files (900 GeV data) ----- vector<string> fileNames; fileNames.push_back("./hiCommonSkimAOD.root"); //fileNames.push_back("../test/hiCommonSkimAOD.root"); fwlite::ChainEvent event(fileNames); //----- define output hists/trees in directories of output file ----- TFile *outFile = new TFile("output_fwlite.root","recreate"); TH1D::SetDefaultSumw2(); // evt hists outFile->cd(); outFile->mkdir("evt"); outFile->cd("evt"); TH1D *hL1TechBits = new TH1D("hL1TechBits","L1 technical trigger bits before mask",64,-0.5,63.5); TH2D *hHfTowers = new TH2D("hHfTowers","Number of HF tower above threshold; positive side; negative side",80,-0.5,79.5,80,-0.5,79.5); TH1D *hHLTPaths = new TH1D("hHLTPaths","HLT Paths",3,0,3); hHLTPaths->SetCanExtend(TH1::kAllAxes); // vtx hists outFile->cd(); outFile->mkdir("vtx"); outFile->cd("vtx"); TH1D *hVtxTrks = new TH1D("hVtxTrks","number of tracks used to fit pixel vertex",50,-0.5,49.5); TH1D *hVtxZ = new TH1D("hVtxZ","z position of best reconstructed pixel vertex", 80,-20,20); // track hists outFile->cd(); outFile->mkdir("trk"); outFile->cd("trk"); TH1D *hTrkPt = new TH1D("hTrkPt","track p_{T}; p_{T} [GeV/c]", 80, 0.0, 20.0); TH1D *hTrkEta = new TH1D("hTrkEta","track #eta; #eta", 60, -3.0, 3.0); TH1D *hTrkPhi = new TH1D("hTrkPhi","track #phi; #phi [radians]", 56, -3.5, 3.5); // correlation hists outFile->cd(); outFile->mkdir("corr"); outFile->cd("corr"); TH2D *hDetaDphi = new TH2D("hDetaDphi","raw two-particle correlation; #Delta#eta; #Delta#phi",50,-5.0,5.0,50,-3.1416,3.1416); // debug ntuple outFile->cd(); TNtuple *nt=0; if(debug) nt = new TNtuple("nt","track debug ntuple", "pt:eta:phi:hits:pterr:d0:d0err:dz:dzerr:jet6:jet15:jet30"); //----- loop over events ----- unsigned int iEvent=0; for(event.toBegin(); !event.atEnd(); ++event, ++iEvent){ if( iEvent == maxEvents ) break; if( iEvent % 1000 == 0 ) cout << "Processing " << iEvent<< "th event: " << "run " << event.id().run() << ", lumi " << event.luminosityBlock() << ", evt " << event.id().event() << endl; // select on L1 trigger bits fwlite::Handle<L1GlobalTriggerReadoutRecord> gt; gt.getByLabel(event, "gtDigis"); const TechnicalTriggerWord& word = gt->technicalTriggerWord(); //before mask for(int bit=0; bit<64; bit++) hL1TechBits->Fill(bit,word.at(bit)); if(!word.at(0)) continue; // BPTX coincidence if(!(word.at(40) || word.at(41))) continue; // BSC coincidence if(word.at(36) || word.at(37) || word.at(38) || word.at(39)) continue; // BSC halo // select on coincidence of HF towers above threshold fwlite::Handle<CaloTowerCollection> towers; towers.getByLabel(event, "towerMaker"); int nHfTowersN=0, nHfTowersP=0; for(CaloTowerCollection::const_iterator calo = towers->begin(); calo != towers->end(); ++calo) { if(calo->energy() < hfEThreshold) continue; if(calo->eta()>3) nHfTowersP++; if(calo->eta()<-3) nHfTowersN++; } hHfTowers->Fill(nHfTowersP,nHfTowersN); if(nHfTowersP < nTowerThreshold || nHfTowersN < nTowerThreshold) continue; // get hlt bits bool accept[nTrigs]={}; fwlite::Handle<edm::TriggerResults> triggerResults; triggerResults.getByLabel(event, "TriggerResults","","HLT"); const edm::TriggerNames triggerNames = event.triggerNames(*triggerResults); for(int i=0; i<nTrigs; i++) { accept[i] = triggerResults->accept(triggerNames.triggerIndex(hltNames[i])); if(accept[i]) hHLTPaths->Fill(hltNames[i],1); } // select on requirement of valid vertex math::XYZPoint vtxpoint(0,0,0); fwlite::Handle<std::vector<reco::Vertex> > vertices; vertices.getByLabel(event, "hiSelectedVertex"); if(!vertices->size()) continue; const reco::Vertex & vtx = (*vertices)[0]; vtxpoint.SetCoordinates(vtx.x(),vtx.y(),vtx.z()); hVtxTrks->Fill(vtx.tracksSize()); hVtxZ->Fill(vtx.z()); // get beamspot fwlite::Handle<reco::BeamSpot> beamspot; beamspot.getByLabel(event, "offlineBeamSpot"); //----- loop over tracks ----- fwlite::Handle<std::vector<reco::Track> > tracks; tracks.getByLabel(event, "hiSelectedTracks"); for(unsigned it=0; it<tracks->size(); ++it){ const reco::Track & trk = (*tracks)[it]; // select tracks based on transverse proximity to beamspot double dxybeam = trk.dxy(beamspot->position()); if(fabs(dxybeam/trk.d0Error()) > normD0Cut) continue; // select tracks based on z-proximity to best vertex double dzvtx = trk.dz(vtxpoint); if(fabs(dzvtx/trk.dzError()) > normDZCut) continue; // fill selected track histograms and debug ntuple hTrkPt->Fill(trk.pt()); hTrkEta->Fill(trk.eta()); hTrkPhi->Fill(trk.phi()); if(debug && trk.pt() > ptDebug) // fill debug ntuple for selection of tracks nt->Fill(trk.pt(),trk.eta(),trk.phi(),trk.numberOfValidHits(),trk.ptError(), dxybeam,trk.d0Error(),dzvtx,trk.dzError(),accept[1],accept[2],accept[3]); } //----- loop over jets ----- fwlite::Handle<vector<reco::CaloJet> > jets; jets.getByLabel(event, "iterativeConePu5CaloJets"); //----- loop over muons ----- //----- loop over photons ----- //----- loop over charged candidates ----- fwlite::Handle<vector<reco::RecoChargedCandidate> > candidates; candidates.getByLabel(event, "allTracks"); for(unsigned it1=0; it1<candidates->size(); ++it1) { const reco::RecoChargedCandidate & c1 = (*candidates)[it1]; for(unsigned it2=0; it2<candidates->size(); ++it2) { if(it1==it2) continue; const reco::RecoChargedCandidate & c2 = (*candidates)[it2]; hDetaDphi->Fill(c1.eta()-c2.eta(),deltaPhi(c1.phi(),c2.phi())); } } } //end loop over events cout << "Number of events processed : " << iEvent << endl; cout << "Number passing all event selection cuts: " << hVtxZ->GetEntries() << endl; // write to output file hHLTPaths->LabelsDeflate(); outFile->Write(); outFile->ls(); outFile->Close(); }
// === Main Function =================================================== void hadTau2(unsigned int id = 11, const TString &effName = "../data/LostLepton_MuonEfficienciesFromWJetMC.root", const TString &respTempl = "../data/HadTau_TauResponseTemplates.root", int nEvts = -1) { const bool isMC = ( id >= 10 ); // --- Declare the Output Histograms --------------------------------- const TString title = isMC ? "Hadronic-Tau Closure Test" : "Hadronic-Tau Prediction"; // Control plot: muon pt in the control sample TH1* hMuonPt = new TH1D("hMuonPt",title+";p_{T}(#mu^{gen}) [GeV];N(events)",50,0.,500.); hMuonPt->Sumw2(); // Predicted distributions TH1* hPredHt = new TH1D("hPredHt",title+";H_{T} [GeV];N(events)",25,500.,3000.); hPredHt->Sumw2(); TH1* hPredMht = new TH1D("hPredMht",title+";#slash{H}_{T} [GeV];N(events)",20,200.,1200.); hPredMht->Sumw2(); TH1* hPredNJets = new TH1D("hPredNJets",title+";N(jets);N(events)",9,3,12); hPredNJets->Sumw2(); // In case of MC: true distributions TH1* hTrueHt = static_cast<TH1*>(hPredHt->Clone("hTrueHt")); TH1* hTrueMht = static_cast<TH1*>(hPredMht->Clone("hTrueMht")); TH1* hTrueNJets = static_cast<TH1*>(hPredNJets->Clone("hTrueNJets")); // Event yields in the different RA2 search bins // First bin (around 0) is baseline selection TH1* hPredYields = new TH1D("hPredYields",title+";;N(events)",37,-0.5,36.5); hPredYields->Sumw2(); hPredYields->GetXaxis()->SetBinLabel(1,"baseline"); for(int bin = 2; bin <= hPredYields->GetNbinsX(); ++bin) { TString label = "Bin "; label += bin-1; hPredYields->GetXaxis()->SetBinLabel(bin,label); } TH1* hTrueYields = static_cast<TH1*>(hPredYields->Clone("hTrueYields")); // --- Tau Templates and Muon Efficiencies --------------------------- // Interface to the tau response templates TauResponse tauResp(respTempl); // Interfaces to the muon acceptance as well as reconstruction and // isolation efficiencies LeptonAcceptance muonAcc(effName,LeptonAcceptance::nameMuonAcc()); LeptonEfficiency muonRecoEff(effName,LeptonEfficiency::nameMuonRecoEff()); LeptonEfficiency muonIsoEff(effName,LeptonEfficiency::nameMuonIsoEff()); // --- Analyse the events -------------------------------------------- // Interface to the event content Event* evt = new Event(Sample::fileNameFullSample(id),nEvts); // Loop over the events (tree entries) while( evt->loadNext() ) { // Select the control sample: // - select events with exactly one well-reconstructed, isolated muon // Use the muon to predict the energy deposits of the // hadronically decaying tau: // - scale the muon pt by a random factor drawn from the // tau-reponse template to simulate the tau measurement // - use the simulated tau-pt to predict HT, MHT, and N(jets) if( evt->isoMuonsN() == 1 && evt->isoElectronsN() == 0 ) { // The kinematic properties of the well-reconstructed, isolated muon const float muPt = evt->isoMuonsPt()[0]; const float muEta = evt->isoMuonsEta()[0]; const float muPhi = evt->isoMuonsPhi()[0]; // Use only events where the muon is inside acceptance if( muPt < TauResponse::ptMin() ) continue; if( std::abs( muEta ) > TauResponse::etaMax() ) continue; // "Cross cleaning": find the jet that corresponds to // the muon. Associate the jet that is closest in // in eta-phi space to the lepton int muJetIdx = -1; const float deltaRMax = 0.2; if( !utils::findMatchedObject(muJetIdx,muEta,muPhi,evt->jetsEta(),evt->jetsPhi(),evt->jetsN(),deltaRMax) ) continue; // Calculate RA2 selection-variables from "cleaned" jets int selNJet = 0; float selHt = 0.; float selMhtX = 0.; float selMhtY = 0.; for(int jetIdx = 0; jetIdx < evt->jetsN(); ++jetIdx) { // Loop over reco jets // Skip this jet if it is the muon if( jetIdx == muJetIdx ) continue; // Calculate NJet and HT if( evt->jetsPt()[jetIdx] > Selection::htJetPtMin() && std::abs(evt->jetsEta()[jetIdx]) < Selection::htJetEtaMax() ) { selNJet++; selHt += evt->jetsPt()[jetIdx]; } // Calculate MHT if( evt->jetsPt()[jetIdx] > Selection::mhtJetPtMin() && std::abs(evt->jetsEta()[jetIdx]) < Selection::mhtJetEtaMax() ) { selMhtX -= evt->jetsPt()[jetIdx]*cos(evt->jetsPhi()[jetIdx]); selMhtY -= evt->jetsPt()[jetIdx]*sin(evt->jetsPhi()[jetIdx]); } } // End of loop over reco jets // Select only events with at least 2 HT jets if( selNJet < 2 ) continue; // Plot the muon pt as control plot hMuonPt->Fill(muPt); // Get random number from tau-response template // The template is chosen according to the muon pt const float scale = tauResp.getRandom(muPt); // Scale muon pt with tau response --> simulate tau jet pt const float simTauJetPt = scale * muPt; const float simTauJetEta = muEta; const float simTauJetPhi = muPhi; // Taking into account the simulated tau jet, recompute // HT, MHT, and N(jets) int simNJet = selNJet; float simHt = selHt; float simMhtX = selMhtX; float simMhtY = selMhtY; // If simulted tau-jet meets same criteria as as HT jets, // recompute NJets and HT if( simTauJetPt > Selection::htJetPtMin() && std::abs(muEta) < Selection::htJetEtaMax() ) { simNJet++; simHt += simTauJetPt; } // If simulated tau-jet meets same criteria as MHT jets, // recompute MHT if( simTauJetPt > Selection::mhtJetPtMin() && std::abs(muEta) < Selection::mhtJetEtaMax() ) { simMhtX -= simTauJetPt*cos(muPhi); simMhtY -= simTauJetPt*sin(muPhi); } const float simMht = sqrt( simMhtX*simMhtX + simMhtY*simMhtY ); const float simMhtPhi = std::atan2(simMhtY,simMhtX); // Apply baseline selection if( !Selection::nJets(simNJet) ) continue; if( !Selection::ht(simHt) ) continue; if( !Selection::mht(simMht) ) continue; if( !deltaPhi(simMhtPhi,evt->jetsN(),evt->jetsPt(),evt->jetsEta(),evt->jetsPhi(),muJetIdx,simTauJetPt,simTauJetEta,simTauJetPhi) ) continue; // Corrections to control sample const double corrBRWToTauHad = 0.65; // Correction for the BR of hadronic tau decays const double corrBRTauToMu = 1./1.15; // Correction for the fact that some muons could come from leptonic decays of taus from W decays const double acc = muonAcc(evt->mht(),evt->nJets()); const double recoEff = muonRecoEff(evt->ht(),evt->mht(),evt->nJets()); const double isoEff = muonIsoEff(evt->ht(),evt->mht(),evt->nJets()); if( !( acc > 0. && recoEff > 0. && isoEff > 0. ) ) continue; const double corrMuAcc = 1./acc; // Correction for muon acceptance const double corrMuRecoEff = 1./recoEff; // Correction for muon reconstruction efficiency const double corrMuIsoEff = 1./isoEff; // Correction for muon isolation efficiency // The overall correction factor const double corr = corrBRTauToMu * corrBRWToTauHad * corrMuAcc * corrMuRecoEff * corrMuIsoEff; // Fill the prediction hPredHt->Fill(simHt,corr); hPredMht->Fill(simMht,corr); hPredNJets->Fill(simNJet,corr); // Predicted event yields hPredYields->Fill(0.,corr); const unsigned int searchBin = Selection::searchBin(simHt,simMht,simNJet); if( searchBin > 0 ) { hPredYields->Fill(searchBin,corr); } } // End if exactly one muon if( isMC ) { // Fill the 'truth' for comparison with the prediction // Select only events where the W decayed into a hadronically // decaying tau if( !( evt->flgW() == 15 && evt->flgTau() == 1 ) ) continue; // Apply baseline selection if( !Selection::nJets(evt->nJets()) ) continue; if( !Selection::ht(evt->ht()) ) continue; if( !Selection::mht(evt->mht()) ) continue; if( !Selection::deltaPhi(evt->deltaPhi1(),evt->deltaPhi2(),evt->deltaPhi3()) ) continue; hTrueHt->Fill(evt->ht()); hTrueMht->Fill(evt->mht()); hTrueNJets->Fill(evt->nJets()); // True event yields hTrueYields->Fill(0.); const unsigned int searchBin = Selection::searchBin(evt->ht(),evt->mht(),evt->nJets()); if( searchBin > 0 ) { hTrueYields->Fill(searchBin); } } // End isMC } // End of loop over events // --- Save the Histograms to File ----------------------------------- const TString outFileName = isMC ? "HadTau_WJetMC_Closure.root" : "HadTau_Data_Prediction.root"; TFile outFile(outFileName,"RECREATE"); hMuonPt->Write(); hTrueHt->Write(); hTrueMht->Write(); hTrueNJets->Write(); hTrueYields->Write(); hPredHt->Write(); hPredMht->Write(); hPredNJets->Write(); hPredYields->Write(); outFile.Close(); }
//!PG main function int selector (TChain * tree, histos & plots) { TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("otherJets", &otherJets) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; int EleId[100]; float IsolEleSumPt[100]; int nEle; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt",IsolEleSumPt ) ; float IsolMuSumPt[100]; int nMu ; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuSumPt",IsolMuSumPt ) ; int nentries = (int) tree->GetEntries () ; //std::cout << "nentries " << nentries << std::endl; //PG loop over the events // int nentries = 100 ; for (int evt = 0 ; evt < nentries ; ++evt) { tree->GetEntry (evt) ; int cutId = 0 ; plots.increase (cutId++) ; //PG 0 if (tagJets->GetEntries () != 2) continue ; plots.increase (cutId++) ; //PG 1 FIXME ctrl numbering //if (electrons->GetEntries () < 1 || // muons->GetEntries () < 1) continue ; plots.increase (cutId++) ; //PG 2 std::vector<lepton> leptons ; //PG pour electrons into leptons collection //PG --------------------------------------- //PG loop over electrons for (int iele = 0; iele < nEle ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //PG loop over electrons //PG loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } //PG loop over muons //PG this check is not necessary //PG if (leptons.size () < 2) continue ; //PG 2 LEPTONS //PG --------- /* applied after the leptons choice: in this case it is possible to differentiate the selections depending on the position of each lepton in the pt-sorting. the algorithm searches the first two most energetic candidates which satisfy the ID selections required for the first and second lepton respectively. If the so-identified first two leptons have the same flavour, the event is rejected, since it is expected to fall into the 2e or 2mu sub-channel. Is it certified that we do not have overlap? */ sort (leptons.rbegin (), leptons.rend (), lessThan ()) ; lepton primoLEP ; lepton secondoLEP ; //PG find the first lepton int ilep = 0 ; for ( ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < 0.2 ; // 0.2 per il momento if (g_ISO1[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID1 == 100 && (eleID/100) != 1) continue; else if (g_ID1 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID1 == 1 && (eleID%10) != 1) continue; } else //PG muon { //PG iso check bool muIso = (IsolMuSumPt[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < 0.2 ; // FIXME pass as parameter if (g_ISO1[1] == 1 && muIso != 1) continue; } primoLEP = leptons[ilep] ; break ; } //PG find the first lepton //PG find the second lepton for (++ilep ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < 0.2 ; // 0.2 per il momento if (g_ISO2[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID2 == 100 && (eleID/100) != 1) continue; else if (g_ID2 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID2 == 1 && (eleID%10) != 1) continue; } else //PG muon { //PG iso check bool muIso = (IsolMuSumPt[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < 0.2 ; // FIXME pass as parameter if (g_ISO2[1] == 1 && muIso != 1) continue; } secondoLEP = leptons[ilep] ; break ; } //PG find the second lepton //PG less than two leptons satisfying the ID is found if (primoLEP.m_flav == -1 || secondoLEP.m_flav == -1) continue ; plots.increase (cutId++) ; // 3 //PG check if the two most transverse-energetic leptons have the same flavour //if (primoLEP.m_flav == secondoLEP.m_flav) continue ; plots.increase (cutId++) ; // 4 //PG choose the sub-channel //PG ---------------------- bool select = true ; switch (g_sub_channel) { case 1 : if (primoLEP.m_flav != 0 || secondoLEP.m_flav != 0) select = false ; break ; case 2 : if (primoLEP.m_flav != 0 || secondoLEP.m_flav != 1) select = false ; break ; case 3 : if (primoLEP.m_flav != 1 || secondoLEP.m_flav != 0) select = false ; break ; case 4 : if (primoLEP.m_flav != 1 || secondoLEP.m_flav != 1) select = false ; break ; } ; if (!select) continue ; plots.increase (cutId++) ; //PG 2 //PG find the two most energetic leptons //PG ----------------------------------- if (primoLEP.m_kine->Pt () < g_hardLEPPtMin[primoLEP.m_flav]) continue ; plots.increase (cutId++) ; // 5 if (secondoLEP.m_kine->Pt () < g_softLEPPtMin[secondoLEP.m_flav]) continue ; plots.increase (cutId++) ; // 6 double lep_deltaPhi = deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()); double lep_deltaEta = fabs(primoLEP.m_kine->Eta () - secondoLEP.m_kine->Eta ()); if (deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) < g_LEPDPhiMin) continue ; plots.increase (cutId++) ; //PG 7 if (deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) > g_LEPDPhiMax) continue ; plots.increase (cutId++) ; //PG 8 TLorentzVector sumLEP = *(primoLEP.m_kine) + *(secondoLEP.m_kine) ; if (sumLEP.M () < g_LEPMinvMin) continue ; plots.increase (cutId++) ; //PG 9 if (sumLEP.M () > g_LEPMinvMax) continue ; plots.increase (cutId++) ; //PG 10 //PG MET //PG --- TLorentzVector* met = ((TLorentzVector*) (MET->At(0))) ; //correct for muons for (int i = 0 ; i < nMu ; i++) { TLorentzVector * mu_v = (TLorentzVector*) (muons->At (i)) ; if (mu_v->Pt () > 3) { met->SetPx (met->Px () - mu_v->Px ()) ; met->SetPy (met->Py () - mu_v->Py ()) ; } } // if (met->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 11 // if (((TLorentzVector*) (MET->At (0)))->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 10 //PG 2 TAGS //PG ------ TLorentzVector * primoTAG = (TLorentzVector*) (tagJets->At (0)) ; TLorentzVector * secondoTAG = (TLorentzVector*) (tagJets->At (1)) ; //PG get the first two in pt if (primoTAG->Pt () < secondoTAG->Pt ()) { primoTAG = (TLorentzVector*) (tagJets->At (1)) ; secondoTAG = (TLorentzVector*) (tagJets->At (0)) ; } if (met->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 11 TLorentzVector total = *primoTAG + *secondoTAG + sumLEP ; if (total.Pt () < g_PtTotMax) continue ; plots.increase (cutId++) ; //PG 11 total += *met ; if (total.Pt () > g_PtTotMetMax) continue ; plots.increase (cutId++) ; //PG 11 if (primoTAG->Pt () < g_hardTAGPtMin) continue ; plots.increase (cutId++) ; //PG 12 if (secondoTAG->Pt () < g_softTAGPtMin) continue ; plots.increase (cutId++) ; //PG 13 if (primoTAG->Eta () * secondoTAG->Eta () > g_TAGDProdEtaMax) continue ; plots.increase (cutId++) ; //PG 14 if (fabs (primoTAG->Eta () - secondoTAG->Eta ()) < g_TAGDetaMin) continue ; plots.increase (cutId++) ; //PG 15 TLorentzVector sumTAG = *primoTAG + *secondoTAG ; if (sumTAG.M () < g_TAGMinv) continue ; plots.increase (cutId++) ; //PG 16 //PG JET VETO //PG -------- //PG loop over other jets double etaMean = 0.5*(primoTAG->Eta () + secondoTAG->Eta ()); int ojetsNum = 0 ; for (int ojetIt = 0 ; ojetIt < otherJets->GetEntries () ; ++ojetIt) { if ( ((TLorentzVector*) (otherJets->At (ojetIt)))->Pt () < g_ojetPtMin) continue ; if ( ((TLorentzVector*) (otherJets->At (ojetIt)))->Eta () < primoTAG->Eta () || ((TLorentzVector*) (otherJets->At (ojetIt)))->Eta () > secondoTAG->Eta ()) continue ; //if ((((TLorentzVector*) (otherJets->At (ojetIt)))->Eta () - etaMean) > g_ojetEtaFromMean) continue; ++ojetsNum ; } //PG loop over other jets if (ojetsNum > g_ojetsMaxNum) continue ; plots.increase (cutId++) ; //PG 17 /* double primoDR = primoELE->DeltaR (*primoTAG) ; if (primoDR < primoELE->DeltaR (*secondoTAG)) primoDR = fabs (primoELE->Eta () - secondoTAG->Eta ()) ; double secondoDR = secondoELE->DeltaR (*primoTAG) ; if (secondoDR < secondoELE->DeltaR (*secondoTAG)) secondoDR = fabs (secondoELE->Eta () - secondoTAG->Eta ()) ; if (secondoDR < g_eleTagDR || primoDR < g_eleTagDR) continue ; plots.increase (cutId++) ; //PG 12 */ //PG Ztautau vetos //PG ------------- //PG the two electrons should not be opposite to each other TVector2 primoLEPT (primoLEP.m_kine->X (), primoLEP.m_kine->Y ()) ; TVector2 secondoLEPT (secondoLEP.m_kine->X (), secondoLEP.m_kine->Y ()) ; TVector2 METT (met->X (), met->Y ()) ; double Sum = METT * primoLEPT + METT * secondoLEPT / (1 + primoLEPT * secondoLEPT) ; double Dif = METT * primoLEPT - METT * secondoLEPT / (1 - primoLEPT * secondoLEPT) ; TVector2 METT1 = 0.5 * (Sum + Dif) * primoLEPT ; TVector2 METT2 = 0.5 * (Sum - Dif) * secondoLEPT ; double ptNu1 = METT1.Mod () / cos (primoLEP.m_kine->Theta ()) ; double ptNu2 = METT2.Mod () / cos (secondoLEP.m_kine->Theta ()) ; } //PG loop over the events plots.normalize () ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; return 0; }
//! main program int main (int argc, char** argv) { //---- output File ---- where saving histograms ---- bool flagOutput = false; std::string outputRootName = "outputHistos.root"; std::string testName = "-o"; if (argc>2) { if (argv[1] == testName) { outputRootName = argv[2]; flagOutput = true; std::cerr << " Name Output file = " << outputRootName << std::endl; } } if (argc>4) { if (argv[3] == testName) { outputRootName = argv[4]; flagOutput = true; std::cerr << " Name Output file = " << outputRootName << std::endl; } } //---- input File ---- where finding input parameters ---- //---- Input Variables ---- double R = 0.2; //---- Radius to match MC and Cluster double dEta_C_Cut = 0.05; //---- dEta to match MC and Cluster double dPhi_C_Cut = 0.1; //---- dPhi to match MC and Cluster double S4oS9C_Cut = 0.85; //---- S4oS9C_-Cluster cut ---- double ptC_Cut = 1.; //---- pt-Cluster cut ---- double ptSum_Cut = 2.; //---- pt-coppia cut ---- double RMax_Cut = 0.2; //---- RMax_Cut cut ---- isolation ---- double DeltaEtaMax_Cut = 0.05; //---- DeltaEtaMax_Cut ---- isolation ---- double et_Cut = 1.; //---- et_Cut ---- isolation ---- double iso_Cut = 0.4; //---- iso/pt-coppia cut ---- isolation ---- double angle_Cut = 0.105; //---- ~6° ---- Angle between two SC ---- double R_eta = 0.1; //---- summed cluster match with MC double dEta_eta = 0.05; double dPhi_eta = 0.1; double ptPh_Cut = 1.; //---- pt-Photon cut ---- int N_events = 10; //----numeber of events to analize -> -1 = all ---- std::string inputName; bool flagInput = false; std::string testNameInput = "-i"; if (argc>2) { if (argv[1] == testNameInput) { inputName = argv[2]; flagInput = true; std::cerr << " Name input file variables = " << inputName << std::endl; } } if (argc>4) { if (argv[3] == testNameInput) { inputName = argv[4]; flagInput = true; std::cerr << " Name input file variables = " << inputName << std::endl; } } if (flagInput) { char buffer[1000]; ifstream file(inputName.c_str()); std::string variableNameR = "R"; std::string variableNameS4oS9C_Cut = "S4oS9C_Cut"; std::string variableNamePtC_Cut = "ptC_Cut"; std::string variableNamePtSum_Cut = "ptSum_Cut"; std::string variableNameMax_Cut = "RMax_Cut"; std::string variableNameDeltaEtaMax_Cut = "DeltaEtaMax_Cut"; std::string variableNameEt_Cut = "et_Cut"; std::string variableNameIso_Cut = "iso_Cut"; std::string variableNameAngle_Cut = "angle_Cut"; std::string variableNameR_eta = "R_eta"; std::string variableNameN_events = "N_events"; std::string variableNameDEta_C_Cut = "dEta_C_Cut"; std::string variableNameDPhi_C_Cut = "dPhi_C_Cut"; std::string variableNameDEta_eta = "dEta_eta"; std::string variableNameDPhi_eta = "dPhi_eta"; std::string variableNamePtPh_Cut = "ptPh_Cut"; std::cerr << " Reading " << inputName << " ... " << std::endl; while (!file.eof()) { file.getline (&buffer[0],1000); std::istrstream line(buffer); std::string variableName; line >> variableName; double variableValue; line >> variableValue; std::cerr << " File -> " << variableName << " = " << variableValue << std::endl; if (variableName == variableNameR) R = variableValue; if (variableName == variableNameS4oS9C_Cut) S4oS9C_Cut = variableValue; if (variableName == variableNamePtC_Cut) ptC_Cut = variableValue; if (variableName == variableNamePtSum_Cut) ptSum_Cut = variableValue; if (variableName == variableNameMax_Cut) RMax_Cut = variableValue; if (variableName == variableNameDeltaEtaMax_Cut) DeltaEtaMax_Cut = variableValue; if (variableName == variableNameEt_Cut) et_Cut = variableValue; if (variableName == variableNameIso_Cut) iso_Cut = variableValue; if (variableName == variableNameAngle_Cut) angle_Cut = variableValue; if (variableName == variableNameR_eta) R_eta = variableValue; if (variableName == variableNameN_events) N_events = variableValue; if (variableName == variableNameDEta_C_Cut) dEta_C_Cut = variableValue; if (variableName == variableNameDPhi_C_Cut) dPhi_C_Cut = variableValue; if (variableName == variableNameDEta_eta) dEta_eta = variableValue; if (variableName == variableNameDPhi_eta) dPhi_eta = variableValue; if (variableName == variableNamePtPh_Cut) ptPh_Cut = variableValue; } } std::string testHelp = "--help"; if (argc==2) { if (argv[1] == testHelp) { std::cout << "Help" << std::endl ; std::cout << " --help : display help" << std::endl ; std::cout << " -o : output root file name (eg histograms.root)" << std::endl ; std::cout << " -i : input file name with cuts values (eg Cuts.txt)" << std::endl ; std::cout << " name of input file : list name of input files ntuples" << std::endl ; exit(1); } } if (argc < 2) { std::cerr << "ERROR : ntuple name missing" << std::endl ; exit (1) ; } TChain * chain = new TChain ("simplePhotonAnalyzer/tTreeUtilities") ; int numC_; int numCB_; int numCE_; std::vector<double> * etaC_; std::vector<double> * thetaC_; std::vector<double> * phiC_; std::vector<double> * S4oS9C_; std::vector<double> * S4C_; std::vector<double> * S9C_; std::vector<double> * S16C_; std::vector<double> * S25C_; std::vector<double> * pxC_; std::vector<double> * pyC_; std::vector<double> * pzC_; std::vector<double> * etC_; std::vector<int> * HitsC_; std::vector<double> * HitsEnergyC_; int numEta_; std::vector<int> * numPh_; //---- number of photons for each Eta ---- std::vector<double> * thetaPh_; std::vector<double> * etaPh_; std::vector<double> * phiPh_; std::vector<double> * pxPh_; std::vector<double> * pyPh_; std::vector<double> * pzPh_; etaC_ = new std::vector<double>; thetaC_ = new std::vector<double>; phiC_ = new std::vector<double>; S4oS9C_ = new std::vector<double>; S4C_ = new std::vector<double>; S9C_ = new std::vector<double>; S16C_ = new std::vector<double>; S25C_ = new std::vector<double>; pxC_ = new std::vector<double>; pyC_ = new std::vector<double>; pzC_ = new std::vector<double>; etC_ = new std::vector<double>; HitsC_ = new std::vector<int>; HitsEnergyC_ = new std::vector<double>; numPh_ = new std::vector<int>; thetaPh_ = new std::vector<double>; etaPh_ = new std::vector<double>; phiPh_ = new std::vector<double>; pxPh_ = new std::vector<double>; pyPh_ = new std::vector<double>; pzPh_ = new std::vector<double>; std::cerr << "---- Tree initialization ---- " << std::endl; //---- ---- Clusters ---- C = cluster ---- chain->SetBranchAddress("numC_",&numC_); chain->SetBranchAddress("numCB_",&numCB_); chain->SetBranchAddress("numCE_",&numCE_); chain->SetBranchAddress("etaC_",&etaC_); chain->SetBranchAddress("thetaC_",&thetaC_); chain->SetBranchAddress("phiC_",&phiC_); chain->SetBranchAddress("S4oS9C_",&S4oS9C_); chain->SetBranchAddress("S4C_",&S4C_); chain->SetBranchAddress("S9C_",&S9C_); chain->SetBranchAddress("S16C_",&S16C_); chain->SetBranchAddress("S25C_",&S25C_); chain->SetBranchAddress("pxC_",&pxC_); chain->SetBranchAddress("pyC_",&pyC_); chain->SetBranchAddress("pzC_",&pzC_); chain->SetBranchAddress("etC_",&etC_); chain->SetBranchAddress("HitsC_",&HitsC_); chain->SetBranchAddress("HitsEnergyC_",&HitsEnergyC_); //---- non è presente per ora ---- //---- ---- Photons from Eta ---- chain->SetBranchAddress("numEta_",&numEta_); chain->SetBranchAddress("numPh_",&numPh_); chain->SetBranchAddress("thetaPh_",&thetaPh_); chain->SetBranchAddress("etaPh_",&etaPh_); chain->SetBranchAddress("phiPh_",&phiPh_); chain->SetBranchAddress("pxPh_",&pxPh_); chain->SetBranchAddress("pyPh_",&pyPh_); chain->SetBranchAddress("pzPh_",&pzPh_); std::cerr << "---- End Tree initialization ---- " << std::endl; if (flagOutput && flagInput) { chain->Add (argv[5]) ; } if ((flagOutput && !flagInput) || ((!flagOutput && flagInput))) { chain->Add (argv[3]) ; } if (!flagOutput && !flagInput) { chain->Add (argv[1]) ; } std::cerr << "---- End Chain initialization ---- " << std::endl; //---- Histograms ---- // TH1F hInvMassEtaC("hInvMassEtaC","Invariant mass Eta from Clusters",1000, 0., 1.); // TH2F hInvMassEtaC_numC("hInvMassEtaC_numC","Invariant mass Eta from Clusters versus number of cluster selected",1000, 0., 1.,100, 0., 100.); // TH1F hPhotonPt("hPhotonPt","Photon pt",10000, 0., 10.); // TH1F hClusterPt("hClusterPt","Single Cluster pt",30000, 0., 30.); // TH1F hPtSum("hPtSum","Summed cluster pt",40000, 0., 40.); // TH1F hInvMassEta2CNoCuts("hInvMassEta2CNoCuts","Invariant mass Eta two cluster selection. No Cuts",1000, 0., 1.); // // TH2F hInvMassEta2CAndPtC1("hInvMassEta2CAndPtC1","Invariant mass Eta two cluster selection versus PtC1. No Cuts.",1000, 0., 1.,1000, 0., 10.); // TH2F hInvMassEta2CAndS4oS9C2("hInvMassEta2CAndS4oS9C2","Invariant mass Eta two cluster selection versus S4oS9. Cuts PtC1 e S4oS9 e PtC2.",1000, 0., 1.,1000, 0., 10.); // TH1F hIsolation("hIsolation","Isolation after all other cuts",1000, 0., 10.); // TH1F hAngle("hAngle","Angle between two BC, any pair of 2 BC",3600, 0., 2.*PI); // // //---- MC matching ---- // TH2F hInvMassEta2CAndPtC1MC("hInvMassEta2CAndPtC1MC","MC match. Invariant mass Eta two cluster selection versus PtC1. No Cuts.",1000, 0., 1.,1000, 0., 10.); // TH2F hInvMassEta2CAndS4oS9C1MC("hInvMassEta2CAndS4oS9C1MC","MC match. Invariant mass Eta two cluster selection versus S4oS9. Cuts PtC1.",1000, 0., 1.,1000, 0., 10.); // TH2F hInvMassEta2CAndPtC2MC("hInvMassEta2CAndPtC2MC","MC match. Invariant mass Eta two cluster selection versus PtC2. Cuts PtC1 e S4oS9.",1000, 0., 1.,1000, 0., 10.); // TH2F hInvMassEta2CAndS4oS9C2MC("hInvMassEta2CAndS4oS9C2MC","MC match. Invariant mass Eta two cluster selection versus S4oS9. Cuts PtC1 e S4oS9 e PtC2.",1000, 0., 1.,1000, 0., 10.); //---- MC Analysis and MC matching ---- TH1F hAngleMC("hAngleMC","MC Data. Angle between the two photons from eta",3600, 0., 2.*PI); TH1F hAngleEtaMC("hAngleEtaMC","MC Data. Angle Eta between the two photons from eta",1000,0.,10.); TH1F hAnglePhiMC("hAnglePhiMC","MC Data. Angle Phi between the two photons from eta",3600, 0., 2.*PI); TH1F hR_eta_C("hR_eta_C","Angle between reconstructed eta from BC without cuts and MC photons",1000, 0., 10.); TH1F hInvMassEtaPh("hInvMassEtaPh","Invariant mass Eta from MC Truth",10000, 0.547449999999, 0.547450000001); TH1F hInvMassEtaCMCTruth("hInvMassEtaCMCTruth","Invariant mass Eta from Clusters. Match with MC Truth",1000, 0., 1.); TH1F hAngleC_MCMatch("hAngleC_MCMatch","Angle between the two photons from BC and MC matching",3600, 0., 2.*PI); TH1F hNPhoton("hNPhoton","number of photons per eta from MC Truth",100, 0., 100.); TH1F hPhotonPt("hPhotonPt","Photon pt",10000, 0., 10.); //---- Data Analysis ---- before cuts ----- TH1F hAngle("hAngle","Angle between two BC, any pair of 2 BC",3600, 0., 2.*PI); TH1F hInvMassEta2CNoCuts("hInvMassEta2CNoCuts","Invariant mass Eta two cluster selection. NO CUTS",1000, 0., 1.); TH2F hInvMassEta2CETNoCuts("hInvMassEta2CETNoCuts","Invariant mass Eta two cluster selection Vs Et. No Cuts.",1000, 0., 1.,1000, 0., 10.); TH2F hInvMassEta2CETNoCutsMC("hInvMassEta2CETNoCutsMC","MC match. Invariant mass Eta two cluster selection vs Et. No Cuts.",1000, 0., 1.,1000, 0., 10.); TH2F h2CPtC1AndPtC2("h2CPtC1AndPtC2","PtC1 versus PtC2. No Cuts",1000, 0., 10.,1000, 0., 10.); //---- Data Analysis ---- after cuts ----- TH2F hInvMassEta2CAndS4oS9C("hInvMassEta2CAndS4oS9C","Invariant mass Eta two cluster selection versus S4oS9. Cuts PtC.",1000, 0., 1.,1000, 0., 10.); TH2F hInvMassEta2CAndS4oS9CMC("hInvMassEta2CAndS4oS9CMC","MC match. Invariant mass Eta two cluster selection versus S4oS9. Cuts PtC.",1000, 0., 1.,1000, 0., 10.); TH3F hInvMassEta2CAndS4oS9CAndPtC("hInvMassEta2CAndS4oS9CAndPtC","Invariant mass Eta two cluster selection versus S4oS9 and PtC. Cuts PtC",100, 0., 1.,100, 0., 10.,100, 0., 10.); TH2F hEta2CS4oS9CAndPtC("hEta2CS4oS9CAndPtC","S4oS9 C versus PtC. Cuts PtC",1000, 0., 10.,1000, 0., 10.); TH2F hInvMassEta2CAndPtCMC("hInvMassEta2CAndPtCMC","MC match. Invariant mass Eta two cluster selection versus PtC. Cuts PtC and S4oS9.",1000, 0., 1.,1000, 0., 10.); TH2F hInvMassEta2CAndPtC("hInvMassEta2CAndPtC","Invariant mass Eta two cluster selection versus PtC. Cuts PtC and S4oS9.",1000, 0., 1.,1000, 0., 10.); TH2F hInvMassEta2CAndIsolationMC("hInvMassEta2CAndIsolationMC","MC match. Invariant mass Eta two cluster selection versus Iso/PtSum. Cut ON",1000, 0., 1.,1000, 0., 10.); TH2F hInvMassEta2CAndIsolation("hInvMassEta2CAndIsolation","Invariant mass Eta two cluster selection versus Iso/PtSum. Cut ON",1000, 0., 1.,1000, 0., 10.); TH1F hIsolation("hIsolation","Isolation after all other cuts",1000, 0., 10.); TH1F hIsolationMC("hIsolationMC","MC match. Isolation after all other cuts",1000, 0., 10.); TH1F hInvMassEta2C("hInvMassEta2C","Invariant mass Eta two cluster selection. After ALL CUTS",1000, 0., 1.); TH1F hInvMassEta2CMC("hInvMassEta2CMC","MC match. Invariant mass Eta two cluster selection. After ALL CUTS",1000, 0., 1.); TH1F hAngleC("hAngleC","Angle between two BC. After ALL CUTS",3600, 0., 2.*PI); TH2F hInvMassEta2PtSumMC("hInvMassEta2PtSumMC","MC Match. Invariant mass Eta two cluster selection versus PtC_Sum. All Cuts",1000, 0., 1.,1000, 0., 100.); TH2F hInvMassEta2PtSum("hInvMassEta2PtSum","Invariant mass Eta two cluster selection versus PtC_Sum. All Cuts",1000, 0., 1.,1000, 0., 100.); //---- Input Variables Loaded ---- std::cerr << "Input Variables Loaded: " << std::endl; std::cerr << " R = " << R << std::endl; std::cerr << " S4oS9C_Cut = " << S4oS9C_Cut << std::endl; std::cerr << " ptC_Cut = " << ptC_Cut << std::endl; std::cerr << " ptSum_Cut = " << ptSum_Cut << std::endl; std::cerr << " RMax_Cut = " << RMax_Cut << std::endl; std::cerr << " DeltaEtaMax_Cut = " << DeltaEtaMax_Cut << std::endl; std::cerr << " et_Cut = " << et_Cut << std::endl; std::cerr << " iso_Cut = " << iso_Cut << std::endl; std::cerr << " angle_Cut = " << angle_Cut << std::endl; std::cerr << " R_eta = " << R_eta << std::endl; std::cerr << " N_events = " << N_events << std::endl; std::cerr << " dEta_C_Cut = " << dEta_C_Cut << std::endl; std::cerr << " dPhi_C_Cut = " << dPhi_C_Cut << std::endl; std::cerr << " dEta_eta = " << dEta_eta << std::endl; std::cerr << " dPhi_eta = " << dPhi_eta << std::endl; std::cerr << " ptPh_Cut = " << ptPh_Cut << std::endl; double RQ = R*R; double R_etaQ = R_eta*R_eta; //---- Starting analysis ---- int nEntries = chain->GetEntries () ; //---- MC Truth analysis ---- int FirstCluster = -1; int SecondCluster = -1; int numEntry = -1; TTree ClusterPairCMC("ClusterPairCMC","ClusterPairCMC"); ClusterPairCMC.Branch("FirstCluster",&FirstCluster,"FirstCluster/I"); ClusterPairCMC.Branch("SecondCluster",&SecondCluster,"SecondCluster/I"); ClusterPairCMC.Branch("numEntry",&numEntry,"numEntry/I"); bool flag2Photons; //--------------------- //---- MC Analysis ---- //--------------------- for (int entry = 0 ; entry < nEntries ; ++entry) //---- TEST VELOCE ---- { chain->GetEntry (entry) ; if (entry%10000 == 0) std::cout << "------> reading entry " << entry << " <------\n" ; numEntry = entry; //---- loop over etas ---- int counterPhotons = 0; for (int ii=0; ii<numEta_; ii++) { flag2Photons = false; FirstCluster = -1; SecondCluster = -1; math::XYZTLorentzVector pPh(0,0,0,0); math::XYZTLorentzVector pC(0,0,0,0); hNPhoton.Fill(numPh_->at(ii)); //---- calculate angle between two photons from Eta MC ---- double angle_MC = -1; //---- default value ---- if (numPh_->at(ii) == 2) { int counterPhotons_Angle = counterPhotons; //---- first photon ---- double pxPh_Angle_1 = pxPh_->at(counterPhotons_Angle); double pyPh_Angle_1 = pyPh_->at(counterPhotons_Angle); double pzPh_Angle_1 = pzPh_->at(counterPhotons_Angle); double EnergyPh_Angle_1 = sqrt(pxPh_Angle_1*pxPh_Angle_1 + pyPh_Angle_1*pyPh_Angle_1 + pzPh_Angle_1*pzPh_Angle_1); math::XYZTLorentzVector pPh_temp_Angle_1(pxPh_Angle_1,pyPh_Angle_1,pzPh_Angle_1,EnergyPh_Angle_1); double etaPh_Angle_1 = etaPh_->at(counterPhotons_Angle); double phiPh_Angle_1 = phiPh_->at(counterPhotons_Angle); //---- second photon ---- counterPhotons_Angle++; double pxPh_Angle_2 = pxPh_->at(counterPhotons_Angle); double pyPh_Angle_2 = pyPh_->at(counterPhotons_Angle); double pzPh_Angle_2 = pzPh_->at(counterPhotons_Angle); double EnergyPh_Angle_2 = sqrt(pxPh_Angle_2*pxPh_Angle_2 + pyPh_Angle_2*pyPh_Angle_2 + pzPh_Angle_2*pzPh_Angle_2); math::XYZTLorentzVector pPh_temp_Angle_2(pxPh_Angle_2,pyPh_Angle_2,pzPh_Angle_2,EnergyPh_Angle_2); double etaPh_Angle_2 = etaPh_->at(counterPhotons_Angle); double phiPh_Angle_2 = phiPh_->at(counterPhotons_Angle); double cosAngle = pxPh_Angle_1 * pxPh_Angle_2 + pyPh_Angle_1 * pyPh_Angle_2 + pzPh_Angle_1 * pzPh_Angle_2; if (EnergyPh_Angle_1!=0 && EnergyPh_Angle_2!=0) cosAngle = cosAngle / (EnergyPh_Angle_1 * EnergyPh_Angle_2); angle_MC = acos(cosAngle); hAngleMC.Fill(angle_MC); hAngleEtaMC.Fill(fabs(etaPh_Angle_1-etaPh_Angle_2)); hAnglePhiMC.Fill(fabs(phiPh_Angle_1-phiPh_Angle_2)); } //---- end calculate angle between two photons from Eta MC ---- int counterPh1 = -1; int counterPh2 = -1; bool flagFirstPhoton = false; bool flagSecondPhoton = false; //---- loop over photons generating an eta ---- for (int jj=0; jj<numPh_->at(ii); jj++) { double pxPh = pxPh_->at(counterPhotons); double pyPh = pyPh_->at(counterPhotons); double pzPh = pzPh_->at(counterPhotons); double ptPh = sqrt(pxPh * pxPh + pyPh * pyPh); double EnergyPh = sqrt(pxPh*pxPh + pyPh*pyPh + pzPh*pzPh); math::XYZTLorentzVector pPh_temp(pxPh,pyPh,pzPh,EnergyPh); double etaPh = etaPh_->at(counterPhotons); double phiPh = phiPh_->at(counterPhotons); pPh = pPh + pPh_temp; double bestTestValueRCQ = 100000; //---- loop over clusters ---- for (int kk=0; kk<numC_; kk++) { double etaC1 = etaC_->at(kk); double phiC1 = phiC_->at(kk); double RC1Q = (etaPh - etaC1) * (etaPh - etaC1) + (phiPh - phiC1) * (phiPh - phiC1); //---- Q at the end stands for ^2 ---- if (RC1Q < RQ) { //---- found a cluster near a photon ---- if (jj == 0) { //---- first photon ---- if ((bestTestValueRCQ > RC1Q) && (fabs(etaPh - etaC1) < dEta_C_Cut) && (fabs(phiPh - phiC1) < dPhi_C_Cut) && (ptPh > ptPh_Cut)) { FirstCluster = kk; counterPh1 = counterPhotons; bestTestValueRCQ = RC1Q; flagFirstPhoton = true; } } else { //---- second photon ---- if ((bestTestValueRCQ > RC1Q) && (fabs(etaPh - etaC1) < dEta_C_Cut) && (deltaPhi(phiPh,phiC1) < dPhi_C_Cut) && (ptPh > ptPh_Cut)) { SecondCluster = kk; //---- if I find a third photon ? --> Never found :D --> if it happens throw away eta event -> flag2Photons = false counterPh2= counterPhotons; bestTestValueRCQ = RC1Q; flagSecondPhoton = true; if (flagFirstPhoton) flag2Photons = true; //---- found 2 photons ---- } } double pxC = pxC_->at(kk); double pyC = pyC_->at(kk); double pzC = pzC_->at(kk); double EnergyC = sqrt(pxC*pxC + pyC*pyC + pzC*pzC); math::XYZTLorentzVector pC_temp(pxC,pyC,pzC,EnergyC); pC = pC + pC_temp; }//---- end found a cluster near a photon ---- }//---- end loop clusters ---- counterPhotons++; }//---- end loop photons generating an eta ---- if (numPh_->at(ii) != 2) flag2Photons = false; //---- I do NOT want != 2 photons events ---- bool flagEtaDirection = true; if (flag2Photons) { //---- match composite cluster <-> eta ---- //---- first photon ---- double etaPh1 = etaPh_->at(counterPh1); double phiPh1 = phiPh_->at(counterPh1); double pxPh1 = pxPh_->at(counterPh1); double pyPh1 = pyPh_->at(counterPh1); double pzPh1 = pzPh_->at(counterPh1); double EnergyPh1 = sqrt(pxPh1*pxPh1 + pyPh1*pyPh1 + pzPh1*pzPh1); math::XYZTLorentzVector pPh_temp1(pxPh1,pyPh1,pzPh1,EnergyPh1); //---- second photon ---- double etaPh2 = etaPh_->at(counterPh2); double phiPh2 = phiPh_->at(counterPh2); double pxPh2 = pxPh_->at(counterPh2); double pyPh2 = pyPh_->at(counterPh2); double pzPh2 = pzPh_->at(counterPh2); double EnergyPh2 = sqrt(pxPh2*pxPh2 + pyPh2*pyPh2 + pzPh2*pzPh2); math::XYZTLorentzVector pPh_temp2(pxPh2,pyPh2,pzPh2,EnergyPh2); math::XYZTLorentzVector pPh_Eta = pPh_temp1 + pPh_temp2; double etaEta = pPh_Eta.eta(); double phiEta = pPh_Eta.phi(); //---- sum cluster ---- double etaSumCluster = pC.eta(); double phiSumCluster = pC.phi(); double R_etaQ_C = (etaEta - etaSumCluster) * (etaEta - etaSumCluster) + deltaPhi(phiEta,phiSumCluster) * deltaPhi(phiEta,phiSumCluster); if ((R_etaQ_C < R_etaQ) && (fabs(etaSumCluster - etaEta) < dEta_eta) && (deltaPhi(phiSumCluster,phiEta) < dPhi_eta)) { //---- found a cluster near a photon ---- flagEtaDirection = true; } hR_eta_C.Fill(sqrt(R_etaQ_C)); } //---- end match composite cluster <-> eta ---- if (flag2Photons && flagEtaDirection) ClusterPairCMC.Fill(); //---- tree filling ---- //---- result in histograms ---- Only if I found two photons and if they are in the right position ---- if (flag2Photons && flagEtaDirection) { double ptPh = sqrt(pPh.x() * pPh.x() + pPh.y() * pPh.y()); hPhotonPt.Fill(ptPh); double InvMassPh = pPh.mag(); hInvMassEtaPh.Fill(InvMassPh); double InvMassC = pC.mag(); if (InvMassC != 0) hInvMassEtaCMCTruth.Fill(InvMassC); //---- if zero -> no clusters found ---- } } //---- end loop over etas ---- } //---- NO MC Truth analysis ---- Pair Analysis ---- //---- and MC Comparison ---- int FirstClusterAfter = -1; int SecondClusterAfter = -1; int numEntryAfter = -1; ClusterPairCMC.SetBranchAddress("FirstCluster",&FirstClusterAfter); ClusterPairCMC.SetBranchAddress("SecondCluster",&SecondClusterAfter); ClusterPairCMC.SetBranchAddress("numEntry",&numEntryAfter); int nEntriesMC = ClusterPairCMC.GetEntries () ; if (N_events == -1) N_events = nEntries; for (int entry = 0 ; entry < N_events ; ++entry) //---- TEST VELOCE ---- { chain->GetEntry (entry) ; if (entry%10000 == 0) std::cout << "------> No MC Truth ---- reading entry " << entry << " <------\n" ; std::cout << "------> No MC Truth ---- reading entry " << entry << " <------\n" ; std::vector<int> numC_Selected; math::XYZTLorentzVector pC(0,0,0,0); int numberC1; int numberC2; double EnergyPair; bool flagMCMatch; double angle_C; //---- Tree with Cluster data ---- TTree PairCluster("PairCluster","PairCluster"); PairCluster.Branch("numberC1",&numberC1,"numberC1/I"); PairCluster.Branch("numberC2",&numberC2,"numberC2/I"); PairCluster.Branch("EnergyPair",&EnergyPair,"EnergyPair/D"); PairCluster.Branch("flagMCMatch",&flagMCMatch,"flagMCMatch/O"); PairCluster.Branch("angle_C",&angle_C,"angle_C/D"); //---- loop over clusters ---- for (int kk=0; kk<numC_; kk++) { double etaC1 = etaC_->at(kk); double phiC1 = phiC_->at(kk); double pxC1 = pxC_->at(kk); double pyC1 = pyC_->at(kk); double pzC1 = pzC_->at(kk); double ptC1 = sqrt(pxC1*pxC1 + pyC1*pyC1); double EnergyC1 = sqrt(pxC1*pxC1 + pyC1*pyC1 + pzC1*pzC1); double EnergyTC1 = sqrt(pxC1*pxC1 + pyC1*pyC1); numberC1 = kk; math::XYZTLorentzVector pC2C_1(pxC1,pyC1,pzC1,EnergyC1); //---- save all pair-photons ---- for (int ll=kk+1; ll<numC_; ll++) { //---- inizio da kk così non rischio di avere doppioni ---- if (ll!=kk) { double pxCIn = pxC_->at(ll); double pyCIn = pyC_->at(ll); double pzCIn = pzC_->at(ll); double EnergyCIn = sqrt(pxCIn*pxCIn + pyCIn*pyCIn + pzCIn*pzCIn); math::XYZTLorentzVector pC2C_2(pxCIn,pyCIn,pzCIn,EnergyCIn); math::XYZTLorentzVector pC2C_sum = pC2C_1 + pC2C_2; numberC2 = ll; EnergyPair = pC2C_sum.mag(); //---- check if cluster pair correspond to a MC photon pair from eta ---- for (int entryMC = 0 ; entryMC < nEntriesMC ; ++entryMC) { ClusterPairCMC.GetEntry(entryMC); if (numEntryAfter == entry) { if (((FirstClusterAfter == ll) && (SecondClusterAfter == kk)) || ((FirstClusterAfter == kk) && (SecondClusterAfter == ll))) flagMCMatch = true; else flagMCMatch = false; } } //---- angle ---- double cosAngle = pxCIn * pxC1 + pyCIn * pyC1 + pzCIn * pzC1; if (EnergyCIn!=0 && EnergyC1!=0) cosAngle = cosAngle / (EnergyCIn * EnergyC1); else cosAngle = 0; //---- -> 90° -> rejected ---- angle_C = acos(cosAngle); hAngle.Fill(angle_C); if (flagMCMatch) hAngleC_MCMatch.Fill(angle_C); //---- Add to pair cluster only if Angle between Basic Clusters is less than "angle_cut" ---- if (angle_C < angle_Cut) PairCluster.Fill(); } }//---- end save all pair-photons ---- }//---- end loop clusters ---- //---- pair-photon tree analysis ---- //---- here add cuts ---- int numberC1After; int numberC2After; double EnergyPairAfter; bool flagMCMatchAfter; double angle_C_After; int nEntriesTreePairCluster = PairCluster.GetEntries () ; PairCluster.SetBranchAddress("numberC1",&numberC1After); PairCluster.SetBranchAddress("numberC2",&numberC2After); PairCluster.SetBranchAddress("EnergyPair",&EnergyPairAfter); PairCluster.SetBranchAddress("flagMCMatch",&flagMCMatchAfter); PairCluster.SetBranchAddress("angle_C",&angle_C_After); //---- loop over cluster-pair ---- for (int pairNumber = 0 ; pairNumber < nEntriesTreePairCluster ; ++pairNumber) { PairCluster.GetEntry(pairNumber); double etaC1_After = etaC_->at(numberC1After); double phiC1_After = phiC_->at(numberC1After); double pxC1_After = pxC_->at(numberC1After); double pyC1_After = pyC_->at(numberC1After); double pzC1_After = pzC_->at(numberC1After); double ptC1_After = sqrt(pxC1_After * pxC1_After + pyC1_After * pyC1_After); double EnergyC1_After = sqrt(pxC1_After * pxC1_After + pyC1_After * pyC1_After + pzC1_After * pzC1_After); math::XYZTLorentzVector pC1_After(pxC1_After,pyC1_After,pzC1_After,EnergyC1_After); double etaC2_After = etaC_->at(numberC2After); double phiC2_After = phiC_->at(numberC2After); double pxC2_After = pxC_->at(numberC2After); double pyC2_After = pyC_->at(numberC2After); double pzC2_After = pzC_->at(numberC2After); double ptC2_After = sqrt(pxC2_After * pxC2_After + pyC2_After * pyC2_After); double EnergyC2_After = sqrt(pxC2_After * pxC2_After + pyC2_After * pyC2_After + pzC2_After * pzC2_After); math::XYZTLorentzVector pC2_After(pxC2_After,pyC2_After,pzC2_After,EnergyC2_After); math::XYZTLorentzVector pC_Sum_After = pC1_After + pC2_After; double etaSum_After = pC_Sum_After.eta(); double phiSum_After = pC_Sum_After.phi(); double pxSum_After = pC_Sum_After.x(); double pySum_After = pC_Sum_After.y(); double pzSum_After = pC_Sum_After.z(); double ptSum_After = sqrt(pxSum_After * pxSum_After + pySum_After * pySum_After); double EnergySum_After = sqrt(pxSum_After * pxSum_After + pySum_After * pySum_After + pzSum_After * pzSum_After); //---- some graphs before cuts ---- hInvMassEta2CNoCuts.Fill(EnergyPairAfter); hInvMassEta2CETNoCuts.Fill(EnergyPairAfter,ptC1_After); //---- save only first cluster -> second cluster selected after ---- if (flagMCMatchAfter) { //---- save only first cluster -> second cluster selected after ---- hInvMassEta2CETNoCutsMC.Fill(EnergyPairAfter,ptC1_After); } h2CPtC1AndPtC2.Fill(ptC1_After,ptC2_After); //---- end some graphs before cuts ---- //---- add cuts ---- //---- cut in pair -> both Clusters ---- //---- pt-Cluster cut Cluster 1 and Cluster 2 ---- if ((ptC1_After > ptC_Cut) && (ptC2_After > ptC_Cut)) { if (flagMCMatchAfter) hInvMassEta2CAndS4oS9CMC.Fill(EnergyPairAfter,S4oS9C_->at(numberC1After)); hInvMassEta2CAndS4oS9C.Fill(EnergyPairAfter,S4oS9C_->at(numberC1After)); hInvMassEta2CAndS4oS9CAndPtC.Fill(EnergyPairAfter,S4oS9C_->at(numberC1After),ptC1_After); hEta2CS4oS9CAndPtC.Fill(S4oS9C_->at(numberC1After),ptC1_After); //---- S4oS9C_-Cluster cut Cluster 1 and Cluster 2 ---- if ((S4oS9C_->at(numberC1After) > S4oS9C_Cut) && (S4oS9C_->at(numberC2After) > S4oS9C_Cut)) { if (flagMCMatchAfter) hInvMassEta2CAndPtCMC.Fill(EnergyPairAfter,ptC1_After); hInvMassEta2CAndPtC.Fill(EnergyPairAfter,ptC1_After); //---- Isolatio cut ---- double iso = 0; for (int ll=0; ll<numC_; ll++) { if ((ll!=numberC1After) && (ll!=numberC2After)) { double etaCIso = etaC_->at(ll); double phiCIso = phiC_->at(ll); double R = sqrt((etaCIso-etaSum_After)*(etaCIso-etaSum_After) + deltaPhi(phiCIso,phiSum_After) * deltaPhi(phiCIso,phiSum_After)); double deta = fabs(etaCIso - etaSum_After); double et = etC_->at(ll); if ( (R < RMax_Cut) && (deta < DeltaEtaMax_Cut) && (et > et_Cut) ) iso = iso + et ; } } if (flagMCMatchAfter) hInvMassEta2CAndIsolationMC.Fill(EnergyPairAfter,iso/ptSum_After); hInvMassEta2CAndIsolation.Fill(EnergyPairAfter,iso/ptSum_After); if (flagMCMatchAfter) hIsolationMC.Fill(iso/ptSum_After); hIsolation.Fill(iso/ptSum_After); if ((iso/ptSum_After) < iso_Cut) { if (flagMCMatchAfter) hInvMassEta2CMC.Fill(EnergyPairAfter); if (flagMCMatchAfter) hInvMassEta2PtSumMC.Fill(EnergyPairAfter,ptSum_Cut); hInvMassEta2PtSum.Fill(ptSum_Cut,EnergyPairAfter); if (ptSum_After < ptSum_Cut) hInvMassEta2C.Fill(EnergyPairAfter); hAngleC.Fill(angle_C_After); //---- cut on angle has been performed in pair filling ---- }//---- end Isolatio cut ---- }//---- end S4oS9C_-Cluster cut Cluster 1 and Cluster 2 ---- }//---- end pt-Cluster cut Cluster 1 and Cluster 2 }//---- end loop over cluster-pair ---- } //---- end loop entries ---- //---- save in file ---- TFile saving (outputRootName.c_str (),"recreate") ; saving.cd () ; hInvMassEtaPh.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEtaPh.Write(); hInvMassEtaCMCTruth.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEtaCMCTruth.Write(); hInvMassEta2C.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2C.Write(); hInvMassEta2CNoCuts.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CNoCuts.Write(); hInvMassEta2CETNoCuts.GetYaxis()->SetTitle("Et (GeV)"); hInvMassEta2CETNoCuts.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CETNoCuts.Write(); hInvMassEta2CAndIsolation.GetYaxis()->SetTitle("iso/PtSum"); hInvMassEta2CAndIsolation.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndIsolation.Write(); hInvMassEta2CAndPtC.GetYaxis()->SetTitle("PtC (GeV)"); hInvMassEta2CAndPtC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndPtC.Write(); hInvMassEta2CAndS4oS9C.GetYaxis()->SetTitle("S4oS9"); hInvMassEta2CAndS4oS9C.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndS4oS9C.Write(); hInvMassEta2CAndS4oS9CAndPtC.GetYaxis()->SetTitle("S4oS9"); hInvMassEta2CAndS4oS9CAndPtC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndS4oS9CAndPtC.GetZaxis()->SetTitle("Pt (GeV)"); hInvMassEta2CAndS4oS9CAndPtC.Write(); hEta2CS4oS9CAndPtC.GetYaxis()->SetTitle("Pt (GeV)"); hEta2CS4oS9CAndPtC.GetXaxis()->SetTitle("S4oS9"); hEta2CS4oS9CAndPtC.Write(); h2CPtC1AndPtC2.GetYaxis()->SetTitle("Pt C2 (GeV)"); h2CPtC1AndPtC2.GetXaxis()->SetTitle("Pt C1 (GeV)"); h2CPtC1AndPtC2.Write(); hIsolation.GetXaxis()->SetTitle("iso/PtSum"); hIsolation.Write(); hIsolationMC.GetXaxis()->SetTitle("iso/PtSum"); hIsolationMC.Write(); hAngleC.GetXaxis()->SetTitle("Angle between BC (rad)"); hAngleC.Write(); hAngle.GetXaxis()->SetTitle("Angle between BC (rad)"); hAngle.Write(); hInvMassEta2PtSum.GetYaxis()->SetTitle("Pt_Sum (GeV)"); hInvMassEta2PtSum.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2PtSum.Write(); //---- MC Match ---- hInvMassEta2PtSumMC.GetYaxis()->SetTitle("Pt_Sum (GeV)"); hInvMassEta2PtSumMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2PtSumMC.Write(); hInvMassEta2CETNoCutsMC.GetYaxis()->SetTitle("Et (GeV)"); hInvMassEta2CETNoCutsMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CETNoCutsMC.Write(); hInvMassEta2CAndPtCMC.GetYaxis()->SetTitle("PtC (GeV/c)"); hInvMassEta2CAndPtCMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndPtCMC.Write(); hInvMassEta2CAndS4oS9CMC.GetYaxis()->SetTitle("S4oS9"); hInvMassEta2CAndS4oS9CMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndS4oS9CMC.Write(); hInvMassEta2CAndIsolationMC.GetYaxis()->SetTitle("Iso/PtSum"); hInvMassEta2CAndIsolationMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CAndIsolationMC.Write(); hInvMassEta2CMC.GetXaxis()->SetTitle("Invariant Mass (GeV)"); hInvMassEta2CMC.Write(); hAngleMC.GetXaxis()->SetTitle("Angle between Photons(rad)"); hAngleMC.Write(); hAngleC_MCMatch.GetXaxis()->SetTitle("Angle between BC (rad)"); hAngleC_MCMatch.Write(); hAngleEtaMC.GetXaxis()->SetTitle("Angle Eta photons (rad)"); hAngleEtaMC.Write(); hAnglePhiMC.GetXaxis()->SetTitle("Angle Phi between photons (rad)"); hAnglePhiMC.Write(); hR_eta_C.GetXaxis()->SetTitle("#eta and #phi plane radius"); hR_eta_C.Write(); hNPhoton.GetXaxis()->SetTitle("number of photons per Eta"); hNPhoton.Write(); hPhotonPt.GetXaxis()->SetTitle("Pt of summed photons from Eta (GeV/c)"); hPhotonPt.Write(); //---- Save Cuts in File ---- TTree Cuts("Cuts","Cuts"); Cuts.Branch("R",&R,"R/D"); Cuts.Branch("S4oS9C_Cut",&S4oS9C_Cut,"S4oS9C_Cut/D"); Cuts.Branch("ptC_Cut",&ptC_Cut,"ptC_Cut/D"); Cuts.Branch("ptSum_Cut",&ptSum_Cut,"ptSum_Cut/D"); Cuts.Branch("RMax_Cut",&RMax_Cut,"RMax_Cut/D"); Cuts.Branch("DeltaEtaMax_Cut",&DeltaEtaMax_Cut,"DeltaEtaMax_Cut/D"); Cuts.Branch("et_Cut",&et_Cut,"et_Cut/D"); Cuts.Branch("iso_Cut",&iso_Cut,"iso_Cut/D"); Cuts.Branch("angle_Cut",&angle_Cut,"angle_Cut/D"); Cuts.Branch("R_eta",&R_eta,"R_eta/D"); Cuts.Branch("N_events",&N_events,"N_events/I"); Cuts.Branch("dEta_C_Cut",&dEta_C_Cut,"dEta_C_Cut/D"); Cuts.Branch("dPhi_C_Cut",&dPhi_C_Cut,"dPhi_C_Cut/D"); Cuts.Branch("dEta_eta",&dEta_eta,"dEta_eta/D"); Cuts.Branch("dPhi_eta",&dPhi_eta,"dPhi_eta/D"); Cuts.Branch("ptPh_Cut",&ptPh_Cut,"ptPh_Cut/D"); Cuts.Fill(); Cuts.Write(); saving.Close (); delete chain; return 0 ; }
double Chi2Func(const double *xx ){ const Double_t DX = xx[0]; const Double_t DY = xx[1]; const Double_t DZ = xx[2]; const Double_t DPHIEuler = xx[3]; ///==== Euler angles const Double_t DTHETAEuler = xx[4]; const Double_t DPSIEuler = xx[5]; /// The transform rotates first, then translates. /// The Euler angles are gotten from HepRotation::eulerAngles() /// (a HepTransform3D is a HepRotation and a HepTranslation). // CLHEP::HepEulerAngles RotMat((CLHEP::HepRotationZ( DPHIEuler )).eulerAngles()); CLHEP::HepEulerAngles RotMat(DPHIEuler,DTHETAEuler,DPSIEuler); HepGeom::Transform3D RotoTrasl( RotMat, CLHEP::Hep3Vector(DX,DY,DZ)); myTree->SetEntryList(0); myTree->Draw(">> myList",globalCut.Data(),"entrylist"); TEntryList *myList = (TEntryList*)gDirectory->Get("myList"); //==== bux fix in ROOT see https://savannah.cern.ch/bugs/?60569 ==== /* TIter next( myList->GetLists() ); if (myList->GetLists() != 0){ // if ((int) myList->GetLists() != 0){ TEntryList *ilist; while( (ilist = (TEntryList*) *next ) ) { ilist->SetTreeName(myTree->GetName()); next(); } TEntryList *duplist = (TEntryList*) myList->Clone(); delete myList; myList = duplist; } else { myList->SetTreeName(myTree->GetName()); } */ //==== end bux fix in ROOT see https://savannah.cern.ch/bugs/?60569 ==== myTree->SetEntryList(myList); myTree->Draw("DeltaEtaIn:DeltaPhiIn:etaSC:phiSC","","para goff"); int nEntries = myList->GetN(); Double_t *vTemp = myTree->GetV1(); Double_t *vDEta = new Double_t[nEntries]; for (int iEntry = 0; iEntry<nEntries; iEntry++){ vDEta[iEntry] = vTemp[iEntry]; } Double_t *vTemp2 = myTree->GetV2(); Double_t *vDPhi = new Double_t[nEntries]; for (int iEntry = 0; iEntry<nEntries; iEntry++){ vDPhi[iEntry] = vTemp2[iEntry]; } Double_t *vEta = myTree->GetV3(); Double_t *vPhi = myTree->GetV4(); myTree->Draw("E5x5:eleCharge","","para goff"); Double_t *vEnergy = myTree->GetV1(); Double_t *vCharge = myTree->GetV2(); Double_t vErrDEta; Double_t vErrDPhi; Double_t vErrEta; Double_t vErrPhi; double Chi2 = 0; int counter = 0; for (int iEntry = 0; iEntry < nEntries; iEntry++){ if ((even && !(iEntry%2)) || (odd && (iEntry%2))) { // if (!(iEntry%10)) { counter++; // for (int iEntry = 0; iEntry<nEntries; iEntry++){ // if (!(iEntry/100)) std::cout << " iEntry = " << iEntry << " : " << nEntries << std::endl; // std::cerr << " " << vDEta[iEntry] << std::endl; // std::cerr << " " << vDPhi[iEntry] << std::endl; // std::cerr << " " << vEta[iEntry] << std::endl; // std::cerr << " " << vPhi[iEntry] << std::endl; // std::cerr << " " << vEnergy[iEntry] << " " << std::endl; vErrDEta = fabs((sqrt(3.6 / sqrt(vEnergy[iEntry]) * 3.6 / sqrt(vEnergy[iEntry]) + 12. / vEnergy[iEntry] * 12. / vEnergy[iEntry] + 0.54*0.54)) / 1000. / (Z * tan(2*atan(exp(-vEta[iEntry])))) * fabs(sin(2*atan(exp(-vEta[iEntry]))))); ///===> /1000 perchè è in "mm" -> "m" vErrDPhi = 1.3 * fabs((sqrt(3.6 / sqrt(vEnergy[iEntry]) * 3.6 / sqrt(vEnergy[iEntry]) + 12. / vEnergy[iEntry] * 12. / vEnergy[iEntry] + 0.54*0.54)) / 1000. / (Z * tan(2*atan(exp(-vEta[iEntry]))))); ///===> /1000 perchè è in "mm" -> "m" vErrEta = 0.0; vErrPhi = 0.0; ///==== (x,y,z) HepGeom::Point3D<double> xyz( Z / cos(2*atan(exp(-vEta[iEntry]))) * sin(2*atan(exp(-vEta[iEntry]))) * cos (vPhi[iEntry]), Z / cos(2*atan(exp(-vEta[iEntry]))) * sin(2*atan(exp(-vEta[iEntry]))) * sin (vPhi[iEntry]), Z ); ///==== (x',y',z') = RotoTrasl(x,y,z) HepGeom::Point3D<double> xyz_prime = RotoTrasl * xyz; ///==== deta / dphi [(x',y',z'),(x,y,z)] double deta = xyz.pseudoRapidity() - xyz_prime.pseudoRapidity(); ///==== deta_data = SC - Tracker double dphi = deltaPhi(xyz.phi() , xyz_prime.phi()); ///==== check sign convention!!!!!!!!!!!!!!!!!!!!! double ddeta = (vDEta[iEntry] - deta); double ddphi = (vDPhi[iEntry] - dphi); ddeta = ddeta - FunctionDeta->Eval(vEta[iEntry],vCharge[iEntry]); ddphi = ddphi - FunctionDphi->Eval(vEta[iEntry],vCharge[iEntry]); Chi2 += (ddeta / vErrDEta * ddeta / vErrDEta + ddphi / vErrDPhi * ddphi / vErrDPhi); } } std::cout << " Chi2 = " << Chi2 << " / " << counter << " = " << Chi2/counter << " - " << DX*1000 << " mm: " << DY*1000 << " mm: " << DZ*1000 << " mm: " << DPHIEuler << " : " << DTHETAEuler << " : " << DPSIEuler << std::endl; return Chi2; }
void JPTRootAnalysisDataMCTau::Loop() { // In a ROOT session, you can do: // Root > .L JPTRootAnalysisDataMCTau.C // Root > JPTRootAnalysisDataMCTau 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(); // histos TH1F * hEtRaw = new TH1F( "hEtRaw", "EtRaw", 100, 0., 100.); TH1F * hEtaRaw = new TH1F( "hEtaRaw", "EtaRaw", 20, -2.0, 2.0); TH1F * hDRjettrk = new TH1F( "hDRjettrk", "DRjettrk", 30, 0., 0.6); TH1F * hd0ltr = new TH1F( "hd0ltr", "d0ltr", 25, 0., 0.05); TH1F * hptltr = new TH1F( "hptltr", "ptltr", 100, 0., 20); TH1F * hntrsign = new TH1F( "hntrsign", "ntrsign", 20, 0., 20); TH1F * hntrisol = new TH1F( "hntrisol", "ntrisol", 20, 0., 20); TH1F * hptminsign = new TH1F( "hptminsign", "ptminsign", 100, 0., 20); TH1F * hptminisol = new TH1F( "hptminisol", "ptminisol", 100, 0., 20); TH1F * hdzmaxltr = new TH1F( "hdzmaxltr", "dzmaxltr", 50, 0., 0.5); TH1F * hpisol = new TH1F( "hpisol", "pisol", 20, 0., 10.); const Int_t netbins = 6; const Int_t netcuts = netbins+1; Double_t et[netcuts]={10., 15., 20., 25., 30., 40., 60.}; TH1F * hetraw = new TH1F( "hetraw","etraw",netbins, et); TH1F * hetrawLeadtrk = new TH1F( "hetrawLeadtrk", "etrawLeadtrk",netbins, et); TH1F * hetrawTrkisol = new TH1F( "hetrawTrkisol", "etrawTrkisol",netbins, et); TH1F * hetrawElrejec = new TH1F( "hetrawElrejec", "etrawElrejec",netbins, et); TH1F * hetaraw = new TH1F( "hetaraw", "etaraw", 5, 0., 2.0); TH1F * hetarawLeadtrk = new TH1F( "hetarawLeadtrk", "etarawLeadtrk", 5, 0., 2.0); TH1F * hetarawTrkisol = new TH1F( "hetarawTrkisol", "etarawTrkisol", 5, 0., 2.0); TH1F * hetarawElrejec = new TH1F( "hetarawElrejec", "etarawElrejec", 5, 0., 2.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(jtau >= 2) { Float_t dphi = deltaPhi( (*PhiRaw)[0] , (*PhiRaw)[1] ); if(dphi > 2.14) { if( fabs((*EtaRaw)[0]) < 2.0 && fabs((*EtaRaw)[1]) < 2.0 ) { if( (*tcEt)[0] > 10. && (*tcEt)[1] > 10. ) { // et , eta raw for (unsigned int i = 0; i < 2; i++) { hEtRaw->Fill((*tcEt)[i]); hEtaRaw->Fill((*tcEta)[i]); } // DR jet track for (unsigned int i = 0; i < 2; i++) { hDRjettrk->Fill((*drltrjet)[i]); } // ip of tracks for (unsigned int i = 0; i < 2; i++) { hd0ltr->Fill((*d0ltr)[i]); } // pt of ltr for (unsigned int i = 0; i < 2; i++) { hptltr->Fill((*ptltr)[i]); } // ntr in signal cone for (unsigned int i = 0; i < 2; i++) { hntrsign->Fill((*ntrsign)[i]); } // ntr in isol cone for (unsigned int i = 0; i < 2; i++) { hntrisol->Fill( (*ntrisol)[i] - (*ntrsign)[i] ); } // pt min in signal cone for (unsigned int i = 0; i < 2; i++) { hptminsign->Fill( (*ptminsign)[i]); } // pt min in isol cone for (unsigned int i = 0; i < 2; i++) { hptminisol->Fill( (*ptminisol)[i]); } // dz max ltr-tr for (unsigned int i = 0; i < 2; i++) { hdzmaxltr->Fill( (*dzmaxltr)[i]); } // e.m. isolation for (unsigned int i = 0; i < 2; i++) { hpisol->Fill( (*emisolat)[i]); } // for (unsigned int i = 0; i < 2; i++) { hetraw->Fill( (*tcEt)[i] ); hetaraw->Fill( fabs((*tcEta)[i]) ); if( (*dByLeadingTrackPtCut)[i] == 1) { hetrawLeadtrk->Fill( (*tcEt)[i] ); hetarawLeadtrk->Fill( fabs((*tcEta)[i]) ); } if( (*dByIsolation)[i] == 1 ) { hetrawTrkisol->Fill( (*tcEt)[i] ); hetarawTrkisol->Fill( fabs((*tcEta)[i]) ); } if( ((*dAgainstElectron)[i] == 1) && ((*dByIsolation)[i] == 1) ) { hetrawElrejec->Fill( (*tcEt)[i] ); hetarawElrejec->Fill( fabs((*tcEta)[i]) ); } } } } } } } setTDRStyle(0); gStyle->SetOptFit(); TFile efile("mctau7TeV.root","recreate"); // TFile efile("datatau7TeV.root","recreate"); hEtRaw->Write(); hEtaRaw->Write(); hDRjettrk->Write(); hd0ltr->Write(); hptltr->Write(); hntrsign->Write(); hntrisol->Write(); hptminsign->Write(); hptminisol->Write(); hdzmaxltr->Write(); hpisol->Write(); hetraw->Write(); hetaraw->Write(); hetrawLeadtrk->Write(); hetrawTrkisol->Write(); hetrawElrejec->Write(); hetarawLeadtrk->Write(); hetarawTrkisol->Write(); hetarawElrejec->Write(); efile.Close(); TCanvas* c1 = new TCanvas("X","Y",1); hDRjettrk->GetXaxis()->SetTitle("DR jet tracks"); hDRjettrk->GetYaxis()->SetTitle("Nev"); hDRjettrk->Draw("hist"); TCanvas* c2 = new TCanvas("X","Y",1); hd0ltr->GetXaxis()->SetTitle("track ip"); hd0ltr->GetYaxis()->SetTitle("Nev"); hd0ltr->Draw("hist"); TCanvas* c3 = new TCanvas("X","Y",1); hptltr->GetXaxis()->SetTitle("pt ltr"); hptltr->GetYaxis()->SetTitle("Nev"); hptltr->Draw("hist"); TCanvas* c4 = new TCanvas("X","Y",1); hntrsign->GetXaxis()->SetTitle("Ntrk in signal cone"); hntrsign->GetYaxis()->SetTitle("Nev"); hntrsign->Draw("hist"); TCanvas* c5 = new TCanvas("X","Y",1); hntrisol->GetXaxis()->SetTitle("Ntrk in isolation annulus"); hntrisol->GetYaxis()->SetTitle("Nev"); hntrisol->Draw("hist"); TCanvas* c6 = new TCanvas("X","Y",1); hptminsign->GetXaxis()->SetTitle("pt min in sign cone"); hptminsign->GetYaxis()->SetTitle("Nev"); hptminsign->Draw("hist"); TCanvas* c7 = new TCanvas("X","Y",1); hptminisol->GetXaxis()->SetTitle("pt min in isol cone"); hptminisol->GetYaxis()->SetTitle("Nev"); hptminisol->Draw("hist"); TCanvas* c8 = new TCanvas("X","Y",1); hdzmaxltr->GetXaxis()->SetTitle("dz max ltr"); hdzmaxltr->GetYaxis()->SetTitle("Nev"); hdzmaxltr->Draw("hist"); TCanvas* c9 = new TCanvas("X","Y",1); hpisol->GetXaxis()->SetTitle("e.m. isolation"); hpisol->GetYaxis()->SetTitle("Nev"); hpisol->Draw("hist"); TCanvas* c10 = new TCanvas("X","Y",1); hetraw->GetXaxis()->SetTitle("Et raw"); hetraw->GetYaxis()->SetTitle("Nev"); hetraw->Draw("hist"); // hetraw->SetMaximum(200.0); hetraw->SetMinimum(0.5); // hetrawLeadtrk->Draw("same"); hetrawTrkisol->Draw("same"); TCanvas* c11 = new TCanvas("X","Y",1); hEtRaw->GetXaxis()->SetTitle("Et raw"); hEtRaw->GetYaxis()->SetTitle("Nev"); hEtRaw->Draw("hist"); }
float transverseMass(float lepPt, float lepPhi, float met, float metPhi) { double cosDPhi = cos(deltaPhi(lepPhi,metPhi)); return sqrt(2*lepPt*met*(1-cosDPhi)); }
float deltaR(float phi1, float eta1, float phi2, float eta2) { return TMath::Sqrt((eta2-eta1)*(eta2-eta1)+deltaPhi(phi1,phi2)*deltaPhi(phi1,phi2)); }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } // Parse the config file parseConfigFile (argv[1]) ; std::string treeName = gConfigParser -> readStringOption("Input::treeName"); std::string inputFile = gConfigParser -> readStringOption("Input::inputFile"); double inputXSection = gConfigParser -> readDoubleOption("Input::inputXSection"); int entryMAX = gConfigParser -> readIntOption("Input::entryMAX"); int entryMIN = gConfigParser -> readIntOption("Input::entryMIN"); int entryMOD = gConfigParser -> readIntOption("Input::entryMOD"); std::cout << ">>>>> input::entryMIN " << entryMIN << std::endl; std::cout << ">>>>> input::entryMAX " << entryMAX << std::endl; std::cout << ">>>>> input::entryMOD " << entryMOD << std::endl; int nStepToDo = 1000; try { nStepToDo = gConfigParser -> readIntOption("Input::nStepToDo"); } catch (char const* exceptionString){ std::cerr << " exception = " << exceptionString << std::endl; nStepToDo = 1000; } std::cout << ">>>>> input::nStepToDo " << nStepToDo << std::endl; // Open ntple TChain* chain = new TChain(treeName.c_str()); chain->Add(inputFile.c_str()); treeReader reader((TTree*)(chain)); ///---- Efficiency preselections ---- std::string treeNameLeptonFilter = gConfigParser -> readStringOption("Input::treeNameLeptonFilter"); std::string treeNameJetCounterFilter = gConfigParser -> readStringOption("Input::treeNameJetCounterFilter"); std::cout << ">>>>> Input::inputFile " << inputFile << std::endl; std::cout << ">>>>> Input::treeNameLeptonFilter " << treeNameLeptonFilter << std::endl; std::cout << ">>>>> Input::treeNameJetCounterFilter " << treeNameJetCounterFilter << std::endl; // Open ntples TFile File(inputFile.c_str()) ; TH1F* hLeptonFilterTotal = (TH1F*) File.Get(TString(treeNameLeptonFilter.c_str()) + "/totalEvents"); TH1F* hLeptonFilterPassed = (TH1F*) File.Get(TString(treeNameLeptonFilter.c_str()) + "/passedEvents"); TH1F* hJetCounterFilterTotal = (TH1F*) File.Get(TString(treeNameJetCounterFilter.c_str()) + "/totalEvents"); TH1F* hJetCounterFilterPassed = (TH1F*) File.Get(TString(treeNameJetCounterFilter.c_str()) + "/passedEvents"); ///---------------------- ///---- LeptonFilter ---- int nLeptonFilterTotal = hLeptonFilterTotal->GetEntries(); int nLeptonFilterPassed = hLeptonFilterPassed->GetEntries(); double lepton_efficiency = static_cast<double>(nLeptonFilterPassed) / static_cast<double>(nLeptonFilterTotal); std::cout << " Lepton Filter = " << nLeptonFilterPassed << " / " << nLeptonFilterTotal << " = " << static_cast<double>(nLeptonFilterPassed) / static_cast<double>(nLeptonFilterTotal) << std::endl; ///-------------------------- ///---- JetCounterFilter ---- int nJetCounterFilterTotal = hJetCounterFilterTotal->GetEntries(); int nJetCounterFilterPassed = hJetCounterFilterPassed->GetEntries(); double jet_efficiency = static_cast<double>(nJetCounterFilterPassed) / static_cast<double>(nJetCounterFilterTotal); std::cout << " JetCounter Filter = " << nJetCounterFilterPassed << " / " << nJetCounterFilterTotal << " = " << static_cast<double>(nJetCounterFilterPassed) / static_cast<double>(nJetCounterFilterTotal) << std::endl; ///----------------------------------- ///---- additional channel filter ---- double eff_Channel_Filter = 1.; if ((TH1F*) File.Get(TString("eff_ee"))) { TH1F* hChannelFilter = (TH1F*) File.Get(TString("eff_ee")); eff_Channel_Filter = hChannelFilter->GetBinContent(1); } if ((TH1F*) File.Get(TString("eff_emu"))) { TH1F* hChannelFilter = (TH1F*) File.Get(TString("eff_emu")); eff_Channel_Filter = hChannelFilter->GetBinContent(1); } if ((TH1F*) File.Get(TString("eff_mumu"))) { TH1F* hChannelFilter = (TH1F*) File.Get(TString("eff_mumu")); eff_Channel_Filter = hChannelFilter->GetBinContent(1); } if ((TH1F*) File.Get(TString("eff_other"))) { TH1F* hChannelFilter = (TH1F*) File.Get(TString("eff_other")); eff_Channel_Filter = hChannelFilter->GetBinContent(1); } ///---------------------- ///---- Preselection ---- double preselection_efficiency = lepton_efficiency * jet_efficiency * eff_Channel_Filter; std::cout << " Preselection efficiency = " << preselection_efficiency << std::endl; ///------------------- ///---- selection ---- std::string OutFileNameEfficiencies = gConfigParser -> readStringOption("Output::OutFileNameEfficiencies"); std::cout << ">>>>> Output::OutFileNameEfficiencies " << OutFileNameEfficiencies << std::endl; TFile outFile(OutFileNameEfficiencies.c_str(),"RECREATE"); int nStep = 10; ///==== number of steps in the analysis TH1F* events = new TH1F("events", "events", nStep+1, 0., 1.*(nStep+1)); std::map<int, int> stepEvents; std::map<int, std::string> stepName; outFile.mkdir("histos"); outFile.cd("histos"); stdHisto* stdHistograms = new stdHisto(nStep, "no",&reader); stdHistograms -> Add1("jets", nStep); stdHistograms -> Add1("muons", nStep); stdHistograms -> Add1Float("muIso", nStep,2000,0,2); stdHistograms -> Add1("electrons", nStep); stdHistograms -> Add1Float("eleIso", nStep,2000,0,2); stdHistograms -> Add1("met", nStep); stdHistograms -> Add2("JJ", nStep); stdHistograms -> Add2("ll", nStep); outFile.cd(); double analysisEfficiency; double XSection = inputXSection; int numEntriesBefore; TTree outTreeSelections("outTreeSelections","outTreeSelections"); outTreeSelections.Branch("XSection",&XSection,"XSection/D"); outTreeSelections.Branch("lepton_efficiency",&lepton_efficiency,"lepton_efficiency/D"); outTreeSelections.Branch("jet_efficiency",&jet_efficiency,"jet_efficiency/D"); outTreeSelections.Branch("preselection_efficiency",&preselection_efficiency,"preselection_efficiency/D"); outTreeSelections.Branch("eff_Channel_Filter",&eff_Channel_Filter,"eff_Channel_Filter/D"); outTreeSelections.Branch("numEntriesBefore",&numEntriesBefore,"numEntriesBefore/I"); outTreeSelections.Branch("analysisEfficiency",&analysisEfficiency,"analysisEfficiency/D"); ///============== ///==== Jets ==== TTree outTreeJetLep("outTreeJetLep","outTreeJetLep"); double bTag_trackCountingHighPurBJetTags_q1; double bTag_trackCountingHighEffBJetTags_q1; double bTag_combinedSecondaryVertexBJetTags_q1; double bTag_combinedSecondaryVertexMVABJetTags_q1; double bTag_trackCountingHighPurBJetTags_q2; double bTag_trackCountingHighEffBJetTags_q2; double bTag_combinedSecondaryVertexBJetTags_q2; double bTag_combinedSecondaryVertexMVABJetTags_q2; double tkIso_l1; double emIso_l1; double hadIso_l1; double tkIso_l2; double emIso_l2; double hadIso_l2; double pT_RECO_q1; double pT_RECO_q2; double phi_RECO_q1; double phi_RECO_q2; double eta_RECO_q1; double eta_RECO_q2; double eta_RECO_q1_eta_RECO_q2; double Deta_RECO_q12; double Mjj; int NBjets_trackCountingHighPurBJetTags; int NBjets_trackCountingHighEffBJetTags; int NBjets_combinedSecondaryVertexBJetTags; int NBjets_combinedSecondaryVertexMVABJetTags; int NBjets_simpleSecondaryVertexBJetTags; int JV_20; int JV_30; int CJV_20; int CJV_30; int Z_01_30; int Z_03_30; int Z_05_30; int Z_07_30; int Z_09_30; int Z_10_30; int Z_12_30; int Z_14_30; int Z_01_20; int Z_03_20; int Z_05_20; int Z_07_20; int Z_09_20; int Z_10_20; int Z_12_20; int Z_14_20; double MET; int AnalysisStep; outTreeJetLep.Branch("bTag_trackCountingHighPurBJetTags_q1",&bTag_trackCountingHighPurBJetTags_q1,"bTag_trackCountingHighPurBJetTags_q1/D"); outTreeJetLep.Branch("bTag_trackCountingHighEffBJetTags_q1",&bTag_trackCountingHighEffBJetTags_q1,"bTag_trackCountingHighEffBJetTags_q1/D"); outTreeJetLep.Branch("bTag_combinedSecondaryVertexBJetTags_q1",&bTag_combinedSecondaryVertexBJetTags_q1,"bTag_combinedSecondaryVertexBJetTags_q1/D"); outTreeJetLep.Branch("bTag_combinedSecondaryVertexMVABJetTags_q1",&bTag_combinedSecondaryVertexMVABJetTags_q1,"bTag_combinedSecondaryVertexMVABJetTags_q1/D"); outTreeJetLep.Branch("bTag_trackCountingHighPurBJetTags_q2",&bTag_trackCountingHighPurBJetTags_q2,"bTag_trackCountingHighPurBJetTags_q2/D"); outTreeJetLep.Branch("bTag_trackCountingHighEffBJetTags_q2",&bTag_trackCountingHighEffBJetTags_q2,"bTag_trackCountingHighEffBJetTags_q2/D"); outTreeJetLep.Branch("bTag_combinedSecondaryVertexBJetTags_q2",&bTag_combinedSecondaryVertexBJetTags_q2,"bTag_combinedSecondaryVertexBJetTags_q2/D"); outTreeJetLep.Branch("bTag_combinedSecondaryVertexMVABJetTags_q2",&bTag_combinedSecondaryVertexMVABJetTags_q2,"bTag_combinedSecondaryVertexMVABJetTags_q2/D"); outTreeJetLep.Branch("tkIso_l1",&tkIso_l1,"tkIso_l1/D"); outTreeJetLep.Branch("emIso_l1",&emIso_l1,"emIso_l1/D"); outTreeJetLep.Branch("hadIso_l1",&hadIso_l1,"hadIso_l1/D"); outTreeJetLep.Branch("tkIso_l2",&tkIso_l2,"tkIso_l2/D"); outTreeJetLep.Branch("emIso_l2",&emIso_l2,"emIso_l2/D"); outTreeJetLep.Branch("hadIso_l2",&hadIso_l2,"hadIso_l2/D"); outTreeJetLep.Branch("pT_RECO_q1",&pT_RECO_q1,"pT_RECO_q1/D"); outTreeJetLep.Branch("pT_RECO_q2",&pT_RECO_q2,"pT_RECO_q2/D"); outTreeJetLep.Branch("phi_RECO_q1",&phi_RECO_q1,"phi_RECO_q1/D"); outTreeJetLep.Branch("phi_RECO_q2",&phi_RECO_q2,"phi_RECO_q2/D"); outTreeJetLep.Branch("eta_RECO_q1",&eta_RECO_q1,"eta_RECO_q1/D"); outTreeJetLep.Branch("eta_RECO_q2",&eta_RECO_q2,"eta_RECO_q2/D"); outTreeJetLep.Branch("eta_RECO_q1_eta_RECO_q2",&eta_RECO_q1_eta_RECO_q2,"eta_RECO_q1_eta_RECO_q2/D"); outTreeJetLep.Branch("Deta_RECO_q12",&Deta_RECO_q12,"Deta_RECO_q12/D"); outTreeJetLep.Branch("Mjj",&Mjj,"Mjj/D"); outTreeJetLep.Branch("JV_20",&JV_20,"JV_20/I"); outTreeJetLep.Branch("JV_30",&JV_30,"JV_30/I"); outTreeJetLep.Branch("CJV_20",&CJV_20,"CJV_20/I"); outTreeJetLep.Branch("CJV_30",&CJV_30,"CJV_30/I"); outTreeJetLep.Branch("AnalysisStep",&AnalysisStep,"AnalysisStep/I"); outTreeJetLep.Branch("Z_01_30",&Z_01_30,"Z_01_30/I"); outTreeJetLep.Branch("Z_03_30",&Z_03_30,"Z_03_30/I"); outTreeJetLep.Branch("Z_05_30",&Z_05_30,"Z_05_30/I"); outTreeJetLep.Branch("Z_07_30",&Z_07_30,"Z_07_30/I"); outTreeJetLep.Branch("Z_09_30",&Z_09_30,"Z_09_30/I"); outTreeJetLep.Branch("Z_10_30",&Z_10_30,"Z_10_30/I"); outTreeJetLep.Branch("Z_12_30",&Z_12_30,"Z_12_30/I"); outTreeJetLep.Branch("Z_14_30",&Z_14_30,"Z_14_30/I"); outTreeJetLep.Branch("Z_01_20",&Z_01_20,"Z_01_20/I"); outTreeJetLep.Branch("Z_03_20",&Z_03_20,"Z_03_20/I"); outTreeJetLep.Branch("Z_05_20",&Z_05_20,"Z_05_20/I"); outTreeJetLep.Branch("Z_07_20",&Z_07_20,"Z_07_20/I"); outTreeJetLep.Branch("Z_09_20",&Z_09_20,"Z_09_20/I"); outTreeJetLep.Branch("Z_10_20",&Z_10_20,"Z_10_20/I"); outTreeJetLep.Branch("Z_12_20",&Z_12_20,"Z_12_20/I"); outTreeJetLep.Branch("Z_14_20",&Z_14_20,"Z_14_20/I"); outTreeJetLep.Branch("MET",&MET,"MET/D"); outTreeJetLep.Branch("NBjets_trackCountingHighPurBJetTags",&NBjets_trackCountingHighPurBJetTags,"NBjets_trackCountingHighPurBJetTags/I"); outTreeJetLep.Branch("NBjets_trackCountingHighEffBJetTags",&NBjets_trackCountingHighEffBJetTags,"NBjets_trackCountingHighEffBJetTags/I"); outTreeJetLep.Branch("NBjets_combinedSecondaryVertexBJetTags",&NBjets_combinedSecondaryVertexBJetTags,"NBjets_combinedSecondaryVertexBJetTags/I"); outTreeJetLep.Branch("NBjets_combinedSecondaryVertexMVABJetTags",&NBjets_combinedSecondaryVertexMVABJetTags,"NBjets_combinedSecondaryVertexMVABJetTags/I"); outTreeJetLep.Branch("NBjets_simpleSecondaryVertexBJetTags",&NBjets_simpleSecondaryVertexBJetTags,"NBjets_simpleSecondaryVertexBJetTags/I"); ///================= ///==== leptons ==== // TTree outTreeJetLep("outTreeJetLep","outTreeJetLep"); int pdgId_RECO_l1; int pdgId_RECO_l2; double pT_RECO_l1; double pT_RECO_l2; double eta_RECO_l1; double eta_RECO_l2; double eta_RECO_l1_eta_RECO_l2; double Deta_RECO_l12; double Dphi_RECO_l12; double Mll; double charge_RECO_l1_charge_RECO_l2; double Z_l1; double Z_l2; outTreeJetLep.Branch("pdgId_RECO_l1",&pdgId_RECO_l1,"pdgId_RECO_l1/I"); outTreeJetLep.Branch("pdgId_RECO_l2",&pdgId_RECO_l2,"pdgId_RECO_l2/I"); outTreeJetLep.Branch("pT_RECO_l1",&pT_RECO_l1,"pT_RECO_l1/D"); outTreeJetLep.Branch("pT_RECO_l2",&pT_RECO_l2,"pT_RECO_l2/D"); outTreeJetLep.Branch("eta_RECO_l1",&eta_RECO_l1,"eta_RECO_l1/D"); outTreeJetLep.Branch("eta_RECO_l2",&eta_RECO_l2,"eta_RECO_l2/D"); outTreeJetLep.Branch("eta_RECO_l1_eta_RECO_l2",&eta_RECO_l1_eta_RECO_l2,"eta_RECO_l1_eta_RECO_l2/D"); outTreeJetLep.Branch("Deta_RECO_l12",&Deta_RECO_l12,"Deta_RECO_l12/D"); outTreeJetLep.Branch("Dphi_RECO_l12",&Dphi_RECO_l12,"Dphi_RECO_l12/D"); outTreeJetLep.Branch("Mll",&Mll,"Mll/D"); outTreeJetLep.Branch("charge_RECO_l1_charge_RECO_l2",&charge_RECO_l1_charge_RECO_l2,"charge_RECO_l1_charge_RECO_l2/D"); outTreeJetLep.Branch("AnalysisStep",&AnalysisStep,"AnalysisStep/I"); outTreeJetLep.Branch("Z_l1",&Z_l1,"Z_l1/D"); outTreeJetLep.Branch("Z_l2",&Z_l2,"Z_l2/D"); double start, end; if (entryMAX == -1) entryMAX = reader.GetEntries(); else if (reader.GetEntries() < entryMAX) entryMAX = reader.GetEntries(); numEntriesBefore = entryMAX - entryMIN; std::cout << ">>>>> analysis::entryMIN " << entryMIN << " ==> entryMAX " << entryMAX << ":" << reader.GetEntries() << std::endl; int step = 0; start = clock(); for(int iEvent = entryMIN ; iEvent < entryMAX ; ++iEvent) { reader.GetEntry(iEvent); if((iEvent%entryMOD) == 0) std::cout << ">>>>> analysis::GetEntry " << iEvent << " : " << entryMAX - entryMIN << std::endl; ///==== define variables ==== std::vector<ROOT::Math::XYZTVector>* jets = reader.Get4V("jets"); // std::vector<ROOT::Math::XYZTVector>* muons = reader.Get4V("muons"); // std::vector<ROOT::Math::XYZTVector>* electrons = reader.Get4V("electrons"); ///********************************************************************************************* ///********************************************************************************************* ///********************************************************************************************* ///********************************************************************************************* ///**************************** ///**** STEP 0 - Ntuplizer **** ///************* no additional selections applied step = 0; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } stepName[step] = "Jet cleaning"; stepEvents[step] += 1; ///==== filling ==== stdHistograms -> Fill1("muons","muons",step,0); stdHistograms -> Fill1("electrons","electrons",step,0); stdHistograms -> Fill1("jets","jets",step,0); stdHistograms -> Fill1("met","met",step,0); ///******************************* ///**** STEP 1 - Jet cleaning **** ///************* it's performed another time here to make sure that the cleaning worked well ///************* possible problems with electron ID step = 1; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } std::vector<ROOT::Math::XYZTVector> electrons_jetCleaning; // build the collection of electros for jet cleaning for(unsigned int eleIt = 0; eleIt < (reader.Get4V("electrons")->size()); ++eleIt) { if( reader.Get4V("electrons")->at(eleIt).pt() < 5. ) continue; if( (reader.GetFloat("electrons_tkIso")->at(eleIt)) / reader.Get4V("electrons")->at(eleIt).pt() > 0.5 ) continue; if( (reader.GetFloat("electrons_IdRobustLoose")->at(eleIt)) < 1. ) continue; electrons_jetCleaning.push_back( reader.Get4V("electrons")->at(eleIt) ); } int nJets = jets->size(); std::vector<int> whitelistJet; std::vector<int> blacklistJet; std::vector<int> blacklistJet_forCJV; std::vector<int> blacklistJet_forBtag; for (int iJet = 0; iJet < nJets; iJet++){ bool skipJet = false; if (jets->at(iJet).Et() < 10.0) skipJet = true; for(unsigned int eleIt = 0; eleIt < electrons_jetCleaning.size(); eleIt++) { ROOT::Math::XYZTVector ele = electrons_jetCleaning.at(eleIt); if (ROOT::Math::VectorUtil::DeltaR(jets->at(iJet),ele) < 0.3 ) skipJet = true; } if (skipJet) { whitelistJet.push_back(0); ///---- reject blacklistJet.push_back(iJet); ///---- reject ///== black list is in a different format blacklistJet_forCJV.push_back(iJet); ///---- reject ///== black list is in a different format blacklistJet_forBtag.push_back(iJet); ///---- reject ///== black list is in a different format } else { whitelistJet.push_back(1); ///---- select } } if (GetNumList(whitelistJet) < 2) continue; ///==== at least 2 jets "isolated" stepName[step] = "Jet cleaning"; stepEvents[step] += 1; ///==== filling ==== stdHistograms -> Fill1("muons","muons",step,0); stdHistograms -> Fill1("electrons","electrons",step,0); stdHistograms -> Fill1("jets","jets",step,&whitelistJet); stdHistograms -> Fill1("met","met",step,0); ///************************************** ///**** STEP 2 - Super-Preselections **** ///************* tighter preselections to start the analysis from the same point ///==== construct considered objets /// Objects considered /// Muon /// PromptTightMuonID /// Pt>10GeV, eta<2.5 /// IsoTr / pTmu <0.5 /// Electron /// Pt>10GeV & |eta|<2.5 /// IsoTr / pTele <0.5 /// eidRobustLoose /// Jet /// Antikt5, L2L3 correction, Pt>30GeV & |eta|<5 /// Remove jet with /// a lepton(e/mu) with pt>10GeV in cone=0.3 /// or /// an electron (the ones defined above) in cone=0.1 /// Preselections /// At least 2 leptons /// Muon (from the collections defined above) /// Pt > 15 GeV /// Electron (from the collection defined above) /// Pt>15 GeV /// At least two calo jets or two pf jets with pt>30GeV /// Jets (from the collection defined above) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ step = 2; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } /// Electron /// Pt>10GeV & |eta|<2.5 /// IsoTr / pTele <0.5 /// eidRobustLoose std::vector<int> whitelistEle; std::vector<int> blacklistEle; int nEles = reader.Get4V("electrons")->size(); for (int iEle = 0; iEle < nEles; iEle++){ bool skipEle = false; if (reader.Get4V("electrons")->at(iEle).pt() < 10.0) skipEle = true; if (fabs(reader.Get4V("electrons")->at(iEle).Eta()) > 2.5) skipEle = true; if ( (reader.GetFloat("electrons_tkIso")->at(iEle)) / reader.Get4V("electrons")->at(iEle).pt() > 0.5 ) skipEle = true; if ( (reader.GetFloat("electrons_IdRobustLoose")->at(iEle)) < 1. ) skipEle = true; if ( (reader.GetFloat("electrons_tkIso")->at(iEle)) / reader.Get4V("electrons")->at(iEle).pt() > 0.1 ) skipEle = true; if ( (reader.GetFloat("electrons_emIso03")->at(iEle)) / reader.Get4V("electrons")->at(iEle).pt() > 0.1 ) skipEle = true; if ( (reader.GetFloat("electrons_hadIso03_1")->at(iEle) + reader.GetFloat("electrons_hadIso03_2")->at(iEle)) / reader.Get4V("electrons")->at(iEle).pt() > 0.1 ) skipEle = true; if (skipEle) { whitelistEle.push_back(0); ///---- reject blacklistEle.push_back(iEle); ///---- reject ///== black list is in a different format } else { whitelistEle.push_back(1); ///---- select } } // std::cerr << "ciao!!!" << std::endl; /// Muon /// PromptTightMuonID /// Pt>10GeV, eta<2.5 /// IsoTr / pTmu <0.5 std::vector<int> whitelistMu; std::vector<int> blacklistMu; int nMus = reader.Get4V("muons")->size(); // std::cerr << "mu = " << nMus << std::endl; for (int iMu = 0; iMu < nMus; iMu++){ bool skipMu = false; if (reader.Get4V("muons")->at(iMu).pt() < 10.0) skipMu = true; // std::cerr << "mu = " << nMus << std::endl; if (fabs(reader.Get4V("muons")->at(iMu).Eta()) > 2.5) skipMu = true; // std::cerr << "mu = " << nMus << " " << reader.GetFloat("muons_tkIsoR03")->at(iMu) << std::endl; if ( (reader.GetFloat("muons_tkIsoR03")->at(iMu)) / reader.Get4V("muons")->at(iMu).pt() > 0.5 ) skipMu = true; // std::cerr << "mu = " << nMus << std::endl; if ( (reader.GetFloat("muons_tkIsoR03")->at(iMu)) / reader.Get4V("muons")->at(iMu).pt() > 0.1 ) skipMu = true; if ( (reader.GetFloat("muons_emIsoR03")->at(iMu)) / reader.Get4V("muons")->at(iMu).pt() > 0.1 ) skipMu = true; if ( (reader.GetFloat("muons_hadIsoR03")->at(iMu)) / reader.Get4V("muons")->at(iMu).pt() > 0.1 ) skipMu = true; if( (reader.GetInt("muons_goodMuon")->at(iMu)) < 1. ) skipMu = true; if (skipMu) { whitelistMu.push_back(0); ///---- reject blacklistMu.push_back(iMu); ///---- reject ///== black list is in a different format } else { whitelistMu.push_back(1); ///---- select } } // std::cerr << "ele = " << nEles << std::endl; /// Jet /// Antikt5, L2L3 correction, Pt>30GeV & |eta|<5 /// Remove jet with /// a lepton(e/mu) with pt>10GeV in cone=0.3 /// or /// an electron (the ones defined above) in cone=0.1 electrons_jetCleaning.clear(); // build the collection of electros for jet cleaning // std::cerr << "ele = " << nEles << std::endl; for(unsigned int iEle = 0; iEle < nEles; ++iEle) { if (whitelistEle.at(iEle) == 0) continue; electrons_jetCleaning.push_back( reader.Get4V("electrons")->at(iEle) ); } for (int iJet = 0; iJet < nJets; iJet++){ bool skipJet = false; if (whitelistJet.at(iJet) == 0) { // skipJet = true; continue; //---- otherwise blacklistJet.push_back(iJet) and blacklistJet becomes too long //-------------- and then it's faster! } if (jets->at(iJet).Et() < 30.0) skipJet = true; if (jets->at(iJet).Eta() > 5.0) skipJet = true; for(unsigned int eleIt = 0; eleIt < electrons_jetCleaning.size(); eleIt++) { ROOT::Math::XYZTVector ele = electrons_jetCleaning.at(eleIt); if (ROOT::Math::VectorUtil::DeltaR(jets->at(iJet),ele) < 0.3 ) skipJet = true; } if (skipJet) { whitelistJet.at(iJet) = 0; ///---- reject blacklistJet.push_back(iJet); ///---- reject ///== black list is in a different format } else { whitelistJet.at(iJet) = 1; ///---- select } } // std::cerr << "ciao!!!" << std::endl; /// At least 2 leptons /// Muon (from the collections defined above) /// Pt > 15 GeV int numLeptons_Accepted = 0; for (int iMu = 0; iMu < nMus; iMu++){ if (whitelistMu.at(iMu) == 1 && reader.Get4V("muons")->at(iMu).pt() > 15.0) numLeptons_Accepted++; } /// Electron (from the collection defined above) /// Pt>15 GeV for (int iEle = 0; iEle < nEles; iEle++){ if (whitelistEle.at(iEle) == 1 && reader.Get4V("electrons")->at(iEle).pt() > 15.0) numLeptons_Accepted++; } // std::cerr << "numLeptons_Accepted = " << numLeptons_Accepted << std::endl; if (numLeptons_Accepted < 2) continue; /// At least two calo jets or two pf jets with pt>30GeV /// Jets (from the collection defined above) int numJets_Accepted = 0; for (int iJet = 0; iJet < nJets; iJet++){ if (whitelistJet.at(iJet) == 1) numJets_Accepted++; } // std::cerr << "numJets_Accepted = " << numJets_Accepted << " = " << GetNumList(whitelistJet) << " = " << nJets << " - " << blacklistJet.size() << std::endl; if (numJets_Accepted < 2) continue; ///==== filling ==== stepName[step] = "Super Pre-Selections"; stepEvents[step] += 1; stdHistograms -> Fill1("muons","muons",step,&whitelistMu); stdHistograms -> Fill1("electrons","electrons",step,&whitelistEle); stdHistograms -> Fill1("jets","jets",step,&whitelistJet); stdHistograms -> Fill1("met","met",step,0); ///************************* ///**** STEP 3 - Jet ID **** ///************* Identification of two tag jets step = 3; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } std::vector<int> itSelJet; double maxPt_jets_selected = SelectJets(itSelJet,*jets,"maxSumPt",-1.,&blacklistJet); // std::cerr << "itSelJet.at(0) = " << itSelJet.at(0) << " : " << nJets << std::endl; // std::cerr << "itSelJet.at(1) = " << itSelJet.at(1) << " : " << nJets << std::endl; int q1 = itSelJet.at(0); int q2 = itSelJet.at(1); ///---- check Pt order ---- if (jets->at(q1).Pt() < jets->at(q2).Pt()) { int tempq = q1; q1 = q2; q2 = tempq; } // std::cerr << "here is ok" << std::endl; ///---- update white/black list jets ---- for (int iJet = 0; iJet < nJets; iJet++){ if (q1 == iJet || q2 == iJet) { whitelistJet.at(iJet) = 1; blacklistJet.push_back(iJet); ///===> blacklistJet used for CJV => no 2 tag jets to be considered! blacklistJet_forCJV.push_back(iJet); ///===> blacklistJet used for CJV => no 2 tag jets to be considered! } else { whitelistJet.at(iJet) = 0; } } MET = reader.Get4V("met")->at(0).Et(); bTag_trackCountingHighPurBJetTags_q1 = reader.GetFloat("jets_trackCountingHighPurBJetTags")->at(q1); bTag_trackCountingHighEffBJetTags_q1 = reader.GetFloat("jets_trackCountingHighEffBJetTags")->at(q1); bTag_combinedSecondaryVertexBJetTags_q1 = reader.GetFloat("jets_combinedSecondaryVertexBJetTags")->at(q1); bTag_combinedSecondaryVertexMVABJetTags_q1 = reader.GetFloat("jets_combinedSecondaryVertexMVABJetTags")->at(q1); bTag_trackCountingHighPurBJetTags_q2 = reader.GetFloat("jets_trackCountingHighPurBJetTags")->at(q2); bTag_trackCountingHighEffBJetTags_q2 = reader.GetFloat("jets_trackCountingHighEffBJetTags")->at(q2); bTag_combinedSecondaryVertexBJetTags_q2 = reader.GetFloat("jets_combinedSecondaryVertexBJetTags")->at(q2); bTag_combinedSecondaryVertexMVABJetTags_q2 = reader.GetFloat("jets_combinedSecondaryVertexMVABJetTags")->at(q2); pT_RECO_q1 = jets->at(q1).Pt(); pT_RECO_q2 = jets->at(q2).Pt(); phi_RECO_q1 = jets->at(q1).Phi(); phi_RECO_q2 = jets->at(q2).Phi(); eta_RECO_q1 = jets->at(q1).Eta(); eta_RECO_q2 = jets->at(q2).Eta(); eta_RECO_q1_eta_RECO_q2 = eta_RECO_q1 * eta_RECO_q2; Deta_RECO_q12 = fabs(eta_RECO_q1-eta_RECO_q2); Mjj = (jets->at(q1) + jets->at(q2)).M(); CJV_20 = getCJV(*jets,q1,q2,20.,&blacklistJet_forCJV); CJV_30 = getCJV(*jets,q1,q2,30.,&blacklistJet_forCJV); JV_20 = getJV(*jets,20.,&blacklistJet_forCJV); JV_30 = getJV(*jets,30.,&blacklistJet_forCJV); JV_20 = getJV(*jets,20.,&blacklistJet_forCJV); JV_30 = getJV(*jets,30.,&blacklistJet_forCJV); Z_01_30 = getZepp(*jets,q1,q2,30.,0.1,&blacklistJet_forCJV); Z_03_30 = getZepp(*jets,q1,q2,30.,0.3,&blacklistJet_forCJV); Z_05_30 = getZepp(*jets,q1,q2,30.,0.5,&blacklistJet_forCJV); Z_07_30 = getZepp(*jets,q1,q2,30.,0.7,&blacklistJet_forCJV); Z_09_30 = getZepp(*jets,q1,q2,30.,0.9,&blacklistJet_forCJV); Z_10_30 = getZepp(*jets,q1,q2,30.,1.0,&blacklistJet_forCJV); Z_12_30 = getZepp(*jets,q1,q2,30.,1.2,&blacklistJet_forCJV); Z_14_30 = getZepp(*jets,q1,q2,30.,1.4,&blacklistJet_forCJV); Z_01_20 = getZepp(*jets,q1,q2,20.,0.1,&blacklistJet_forCJV); Z_03_20 = getZepp(*jets,q1,q2,20.,0.3,&blacklistJet_forCJV); Z_05_20 = getZepp(*jets,q1,q2,20.,0.5,&blacklistJet_forCJV); Z_07_20 = getZepp(*jets,q1,q2,20.,0.7,&blacklistJet_forCJV); Z_09_20 = getZepp(*jets,q1,q2,20.,0.9,&blacklistJet_forCJV); Z_10_20 = getZepp(*jets,q1,q2,20.,1.0,&blacklistJet_forCJV); Z_12_20 = getZepp(*jets,q1,q2,20.,1.2,&blacklistJet_forCJV); Z_14_20 = getZepp(*jets,q1,q2,20.,1.4,&blacklistJet_forCJV); NBjets_trackCountingHighPurBJetTags = 0; NBjets_trackCountingHighEffBJetTags = 0; NBjets_combinedSecondaryVertexBJetTags = 0; NBjets_combinedSecondaryVertexMVABJetTags = 0; NBjets_simpleSecondaryVertexBJetTags = 0; for (int iJet = 0; iJet < nJets; iJet++){ bool skipJet = false; for(unsigned int kk = 0; kk < blacklistJet_forBtag.size(); ++kk) { if(blacklistJet_forBtag.at(kk) == static_cast<int>(iJet)) skipJet = true; } if (reader.Get4V("jets")->at(iJet).pt() < 10.0) skipJet = true; if (skipJet) continue; if (reader.GetFloat("jets_trackCountingHighPurBJetTags")->at(iJet) > -50.0) NBjets_trackCountingHighPurBJetTags++; if (reader.GetFloat("jets_trackCountingHighEffBJetTags")->at(iJet) > -50.0) NBjets_trackCountingHighEffBJetTags++; if (reader.GetFloat("jets_combinedSecondaryVertexBJetTags")->at(iJet) > -5.0) NBjets_combinedSecondaryVertexBJetTags++; if (reader.GetFloat("jets_combinedSecondaryVertexMVABJetTags")->at(iJet) > -5.0) NBjets_combinedSecondaryVertexMVABJetTags++; if (reader.GetFloat("jets_simpleSecondaryVertexBJetTags")->at(iJet) > 2.5) NBjets_simpleSecondaryVertexBJetTags++; } AnalysisStep = step; // std::cerr << "here is ok" << std::endl; ///==== filling ==== stepName[step] = "Jet ID"; stepEvents[step] += 1; stdHistograms -> Fill1("muons","muons",step,&whitelistMu); stdHistograms -> Fill1("electrons","electrons",step,&whitelistEle); stdHistograms -> Fill1("jets","jets",step,&whitelistJet); stdHistograms -> Fill1("met","met",step,0); stdHistograms -> Fill2(jets->at(q1),jets->at(q2), "JJ", step); ///******************************** ///**** STEP 4 - Lepton ID **** ///************* Identification of the two leptons step = 5; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } std::vector<ROOT::Math::XYZTVector> electrons; std::vector<ROOT::Math::XYZTVector> muons; std::vector<ROOT::Math::XYZTVector> leptons; std::vector<std::string> leptonFlavours; std::vector<int> leptonFlavours_pdgId; std::vector<float> leptons_charge; std::vector<float> leptons_tkIso; std::vector<float> leptons_emIso; std::vector<float> leptons_hadIso; std::vector<float> leptons_lipSig; std::vector<float> leptons_tipSig; std::vector<float> leptons_3DipSig; // std::cerr << "here is ok 3" << std::endl; for(unsigned int iEle = 0; iEle < nEles; iEle++){ if (whitelistEle.at(iEle) == 1){ leptons.push_back( reader.Get4V("electrons")->at(iEle) ); leptonFlavours.push_back("electron"); leptonFlavours_pdgId.push_back(11); leptons_charge.push_back(reader.GetFloat("electrons_charge")->at(iEle)); leptons_tkIso.push_back(reader.GetFloat("electrons_tkIso")->at(iEle)); leptons_emIso.push_back(reader.GetFloat("electrons_emIso03")->at(iEle)); leptons_hadIso.push_back(reader.GetFloat("electrons_hadIso03_1")->at(iEle)+reader.GetFloat("electrons_hadIso03_2")->at(iEle)); leptons_lipSig.push_back(reader.GetFloat("electrons_lipSignificance")->at(iEle)); leptons_tipSig.push_back(reader.GetFloat("electrons_tipSignificance")->at(iEle)); leptons_3DipSig.push_back(reader.GetFloat("electrons_3DipSignificance")->at(iEle)); } } // std::cerr << "here is ok 4" << std::endl; for(unsigned int iMu = 0; iMu < nMus; iMu++){ if (whitelistMu.at(iMu) == 1){ // muons.push_back( reader.Get4V("muons")->at(iMu) ); leptons.push_back( reader.Get4V("muons")->at(iMu) ); leptonFlavours.push_back("muon"); leptonFlavours_pdgId.push_back(13); leptons_charge.push_back(reader.GetFloat("muons_charge")->at(iMu)); leptons_tkIso.push_back(reader.GetFloat("muons_tkIsoR03")->at(iMu)); leptons_emIso.push_back(reader.GetFloat("muons_emIsoR03")->at(iMu)); leptons_hadIso.push_back(reader.GetFloat("muons_hadIsoR03")->at(iMu)); leptons_lipSig.push_back(reader.GetFloat("muons_lipSignificance")->at(iMu)); leptons_tipSig.push_back(reader.GetFloat("muons_tipSignificance")->at(iMu)); leptons_3DipSig.push_back(reader.GetFloat("muons_3DipSignificance")->at(iMu)); } } // std::cerr << "leptons.size() = " << leptons.size() << std::endl; if (leptons.size() < 2) continue; ///=== I want at least 2 leptons!!! std::vector<int> itSelLep; double maxPt_lept_selected = SelectJets(itSelLep,leptons,"maxSumPt",-1.,0); int l1 = itSelLep.at(0); int l2 = itSelLep.at(1); ///---- check Pt order ---- if (leptons.at(l1).Pt() < leptons.at(l2).Pt()) { int templ = l1; l1 = l2; l2 = templ; } pdgId_RECO_l1 = leptonFlavours_pdgId.at(l1); pdgId_RECO_l2 = leptonFlavours_pdgId.at(l2); pT_RECO_l1 = leptons.at(l1).Pt(); pT_RECO_l2 = leptons.at(l2).Pt(); eta_RECO_l1 = leptons.at(l1).Eta(); eta_RECO_l2 = leptons.at(l2).Eta(); eta_RECO_l1_eta_RECO_l2 = eta_RECO_l1 * eta_RECO_l2; Deta_RECO_l12 = fabs(eta_RECO_l1-eta_RECO_l2); Dphi_RECO_l12 = deltaPhi(leptons.at(l1).Phi(),leptons.at(l2).Phi()); Mll = (leptons.at(l1) + leptons.at(l2)).M(); charge_RECO_l1_charge_RECO_l2 = leptons_charge.at(l1) * leptons_charge.at(l2); tkIso_l1 = leptons_tkIso.at(l1); emIso_l1 = leptons_emIso.at(l1); hadIso_l1 = leptons_hadIso.at(l1); tkIso_l2 = leptons_tkIso.at(l2); emIso_l2 = leptons_emIso.at(l2); hadIso_l2 = leptons_hadIso.at(l2); ///==== Zepp for lepton ==== double etaMin = jets->at(q1).Eta(); double etaMax = jets->at(q2).Eta(); if (etaMax < etaMin) std::swap(etaMin,etaMax); double etaMean = (etaMax + etaMin) / 2.; double dEta = (etaMax - etaMin); Z_l1 = (leptons.at(l1).Eta() - etaMean)/dEta; Z_l2 = (leptons.at(l2).Eta() - etaMean)/dEta; ///========================= stdHistograms -> Fill1("muons","muons",step,&whitelistMu); stdHistograms -> Fill1("electrons","electrons",step,&whitelistEle); stdHistograms -> Fill1("jets","jets",step,&whitelistJet); stdHistograms -> Fill1("met","met",step,0); stdHistograms -> Fill2(jets->at(q1),jets->at(q2), "JJ", step); stdHistograms -> Fill2(leptons.at(l1),leptons.at(l2), "ll", step); stepName[step] = "Lepton ID"; stepEvents[step] += 1; ///********************************* ///**** STEP 5 - Jet Selections **** ///************* Loose selections of tag jets step = 4; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } if (pT_RECO_q1 < 30.) continue; if (pT_RECO_q2 < 30.) continue; if (Mjj < 200.) continue; if (Deta_RECO_q12 < 1.) continue; if (eta_RECO_q1_eta_RECO_q2 > 0.) continue; ///==== filling ==== stepName[step] = "Jet Selections"; stepEvents[step] += 1; stdHistograms -> Fill1("muons","muons",step,&whitelistMu); stdHistograms -> Fill1("electrons","electrons",step,&whitelistEle); stdHistograms -> Fill1("jets","jets",step,&whitelistJet); stdHistograms -> Fill1("met","met",step,0); stdHistograms -> Fill2(jets->at(q1),jets->at(q2), "JJ", step); ///************************************ ///**** STEP 6 - Final Production ***** ///************************************ ///**** No more selections applied **** step = 6; if (step > nStepToDo) { outTreeJetLep.Fill(); continue; } ///=== Jets === AnalysisStep = step; outTreeJetLep.Fill(); // outTreeJetLep.Fill(); // std::cerr << "======================================= end " << std::endl; ///==== ... to be continued in next program ... ==== ///================================================= } end = clock(); std::cout <<"Time = " << ((double) (end - start)) << " (a.u.)" << std::endl; // outFile.Write(); ///==== save additional information ==== // TFile* outputRootFile = new TFile(OutFileNameEfficiencies.c_str(), "recreate"); // outputRootFile -> cd(); for(step = 0; step < nStep; ++step) { events -> SetBinContent(step+2, stepEvents[step]); events -> GetXaxis() -> SetBinLabel(step+2, stepName[step].c_str()); if (step != 0){ analysisEfficiency = static_cast<double>(stepEvents[step]) / static_cast<double>(stepEvents[0]); ///---- fractio => efficiency outTreeSelections.Fill(); } } events -> Write(); outFile.Write(); std::cerr << " === end === " << std::endl; delete stdHistograms; }
inline double evalHMETMassiveMt(double m0, double pt0, double phi0, double m1, double pt1, double phi1) { return TMath::Sqrt(m0*m0 + m1*m1 + 2.0 * (TMath::Sqrt((m0*m0+pt0*pt0)*(m1*m1+pt1*pt1)) - pt0*pt1*TMath::Cos(deltaPhi(phi0, phi1)) )); }
void VBFHinvis::Loop() { // In a ROOT session, you can do: // Root > .L VBFHinvis.C // Root > VBFHinvis 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 // // 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; // selections TH1F * hPtJ1 = new TH1F( "hPtJ1", "PtJ1", 30, 0., 150.); TH1F * hPtJ2 = new TH1F( "hPtJ2", "PtJ2", 30, 0., 150.); TH1F * hEtaJ1 = new TH1F( "hEtaJ1", "EtaJ1", 50, -5.0, 5.0); TH1F * hEtaJ2 = new TH1F( "hEtaJ2", "EtaJ2", 50, -5.0, 5.0); TH1F * hmJJ = new TH1F( "hmJJ", "mJJ", 40, 0., 2000.); TH2F * hDetaJJmJJ = new TH2F( "hDetaJJmJJ", "DetaJJmJJ", 50, 0., 10.,40,0.,2000.); TH1F * hDphiJJ = new TH1F( "hDphiJJ", "DphiJJ", 17, 0., 3.4); TH1F * hDphiJJmJJ300 = new TH1F( "hDphiJJmJJ300", "DphiJJmJJ300", 17, 0., 3.4); TH1F * hDphiJJmJJ500 = new TH1F( "hDphiJJmJJ500", "DphiJJmJJ500", 17, 0., 3.4); TH1F * hDphiJJDetaJJ2 = new TH1F( "hDphiJJDetaJJ2", "DphiJJDetaJJ2", 17, 0., 3.4); TH1F * hDphiJJDetaJJ3 = new TH1F( "hDphiJJDetaJJ3", "DphiJJDetaJJ3", 17, 0., 3.4); Long64_t nentries = fChain->GetEntriesFast(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); // break; if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; // cout <<" run number = " << run << endl; // jet Int_t njets = EtJPT->size(); if(njets < 2) {continue;} Double_t pTj1 = (*EtJPT)[0]; Double_t pTj2 = (*EtJPT)[1]; if(pTj1 <= 50. || pTj2 <= 50.) {continue;} Double_t DphiJJ = deltaPhi((*PhiJPT)[0],(*PhiJPT)[1]); Double_t DetaJJ = deltaEta((*EtaJPT)[0],(*EtaJPT)[1]); // Mj1j2 calculations Double_t PJ1x = pTj1 * cos((*PhiJPT)[0]); Double_t PJ1y = pTj1 * sin((*PhiJPT)[0]); Double_t Eta = (*EtaJPT)[0]; Double_t theta = 2. * atan(exp(-Eta)); Double_t PJ1z = pTj1 / tan(theta); Double_t EJ1 = pTj1 / sin(theta); Double_t PJ2x = pTj2 * cos((*PhiJPT)[1]); Double_t PJ2y = pTj2 * sin((*PhiJPT)[1]); Eta = (*EtaJPT)[1]; theta = 2. * atan(exp(-Eta)); Double_t PJ2z = pTj2 / tan(theta); Double_t EJ2 = pTj2 / sin(theta); Double_t mJJ = sqrt( (EJ1+EJ2)*(EJ1+EJ2) - (PJ1x+PJ2x)*(PJ1x+PJ2x) - (PJ1y+PJ2y)*(PJ1y+PJ2y) - (PJ1z+PJ2z)*(PJ1z+PJ2z) ); if(L1ETM40 == 1) { hPtJ1->Fill(pTj1); hPtJ2->Fill(pTj2); hEtaJ1->Fill((*EtaJPT)[0]); hEtaJ2->Fill((*EtaJPT)[1]); hmJJ->Fill(mJJ); hDphiJJ->Fill(DphiJJ); hDetaJJmJJ->Fill(DetaJJ,mJJ); if(mJJ > 300.) {hDphiJJmJJ300->Fill(DphiJJ);} if(mJJ > 500.) {hDphiJJmJJ500->Fill(DphiJJ);} if(DetaJJ > 2.0) {hDphiJJDetaJJ2->Fill(DphiJJ);} if(DetaJJ > 3.0) {hDphiJJDetaJJ3->Fill(DphiJJ);} } } TFile efile("VBFHinvisAnalysis.root","recreate"); hmJJ->Write(); hPtJ1->Write(); hPtJ2->Write(); hEtaJ1->Write(); hEtaJ2->Write(); hDphiJJ->Write(); hDetaJJmJJ->Write(); hDphiJJmJJ300->Write(); hDphiJJmJJ500->Write(); hDphiJJDetaJJ2->Write(); hDphiJJDetaJJ3->Write(); efile.Close(); }
inline float deltaPhiMETjets(float metphi, float jetphi, float jetpt, float jeteta, float minpt=25, float maxeta=4.5) { if(jetpt <= minpt || TMath::Abs(jeteta) >= maxeta) return 999.; else return fabs(deltaPhi(metphi, jetphi)); }
void Plotter::DoPlots(int prompt){ Plotter::SetUpPlots(); nentries = tpho->GetEntries(); std::cout << "nentries = " << nentries << std::endl; Double_t effPUn[60]={0}; Double_t effPUd[60]={0}; Double_t effptn[60]={0}; Double_t effptd[60]={0}; fTH1DMap["hlt"]->Fill(0.5,nentries); // fSelection[i]-> 1=trigger, 2=presel, 3=selection, 4=pt1>30,pt2>20, 5=pt1>mgg/3,pt2>mgg/4, 6=goodVtx, 7=mgg, 8=met for (UInt_t i=0; i<7; i++){ fTH1DMap["selection"]->Fill(i+0.5,fSelection[i]); } Int_t numFailingMETfil = 0; Int_t numOutOfMggRange = 0; Int_t numNegativeWeight = 0; Int_t numFailEV = 0; Int_t numDuplicateRemoved = 0; Int_t numPassingAll = 0; Int_t numRelFailingMETfil = 0; Int_t numRelOutOfMggRange = 0; Int_t numRelFailEV = 0; Int_t nRel0entries = nentries; Int_t nRel1entries = 0; Int_t nRel2entries = 0; Int_t nRel3entries = 0; for (UInt_t entry = 0; entry < nentries; entry++){ tpho->GetEntry(entry); // Fill TLorentzVector fLorenzVec1.SetPtEtaPhiM(pt1,eta1,phi1,0.); fLorenzVec2.SetPtEtaPhiM(pt2,eta2,phi2,0.); fLorenzVecgg = fLorenzVec1 + fLorenzVec2; // calculate the weight Double_t Weight = (weight)*fPUWeights[nvtx];// PURW[0] corresponds to bin1=0vtx if (hltPhoton26Photon16Mass60 == 1) fTH1DMap["hlt"]->Fill(1.5,1); if (hltPhoton36Photon22Mass15 == 1) fTH1DMap["hlt"]->Fill(2.5,1); if (hltPhoton42Photon25Mass15 == 1) fTH1DMap["hlt"]->Fill(3.5,1); if (hltDiphoton30Mass95 == 1) fTH1DMap["hlt"]->Fill(4.5,1); if (hltDiphoton30Mass70 == 1) fTH1DMap["hlt"]->Fill(5.5,1); if (hltDiphoton30Mass55 == 1) fTH1DMap["hlt"]->Fill(6.5,1); if (hltDiphoton30Mass55PV == 1) fTH1DMap["hlt"]->Fill(7.5,1); if (hltDiphoton30Mass55EB == 1) fTH1DMap["hlt"]->Fill(8.5,1); fTH1DMap["eff_sel"]->Fill(0.5,Weight); Bool_t passCH1 = false; Bool_t passCH2 = false; Bool_t passNH1 = false; Bool_t passNH2 = false; Bool_t passPH1 = false; Bool_t passPH2 = false; Bool_t passS1 = false; Bool_t passS2 = false; Bool_t passHE1 = false; Bool_t passHE2 = false; Bool_t passAll1 = false; Bool_t passAll2 = false; Bool_t passBoth = false; Bool_t passEV1 = false; Bool_t passEV2 = false; // For LOOSE Photon ID Working Point // Can replace "Loose" with "Tight" // OR remove "Loose" for Medium WP if (passLooseCHiso1==1) passCH1 = true; if (passLooseCHiso2==1) passCH2 = true; if (passLooseNHiso1==1) passNH1 = true; if (passLooseNHiso2==1) passNH2 = true; if (passLoosePHiso1==1) passPH1 = true; if (passLoosePHiso2==1) passPH2 = true; if (passLooseSieie1==1) passS1 = true; if (passLooseSieie2==1) passS2 = true; if (passLooseHoe1==1) passHE1 = true; if (passLooseHoe2==1) passHE2 = true; if (eleveto1==1) passEV1 = true; if (eleveto2==1) passEV2 = true; //if (!passCH1) std::cout << "Fails CHIso1" << std::endl; //if (!passCH2) std::cout << "Fails CHIso2" << std::endl; //if (!passNH1) std::cout << "Fails NHIso1" << std::endl; //if (!passNH2) std::cout << "Fails NHIso2" << std::endl; //if (!passPH1) std::cout << "Fails PHIso1" << std::endl; //if (!passPH2) std::cout << "Fails PHIso2" << std::endl; //if (!passS1) std::cout << "Fails SIEIE1" << std::endl; //if (!passS2) std::cout << "Fails SIEIE2" << std::endl; //if (!passHE1) std::cout << "Fails HoE1" << std::endl; //if (!passHE2) std::cout << "Fails HoE2" << std::endl; if (passCH1 && passNH1 && passPH1 && passS1 && passHE1 && passEV1) passAll1 = true; if (passCH2 && passNH2 && passPH2 && passS2 && passHE2 && passEV2) passAll2 = true; if (passAll1 && passAll2) passBoth = true; Bool_t EB1, EB2, EE1, EE2, inEE, inEB; Bool_t hiR9, loR9; // Check if the Data passes MET filters Bool_t passMETfil = true; if (isData){ if (metF_GV!=1 || metF_HBHENoise!=1 || metF_HBHENoiseIso!=1 || metF_CSC!=1 || metF_eeBadSC!=1 ) passMETfil = false; } if (!passMETfil) numFailingMETfil++; if (!isData && !passMETfil) std::cout << "SOMETHING WRONG W/ MET FILTERS" << std::endl; // Check that the weight is not less than 0 Bool_t weightNegative = false; if (Weight <= 0) weightNegative = true; //if ((passMETfil || !passMETfil) && !weightNegative && mgg >= 100 && mgg < 200 && passBoth && hltDiphoton30Mass95==1){ // if (isData && doBlind){ // if (t1pfmet < 100) fTH1DMap["t1pfmet_zoom_wofil"]->Fill(t1pfmet,Weight); // } // else fTH1DMap["t1pfmet_zoom_wofil"]->Fill(t1pfmet,Weight); //} if (mgg < 100 || mgg >= 180) numOutOfMggRange++; if (weightNegative) numNegativeWeight++; if (!passEV1 || !passEV2) numFailEV++; if (prompt==1 || prompt==2){ if (genmatch1==1 && genmatch2==1) numDuplicateRemoved++; } if (mgg >= 100 && mgg < 180){ nRel1entries++; if (!passBoth){ numRelFailEV++; } else{ nRel2entries++; if (!passMETfil){ numRelFailingMETfil++; } else nRel3entries++; } } // START full selection for plots if (passMETfil && !weightNegative){ //Data passes MET filters && not a negativeWeight if (mgg >= 100 && mgg < 180 && passEV1 && passEV2 /*&& pt1 > 0.65*mgg && pt2 > 0.25*mgg */ /*&& t1pfmet > 80*/ ){ fTH1DMap["eff_sel"]->Fill(1.5,Weight); if (hltDiphoton30Mass95==1){ //passes trigger // to remove duplicate events // original implementation: if (prompt==1 && (genmatch1==1 && genmatch2==1)) continue; // only PF and FF for gjets if (prompt==2 && (genmatch1==1 && genmatch2==1)) continue; // only PF and FF for gjets //if (prompt==2 && (genmatch1==1 || genmatch2==1)) continue; // only FF for QCD numPassingAll++; // split events by eta EB1 = false; EB2 = false; EE1 = false; EE2 = false; if (fabs(eta1)>1.566) EE1=true; if (fabs(eta2)>1.566) EE2=true; if (fabs(eta1)<1.4442) EB1=true; if (fabs(eta2)<1.4442) EB2=true; inEE=false; inEB=false; if (EB1 && EB2) inEB=true; else if (EE1 || EE2) inEE=true; // split events by r9 hiR9 = false; loR9 = false; if (r91 > 0.94 && r92 > 0.94) hiR9 = true; else if (r91 <= 0.94 || r92 <= 0.94) loR9 = true; //if (passEV1 && passEV2){ // if (inEB && hiR9){ // if (isData && doBlind){ // if (mgg<115 || mgg>135) fTH1DMap["EBHighR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EBHighR9_ptgg"]->Fill(ptgg,Weight); // if (t1pfmet<100) fTH1DMap["EBHighR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // else{ // fTH1DMap["EBHighR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EBHighR9_ptgg"]->Fill(ptgg,Weight); // fTH1DMap["EBHighR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // } // if (inEB && loR9){ // if (isData && doBlind){ // if (mgg<115 || mgg>135) fTH1DMap["EBLowR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EBLowR9_ptgg"]->Fill(ptgg,Weight); // if (t1pfmet<100) fTH1DMap["EBLowR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // else{ // fTH1DMap["EBLowR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EBLowR9_ptgg"]->Fill(ptgg,Weight); // fTH1DMap["EBLowR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // } // if (inEE && hiR9){ // if (isData && doBlind){ // if (mgg<115 || mgg>135) fTH1DMap["EEHighR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EEHighR9_ptgg"]->Fill(ptgg,Weight); // if (t1pfmet<100) fTH1DMap["EEHighR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // else{ // fTH1DMap["EEHighR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EEHighR9_ptgg"]->Fill(ptgg,Weight); // fTH1DMap["EEHighR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // } // if (inEE && loR9){ // if (isData && doBlind){ // if (mgg<115 || mgg>135) fTH1DMap["EELowR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EELowR9_ptgg"]->Fill(ptgg,Weight); // if (t1pfmet<100) fTH1DMap["EELowR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // else{ // fTH1DMap["EELowR9_mgg"]->Fill(mgg,Weight); // fTH1DMap["EELowR9_ptgg"]->Fill(ptgg,Weight); // fTH1DMap["EELowR9_t1pfmet"]->Fill(t1pfmet,Weight); // } // } //} fTH1DMap["eff_sel"]->Fill(2.5,Weight); //Fill histograms if (isData && doBlind){ // BLIND THE DATA mgg and met distributions if (mgg < 115 || mgg > 135){ fTH1DMap["mgg"]->Fill(mgg,Weight); fTH2DMap["mgg_PU"]->Fill(nvtx,mgg,Weight); fTH2DMap["mgg_ptgg"]->Fill(ptgg,mgg,Weight); } if (t1pfmet < 100){ fTH1DMap["t1pfmet"]->Fill(t1pfmet,Weight); fTH1DMap["t1pfmet_zoom"]->Fill(t1pfmet,Weight); fTH2DMap["t1pfmet_PU"]->Fill(nvtx,t1pfmet,Weight); fTH2DMap["t1pfmet_ptgg"]->Fill(ptgg,t1pfmet,Weight); } if (pfmet < 100) fTH1DMap["pfmet"]->Fill(pfmet,Weight); if (calomet < 100) fTH1DMap["calomet"]->Fill(calomet,Weight); /*if (ptgg<0) */ fTH1DMap["ptgg"]->Fill(ptgg,Weight); } else{ fTH1DMap["mgg"]->Fill(mgg,Weight); fTH1DMap["ptgg"]->Fill(ptgg,Weight); fTH1DMap["t1pfmet"]->Fill(t1pfmet,Weight); fTH1DMap["pfmet"]->Fill(pfmet,Weight); fTH1DMap["calomet"]->Fill(calomet,Weight); fTH1DMap["t1pfmet_zoom"]->Fill(t1pfmet,Weight); fTH2DMap["mgg_PU"]->Fill(nvtx,mgg,Weight); fTH2DMap["mgg_ptgg"]->Fill(ptgg,mgg,Weight); fTH2DMap["t1pfmet_PU"]->Fill(nvtx,t1pfmet,Weight); fTH2DMap["t1pfmet_ptgg"]->Fill(ptgg,t1pfmet,Weight); fTH2DMap["t1pfmet_ptgg"]->Fill(ptgg,t1pfmet,Weight); } // UNBLINDED plot to get inclusive numbers for ABCD ONLY. //if (mgg>100 && mgg<180) fTH2DMap["met_mgg"]->Fill(mgg,t1pfmet,Weight); fTH1DMap["nvtx"]->Fill(nvtx,Weight); fTH1DMap["pt1"]->Fill(pt1,Weight); fTH1DMap["pt2"]->Fill(pt2,Weight); fTH1DMap["t1pfmetphi"]->Fill(t1pfmetphi,Weight); fTH1DMap["pfmetphi"]->Fill(pfmetphi,Weight); fTH1DMap["calometphi"]->Fill(calometphi,Weight); fTH1DMap["phi1"]->Fill(phi1,Weight); fTH1DMap["phi2"]->Fill(phi2,Weight); fTH1DMap["eta1"]->Fill(eta1,Weight); fTH1DMap["eta2"]->Fill(eta2,Weight); fTH1DMap["chiso1"]->Fill(chiso1,Weight); fTH1DMap["chiso2"]->Fill(chiso2,Weight); fTH1DMap["neuiso1"]->Fill(neuiso1,Weight); fTH1DMap["neuiso2"]->Fill(neuiso2,Weight); fTH1DMap["phoiso1"]->Fill(phoiso1,Weight); fTH1DMap["phoiso2"]->Fill(phoiso2,Weight); fTH1DMap["sieie1"]->Fill(sieie1,Weight); fTH1DMap["sieie2"]->Fill(sieie2,Weight); fTH1DMap["hoe1"]->Fill(hoe1,Weight); fTH1DMap["hoe2"]->Fill(hoe2,Weight); fTH1DMap["r91"]->Fill(r91,Weight); fTH1DMap["r92"]->Fill(r92,Weight); fTH1DMap["eleveto1"]->Fill(eleveto1,Weight); fTH1DMap["eleveto2"]->Fill(eleveto2,Weight); fTH1DMap["phigg"]->Fill(fLorenzVecgg.Phi(),Weight); fTH1DMap["dphi_ggmet"]->Fill(deltaPhi(fLorenzVecgg.Phi(),t1pfmetphi),Weight); fTH1DMap["absdphi_ggmet"]->Fill(TMath::Abs(deltaPhi(fLorenzVecgg.Phi(),t1pfmetphi)),Weight); fTH1DMap["deta_gg"]->Fill((eta1-eta2),Weight); fTH1DMap["absdeta_gg"]->Fill(TMath::Abs(eta1-eta2),Weight); //if (!isData){ // for (UInt_t ptcut = 0; ptcut < 200; ptcut++){ // if (ptgg > 10*cut){ // // } // } //} //std::cout << passCH1 <<" "<< passNH1 <<" "<< passPH1 <<" "<< passHE1 <<" "<< passS1 << std::endl; //std::cout << passCH2 <<" "<< passNH2 <<" "<< passPH2 <<" "<< passHE2 <<" "<< passS2 << std::endl; //std::cout << passAll1 <<" "<< passAll2 <<" "<< passBoth << std::endl; //fill n-1 plots for the photon ID selection variables if (passCH1 && passNH1 && passPH1 && passS1) fTH1DMap["hoe1_n-1"]->Fill(hoe1,Weight); if (passCH1 && passNH1 && passPH1 && passHE1) fTH1DMap["sieie1_n-1"]->Fill(sieie1,Weight); if (passCH1 && passNH1 && passHE1 && passS1) fTH1DMap["phoiso1_n-1"]->Fill(phoiso1,Weight); if (passCH1 && passPH1 && passHE1 && passS1) fTH1DMap["neuiso1_n-1"]->Fill(neuiso1,Weight); if (passPH1 && passNH1 && passHE1 && passS1) fTH1DMap["chiso1_n-1"]->Fill(chiso1,Weight); if (passCH2 && passNH2 && passPH2 && passS2) fTH1DMap["hoe2_n-1"]->Fill(hoe2,Weight); if (passCH2 && passNH2 && passPH2 && passHE2) fTH1DMap["sieie2_n-1"]->Fill(sieie2,Weight); if (passCH2 && passNH2 && passHE2 && passS2) fTH1DMap["phoiso2_n-1"]->Fill(phoiso2,Weight); if (passCH2 && passPH2 && passHE2 && passS2) fTH1DMap["neuiso2_n-1"]->Fill(neuiso2,Weight); if (passPH2 && passNH2 && passHE2 && passS2) fTH1DMap["chiso2_n-1"]->Fill(chiso2,Weight); if (passAll1){// fill pho1 plots if these photons pass phoID fTH1DMap["pt1_n-1"]->Fill(pt1,Weight); fTH1DMap["r91_n-1"]->Fill(r91,Weight); fTH1DMap["phi1_n-1"]->Fill(phi1,Weight); fTH1DMap["eta1_n-1"]->Fill(eta1,Weight); } if (passAll2){// fill pho2 plots if these photons pass phoID fTH1DMap["pt2_n-1"]->Fill(pt2,Weight); fTH1DMap["r92_n-1"]->Fill(r92,Weight); fTH1DMap["phi2_n-1"]->Fill(phi2,Weight); fTH1DMap["eta2_n-1"]->Fill(eta2,Weight); } if (passBoth){ fTH1DMap["nvtx_n-1"]->Fill(nvtx,Weight); fTH1DMap["t1pfmetphi_n-1"]->Fill(t1pfmetphi,Weight); fTH1DMap["pfmetphi_n-1"]->Fill(pfmetphi,Weight); fTH1DMap["calometphi_n-1"]->Fill(calometphi,Weight); if (isData && doBlind){// BLIND THE DATA if (mgg < 115 || mgg > 135){ fTH1DMap["mgg_n-1"]->Fill(mgg,Weight); if (t1pfmet < 100) fTH2DMap["t1pfmet_mgg"]->Fill(mgg,t1pfmet,Weight); } if (t1pfmet < 100) fTH1DMap["t1pfmet_n-1"]->Fill(t1pfmet,Weight); if (pfmet < 100) fTH1DMap["pfmet_n-1"]->Fill(pfmet,Weight); if (calomet < 100) fTH1DMap["calomet_n-1"]->Fill(calomet,Weight); /*if (ptgg<0)*/ fTH1DMap["ptgg_n-1"]->Fill(ptgg,Weight); //if (mgg >= 110 && mgg <= 130) fTH1DMap["t1pfmet_selmgg"]->Fill(t1pfmet,Weight); if (t1pfmet >= 50 && ( mgg < 115 || mgg > 135)) fTH1DMap["mgg_selt1pfmet"]->Fill(mgg,Weight); } else{ fTH1DMap["mgg_n-1"]->Fill(mgg,Weight); fTH2DMap["t1pfmet_mgg"]->Fill(mgg,t1pfmet,Weight); fTH1DMap["t1pfmet_n-1"]->Fill(t1pfmet,Weight); fTH1DMap["pfmet_n-1"]->Fill(pfmet,Weight); fTH1DMap["calomet_n-1"]->Fill(calomet,Weight); fTH1DMap["ptgg_n-1"]->Fill(ptgg,Weight); if (mgg >= 110 && mgg <= 130) fTH1DMap["t1pfmet_selmgg"]->Fill(t1pfmet,Weight); if (ptgg > 70) fTH1DMap["t1pfmet_selptgg"]->Fill(t1pfmet,Weight); if (t1pfmet >= 50){ fTH1DMap["mgg_selt1pfmet"]->Fill(mgg,Weight); fTH1DMap["ptgg_selt1pfmet"]->Fill(ptgg,Weight); //std::cout << "DY mgg is " << mgg << std::endl; } } } if (passCH1 && passCH2){ fTH1DMap["eff_sel"]->Fill(3.5,Weight); if (passNH1 && passNH2){ fTH1DMap["eff_sel"]->Fill(4.5,Weight); if (passPH1 && passPH2){ fTH1DMap["eff_sel"]->Fill(5.5,Weight); if (passS1 && passS2){ fTH1DMap["eff_sel"]->Fill(6.5,Weight); if (passHE1 && passHE2){ fTH1DMap["eff_sel"]->Fill(7.5,Weight); if (!isData || !doBlind){// BLIND THE DATA if (mgg >= 115 && mgg <= 135){ fTH1DMap["eff_sel"]->Fill(8.5,Weight); if (t1pfmet >= 100){ fTH1DMap["eff_sel"]->Fill(9.5,Weight); } } } } } } } } for (UInt_t i = 0; i < 60; i++){ if (nvtx == i){ effPUd[i]++; if (passBoth) effPUn[i]++; } if (ptgg >= 10*i && ptgg < 10*(i+1)){ effptd[i]++; if (passBoth) effptn[i]++; } } }// end if passes trigger }// end if passes mass,pt,EV cuts if (hltDiphoton30Mass95==1){ //passes trigger if(passAll2 && pt2 > mgg/4) fTH1DMap["phi1_pho2pass"]->Fill(phi1,Weight); if(passAll1 && pt1 > mgg/3) fTH1DMap["phi2_pho1pass"]->Fill(phi2,Weight); } }// end if passes MET filter }// end loop over entries in tree std::cout << "Number Events that have passed Analyzer: " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by MET filters: " << numFailingMETfil << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by Mgg range: " << numOutOfMggRange << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by Neg Weight: " << numNegativeWeight << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by ElectronVeto: " << numFailEV << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by DupRemoval: " << numDuplicateRemoved << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events PASSING all selection: " << numPassingAll << " out of " << nentries << " events. " << std::endl; std::cout << "Number Events that have passed Analyzer: " << nentries << " events. " << std::endl; std::cout << "Number Events rejected by Mgg range: " << numOutOfMggRange << " out of rel " << nRel0entries << " events. " << std::endl; std::cout << "Number Events rejected by ElectronVeto: " << numRelFailEV << " out of rel " << nRel1entries << " events. " << std::endl; std::cout << "Number Events rejected by MET filters: " << numRelFailingMETfil << " out of rel " << nRel2entries << " events. " << std::endl; std::cout << "Number Events PASSING all selection: " << numPassingAll << " out of rel " << nRel3entries << " events. " << std::endl; Double_t effPU = 0; Double_t effpt = 0; Double_t bin = 0; for (UInt_t i=0; i<60; i++){ bin = (Double_t)i; if (effPUd[i] > 0) effPU = (Double_t)effPUn[i]/(Double_t)effPUd[i]; if (effptd[i] > 0) effpt = (Double_t)effptn[i]/(Double_t)effptd[i]; fTH1DMap["eff_PU"]->Fill(bin,effPU); fTH1DMap["eff_pt"]->Fill(bin*10,effpt); } fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(1,"nentries"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(2,"passPt"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(3,"passTrigger"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(4,"passCHiso"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(5,"passNHiso"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(6,"passPHiso"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(7,"passSieie"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(8,"passHoe"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(9,"passMgg"); fTH1DMap["eff_sel"]->GetXaxis()->SetBinLabel(10,"passMet"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(1,"nentries"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(2,"Pho26Pho16M60"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(3,"Pho36Pho22M15"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(4,"Pho42Pho25M15"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(5,"Dipho30M95"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(6,"Dipho30M70"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(7,"Dipho30M55"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(8,"Dipho30M55PV"); fTH1DMap["hlt"]->GetXaxis()->SetBinLabel(9,"Dipho30M55EB"); //std::cout << "phi1 " << fTH1DMap["phi1_n-1"]->Integral() << " phi2 " << fTH1DMap["phi2_n-1"]->Integral() << std::endl; Plotter::SavePlots(); }// end Plotter::DoPlots
void HiForest::sortJets(TTree* jetTree, Jets& jets, double etaMax, double ptMin, bool allEvents, int smearType){ jetsmear::JetResolution* res = 0; if(smearType==0){ res = new jetsmear::JetResolution(); } vector<TBranch*> branches(0); if(allEvents || currentEvent == 0){ branches.push_back(jetTree->Branch("Lead",&jtLead,"Lead/I")); branches.push_back(jetTree->Branch("SubLead",&jtSubLead,"SubLead/I")); branches.push_back(jetTree->Branch("HasDijet",&jtHasDijet,"HasDijet/O")); branches.push_back(jetTree->Branch("HasLeadingJet",&jtHasLeadingJet,"HasLeadingJet/O")); if(smearType==0 && !mc){ branches.push_back(jetTree->Branch("smpt",jets.smpt,"smpt[nref]/F")); } jetTree->SetAlias("AJ","(jtpt[Lead]-jtpt[SubLead])/(jtpt[Lead]+jtpt[SubLead])"); jetTree->SetAlias("dijetEta","(jteta[Lead]+jteta[SubLead])/2."); } vector<JetIndex> vecs; vecs.reserve(maxEntry); for (int i=0; allEvents ? i<GetEntries() : 1;i++){ if(verbose && i % 50000 == 0) cout<<"Processing Event : "<<i<<endl; if(allEvents){ jetTree->GetEntry(i); } vecs.clear(); if(smearType == 0)res->roll(); for(int j = 0; j < jets.nref; ++j){ // if(jets.jtpt[j] < ptMin) continue; if(fabs(jets.jteta[j]) > etaMax) continue; JetIndex entry; entry.pt = jets.jtpt[j]; entry.index = j; if(smearType == 0){ entry.pt += res->getFluct(jets,j); if(collisionMode == cPbPb && i>=0) cout<<"Flucted"<<endl; jets.smpt[j] = entry.pt; jets.jtpt[j] = entry.pt; } vecs.push_back(entry); } sort(vecs.begin(),vecs.end(),comparePt); jtLead=-1; jtSubLead=-1; jtHasLeadingJet = 0; jtHasDijet = 0; if(vecs.size() > 0){ jtLead = vecs[0].index; if(smearType == 0 && jets.smpt[jtLead] > 100) jtHasLeadingJet = 1; if(smearType != 0 && jets.jtpt[jtLead] > 100) jtHasLeadingJet = 1; } if(vecs.size() > 1){ jtSubLead = vecs[1].index; if(smearType == 0 &&jets.smpt[jtSubLead] > 40){ jtHasDijet = jtHasLeadingJet && fabs(deltaPhi(jets.jtphi[jtLead],jets.jtphi[jtSubLead])) > 2.*3.1415926/3.; } if(smearType != 0 && jets.jtpt[jtSubLead] > 40){ jtHasDijet = jtHasLeadingJet && fabs(deltaPhi(jets.jtphi[jtLead],jets.jtphi[jtSubLead])) > 2.*3.1415926/3.; } } for(int ib = 0; ib < branches.size(); ++ib){ branches[ib]->Fill(); } } return; }
int main() { constexpr long long maxint = (long long)(std::numeric_limits<int>::max())+1LL; constexpr int pi2 = int(maxint/2LL); constexpr int pi4 = int(maxint/4LL); constexpr int pi34 = int(3LL*maxint/4LL); std::cout << "pi, pi2, pi4, p34 " << maxint << ' ' << pi2 << ' ' << pi4 << ' ' << pi34 << ' ' << pi2+pi4 << '\n'; std::cout << "Maximum value for int: " << std::numeric_limits<int>::max() << '\n'; std::cout << "Maximum value for int+2: " << std::numeric_limits<int>::max()+2 << '\n'; std::cout << "Maximum value for int+1 as LL: " << (long long)(std::numeric_limits<int>::max())+1LL << std::endl; std::cout << "Maximum value for short: " << std::numeric_limits<short>::max() << '\n'; std::cout << "Maximum value for short+2: " << short(std::numeric_limits<short>::max()+short(2)) << '\n'; std::cout << "Maximum value for short+1 as int: " << (int)(std::numeric_limits<short>::max())+1 << std::endl; auto d = float(M_PI) -std::nextafter(float(M_PI),0.f); std::cout << "abs res at pi for float " << d << ' ' << phi2int(d) << std::endl; std::cout << "abs res at for int " << int2dphi(1) << std::endl; std::cout << "abs res at for short " << short2phi(1) << std::endl; assert(-std::numeric_limits<int>::max() == (std::numeric_limits<int>::max()+2)); assert(phiLess(0.f,2.f)); assert(phiLess(6.f,0.f)); assert(phiLess(3.2f,0.f)); assert(phiLess(3.0f,3.2f)); assert(phiLess(-0.3f,0.f)); assert(phiLess(-0.3f,0.1f)); assert(phiLess(-3.0f,0.f)); assert(phiLess(3.0f,-3.0f)); assert(phiLess(0.f,-3.4f)); // go around the clock float phi1= -7.; while (phi1<8) { auto p1 = toPhi(phi1); auto ip1 = phi2int(p1); std::cout << "phi1 " << phi1 << ' ' << p1 << ' ' << ip1 << ' ' << int2phi(ip1) << std::endl; float phi2= -7.2; while (phi2<8) { auto p2 = toPhi(phi2); auto ip2 = phi2int(p2); std::cout << "phi2 " << phi2 << ' ' << deltaPhi(phi1,phi2) << ' ' << deltaPhi(phi2,phi1) << ' ' << int2phi(ip1-ip2) << ' ' << int2phi(ip2-ip1) << ' ' << toPhi(phi2+phi1) << ' ' << int2phi(ip1+ip2) << std::endl; phi2+=1; } phi1+=1; } return 0; }
int main(int argc, char** argv) { //Check if all nedeed arguments to parse are there if(argc != 2) { std::cerr << ">>>>> analysis.cpp::usage: " << argv[0] << " configFileName" << std::endl ; return 1; } // Parse the config file parseConfigFile (argv[1]) ; std::string treeName = gConfigParser -> readStringOption("Input::treeName"); std::string inputFile = gConfigParser -> readStringOption("Input::inputFile"); int entryMAX = gConfigParser -> readIntOption("Input::entryMAX"); int entryMIN = gConfigParser -> readIntOption("Input::entryMIN"); int entryMOD = gConfigParser -> readIntOption("Input::entryMOD"); std::cout << ">>>>> input::entryMIN " << entryMIN << std::endl; std::cout << ">>>>> input::entryMAX " << entryMAX << std::endl; std::cout << ">>>>> input::entryMOD " << entryMOD << std::endl; // Open ntple TChain* chain = new TChain(treeName.c_str()); chain->Add(inputFile.c_str()); treeReader reader((TTree*)(chain)); ///---------------- ///---- output ---- std::string OutFileName = gConfigParser -> readStringOption("Output::outFileName"); std::cout << ">>>>> Output::outFileName " << OutFileName << std::endl; TFile outFile(OutFileName.c_str(),"RECREATE"); outFile.cd(); TTree myTree("myTree","myTree"); double Eta; double pT; double ET; double EoP; double SwissE4; double MaxEnergy; TH2F *h2ShowerShapeEB = new TH2F("h2ShowerShapeEB","Shower Shape i#phi i#eta",170,-85,85,360,0,360); TH2F *h2ShowerShapeEE = new TH2F("h2ShowerShapeEE","Shower Shape ix iy",100,0,100,100,0,100); h2ShowerShapeEB->GetXaxis()->SetTitle("i#eta"); h2ShowerShapeEB->GetYaxis()->SetTitle("i#phi"); h2ShowerShapeEE->GetXaxis()->SetTitle("ix"); h2ShowerShapeEE->GetYaxis()->SetTitle("iy"); myTree.Branch("Eta",&Eta,"Eta/D"); myTree.Branch("ET",&ET,"ET/D"); myTree.Branch("pT",&pT,"pT/D"); myTree.Branch("EoP",&EoP,"EoP/D"); myTree.Branch("SwissE4",&SwissE4,"SwissE4/D"); myTree.Branch("MaxEnergy",&MaxEnergy,"MaxEnergy/D"); myTree.Branch("h2ShowerShapeEB","TH2F",&h2ShowerShapeEB,128000,0); myTree.Branch("h2ShowerShapeEE","TH2F",&h2ShowerShapeEE,128000,0); double start, end; if (entryMAX == -1) entryMAX = reader.GetEntries(); else if (reader.GetEntries() < entryMAX) entryMAX = reader.GetEntries(); start = clock(); for(int iEvent = entryMIN ; iEvent < entryMAX ; ++iEvent) { reader.GetEntry(iEvent); if((iEvent%entryMOD) == 0) std::cout << ">>>>> analysis::GetEntry " << iEvent << ":" << entryMAX << std::endl; h2ShowerShapeEB->Reset(); h2ShowerShapeEE->Reset(); int nXtal = reader.GetFloat("E_xtal")->size(); for (int iXtal = 0; iXtal < nXtal; iXtal++){ if (reader.GetInt("ix_xtal")->at(iXtal) == -1000) { ///==== Barrel EB ==== h2ShowerShapeEB->Fill(reader.GetInt("ieta_xtal")->at(iXtal),reader.GetInt("iphi_xtal")->at(iXtal),reader.GetFloat("E_xtal")->at(iXtal)); } else { ///==== Endcap EE ==== h2ShowerShapeEE->Fill(reader.GetInt("ix_xtal")->at(iXtal),reader.GetInt("iy_xtal")->at(iXtal),reader.GetFloat("E_xtal")->at(iXtal)); } } if (reader.GetInt("runId")->size()!=0){ TString TitleEB = Form ("Shower Shape i#phi i#eta Run = %d --- lumi = %d --- event = %d",reader.GetInt("runId")->at(0),reader.GetInt("lumiId")->at(0),reader.GetInt("eventId")->at(0)); h2ShowerShapeEB->SetTitle(TitleEB); TString TitleEE = Form ("Shower Shape ix iy Run = %d --- lumi = %d --- event = %d",reader.GetInt("runId")->at(0),reader.GetInt("lumiId")->at(0),reader.GetInt("eventId")->at(0)); h2ShowerShapeEE->SetTitle(TitleEE); } int nEles = reader.Get4V("electrons")->size(); for (int iEle = 0; iEle < nEles; iEle++){ // std::cerr << "iEle = " << iEle << " : " << nEles << std::endl; if ( (reader.Get4V("met")->at(0)).Et() > 20 && reader.Get4V("electrons")->at(iEle).Pt() > 10 && reader.Get4V("electrons")->at(iEle).Pt() < 60 && deltaPhi(reader.Get4V("electrons")->at(iEle).Phi(),(reader.Get4V("met")->at(0)).Phi()) > 0.75 && (((reader.Get4V("met")->at(0)).Et() / reader.GetFloat("sumEt")->at(0)) > (-0.07 * (reader.Get4V("met")->at(0)).Et() + 3.5 ) || ((reader.Get4V("met")->at(0)).Et() / reader.GetFloat("sumEt")->at(0)) > 0.4) ) { std::cerr << "selected ..." << std::endl; pT = reader.Get4V("electrons")->at(iEle).Pt(); ET = (reader.GetFloat("electrons_scE")->at(iEle)) * sin(reader.Get4V("electrons")->at(iEle).Theta()); EoP = reader.GetFloat("electrons_eOverP")->at(iEle); Eta = reader.Get4V("electrons")->at(iEle).Eta(); SwissE4 = reader.GetFloat("SwissE4")->at(iEle); MaxEnergy = reader.GetFloat("MaxEnergy")->at(iEle); myTree.Fill(); } } } //loop over the events end = clock(); std::cout <<"Time = " << ((double) (end - start)) << " (a.u.)" << std::endl; myTree.Write(); outFile.Write(); return 0; }
void HiForest::correlateTracks(TTree* jetTree, Jets& jets, bool allEvents, bool smeared){ vector<TBranch*> branches(0); if(allEvents || currentEvent == 0){ if(1){ jtChg = new Float_t[maxEntry]; jtNeut = new Float_t[maxEntry]; jtEM = new Float_t[maxEntry]; jtChgGen = new Float_t[maxEntry]; jtNeutGen = new Float_t[maxEntry]; jtEMGen = new Float_t[maxEntry]; jtPtMax = new Float_t[maxEntry]; jtPtMean = new Float_t[maxEntry]; jtPtMeanW = new Float_t[maxEntry]; jtLeadType = new Int_t[maxEntry]; } tjDeltaEtaLead = new Float_t[maxEntryTrack]; tjDeltaPhiLead = new Float_t[maxEntryTrack]; zLead = new Float_t[maxEntryTrack]; tjDeltaEtaSubLead = new Float_t[maxEntryTrack]; tjDeltaPhiSubLead = new Float_t[maxEntryTrack]; zSubLead = new Float_t[maxEntryTrack]; zOldLead = new Float_t[maxEntryTrack]; zOldSubLead = new Float_t[maxEntryTrack]; zSingleLead = new Float_t[maxEntryTrack]; zLabLead = new Float_t[maxEntryTrack]; tjDeltaThetaLead = new Float_t[maxEntryTrack]; tjDeltaThetaLabLead = new Float_t[maxEntryTrack]; tjDeltaThetaSingleLead = new Float_t[maxEntryTrack]; zSingleSubLead = new Float_t[maxEntryTrack]; zLabSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaLabSubLead = new Float_t[maxEntryTrack]; tjDeltaThetaSingleSubLead = new Float_t[maxEntryTrack]; corrLead = new Float_t[maxEntryTrack]; corrSubLead = new Float_t[maxEntryTrack]; branches.push_back(jetTree->Branch("jtChg",jtChg,"jtChg[nref]/F")); branches.push_back(jetTree->Branch("jtNeut",jtNeut,"jtNeut[nref]/F")); branches.push_back(jetTree->Branch("jtEM",jtEM,"jtEM[nref]/F")); branches.push_back(jetTree->Branch("jtChgGen",jtChgGen,"jtChgGen[nref]/F")); branches.push_back(jetTree->Branch("jtNeutGen",jtNeutGen,"jtNeutGen[nref]/F")); branches.push_back(jetTree->Branch("jtEMGen",jtEMGen,"jtEMGen[nref]/F")); branches.push_back(jetTree->Branch("jtPtMax",jtPtMax,"jtPtMax[nref]/F")); branches.push_back(jetTree->Branch("jtPtMean",jtPtMean,"jtPtMean[nref]/F")); branches.push_back(jetTree->Branch("jtPtMeanW",jtPtMeanW,"jtPtMeanW[nref]/F")); branches.push_back(jetTree->Branch("jtLeadType",jtLeadType,"jtLeadType[nref]/I")); branches.push_back(trackTree->Branch("tjDetaLead",tjDeltaEtaLead,"tjDetaLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDphiLead",tjDeltaPhiLead,"tjDphiLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLead",zLead,"zLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDetaSubLead",tjDeltaEtaSubLead,"tjDetaSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDphiSubLead",tjDeltaPhiSubLead,"tjDphiSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSubLead",zSubLead,"zSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zOldLead",zOldLead,"zOldLead[nTrk]/F")); branches.push_back(trackTree->Branch("zOldSubLead",zOldSubLead,"zOldSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSingleLead",zSingleLead,"zSingleLead[nTrk]/F")); branches.push_back(trackTree->Branch("zSingleSubLead",zSingleSubLead,"zSingleSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLabLead",zLabLead,"zLabLead[nTrk]/F")); branches.push_back(trackTree->Branch("zLabSubLead",zSubLead,"zLabSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLead",tjDeltaThetaLead,"tjDthetaLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLabLead",tjDeltaThetaLabLead,"tjDthetaLabLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSingleLead",tjDeltaThetaSingleLead,"tjDthetaSingleLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSubLead",tjDeltaThetaSubLead,"tjDthetaSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaLabSubLead",tjDeltaThetaLabSubLead,"tjDthetaLabSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("tjDthetaSingleSubLead",tjDeltaThetaSingleSubLead,"tjDthetaSingleSubLead[nTrk]/F")); branches.push_back(trackTree->Branch("corrLead",corrLead,"corrLead[nTrk]/F")); branches.push_back(trackTree->Branch("corrSubLead",corrSubLead,"corrSubLead[nTrk]/F")); jetTree->SetAlias("jtFracChg","jtChg/jtpt"); jetTree->SetAlias("jtFracNeut","jtNeut/jtpt"); jetTree->SetAlias("jtFracEM","jtFracEM/jtpt"); jetTree->SetAlias("refFracChg","jtChg/refpt"); jetTree->SetAlias("refFracNeut","jtNeut/refpt"); jetTree->SetAlias("refFracEM","jtFracEM/refpt"); jetTree->SetAlias("jtFracChgGen","jtChgGen/jtpt"); jetTree->SetAlias("jtFracNeutGen","jtNeutGen/refpt"); jetTree->SetAlias("jtFracEMGen","jtFracEMGen/refpt"); trackTree->SetAlias("tjDRlead","sqrt(tjDetaLead*tjDetaLead+tjDphiLead*tjDphiLead)"); trackTree->SetAlias("tjDRsublead","sqrt(tjDetaSubLead*tjDetaSubLead+tjDphiSubLead*tjDphiSubLead)"); } double correctionFactors[4] = {0,0,0,0}; for (int i=0; allEvents ? i<GetEntries() : 1;i++){ if(i % 1000 == 0) cout<<"Processing Event : "<<i<<endl; if(allEvents){ jetTree->GetEntry(i); trackTree->GetEntry(i); hltTree->GetEntry(i); } int cbin = evt.hiBin; if(collisionMode == cPP) cbin = 33; double eventEta = 0; if(hasDiJet(jets)) eventEta = (jets.jteta[jtLead]+jets.jteta[jtSubLead])/2.; for(int j = 0; j < jets.nref; ++j){ jtChg[j] = 0; jtNeut[j] = 0; jtEM[j] = 0; jtPtMax[j] = 0; jtPtMean[j] = 0; jtPtMeanW[j] = 0; jtLeadType[j] = 0; for (int t = 0; t < track.nTrk; ++t) { double jetPt = jets.jtpt[j]; if(smeared)jetPt = jets.smpt[j]; if(j == jtLead){ tjDeltaEtaLead[t] = track.trkEta[t] - jets.jteta[j]; tjDeltaPhiLead[t] = deltaPhi(track.trkPhi[t],jets.jtphi[j]); zOldLead[t] = track.trkPt[t]/jetPt; zLead[t] = getProjectedZ(jetPt,jets.jteta[j],jets.jtphi[j],track.trkPt[t],track.trkEta[t],track.trkPhi[t],eventEta); // cout<<"jtpt : "<<jets.jtpt[j]<<" spt : "<<jets.smpt[j]<<endl; corrLead[t] = trackCorrections[0]->GetCorr(track.trkPt[t],track.trkEta[t],jetPt,cbin,correctionFactors); } if(j == jtSubLead){ tjDeltaEtaSubLead[t] = track.trkEta[t] - jets.jteta[j]; tjDeltaPhiSubLead[t] = deltaPhi(track.trkPhi[t],jets.jtphi[j]); zSubLead[t] = getProjectedZ(jetPt,jets.jteta[j],jets.jtphi[j],track.trkPt[t],track.trkEta[t],track.trkPhi[t],eventEta); zOldSubLead[t] = track.trkPt[t]/jetPt; corrSubLead[t] = trackCorrections[1]->GetCorr(track.trkPt[t],track.trkEta[t],jetPt,cbin,correctionFactors); } double dr = deltaR(track.trkEta[t],track.trkPhi[t],jets.jteta[j],jets.jtphi[j]); if(dr > cone) continue; if(jtPtMax[j] < track.trkPt[t]) jtPtMax[j] = track.trkPt[t]; jtChg[j] += track.trkPt[t]; } } for(unsigned int ib = 0; ib < branches.size(); ++ib){ branches[ib]->Fill(); } } return; }
void fakeMonoPhotons() { //************************************************************************************************* // Loose Photon Definition //************************************************************************************************* // Photon energy > x Double_t x_phoE = 160; // Low Missing energy < x Double_t x_met = 30; // High MET defined as > x Double_t x_highMet = 140; // |Photon Eta| < x Double_t x_eta = 1.479; // E_Had / E_Em < x Double_t x_hadEm = 0.05; // x < sigma_ietai_eta < y Double_t x_covEta = 0.001; Double_t y_covEta = 0.013; // x < sigma_iphii_phi Double_t x_covPhi = 0.001; // |Lead time span| < x Double_t x_leadTime = 8.0; // No Pixel Seed // Is HLT Trigger Object // Not Electron // Not Beam Halo Tagged // Cosmic Veto // Seed Time > x Double_t x_seedTime = -1.5; // Jet Veto Double_t x_jetPt = 1000000.; // Iso < Min( x*(den Iso), y*(photon pt) ) Double_t x_looseIso = 5.0; // Double_t y_looseIso = 0.2; // QCD Sideband Iso x*x_iso3 < Iso3 < y*x_iso3 Double_t x_sideband = 0.5; Double_t y_sideband = 2; //************************************************************************************************* // Numerator Definition (loose photon + ..) //************************************************************************************************* // Iso < x, if Photon R9 >= y Double_t x_iso1high = 6.0; Double_t x_iso2high = 10.0; Double_t x_iso3high = 3.8; Double_t y_isoR9 = 0.94; // Iso < x, if Photon R9 < y Double_t x_iso1low = 4.7; Double_t x_iso2low = 6.5; Double_t x_iso3low = 2.5; Double_t x_iso1; Double_t x_iso2; Double_t x_iso3; //************************************************************************************************* // Denominator Definition (loose photon + ..) //************************************************************************************************* // One inverted isolation requirement (Iso > x + y*(photon pt)) //************************************************************************************************* // Output objects //************************************************************************************************* const Int_t nBins = 6; Double_t xBins[nBins+1] = { 145, 160, 190, 250, 400, 700, 1000, }; TH1D *numerators = new TH1D("numerators","Numerators",nBins,xBins); TH1D *denominators = new TH1D("denominators","Denominators",nBins,xBins); TH1D *looseSelection= new TH1D("looseSelection","Loose Selection",nBins,xBins); TH1D *loosePhotons = new TH1D("loosePhotons","Loose Photons",1000,0,1000); TH1D *data145_160 = new TH1D("data145_160","Data",200,0,0.04); TH1D *data160_190 = new TH1D("data160_190","Data",200,0,0.04); TH1D *data190_250 = new TH1D("data190_250","Data",200,0,0.04); TH1D *data250_400 = new TH1D("data250_400","Data",200,0,0.04); TH1D *data400_700 = new TH1D("data400_700","Data",200,0,0.04); TH1D *data700_1000 = new TH1D("data700_1000","Data",200,0,0.04); TH1D *fake145_160 = new TH1D("fake145_160","Fake",200,0,0.04); TH1D *fake160_190 = new TH1D("fake160_190","Fake",200,0,0.04); TH1D *fake190_250 = new TH1D("fake190_250","Fake",200,0,0.04); TH1D *fake250_400 = new TH1D("fake250_400","Fake",200,0,0.04); TH1D *fake400_700 = new TH1D("fake400_700","Fake",200,0,0.04); TH1D *fake700_1000 = new TH1D("fake700_1000","Fake",200,0,0.04); TH1D *mc145_160 = new TH1D("mc145_160","MC",200,0,0.04); TH1D *mc160_190 = new TH1D("mc160_190","MC",200,0,0.04); TH1D *mc190_250 = new TH1D("mc190_250","MC",200,0,0.04); TH1D *mc250_400 = new TH1D("mc250_400","MC",200,0,0.04); TH1D *mc400_700 = new TH1D("mc400_700","MC",200,0,0.04); TH1D *mc700_1000 = new TH1D("mc700_1000","MC",200,0,0.04); TH1D *dataHist; TH1D *fakeHist; TH1D *mcHist; Double_t loosePhMet[nBins]; Double_t num[nBins]; Double_t den[nBins]; Int_t whichBin; for ( Int_t i=0; i<nBins; i++ ) { loosePhMet[i] = 0; num[i] = 0; den[i] = 0; } //************************************************************************************************* // Loop //************************************************************************************************* // Get list of files std::string dataString("r12"); std::string mcString("s12"); std::string buff; std::ifstream file ("files.txt"); while ( file.good() ) { // Load each file name std::getline (file,buff); // Stop if end of file if( buff == "" ) break; // Initialize file MitGPTree event; TString filename = TString("monoph-2013-July9_") + TString(buff) + TString("_noskim.root"); event.LoadTree(TString("/scratch/cferko/hist/monoph-2013-July9/merged/") + filename,2); event.InitTree(0); // Loop over events Int_t nEntries = event.tree_->GetEntries(); for ( Int_t i=0; i<nEntries; i++ ) { event.tree_->GetEntry(i); // Loop over photons of each event for ( Int_t j=1; j<5; j++ ) { //******************************************************************************************* // Set Variables //******************************************************************************************* // Define Double_t phoPt; Double_t phoE; Double_t phoEta; Double_t phoPhi; Double_t hadEm; Double_t covEta; Double_t covPhi; Double_t leadTime; Double_t phoR9; Bool_t pxlSeed; Bool_t hltMatch; Bool_t notEle; Bool_t isHalo; Double_t seedTime; Int_t nleps; Int_t ncosmics; Double_t jetPt; Double_t iso1; Double_t iso2; Double_t iso3; Double_t dPhi; if ( j == 1 ) { phoPt = event.pho1_.Pt(); phoE = event.pho1_.E(); phoEta = event.pho1_.Eta(); phoPhi = event.pho1_.Phi(); hadEm = event.phoHadOverEm_a1_; covEta = event.phoCoviEtaiEta_a1_; covPhi = event.phoCoviPhiiPhi_a1_; leadTime = event.phoLeadTimeSpan_a1_; phoR9 = event.phoR9_a1_; pxlSeed = event.phoHasPixelSeed_a1_; hltMatch = event.phoIsTrigger_a1_; notEle = event.phoPassEleVeto_a1_; isHalo = event.phoMipIsHalo_a1_; seedTime = event.phoSeedTime_a1_; iso1 = event.phoCombIso1_a1_; iso2 = event.phoCombIso2_a1_; iso3 = event.phoCombIso3_a1_; } if ( j == 2 ) { phoPt = event.pho2_.Pt(); phoE = event.pho2_.E(); phoEta = event.pho2_.Eta(); phoPhi = event.pho2_.Phi(); hadEm = event.phoHadOverEm_a2_; covEta = event.phoCoviEtaiEta_a2_; covPhi = event.phoCoviPhiiPhi_a2_; leadTime = event.phoLeadTimeSpan_a2_; phoR9 = event.phoR9_a2_; pxlSeed = event.phoHasPixelSeed_a2_; hltMatch = event.phoIsTrigger_a2_; notEle = event.phoPassEleVeto_a2_; isHalo = event.phoMipIsHalo_a2_; seedTime = event.phoSeedTime_a2_; iso1 = event.phoCombIso1_a2_; iso2 = event.phoCombIso2_a2_; iso3 = event.phoCombIso3_a2_; } if ( j == 3 ) { phoPt = event.pho3_.Pt(); phoE = event.pho3_.E(); phoEta = event.pho3_.Eta(); phoPhi = event.pho3_.Phi(); hadEm = event.phoHadOverEm_a3_; covEta = event.phoCoviEtaiEta_a3_; covPhi = event.phoCoviPhiiPhi_a3_; leadTime = event.phoLeadTimeSpan_a3_; phoR9 = event.phoR9_a3_; pxlSeed = event.phoHasPixelSeed_a3_; hltMatch = event.phoIsTrigger_a3_; notEle = event.phoPassEleVeto_a3_; isHalo = event.phoMipIsHalo_a3_; seedTime = event.phoSeedTime_a3_; iso1 = event.phoCombIso1_a3_; iso2 = event.phoCombIso2_a3_; iso3 = event.phoCombIso3_a3_; } if ( j == 4 ) { phoPt = event.pho4_.Pt(); phoE = event.pho4_.E(); phoEta = event.pho4_.Eta(); phoPhi = event.pho4_.Phi(); hadEm = event.phoHadOverEm_a4_; covEta = event.phoCoviEtaiEta_a4_; covPhi = event.phoCoviPhiiPhi_a4_; leadTime = event.phoLeadTimeSpan_a4_; phoR9 = event.phoR9_a4_; pxlSeed = event.phoHasPixelSeed_a4_; hltMatch = event.phoIsTrigger_a4_; notEle = event.phoPassEleVeto_a4_; isHalo = event.phoMipIsHalo_a4_; seedTime = event.phoSeedTime_a4_; iso1 = event.phoCombIso1_a4_; iso2 = event.phoCombIso2_a4_; iso3 = event.phoCombIso3_a4_; } nleps = event.nlep_; ncosmics = event.ncosmics_; jetPt = event.jet1_.Pt(); dPhi = deltaPhi(phoPhi,event.metPhi_); // Determine correct bin if ( phoPt < xBins[1] ) { whichBin = 0; dataHist = data145_160; fakeHist = fake145_160; mcHist = mc145_160; } if ( xBins[1] <= phoPt && phoPt < xBins[2] ) { whichBin = 1; dataHist = data160_190; fakeHist = fake160_190; mcHist = mc160_190; } if ( xBins[2] <= phoPt && phoPt < xBins[3] ) { whichBin = 2; dataHist = data190_250; fakeHist = fake190_250; mcHist = mc190_250; } if ( xBins[3] <= phoPt && phoPt < xBins[4] ) { whichBin = 3; dataHist = data250_400; fakeHist = fake250_400; mcHist = mc250_400; } if ( xBins[4] <= phoPt && phoPt < xBins[5] ) { whichBin = 4; dataHist = data400_700; fakeHist = fake400_700; mcHist = mc400_700; } if ( xBins[5] <= phoPt ) { whichBin = 5; dataHist = data700_1000; fakeHist = fake700_1000; mcHist = mc700_1000; } // Which isolation requirements if ( phoR9 >= y_isoR9 ) { x_iso1 = x_iso1high; x_iso2 = x_iso2high; x_iso3 = x_iso3high; } if ( phoR9 < y_isoR9 ) { x_iso1 = x_iso1low; x_iso2 = x_iso2low; x_iso3 = x_iso3low; } //******************************************************************************************* // Cuts //******************************************************************************************* // Regional cuts if ( phoE < x_phoE ) continue; if ( TMath::Abs(phoEta) > x_eta ) continue; if ( hadEm > x_hadEm ) continue; if ( covEta < x_covEta ) continue; if ( covPhi < x_covPhi ) continue; if ( TMath::Abs(leadTime) > x_leadTime ) continue; if ( !hltMatch ) continue; if ( !notEle ) continue; if ( isHalo ) continue; if ( seedTime < x_seedTime ) continue; if ( nleps != 0 ) continue; if ( ncosmics != 0 ) continue; // Check whether reading data if ( buff.compare(0, dataString.length(), dataString) == 0 ) { // Check whether loose photon + high met candidate if ( event.met_ > x_met ) { if ( event.met_ > x_highMet ) if ( iso1 > x_iso1 || iso2 > x_iso2 || iso3 > x_iso3 ) if ( iso1 < x_looseIso*x_iso1 ) if ( iso2 < x_looseIso*x_iso2 ) if ( iso3 < x_looseIso*x_iso3 ) if ( covEta > x_covEta && covEta < y_covEta ) { loosePhMet[whichBin]++; loosePhotons->Fill(phoPt); } continue; } // Numerators if ( iso1 < x_iso1 ) if ( iso2 < x_iso2 ) { if ( iso3 < x_iso3 ) // Jet veto if ( jetPt < x_jetPt ) { // // BLIND // if ( TMath::Cos(dPhi) > -0.97 ) { dataHist->Fill(TMath::Abs(covEta)); if ( covEta > x_covEta && covEta < y_covEta ) num[whichBin]++; // } } // Sideband if ( iso3 > x_sideband*x_iso3 && iso3 < y_sideband*x_iso3 ) fakeHist->Fill(TMath::Abs(covEta)); } // Denominators if ( iso1 > x_iso1 || iso2 > x_iso2 || iso3 > x_iso3 ) if ( iso1 < x_looseIso*x_iso1 ) if ( iso2 < x_looseIso*x_iso2 ) if ( iso3 < x_looseIso*x_iso3 ) if ( covEta > x_covEta && covEta < y_covEta ) den[whichBin]++; } // Check whether reading monte carlo if ( buff.compare(0, mcString.length(), mcString) == 0 ) { if ( event.met_ > x_met ) continue; if ( iso1 < x_iso1 ) if ( iso2 < x_iso2 ) if ( iso3 < x_iso3 ) mcHist->Fill(TMath::Abs(covEta)); } } } } //************************************************************************************************* // Plots for fakePhotonsCalculator.C //************************************************************************************************* for ( Int_t i=0; i<nBins; i++ ) { denominators->Fill(xBins[i],den[i]); numerators->Fill(xBins[i],num[i]); looseSelection->Fill(xBins[i],loosePhMet[i]); } TFile *preFit = new TFile("sysBin.root","RECREATE"); data145_160->Write(); fake145_160->Write(); mc145_160->Write(); data160_190->Write(); fake160_190->Write(); mc160_190->Write(); data190_250->Write(); fake190_250->Write(); mc190_250->Write(); data250_400->Write(); fake250_400->Write(); mc250_400->Write(); data400_700->Write(); fake400_700->Write(); mc400_700->Write(); data700_1000->Write(); fake700_1000->Write(); mc700_1000->Write(); numerators->Write(); denominators->Write(); looseSelection->Write(); loosePhotons->Write(); preFit->Close(); }
double HiForest::deltaPhiDijet(Jets& jets){ return fabs(deltaPhi(jets.jtphi[leadingJet()],jets.jtphi[subleadingJet()])); }
double L1Ntuple::deltaR(double eta1, double phi1, double eta2, double phi2) { double deta = eta1 - eta2; double dphi = deltaPhi(phi1, phi2); return sqrt(deta*deta + dphi*dphi); }
void HiForest::fakeRejection(TTree *jetTree, Jets &jets, bool allEvents) { std::vector<TBranch *> branch; branch.push_back(jetTree->Branch("fr01Chg", jets.fr01Chg, "fr01Chg[nref]/F")); branch.push_back(jetTree->Branch("fr01EM", jets.fr01EM, "fr01EM[nref]/F")); branch.push_back(jetTree->Branch("fr01", jets.fr01, "fr01[nref]/F")); for (int i = 0; i < (allEvents ? GetEntries() : 1); i++) { if (allEvents) { jetTree->GetEntry(i); trackTree->GetEntry(i); photonTree->GetEntry(i); if (i % 1000 == 0) { std::cout << i <<" / "<< GetEntries() << endl; } } for (int j = 0; j < jets.nref; j++) { float pseudorapidity_adapt = jets.jteta[j]; float azimuth_adapt = jets.jtphi[j]; float max_weighted_perp = 0; float sum; jets.fr01Chg[j] = 0; jets.fr01EM[j] = 0; // Unadapted discriminant with adaption search sum = 0; for (int k = 0; k < track.nTrk; k++) { const float dpseudorapidity = track.trkEta[k] - jets.jteta[j]; const float dazimuth = deltaPhi(track.trkPhi[k], jets.jtphi[j]); const float angular_weight = exp(-50.0F * (dpseudorapidity * dpseudorapidity + dazimuth * dazimuth)); const float weighted_perp = angular_weight * track.trkPt[k] * track.trkPt[k]; const float weighted_perp_square = weighted_perp * track.trkPt[k]; sum += weighted_perp_square; if (weighted_perp >= max_weighted_perp) { pseudorapidity_adapt = track.trkEta[k]; azimuth_adapt = track.trkPhi[k]; max_weighted_perp = weighted_perp; } } jets.fr01Chg[j] = std::max(jets.fr01Chg[j], sum); sum = 0; for (int k = 0; k < photon.nPhotons; k++) { const float dpseudorapidity = photon.eta[k] - jets.jteta[j]; const float dazimuth = deltaPhi(photon.phi[k], jets.jtphi[j]); const float angular_weight = exp(-50.0F * (dpseudorapidity * dpseudorapidity + dazimuth * dazimuth)); const float weighted_perp = angular_weight * photon.pt[k] * photon.pt[k]; const float weighted_perp_square = weighted_perp * photon.pt[k]; sum += weighted_perp_square; if (weighted_perp >= max_weighted_perp) { pseudorapidity_adapt = photon.eta[k]; azimuth_adapt = photon.phi[k]; max_weighted_perp = weighted_perp; } } jets.fr01EM[j] = std::max(jets.fr01EM[j], sum); // (First order) adapted discriminant sum = 0; for (int k = 0; k < track.nTrk; k++) { const float dpseudorapidity = track.trkEta[k] - pseudorapidity_adapt; const float dazimuth = deltaPhi(track.trkPhi[k], azimuth_adapt); const float angular_weight = exp(-50.0F * (dpseudorapidity * dpseudorapidity + dazimuth * dazimuth)); const float weighted_perp = angular_weight * track.trkPt[k] * track.trkPt[k]; const float weighted_perp_square = weighted_perp * track.trkPt[k]; sum += weighted_perp_square; } jets.fr01Chg[j] = std::max(jets.fr01Chg[j], sum); sum = 0; for (int k = 0; k < photon.nPhotons; k++) { const float dpseudorapidity = photon.eta[k] - jets.jteta[j]; const float dazimuth = deltaPhi(photon.phi[k], jets.jtphi[j]); const float angular_weight = exp(-50.0F * (dpseudorapidity * dpseudorapidity + dazimuth * dazimuth)); const float weighted_perp = angular_weight * photon.pt[k] * photon.pt[k]; const float weighted_perp_square = weighted_perp * photon.pt[k]; sum += weighted_perp_square; if (weighted_perp >= max_weighted_perp) { pseudorapidity_adapt = photon.eta[k]; azimuth_adapt = photon.phi[k]; max_weighted_perp = weighted_perp; } } jets.fr01EM[j] = std::max(jets.fr01EM[j], sum); // Combine charged track and ECAL energy (HCAL is too // coarse for fake rejection purpose) jets.fr01[j] = jets.fr01Chg[j] + jets.fr01EM[j]; } for(std::vector<TBranch *>::const_iterator iterator = branch.begin(); iterator != branch.end(); iterator++) { (*iterator)->Fill(); } } }
//!PG main function int selector (TChain * tree, histos & plots, int if_signal) { plots.v_hardTAGPt = -99; plots.v_softTAGPt = -99; plots.v_TAGDProdEta = -99; plots.v_TAGDeta = -99; plots.v_TAGMinv = -99; plots.v_LepLep = -99; plots.v_hardLEPPt = -99; plots.v_softLEPPt = -99; plots.v_LEPDPhi = -99; plots.v_LEPDEta = -99; plots.v_LEPDR = -99; plots.v_LEPMinv = -99; plots.v_LEPProdCharge = -99; plots.v_hardLEPCharge = -99; plots.v_softLEPCharge = -99; plots.v_MET = -99; plots.v_ojets = -99 ; plots.v_ojetsCJV = -99 ; plots.v_ojetsRegionalCJV = -99 ; plots.v_ojetsZepp_01 = -99 ; plots.v_ojetsZepp_02 = -99 ; plots.v_ojetsZepp_03 = -99 ; plots.v_ojetsZepp_04 = -99 ; plots.v_ojetsZepp_05 = -99 ; plots.v_ojetsZepp_06 = -99 ; plots.v_ojetsZepp_07 = -99 ; plots.v_ojetsZepp_08 = -99 ; plots.v_ojetsZepp_09 = -99 ; plots.v_ojetsZepp_10 = -99 ; plots.v_ojetsZepp_11 = -99 ; plots.v_ojetsZepp_12 = -99 ; plots.v_ojetsZepp_13 = -99 ; plots.v_ojetsZepp_14 = -99 ; plots.v_decay_Channel_e = -99 ; plots.v_decay_Channel_mu = -99 ; plots.v_decay_Channel_tau = -99 ; TClonesArray * genParticles = new TClonesArray ("TParticle") ; tree->SetBranchAddress ("genParticles", &genParticles) ; // TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; // tree->SetBranchAddress ("tagJets", &tagJets) ; TClonesArray * otherJets_temp = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress (g_KindOfJet.c_str(), &otherJets_temp) ; // tree->SetBranchAddress ("otherJets", &otherJets_temp) ; TClonesArray * electrons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("electrons", &electrons) ; TClonesArray * muons = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("muons", &muons) ; TClonesArray * MET = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("MET", &MET) ; TClonesArray * tracks = new TClonesArray ("TLorentzVector") ; tree->SetBranchAddress ("tracks", &tracks) ; TClonesArray * tagJets = new TClonesArray ("TLorentzVector") ; TClonesArray * otherJets = new TClonesArray ("TLorentzVector") ; int EleId[100]; float IsolEleSumPt_VBF[100]; int nEle; int EleCharge[30]; tree->SetBranchAddress ("nEle", &nEle) ; tree->SetBranchAddress ("EleId",EleId ) ; tree->SetBranchAddress ("IsolEleSumPt_VBF",IsolEleSumPt_VBF ) ; tree->SetBranchAddress ("EleCharge",EleCharge ) ; float IsolMuTr[100]; int nMu ; int MuCharge[30]; tree->SetBranchAddress ("nMu", &nMu) ; tree->SetBranchAddress ("IsolMuTr",IsolMuTr ) ; tree->SetBranchAddress ("MuCharge", MuCharge) ; int IdEvent; tree->SetBranchAddress ("IdEvent", &IdEvent) ; int nentries = (int) tree->GetEntries () ; plots.passedJetAndLepNumberSelections = 0; plots.analyzed = 0; plots.analyzed_ee = 0; plots.analyzed_mumu = 0; plots.analyzed_tautau = 0; plots.analyzed_emu = 0; plots.analyzed_etau = 0; plots.analyzed_mutau = 0; plots.passedJetAndLepNumberSelections_ee = 0; plots.passedJetAndLepNumberSelections_mumu = 0; plots.passedJetAndLepNumberSelections_tautau = 0; plots.passedJetAndLepNumberSelections_emu = 0; plots.passedJetAndLepNumberSelections_etau = 0; plots.passedJetAndLepNumberSelections_mutau = 0; //PG loop over the events for (int evt = 0 ; evt < nentries ; ++evt) { tree->GetEntry (evt) ; tagJets -> Clear () ; otherJets -> Clear () ; //---- check if signal ---- if (if_signal && (IdEvent!=123 && IdEvent!=124)) continue; plots.analyzed++; //!---- MC ---- if (IdEvent==123 || IdEvent==124) { //---- VBF event ---- plots.v_decay_Channel_e = 0; plots.v_decay_Channel_mu = 0; plots.v_decay_Channel_tau = 0; for (int iGen = 0; iGen < genParticles->GetEntries() ; ++iGen){ TParticle* myparticle = (TParticle*) genParticles->At(iGen); if (abs(myparticle->GetPdgCode()) == 24) { //---- W Int_t mother1 = 0; mother1 = myparticle->GetMother(0); if (mother1 == 25) { //---- mother is higgs ---- for (int iDaughter = 0; iDaughter<2; iDaughter++){ if (abs(myparticle->GetDaughter(iDaughter)) == 11) {//---- W -> e plots.v_decay_Channel_e++; } if (abs(myparticle->GetDaughter(iDaughter)) == 13) {//---- W -> mu plots.v_decay_Channel_mu++; } if (abs(myparticle->GetDaughter(iDaughter)) == 15) {//---- W -> tau plots.v_decay_Channel_tau++; } } } } } } if (plots.v_decay_Channel_e == 2) plots.analyzed_ee++; if (plots.v_decay_Channel_mu == 2) plots.analyzed_mumu++; if (plots.v_decay_Channel_tau == 2) plots.analyzed_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.analyzed_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.analyzed_mutau++; int cutId = 0 ; plots.increase (cutId++) ; //AM 0 -> total number of events // std::cerr << "--- preambolo leptoni " << std::endl; std::vector<lepton> leptons ; //PG pour electrons into leptons collection //PG --------------------------------------- //PG loop over electrons for (int iele = 0; iele < electrons->GetEntries () ; ++iele) { TLorentzVector * theEle = (TLorentzVector*) (electrons->At (iele)) ; lepton dummy (theEle, 0, iele) ; leptons.push_back (dummy) ; } //PG loop over electrons //PG loop over muons for (int imu = 0 ; imu < nMu ; ++imu) { TLorentzVector * theMu = (TLorentzVector*) (muons->At (imu)) ; lepton dummy (theMu, 1, imu) ; leptons.push_back (dummy) ; } //PG loop over muons //PG this check is not necessary //PG if (leptons.size () < 2) continue ; // std::cerr << "--- inizia leptoni " << std::endl; //PG 2 LEPTONS //PG --------- /* applied after the leptons choice: in this case it is possible to differentiate the selections depending on the position of each lepton in the pt-sorting. the algorithm searches the first two most energetic candidates which satisfy the ID selections required for the first and second lepton respectively. Then check for channel analysis according to "g_LepLep" 0 == ee 1 == mumu 2 == emu 3 == mue pt ordered */ sort (leptons.rbegin (), leptons.rend (), lessThan ()) ; lepton primoLEP ; lepton secondoLEP ; double first_lepton_charge = 0; double second_lepton_charge = 0; int lepton_counter = 0; int electron_counter = 0; int muon_counter = 0; //PG find the first lepton int ilep = 0 ; for ( ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO1[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID1 == 100 && (eleID/100) != 1) continue; else if (g_ID1 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID1 == 1 && (eleID%10) != 1) continue; first_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO1[1] == 1 && muIso != 1) continue; first_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } primoLEP = leptons[ilep] ; lepton_counter++; if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; break ; } //PG find the first lepton //PG find the second lepton bool flag_secondoLEP = false; for (++ilep ; ilep < leptons.size () ; ++ilep) { if (leptons.at (ilep).m_flav == 0) //PG electron { //PG iso check bool eleIso = (IsolEleSumPt_VBF[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoElectron ; // 0.2 per il momento if (g_ISO2[0] == 1 && eleIso != 1) continue; //PG eleID check int eleID = EleId[leptons.at (ilep).m_index] ; if (g_ID2 == 100 && (eleID/100) != 1) continue; else if (g_ID2 == 10 && ((eleID%100)/10) != 1) continue; else if (g_ID2 == 1 && (eleID%10) != 1) continue; second_lepton_charge = EleCharge[leptons.at (ilep).m_index]; } else //PG muon { //PG iso check bool muIso = (IsolMuTr[leptons.at (ilep).m_index] / leptons.at (ilep).m_kine->Pt () ) < g_IsoMuon ; if (g_ISO2[1] == 1 && muIso != 1) continue; second_lepton_charge = MuCharge[leptons.at (ilep).m_index]; } if (!flag_secondoLEP) { secondoLEP = leptons[ilep] ; flag_secondoLEP = true; } if (leptons.at (ilep).m_kine->Pt () > 0) { if (leptons.at (ilep).m_flav == 0) electron_counter++; else muon_counter++; lepton_counter++; } } //PG find the second lepton //---- AM 3 --- 2 leptons after Id if (primoLEP.m_flav == -1 || secondoLEP.m_flav == -1) continue ; //---- AM 4 check for the two most transverse-energetic leptons have the right flavours plots.v_numLep = lepton_counter; plots.v_numEle = electron_counter; plots.v_numMu = muon_counter; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 0) plots.v_LepLep = 0 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 1) plots.v_LepLep = 1 ; if (primoLEP.m_flav == 0 && secondoLEP.m_flav == 1) plots.v_LepLep = 2 ; if (primoLEP.m_flav == 1 && secondoLEP.m_flav == 0) plots.v_LepLep = 3 ; plots.v_hardLEPPt = primoLEP.m_kine->Pt () ; //---- AM 5 pt_min of the most energetic lepton plots.v_softLEPPt = secondoLEP.m_kine->Pt () ; //---- AM 6 pt_min of the least energetic lepton plots.v_LEPDPhi = deltaPhi (primoLEP.m_kine->Phi (), secondoLEP.m_kine->Phi ()) ; //---- AM 7 Delta_phi_min between leptons plots.v_LEPDEta = deltaEta (primoLEP.m_kine->Eta (), secondoLEP.m_kine->Eta ()) ; plots.v_LEPDR = deltaR (primoLEP.m_kine->Phi (),primoLEP.m_kine->Eta (), secondoLEP.m_kine->Phi (), secondoLEP.m_kine->Eta ()) ; TLorentzVector sumLEP = *(primoLEP.m_kine) + *(secondoLEP.m_kine) ; plots.v_LEPMinv = sumLEP.M () ; //---- AM 9 MInv_min of leptons plots.v_LEPProdCharge = first_lepton_charge * second_lepton_charge ; plots.v_hardLEPCharge = first_lepton_charge ; plots.v_softLEPCharge = second_lepton_charge ; //PG MET //PG --- // std::cerr << "--- finito " << std::endl; TLorentzVector* met = ((TLorentzVector*) (MET->At(0))) ; //correct for muons for (int i = 0 ; i < nMu ; i++) { TLorentzVector * mu_v = (TLorentzVector*) (muons->At (i)) ; if (mu_v->Pt () > 3) { met->SetPx (met->Px () - mu_v->Px ()) ; met->SetPy (met->Py () - mu_v->Py ()) ; } } plots.v_MET = met->Pt () ; //---- AM 11 Met_min ----------------> Met correction ? // if (((TLorentzVector*) (MET->At (0)))->Pt () < g_METMin) continue ; plots.increase (cutId++) ; //PG 10 //PG Ztautau vetos //PG ------------- //PG the two electrons should not be opposite to each other // // TVector2 primoLEPT (primoLEP.m_kine->X (), primoLEP.m_kine->Y ()) ; // TVector2 secondoLEPT (secondoLEP.m_kine->X (), secondoLEP.m_kine->Y ()) ; // TVector2 METT (met->X (), met->Y ()) ; // // double Sum = METT * primoLEPT + METT * secondoLEPT / (1 + primoLEPT * secondoLEPT) ; // double Dif = METT * primoLEPT - METT * secondoLEPT / (1 - primoLEPT * secondoLEPT) ; // // TVector2 METT1 = 0.5 * (Sum + Dif) * primoLEPT ; // TVector2 METT2 = 0.5 * (Sum - Dif) * secondoLEPT ; // // double ptNu1 = METT1.Mod () / cos (primoLEP.m_kine->Theta ()) ; // double ptNu2 = METT2.Mod () / cos (secondoLEP.m_kine->Theta ()) ; plots.m_tree_selections->Fill(); plots.passedJetAndLepNumberSelections++; if (plots.v_decay_Channel_e == 2) plots.passedJetAndLepNumberSelections_ee++; if (plots.v_decay_Channel_mu == 2) plots.passedJetAndLepNumberSelections_mumu++; if (plots.v_decay_Channel_tau == 2) plots.passedJetAndLepNumberSelections_tautau++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_mu == 1) plots.passedJetAndLepNumberSelections_emu++; if (plots.v_decay_Channel_e == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_etau++; if (plots.v_decay_Channel_mu == 1 && plots.v_decay_Channel_tau == 1) plots.passedJetAndLepNumberSelections_mutau++; } //PG loop over the events plots.m_efficiency->Fill(); plots.m_efficiency->Write(); plots.m_tree_selections->Write(); delete otherJets_temp ; delete tagJets ; delete otherJets ; delete electrons ; delete muons ; delete MET ; delete tracks ; return 0; }
int main (int argc, char** argv) { gROOT->SetStyle("Plain"); TChain * chain = new TChain ("EcalCosmicsAnalysis") ; chain->Add ("/afs/cern.ch/user/m/mattia/MuonTree_43439/MuonTree_43439_*.root") ; EcalCosmicsAnalysisVariables treeVars ; chain->SetBranchAddress ("runId", &treeVars.runId) ; chain->SetBranchAddress ("eventId", &treeVars.eventId) ; chain->SetBranchAddress ("timeStampLow", &treeVars.timeStampLow) ; chain->SetBranchAddress ("timeStampHigh", &treeVars.timeStampHigh) ; chain->SetBranchAddress ("isECALL1", &treeVars.isECALL1) ; chain->SetBranchAddress ("isHCALL1", &treeVars.isHCALL1) ; chain->SetBranchAddress ("isDTL1", &treeVars.isDTL1) ; chain->SetBranchAddress ("isRPCL1", &treeVars.isRPCL1) ; chain->SetBranchAddress ("isCSCL1", &treeVars.isCSCL1) ; chain->SetBranchAddress ("nCosmicsCluster", &treeVars.nCosmicsCluster) ; chain->SetBranchAddress ("cosmicClusterEnergy", treeVars.cosmicClusterEnergy) ; chain->SetBranchAddress ("cosmicClusterE1", treeVars.cosmicClusterE1) ; chain->SetBranchAddress ("cosmicClusterE2", treeVars.cosmicClusterE2) ; chain->SetBranchAddress ("cosmicClusterE9", treeVars.cosmicClusterE9) ; chain->SetBranchAddress ("cosmicClusterE25", treeVars.cosmicClusterE25) ; chain->SetBranchAddress ("cosmicClusterTime", treeVars.cosmicClusterTime) ; chain->SetBranchAddress ("cosmicClusterEta", treeVars.cosmicClusterEta) ; chain->SetBranchAddress ("cosmicClusterPhi", treeVars.cosmicClusterPhi) ; chain->SetBranchAddress ("cosmicClusterXtals", treeVars.cosmicClusterXtals) ; chain->SetBranchAddress ("cosmicClusterXtalsAbove3Sigma", treeVars.cosmicClusterXtalsAbove3Sigma) ; chain->SetBranchAddress ("cosmicClusterMaxId", treeVars.cosmicClusterMaxId) ; chain->SetBranchAddress ("cosmicCluster2ndId", treeVars.cosmicCluster2ndId) ; chain->SetBranchAddress ("nRecoMuons", &treeVars.nRecoMuons) ; chain->SetBranchAddress ("muonPt", treeVars.muonPt) ; chain->SetBranchAddress ("muonEta", treeVars.muonEta) ; chain->SetBranchAddress ("muonPhi", treeVars.muonPhi) ; chain->SetBranchAddress ("muonNChi2", treeVars.muonNChi2) ; chain->SetBranchAddress ("muonNDof", treeVars.muonNDof) ; chain->SetBranchAddress ("muonNHits", treeVars.muonNHits) ; chain->SetBranchAddress ("muonCharge", treeVars.muonCharge) ; chain->SetBranchAddress ("muonQOverP", treeVars.muonQOverP) ; chain->SetBranchAddress ("muond0", treeVars.muond0) ; chain->SetBranchAddress ("muondz", treeVars.muondz) ; chain->SetBranchAddress ("muonTkAtEcalEta", treeVars.muonTkAtEcalEta) ; chain->SetBranchAddress ("muonTkAtEcalPhi", treeVars.muonTkAtEcalPhi) ; chain->SetBranchAddress ("muonTkAtHcalEta", treeVars.muonTkAtHcalEta) ; chain->SetBranchAddress ("muonTkAtHcalPhi", treeVars.muonTkAtHcalPhi) ; chain->SetBranchAddress ("muonEcalEnergy3x3", treeVars.muonEcalEnergy3x3) ; chain->SetBranchAddress ("muonEcalEnergy5x5", treeVars.muonEcalEnergy5x5) ; chain->SetBranchAddress ("muonEcalEnergyCrossed", treeVars.muonEcalEnergyCrossed) ; chain->SetBranchAddress ("muonHcalEnergy3x3", treeVars.muonHcalEnergy3x3) ; chain->SetBranchAddress ("muonHcalEnergyCrossed", treeVars.muonHcalEnergyCrossed) ; chain->SetBranchAddress ("muonNCrossedEcalDetId", treeVars.muonNCrossedEcalDetId) ; chain->SetBranchAddress ("muonMaxEneEcalDetIdCrossed", treeVars.muonMaxEneEcalDetIdCrossed) ; chain->SetBranchAddress ("cosmicClusterEnergyXtals", treeVars.cosmicClusterEnergyXtals) ; chain->SetBranchAddress ("cosmicClusterLengthXtals_0", treeVars.cosmicClusterLengthXtals_0) ; chain->SetBranchAddress ("cosmicClusterLengthXtals_1", treeVars.cosmicClusterLengthXtals_1) ; TApplication *theApp = new TApplication( "app", &argc, argv ); //eta phi //TH2F Occupancy("Occupancy","Occupancy",170,-1.47,1.47,360,-3.14,3.14); TH2F Occupancy("Occupancy","Occupancy",170,-85.,85.,360,0.,360.); TH2F EnergyOnCrystals("EnergyOnCrystals","EnergyOnCrystals",170,-1.47,1.47,360,-3.14,3.14); TH2F MeanEnergy("MeanEnergy","MeanEnergy",170,-85.,85.,360,0.,360.); TH2F EoPCrystals("EoPCrystals","EoPCrystals",170,-1.47,1.47,360,-3.14,3.14); int nEvents = (int) chain->GetEntries () ; //PG loop over entries for (int iEvent = 0 ; iEvent < nEvents ; ++iEvent) //for (int iEvent = 0 ; iEvent < 1000000 ; ++iEvent) { if(iEvent%10000 == 0) std::cout << "event n. " << iEvent << std::endl; chain->GetEntry (iEvent) ; //base selections if (treeVars.nCosmicsCluster != 2) continue ; if(deltaPhi(treeVars.cosmicClusterPhi[0],treeVars.cosmicClusterPhi[1]) < 3.14159265358979 / 2./*90gradi*/) continue; //TAGLIO IN DELTAPHI EBDetId ciccio(treeVars.cosmicClusterMaxId); //SOSTITUIRE POSIZIONE Occupancy.Fill(ciccio.ieta(),ciccio.iphi()); //Occupancy.Fill(treeVars.cosmicClusterEta[0],treeVars.cosmicClusterPhi[0]); //Occupancy.Fill(treeVars.cosmicClusterEta[1],treeVars.cosmicClusterPhi[1]); EnergyOnCrystals.Fill(treeVars.cosmicClusterEta[0],treeVars.cosmicClusterPhi[0],treeVars.cosmicClusterE1[0]); EnergyOnCrystals.Fill(treeVars.cosmicClusterEta[1],treeVars.cosmicClusterPhi[1],treeVars.cosmicClusterE1[1]); //EoPCrystals.Fill(treeVars.cosmicClusterEta[0],treeVars.cosmicClusterPhi[0],enerTop/lunghTop); //EoPCrystals.Fill(treeVars.cosmicClusterEta[1],treeVars.cosmicClusterPhi[1],enerBot/lunghBot); } //PG loop over entries //MF loop over crystals double nOverCrystals = 0; //numero eventi per cristallo double EOverCrystals = 0; //energia x cristallo for(int indexeta = 0 ; indexeta < 170 ; indexeta++) // eta 170,-1.47,1.47, for(int indexphi = 0 ; indexphi < 360 ; indexphi++) // phi 360,-3.14,3.14 { nOverCrystals = Occupancy.GetBinContent(indexeta,indexphi); EOverCrystals = EnergyOnCrystals.GetBinContent(indexeta,indexphi); if(nOverCrystals==0) EOverCrystals = 0; MeanEnergy.Fill(-85+indexeta,indexphi,EOverCrystals/nOverCrystals); } //MF loop over crystals //Writing Histos TFile out ("Mappe.root","recreate") ; TDirectory* Rings = gDirectory->mkdir("Rings"); TDirectory* Slices = gDirectory->mkdir("Slices"); Occupancy.Write(); EnergyOnCrystals.Write(); EoPCrystals.Write(); MeanEnergy.Write(); return(0); }