double Rho0Omega::Getp( const double& mpipi ) const { const TLorentzVector p4pipi = (BW_BW::daughterP4(0)+BW_BW::daughterP4(1))*(1.0/GeV); const TLorentzVector p4init = _theDecay.getParent()->getVal().p(getEvent())*(1.0/GeV); const TLorentzVector p4rec = p4init-p4pipi; const double minit = p4init.M(); const double mrec = p4rec.M(); const double m2init = minit*minit; const double mpipi_p2_mrec = (mpipi + mrec)*(mpipi + mrec); const double mpipi_m2_mrec = (mpipi - mrec)*(mpipi - mrec); const double p = sqrt((m2init-mpipi_p2_mrec)*(m2init-mpipi_m2_mrec))/ (2.0*minit); if( (m2init-mpipi_p2_mrec)*(m2init-mpipi_m2_mrec) < 0.0 ){ std::cout << "p is negative. This should never happen." << std::endl; exit(1); } return p; }
// Takes as input a given process with corresponding luminosity, as well as sample CME, cuts, directory location, and output file name - saves corresponding histogram in root file. void processtree(TString sample, Double_t weight, TLorentzVector CME, TString filename, TString directory, TString param, TString cut, std::clock_t start, Int_t all){ //Open File TFile *f = new TFile(directory); TTree *ttree = (TTree*)f->Get(sample); TString recohistname, paramhistname; if (all==0){ recohistname = "_recoilmassHIST"; paramhistname = "_parameterHIST"; } if (all==1){ recohistname = "_recoilmassHIST_all"; paramhistname = "_parameterHIST_all"; } TString histname = sample + recohistname; TH1D *recoilmassHIST = new TH1D(histname,histname,CME.M()/2,0,CME.M()); //recoilmassHIST->SetCanExtend(kAllAxes); ttree->Project(histname, "recoilmass", cut); histname = sample + paramhistname; TH1D *parameterHIST = new TH1D(histname,histname,CME.M()/2,1,-1); //parameterHIST->SetCanExtend(kAllAxes); ttree->Project(histname, param, cut); //Normalize Hist recoilmassHIST->Scale(1/recoilmassHIST->GetMaximum()); parameterHIST->Scale(1/parameterHIST->GetMaximum()) ; //Normalize Hist // recoilmassHIST->Scale(weight); // parameterHIST->Scale(weight) ; // Writes yield of each histogram for each cut to text file ofstream myfile; Double_t yield = recoilmassHIST->Integral(); myfile.open ("yield.txt", ios::app); cout << "Yield for " << sample << " for Cut " << param << " is " << yield << endl; myfile << param << " " << all << " " << sample << " " << yield << "\n"; //write to file myfile.close(); if (recoilmassHIST->Integral() == 0){ recoilmassHIST->Fill(0); } if (parameterHIST->Integral() == 0){ parameterHIST->Fill(0); } TFile g(filename, "update"); recoilmassHIST->Write(); parameterHIST->Write(); g.Close(); }
void fillCorrectMassBin(TH1D* numhist[nMassBins], TLorentzVector sumVect, double phiSR, TH1D* polHist[nMassBins][nPhisrBins], double polarization, TH1D* massHist[nMassBins]){ for (int iMass = 0; iMass < nMassBins; iMass++) { if (sumVect.M() >= massBinStart[iMass] && sumVect.M() < massBinEnd[iMass]) { numhist[iMass]->Fill(phiSR); massHist[iMass]->Fill(sumVect.M()); int phiSRbin = numhist[iMass]->FindBin(phiSR); polHist[iMass][phiSRbin-1]->Fill(polarization); } } }
void smearEmEnergy( const EnergyScaleCorrection_class& egcor, TLorentzVector& p, const ZGTree& myTree, float r9 ) { float smearSigma = egcor.getSmearingSigma(myTree.run, fabs(p.Eta())<1.479, r9, p.Eta(), p.Pt(), 0., 0.); float cor = myRandom_.Gaus( 1., smearSigma ); p.SetPtEtaPhiM( p.Pt()*cor, p.Eta(), p.Phi(), p.M() ); }
void ToyEvent7::GenerateSignalKinematics(TRandom *rnd,Bool_t isData) { // fake decay of Z0 to two fermions double M0=91.1876; double Gamma=2.4952; // generated mass do { fMGen[2]=rnd->BreitWigner(M0,Gamma); } while(fMGen[2]<=0.0); double N_ETA=3.0; double MU_PT=5.; double SIGMA_PT=2.0; double DECAY_A=0.2; if(isData) { //N_ETA=2.5; MU_PT=6.; SIGMA_PT=1.8; //DECAY_A=0.5; } fEtaGen[2]=TMath::Power(rnd->Uniform(0,1.5),N_ETA); if(rnd->Uniform(-1.,1.)<0.) fEtaGen[2] *= -1.; fPhiGen[2]=rnd->Uniform(-M_PI,M_PI); do { fPtGen[2]=rnd->Landau(MU_PT,SIGMA_PT); } while((fPtGen[2]<=0.0)||(fPtGen[2]>500.)); //========================== decay TLorentzVector sum; sum.SetPtEtaPhiM(fPtGen[2],fEtaGen[2],fPhiGen[2],fMGen[2]); // boost into lab-frame TVector3 boost=sum.BoostVector(); // decay in rest-frame TLorentzVector p[3]; double m=MASS1; double costh; do { double r=rnd->Uniform(-1.,1.); costh=r*(1.+DECAY_A*r*r); } while(fabs(costh)>=1.0); double phi=rnd->Uniform(-M_PI,M_PI); double e=0.5*sum.M(); double ptot=TMath::Sqrt(e+m)*TMath::Sqrt(e-m); double pz=ptot*costh; double pt=TMath::Sqrt(ptot+pz)*TMath::Sqrt(ptot-pz); double px=pt*cos(phi); double py=pt*sin(phi); p[0].SetXYZT(px,py,pz,e); p[1].SetXYZT(-px,-py,-pz,e); for(int i=0;i<2;i++) { p[i].Boost(boost); } p[2]=p[0]+p[1]; for(int i=0;i<3;i++) { fPtGen[i]=p[i].Pt(); fEtaGen[i]=p[i].Eta(); fPhiGen[i]=p[i].Phi(); fMGen[i]=p[i].M(); } }
TLorentzVector smearMom(TLorentzVector const& b,TF1 const * const fMomResolution) { float const pt = b.Perp(); float const sPt = gRandom->Gaus(pt,pt*fMomResolution->Eval(pt)); TLorentzVector sMom; sMom.SetXYZM(sPt*cos(b.Phi()),sPt*sin(b.Phi()),sPt*sinh(b.PseudoRapidity()),b.M()); return sMom; }
double InvMass(double pt1, double eta1, double phi1, double m1, double pt2, double eta2, double phi2, double m2){ TLorentzVector vec1; TLorentzVector vec2; vec1.SetPtEtaPhiM(pt1, eta1, phi1, m1); vec2.SetPtEtaPhiM(pt2, eta2, phi2, m2); TLorentzVector Z = vec1 + vec2; return Z.M(); }
Double_t EventClassifier::ScoreEvent(struct WWScatteringComponents *event) { TLorentzVector *jetPair = new TLorentzVector(*event->positiveJet + *event->negativeJet); HadronicJetAbsEta = abs(event->hadronicJet->Eta()); HadronicJetPT = event->hadronicJet->Phi(); HadronicJetMass = event->hadronicJet->M(); MissingET = event->missingET->E(); Mjj = jetPair->M(); LeptonAbsEta = abs(event->lepton->Eta()); LeptonPT = event->lepton->Pt(); return reader->EvaluateMVA("LD"); }
//these can be done better, pass in a specific struct and populate that struct //could reduce these 6 calls into 1 or 2 void DalitzChiSq2::setap2(TLorentzVector vec){ ap2.v.SetXYZM(vec.Px(),vec.Py(),vec.Pz(),vec.M()); double Pt = TMath::Sqrt(vec.Px()*vec.Px() + vec.Py()*vec.Py()); double p = TMath::Sqrt(Pt*Pt + vec.Pz()*vec.Pz()); double thet = TMath::ACos(vec.Pz()/p); ap2.pt=Pt; ap2.theta=thet; ap2.x_m=1/Pt; }
void DalitzChiSq2::setp2(TLorentzVector vec){ p2.v.SetXYZM(vec.Px(),vec.Py(),vec.Pz(),vec.M()); double Pt = TMath::Sqrt(vec.Px()*vec.Px() + vec.Py()*vec.Py()); double p = TMath::Sqrt(Pt*Pt + vec.Pz()*vec.Pz()); double thet = TMath::ACos(vec.Pz()/p); p2.pt=Pt; p2.theta=thet; p2.x_m=1/Pt; //cout<<"electron : pt theta x1m : "<<Pt<<" "<<thet<<" "<<1/Pt<<endl; }
void Boost_To_Stop_Rest_Frame(TLorentzVector& stop4, TLorentzVector& chargino4, TLorentzVector& b4, TLorentzVector& neutralino4, TLorentzVector& W4, TLorentzVector& up4, TLorentzVector& down4, TLorentzVector& s4) { TVector3 betaV(-stop4.Px()/stop4.Energy(),-stop4.Py()/stop4.Energy(),-stop4.Pz()/stop4.Energy()); stop4.Boost(betaV); chargino4.Boost(betaV); b4.Boost(betaV); neutralino4.Boost(betaV); W4.Boost(betaV); up4.Boost(betaV); down4.Boost(betaV); s4.SetE(chargino4.P()/chargino4.M()); s4.SetVect(chargino4.Vect().Unit()*chargino4.Gamma()); }
Double_t ACAna::Minv(TLorentzVector *particle[],Int_t Number) { TLorentzVector *sparticle = new TLorentzVector(0,0,0,0); for (Int_t i=0;i<Number;++i) { //cout<<"Energie: "<< particle[i]->E()<<" i: "<<i<<endl; *sparticle += *(particle[i]); } Double_t Minv =sparticle->M(); delete sparticle; return Minv; //Double_t Minvsq = sE*sE - sPx*sPx - sPy*sPy- sPz*sPz; //return Minvsq >= 0. ? sqrt(Minvsq) : -sqrt(-Minvsq); }
void testTDime(Int_t nev = 100) { gSystem->Load("libEVGEN"); gSystem->Load("libTDime"); gSystem->Load("libdime"); TDime* dime = new TDime(); dime->SetEnergyCMS(7000.0); dime->SetYRange(-2.0, 2.0); // Set rapidity range of mesons dime->SetMinPt(0.1); // Minimum pT of mesons dime->Initialize(); // (pi+pi-) histograms TH1* hM = new TH1D("hM", "DIME #pi^{+}#pi^{-};M_{#pi^{+}#pi^{-}} #[]{GeV/#it{c}^{2}}", 100, 0.0, 5.0); TClonesArray* particles = new TClonesArray("TParticle", 6); TParticle* part = NULL; TLorentzVector v[2]; TLorentzVector vSum; // Event loop for (Int_t i = 0; i < nev; ++i) { dime->GenerateEvent(); Int_t np = dime->ImportParticles(particles, "All"); printf("\n DIME Event %d: Imported %3d particles \n", i, np); Int_t nPrimary = 0; // Loop over pion (j = 4,5) tracks for (Int_t j = 4; j < 6; ++j) { part = (TParticle*) particles->At(j); // Choose the particle part->Print(); part->Momentum(v[nPrimary]); // Copy content to v nPrimary++; } //particles.Clear(); // 4-vector sum vSum = v[0] + v[1]; // Fill pi+pi- histograms hM->Fill(vSum.M()); } // Save plots as pdf hM->Draw(); c1->SaveAs("massTDime.pdf"); }
float getMT(TLorentzVector pZ, TLorentzVector pH) { //take MET from pZ float myMET = pZ.Pt(); float myMETx = pZ.Px(); float myMETy = pZ.Py(); float Et = pH.Et(); float px = pH.Px(); float py = pH.Py(); float m = pH.M(); float MT = -99; float MT2 = m*m + 2*( Et * myMET - (px*myMETx + py*myMETy) ); if(MT2>0.) {MT=sqrt(MT2);} return MT; }
void smearEmEnergy( TLorentzVector& p ) { float smearEBlowEta = 0.013898; float smearEBhighEta = 0.0189895; float smearEElowEta = 0.027686; float smearEEhighEta = 0.031312; float theGaussMean = 1.; float pt = p.Pt(); float eta = p.Eta(); float phi = p.Phi(); float mass = p.M(); float theSmear = 0.; if (fabs(eta)<1. ) theSmear = smearEBlowEta; else if (fabs(eta)>=1. && fabs(eta)<1.5) theSmear = smearEBhighEta; else if (fabs(eta)>=1.5 && fabs(eta)<2. ) theSmear = smearEElowEta; else if (fabs(eta)>=2. && fabs(eta)<2.5) theSmear = smearEEhighEta; float fromGauss = myRandom_.Gaus(theGaussMean,theSmear); p.SetPtEtaPhiM( fromGauss*pt, eta, phi, mass ); // keep mass and direction same }
void DalitzChiSq2::setap3(TLorentzVector vec){ ap3.v.SetXYZM(vec.Px(),vec.Py(),vec.Pz(),vec.M()); //em & ep double cos12 = (ap1.v.Px()*ap2.v.Px() + ap1.v.Py()*ap2.v.Py() + ap1.v.Pz()*ap2.v.Pz())/(ap1.v.P()*ap2.v.P()); //em & gm double cos23 = (ap2.v.Px()*ap3.v.Px() + ap2.v.Py()*ap3.v.Py() + ap2.v.Pz()*ap3.v.Pz())/(ap3.v.P()*ap2.v.P()); //ep & gm double cos13 = (ap1.v.Px()*ap3.v.Px() + ap1.v.Py()*ap3.v.Py() + ap1.v.Pz()*ap3.v.Pz())/(ap1.v.P()*ap3.v.P()); double beta1 = ap1.v.P()/ap1.v.E(); double beta2 = ap2.v.P()/ap2.v.E(); double z12 = 2*((1/(beta1*beta2)) -cos12); double z23 = 2*((1/beta2)-cos23); double z13 = 2*((1/beta1)-cos13); double topterm = M*M - 2*m_e*m_e - ( z12/(TMath::Sin(ap1.theta) * TMath::Sin(ap2.theta) *ap1.x_m*ap2.x_m)); double bottomterm = ( (z13/(TMath::Sin(ap1.theta) * ap1.x_m)) + (z23/(TMath::Sin(ap2.theta) * ap2.x_m)) ); ap3.x_m=topterm/bottomterm; }
void ptLooper::doLoop() { for (int i = ievent_; i < max_entry; i++) { if (i % 100000 == 0) cout << i << " / " << max_entry << endl; tree->GetEntry(i); TLorentzVector muPN; muPN = *muonP_p4 + *muonN_p4; muPN_mass_h.Fill(muPN.M()); mass_h.Fill(dimuon_p4->M()); dimuonPt_h.Fill(dimuon_p4->Pt()); dimuonEta_h.Fill(dimuon_p4->Eta()); dimuonpteta_h.Fill(dimuon_p4->Eta(), dimuon_p4->Pt()); muonpteta_h.Fill(muonP_p4->Eta(), muonP_p4->Pt()); muonpteta_h.Fill(muonN_p4->Eta(), muonN_p4->Pt()); if (muonP_p4->Pt() > 4. && muonN_p4->Pt()>4.) { dimuonPt4_h.Fill(dimuon_p4->Pt()); dimuonEta4_h.Fill(dimuon_p4->Eta()); } if (simul_Jpsi_trigger(muonP_p4, muonN_p4, dimuon_p4)) { dimuonPtTriggered_h.Fill(dimuon_p4->Pt()); } } histos1D.push_back(dimuonPt_h); histos1D.push_back(dimuonPt4_h); histos1D.push_back(dimuonEta_h); histos1D.push_back(dimuonEta4_h); histos1D.push_back(muPN_mass_h); histos1D.push_back(mass_h); histos1D.push_back(dimuonPtTriggered_h); }
int xAna::HggTreeWriteLoop(const char* filename, int ijob, bool correctVertex, bool correctEnergy, bool setRho0 ) { //bool invDRtoTrk = false; if( _config == 0 ) { cout << " config file was not set properly... bail out" << endl; return -1; } if (fChain == 0) return -1; Long64_t nentries = fChain->GetEntriesFast(); // nentries = 10000; cout << "nentries: " << nentries << endl; Long64_t entry_start = ijob *_config->nEvtsPerJob(); Long64_t entry_stop = (ijob+1)*_config->nEvtsPerJob(); if( _config->nEvtsPerJob() < 0 ) { entry_stop = nentries; } if( entry_stop > nentries ) entry_stop = nentries; cout << " *** doing entries from: " << entry_start << " -> " << entry_stop << endl; if( entry_start > entry_stop ) return -1; EnergyScaleReader enScaleSkimEOS; /// skim EOS bugged so need to undo the energy scale in the skim EnergyScaleReader enScale; // enScaleSkimEOS.setup( "ecalCalibFiles/EnergyScale2012_Lisbon_9fb.txt" ); enScale.setup( _config->energyScaleFile() ); Float_t HiggsMCMass = _weight_manager->getCrossSection()->getHiggsMass(); Float_t HiggsMCPt = -1; bool isHiggsSignal = false; if( HiggsMCMass > 0 ) isHiggsSignal = true; mode_ = _weight_manager->getCrossSection()->mode(); isData = false; if(mode_==-1) isData = true; // mode_ = ijob; // DoCorrectVertex_ = correctVertex; DoCorrectEnergy_ = correctEnergy; DoSetRho0_ = setRho0; doJetRegression = _config->getDoJetRegression(); doControlSample = _config->getDoControlSample(); phoID_2011[0] = new TMVA::Reader("!Color:Silent"); phoID_2011[1] = new TMVA::Reader("!Color:Silent"); phoID_2012[0] = new TMVA::Reader("!Color:Silent"); phoID_2012[1] = new TMVA::Reader("!Color:Silent"); DiscriDiPho_2011 = new TMVA::Reader("!Color:Silent"); DiscriDiPho_2012 = new TMVA::Reader("!Color:Silent"); if(doJetRegression!=0) jetRegres = new TMVA::Reader("!Color:Silent"); Setup_MVA(); if( _config->setup() == "ReReco2011" ) for( int i = 0 ; i < 2; i++ ) phoID_mva[i] = phoID_2011[i]; else for( int i = 0 ; i < 2; i++ ) phoID_mva[i] = phoID_2012[i]; MassResolution massResoCalc; massResoCalc.addSmearingTerm(); if( _config->setup() == "ReReco2011" ) Ddipho_mva = DiscriDiPho_2011; else Ddipho_mva = DiscriDiPho_2012; float Ddipho_cat[5]; Ddipho_cat[4] = -1; if( _config->setup() == "ReReco2011" ) { Ddipho_cat[0] = 0.89; Ddipho_cat[1] = 0.72; Ddipho_cat[2] = 0.55; Ddipho_cat[3] = +0.05; } else { Ddipho_cat[0] = 0.91; Ddipho_cat[1] = 0.79; Ddipho_cat[2] = 0.49; Ddipho_cat[3] = -0.05; } // else { Ddipho_cat[0] = 0.88; Ddipho_cat[1] = 0.71; Ddipho_cat[2] = 0.50; Ddipho_cat[3] = -0.05; } DiscriVBF_UseDiPhoPt = true; DiscriVBF_UsePhoPt = true; DiscriVBF_cat.resize(2); DiscriVBF_cat[0] = 0.985; DiscriVBF_cat[1] = 0.93; DiscriVBF_useMvaSel = _config->doVBFmvaCat(); /// depending on the selection veto or not on electrons (can do muele, elemu,eleele) bool vetoElec[2] = {true,true}; if( _config->invertElectronVeto() ) { vetoElec[0] = false; vetoElec[1] = false; } if( _config->isEleGamma() ) { vetoElec[0] = false; vetoElec[1] = true ; } if( _config->isGammaEle() ) { vetoElec[0] = true ; vetoElec[1] = false; } cout << " --------- veto electron config -----------" << endl; cout << " Leading Pho VetoElec: " << vetoElec[0] << endl; cout << " Trailing Pho VetoElec: " << vetoElec[1] << endl; DoDebugEvent = true; bool DoPreselection = true; // bool DoPrint = true; TString VertexFileNamePrefix; TRandom3 *rnd = new TRandom3(); rnd->SetSeed(0); /// output tree and cross check file _xcheckTextFile.open(TString(filename)+".xcheck.txt"); // _xcheckTextFile = cout; _minitree = new MiniTree( filename ); TTree * tSkim = 0; if( _config->doSkimming() ) tSkim = (TTree*) fChain->CloneTree(0); InitHists(); _minitree->mc_wXsec = _weight_manager->xSecW(); _minitree->mc_wNgen = 100000./_weight_manager->getNevts(); if( isData ) { _minitree->mc_wXsec = 1; _minitree->mc_wNgen = 1; } Int_t isprompt0 = -1; Int_t isprompt1 = -1; set<Long64_t> syncEvt; cout <<" ================ mode " << mode_ <<" =============================== "<<endl; /// setupType has to be passed via config file // photonOverSmearing overSmearICHEP("Test52_ichep"); photonOverSmearing overSmearHCP( "oversmear_hcp2012" ); photonOverSmearing overSmear( _config->setup() ); int overSmearSyst = _config->getEnergyOverSmearingSyst(); Long64_t nbytes = 0, nb = 0; //////////////////////////////////////////////////////////////////////////// //////////////////////////// Start the loop //////////////////////////////// //////////////////////////////////////////////////////////////////////////// vector<int> nEvts; vector<string> nCutName; nCutName.push_back("TOTAL :"); nEvts.push_back(0); nCutName.push_back("2 gammas :"); nEvts.push_back(0); nCutName.push_back("triggers :"); nEvts.push_back(0); nCutName.push_back("nan weight :"); nEvts.push_back(0); nCutName.push_back("presel kin cuts:"); nEvts.push_back(0); nCutName.push_back("pass 2 gam incl:"); nEvts.push_back(0); nCutName.push_back("pass all :"); nEvts.push_back(0); nCutName.push_back(" --> pass 2 gam lep: "); nEvts.push_back(0); nCutName.push_back(" --> pass 2 gam vbf: "); nEvts.push_back(0); vector<int> selVtxSumPt2(3); selVtxSumPt2[0] = 0; selVtxSumPt2[1] = -1; selVtxSumPt2[2] = -1; for (Long64_t jentry=entry_start; jentry< entry_stop ; ++jentry) { Long64_t ientry = LoadTree(jentry); if (ientry < -9999) break; if( jentry % 10000 == 0) cout<<"processing event "<<jentry<<endl; nb = fChain->GetEntry(jentry); nbytes += nb; /// reset minitree variables _minitree->initEvent(); // study mc truth block if( !isData ) { fillMCtruthInfo_HiggsSignal(); _minitree->fillMCtrueOnly(); } /// reco analysis unsigned icutlevel = 0; nEvts[icutlevel++]++; if( nPho < 2 ) continue; nEvts[icutlevel++]++; /// set synchronisation flag if( syncEvt.find(event) != syncEvt.end() ) DoDebugEvent = true; else DoDebugEvent = false; if( DoDebugEvent ) _xcheckTextFile << "==========================================================" << endl; if( DoDebugEvent ) _xcheckTextFile << "================= debugging event: " << event << endl; /// PU & BSz reweightings if( !isData ) { int itpu = 1; /// 0 without OOT PU - 1 with OOT PU _minitree->mc_wPU = _weight_manager->puW( nPU[itpu] ); // PUwei = _weight_manager->puWTrue( puTrue[itpu] ); } hTotEvents->Fill(1,_minitree->mc_wPU); bool sigWH = false ; bool sigZH = false ; int mc_whzh_type = 0; _minitree->mc_wHQT = 1; if( isHiggsSignal ) { if ( _weight_manager->getCrossSection()->getMCType() == "vh" ) for( Int_t i=0; i < nMC && i <= 1; ++i ) { if( abs(mcPID[i]) == 24 ) sigWH=true; if( abs(mcPID[i]) == 23 ) sigZH=true; } if( sigWH ) mc_whzh_type = 1; if( sigZH ) mc_whzh_type = 2; for( Int_t i=0; i<nMC; ++i) if ( abs(mcPID[i]) == 25 ) HiggsMCPt = mcPt[i]; if( _weight_manager->getCrossSection()->getMCType() == "ggh" && _config->setup().find( "ReReco2011" ) != string::npos ) _minitree->mc_wHQT = getHqTWeight(HiggsMCMass, HiggsMCPt); } if ((mode_ == 2 || mode_ ==1 || mode_ == 18 || mode_ == 19) && processID==18) continue; // Remove double counting in gamma+jets and QCDjets Int_t mcIFSR_pho = 0; Int_t mcPartonic_pho = 0; if (mode_ == 1 || mode_ == 2 || mode_ == 3 || mode_ == 18 || mode_ == 19 ) { for (Int_t i=0; i<nMC; ++i) { if (mcPID[i] == 22 && (fabs(mcMomPID[i]) < 6 || mcMomPID[i] == 21)) mcIFSR_pho++; if (mcPID[i] == 22 && mcMomPID[i] == 22) mcPartonic_pho++; } } // if pythia is used for diphoton.. no IFSR removing from QCD and Gjets!!!!!! if ((mode_==1 || mode_ == 2 || mode_ == 18 ) && mcIFSR_pho >= 1 && mcPartonic_pho >=1) continue; if ((mode_ == 3 || mode_ == 19 )&& mcIFSR_pho == 2) continue; bool prompt2= false; bool prompt1= false; bool prompt0= false; vertProb = -1; if (mode_ == 2 || mode_ == 1 || mode_ == 18 ){ if ( mcPartonic_pho >= 1 && mcIFSR_pho >= 1 ) prompt2 = true; else if ( mcPartonic_pho >= 1 && mcIFSR_pho == 0 ) prompt1 = true; else if ( mcPartonic_pho == 0 && mcIFSR_pho == 0 ) prompt0 = true; } else if(mode_ == 3 || mode_ == 19 ){ if ( mcIFSR_pho >= 2 ) prompt2 = true; else if ( mcIFSR_pho == 1 ) prompt1 = true; else if ( mcIFSR_pho == 0 ) prompt0 = true; if( prompt1 ) _minitree->mc_wXsec = 1.3*_weight_manager->xSecW(); } if(mode_==1 || mode_==2 || mode_==3 || mode_==18 || mode_==19){ if(prompt0)isprompt0=1; else isprompt0=0; if(prompt1)isprompt1=1; else isprompt1=0; } if( mode_ == 20 && isZgamma() ) continue; /// wei weight is just temporary and may not contain all info. float wei = _minitree->mc_wXsec * _minitree->mc_wPU * _minitree->mc_wNgen * _minitree->mc_wHQT; if( isData && !PassTriggerSelection() ) continue; nEvts[icutlevel++]++; if( std::isinf( wei ) || std::isnan( wei ) )continue; nEvts[icutlevel++]++; //// ********************* define S4 variable **********************//// for( int i=0; i<nPho; ++i){ if( _config->setup() == "ReReco2011" ) phoS4ratio[i] = 1; else phoS4ratio[i] = phoE2x2[i] / phoE5x5[i]; } //// ************************************************************* //// if( !isData ) { //// ************** MC corrections (mostly MC) ******************* //// // 1. energy shifting / smearing for( int i=0; i<nPho; ++i) if( fabs(phoSCEta[i]) <= 2.5 ) { float smearing = overSmear.randOverSmearing(phoSCEta[i],phoR9[i],isInGAP_EB(i),overSmearSyst); phoRegrE[i] *= (1 + smearing); phoE[i] *= (1 + smearing); /// from MassFactorized in gglobe: energyCorrectedError[ipho] *=(l.pho_isEB[ipho]) ? 1.07 : 1.045 ; float smearFactor = 1; if( _config->setup() == "ReReco2011" ) smearFactor = fabs(phoSCEta[i]) < 1.45 ? 1.07: 1.045; phoRegrErr[i] *= smearFactor; } // 2. reweighting of photon id variables (R9...) for (int i=0; i<nPho; ++i) ReweightMC_phoIdVar(i); //// ************************************************************* //// } //// ********** Apply regression energy ************* //// float phoStdE[500]; for( int i=0; i<nPho; ++i) if( fabs(phoSCEta[i]) <= 2.5 ) { if( isData ){ float enCorrSkim = 1;//enScaleSkimEOS.energyScale( phoR9[i], phoSCEta[i], run); float phoEnScale = enScale.energyScale( phoR9[i], phoSCEta[i], run)/enCorrSkim; phoRegrE[i] *= phoEnScale; phoE[i] *= phoEnScale; } phoStdE[i] = phoE[i]; phoE[i] = phoRegrE[i]; /// transform calo position abd etaVtx, phiVtx with SC position for( int x = 0 ; x < 3; x++ ) phoCaloPos[i][x] = phoSCPos[i][x]; for( int ivtx = 0 ; ivtx < nVtxBS; ivtx++ ) { TVector3 xxi = getCorPhotonTVector3(i,ivtx); phoEtaVtx[i][ivtx] = xxi.Eta(); phoPhiVtx[i][ivtx] = xxi.Phi(); } /// additionnal smearing to go to data energy resolution phoRegrSmear[i] = phoE[i]*overSmearHCP.meanOverSmearing(phoSCEta[i],phoR9[i],isInGAP_EB(i),0); phoEt[i] = phoE[i] / cosh(phoEta[i]); } //// ************************************************* //// /// lepton selection int iElecVtx(-1), iMuonVtx(-1); vector<int> elecIndex = selectElectronsHCP2012( wei, iElecVtx ); vector<int> muonIndex = selectMuonsHCP2012( wei, iMuonVtx ); vector<int> event_vtx; vector<int> event_ilead ; vector<int> event_itrail; vector<TLorentzVector> event_plead ; vector<TLorentzVector> event_ptrail; TLorentzVector leptag; int lepCat = -1; bool exitLoop = false; for( int ii = 0 ; ii < nPho ; ++ii ) { for( int jj = (ii+1); jj < nPho ; ++jj ) { // Preselection 2nd leg if (DoPreselection && !preselectPhoton(ii,phoEt[ii])) continue; if (DoPreselection && !preselectPhoton(jj,phoEt[jj])) continue; /// define i, j locally, so when they are inverted this does not mess up the loop int i = ii; int j = jj; if(phoEt[j] > phoEt[i]){ i = jj; j = ii; } // Select vertex int selVtx = 0; TLorentzVector gi,gj; double mij(-1); vector<int> selVtxIncl; if(_config->vtxSelType()==0) selVtxIncl = getSelectedVertex(i,j,true,true ); else //use sumpt2 ranking selVtxIncl = selVtxSumPt2; selVtx = selVtxIncl[0]; if( selVtx < 0 ) continue; /// check lepton tag if( muonIndex.size() > 0 ) { //selVtx = iMuonVtx; leptag.SetPtEtaPhiM( muPt[muonIndex[0]], muEta[muonIndex[0]], muPhi[muonIndex[0]],0); if( selectTwoPhotons(i,j,selVtx,gi,gj,vetoElec) ) { lepCat = 0; } } /// check electron tag only if muon tag failed if( elecIndex.size() > 0 && lepCat == -1 ) { //selVtx = iElecVtx; leptag.SetPtEtaPhiM( elePt[elecIndex[0]], eleEta[elecIndex[0]], elePhi[elecIndex[0]],0); if( selectTwoPhotons(i,j,selVtx,gi,gj,vetoElec) ) { lepCat = 1; if( fabs( (leptag+gi).M() - 91.19 ) < 10 || fabs( (leptag+gj).M() - 91.19 ) < 10 ) lepCat = -1; /// this is not actually the cut, but it should be but ok (dR(pho,eleTrk) > 1 no dR(pho,anyTrk) > 1 ) if(phoCiCdRtoTrk[i] < 1 || phoCiCdRtoTrk[j] <1 ) lepCat = -1; } } if( lepCat >= 0 ) { mij = (gi+gj).M(); if( _config->analysisType() == "MVA" ) if( gi.Pt() / mij < 45./120. || gj.Pt() / mij < 30./120. ) lepCat = -1; if( _config->analysisType() == "baselineCiC4PF" ) if( gi.Pt() / mij < 45./120. || gj.Pt() < 25. ) lepCat = -1; if( leptag.DeltaR(gi) < 1.0 || leptag.DeltaR(gj) < 1.0 ) lepCat = -1; } if( lepCat >= 0 ) { cout << " ****** keep leptag event pts[photons] i: " << i << " j: " << j << " -> event: " << ientry << endl; cout << " leptonCat: " << lepCat << endl; /// if one pair passes lepton tag then no need to go further /// fill in variables event_vtx.resize( 1); event_vtx[0] = selVtx; event_ilead.resize( 1); event_ilead[0] = i; event_itrail.resize(1); event_itrail[0] = j; event_plead.resize( 1); event_plead[0] = gi; event_ptrail.resize(1); event_ptrail[0] = gj; exitLoop = true; break; } else { /// inclusive + VBF + MetTag preselection /// apply kinematic cuts if( !selectTwoPhotons(i,j,selVtx,gi,gj,vetoElec) ) continue; /// drop photon pt cuts from inclusive cuts (add them in categorisation only) mij = (gi+gj).M(); if( ! _config->doSkimming() && ( gi.Pt() < _config->pt1Cut() || gi.Pt() < _config->pt2Cut() || gi.Pt()/mij < _config->loosePt1MCut() || gj.Pt()/mij < _config->loosePt2MCut() ) ) continue; } /// here i = lead; j = trail (selectTwoPhotons does that) /// fill in variables event_vtx.push_back( selVtx ); event_ilead.push_back( i ); event_itrail.push_back( j ); event_plead.push_back( gi ); event_ptrail.push_back( gj ); } if( exitLoop ) break; } if(event_ilead.size()==0 || event_itrail.size()==0)continue; if(event_vtx.size() == 0 ) continue; // no pairs selected nEvts[icutlevel++]++; // Now decide which photon-photon pair in the event to select // for lepton tag (size of arrays is 1, so dummy selection) unsigned int selectedPair = 0; float sumEt = -1; for (unsigned int p=0; p < event_vtx.size(); p++) { float tempSumEt = event_plead[p].Pt() + event_ptrail[p].Pt(); if( tempSumEt > sumEt) { sumEt = tempSumEt; selectedPair = p; } } int ilead = event_ilead[ selectedPair ]; int itrail = event_itrail[ selectedPair ]; int selVtx = event_vtx[ selectedPair ]; TLorentzVector glead = event_plead[selectedPair]; TLorentzVector gtrail = event_ptrail[selectedPair]; TLorentzVector hcand = glead + gtrail; int CAT4 = cat4(phoR9[ilead], phoR9[itrail], phoSCEta[ilead], phoSCEta[itrail]); if( glead.Pt() < _config->pt1Cut() ) continue; if( gtrail.Pt() < _config->pt2Cut() ) continue; if( hcand.M() < _config->mggCut() ) continue; nEvts[icutlevel++]++; _minitree->mtree_runNum = run; _minitree->mtree_evtNum = event; _minitree->mtree_lumiSec = lumis; // TLorentzVector g1,g2; // g1.SetPtEtaPhiM(phoE[ilead ]/cosh(phoEta[ilead]),phoEta[ilead ], phoPhi[ilead ], 0); // g2.SetPtEtaPhiM(phoE[itrail]/cosh(phoEta[ilead]),phoEta[itrail], phoPhi[itrail], 0); // TLorentzVector lgg = g1 + g2; //_minitree->mtree_massDefVtx = lgg.M(); _minitree->mtree_massDefVtx = hcand.M()/sqrt(phoE[ilead]*phoE[itrail])*sqrt(phoStdE[ilead]*phoStdE[itrail]); // calc again vertex to get correct vertex probability (can be different from last one in loop) vector<int> sortedVertex; if(_config->vtxSelType()==0) sortedVertex = getSelectedVertex( ilead, itrail, true, true ); else //use sumpt2 ranking sortedVertex = selVtxSumPt2; if( sortedVertex.size() < 2 ) sortedVertex.push_back(-1); if( sortedVertex.size() < 3 ) sortedVertex.push_back(-1); if( lepCat >= 0 ) { /// lepton tag sortedVertex[0] = selVtx; sortedVertex[1] = -1; sortedVertex[2] = -1; // vertProb = 1; } _minitree->mtree_rho = rho2012; _minitree->mtree_rho25 = rho25; _minitree->mtree_zVtx = vtxbs[selVtx][2]; _minitree->mtree_nVtx = nVtxBS; _minitree->mtree_ivtx1 = selVtx; _minitree->mtree_ivtx2 = sortedVertex[1]; _minitree->mtree_ivtx3 = sortedVertex[2]; _minitree->mtree_vtxProb = vertProb; _minitree->mtree_vtxMva = vertMVA; _minitree->mtree_mass = hcand.M(); _minitree->mtree_pt = hcand.Pt(); _minitree->mtree_piT = hcand.Pt()/hcand.M(); _minitree->mtree_y = hcand.Rapidity(); /// spin variables TLorentzVector gtmp1 = glead; gtmp1.Boost( -hcand.BoostVector() ); TLorentzVector gtmp2 = gtrail; gtmp2.Boost( -hcand.BoostVector() ); _minitree->mtree_cThetaLead_heli = cos( gtmp1.Angle(hcand.BoostVector()) ); _minitree->mtree_cThetaTrail_heli = cos( gtmp2.Angle(hcand.BoostVector()) ); _minitree->mtree_cThetaStar_CS = 2*(glead.E()*gtrail.Pz() - gtrail.E()*glead.Pz())/(hcand.M()*sqrt(hcand.M2()+hcand.Pt()*hcand.Pt())); /// fill photon id variables in main tree _minitree->mtree_minR9 = +999; _minitree->mtree_minPhoIdEB = +999; _minitree->mtree_minPhoIdEE = +999; _minitree->mtree_maxSCEta = -1; _minitree->mtree_minSCEta = +999; for( int i = 0 ; i < 2; i++ ) { int ipho = -1; if( i == 0 ) ipho = ilead; if( i == 1 ) ipho = itrail; fillPhotonVariablesToMiniTree( ipho, selVtx, i ); if( _minitree->mtree_r9[i] < _minitree->mtree_minR9 ) _minitree->mtree_minR9 = _minitree->mtree_r9[i]; if( fabs( _minitree->mtree_sceta[i] ) < 1.5 && _minitree->mtree_mvaid[i] < _minitree->mtree_minPhoIdEB ) _minitree->mtree_minPhoIdEB = _minitree->mtree_mvaid[i]; if( fabs( _minitree->mtree_sceta[i] ) >= 1.5 && _minitree->mtree_mvaid[i] < _minitree->mtree_minPhoIdEE ) _minitree->mtree_minPhoIdEE = _minitree->mtree_mvaid[i]; if( fabs( _minitree->mtree_sceta[i] ) > _minitree->mtree_maxSCEta ) _minitree->mtree_maxSCEta = fabs(_minitree->mtree_sceta[i]); if( fabs( _minitree->mtree_sceta[i] ) < _minitree->mtree_minSCEta ) _minitree->mtree_minSCEta = fabs(_minitree->mtree_sceta[i]); } //------------ compute diphoton mva (add var to minitree inside function) ----------------// massResoCalc.setP4CalPosVtxResoSmear( glead,gtrail, TVector3(phoCaloPos[ilead ][0], phoCaloPos[ilead ][1],phoCaloPos[ilead ][2]), TVector3(phoCaloPos[itrail][0], phoCaloPos[itrail][1],phoCaloPos[itrail][2]), TVector3(vtxbs[selVtx][0], vtxbs[selVtx][1], vtxbs[selVtx][2]), _minitree->mtree_relResOverE, _minitree->mtree_relSmearing ); _minitree->mtree_massResoTot = massResoCalc.relativeMassResolutionFab_total( vertProb ); _minitree->mtree_massResoEng = massResoCalc.relativeMassResolutionFab_energy( ); _minitree->mtree_massResoAng = massResoCalc.relativeMassResolutionFab_angular(); float diphotonmva = DiPhoID_MVA( glead, gtrail, hcand, massResoCalc, vertProb, _minitree->mtree_mvaid[0],_minitree->mtree_mvaid[1] ); // ---- Start categorisation ---- // _minitree->mtree_lepTag = 0; _minitree->mtree_metTag = 0; _minitree->mtree_vbfTag = 0; _minitree->mtree_hvjjTag = 0; // 1. lepton tag if( lepCat >= 0 ) { _minitree->mtree_lepTag = 1; _minitree->mtree_lepCat = lepCat; _minitree->mtree_fillLepTree = true; // if( lepCat == 0 ) fillMuonTagVariables(lepTag,glead,gtrail,elecIndex[0],selVtx); // if( lepCat == 1 ) fillElecTagVariables(lepTag,glead,gtrail,muonIndex[0],selVtx); } // 3. met tag (For the jet energy regression, MET needs to be corrected first.) _minitree->mtree_rawMet = recoPfMET; _minitree->mtree_rawMetPhi = recoPfMETPhi; // if( !isData ) { /// bug in data skim, met correction already applied //3.1 Soft Jet correction (FC?) applyJEC4SoftJets(); //3.2 smearing if( !isData ) METSmearCorrection(ilead, itrail); //3.3 shifting (even in data? but different in data and MC) METPhiShiftCorrection(); //3.4 scaling if( isData) METScaleCorrection(ilead, itrail); // } _minitree->mtree_corMet = recoPfMET; _minitree->mtree_corMetPhi = recoPfMETPhi; // 2. dijet tag Int_t nVtxJetID = -1; if( _config->doPUJetID() ) nVtxJetID = nVtxBS; //vector<int> goodJetsIndex = selectJets( ilead, itrail, nVtxJetID, wei, selVtx ); vector<int> goodJetsIndex = selectJetsJEC( ilead, itrail, nVtxJetID, wei, selVtx ); int vbftag(-1),hstratag(-1),catjet(-1); dijetSelection( glead, gtrail, goodJetsIndex, wei, selVtx, vbftag, hstratag, catjet); _minitree->mtree_vbfTag = vbftag; _minitree->mtree_hvjjTag = hstratag; _minitree->mtree_vbfCat = catjet; // 2x. radion analysis // take the very same photon candidates as in the H->GG analysis above _minitree->radion_evtNum = event; *(_minitree->radion_gamma1) = glead; *(_minitree->radion_gamma2) = gtrail; vector<int> goodJetsIndexRadion = selectJetsRadion(nVtxJetID, selVtx); _minitree->radion_bJetTags->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_genJetPt ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_eta ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_cef ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_nef ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_mef ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_nconstituents ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_chf ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_JECUnc ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_ptLeadTrack ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_vtxPt ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_vtx3dL ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_SoftLeptPtCut ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_dPhiMETJet ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_nch ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_vtx3deL ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_vtxMass ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_ptRaw ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_EnRaw ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_SoftLeptptRelCut->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_SoftLeptdRCut ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_partonID ->Set(goodJetsIndexRadion.size()); _minitree->radion_jet_dRJetGenJet ->Set(goodJetsIndexRadion.size()); _minitree->radion_MET = recoPfMET; _minitree->radion_rho25 = rho25; for (unsigned i = 0; i < goodJetsIndexRadion.size(); i++) { int iJet = goodJetsIndexRadion[i]; //_minitree->radion_bJetTags->AddAt(jetCombinedSecondaryVtxMVABJetTags[iJet], i); _minitree->radion_bJetTags->AddAt(jetCombinedSecondaryVtxBJetTags[iJet], i); _minitree->radion_jet_genJetPt ->AddAt(jetGenJetPt[iJet], i); _minitree->radion_jet_eta ->AddAt(jetEta[iJet], i); _minitree->radion_jet_cef ->AddAt(jetCEF[iJet], i); _minitree->radion_jet_nef ->AddAt(jetNEF[iJet], i); _minitree->radion_jet_mef ->AddAt(jetMEF[iJet], i); _minitree->radion_jet_nconstituents ->AddAt(jetNConstituents[iJet], i); _minitree->radion_jet_chf ->AddAt(jetCHF[iJet], i); _minitree->radion_jet_JECUnc ->AddAt(jetJECUnc[iJet], i); _minitree->radion_jet_ptLeadTrack ->AddAt(jetLeadTrackPt[iJet], i); _minitree->radion_jet_vtxPt ->AddAt(jetVtxPt[iJet], i); _minitree->radion_jet_vtx3dL ->AddAt(jetVtx3dL[iJet], i); _minitree->radion_jet_SoftLeptPtCut ->AddAt(jetSoftLeptPt[iJet], i); _minitree->radion_jet_nch ->AddAt(jetNCH[iJet], i); _minitree->radion_jet_vtx3deL ->AddAt(jetVtx3deL[iJet], i); _minitree->radion_jet_vtxMass ->AddAt(jetVtxMass[iJet], i); _minitree->radion_jet_ptRaw ->AddAt(jetRawPt[iJet], i); _minitree->radion_jet_EnRaw ->AddAt(jetRawEn[iJet], i); _minitree->radion_jet_SoftLeptptRelCut ->AddAt(jetSoftLeptPtRel[iJet], i); _minitree->radion_jet_SoftLeptdRCut ->AddAt(jetSoftLeptdR[iJet], i); _minitree->radion_jet_partonID ->AddAt(jetPartonID[iJet], i); _minitree->radion_jet_dRJetGenJet ->AddAt(sqrt(pow(jetEta[iJet]-jetGenEta[iJet],2)+pow(jetPhi[iJet]-jetGenPhi[iJet],2)), i); float tmpPi = 3.1415927, tmpDPhi=fabs(jetPhi[iJet]-recoPfMETPhi); if(tmpDPhi>tmpPi) tmpDPhi=2*tmpPi-tmpDPhi; _minitree->radion_jet_dPhiMETJet ->AddAt(tmpDPhi, i); TLorentzVector* jet = new((*(_minitree->radion_jets))[_minitree->radion_jets->GetEntriesFast()]) TLorentzVector(); jet->SetPtEtaPhiE(jetPt[iJet], jetEta[iJet], jetPhi[iJet], jetEn[iJet]); } // Continue step 3. if ( MetTagSelection(glead,gtrail,goodJetsIndex) && _minitree->mtree_vbfTag == 0 && _minitree->mtree_lepTag == 0 && _minitree->mtree_corMet > 70. && fabs( phoSCEta[ilead] ) < 1.45 && fabs( phoSCEta[itrail]) < 1.45 ) _minitree->mtree_metTag = 1; //----------- categorisation (for now incl + vbf + lep + met) -----------// _minitree->mtree_catBase = CAT4; _minitree->mtree_catMva = -1; for( int icat_mva = 0 ; icat_mva < 4; icat_mva++ ) if( diphotonmva >= Ddipho_cat[icat_mva] ) { _minitree->mtree_catMva = icat_mva; break; } if ( _minitree->mtree_lepTag == 1 ) { _minitree->mtree_catBase = _minitree->mtree_lepCat + 6; _minitree->mtree_catMva = _minitree->mtree_lepCat + 6; } else if( _minitree->mtree_vbfTag == 1 ) { _minitree->mtree_catBase = _minitree->mtree_vbfCat + 4; _minitree->mtree_catMva = _minitree->mtree_vbfCat + 4; } else if( _minitree->mtree_metTag == 1 ) { _minitree->mtree_catBase = 8; _minitree->mtree_catMva = 8; } if( diphotonmva < Ddipho_cat[3] ) _minitree->mtree_catMva = -1; /// photon pt cut was dropped from the inclusive cuts if( _minitree->mtree_catMva < 4 && (glead.Pt()/hcand.M() < 1./3. || gtrail.Pt()/hcand.M() < 1./4.) ) _minitree->mtree_catMva = -1; if( _minitree->mtree_catBase < 4 && (glead.Pt()/hcand.M() < 1./3. || gtrail.Pt()/hcand.M() < 1./4.) ) _minitree->mtree_catBase = -1; //------------ MC weighting factors and corrections if( !isData ) { /// needs to be recomputed for each event (because reinit var for each event) _minitree->mc_wNgen = 100000./_weight_manager->getNevts(); _minitree->mc_wXsec = _weight_manager->xSecW(mc_whzh_type); if( ( mode_ == 3 || mode_ == 19 ) && isprompt1 == 1 ) _minitree->mc_wXsec *= 1.3; _minitree->mc_wBSz = _weight_manager->bszW(vtxbs[selVtx][2]-mcVtx[0][2]); _minitree->mc_wVtxId = _weight_manager->vtxPtCorrW( hcand.Pt() ); /// photon identification float wPhoId[] = { 1., 1.}; for( int i = 0 ; i < 2; i++ ) { wPhoId[i] = 1; int index = -1; if( i == 0 ) index = ilead; if( i == 1 ) index = itrail; wPhoId[i] *= _weight_manager->phoIdPresel(phoR9[index],phoSCEta[index]); if( _config->analysisType() == "baselineCiC4PF" ) wPhoId[i] *= _weight_manager->phoIdCiC(phoR9[index],phoSCEta[index]); if( _config->analysisType() == "MVA" ) wPhoId[i] *= _weight_manager->phoIdMVA(phoR9[index],phoSCEta[index]); if( vetoElec[i] ) wPhoId[i] *= _weight_manager->phoIdEleVeto(phoR9[index],phoSCEta[index]); } _minitree->mc_wPhoEffi = wPhoId[0]*wPhoId[1]; /// trigger efficiency _minitree->mc_wTrigEffi = 0.9968; /// FIX ME /// cross section volontary not included in total weight _minitree->mc_wei = _minitree->mc_wPU * _minitree->mc_wBSz * _minitree->mc_wHQT * /// = 1 but in 2011 _minitree->mc_wVtxId * _minitree->mc_wPhoEffi * _minitree->mc_wTrigEffi * _minitree->mc_wNgen; wei = _minitree->mc_wei; } nEvts[icutlevel++]++; if( _minitree->mtree_lepTag ) nEvts[icutlevel+0]++; if( _minitree->mtree_vbfTag ) nEvts[icutlevel+1]++; //// following crap can be removed when the synchornization will be successfull. if( DoDebugEvent ) { _minitree->setSynchVariables(); _xcheckTextFile << " pho1 pos: " << phoPos[ilead] << endl; _xcheckTextFile << " ieta1 : " << phoSeedDetId1[ilead] << " iphi1: " << phoSeedDetId2[ilead] << endl; _xcheckTextFile << " pho2 pos: " << phoPos[itrail] << endl; _xcheckTextFile << " ieta1 : " << phoSeedDetId1[itrail] << " iphi1: " << phoSeedDetId2[itrail] << endl; _xcheckTextFile << " oversmear 1: " << overSmear.meanOverSmearing(phoSCEta[ilead],phoR9[ilead] ,isInGAP_EB(ilead),0) << endl; _xcheckTextFile << " oversmear 2: " << overSmear.meanOverSmearing(phoSCEta[itrail],phoR9[itrail],isInGAP_EB(itrail),0) << endl; _xcheckTextFile << " mass reso (eng only): " << _minitree->mtree_massResoEng << endl; _xcheckTextFile << " mass reso (ang only): " << _minitree->mtree_massResoAng << endl; for( unsigned i = 0 ; i < _minitree->sync_iName.size(); i++ ) cout << _minitree->sync_iName[i] << ":" << *_minitree->sync_iVal[i] << " "; for( unsigned i = 0 ; i < _minitree->sync_lName.size(); i++ ) cout << _minitree->sync_lName[i] << ":" << *_minitree->sync_lVal[i] << " "; for( unsigned i = 0 ; i < _minitree->sync_fName.size(); i++ ) cout << _minitree->sync_fName[i] << ":" << *_minitree->sync_fVal[i] << " "; cout << endl; cout << " myVtx = " << selVtx << "; 1=" << sortedVertex[1] << " 2= " << sortedVertex[2] << endl; for( int ivtx = 0; ivtx < nVtxBS; ivtx++ ) { cout << " etas[ ivtx = " << ivtx << "] = " << phoEtaVtx[ilead][ivtx] << " - " << phoEtaVtx[itrail][ivtx] << " - zVtx = " << vtxbs[ivtx][2] << endl; } } _minitree->fill(); if( _config->doSkimming() && tSkim ) { /// undo all modifs before filling the skim fChain->GetEntry(jentry); tSkim->Fill(); } //--------------- // } }// end for entry if( _config->doSkimming() ) { _minitree->mtree_file->cd(); TH1F *hEvents = new TH1F("hEvents","hEvents",2,0,2); hEvents->SetBinContent(1,_weight_manager->getNevts()); hEvents->SetBinContent(2,nEvts[nEvts.size()-1]); hEvents->Write(); tSkim->Write(); _minitree->mtree_file->Close(); } else _minitree->end(); for( unsigned icut = 0 ; icut < nEvts.size(); icut++ ) cout << nCutName[icut] << nEvts[icut] << endl; delete rnd; return nEvts[nEvts.size()-1]; }
void fill(int const kf, TLorentzVector* b, double weight, TLorentzVector const& p1Mom, TLorentzVector const& p2Mom, TVector3 v00) { int const centrality = floor(nCent * gRandom->Rndm()); TVector3 const vertex = getVertex(centrality); // smear primary vertex // float const sigmaVertex = sigmaVertexCent[cent]; // TVector3 const vertex(gRandom->Gaus(0, sigmaVertex), gRandom->Gaus(0, sigmaVertex), gRandom->Gaus(0, sigmaVertex)); v00 += vertex; // smear momentum TLorentzVector const p1RMom = smearMom(0, p1Mom); TLorentzVector const p2RMom = smearMom(0, p2Mom); // smear position TVector3 const p1RPos = smearPosData(0, vertex.z(), centrality, p1RMom, v00); TVector3 const p2RPos = smearPosData(0, vertex.z(), centrality, p2RMom, v00); // TVector3 const kRPos = smearPos(kMom, kRMom, v00); // TVector3 const pRPos = smearPos(pMom, pRMom, v00); // reconstruct TLorentzVector const rMom = p1RMom + p2RMom; float const p1Dca = dca(p1Mom.Vect(), v00, vertex); float const p2Dca = dca(p2Mom.Vect(), v00, vertex); float const p1RDca = dca(p1RMom.Vect(), p1RPos, vertex); float const p2RDca = dca(p2RMom.Vect(), p2RPos, vertex); TVector3 v0; float const dca12 = dca1To2(p1RMom.Vect(), p1RPos, p2RMom.Vect(), p2RPos, v0); float const decayLength = (v0 - vertex).Mag(); float const dcaD0ToPv = dca(rMom.Vect(), v0, vertex); float const cosTheta = (v0 - vertex).Unit().Dot(rMom.Vect().Unit()); float const angle12 = p1RMom.Vect().Angle(p2RMom.Vect()); TLorentzVector p1RMomRest = p1RMom; TVector3 beta; beta.SetMagThetaPhi(rMom.Beta(), rMom.Theta(), rMom.Phi()); p1RMomRest.Boost(-beta); float const cosThetaStar = rMom.Vect().Unit().Dot(p1RMomRest.Vect().Unit()); // save float arr[100]; int iArr = 0; arr[iArr++] = centrality; arr[iArr++] = vertex.X(); arr[iArr++] = vertex.Y(); arr[iArr++] = vertex.Z(); arr[iArr++] = kf; arr[iArr++] = b->M(); arr[iArr++] = b->Perp(); arr[iArr++] = b->PseudoRapidity(); arr[iArr++] = b->Rapidity(); arr[iArr++] = b->Phi(); arr[iArr++] = v00.X(); arr[iArr++] = v00.Y(); arr[iArr++] = v00.Z(); arr[iArr++] = rMom.M(); arr[iArr++] = rMom.Perp(); arr[iArr++] = rMom.PseudoRapidity(); arr[iArr++] = rMom.Rapidity(); arr[iArr++] = rMom.Phi(); arr[iArr++] = v0.X(); arr[iArr++] = v0.Y(); arr[iArr++] = v0.Z(); arr[iArr++] = dca12; arr[iArr++] = decayLength; arr[iArr++] = dcaD0ToPv; arr[iArr++] = cosTheta; arr[iArr++] = angle12; arr[iArr++] = cosThetaStar; arr[iArr++] = p1Mom.M(); arr[iArr++] = p1Mom.Perp(); arr[iArr++] = p1Mom.PseudoRapidity(); arr[iArr++] = p1Mom.Rapidity(); arr[iArr++] = p1Mom.Phi(); arr[iArr++] = p1Dca; arr[iArr++] = p1RMom.M(); arr[iArr++] = p1RMom.Perp(); arr[iArr++] = p1RMom.PseudoRapidity(); arr[iArr++] = p1RMom.Rapidity(); arr[iArr++] = p1RMom.Phi(); arr[iArr++] = p1RPos.X(); arr[iArr++] = p1RPos.Y(); arr[iArr++] = p1RPos.Z(); arr[iArr++] = p1RDca; arr[iArr++] = tpcReconstructed(0,1,centrality,p1RMom); arr[iArr++] = p2Mom.M(); arr[iArr++] = p2Mom.Perp(); arr[iArr++] = p2Mom.PseudoRapidity(); arr[iArr++] = p2Mom.Rapidity(); arr[iArr++] = p2Mom.Phi(); arr[iArr++] = p2Dca; arr[iArr++] = p2RMom.M(); arr[iArr++] = p2RMom.Perp(); arr[iArr++] = p2RMom.PseudoRapidity(); arr[iArr++] = p2RMom.Rapidity(); arr[iArr++] = p2RMom.Phi(); arr[iArr++] = p2RPos.X(); arr[iArr++] = p2RPos.Y(); arr[iArr++] = p2RPos.Z(); arr[iArr++] = p2RDca; arr[iArr++] = tpcReconstructed(0,-1,centrality,p2RMom); arr[iArr++] = matchHft(1, vertex.z(), centrality, p1RMom); arr[iArr++] = matchHft(0, vertex.z(), centrality, p2RMom); nt->Fill(arr); }
void PID_misidentification() { // -- define tuple file name, tuple name and cuts to apply----------------------- // -- and also the name of the output file const std::string filename = "/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/background_MC_samples/Bs2JpsiX_MC_2012_signal_withbdt.root"; const std::string treename = "withbdt"; const std::string outFilename("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/background_MC_samples/Bs2JpsiX_MC_2012_signal_withbdt_misidentification.root"); TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need--------------------------------------------- tree->SetBranchStatus("*", 1); // -- this file is just here to make the 'CopyTree' happy TFile* dummyFile = new TFile("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree("bdtg>=0.85"); double chi_c_M, chi_c_P, chi_c_PE, chi_c_PT, chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_ETA; double kaon_M, kaon_P, kaon_PE, kaon_PX, kaon_PT, kaon_PY, kaon_PZ, kaon_ETA, kaon_IPCHI2_OWNPV, kaon_TRACK_GhostProb, kaon_ProbNNp, kaon_ProbNNk; double proton_M, proton_P, proton_PE, proton_PT, proton_PX, proton_PY, proton_PZ, proton_ETA, proton_IPCHI2_OWNPV, proton_TRACK_GhostProb, proton_ProbNNp, proton_ProbNNk; double Jpsi_M, Jpsi_P, Jpsi_PE, Jpsi_PT, Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_ETA; double gamma_M, gamma_P, gamma_PE, gamma_PT, gamma_PX, gamma_PY, gamma_PZ, gamma_ETA, gamma_CL; double muminus_M, muminus_P, muminus_PE, muminus_PT, muminus_PX, muminus_PY, muminus_PZ, muminus_ETA, muminus_ProbNNmu, muminus_TRACK_GhostProb; double muplus_M, muplus_P, muplus_PE, muplus_PT, muplus_PX, muplus_PY, muplus_PZ, muplus_ETA, muplus_ProbNNmu, muplus_TRACK_GhostProb; double Lambda_b0_DTF_MASS_constr1, Lambda_b0_DTF_CHI2NDOF, Lambda_b0_IPCHI2_OWNPV; double Lambda_b0_FDS, Lambda_b0_pi0veto, Lambda_b0_PT; float bdtg; bool Lambda_b0_L0MuonDecision_TOS, Lambda_b0_L0DiMuonDecision_TOS; bool Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, Lambda_b0_Hlt1DiMuonLowMassDecision_TOS; bool Lambda_b0_Hlt1TrackMuonDecision_TOS, Lambda_b0_Hlt1TrackAllL0Decision_TOS; bool Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedDecision_TOS; bool Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS; rTree1->SetBranchAddress("chi_c_M", &chi_c_M); rTree1->SetBranchAddress("chi_c_P", &chi_c_P); rTree1->SetBranchAddress("chi_c_PE", &chi_c_PE); rTree1->SetBranchAddress("chi_c_PT", &chi_c_PT); rTree1->SetBranchAddress("chi_c_PX", &chi_c_PX); rTree1->SetBranchAddress("chi_c_PY", &chi_c_PY); rTree1->SetBranchAddress("chi_c_PZ", &chi_c_PZ); //rTree1->SetBranchAddress("chi_c_ETA", &chi_c_ETA); rTree1->SetBranchAddress("kaon_M", &kaon_M); rTree1->SetBranchAddress("kaon_P", &kaon_P); rTree1->SetBranchAddress("kaon_PE", &kaon_PE); rTree1->SetBranchAddress("kaon_PX", &kaon_PX); rTree1->SetBranchAddress("kaon_PT", &kaon_PT); rTree1->SetBranchAddress("kaon_PY", &kaon_PY); rTree1->SetBranchAddress("kaon_PZ", &kaon_PZ); //rTree1->SetBranchAddress("kaon_ETA", &kaon_ETA); rTree1->SetBranchAddress("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV); rTree1->SetBranchAddress("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb); rTree1->SetBranchAddress("kaon_ProbNNp", &kaon_ProbNNp); rTree1->SetBranchAddress("kaon_ProbNNk", &kaon_ProbNNk); rTree1->SetBranchAddress("proton_M", &proton_M); rTree1->SetBranchAddress("proton_P", &proton_P); rTree1->SetBranchAddress("proton_PE", &proton_PE); rTree1->SetBranchAddress("proton_PT", &proton_PT); rTree1->SetBranchAddress("proton_PX", &proton_PX); rTree1->SetBranchAddress("proton_PY", &proton_PY); rTree1->SetBranchAddress("proton_PZ", &proton_PZ); //rTree1->SetBranchAddress("proton_ETA", &proton_ETA); rTree1->SetBranchAddress("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV); rTree1->SetBranchAddress("proton_TRACK_GhostProb", &proton_TRACK_GhostProb); rTree1->SetBranchAddress("proton_ProbNNp", &proton_ProbNNp); rTree1->SetBranchAddress("proton_ProbNNk", &proton_ProbNNk); rTree1->SetBranchAddress("Jpsi_M", &Jpsi_M); rTree1->SetBranchAddress("Jpsi_P", &Jpsi_P); rTree1->SetBranchAddress("Jpsi_PE", &Jpsi_PE); rTree1->SetBranchAddress("Jpsi_PT", &Jpsi_PT); rTree1->SetBranchAddress("Jpsi_PX", &Jpsi_PX); rTree1->SetBranchAddress("Jpsi_PY", &Jpsi_PY); rTree1->SetBranchAddress("Jpsi_PZ", &Jpsi_PZ); //rTree1->SetBranchAddress("Jpsi_ETA", &Jpsi_ETA); rTree1->SetBranchAddress("gamma_M", &gamma_M); rTree1->SetBranchAddress("gamma_P", &gamma_P); rTree1->SetBranchAddress("gamma_PE", &gamma_PE); rTree1->SetBranchAddress("gamma_PT", &gamma_PT); rTree1->SetBranchAddress("gamma_PX", &gamma_PX); rTree1->SetBranchAddress("gamma_PY", &gamma_PY); rTree1->SetBranchAddress("gamma_PZ", &gamma_PZ); //rTree1->SetBranchAddress("gamma_ETA", &gamma_ETA); rTree1->SetBranchAddress("gamma_CL", &gamma_CL); rTree1->SetBranchAddress("muminus_M", &muminus_M); rTree1->SetBranchAddress("muminus_P", &muminus_P); rTree1->SetBranchAddress("muminus_PE", &muminus_PE); rTree1->SetBranchAddress("muminus_PT", &muminus_PT); rTree1->SetBranchAddress("muminus_PX", &muminus_PX); rTree1->SetBranchAddress("muminus_PY", &muminus_PY); rTree1->SetBranchAddress("muminus_PZ", &muminus_PZ); //rTree1->SetBranchAddress("muminus_ETA", &muminus_ETA); rTree1->SetBranchAddress("muminus_ProbNNmu", &muminus_ProbNNmu); rTree1->SetBranchAddress("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb); rTree1->SetBranchAddress("muplus_M", &muplus_M); rTree1->SetBranchAddress("muplus_P", &muplus_P); rTree1->SetBranchAddress("muplus_PE", &muplus_PE); rTree1->SetBranchAddress("muplus_PT", &muplus_PT); rTree1->SetBranchAddress("muplus_PX", &muplus_PX); rTree1->SetBranchAddress("muplus_PY", &muplus_PY); rTree1->SetBranchAddress("muplus_PZ", &muplus_PZ); //rTree1->SetBranchAddress("muplus_ETA", &muplus_ETA); rTree1->SetBranchAddress("muplus_ProbNNmu", &muplus_ProbNNmu); rTree1->SetBranchAddress("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1); rTree1->SetBranchAddress("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF); rTree1->SetBranchAddress("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV); rTree1->SetBranchAddress("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_FDS", &Lambda_b0_FDS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_pi0veto", &Lambda_b0_pi0veto); rTree1->SetBranchAddress("Lambda_b0_PT", &Lambda_b0_PT); rTree1->SetBranchAddress("bdtg", &bdtg); //------------------------------------------------------------------------------- TFile* rFile = new TFile( outFilename.c_str() ,"RECREATE"); TTree* rTree2 = new TTree(); rTree2->SetName("withbdt"); rTree2->Branch("chi_c_M", &chi_c_M, "chi_c_M/D"); rTree2->Branch("chi_c_P", &chi_c_P, "chi_c_P/D"); rTree2->Branch("chi_c_PE", &chi_c_PE, "chi_c_PE/D"); rTree2->Branch("chi_c_PT", &chi_c_PT, "chi_c_PT/D"); rTree2->Branch("chi_c_PX", &chi_c_PX, "chi_c_PX/D"); rTree2->Branch("chi_c_PY", &chi_c_PY, "chi_c_PY/D"); rTree2->Branch("chi_c_PZ", &chi_c_PZ, "chi_c_PZ/D"); //rTree2->Branch("chi_c_ETA", &chi_c_ETA, "chi_c_ETA/D"); rTree2->Branch("kaon_M", &kaon_M, "kaon_M/D"); rTree2->Branch("kaon_P", &kaon_P, "kaon_P/D"); rTree2->Branch("kaon_PE", &kaon_PE, "kaon_PE/D"); rTree2->Branch("kaon_PX", &kaon_PX, "kaon_PX/D"); rTree2->Branch("kaon_PT", &kaon_PT, "kaon_PT/D"); rTree2->Branch("kaon_PY", &kaon_PY, "kaon_PY/D"); rTree2->Branch("kaon_PZ", &kaon_PZ, "kaon_PZ/D"); //rTree2->Branch("kaon_ETA", &kaon_ETA, "kaon_ETA/D"); rTree2->Branch("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV, "kaon_IPCHI2_OWNPV/D"); rTree2->Branch("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb, "kaon_TRACK_GhostProb/D"); rTree2->Branch("kaon_ProbNNp", &kaon_ProbNNp, "kaon_ProbNNp/D"); rTree2->Branch("kaon_ProbNNk", &kaon_ProbNNk, "kaon_ProbNNk/D"); rTree2->Branch("proton_M", &proton_M, "proton_M/D"); rTree2->Branch("proton_P", &proton_P, "proton_P/D"); rTree2->Branch("proton_PE", &proton_PE, "proton_PE/D"); rTree2->Branch("proton_PT", &proton_PT, "proton_PT/D"); rTree2->Branch("proton_PX", &proton_PX, "proton_PX/D"); rTree2->Branch("proton_PY", &proton_PY, "proton_PY/D"); rTree2->Branch("proton_PZ", &proton_PZ, "proton_PZ/D"); //rTree2->Branch("proton_ETA", &proton_ETA, "proton_ETA/D"); rTree2->Branch("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV, "proton_IPCHI2_OWNPV/D"); rTree2->Branch("proton_TRACK_GhostProb", &proton_TRACK_GhostProb, "proton_TRACK_GhostProb/D"); rTree2->Branch("proton_ProbNNp", &proton_ProbNNp, "proton_ProbNNp/D"); rTree2->Branch("proton_ProbNNk", &proton_ProbNNk, "proton_ProbNNk/D"); rTree2->Branch("Jpsi_M", &Jpsi_M, "Jpsi_M/D"); rTree2->Branch("Jpsi_P", &Jpsi_P, "Jpsi_P/D"); rTree2->Branch("Jpsi_PE", &Jpsi_PE, "Jpsi_PE/D"); rTree2->Branch("Jpsi_PT", &Jpsi_PT, "Jpsi_PT/D"); rTree2->Branch("Jpsi_PX", &Jpsi_PX, "Jpsi_PX/D"); rTree2->Branch("Jpsi_PY", &Jpsi_PY, "Jpsi_PY/D"); rTree2->Branch("Jpsi_PZ", &Jpsi_PZ, "Jpsi_PZ/D"); //rTree2->Branch("Jpsi_ETA", &Jpsi_ETA, "Jpsi_ETA/D"); rTree2->Branch("gamma_M", &gamma_M, "gamma_M/D"); rTree2->Branch("gamma_P", &gamma_P, "gamma_P/D"); rTree2->Branch("gamma_PE", &gamma_PE, "gamma_PE/D"); rTree2->Branch("gamma_PT", &gamma_PT, "gamma_PT/D"); rTree2->Branch("gamma_PX", &gamma_PX, "gamma_PX/D"); rTree2->Branch("gamma_PY", &gamma_PY, "gamma_PY/D"); rTree2->Branch("gamma_PZ", &gamma_PZ, "gamma_PZ/D"); //rTree2->Branch("gamma_ETA", &gamma_ETA, "gamma_ETA/D"); rTree2->Branch("gamma_CL", &gamma_CL, "gamma_CL/D"); rTree2->Branch("muminus_M", &muminus_M, "muminus_M/D"); rTree2->Branch("muminus_P", &muminus_P, "muminus_P/D"); rTree2->Branch("muminus_PE", &muminus_PE, "muminus_PE/D"); rTree2->Branch("muminus_PT", &muminus_PT, "muminus_PT/D"); rTree2->Branch("muminus_PX", &muminus_PX, "muminus_PX/D"); rTree2->Branch("muminus_PY", &muminus_PY, "muminus_PY/D"); rTree2->Branch("muminus_PZ", &muminus_PZ, "muminus_PZ/D"); //rTree2->Branch("muminus_ETA", &muminus_ETA, "muminus_ETA/D"); rTree2->Branch("muminus_ProbNNmu", &muminus_ProbNNmu, "muminus_ProbNNmu/D"); rTree2->Branch("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb, "muminus_TRACK_GhostProb/D"); rTree2->Branch("muplus_M", &muplus_M, "muplus_M/D"); rTree2->Branch("muplus_P", &muplus_P, "muplus_P/D"); rTree2->Branch("muplus_PE", &muplus_PE, "muplus_PE/D"); rTree2->Branch("muplus_PT", &muplus_PT, "muplus_PT/D"); rTree2->Branch("muplus_PX", &muplus_PX, "muplus_PX/D"); rTree2->Branch("muplus_PY", &muplus_PY, "muplus_PY/D"); rTree2->Branch("muplus_PZ", &muplus_PZ, "muplus_PZ/D"); //rTree2->Branch("muplus_ETA", &muplus_ETA, "muplus_ETA/D"); rTree2->Branch("muplus_ProbNNmu", &muplus_ProbNNmu, "muplus_ProbNNmu/D"); rTree2->Branch("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb, "muplus_TRACK_GhostProb/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1, "Lambda_b0_DTF_MASS_constr1/D"); rTree2->Branch("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF, "Lambda_b0_DTF_CHI2NDOF/D"); rTree2->Branch("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV, "Lambda_b0_IPCHI2_OWNPV/D"); rTree2->Branch("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS, "Lambda_b0_L0DiMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS, "Lambda_b0_L0MuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_FDS", &Lambda_b0_FDS, "Lambda_b0_FDS/D"); rTree2->Branch("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, "Lambda_b0_Hlt1DiMuonHighMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS, "Lambda_b0_Hlt1DiMuonLowMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS, "Lambda_b0_Hlt1TrackMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS, "Lambda_b0_Hlt1TrackAllL0Decision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, "Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS/B"); rTree2->Branch("Lambda_b0_pi0veto", &Lambda_b0_pi0veto, "Lambda_b0_pi0veto/D"); rTree2->Branch("Lambda_b0_PT", &Lambda_b0_PT, "Lambda_b0_PT/D"); rTree2->Branch("bdtg", &bdtg, "bdtg/F"); //This is where the misidentification is calculated for P and K--------------------------- const double mK(0.493677); double mass_proton_as_proton, mass_proton_as_kaon, mass_kaon_as_kaon; rTree2->Branch("mass_proton_as_proton", &mass_proton_as_proton, "mass_proton_as_proton/D"); rTree2->Branch("mass_proton_as_kaon", &mass_proton_as_kaon, "mass_proton_as_kaon/D"); rTree2->Branch("mass_kaon_as_kaon", &mass_kaon_as_kaon, "mass_kaon_as_kaon/D"); double proton_P = sqrt(proton_PX*proton_PX + proton_PY*proton_PY + proton_PZ*proton_PZ) ; for(int i = 0; i < rTree1->GetEntries(); ++i){ //for event in tree rTree1->GetEntry(i); TLorentzVector * proton = new TLorentzVector(proton_PX, proton_PY, proton_PZ, proton_PE); TLorentzVector * proton_as_kaon = new TLorentzVector(proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mK*mK)); TLorentzVector * kaon = new TLorentzVector(kaon_PX, kaon_PY, kaon_PZ, kaon_PE); mass_proton_as_proton = proton->M(); mass_proton_as_kaon = proton_as_kaon->M(); mass_kaon_as_kaon = kaon->M(); rTree2->Fill(); } rTree2->Print(); rTree2->Write(); rFile->Save(); }
//!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; }
void plots() { gSystem->Load("libEVGEN"); // Needs to be! AliRunLoader* rl = AliRunLoader::Open("galice.root"); rl->LoadKinematics(); rl->LoadHeader(); // 4pi histograms TH1* hM = new TH1D("hM", "DIME #rho#rho;M_{4#pi} #(){GeV/#it{c}^{2}}", 100, 1.0, 3.0); TH1* hPt = new TH1D("hPt", "DIME #rho#rho;p_{T}#(){4#pi} #(){GeV/#it{c}}", 100, 0.0, 3.0); // pi+- histograms TH1* hPt1 = new TH1D("hPt1", "DIME #rho#rho;p_{T}#(){#pi^{#pm}} #(){Gev/#it{c}}", 100, 0.0, 3.0); AliStack* stack = NULL; TParticle* part = NULL; TLorentzVector v[4]; TLorentzVector vSum; // Loop over events for (Int_t i = 0; i < rl->GetNumberOfEvents(); ++i) { rl->GetEvent(i); stack = rl->Stack(); Int_t nPrimary = 0; // Loop over all particles for (Int_t j = 0; j < stack->GetNtrack(); ++j) { part = stack->Particle(j); // Get particle part->Print(); // Print contents if (abs(part->GetPdgCode()) == 211 // Is pi+ or pi- & part->GetStatusCode() == 1 // Is stable final state & stack->IsPhysicalPrimary(j)) { // Is from generator level part->Momentum(v[nPrimary]); // Set content of v ++nPrimary; } } if (nPrimary != 4) { printf("Error: nPrimary=%d != 4 \n", nPrimary); continue; } // 4-vector sum vSum = v[0] + v[1] + v[2] + v[3]; // Fill 4pi histograms hM->Fill(vSum.M()); hPt->Fill(vSum.Perp()); // Fill pi+- histograms for (Int_t k = 0; k < 4; ++k) { hPt1->Fill(v[k].Perp()); } printf("\n"); } // Save plots as pdf hM->Draw(); c1->SaveAs("plotM.pdf"); hPt->Draw(); c1->SaveAs("plotPt.pdf"); hPt1->Draw(); c1->SaveAs("plotPt1.pdf"); }
void readOutAngles_LMH(std::string filename, bool applyRes=false){ ifstream fin; std::string filenameT = filename + (applyRes?"_true":"_false") + ".txt"; std::cout << "Processing " << filenameT << std::endl; fin.open(filenameT.c_str()); int maxEvents = 300000; char oname[192]; if(applyRes) sprintf(oname,"%s_wResolution.root",filename.c_str()); else sprintf(oname,"%s.root",filename.c_str()); TFile fout(oname, "RECREATE"); TTree* tree = new TTree("angles", "angles"); Double_t m_costheta1, m_costheta2, m_phi, m_costhetastar, m_phistar1, m_phistar2, m_phistar12, m_phi1, m_phi2; Double_t m_zzmass, m_z1mass, m_z2mass; tree->Branch("zzmass", &m_zzmass, "zzmass/D"); tree->Branch("z1mass", &m_z1mass, "z1mass/D"); tree->Branch("z2mass", &m_z2mass, "z2mass/D"); tree->Branch("costheta1", &m_costheta1, "costheta1/D"); tree->Branch("costheta2", &m_costheta2, "costheta2/D"); tree->Branch("phi", &m_phi, "phi/D"); tree->Branch("costhetastar", &m_costhetastar, "costhetastar/D"); tree->Branch("upsilon1", &m_phi1, "phi1/D"); tree->Branch("upsilon2", &m_phi2, "phi2/D"); tree->Branch("phistar1", &m_phistar1, "phistar1/D"); tree->Branch("phistar2", &m_phistar2, "phistar2/D"); tree->Branch("phistar12", &m_phistar12, "phistar12/D"); Double_t m_l1minus_pT, m_l1plus_pT, m_l2minus_pT, m_l2plus_pT; Double_t m_l1minus_eta, m_l1plus_eta, m_l2minus_eta, m_l2plus_eta; Double_t Y4l, eta4l, pT4l; tree->Branch("l1m_pT", &m_l1minus_pT, "l1m_pT/D"); tree->Branch("l1p_pT", &m_l1plus_pT, "l1p_pT/D"); tree->Branch("l2m_pT", &m_l2minus_pT, "l2m_pT/D"); tree->Branch("l2p_pT", &m_l2plus_pT, "l2p_pT/D"); tree->Branch("l1m_eta", &m_l1minus_eta, "l1m_eta/D"); tree->Branch("l1p_eta", &m_l1plus_eta, "l1p_eta/D"); tree->Branch("l2m_eta", &m_l2minus_eta, "l2m_eta/D"); tree->Branch("l2p_eta", &m_l2plus_eta, "l2p_eta/D"); tree->Branch("Y4l",&Y4l,"Y4l/D"); tree->Branch("eta4l",&eta4l,"eta4l/D"); tree->Branch("pT4l",&pT4l,"pT4l/D"); int ctr = 0; int iFile = 0; while (!fin.eof() && fin.good()){ std::vector <double> listOfMom; int idup[4], istup[4], mothup[4][2], icolup[4][2]; double pup[4][5], vtimup[4], spinup[4]; for (int a = 0; a < 4; a++){ fin >> idup[a] >> istup[a] >> mothup[a][0] >> mothup[a][1] >> icolup[a][0] >> icolup[a][1]; //std::cout << idup[a] << ", " << istup[a] << std::endl; for (int i = 0; i < 5; i++){ fin >> pup[a][i]; } fin >> vtimup[a] >> spinup[a]; } TLorentzVector *l1_minus=0, *l1_plus=0, *l2_minus=0, *l2_plus=0; if (mothup[0][0] == mothup[1][0]){ //std::cout << "mothup[0][0] == mothup[1][0]" << std::endl; l1_minus = new TLorentzVector(pup[0][0], pup[0][1], pup[0][2], pup[0][3]); l1_plus = new TLorentzVector(pup[1][0], pup[1][1], pup[1][2], pup[1][3]); if (idup[2] > 0){ //std::cout << ">0" << std::endl; l2_minus = new TLorentzVector(pup[2][0], pup[2][1], pup[2][2], pup[2][3]); l2_plus = new TLorentzVector(pup[3][0], pup[3][1], pup[3][2], pup[3][3]); } else { //std::cout << "<0" << std::endl; l2_plus = new TLorentzVector(pup[2][0], pup[2][1], pup[2][2], pup[2][3]); l2_minus = new TLorentzVector(pup[3][0], pup[3][1], pup[3][2], pup[3][3]); } } else if (mothup[0][0] == mothup[2][0]){ //std::cout << "mothup[0][0] == mothup[2][0]" << std::endl; l1_minus = new TLorentzVector(pup[0][0], pup[0][1], pup[0][2], pup[0][3]); l1_plus = new TLorentzVector(pup[2][0], pup[2][1], pup[2][2], pup[2][3]); if (idup[1] > 0){ //std::cout << ">0" << std::endl; l2_minus = new TLorentzVector(pup[1][0], pup[1][1], pup[1][2], pup[1][3]); l2_plus = new TLorentzVector(pup[3][0], pup[3][1], pup[3][2], pup[3][3]); } else { //std::cout << "<0" << std::endl; l2_plus = new TLorentzVector(pup[1][0], pup[1][1], pup[1][2], pup[1][3]); l2_minus = new TLorentzVector(pup[3][0], pup[3][1], pup[3][2], pup[3][3]); } } else if (mothup[0][0] == mothup[3][0]){ //std::cout << "mothup[0][0] == mothup[3][0]" << std::endl; l1_minus = new TLorentzVector(pup[0][0], pup[0][1], pup[0][2], pup[0][3]); l1_plus = new TLorentzVector(pup[3][0], pup[3][1], pup[3][2], pup[3][3]); if (idup[1] > 0){ //std::cout << ">0" << std::endl; l2_minus = new TLorentzVector(pup[1][0], pup[1][1], pup[1][2], pup[1][3]); l2_plus = new TLorentzVector(pup[2][0], pup[2][1], pup[2][2], pup[2][3]); } else { //std::cout << "<0" << std::endl; l2_plus = new TLorentzVector(pup[1][0], pup[1][1], pup[1][2], pup[1][3]); l2_minus = new TLorentzVector(pup[2][0], pup[2][1], pup[2][2], pup[2][3]); } }else{continue;} if(applyRes){ l1_minus = applyResolution(l1_minus); l2_minus = applyResolution(l2_minus); l1_plus = applyResolution(l1_plus); l2_plus = applyResolution(l2_plus); } //std::cout << "l1m: " << l1_minus->E() << std::endl; TLorentzVector Z1 = *l1_minus+*l1_plus; TLorentzVector Z2 = *l2_minus+*l2_plus; TLorentzVector Graviton = Z1+Z2; const double PDGZmass = 91.2; TLorentzVector pZ1; TLorentzVector pl1_m; TLorentzVector pl1_p; TLorentzVector pZ2; TLorentzVector pl2_m; TLorentzVector pl2_p; if ( fabs(PDGZmass-Z1.M()) > fabs(PDGZmass-Z2.M()) ){ pZ1 = Z2; pl1_m = *l2_minus; pl1_p = *l2_plus; pZ2 = Z1; pl2_m = *l1_minus; pl2_p = *l1_plus; } else { pZ1 = Z1; pl1_m = *l1_minus; pl1_p = *l1_plus; pZ2 = Z2; pl2_m = *l2_minus; pl2_p = *l2_plus; } double angle_costheta1, angle_costheta2, angle_phi, angle_costhetastar, angle_phistar1, angle_phistar2, angle_phistar12, angle_phi1, angle_phi2; calculateAngles( Graviton, pZ1, pl1_m, pl1_p, pZ2, pl2_m, pl2_p, angle_costheta1, angle_costheta2, angle_phi, angle_costhetastar, angle_phistar1, angle_phistar2, angle_phistar12, angle_phi1, angle_phi2); Y4l = 0; //Graviton.Rapidity(); eta4l = 0; //BGraviton.Eta(); pT4l = 0; //Graviton.Pt(); m_costheta1 = angle_costheta1; m_costheta2 = angle_costheta2; m_phi = angle_phi; m_costhetastar = angle_costhetastar; m_phistar1 = angle_phistar1; m_phistar2 = angle_phistar2; m_phistar12 = angle_phistar12; m_phi1 = angle_phi1; m_phi2 = angle_phi2; m_zzmass = Graviton.M(); m_z1mass = pZ1.M(); m_z2mass = pZ2.M(); m_l1minus_pT = pl1_m.Pt(); m_l1plus_pT = pl1_p.Pt(); m_l2minus_pT = pl2_m.Pt(); m_l2plus_pT = pl2_p.Pt(); m_l1minus_eta = pl1_m.Eta(); m_l1plus_eta = pl1_p.Eta(); m_l2minus_eta = pl2_m.Eta(); m_l2plus_eta = pl2_p.Eta(); tree->Fill(); // counter ctr++; if (ctr%1000 == 0) std::cout << "event number: " << ctr << std::endl; if (ctr == maxEvents) break; } fout.cd(); tree->Write(); fout.Close(); }
int main(int argc, char * argv[]) { // first argument - config file // second argument - filelist using namespace std; // **** configuration Config cfg(argv[1]); // vertex cuts const float ndofVertexCut = cfg.get<float>("NdofVertexCut"); const float zVertexCut = cfg.get<float>("ZVertexCut"); const float dVertexCut = cfg.get<float>("DVertexCut"); // electron cuta const float ptElectronLowCut = cfg.get<float>("ptElectronLowCut"); const float ptElectronHighCut = cfg.get<float>("ptElectronHighCut"); const float etaElectronCut = cfg.get<float>("etaElectronCut"); const float dxyElectronCut = cfg.get<float>("dxyElectronCut"); const float dzElectronCut = cfg.get<float>("dzElectronCut"); const float isoElectronLowCut = cfg.get<float>("isoElectronLowCut"); const float isoElectronHighCut = cfg.get<float>("isoElectronHighCut"); const bool applyElectronId = cfg.get<bool>("ApplyElectronId"); // tau cuts const float ptTauLowCut = cfg.get<float>("ptTauLowCut"); const float ptTauHighCut = cfg.get<float>("ptTauHighCut"); const float etaTauCut = cfg.get<float>("etaTauCut"); const bool applyTauId = cfg.get<bool>("ApplyTauId"); // pair selection const float dRleptonsCut = cfg.get<float>("dRleptonsCut"); // additional lepton veto const float ptDiElectronVeto = cfg.get<float>("ptDiElectronVeto"); const float etaDiElectronVeto = cfg.get<float>("etaDiElectronVeto"); // topological cuts const float dZetaCut = cfg.get<float>("dZetaCut"); const bool oppositeSign = cfg.get<bool>("oppositeSign"); const float deltaRTrigMatch = cfg.get<float>("DRTrigMatch"); const bool isIsoR03 = cfg.get<bool>("IsIsoR03"); const float jetEtaCut = cfg.get<float>("JetEtaCut"); const float jetPtLowCut = cfg.get<float>("JetPtLowCut"); const float jetPtHighCut = cfg.get<float>("JetPtHighCut"); const float dRJetLeptonCut = cfg.get<float>("dRJetLeptonCut"); const bool applyJetPfId = cfg.get<bool>("ApplyJetPfId"); const bool applyJetPuId = cfg.get<bool>("ApplyJetPuId"); const float bJetEtaCut = cfg.get<float>("bJetEtaCut"); const float btagCut = cfg.get<float>("btagCut"); // check overlap const bool checkOverlap = cfg.get<bool>("CheckOverlap"); const bool debug = cfg.get<bool>("debug"); // **** end of configuration // file name and tree name TString rootFileName(argv[2]); std::ifstream fileList(argv[2]); std::ifstream fileList0(argv[2]); std::string ntupleName("makeroottree/AC1B"); rootFileName += "_et_Sync.root"; std::cout <<rootFileName <<std::endl; // output fileName with histograms TFile * file = new TFile( rootFileName ,"recreate"); file->cd(""); TH1F * inputEventsH = new TH1F("inputEventsH","",1,-0.5,0.5); TTree * tree = new TTree("TauCheck","TauCheck"); Spring15Tree *otree = new Spring15Tree(tree); int nTotalFiles = 0; std::string dummy; // count number of files ---> while (fileList0 >> dummy) nTotalFiles++; int nEvents = 0; int selEvents = 0; int nFiles = 0; vector<int> runList; runList.clear(); vector<int> eventList; eventList.clear(); int nonOverlap = 0; std::ifstream fileEvents("overlap.txt"); int Run, Event, Lumi; if (checkOverlap) { std::cout << "Non-overlapping events ->" << std::endl; while (fileEvents >> Run >> Event >> Lumi) { runList.push_back(Run); eventList.push_back(Event); std::cout << Run << ":" << Event << std::endl; } std::cout << std::endl; } std::ofstream fileOutput("overlap.out"); for (int iF=0; iF<nTotalFiles; ++iF) { std::string filen; fileList >> filen; std::cout << "file " << iF+1 << " out of " << nTotalFiles << " filename : " << filen << std::endl; TFile * file_ = TFile::Open(TString(filen)); TTree * _tree = NULL; _tree = (TTree*)file_->Get(TString(ntupleName)); if (_tree==NULL) continue; TH1D * histoInputEvents = NULL; histoInputEvents = (TH1D*)file_->Get("makeroottree/nEvents"); if (histoInputEvents==NULL) continue; int NE = int(histoInputEvents->GetEntries()); std::cout << " number of input events = " << NE << std::endl; for (int iE=0;iE<NE;++iE) inputEventsH->Fill(0.); AC1B analysisTree(_tree); Long64_t numberOfEntries = analysisTree.GetEntries(); std::cout << " number of entries in Tree = " << numberOfEntries << std::endl; for (Long64_t iEntry=0; iEntry<numberOfEntries; iEntry++) { analysisTree.GetEntry(iEntry); nEvents++; if (nEvents%10000==0) cout << " processed " << nEvents << " events" << endl; otree->run = int(analysisTree.event_run); otree->lumi = int(analysisTree.event_luminosityblock); otree->evt = int(analysisTree.event_nr); bool overlapEvent = true; for (unsigned int iEvent=0; iEvent<runList.size(); ++iEvent) { if (runList.at(iEvent)==otree->run && eventList.at(iEvent)==otree->evt) { overlapEvent = false; } } if (overlapEvent&&checkOverlap) continue; nonOverlap++; if (debug) { fileOutput << std::endl; fileOutput << "Run = " << otree->run << " Event = " << otree->evt << std::endl; } // weights otree->mcweight = 0; otree->puweight = 0; otree->trigweight_1 = 0; otree->trigweight_2 = 0; otree->idweight_1 = 0; otree->idweight_2 = 0; otree->isoweight_1 = 0; otree->isoweight_2 = 0; otree->effweight = 0; otree->fakeweight = 0; otree->embeddedWeight = 0; otree->signalWeight = 0; otree->weight = 1; otree->npv = analysisTree.primvertex_count; otree->npu = analysisTree.numpileupinteractions; otree->rho = analysisTree.rho; // vertex cuts if (fabs(analysisTree.primvertex_z)>zVertexCut) continue; if (analysisTree.primvertex_ndof<=ndofVertexCut) continue; float dVertex = sqrt(analysisTree.primvertex_x*analysisTree.primvertex_x+ analysisTree.primvertex_y*analysisTree.primvertex_y); if (dVertex>dVertexCut) continue; if (debug) fileOutput << "Vertex cuts are passed " << std::endl; // electron selection vector<int> electrons; electrons.clear(); if (debug) fileOutput << "# electrons = " << analysisTree.electron_count << std::endl; for (unsigned int ie = 0; ie<analysisTree.electron_count; ++ie) { bool electronMvaId = electronMvaIdTight(analysisTree.electron_superclusterEta[ie], analysisTree.electron_mva_id_nontrigPhys14[ie]); if (checkOverlap) fileOutput << " " << ie << " pt = " << analysisTree.electron_pt[ie] << " eta = " << analysisTree.electron_eta[ie] << " dxy = " << analysisTree.electron_dxy[ie] << " dz = " << analysisTree.electron_dz[ie] << " passConv = " << analysisTree.electron_pass_conversion[ie] << " nmisshits = " << int(analysisTree.electron_nmissinginnerhits[ie]) << " mvaTight = " << electronMvaId << std::endl; if (analysisTree.electron_pt[ie]<ptElectronLowCut) continue; if (fabs(analysisTree.electron_eta[ie])>etaElectronCut) continue; if (fabs(analysisTree.electron_dxy[ie])>dxyElectronCut) continue; if (fabs(analysisTree.electron_dz[ie])>dzElectronCut) continue; if (!electronMvaId&&applyElectronId) continue; if (!analysisTree.electron_pass_conversion[ie]&&applyElectronId) continue; if (analysisTree.electron_nmissinginnerhits[ie]!=0&&applyElectronId) continue; electrons.push_back(ie); } // tau selection if (debug) fileOutput << "# taus = " << analysisTree.tau_count << std::endl; vector<int> taus; taus.clear(); for (unsigned int it = 0; it<analysisTree.tau_count; ++it) { if (debug) fileOutput << " " << it << " pt = " << analysisTree.tau_pt[it] << " eta = " << analysisTree.tau_eta[it] << " decayModeFinding = " << analysisTree.tau_decayModeFinding[it] << " decayModeFindingNewDMs = " << analysisTree.tau_decayModeFindingNewDMs[it] << " tau_vertexz = " << analysisTree.tau_vertexz[it] <<std::endl; if (analysisTree.tau_pt[it]<ptTauLowCut) continue; if (fabs(analysisTree.tau_eta[it])>etaTauCut) continue; if (applyTauId && analysisTree.tau_decayModeFinding[it] < 0.5 && analysisTree.tau_decayModeFindingNewDMs[it] < 0.5) continue; float ctgTheta = analysisTree.tau_pz[it] / sqrt(analysisTree.tau_px[it]*analysisTree.tau_px[it] + analysisTree.tau_py[it]*analysisTree.tau_py[it]); float zImpact = analysisTree.tau_vertexz[it] + 130. * ctgTheta; if ( zImpact > -1.5 && zImpact < 0.5) continue; if (analysisTree.tau_vertexz[it]!=analysisTree.primvertex_z) continue; taus.push_back(it); } if (debug) { fileOutput << " # selected electron = " << electrons.size() << std::endl; fileOutput << " # selected taus = " << taus.size() << std::endl; } if (electrons.size()==0) continue; if (taus.size()==0) continue; // selecting muon and tau pair (OS or SS); int electronIndex = -1; int tauIndex = -1; float isoEleMin = 1e+10; float isoTauMin = 1e+10; for (unsigned int ie=0; ie<electrons.size(); ++ie) { bool isTrigEle22 = false; bool isTrigEle32 = false; unsigned int eIndex = electrons.at(ie); float neutralHadIsoEle = analysisTree.electron_neutralHadIso[ie]; float photonIsoEle = analysisTree.electron_photonIso[ie]; float chargedHadIsoEle = analysisTree.electron_chargedHadIso[ie]; float puIsoEle = analysisTree.electron_puIso[ie]; if (isIsoR03) { neutralHadIsoEle = analysisTree.electron_r03_sumNeutralHadronEt[ie]; photonIsoEle = analysisTree.electron_r03_sumPhotonEt[ie]; chargedHadIsoEle = analysisTree.electron_r03_sumChargedHadronPt[ie]; puIsoEle = analysisTree.electron_r03_sumPUPt[ie]; } float neutralIsoEle = neutralHadIsoEle + photonIsoEle - 0.5*puIsoEle; neutralIsoEle = TMath::Max(float(0),neutralIsoEle); float absIsoEle = chargedHadIsoEle + neutralIsoEle; float relIsoEle = absIsoEle/analysisTree.electron_pt[ie]; if (debug) fileOutput << "Electron " << eIndex << " -> relIso = "<<relIsoEle<<" absIso = "<<absIsoEle<<std::endl; for (unsigned int iT=0; iT<analysisTree.trigobject_count; ++iT) { /*if (analysisTree.trigobject_isElectron[iT] || !analysisTree.trigobject_isMuon[iT] || analysisTree.trigobject_isTau[iT]) continue;*/ float dRtrig = deltaR(analysisTree.electron_eta[eIndex],analysisTree.electron_phi[eIndex], analysisTree.trigobject_eta[iT],analysisTree.trigobject_phi[iT]); if (dRtrig < deltaRTrigMatch){ if (analysisTree.trigobject_filters[iT][7] && analysisTree.trigobject_filters[iT][8]) // Ele22 Leg isTrigEle22 = true; if (analysisTree.trigobject_filters[iT][10]) // Ele32 Leg isTrigEle32 = true; } } if (debug) fileOutput << "Electron " << eIndex << " -> isTrigEle22 = " << isTrigEle22 << " ; isTrigEle32 = " << isTrigEle32 << std::endl; if ((!isTrigEle22) && (!isTrigEle32)) continue; for (unsigned int it=0; it<taus.size(); ++it) { unsigned int tIndex = taus.at(it); float absIsoTau = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[tIndex]; float relIsoTau = absIsoTau / analysisTree.tau_pt[tIndex]; if (debug) fileOutput << "tau" << tIndex << " -> relIso = "<<relIsoTau<<" absIso = "<<absIsoTau<<std::endl; float dR = deltaR(analysisTree.tau_eta[tIndex],analysisTree.tau_phi[tIndex], analysisTree.electron_eta[eIndex],analysisTree.electron_phi[eIndex]); if (debug) fileOutput << "dR(ele,tau) = " << dR << std::endl; if (dR<dRleptonsCut) continue; bool isTrigTau = false; float dRtrig_min = 9999.; for (unsigned int iT=0; iT<analysisTree.trigobject_count; ++iT) { if (debug){ if (analysisTree.trigobject_isElectron[iT] && analysisTree.trigobject_isMuon[iT]) fileOutput<<" trigObj "<<iT<<" both e and mu"<<std::endl; if (analysisTree.trigobject_isMuon[iT] && analysisTree.trigobject_isTau[iT]) fileOutput<<" trigObj "<<iT<<" both mu and tau"<<std::endl; if (analysisTree.trigobject_isElectron[iT] && analysisTree.trigobject_isTau[iT]) fileOutput<<" trigObj "<<iT<<" both e and tau"<<std::endl; } if (analysisTree.trigobject_isElectron[iT] || analysisTree.trigobject_isMuon[iT] || !analysisTree.trigobject_isTau[iT]) continue; float dRtrig = deltaR(analysisTree.tau_eta[tIndex],analysisTree.tau_phi[tIndex], analysisTree.trigobject_eta[iT],analysisTree.trigobject_phi[iT]); if (dRtrig < deltaRTrigMatch){ if (analysisTree.trigobject_filters[iT][7] && analysisTree.trigobject_filters[iT][8]){ isTrigTau = true; if (dRtrig < dRtrig_min) dRtrig_min = dRtrig; } } } if (debug) fileOutput << "Tau " << it << " -> isTrigTau = " << isTrigTau << " DR="<<dRtrig_min<<std::endl; bool trigMatch = isTrigEle32 || (isTrigEle22 && isTrigTau); if (isTrigEle32 && analysisTree.hltriggerresults_second[4]==false) if (debug) std::cout<<"IsoEle32 Trigger Mismatch"<<std::endl; if (isTrigEle22 && isTrigTau && analysisTree.hltriggerresults_second[1]==false) if (debug) std::cout<<"xEleTau Trigger Mismatch"<<std::endl; if (!trigMatch) continue; bool isKinematicMatch = false; if (isTrigEle32) { if (analysisTree.electron_pt[eIndex]>ptElectronHighCut) isKinematicMatch = true; } if (isTrigEle22 && isTrigTau) { if (analysisTree.electron_pt[eIndex]>ptElectronLowCut && analysisTree.tau_pt[tIndex]>ptTauHighCut) isKinematicMatch = true; } if (!isKinematicMatch) continue; bool changePair = false; if (relIsoEle<isoEleMin) { changePair = true; } else if (fabs(relIsoEle - isoEleMin) < 1.e-5) { if (analysisTree.electron_pt[eIndex] > analysisTree.electron_pt[electronIndex]) { changePair = true; } else if (fabs(analysisTree.electron_pt[eIndex] - analysisTree.electron_pt[electronIndex]) < 1.e-5) { if (absIsoTau < isoTauMin) { changePair = true; } else if ((absIsoTau - isoTauMin) < 1.e-5){ if (analysisTree.tau_pt[tIndex] > analysisTree.tau_pt[tauIndex]) { changePair = true; } } } } if (changePair){ isoEleMin = relIsoEle; electronIndex = eIndex; isoTauMin = absIsoTau; tauIndex = tIndex; } } } if (electronIndex<0) continue; if (tauIndex<0) continue; // filling electron variables otree->pt_1 = analysisTree.electron_pt[electronIndex]; otree->eta_1 = analysisTree.electron_eta[electronIndex]; otree->phi_1 = analysisTree.electron_phi[electronIndex]; otree->m_1 = electronMass; otree->q_1 = -1; if (analysisTree.electron_charge[electronIndex]>0) otree->q_1 = 1; otree->iso_1 = isoEleMin; otree->mva_1 = analysisTree.electron_mva_id_nontrigPhys14[electronIndex]; otree->d0_1 = analysisTree.electron_dxy[electronIndex]; otree->dZ_1 = analysisTree.electron_dz[electronIndex]; otree->byCombinedIsolationDeltaBetaCorrRaw3Hits_1 = 0; otree->againstElectronLooseMVA5_1 = 0; otree->againstElectronMediumMVA5_1 = 0; otree->againstElectronTightMVA5_1 = 0; otree->againstElectronVLooseMVA5_1 = 0; otree->againstElectronVTightMVA5_1 = 0; otree->againstMuonLoose3_1 = 0; otree->againstMuonTight3_1 = 0; // filling tau variables otree->pt_2 = analysisTree.tau_pt[tauIndex]; otree->eta_2 = analysisTree.tau_eta[tauIndex]; otree->phi_2 = analysisTree.tau_phi[tauIndex]; otree->q_2 = -1; if (analysisTree.tau_charge[tauIndex]>0) otree->q_2 = 1; otree->mva_2 = log(0); otree->d0_2 = analysisTree.tau_dxy[tauIndex]; otree->dZ_2 = analysisTree.tau_dz[tauIndex]; otree->iso_2 = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[tauIndex]; otree->m_2 = analysisTree.tau_mass[tauIndex]; otree->byCombinedIsolationDeltaBetaCorrRaw3Hits_2 = analysisTree.tau_byCombinedIsolationDeltaBetaCorrRaw3Hits[tauIndex]; otree->againstElectronLooseMVA5_2 = analysisTree.tau_againstElectronLooseMVA5[tauIndex]; otree->againstElectronMediumMVA5_2 = analysisTree.tau_againstElectronMediumMVA5[tauIndex]; otree->againstElectronTightMVA5_2 = analysisTree.tau_againstElectronTightMVA5[tauIndex]; otree->againstElectronVLooseMVA5_2 = analysisTree.tau_againstElectronVLooseMVA5[tauIndex]; otree->againstElectronVTightMVA5_2 = analysisTree.tau_againstElectronVTightMVA5[tauIndex]; otree->againstMuonLoose3_2 = analysisTree.tau_againstMuonLoose3[tauIndex]; otree->againstMuonTight3_2 = analysisTree.tau_againstMuonTight3[tauIndex]; // ditau system TLorentzVector electronLV; electronLV.SetXYZM(analysisTree.electron_px[electronIndex], analysisTree.electron_py[electronIndex], analysisTree.electron_pz[electronIndex], electronMass); TLorentzVector tauLV; tauLV.SetXYZM(analysisTree.tau_px[tauIndex], analysisTree.tau_py[tauIndex], analysisTree.tau_pz[tauIndex], tauMass); TLorentzVector dileptonLV = electronLV + tauLV; otree->m_vis = dileptonLV.M(); otree->pt_tt = dileptonLV.Pt(); // opposite charge otree->os = (otree->q_1 * otree->q_2) < 0.; // dimuon veto otree->dilepton_veto = 0; for (unsigned int ie = 0; ie<analysisTree.electron_count; ++ie) { if (analysisTree.electron_pt[ie]<ptDiElectronVeto) continue; if (fabs(analysisTree.electron_eta[ie])>etaDiElectronVeto) continue; if (fabs(analysisTree.electron_dxy[ie])>dxyElectronCut) continue; if (fabs(analysisTree.electron_dz[ie])>dzElectronCut) continue; if (otree->q_1 * analysisTree.electron_charge[ie] > 0.) continue; float neutralHadIsoEle = analysisTree.electron_neutralHadIso[ie]; float photonIsoEle = analysisTree.electron_photonIso[ie]; float chargedHadIsoEle = analysisTree.electron_chargedHadIso[ie]; float puIsoEle = analysisTree.electron_puIso[ie]; if (isIsoR03) { neutralHadIsoEle = analysisTree.electron_r03_sumNeutralHadronEt[ie]; photonIsoEle = analysisTree.electron_r03_sumPhotonEt[ie]; chargedHadIsoEle = analysisTree.electron_r03_sumChargedHadronPt[ie]; puIsoEle = analysisTree.electron_r03_sumPUPt[ie]; } float neutralIsoEle = neutralHadIsoEle + photonIsoEle - 0.5*puIsoEle; neutralIsoEle = TMath::Max(float(0),neutralIsoEle); float absIsoEle = chargedHadIsoEle + neutralIsoEle; float relIsoEle = absIsoEle/analysisTree.electron_pt[ie]; if(relIsoEle > 0.3) continue; float dr = deltaR(analysisTree.electron_eta[ie],analysisTree.electron_phi[ie], otree->eta_1,otree->phi_1); if(dr<0.15) continue; otree->dilepton_veto = 1; } // extra electron veto otree->extraelec_veto = 0; // extra muon veto otree->extramuon_veto = 0; // svfit variables otree->m_sv = -9999; otree->pt_sv = -9999; otree->eta_sv = -9999; otree->phi_sv = -9999; // pfmet variables otree->met = TMath::Sqrt(analysisTree.pfmet_ex*analysisTree.pfmet_ex + analysisTree.pfmet_ey*analysisTree.pfmet_ey); otree->metphi = TMath::ATan2(analysisTree.pfmet_ey,analysisTree.pfmet_ex); otree->metcov00 = analysisTree.pfmet_sigxx; otree->metcov01 = analysisTree.pfmet_sigxy; otree->metcov10 = analysisTree.pfmet_sigyx; otree->metcov11 = analysisTree.pfmet_sigyy; // bisector of muon and tau transverse momenta float electronUnitX = electronLV.Px()/electronLV.Pt(); float electronUnitY = electronLV.Py()/electronLV.Pt(); float tauUnitX = tauLV.Px()/tauLV.Pt(); float tauUnitY = tauLV.Py()/tauLV.Pt(); float zetaX = electronUnitX + tauUnitX; float zetaY = electronUnitY + tauUnitY; float normZeta = TMath::Sqrt(zetaX*zetaX+zetaY*zetaY); zetaX = zetaX/normZeta; zetaY = zetaY/normZeta; float vectorVisX = electronLV.Px() + tauLV.Px(); float vectorVisY = electronLV.Py() + tauLV.Py(); otree->pzetavis = vectorVisX*zetaX + vectorVisY*zetaY; // choosing mva met unsigned int iMet = 0; for (; iMet<analysisTree.mvamet_count; ++iMet) { if ((int)analysisTree.mvamet_channel[iMet]==2) break; } if (iMet>=analysisTree.mvamet_count){ if(debug) fileOutput<<"MVA MET channel ploblems.."<<std::endl; otree->mvamet = log(0); otree->mvametphi = log(0); otree->mvacov00 = log(0); otree->mvacov01 = log(0); otree->mvacov10 = log(0); otree->mvacov11 = log(0); otree->mt_1 = log(0); otree->mt_2 = log(0); otree->pzetamiss = log(0); } else { float mvamet_x = analysisTree.mvamet_ex[iMet]; float mvamet_y = analysisTree.mvamet_ey[iMet]; float mvamet_x2 = mvamet_x * mvamet_x; float mvamet_y2 = mvamet_y * mvamet_y; otree->mvamet = TMath::Sqrt(mvamet_x2+mvamet_y2); otree->mvametphi = TMath::ATan2(mvamet_y,mvamet_x); otree->mvacov00 = analysisTree.mvamet_sigxx[iMet]; otree->mvacov01 = analysisTree.mvamet_sigxy[iMet]; otree->mvacov10 = analysisTree.mvamet_sigyx[iMet]; otree->mvacov11 = analysisTree.mvamet_sigyy[iMet]; // computation of mt otree->mt_1 = sqrt(2*otree->pt_1*otree->mvamet*(1.-cos(otree->phi_1-otree->mvametphi))); otree->mt_2 = sqrt(2*otree->pt_2*otree->mvamet*(1.-cos(otree->phi_2-otree->mvametphi))); // computation of DZeta variable otree->pzetamiss = analysisTree.pfmet_ex*zetaX + analysisTree.pfmet_ey*zetaY; } // counting jets vector<unsigned int> jets; jets.clear(); vector<unsigned int> jetspt20; jetspt20.clear(); vector<unsigned int> bjets; bjets.clear(); int indexLeadingJet = -1; float ptLeadingJet = -1; int indexSubLeadingJet = -1; float ptSubLeadingJet = -1; int indexLeadingBJet = -1; float ptLeadingBJet = -1; for (unsigned int jet=0; jet<analysisTree.pfjet_count; ++jet) { float absJetEta = fabs(analysisTree.pfjet_eta[jet]); if (absJetEta>jetEtaCut) continue; float jetPt = analysisTree.pfjet_pt[jet]; if (jetPt<jetPtLowCut) continue; float dR1 = deltaR(analysisTree.pfjet_eta[jet],analysisTree.pfjet_phi[jet], otree->eta_1,otree->phi_1); float dR2 = deltaR(analysisTree.pfjet_eta[jet],analysisTree.pfjet_phi[jet], otree->eta_2,otree->phi_2); // pf jet Id float energy = analysisTree.pfjet_e[jet]; float chf = analysisTree.pfjet_chargedhadronicenergy[jet]/energy; float nhf = analysisTree.pfjet_neutralhadronicenergy[jet]/energy; float phf = analysisTree.pfjet_neutralemenergy[jet]/energy; float elf = analysisTree.pfjet_chargedemenergy[jet]/energy; float chm = analysisTree.pfjet_chargedmulti[jet]; float npr = analysisTree.pfjet_chargedmulti[jet] + analysisTree.pfjet_neutralmulti[jet]; bool isPFJetId = (npr>1 && phf<0.99 && nhf<0.99) && (absJetEta>2.4 || (elf<0.99 && chf>0 && chm>0)); // muon fraction missing if(debug) fileOutput<<" jet "<<jet<<": pt="<<analysisTree.pfjet_pt[jet]<<" eta="<<analysisTree.pfjet_eta[jet] <<" dr1="<<dR1<<" dr2="<<dR2<<" npr="<<npr<<" phf="<<phf<<" nhf="<<nhf<<std::endl; // apply dR cut if (dR1<dRJetLeptonCut) continue; if (dR2<dRJetLeptonCut) continue; // apply pf jet Id if (applyJetPfId&&!isPFJetId) continue; // pu jet Id if (applyJetPuId&&!puJetIdLoose(analysisTree.pfjet_eta[jet],analysisTree.pfjet_pu_jet_full_mva[jet])) continue; jetspt20.push_back(jet); if (absJetEta<bJetEtaCut && analysisTree.pfjet_btag[jet][6]>btagCut) { // b-jet bjets.push_back(jet); if (jetPt>ptLeadingBJet) { ptLeadingBJet = jetPt; indexLeadingBJet = jet; } } if (jetPt<jetPtHighCut) continue; jets.push_back(jet); if(jetPt>ptLeadingJet){ ptSubLeadingJet = ptLeadingJet; indexSubLeadingJet = indexLeadingJet; ptLeadingJet = jetPt; indexLeadingJet = jet; } else if(jetPt>ptSubLeadingJet){ ptSubLeadingJet = jetPt; indexSubLeadingJet = jet; } } otree->njets = jets.size(); otree->njetspt20 = jetspt20.size(); otree->nbtag = bjets.size(); otree->bpt = -9999; otree->beta = -9999; otree->bphi = -9999; if (indexLeadingBJet>=0) { otree->bpt = analysisTree.pfjet_pt[indexLeadingBJet]; otree->beta = analysisTree.pfjet_eta[indexLeadingBJet]; otree->bphi = analysisTree.pfjet_phi[indexLeadingBJet]; } otree->jpt_1 = -9999; otree->jeta_1 = -9999; otree->jphi_1 = -9999; otree->jptraw_1 = -9999; otree->jptunc_1 = -9999; otree->jmva_1 = -9999; otree->jlrm_1 = -9999; otree->jctm_1 = -9999; if (indexLeadingJet>=0&&indexSubLeadingJet>=0&&indexLeadingJet==indexSubLeadingJet) cout << "warning : indexLeadingJet ==indexSubLeadingJet = " << indexSubLeadingJet << endl; if (indexLeadingJet>=0) { otree->jpt_1 = analysisTree.pfjet_pt[indexLeadingJet]; otree->jeta_1 = analysisTree.pfjet_eta[indexLeadingJet]; otree->jphi_1 = analysisTree.pfjet_phi[indexLeadingJet]; otree->jptraw_1 = analysisTree.pfjet_pt[indexLeadingJet]*analysisTree.pfjet_energycorr[indexLeadingJet]; otree->jmva_1 = analysisTree.pfjet_pu_jet_full_mva[indexLeadingJet]; } otree->jpt_2 = -9999; otree->jeta_2 = -9999; otree->jphi_2 = -9999; otree->jptraw_2 = -9999; otree->jptunc_2 = -9999; otree->jmva_2 = -9999; otree->jlrm_2 = -9999; otree->jctm_2 = -9999; if (indexSubLeadingJet>=0) { otree->jpt_2 = analysisTree.pfjet_pt[indexSubLeadingJet]; otree->jeta_2 = analysisTree.pfjet_eta[indexSubLeadingJet]; otree->jphi_2 = analysisTree.pfjet_phi[indexSubLeadingJet]; otree->jptraw_2 = analysisTree.pfjet_pt[indexSubLeadingJet]*analysisTree.pfjet_energycorr[indexSubLeadingJet]; otree->jmva_2 = analysisTree.pfjet_pu_jet_full_mva[indexSubLeadingJet]; } otree->mjj = -9999; otree->jdeta = -9999; otree->njetingap = 0; if (indexLeadingJet>=0 && indexSubLeadingJet>=0) { TLorentzVector jet1; jet1.SetPxPyPzE(analysisTree.pfjet_px[indexLeadingJet], analysisTree.pfjet_py[indexLeadingJet], analysisTree.pfjet_pz[indexLeadingJet], analysisTree.pfjet_e[indexLeadingJet]); TLorentzVector jet2; jet2.SetPxPyPzE(analysisTree.pfjet_px[indexSubLeadingJet], analysisTree.pfjet_py[indexSubLeadingJet], analysisTree.pfjet_pz[indexSubLeadingJet], analysisTree.pfjet_e[indexSubLeadingJet]); otree->mjj = (jet1+jet2).M(); otree->jdeta = abs(analysisTree.pfjet_eta[indexLeadingJet]- analysisTree.pfjet_eta[indexSubLeadingJet]); float etamax = analysisTree.pfjet_eta[indexLeadingJet]; float etamin = analysisTree.pfjet_eta[indexSubLeadingJet]; if (etamax<etamin) { float tmp = etamax; etamax = etamin; etamin = tmp; } for (unsigned int jet=0; jet<jetspt20.size(); ++jet) { int index = jetspt20.at(jet); float etaX = analysisTree.pfjet_eta[index]; if (index!=indexLeadingJet&&index!=indexSubLeadingJet&&etaX>etamin&&etaX<etamax) otree->njetingap++; } } otree->Fill(); selEvents++; } // end of file processing (loop over events in one file) nFiles++; delete _tree; file_->Close(); delete file_; } std::cout << std::endl; int allEvents = int(inputEventsH->GetEntries()); std::cout << "Total number of input events = " << allEvents << std::endl; std::cout << "Total number of events in Tree = " << nEvents << std::endl; std::cout << "Total number of selected events = " << selEvents << std::endl; std::cout << std::endl; file->cd(""); file->Write(); file->Close(); delete file; }
void HHbbbbMikeBase(int wMs,int wM, string st,string st2,string option=""){ //1=signal ,0=QCD ,2=data----------------------------------------------------------- int nameRoot=1; if(st2.find("QCD")!= std::string::npos)nameRoot=0; if(st2.find("data")!= std::string::npos)nameRoot=2; //---------------------Thea correction TFile *f3; f3=TFile::Open("puppiCorr.root"); TF1 * puppisd_corrGEN,* puppisd_corrRECO_cen,* puppisd_corrRECO_for; puppisd_corrGEN=(TF1 *) f3->FindObjectAny("puppiJECcorr_gen"); puppisd_corrRECO_cen=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_0eta1v3"); puppisd_corrRECO_for=(TF1 *) f3->FindObjectAny("puppiJECcorr_reco_1v3eta2v5"); TF1* tf1[3]; tf1[0]=puppisd_corrGEN; tf1[1]=puppisd_corrRECO_cen; tf1[2]=puppisd_corrRECO_for; //option----------------------------------------------------------- int JESOption=0; if(option.find("JESUp")!= std::string::npos)JESOption=1; if(option.find("JESDown")!= std::string::npos)JESOption=2; if(option.find("BtagUp")!= std::string::npos)JESOption=3; if(option.find("BtagDown")!= std::string::npos)JESOption=4; if(option.find("tau21Up")!= std::string::npos)JESOption=5; if(option.find("tau21Down")!= std::string::npos)JESOption=6; cout<<"JESOption = "<<JESOption<<endl; bool printHighPtSubjet=0; bool isFast=1; //tuple tree and cutflow variables------------------------------------------------------------------------------------ TFile *f; TTree *tree; int nPass[20]={0},total=0,dataPassingcsc=0; double nPassB[6]={0}; double fixScaleNum[2]={0}; //using for Btag Eff ----------------------------------------------------------------------------- string btagsystematicsType="central"; if(JESOption==3)btagsystematicsType="up"; else if(JESOption==4)btagsystematicsType="down"; BTagCalibration calib("CSVv2L", "subjet_CSVv2_ichep.csv"); BTagCalibrationReader LF(BTagEntry::OP_LOOSE,"central", {"up", "down"}); BTagCalibrationReader HFC(BTagEntry::OP_LOOSE, "central", {"up", "down"}); // other sys types BTagCalibrationReader HF(BTagEntry::OP_LOOSE,"central",{"up", "down"}); // other sys types LF.load(calib, BTagEntry::FLAV_UDSG, // btag flavour "incl"); // measurement type HFC.load(calib, BTagEntry::FLAV_C, // btag flavour "lt"); // measurement type HF.load(calib, BTagEntry::FLAV_B, // btag flavour "lt"); // measurement type TFile *f1; if(nameRoot==2)f1=TFile::Open("btagEffSource/data.root"); else if (nameRoot!=2 && (JESOption==0||JESOption==3||JESOption==4||JESOption==5||JESOption==6))f1=TFile::Open(Form("btagEffSource/%s.root",st2.data())); else if (nameRoot!=2 && JESOption==1)f1=TFile::Open(Form("btagEffSource/%s_JESUp.root",st2.data())); else if (nameRoot!=2 && JESOption==2)f1=TFile::Open(Form("btagEffSource/%s_JESDown.root",st2.data())); TH1D* th1[6]; string btaggingEff[6]={"effD_b","effN_b","effD_c","effN_c","effD_l","effN_l"}; for(int i=0;i<6;i++){ th1[i]=(TH1D*)f1->FindObjectAny(Form("%s_1d",btaggingEff[i].data())); if(i==1||i==3||i==5)th1[i]->Divide(th1[i-1]); } //check for zero btagging SF---------------------------------------------------------------------------------------- TH2D* th3[6]; th3[0]=new TH2D("zeroSF_b","zeroSF_b",200,0,2000,60,-3,3); th3[1]=new TH2D("zeroSF_c","zeroSF_c",200,0,2000,60,-3,3); th3[2]=new TH2D("zeroSF_l","zeroSF_l",200,0,2000,60,-3,3); th3[3]=new TH2D("SF_vs_Pt_b","SF_vs_Pt_b",120,0,1200,40,0.8,1.2); th3[4]=new TH2D("SF_vs_Pt_c","SF_vs_Pt_c",120,0,1200,40,0.8,1.2); th3[5]=new TH2D("SF_vs_Pt_l","SF_vs_Pt_l",120,0,1200,40,0.8,1.2); for(int i=0;i<6;i++)th3[i]->Sumw2(); //check for high btagging SF---------------------------------------------------------------------------------------- TH1D* th4[14]; string SF_jet_sub[8]={"SF_jet0_sub0_pass","SF_jet0_sub1_pass","SF_jet1_sub0_pass","SF_jet1_sub1_pass","SF_jet0_sub0_fail","SF_jet0_sub1_fail","SF_jet1_sub0_fail","SF_jet1_sub1_fail"}; for(int i=0;i<8;i++)th4[i]=new TH1D(Form("%s",SF_jet_sub[i].data()),Form("%s",SF_jet_sub[i].data()),40,0.8,1.2); string weightName[6]={"weight","weight_0b","weight_1b","weight_2b","weight_2b_ll","weight_2b_onel"}; for(int i=0;i<6;i++)th4[i+8]=new TH1D(Form("%s",weightName[i].data()),Form("%s",weightName[i].data()),40,0,2); for(int i=0;i<14;i++)th4[i]->Sumw2(); //saving variables---------------------------------------------------------------------------------------- TH1D * th5[300],* th6[300]; for(int i=0;i<2;i++){ for(int j=0;j<2;j++){ for(int k=0;k<5;k++){ th5[(i*2+j)*5+k]=new TH1D(Form("Pt_j%d_sj%d_%db",i,j,k),Form("Pt_j%d_sj%d_%db",i,j,k),200,0,2000); th5[(i*2+j)*5+k+20]=new TH1D(Form("Eta_j%d_sj%d_%db",i,j,k),Form("Eta_j%d_sj%d_%db",i,j,k),60,-3,3); th5[(i*2+j)*5+k+85]=new TH1D(Form("subCSV_j%d_sj%d_%db",i,j,k),Form("subCSV_j%d_sj%d_%db",i,j,k),20,0,1); th5[(i*2+j)*5+k+194]=new TH1D(Form("subCSVCut_j%d_sj%d_%db",i,j,k),Form("subCSVCut_j%d_sj%d_%db",i,j,k),20,0,1); } } for(int k=0;k<5;k++){ th5[i*5+k+40]=new TH1D(Form("deltaR_j%d_%db",i,k),Form("deltaR_j%d_%db",i,k),20,0,1); th5[i*5+k+50]=new TH1D(Form("Pt_j%d_%db",i,k),Form("Pt_j%d_%db",i,k),200,0,2000); th5[i*5+k+60]=new TH1D(Form("Eta_j%d_%db",i,k),Form("Eta_j%d_%db",i,k),60,-3,3); th5[i*5+k+70]=new TH1D(Form("prMassL2L3_j%d_%db",i,k),Form("prMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+105]=new TH1D(Form("tau21_j%d_%db",i,k),Form("tau21_j%d_%db",i,k),25,0,1); th5[i*5+k+120]=new TH1D(Form("PuppiSDMassL2L3_j%d_%db",i,k),Form("PuppiSDMassL2L3_j%d_%db",i,k),15,90,150); th5[i*5+k+130]=new TH1D(Form("puppiTau21_j%d_%db",i,k),Form("puppiTau21_j%d_%db",i,k),25,0,1); th5[i*5+k+140]=new TH1D(Form("prMass_j%d_%db",i,k),Form("prMass_j%d_%db",i,k),15,90,150); th5[i*5+k+150]=new TH1D(Form("PuppiSDMass_j%d_%db",i,k),Form("PuppiSDMass_j%d_%db",i,k),15,90,150); th5[i*5+k+170]=new TH1D(Form("doubleSV_j%d_%db",i,k),Form("doubleSV_j%d_%db",i,k),40,-1,1); th5[i*5+k+184]=new TH1D(Form("FatSV_j%d_%db",i,k),Form("FatSV_j%d_%db",i,k),20,0,1); th5[i*5+k+250]=new TH1D(Form("PuppiSDMassThea_j%d_%db",i,k),Form("PuppiSDMassThea_j%d_%db",i,k),15,90,150); } } for(int k=0;k<5;k++){ th5[k+80]=new TH1D(Form("totalMass_%db",k),Form("totalMass_%db",k),200,1000,5000); th5[k+115]=new TH1D(Form("deltaEta_%db",k),Form("deltaEta_%db",k),40,0,2); th5[k+160]=new TH1D(Form("logPt_%db",k),Form("logPt_%db",k),70,0,7); th5[k+165]=new TH1D(Form("totalMassRed_%db",k),Form("totalMassRed_%db",k),200,1000,5000); } th5[180]= new TH1D("h_nvtx","h_nvtx",60,0,60); th5[181]= new TH1D("h_ntrue","h_ntrue",60,0,60); th5[182]= new TH1D("h_nvtx_cut","h_nvtx_cut",60,0,60); th5[183]= new TH1D("h_ntrue_cut","h_ntrue_cut",60,0,60); string prMass_no[4]={"prMass","prMassL2L3","PuppiSDMass","PuppiSDMassL2L3"}; string tau21_no[2]={"tau21","puppiTau21"}; for (int i=0;i<4;i++){ th5[214+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",prMass_no[i].data()),Form("%s_j0_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[215+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",prMass_no[i].data()),Form("%s_j1_noPr_noTau21",prMass_no[i].data()),200,0,200); th5[222+i*2]=new TH1D(Form("%s_j0_noPr",prMass_no[i].data()),Form("%s_j0_noPr",prMass_no[i].data()),200,0,200); th5[223+i*2]=new TH1D(Form("%s_j1_noPr",prMass_no[i].data()),Form("%s_j1_noPr",prMass_no[i].data()),200,0,200); th5[230+i*2]=new TH1D(Form("%s_j0_noTau21",prMass_no[i].data()),Form("%s_j0_noTau21",prMass_no[i].data()),15,90,150); th5[231+i*2]=new TH1D(Form("%s_j1_noTau21",prMass_no[i].data()),Form("%s_j1_noTau21",prMass_no[i].data()),15,90,150); } for (int i=0;i<2;i++){ th5[238+i*2]=new TH1D(Form("%s_j0_noPr_noTau21",tau21_no[i].data()),Form("%s_j0_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[239+i*2]=new TH1D(Form("%s_j1_noPr_noTau21",tau21_no[i].data()),Form("%s_j1_noPr_noTau21",tau21_no[i].data()),25,0,1); th5[242+i*2]=new TH1D(Form("%s_j0_noPr",tau21_no[i].data()),Form("%s_j0_noPr",tau21_no[i].data()),25,0,1); th5[243+i*2]=new TH1D(Form("%s_j1_noPr",tau21_no[i].data()),Form("%s_j1_noPr",tau21_no[i].data()),25,0,1); th5[246+i*2]=new TH1D(Form("%s_j0_noTau21",tau21_no[i].data()),Form("%s_j0_noTau21",tau21_no[i].data()),25,0,1); th5[247+i*2]=new TH1D(Form("%s_j1_noTau21",tau21_no[i].data()),Form("%s_j1_noTau21",tau21_no[i].data()),25,0,1); } string flavor[4]={"bb","b","cc","udscg"}; for (int i=0;i<4;i++){ th5[260+i]=new TH1D(Form("Pt_j0_0b_%s",flavor[i].data()),Form("Pt_j0_0b_%s",flavor[i].data()),200,0,2000); th5[264+i]=new TH1D(Form("Pt_j0_1b_%s",flavor[i].data()),Form("Pt_j0_1b_%s",flavor[i].data()),200,0,2000); th5[268+i]=new TH1D(Form("Pt_j0_2b_%s",flavor[i].data()),Form("Pt_j0_2b_%s",flavor[i].data()),200,0,2000); th5[272+i]=new TH1D(Form("Pt_j0_DSV_%s",flavor[i].data()),Form("Pt_j0_DSV_%s",flavor[i].data()),200,0,2000); } for(int i=0;i<276;i++){ th6[i]=(TH1D* )th5[i]->Clone(Form("%ss",th5[i]->GetTitle())); th5[i]->Sumw2(); th6[i]->Sumw2(); } //pileup uncertainty---------------------------------------------------------------------------------------- TH1D* th7[14]; th7[0]=new TH1D("totalMass","totalMass",200,1000,5000); th7[1]=new TH1D("totalMass_pileup_up","totalMass_pileup_up",200,1000,5000); th7[2]=new TH1D("totalMass_pileup_down","totalMass_pileup_down",200,1000,5000); th7[3]=new TH1D("pileupEff","pileupEff",15,0.5,15.5); double totalPileup[3]={0},passPileup[3]={0}; standalone_LumiReWeighting LumiWeights_central(0),LumiWeights_up(1),LumiWeights_down(-1); //PDF uncertainty th7[4]=new TH1D("PDFEff","PDFEff",101,0.5,101.5); double passPDF[101]={0},totalPDF[101]={0}; //QCD uncertainty for(int i=5;i<14;i++)th7[i]=new TH1D(Form("uns_QCD_%d",i-5),Form("uns_QCD_%d",i-5),200,1000,5000); //NCUtuple loop---------------------------------------------------------------------------------------- for (int w=wMs;w<wM;w++){ if(w%20==0)cout<<w<<endl; //Get ntuple---------------------------------------------------------------------------------------- if (nameRoot!=1)f = TFile::Open(Form("%s%d.root",st.data(),w)); else f = TFile::Open(st.data()); if (!f || !f->IsOpen())continue; TDirectory * dir; if (nameRoot!=1)dir = (TDirectory*)f->Get(Form("%s%d.root:/tree",st.data(),w)); else dir = (TDirectory*)f->Get(Form("%s:/tree",st.data())); dir->GetObject("treeMaker",tree); TreeReader data(tree); total+=data.GetEntriesFast(); for(Long64_t jEntry=0; jEntry<data.GetEntriesFast() ;jEntry++){//event loop---------------------------------------------------------------------------------------- data.GetEntry(jEntry); Int_t nVtx = data.GetInt("nVtx"); Float_t ntrue= data.GetFloat("pu_nTrueInt"); //Float_t* pdfscaleSysWeights= data.GetPtrFloat("pdfscaleSysWeights"); th5[180]->Fill(nVtx); th5[181]->Fill(ntrue); double PU_weight[3]={1,1,1}; if(nameRoot!=2){ if(ntrue<51){ PU_weight[0] = LumiWeights_central.weight(ntrue); PU_weight[1]= LumiWeights_up.weight(ntrue); PU_weight[2] = LumiWeights_down.weight(ntrue); } else { PU_weight[0] = LumiWeights_central.weight(50); PU_weight[1] = LumiWeights_up.weight(50); PU_weight[2]= LumiWeights_down.weight(50); } } th6[180]->Fill(nVtx,PU_weight[0]); th6[181]->Fill(ntrue,PU_weight[0]); fixScaleNum[0]+=PU_weight[0]; for(int i=0;i<3;i++)totalPileup[i]+=PU_weight[i]; for(int i=0;i<101;i++)totalPDF[i]+=PU_weight[0]; //1.trigger std::string* trigName = data.GetPtrString("hlt_trigName"); vector<bool> &trigResult = *((vector<bool>*) data.GetPtr("hlt_trigResult")); bool passTrigger=false; for(int it=0; it< data.GetPtrStringSize(); it++){ std::string thisTrig= trigName[it]; bool results = trigResult[it]; if( ((thisTrig.find("HLT_PFHT800")!= std::string::npos ) && results==1)){ passTrigger=true; break; } } if(!passTrigger && nameRoot==2)continue;nPass[1]++; Float_t HT= data.GetFloat("HT"); if(nameRoot!=2 && HT<800)continue; int nFATJet = data.GetInt("FATnJet"); TClonesArray* fatjetP4 = (TClonesArray*) data.GetPtrTObject("FATjetP4"); float* FATjetCorrUncUp = data.GetPtrFloat("FATjetCorrUncUp"); float* FATjetCorrUncDown = data.GetPtrFloat("FATjetCorrUncDown"); vector<bool> &FATjetPassIDTight = *((vector<bool>*) data.GetPtr("FATjetPassIDTight")); //2.nJets if(nFATJet<2)continue;nPass[2]++; TLorentzVector* thisJet ,* thatJet; if (JESOption==1){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1+FATjetCorrUncUp[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1+FATjetCorrUncUp[1] ); thisJet= &test0; thatJet= &test1; } else if (JESOption==2){ TLorentzVector test0= (*((TLorentzVector*)fatjetP4->At(0)))*(1-FATjetCorrUncDown[0] ); TLorentzVector test1= (*((TLorentzVector*)fatjetP4->At(1)))*(1-FATjetCorrUncDown[1] ); thisJet= &test0; thatJet= &test1; } else{ thisJet= (TLorentzVector*)fatjetP4->At(0); thatJet = (TLorentzVector*)fatjetP4->At(1); } //3. Pt if(thisJet->Pt()<200||thatJet->Pt()<200)continue; nPass[3]++; //4tightId----------------------------------------- if(FATjetPassIDTight[0]==0||FATjetPassIDTight[1]==0)continue; nPass[4]++; //5. Eta----------------------------------------- if(fabs(thisJet->Eta())>2.4||fabs(thatJet->Eta())>2.4)continue; nPass[5]++; //6. DEta----------------------------------------- float dEta = fabs(thisJet->Eta()-thatJet->Eta()); if(dEta>1.3)continue; nPass[6]++; //7. Mjj----------------------------------------- float mjj = (*thisJet+*thatJet).M(); float mjjRed = (*thisJet+*thatJet).M()+250-thisJet->M()-thatJet->M(); //if(mjjRed<1000)continue; nPass[7]++; //8. fatjetPRmassL2L3Corr----------------------------------------- Float_t* fatjetPRmassL2L3Corr = data.GetPtrFloat("FATjetPRmassL2L3Corr"); vector<float> *subjetSDCSV = data.GetPtrVectorFloat("FATsubjetSDCSV"); vector<Int_t> *FATsubjetSDHadronFlavor = data.GetPtrVectorInt("FATsubjetSDHadronFlavor"); int nbtag=0,nbtag2=0; float MaxBJetPt = 670., MaxLJetPt = 1000.; double sf[2][2],eta[2],pt[2],dr[2],subjetPt[2][2],subjetEta[2][2],eff[2][2],btaggingscaleFactor=1; pt[0]=thisJet->Pt(); pt[1]=thatJet->Pt(); double scaleFactor=PU_weight[0]*btaggingscaleFactor; Float_t* fatjetTau1 = data.GetPtrFloat("FATjetTau1"); Float_t* fatjetTau2 = data.GetPtrFloat("FATjetTau2"); Float_t* FATjetPuppiTau1 = data.GetPtrFloat("FATjetPuppiTau1"); Float_t* FATjetPuppiTau2 = data.GetPtrFloat("FATjetPuppiTau2"); double tau21[2]; tau21[0]=(fatjetTau2[0]/fatjetTau1[0]),tau21[1]=(fatjetTau2[1]/fatjetTau1[1]); double puppiTau21[2]; puppiTau21[0]=(FATjetPuppiTau2[0]/FATjetPuppiTau1[0]),puppiTau21[1]=(FATjetPuppiTau2[1]/FATjetPuppiTau1[1]); if(fatjetPRmassL2L3Corr[0]<50||fatjetPRmassL2L3Corr[0]>300)continue; if(fatjetPRmassL2L3Corr[1]<50||fatjetPRmassL2L3Corr[1]>300)continue; nPass[8]++; //9.----------------------------------------- if(tau21[0]>0.6 || tau21[1]>0.6) continue; nPass[9]++; Int_t* FATjetHadronFlavor = data.GetPtrInt("FATjetHadronFlavor"); if(subjetSDCSV[0][0]<0.605 && subjetSDCSV[0][1]<0.605){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[260]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[261]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[262]->Fill(thisJet->Pt()); else th5[263]->Fill(thisJet->Pt()); } else if (subjetSDCSV[0][0]>0.605 && subjetSDCSV[0][1]>0.605){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[268]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[269]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[270]->Fill(thisJet->Pt()); else th5[271]->Fill(thisJet->Pt()); } else { if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[264]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[265]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[266]->Fill(thisJet->Pt()); else th5[267]->Fill(thisJet->Pt()); } fixScaleNum[1]+=PU_weight[0]; Float_t* ADDjet_DoubleSV = data.GetPtrFloat("ADDjet_DoubleSV"); Float_t FATjet_DoubleSV[2]={0}; Int_t ADDnJet = data.GetInt("ADDnJet"); bool matchThis=0,matchThat=0; TClonesArray* ADDjetP4 = (TClonesArray*) data.GetPtrTObject("ADDjetP4"); for(int i=0;i<ADDnJet;i++){ TLorentzVector* thisAddJet ; thisAddJet= (TLorentzVector*)ADDjetP4->At(i); if(!matchThis && thisAddJet->DeltaR(*thisJet)<0.8){ matchThis=1; FATjet_DoubleSV[0]=ADDjet_DoubleSV[i]; continue; } if(!matchThat && thisAddJet->DeltaR(*thatJet)<0.8){ matchThat=1; FATjet_DoubleSV[1]=ADDjet_DoubleSV[i]; } if(matchThis&& matchThat){ //cout<<"match"<<FATjet_DoubleSV[0]<<","<<FATjet_DoubleSV[0]<<endl; break; } } if(FATjet_DoubleSV[0]>-0.8){ if(FATjetHadronFlavor[0]==5 && FATsubjetSDHadronFlavor[0][0]==5 && FATsubjetSDHadronFlavor[0][1]==5)th5[272]->Fill(thisJet->Pt()); else if(FATjetHadronFlavor[0]==5 && (FATsubjetSDHadronFlavor[0][0]==5 || FATsubjetSDHadronFlavor[0][1]==5))th5[273]->Fill(thisJet->Pt()); else if (FATjetHadronFlavor[0]==4 && FATsubjetSDHadronFlavor[0][0]==4 && FATsubjetSDHadronFlavor[0][1]==4)th5[274]->Fill(thisJet->Pt()); else th5[275]->Fill(thisJet->Pt()); } }//end event loop---------------------------------------------------------------------------------------- } //end ntuple loop---------------------------------------------------------------------------------------- cout<<"entries="<<total<<endl; for(int i=0;i<6;i++)cout<<"nPassB["<<i<<"]="<<nPassB[i]<<endl; for(int i=0;i<16;i++)cout<<"nPass["<<i<<"]="<<nPass[i]<<endl; for(int i=0;i<3;i++)th7[3]->SetBinContent(i+1,passPileup[i]/totalPileup[i]); for(int i=0;i<101;i++)th7[4]->SetBinContent(i+1,passPDF[i]/totalPDF[i]); TH1D * th2o=new TH1D("Nbtagjet","Nbtagjet",5,-0.5,4.5); for (int i=0;i<5;i++){ if(nameRoot==2 && i>2)continue; th2o->SetBinContent(i+1,nPass[i+10]); } TH1D * th2ob=new TH1D("NbtagjetB","NbtagjetB",5,-0.5,4.5); for (int i=0;i<5;i++){ if(nameRoot==2 && i>2)continue; th2ob->SetBinContent(i+1,nPassB[i]); } TH1D * fixScale=new TH1D("fixScale","fixScale",2,-0.5,1.5); fixScale->SetBinContent(1,fixScaleNum[0]); fixScale->SetBinContent(2,fixScaleNum[1]); TH1D * cutflow=new TH1D("cutflow","cutflow",16,0.5,16.5); cutflow->SetBinContent(1,total); if(nameRoot==2)for(int ii=1;ii<14;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); else for(int ii=1;ii<16;ii++)cutflow->SetBinContent(ii+1,nPass[ii-1]); TFile* outFile = new TFile(Form("root_file_mike/%s.root",st2.data()),"recreate"); th2o->Write(); th2ob->Write(); fixScale->Write(); cutflow->Write(); for(int i=0;i<6;i++)th3[i]->Write(); for(int i=0;i<14;i++)th4[i]->Write(); for(int i=0;i<276;i++){ th5[i]->Write(); th6[i]->Write(); } for(int i=0;i<14;i++)th7[i]->Write(); outFile->Close(); }
int process(TString nameChain, TString file, int iFile, int nEntries, TString dirOut, ofstream& outlog, int iJson, TString RunPhase, bool debug) { // OUTPUT FILE // ostringstream ossi(""); ossi << iFile ; // std::cout<<"ossi is what?? "<<ossi<<std::endl; // std::cout<<"ossi is what?? "<<ossi<<std::endl; // std::cout<<"ossi.str() is what?? "<<ossi.str()<<std::endl; TString name=(TString)("elepairs_"+ossi.str()+".root"); TFile *outfile = new TFile(name,"RECREATE"); ossi.str(""); // INPUT TREE // TChain * myChain = new TChain(nameChain); myChain->Add(file); int nEvent, nRun, nLumi ; // Vertices // int _vtx_N; double _vtx_x[200], _vtx_y[200], _vtx_z[200]; double _vtx_normalizedChi2[200], _vtx_ndof[200], _vtx_nTracks[200], _vtx_d0[200]; // Trigger Paths // int trig_hltInfo[250]; int _trig_isEleHLTpath; int trig_HLT_path[4]; // unbias, EG5, EG8, EG12 char trig_fired_names[5000]; // vector<string> m_HLT_pathsV; vector<string> m_HLT_triggered; vector<int> m_HLT_pathsV_check; // m_HLT_pathsV.clear(); // m_HLT_pathsV_check.clear(); // for(int iP=0 ; iP<(int)HLT_paths_.size() ; iP++) { // m_HLT_pathsV.push_back( HLT_paths_[iP]); // m_HLT_pathsV_check.push_back(0); // } // Electrons TClonesArray * electrons = new TClonesArray ("TLorentzVector"); int ele_N, sc_hybrid_N; int ele_outOfTimeSeed[10],ele_severityLevelSeed[10]; double ele_he[10], ele_sigmaietaieta[10]; double ele_hcalDepth1TowerSumEt_dr03[10], ele_hcalDepth2TowerSumEt_dr03[10]; double ele_ecalRecHitSumEt_dr03[10], ele_tkSumPt_dr03[10]; double ele_sclEta[10], ele_sclEt[10]; //double ecalIsoRel03,hcalIsoRel03,trackIsoRel03; double ele_deltaphiin[10], ele_deltaetain[10]; double ele_conv_dist[10], ele_conv_dcot[10]; double ele_fbrem[10]; int ele_expected_inner_hits[10]; //int ele_ambiguousGsfTracks[10]; int ele_isConversion[10]; int ele_echarge[10]; // int ele_RCTeta[10], ele_RCTphi[10], ele_RCTL1iso[10], ele_RCTL1noniso[10], ele_RCTL1iso_M[10], ele_RCTL1noniso_M[10]; int ele_TTetaVect[10][50], ele_TTphiVect[10][50]; double ele_TTetVect[10][50]; int ele_RCTetaVect[10][10], ele_RCTphiVect[10][10], ele_RCTL1isoVect[10][10], ele_RCTL1nonisoVect[10][10],ele_RCTL1isoVect_M[10][10], ele_RCTL1nonisoVect_M[10][10]; double ele_RCTetVect[10][10]; // TP info const int nTow = 4032; int trig_tower_N,trig_tower_ieta[nTow],trig_tower_iphi[nTow],trig_tower_adc[nTow],trig_tower_sFGVB[nTow]; int trig_tower_N_modif,trig_tower_ieta_modif[nTow],trig_tower_iphi_modif[nTow],trig_tower_adc_modif[nTow],trig_tower_sFGVB_modif[nTow]; int trig_tower_N_emul,trig_tower_ieta_emul[nTow],trig_tower_iphi_emul[nTow],trig_tower_adc_emul[nTow][5],trig_tower_sFGVB_emul[nTow][5]; // HCAL TP int trig_tower_hcal_N, trig_tower_hcal_ieta[4032], trig_tower_hcal_iphi[4032], trig_tower_hcal_FG[4032],trig_tower_hcal_et[4032]; int trig_L1emIso_N, trig_L1emNonIso_N, trig_L1emIso_N_M, trig_L1emNonIso_N_M; // L1 candidates info int trig_L1emIso_ieta[4], trig_L1emIso_iphi[4], trig_L1emIso_rank[4]; int trig_L1emNonIso_ieta[4], trig_L1emNonIso_iphi[4], trig_L1emNonIso_rank[4]; int trig_L1emIso_ieta_M[4], trig_L1emIso_iphi_M[4], trig_L1emIso_rank_M[4]; int trig_L1emNonIso_ieta_M[4], trig_L1emNonIso_iphi_M[4], trig_L1emNonIso_rank_M[4]; // L1 prefiring int trig_preL1emIso_N; int trig_preL1emNonIso_N; int trig_preL1emIso_ieta[4], trig_preL1emIso_iphi[4], trig_preL1emIso_rank[4]; int trig_preL1emNonIso_ieta[4], trig_preL1emNonIso_iphi[4],trig_preL1emNonIso_rank[4]; // L1 postfiring int trig_postL1emIso_N; int trig_postL1emNonIso_N; int trig_postL1emIso_ieta[4], trig_postL1emIso_iphi[4], trig_postL1emIso_rank[4]; int trig_postL1emNonIso_ieta[4], trig_postL1emNonIso_iphi[4],trig_postL1emNonIso_rank[4]; // Masking int trig_nMaskedRCT, trig_nMaskedCh; int trig_iMaskedRCTeta[100], trig_iMaskedRCTphi[100], trig_iMaskedRCTcrate[100], trig_iMaskedTTeta[100], trig_iMaskedTTphi[100]; int trig_strip_mask_N; int trig_strip_mask_TTieta[1000], trig_strip_mask_TTiphi[1000], trig_strip_mask_status[1000], trig_strip_mask_StripID[1000], trig_strip_mask_PseudoStripID[1000], trig_strip_mask_TccID[1000], trig_strip_mask_CCU[1000], trig_strip_mask_xtal_ix[1000][5], trig_strip_mask_xtal_iy[1000][5], trig_strip_mask_xtal_iz[1000][5]; int trig_xtal_mask_N; // [EB+EE] int trig_xtal_mask_ieta[1000],trig_xtal_mask_iphi[1000], // for EE : xtal ieta->ix ; iphi -> iy trig_xtal_mask_TTieta[1000],trig_xtal_mask_TTiphi[1000], // but for EE towers, still ieta, iphi... trig_xtal_mask_Rieta[1000],trig_xtal_mask_Riphi[1000], trig_xtal_mask_status[1000], trig_xtal_mask_EBEE[1000]; // EBEE = {0,1} => 0=EB ; 1=EE //double trig_xtal_mask_eT[1000]; // INITIALIZATION // // // Global nEvent = 0; nRun = 0; nLumi = 0; // // Vertices _vtx_N = 0; for(int iv=0;iv<200;iv++) { _vtx_normalizedChi2[iv] = 0.; _vtx_ndof[iv] = 0.; _vtx_nTracks[iv] = 0.; _vtx_d0[iv] = 0.; _vtx_x[iv] = 0.; _vtx_y[iv] = 0.; _vtx_z[iv] = 0.; } // // L1 candidates trig_L1emIso_N = 0; trig_L1emNonIso_N = 0; trig_preL1emIso_N = 0; trig_preL1emNonIso_N = 0; trig_postL1emIso_N = 0; trig_postL1emNonIso_N = 0; // for(int il1=0 ; il1<4 ; il1++) { trig_L1emIso_ieta[il1] = 0; trig_L1emIso_iphi[il1] = 0; trig_L1emIso_rank[il1] = 0; trig_L1emNonIso_ieta[il1] = 0; trig_L1emNonIso_iphi[il1] = 0; trig_L1emNonIso_rank[il1] = 0; trig_preL1emIso_ieta[il1] = 0; trig_preL1emIso_iphi[il1] = 0; trig_preL1emIso_rank[il1] = 0; trig_preL1emNonIso_ieta[il1] = 0; trig_preL1emNonIso_iphi[il1] = 0; trig_preL1emNonIso_rank[il1] = 0; trig_postL1emIso_ieta[il1] = 0; trig_postL1emIso_iphi[il1] = 0; trig_postL1emIso_rank[il1] = 0; trig_postL1emNonIso_ieta[il1] = 0; trig_postL1emNonIso_iphi[il1] = 0; trig_postL1emNonIso_rank[il1] = 0; } // // Trigger towers trig_tower_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta[iTow] = trig_tower_iphi[iTow] = -999; trig_tower_adc[iTow] = trig_tower_sFGVB[iTow] = -999; } trig_tower_N_modif = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_modif[iTow] = trig_tower_iphi_modif[iTow] = -999; trig_tower_adc_modif[iTow] = trig_tower_sFGVB_modif[iTow] = -999; } trig_tower_N_emul = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_emul[iTow] = trig_tower_iphi_emul[iTow] = -999; for(int i=0 ; i<5 ; i++) trig_tower_adc_emul[iTow][i] = trig_tower_sFGVB_emul[iTow][i] = -999; } trig_tower_hcal_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_hcal_ieta[iTow] = trig_tower_hcal_iphi[iTow] = -999; trig_tower_hcal_FG[iTow] = trig_tower_hcal_et[iTow] = -999; } // // Masked Towers trig_nMaskedRCT=0; trig_nMaskedCh=0; // for (int ii=0;ii<100;ii++) { trig_iMaskedRCTeta[ii] = -999; trig_iMaskedRCTphi[ii] = -999; trig_iMaskedRCTcrate[ii] = -999; trig_iMaskedTTeta[ii] = -999; trig_iMaskedTTphi[ii] = -999; } // // Masked strip/xtals trig_strip_mask_N = 0; trig_xtal_mask_N = 0; // for(int i=0 ; i<1000 ; i++) { trig_strip_mask_TTieta[i] = -999; trig_strip_mask_TTiphi[i] = -999; trig_strip_mask_status[i] = -999; trig_strip_mask_StripID[i] = -999; trig_strip_mask_PseudoStripID[i] = -999; trig_strip_mask_TccID[i] = -999; trig_strip_mask_CCU[i] = -999; // for(int j=0 ; j<5 ; j++) { trig_strip_mask_xtal_ix[i][j] = -999; trig_strip_mask_xtal_iy[i][j] = -999; trig_strip_mask_xtal_iz[i][j] = -999; } trig_xtal_mask_ieta[i] = -999; trig_xtal_mask_iphi[i] = -999; trig_xtal_mask_TTieta[i] = -999; trig_xtal_mask_TTiphi[i] = -999; trig_xtal_mask_Rieta[i] = -999; trig_xtal_mask_Riphi[i] = -999; trig_xtal_mask_status[i] = -999; trig_xtal_mask_EBEE[i] = -999; } // Disable useless branches //myChain->SetBranchStatus("spike_*",0); //myChain->SetBranchStatus("vtx_*",0); //myChain->SetBranchStatus("skim_*",0); //myChain->SetBranchStatus("trig_pre*",0); //myChain->SetBranchStatus("trig_post*",0); //myChain->SetBranchStatus("trig_HLT*",0); //myChain->SetBranchStatus("BS*",0); //myChain->SetBranchStatus("MC_*",0); //myChain->SetBranchStatus("ele_MC*",0); ////myChain->SetBranchStatus("ele_eid*",0); ////myChain->SetBranchStatus("ele_Seed*",0); //myChain->SetBranchStatus("ele_charge*",0); //myChain->SetBranchStatus("met_*",0); //myChain->SetBranchStatus("muons*",0); //myChain->SetBranchStatus("jets*",0); myChain->SetBranchStatus("sc*",0); //myChain->SetBranchStatus("sc_hybrid_N",1); //myChain->SetBranchStatus("",0); // Global myChain->SetBranchAddress("nEvent",&nEvent); myChain->SetBranchAddress("nRun",&nRun); myChain->SetBranchAddress("nLumi",&nLumi); // Trigger // myChain->SetBranchAddress ("trig_HLT_triggered", &m_HLT_triggered); // myChain->SetBranchAddress ("trig_HLT_pathsV", &m_HLT_pathsV); // myChain->SetBranchAddress ("trig_HLT_pathsV_check", &m_HLT_pathsV_check); // myChain->SetBranchAddress("trig_HLT_path",&trig_HLT_path); // unbias, EG5, EG8, EG12 // myChain->SetBranchAddress("trig_fired_names",&trig_fired_names); myChain->SetBranchAddress("trig_hltInfo",&trig_hltInfo); // SC //myChain->SetBranchAddress("sc_hybrid_N", &sc_hybrid_N); // Electrons myChain->SetBranchAddress("ele_N", &ele_N); myChain->SetBranchAddress("electrons",&electrons); myChain->SetBranchAddress("ele_severityLevelSeed", &ele_severityLevelSeed); myChain->SetBranchAddress("ele_he",&ele_he); myChain->SetBranchAddress("ele_sigmaietaieta",&ele_sigmaietaieta); myChain->SetBranchAddress("ele_hcalDepth1TowerSumEt_dr03", &ele_hcalDepth1TowerSumEt_dr03); myChain->SetBranchAddress("ele_hcalDepth2TowerSumEt_dr03", &ele_hcalDepth2TowerSumEt_dr03); myChain->SetBranchAddress("ele_ecalRecHitSumEt_dr03", &ele_ecalRecHitSumEt_dr03); myChain->SetBranchAddress("ele_tkSumPt_dr03",&ele_tkSumPt_dr03); myChain->SetBranchAddress("ele_sclEta",&ele_sclEta); myChain->SetBranchAddress("ele_sclEt",&ele_sclEt); myChain->SetBranchAddress("ele_expected_inner_hits",&ele_expected_inner_hits); myChain->SetBranchAddress("ele_deltaphiin",&ele_deltaphiin); myChain->SetBranchAddress("ele_deltaetain",&ele_deltaetain); myChain->SetBranchAddress("ele_conv_dist",&ele_conv_dist); myChain->SetBranchAddress("ele_conv_dcot",&ele_conv_dcot); myChain->SetBranchAddress("ele_fbrem",&ele_fbrem); //myChain->SetBranchAddress("ele_ambiguousGsfTracks", &ele_ambiguousGsfTracks); myChain->SetBranchAddress("ele_isConversion",&ele_isConversion); myChain->SetBranchAddress("ele_echarge",&ele_echarge); // L1 electron informations myChain->SetBranchAddress("ele_TTetaVect", &ele_TTetaVect); myChain->SetBranchAddress("ele_TTphiVect", &ele_TTphiVect); myChain->SetBranchAddress("ele_TTetVect", &ele_TTetVect); // myChain->SetBranchAddress("ele_RCTeta", &ele_RCTeta); myChain->SetBranchAddress("ele_RCTphi", &ele_RCTphi); myChain->SetBranchAddress("ele_RCTL1iso", &ele_RCTL1iso); myChain->SetBranchAddress("ele_RCTL1noniso", &ele_RCTL1noniso); myChain->SetBranchAddress("ele_RCTL1iso_M", &ele_RCTL1iso_M); myChain->SetBranchAddress("ele_RCTL1noniso_M", &ele_RCTL1noniso_M); myChain->SetBranchAddress("ele_RCTetaVect", &ele_RCTetaVect); myChain->SetBranchAddress("ele_RCTphiVect", &ele_RCTphiVect); myChain->SetBranchAddress("ele_RCTetVect", &ele_RCTetVect); myChain->SetBranchAddress("ele_RCTL1isoVect", &ele_RCTL1isoVect); myChain->SetBranchAddress("ele_RCTL1nonisoVect", &ele_RCTL1nonisoVect); myChain->SetBranchAddress("ele_RCTL1isoVect_M", &ele_RCTL1isoVect_M); myChain->SetBranchAddress("ele_RCTL1nonisoVect_M", &ele_RCTL1nonisoVect_M); // L1 candidates myChain->SetBranchAddress("trig_L1emIso_N", &trig_L1emIso_N); myChain->SetBranchAddress("trig_L1emIso_ieta", &trig_L1emIso_ieta); myChain->SetBranchAddress("trig_L1emIso_iphi", &trig_L1emIso_iphi); myChain->SetBranchAddress("trig_L1emIso_rank", &trig_L1emIso_rank); myChain->SetBranchAddress("trig_L1emNonIso_N", &trig_L1emNonIso_N); myChain->SetBranchAddress("trig_L1emNonIso_ieta", &trig_L1emNonIso_ieta); myChain->SetBranchAddress("trig_L1emNonIso_iphi", &trig_L1emNonIso_iphi); myChain->SetBranchAddress("trig_L1emNonIso_rank", &trig_L1emNonIso_rank); myChain->SetBranchAddress("trig_L1emIso_N_M", &trig_L1emIso_N_M); myChain->SetBranchAddress("trig_L1emIso_ieta_M", &trig_L1emIso_ieta_M); myChain->SetBranchAddress("trig_L1emIso_iphi_M", &trig_L1emIso_iphi_M); myChain->SetBranchAddress("trig_L1emIso_rank_M", &trig_L1emIso_rank_M); myChain->SetBranchAddress("trig_L1emNonIso_N_M", &trig_L1emNonIso_N_M); myChain->SetBranchAddress("trig_L1emNonIso_ieta_M", &trig_L1emNonIso_ieta_M); myChain->SetBranchAddress("trig_L1emNonIso_iphi_M", &trig_L1emNonIso_iphi_M); myChain->SetBranchAddress("trig_L1emNonIso_rank_M", &trig_L1emNonIso_rank_M); // Pre/post - firing L1 candidates myChain->SetBranchAddress("trig_preL1emIso_N", &trig_preL1emIso_N); myChain->SetBranchAddress("trig_preL1emIso_ieta", &trig_preL1emIso_ieta); myChain->SetBranchAddress("trig_preL1emIso_iphi", &trig_preL1emIso_iphi); myChain->SetBranchAddress("trig_preL1emIso_rank", &trig_preL1emIso_rank); // myChain->SetBranchAddress("trig_preL1emNonIso_N", &trig_preL1emNonIso_N); myChain->SetBranchAddress("trig_preL1emNonIso_ieta", &trig_preL1emNonIso_ieta); myChain->SetBranchAddress("trig_preL1emNonIso_iphi", &trig_preL1emNonIso_iphi); myChain->SetBranchAddress("trig_preL1emNonIso_rank", &trig_preL1emNonIso_rank); // myChain->SetBranchAddress("trig_postL1emIso_N", &trig_postL1emIso_N); myChain->SetBranchAddress("trig_postL1emIso_ieta", &trig_postL1emIso_ieta); myChain->SetBranchAddress("trig_postL1emIso_iphi", &trig_postL1emIso_iphi); myChain->SetBranchAddress("trig_postL1emIso_rank", &trig_postL1emIso_rank); // myChain->SetBranchAddress("trig_postL1emNonIso_N", &trig_postL1emNonIso_N); myChain->SetBranchAddress("trig_postL1emNonIso_ieta", &trig_postL1emNonIso_ieta); myChain->SetBranchAddress("trig_postL1emNonIso_iphi", &trig_postL1emNonIso_iphi); myChain->SetBranchAddress("trig_postL1emNonIso_rank", &trig_postL1emNonIso_rank); // Trigger Towers // normal collection myChain->SetBranchAddress("trig_tower_N", &trig_tower_N); myChain->SetBranchAddress("trig_tower_ieta", &trig_tower_ieta); myChain->SetBranchAddress("trig_tower_iphi", &trig_tower_iphi); myChain->SetBranchAddress("trig_tower_adc", &trig_tower_adc); myChain->SetBranchAddress("trig_tower_sFGVB", &trig_tower_sFGVB); // modified collection myChain->SetBranchAddress("trig_tower_N_modif", &trig_tower_N_modif); myChain->SetBranchAddress("trig_tower_ieta_modif", &trig_tower_ieta_modif); myChain->SetBranchAddress("trig_tower_iphi_modif", &trig_tower_iphi_modif); myChain->SetBranchAddress("trig_tower_adc_modif", &trig_tower_adc_modif); myChain->SetBranchAddress("trig_tower_sFGVB_modif", &trig_tower_sFGVB_modif); myChain->SetBranchAddress("trig_tower_N_emul", &trig_tower_N_emul); myChain->SetBranchAddress("trig_tower_ieta_emul", &trig_tower_ieta_emul); myChain->SetBranchAddress("trig_tower_iphi_emul", &trig_tower_iphi_emul); myChain->SetBranchAddress("trig_tower_adc_emul", &trig_tower_adc_emul); myChain->SetBranchAddress("trig_tower_sFGVB_emul", &trig_tower_sFGVB_emul); // HCAL TP myChain->SetBranchAddress("trig_tower_hcal_N", &trig_tower_hcal_N); myChain->SetBranchAddress("trig_tower_hcal_ieta", &trig_tower_hcal_ieta); myChain->SetBranchAddress("trig_tower_hcal_iphi", &trig_tower_hcal_iphi); myChain->SetBranchAddress("trig_tower_hcal_et", &trig_tower_hcal_et); myChain->SetBranchAddress("trig_tower_hcal_FG", &trig_tower_hcal_FG); // Strip masking myChain->SetBranchAddress("trig_strip_mask_N", &trig_strip_mask_N); myChain->SetBranchAddress("trig_strip_mask_TTieta", &trig_strip_mask_TTieta); myChain->SetBranchAddress("trig_strip_mask_TTiphi", &trig_strip_mask_TTiphi); myChain->SetBranchAddress("trig_strip_mask_StripID", &trig_strip_mask_StripID); myChain->SetBranchAddress("trig_strip_mask_PseudoStripID", &trig_strip_mask_PseudoStripID); myChain->SetBranchAddress("trig_strip_mask_TccID", &trig_strip_mask_TccID); myChain->SetBranchAddress("trig_strip_mask_CCU", &trig_strip_mask_CCU); myChain->SetBranchAddress("trig_strip_mask_xtal_ix", &trig_strip_mask_xtal_ix); myChain->SetBranchAddress("trig_strip_mask_xtal_iy", &trig_strip_mask_xtal_iy); myChain->SetBranchAddress("trig_strip_mask_xtal_iz", &trig_strip_mask_xtal_iz); // // Crystal masking myChain->SetBranchAddress("trig_xtal_mask_N", &trig_xtal_mask_N); myChain->SetBranchAddress("trig_xtal_mask_ieta", &trig_xtal_mask_ieta); myChain->SetBranchAddress("trig_xtal_mask_iphi", &trig_xtal_mask_iphi); myChain->SetBranchAddress("trig_xtal_mask_TTieta", &trig_xtal_mask_TTieta); myChain->SetBranchAddress("trig_xtal_mask_TTiphi", &trig_xtal_mask_TTiphi); myChain->SetBranchAddress("trig_xtal_mask_Rieta", &trig_xtal_mask_Rieta); myChain->SetBranchAddress("trig_xtal_mask_Riphi", &trig_xtal_mask_Riphi); myChain->SetBranchAddress("trig_xtal_mask_status", &trig_xtal_mask_status); myChain->SetBranchAddress("trig_xtal_mask_EBEE", &trig_xtal_mask_EBEE); // Masking myChain->SetBranchAddress("trig_nMaskedRCT", &trig_nMaskedRCT); myChain->SetBranchAddress("trig_iMaskedRCTeta", &trig_iMaskedRCTeta); myChain->SetBranchAddress("trig_iMaskedRCTcrate", &trig_iMaskedRCTcrate); myChain->SetBranchAddress("trig_iMaskedRCTphi", &trig_iMaskedRCTphi); myChain->SetBranchAddress("trig_nMaskedCh", &trig_nMaskedCh); myChain->SetBranchAddress("trig_iMaskedTTeta", &trig_iMaskedTTeta); myChain->SetBranchAddress("trig_iMaskedTTphi", &trig_iMaskedTTphi); if(debug) cout << "got the input tree, start to define output tree" << endl; // OUTPUT TREE // TTree * outtree = new TTree("ElePairs","ElePairs"); // General informations outtree->Branch("nRun",&nRun,"nRun/I"); outtree->Branch("nLumi",&nLumi,"nLumi/I"); outtree->Branch("nEvent",&nEvent,"nEvent/I"); // Vertices outtree->Branch("vtx_N",&_vtx_N,"vtx_N/I"); outtree->Branch("vtx_normalizedChi2",&_vtx_normalizedChi2,"vtx_normalizedChi2[200]/D"); outtree->Branch("vtx_ndof",&_vtx_ndof,"vtx_ndof[200]/D"); outtree->Branch("vtx_nTracks",&_vtx_nTracks,"vtx_nTracks[200]/D"); outtree->Branch("vtx_d0",&_vtx_d0,"vtx_d0[200]/D"); outtree->Branch("vtx_x",&_vtx_x,"vtx_x[200]/D"); outtree->Branch("vtx_y",&_vtx_y,"vtx_y[200]/D"); outtree->Branch("vtx_z",&_vtx_z,"vtx_z[200]/D"); // HLT informations // outtree->Branch ("trig_HLT_triggered", &m_HLT_triggered, 256000,0); // outtree->Branch ("trig_HLT_pathsV", &m_HLT_pathsV, 256000,0); // outtree->Branch ("trig_HLT_pathsV_check", &m_HLT_pathsV_check, 256000,0); // outtree->Branch("trig_HLT_path",&trig_HLT_path,"trig_HLT_path[4]/I"); // unbias, EG5, EG8, EG12 // outtree->Branch("trig_fired_names",&trig_fired_names,"trig_fired_names[5000]/C"); outtree->Branch("trig_hltInfo",&trig_hltInfo,"trig_hltInfo[250]/I"); // Trigger towers outtree->Branch("trig_tower_N",&trig_tower_N,"trig_tower_N/I"); outtree->Branch("trig_tower_ieta",&trig_tower_ieta,"trig_tower_ieta[4032]/I"); outtree->Branch("trig_tower_iphi",&trig_tower_iphi,"trig_tower_iphi[4032]/I"); outtree->Branch("trig_tower_adc",&trig_tower_adc,"trig_tower_adc[4032]/I"); outtree->Branch("trig_tower_sFGVB",&trig_tower_sFGVB,"trig_tower_sFGVB[4032]/I"); // outtree->Branch("trig_tower_N_modif",&trig_tower_N_modif,"trig_tower_N_modif/I"); outtree->Branch("trig_tower_ieta_modif",&trig_tower_ieta_modif,"trig_tower_ieta_modif[4032]/I"); outtree->Branch("trig_tower_iphi_modif",&trig_tower_iphi_modif,"trig_tower_iphi_modif[4032]/I"); outtree->Branch("trig_tower_adc_modif",&trig_tower_adc_modif,"trig_tower_adc_modif[4032]/I"); outtree->Branch("trig_tower_sFGVB_modif",&trig_tower_sFGVB_modif,"trig_tower_sFGVB_modif[4032]/I"); // outtree->Branch("trig_tower_N_emul",&trig_tower_N_emul,"trig_tower_N_emul/I"); outtree->Branch("trig_tower_ieta_emul",&trig_tower_ieta_emul,"trig_tower_ieta_emul[4032]/I"); outtree->Branch("trig_tower_iphi_emul",&trig_tower_iphi_emul,"trig_tower_iphi_emul[4032]/I"); outtree->Branch("trig_tower_adc_emul",&trig_tower_adc_emul,"trig_tower_adc_emul[4032][5]/I"); outtree->Branch("trig_tower_sFGVB_emul",&trig_tower_sFGVB_emul,"trig_tower_sFGVB_emul[4032][5]/I"); // HCAL TP outtree->Branch("trig_tower_hcal_N", &trig_tower_hcal_N, "trig_tower_hcal_N/I"); outtree->Branch("trig_tower_hcal_ieta", &trig_tower_hcal_ieta, "trig_tower_hcal_ieta[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_iphi", &trig_tower_hcal_iphi, "trig_tower_hcal_iphi[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_et", &trig_tower_hcal_et, "trig_tower_hcal_et[trig_tower_N]/I"); outtree->Branch("trig_tower_hcal_FG", &trig_tower_hcal_FG, "trig_tower_hcal_FG[trig_tower_N]/I"); // Strip masking outtree->Branch("trig_strip_mask_N", &trig_strip_mask_N, "trig_strip_mask_N/I"); outtree->Branch("trig_strip_mask_TTieta", &trig_strip_mask_TTieta, "trig_strip_mask_TTieta[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_TTiphi", &trig_strip_mask_TTiphi, "trig_strip_mask_TTiphi[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_StripID", &trig_strip_mask_StripID, "trig_strip_mask_StripID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_PseudoStripID", &trig_strip_mask_PseudoStripID, "trig_strip_mask_PseudoStripID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_TccID", &trig_strip_mask_TccID, "trig_strip_mask_TccID[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_CCU", &trig_strip_mask_CCU, "trig_strip_mask_CCU[trig_strip_mask_N]/I"); outtree->Branch("trig_strip_mask_xtal_ix", &trig_strip_mask_xtal_ix, "trig_strip_mask_xtal_ix[trig_strip_mask_N][5]/I"); outtree->Branch("trig_strip_mask_xtal_iy", &trig_strip_mask_xtal_iy, "trig_strip_mask_xtal_iy[trig_strip_mask_N][5]/I"); outtree->Branch("trig_strip_mask_xtal_iz", &trig_strip_mask_xtal_iz, "trig_strip_mask_xtal_iz[trig_strip_mask_N][5]/I"); // // Crystal masking outtree->Branch("trig_xtal_mask_N", &trig_xtal_mask_N, "trig_xtal_mask_N/I"); outtree->Branch("trig_xtal_mask_ieta", &trig_xtal_mask_ieta, "trig_xtal_mask_ieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_iphi", &trig_xtal_mask_iphi, "trig_xtal_mask_iphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_TTieta", &trig_xtal_mask_TTieta, "trig_xtal_mask_TTieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_TTiphi", &trig_xtal_mask_TTiphi, "trig_xtal_mask_TTiphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_Rieta", &trig_xtal_mask_Rieta, "trig_xtal_mask_Rieta[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_Riphi", &trig_xtal_mask_Riphi, "trig_xtal_mask_Riphi[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_status", &trig_xtal_mask_status, "trig_xtal_mask_status[trig_xtal_mask_N]/I"); outtree->Branch("trig_xtal_mask_EBEE", &trig_xtal_mask_EBEE, "trig_xtal_mask_EBEE[trig_xtal_mask_N]/I"); // L1 candidates outtree->Branch("trig_L1emIso_N", &trig_L1emIso_N, "trig_L1emIso_N/I"); outtree->Branch("trig_L1emIso_ieta", &trig_L1emIso_ieta, "trig_L1emIso_ieta[4]/I"); outtree->Branch("trig_L1emIso_iphi", &trig_L1emIso_iphi, "trig_L1emIso_iphi[4]/I"); outtree->Branch("trig_L1emIso_rank", &trig_L1emIso_rank, "trig_L1emIso_rank[4]/I"); //outtree->Branch("trig_L1emIso_eta", &trig_L1emIso_eta, "trig_L1emIso_eta[4]/D"); //outtree->Branch("trig_L1emIso_phi", &trig_L1emIso_phi, "trig_L1emIso_phi[4]/D"); // outtree->Branch("trig_L1emIso_energy",&trig_L1emIso_energy,"trig_L1emIso_energy[4]/D"); // outtree->Branch("trig_L1emIso_et", &trig_L1emIso_et, "trig_L1emIso_et[4]/D"); // outtree->Branch("trig_L1emNonIso_N", &trig_L1emNonIso_N, "trig_L1emNonIso_N/I"); outtree->Branch("trig_L1emNonIso_ieta", &trig_L1emNonIso_ieta, "trig_L1emNonIso_ieta[4]/I"); outtree->Branch("trig_L1emNonIso_iphi", &trig_L1emNonIso_iphi, "trig_L1emNonIso_iphi[4]/I"); outtree->Branch("trig_L1emNonIso_rank", &trig_L1emNonIso_rank, "trig_L1emNonIso_rank[4]/I"); // outtree->Branch("trig_L1emNonIso_eta", &trig_L1emNonIso_eta, "trig_L1emNonIso_eta[4]/D"); // outtree->Branch("trig_L1emNonIso_phi", &trig_L1emNonIso_phi, "trig_L1emNonIso_phi[4]/D"); // outtree->Branch("trig_L1emNonIso_energy",&trig_L1emNonIso_energy,"trig_L1emNonIso_energy[4]/D"); // outtree->Branch("trig_L1emNonIso_et", &trig_L1emNonIso_et, "trig_L1emNonIso_et[4]/D"); // outtree->Branch("trig_L1emIso_N_M", &trig_L1emIso_N_M, "trig_L1emIso_N_M/I"); outtree->Branch("trig_L1emIso_ieta_M", &trig_L1emIso_ieta_M, "trig_L1emIso_ieta_M[4]/I"); outtree->Branch("trig_L1emIso_iphi_M", &trig_L1emIso_iphi_M, "trig_L1emIso_iphi_M[4]/I"); outtree->Branch("trig_L1emIso_rank_M", &trig_L1emIso_rank_M, "trig_L1emIso_rank_M[4]/I"); // outtree->Branch("trig_L1emIso_eta_M", &trig_L1emIso_eta_M, "trig_L1emIso_eta_M[4]/D"); // outtree->Branch("trig_L1emIso_phi_M", &trig_L1emIso_phi_M, "trig_L1emIso_phi_M[4]/D"); // outtree->Branch("trig_L1emIso_energy_M",&trig_L1emIso_energy_M,"trig_L1emIso_energy_M[4]/D"); // outtree->Branch("trig_L1emIso_et_M", &trig_L1emIso_et_M, "trig_L1emIso_et_M[4]/D"); // outtree->Branch("trig_L1emNonIso_N_M", &trig_L1emNonIso_N_M, "trig_L1emNonIso_N_M/I"); outtree->Branch("trig_L1emNonIso_ieta_M", &trig_L1emNonIso_ieta_M, "trig_L1emNonIso_ieta_M[4]/I"); outtree->Branch("trig_L1emNonIso_iphi_M", &trig_L1emNonIso_iphi_M, "trig_L1emNonIso_iphi_M[4]/I"); outtree->Branch("trig_L1emNonIso_rank_M", &trig_L1emNonIso_rank_M, "trig_L1emNonIso_rank_M[4]/I"); // outtree->Branch("trig_L1emNonIso_eta_M", &trig_L1emNonIso_eta_M, "trig_L1emNonIso_eta_M[4]/D"); // outtree->Branch("trig_L1emNonIso_phi_M", &trig_L1emNonIso_phi_M, "trig_L1emNonIso_phi_M[4]/D"); // outtree->Branch("trig_L1emNonIso_energy_M",&trig_L1emNonIso_energy_M,"trig_L1emNonIso_energy_M[4]/D"); // outtree->Branch("trig_L1emNonIso_et_M", &trig_L1emNonIso_et_M, "trig_L1emNonIso_et_M[4]/D"); // pre-post firing L1 candidates outtree->Branch("trig_preL1emIso_N", &trig_preL1emIso_N, "trig_preL1emIso_N/I"); outtree->Branch("trig_preL1emIso_ieta", &trig_preL1emIso_ieta, "trig_preL1emIso_ieta[4]/I"); outtree->Branch("trig_preL1emIso_iphi", &trig_preL1emIso_iphi, "trig_preL1emIso_iphi[4]/I"); outtree->Branch("trig_preL1emIso_rank", &trig_preL1emIso_rank, "trig_preL1emIso_rank[4]/I"); // outtree->Branch("trig_preL1emNonIso_N", &trig_preL1emNonIso_N, "trig_preL1emNonIso_N/I"); outtree->Branch("trig_preL1emNonIso_ieta", &trig_preL1emNonIso_ieta, "trig_preL1emNonIso_ieta[4]/I"); outtree->Branch("trig_preL1emNonIso_iphi", &trig_preL1emNonIso_iphi, "trig_preL1emNonIso_iphi[4]/I"); outtree->Branch("trig_preL1emNonIso_rank", &trig_preL1emNonIso_rank, "trig_preL1emNonIso_rank[4]/I"); // outtree->Branch("trig_postL1emIso_N", &trig_postL1emIso_N, "trig_postL1emIso_N/I"); outtree->Branch("trig_postL1emIso_ieta", &trig_postL1emIso_ieta, "trig_postL1emIso_ieta[4]/I"); outtree->Branch("trig_postL1emIso_iphi", &trig_postL1emIso_iphi, "trig_postL1emIso_iphi[4]/I"); outtree->Branch("trig_postL1emIso_rank", &trig_postL1emIso_rank, "trig_postL1emIso_rank[4]/I"); // outtree->Branch("trig_postL1emNonIso_N", &trig_postL1emNonIso_N, "trig_postL1emNonIso_N/I"); outtree->Branch("trig_postL1emNonIso_ieta", &trig_postL1emNonIso_ieta, "trig_postL1emNonIso_ieta[4]/I"); outtree->Branch("trig_postL1emNonIso_iphi", &trig_postL1emNonIso_iphi, "trig_postL1emNonIso_iphi[4]/I"); outtree->Branch("trig_postL1emNonIso_rank", &trig_postL1emNonIso_rank, "trig_postL1emNonIso_rank[4]/I"); // outtree->Branch("trig_nMaskedRCT", &trig_nMaskedRCT, "trig_nMaskedRCT/I"); outtree->Branch("trig_iMaskedRCTeta", &trig_iMaskedRCTeta, "trig_iMaskedRCTeta[trig_nMaskedRCT]/I"); outtree->Branch("trig_iMaskedRCTcrate", &trig_iMaskedRCTcrate,"trig_iMaskedRCTcrate[trig_nMaskedRCT]/I"); outtree->Branch("trig_iMaskedRCTphi", &trig_iMaskedRCTphi, "trig_iMaskedRCTphi[trig_nMaskedRCT]/I"); outtree->Branch("trig_nMaskedCh", &trig_nMaskedCh, "trig_nMaskedCh/I"); outtree->Branch("trig_iMaskedTTeta", &trig_iMaskedTTeta, "trig_iMaskedTTeta[trig_nMaskedCh]/I"); outtree->Branch("trig_iMaskedTTphi", &trig_iMaskedTTphi, "trig_iMaskedTTphi[trig_nMaskedCh]/I"); // Pairs informations double pair_M; double pair_eta[2], pair_sclEta[2], pair_sclEt[2], pair_phi[2], pair_pT[2], pair_eT[2], pair_E[2]; int pair_cuts[2], pair_HLT_Ele27_cut[2], pair_fidu[2], pair_charge[2], pair_RCTeta[2], pair_RCTphi[2], pair_L1iso[2], pair_L1noniso[2], pair_L1iso_M[2], pair_L1noniso_M[2]; int pair_RCTetaVect[2][10], pair_RCTphiVect[2][10], pair_L1isoVect[2][10], pair_L1nonisoVect[2][10],pair_L1isoVect_M[2][10], pair_L1nonisoVect_M[2][10]; double pair_RCTetVect[2][10]; int pair_TTetaVect[2][50], pair_TTphiVect[2][50]; double pair_TTetVect[2][50]; // outtree->Branch("pair_M",&pair_M,"pair_M/D"); // outtree->Branch("pair_cuts",&pair_cuts,"pair_cuts[2]/I"); // 0 : noCut | 1 : VBTF 95 | 2 : VBTF 80 | 3 : VBTF 60 outtree->Branch("pair_HLT_Ele27_cut",&pair_HLT_Ele27_cut,"pair_HLT_Ele27_cut[2]/I"); outtree->Branch("pair_fidu",&pair_fidu,"pair_fidu[2]/I"); // outtree->Branch("pair_eta",&pair_eta,"pair_eta[2]/D"); outtree->Branch("pair_sclEta",&pair_sclEta,"pair_sclEta[2]/D"); outtree->Branch("pair_phi",&pair_phi,"pair_phi[2]/D"); outtree->Branch("pair_RCTeta",&pair_RCTeta,"pair_RCTeta[2]/I"); outtree->Branch("pair_RCTphi",&pair_RCTphi,"pair_RCTphi[2]/I"); // outtree->Branch("pair_charge",&pair_charge,"pair_charge[2]/I"); outtree->Branch("pair_pT",&pair_pT,"pair_pT[2]/D"); outtree->Branch("pair_eT",&pair_eT,"pair_eT[2]/D"); outtree->Branch("pair_sclEt",&pair_sclEt,"pair_sclEt[2]/D"); outtree->Branch("pair_E",&pair_E,"pair_E[2]/D"); outtree->Branch("pair_TTetaVect", &pair_TTetaVect,"pair_TTetaVect[2][50]/I"); outtree->Branch("pair_TTphiVect", &pair_TTphiVect,"pair_TTphiVect[2][50]/I"); outtree->Branch("pair_TTetVect", &pair_TTetVect,"pair_TTetVect[2][50]/D"); outtree->Branch("pair_L1iso",&pair_L1iso,"pair_L1iso[2]/I"); outtree->Branch("pair_L1noniso",&pair_L1noniso,"pair_L1noniso[2]/I"); outtree->Branch("pair_L1iso_M",&pair_L1iso_M,"pair_L1iso_M[2]/I"); outtree->Branch("pair_L1noniso_M",&pair_L1noniso_M,"pair_L1noniso_M[2]/I"); // outtree->Branch("pair_RCTetVect",&pair_RCTetVect,"pair_RCTetVect[2][10]/D"); outtree->Branch("pair_RCTetaVect",&pair_RCTetaVect,"pair_RCTetaVect[2][10]/I"); outtree->Branch("pair_RCTphiVect",&pair_RCTphiVect,"pair_RCTphiVect[2][10]/I"); outtree->Branch("pair_L1isoVect",&pair_L1isoVect,"pair_L1isoVect[2][10]/I"); outtree->Branch("pair_L1nonisoVect",&pair_L1nonisoVect,"pair_L1nonisoVect[2][10]/I"); outtree->Branch("pair_L1isoVect_M",&pair_L1isoVect_M,"pair_L1isoVect_M[2][10]/I"); outtree->Branch("pair_L1nonisoVect_M",&pair_L1nonisoVect_M,"pair_L1nonisoVect_M[2][10]/I"); if(debug) cout << "output tree defined" << endl; // USEFUL VARIABLES // vector<int> pairIdx; int cutEle[2], fidu[2]; bool cut_HLT_Ele27[2]; TLorentzVector * cand[2]; TLorentzVector total; bool isGoodRun; TString filename; // // JSON FILE READER // // // string jsonDir = "/data_CMS/cms/ndaci/" ; // const int nJson = 10; // string jsonFile[nJson]; // 2010B, May10, Aug05, Prompt // map<int, vector<pair<int, int> > > jsonMap[nJson] ; // // jsonFile[0] = jsonDir + "ndaci_2011A/JSON/goodrunlist_json.txt" ; // jsonFile[1] = jsonDir + "ndaci_2011A/JSON/Cert_160404-163869_7TeV_May10ReReco_Collisions11_JSON_v3.txt" ; // jsonFile[2] = jsonDir + "ndaci_2011A/JSON/Cert_170249-172619_7TeV_ReReco5Aug_Collisions11_JSON_v3.txt" ; // jsonFile[3] = jsonDir + "ndaci_2011A/JSON/Cert_160404-180252_7TeV_PromptReco_Collisions11_JSON.txt" ; // jsonFile[4] = jsonDir + "ndaci_2011A/JSON/Cert_160404-180252_7TeV_ReRecoNov08_Collisions11_JSON.txt" ; // // // 2012 // jsonFile[5] = jsonDir + "ndaci_2012/JSON/Cert_190456-203002_8TeV_PromptReco_Collisions12_JSON.txt"; // jsonFile[6] = jsonDir + "ndaci_2012/JSON/Cert_190456-196531_8TeV_13Jul2012ReReco_Collisions12_JSON_v2.txt"; // jsonFile[7] = jsonDir + "ndaci_2012/JSON/Cert_190782-190949_8TeV_06Aug2012ReReco_Collisions12_JSON.txt"; // jsonFile[8] = jsonDir + "ndaci_2012/JSON/Cert_198022-198523_8TeV_24Aug2012ReReco_Collisions12_JSON.txt"; // jsonFile[9] = jsonDir + "ndaci_2012/JSON/Cert_190456-208357_8TeV_PromptReco_Collisions12_JSON.txt"; // // for(int i=0 ; i<nJson ; i++) // jsonMap[i] = readJSONFile(jsonFile[i]); // // if(debug) cout << "JSON defined" << endl; if(debug) cout << "skipping JSON definition and JSON checks" << endl; // ------------------------------------------------------------------------------- // LOOP OVER EVENTS // ------------------------------------------------------------------------------- if(debug) cout << "gonna loop over events" << endl; int numEntries = myChain->GetEntries () ; int nProcess = numEntries; if(nEntries>=0 && nEntries<numEntries) nProcess = nEntries; int nCurrentRun = -999; outlog << "will process " << nProcess << "/" << numEntries << "entries" << endl; for (int iEvent = 0 ; iEvent < nProcess ; iEvent++ ) { // HLT information for(int i=0 ; i<4 ; i++) trig_HLT_path[i]=0; for(int i=0 ; i<250 ; i++) trig_hltInfo[i]=0; // TP Initialization trig_tower_N = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta[iTow] = trig_tower_iphi[iTow] = -999; trig_tower_adc[iTow] = trig_tower_sFGVB[iTow] = -999; } trig_tower_N_modif = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_modif[iTow] = trig_tower_iphi_modif[iTow] = -999; trig_tower_adc_modif[iTow] = trig_tower_sFGVB_modif[iTow] = -999; } trig_tower_N_emul = 0; for(int iTow=0 ; iTow<nTow ; iTow++) { trig_tower_ieta_emul[iTow] = trig_tower_iphi_emul[iTow] = -999; for(int i=0 ; i<5 ; i++) trig_tower_adc_emul[iTow][i] = trig_tower_sFGVB_emul[iTow][i] = -999; } myChain->GetEntry (iEvent) ; // show processed file if(iEvent==0) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << filename << endl << endl; } else if( filename != myChain->GetFile()->GetName() ) { filename = myChain->GetFile()->GetName() ; outlog << "File : " << myChain->GetFile()->GetName() << endl << endl; } // show current run/iCat processed if(iEvent==0) { nCurrentRun = nRun ; outlog << "nRun=" << nRun << endl; } else if(nRun!=nCurrentRun) { nCurrentRun=nRun ; outlog << "nRun=" << nRun << endl; } // // run selection (using both json files) // //int iJson = detJson(nRun); // //int iJson = 4; // if(debug) cout << "iJson = " << iJson << endl; // outlog << "iJson = " << iJson << endl; // if( iJson>-1 && iJson<9) { // isGoodRun = AcceptEventByRunAndLumiSection(nRun, nLumi, jsonMap[iJson]); // if(!isGoodRun) { // outlog << "failed JSON" << endl; // continue; // } // } // else { // outlog << "no proper JSON file" << endl; // //continue; // } // at least 2 electrons if(ele_N<2) continue; else outlog << "ele_N=" << ele_N << endl; // LOOP OVER ELECTRONS // if(debug) cout << "<-- ele_N=" << ele_N << endl << "--- electrons.size=" << electrons->GetSize() << endl; for( int iEle1=0 ; iEle1<ele_N ; iEle1++ ) { if(debug) cout << "--- get ele #" << iEle1 << endl; cand[0] = (TLorentzVector*) (electrons->At (iEle1)) ; if(debug) cout << "--- got it" << endl; // severity selection if( ele_severityLevelSeed[iEle1] >= 3 ) continue; // check whether electrons of the pair pass HLT_Ele27 Id/Iso cuts if(debug) cout << "--- checks VBTF cuts" << endl; cut_HLT_Ele27[0] = VBTFcuts( "HLT_Ele27", RunPhase, cand[0]->Pt(), cand[0]->Et(), ele_sclEta[iEle1], cand[0]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; // check if ele is a good tag candidate : pass VBTF 95 and has pT>5 GeV cutEle[0] = 0; cutEle[0] = whichCuts( RunPhase, cand[0]->Pt(), cand[0]->Et(), ele_sclEta[iEle1], cand[0]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; fidu[0] = 0; if ( fabs(ele_sclEta[iEle1]) < 2.5 && ( fabs(ele_sclEta[iEle1]) > 1.566 || fabs(ele_sclEta[iEle1])<1.4442 ) ) fidu[0] = 1 ; if( cutEle[0]>0 && cand[0]->Et()>=5. ) { if(debug) cout << "--- ele #" << iEle1 << " is a good tag candidate" << endl; // loop to find probe candidates for( int iEle2=0 ; iEle2<ele_N ; iEle2++ ) { if(debug) cout << "----- looks Ele #" << iEle2 << endl; cand[1] = (TLorentzVector*) (electrons->At (iEle2)) ; // severity if( ele_severityLevelSeed[iEle2] >= 3 ) continue; // check HLT_Ele27 cuts cut_HLT_Ele27[1] = VBTFcuts( "HLT_Ele27", RunPhase, cand[1]->Pt(), cand[1]->Et(), ele_sclEta[iEle1], cand[1]->Eta(), ele_tkSumPt_dr03[iEle1], ele_ecalRecHitSumEt_dr03[iEle1], ele_hcalDepth1TowerSumEt_dr03[iEle1], ele_hcalDepth2TowerSumEt_dr03[iEle1], ele_expected_inner_hits[iEle1], ele_deltaphiin[iEle1], ele_deltaetain[iEle1], ele_he[iEle1], ele_sigmaietaieta[iEle1], ele_conv_dist[iEle1], ele_conv_dcot[iEle1], ele_fbrem[iEle1], ele_isConversion[iEle1] ) ; // check cuts passed by probe candidate cutEle[1] = whichCuts( RunPhase, cand[1]->Pt(), cand[0]->Et(), ele_sclEta[iEle2], cand[1]->Eta(), ele_tkSumPt_dr03[iEle2], ele_ecalRecHitSumEt_dr03[iEle2], ele_hcalDepth1TowerSumEt_dr03[iEle2], ele_hcalDepth2TowerSumEt_dr03[iEle2], ele_expected_inner_hits[iEle2], ele_deltaphiin[iEle2], ele_deltaetain[iEle2], ele_he[iEle2], ele_sigmaietaieta[iEle2], ele_conv_dist[iEle2], ele_conv_dcot[iEle2], ele_fbrem[iEle2], ele_isConversion[iEle2] ) ; fidu[1] = 0; if ( fabs(ele_sclEta[iEle2]) < 2.5 && ( fabs(ele_sclEta[iEle2]) > 1.566 || fabs(ele_sclEta[iEle2])<1.4442 ) ) fidu[1] = 1 ; if( cutEle[1]>0 && iEle2<=iEle1 ) continue; // prevents to create several times the same pair if(debug) cout << "---> OK to form a pre-selected pair <--" << endl; // get the pair informations total = (*cand[0]) + (*cand[1]) ; // keep only pairs with Mee > 30 GeV if( total.M() < 30. ) continue; pair_M = total.M() ; pairIdx.clear(); pairIdx.push_back(iEle1); pairIdx.push_back(iEle2); for(int iP=0 ; iP<2 ; iP++) { pair_cuts[iP] = cutEle[iP]; pair_fidu[iP] = fidu[iP]; pair_HLT_Ele27_cut[iP] = cut_HLT_Ele27[iP]; // pair_eta[iP] = cand[iP]->Eta(); pair_sclEta[iP] = ele_sclEta[pairIdx[iP]]; pair_phi[iP] = cand[iP]->Phi(); pair_RCTeta[iP] = ele_RCTeta[pairIdx[iP]]; pair_RCTphi[iP] = ele_RCTphi[pairIdx[iP]]; // pair_charge[iP] = ele_echarge[pairIdx[iP]]; pair_pT[iP] = cand[iP]->Pt(); pair_eT[iP] = cand[iP]->Et(); pair_sclEt[iP] = ele_sclEt[pairIdx[iP]]; pair_E[iP] = cand[iP]->E(); // pair_L1iso[iP] = ele_RCTL1iso[pairIdx[iP]]; pair_L1noniso[iP] = ele_RCTL1noniso[pairIdx[iP]]; pair_L1iso_M[iP] = ele_RCTL1iso_M[pairIdx[iP]]; pair_L1noniso_M[iP] = ele_RCTL1noniso_M[pairIdx[iP]]; // for(int iV=0 ; iV<10 ; iV++) { pair_RCTetVect[iP][iV] = ele_RCTetVect[pairIdx[iP]][iV]; pair_RCTetaVect[iP][iV] = ele_RCTetaVect[pairIdx[iP]][iV]; pair_RCTphiVect[iP][iV] = ele_RCTphiVect[pairIdx[iP]][iV]; pair_L1isoVect[iP][iV] = ele_RCTL1isoVect[pairIdx[iP]][iV]; pair_L1nonisoVect[iP][iV] = ele_RCTL1nonisoVect[pairIdx[iP]][iV]; pair_L1isoVect_M[iP][iV] = ele_RCTL1isoVect_M[pairIdx[iP]][iV]; pair_L1nonisoVect_M[iP][iV] = ele_RCTL1nonisoVect_M[pairIdx[iP]][iV]; } // for(int iV=0 ; iV<50 ; iV++) { pair_TTetaVect[iP][iV] = ele_TTetaVect[pairIdx[iP]][iV]; pair_TTphiVect[iP][iV] = ele_TTphiVect[pairIdx[iP]][iV]; pair_TTetVect[iP][iV] = ele_TTetVect[pairIdx[iP]][iV]; } } if(debug) cout << "outtree->Fill();" << endl; outtree->Fill(); } // loop for probe } // endif ele1 is good tag candidate } // loop over electrons }//loop over events if(debug) cout << "End loop events" << endl; outlog << "End loop events" << endl; // Record tree if(debug) cout << "recording tree..." << endl; outlog << "recording tree..." << endl; outtree->Write(); if(debug) cout << "recorded !" << endl; outlog << "recorded !" << endl; outfile->Close(); if(debug) cout << "file closed." << endl; outlog << "file closed." << endl; return 1; }
void selectEleHZZHCP2012IDGivenIsoWithTightTagPerFile(const string inputfile, // input file const string outputfile, // output directory const Bool_t matchGen = kFALSE, // match to generator muons Int_t dataType = 0, // del = 0, sel = 1, mc = -1 Int_t DataEraInput = 2 ) { gBenchmark->Start("selectEleMVAIsoTightGivenID"); //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== UInt_t DataEra = kDataEra_NONE; if (DataEraInput == 1) DataEra = kDataEra_2011_MC; if (DataEraInput == 2) DataEra = kDataEra_2012_MC; if (DataEraInput == 11) DataEra = kDataEra_2011_Data; if (DataEraInput == 12) DataEra = kDataEra_2012_Data; //***************************************************************************************** //Setup MVA //***************************************************************************************** EGammaMvaEleEstimator *eleIDMVA = new EGammaMvaEleEstimator(); vector<string> weightFiles; weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat1.weights.xml")).c_str()); weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat2.weights.xml")).c_str()); weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat3.weights.xml")).c_str()); weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat4.weights.xml")).c_str()); weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat5.weights.xml")).c_str()); weightFiles.push_back((string(getenv("CMSSW_BASE"))+string("/src/HiggsAna/HZZ4l/data/ElectronIDMVAWeights/Electrons_BDTG_NonTrigV0_Cat6.weights.xml")).c_str()); eleIDMVA->initialize( "BDT", EGammaMvaEleEstimator::kNonTrig, kTRUE, weightFiles); // mass region Double_t massLo = 40; Double_t massHi = 200; //-------------------------------------------------------------------------------------------------------------- // Main analysis code //============================================================================================================== Double_t nProbes = 0; // // Set up output ntuple // TFile *outFile = new TFile(outputfile.c_str(),"RECREATE"); TTree *outTree = new TTree("Events","Events"); EffData data; outTree->Branch("Events",&data.mass,"mass/F:pt:eta:phi:weight:q/I:npv/i:npu:pass:runNum:lumiSec:evtNum:rho/F"); TFile *infile=0; TTree *eventTree=0; // Data structures to store info from TTrees higgsana::TEventInfo *info = new higgsana::TEventInfo(); higgsana::TGenInfo *gen = new higgsana::TGenInfo(); TClonesArray *electronArr = new TClonesArray("higgsana::TElectron"); TClonesArray *pfcandidateArr = new TClonesArray("higgsana::TPFCandidate"); TClonesArray *muonArr = new TClonesArray("higgsana::TMuon"); // Read input file and get the TTrees cout << "Processing " << inputfile << "..." << endl; infile = TFile::Open(inputfile.c_str(),"read"); assert(infile); //******************************************************** // Good RunLumi Selection //******************************************************** Bool_t hasJSON = kFALSE; mithep::RunLumiRangeMap rlrm; if (!matchGen) { hasJSON = kTRUE; rlrm.AddJSONFile("/afs/cern.ch/work/s/sixie/public/HZZ4l/auxiliar/2012/Cert_Full2012_53X_JSON.txt"); rlrm.AddJSONFile("/afs/cern.ch/work/s/sixie/public/HZZ4l/auxiliar/2011/2011Combined.json"); } eventTree = (TTree*)infile->Get("Events"); assert(eventTree); eventTree->SetBranchAddress("Info", &info); TBranch *infoBr = eventTree->GetBranch("Info"); eventTree->SetBranchAddress("Electron", &electronArr); TBranch *electronBr = eventTree->GetBranch("Electron"); eventTree->SetBranchAddress("Muon", &muonArr); TBranch *muonBr = eventTree->GetBranch("Muon"); eventTree->SetBranchAddress("PFCandidate", &pfcandidateArr); TBranch *pfcandidateBr = eventTree->GetBranch("PFCandidate"); cout << "NEvents = " << eventTree->GetEntries() << endl; TBranch *genBr = 0; if(matchGen) { eventTree->SetBranchAddress("Gen", &gen); genBr = eventTree->GetBranch("Gen"); } Double_t weight = 1; // loop over events for(UInt_t ientry=0; ientry<eventTree->GetEntries(); ientry++) { if (ientry % 100000 == 0) cout << "Processed Event " << ientry << endl; infoBr->GetEntry(ientry); // check for certified runs mithep::RunLumiRangeMap::RunLumiPairType rl(info->runNum, info->lumiSec); if(hasJSON && !rlrm.HasRunLumi(rl)) continue; //*********************************************************** // Definition of Pileup Energy density //*********************************************************** Double_t rhoEleIso = 0; UInt_t EleEAEra = 0; if (DataEra == kDataEra_2011_MC) { if (!(isnan(info->RhoKt6PFJetsForIso25) || isinf(info->RhoKt6PFJetsForIso25))) { rhoEleIso = info->RhoKt6PFJetsForIso25; } EleEAEra = kDataEra_2011_Data; } else if (DataEra == kDataEra_2012_MC) { if (!(isnan(info->RhoKt6PFJets) || isinf(info->RhoKt6PFJets))) { rhoEleIso = info->RhoKt6PFJets; } EleEAEra = kDataEra_2012_Data; } //use only odd numbered events to evaluate efficiency for data. even numbered events were used for training //if (info->evtNum % 2 == 0 && !matchGen) continue; // trigger requirement Bool_t passTrigger = kFALSE; if(dataType == 0) { if ((info->triggerBits & kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) == kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) passTrigger = kTRUE; if ((info->triggerBits & kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) == kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) passTrigger = kTRUE; if ((info->triggerBits & kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) == kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) passTrigger = kTRUE; } else if(dataType == 1) { if(DataEraInput == 2) { if(info->triggerBits & kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) continue; if(info->triggerBits & kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) continue; if(info->triggerBits & kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) continue; } if ((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) == kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) passTrigger = kTRUE; } if(dataType != -1 && !passTrigger) continue; // good vertex requirement if(!(info->hasGoodPV)) continue; if(matchGen) genBr->GetEntry(ientry); electronArr->Clear(); muonArr->Clear(); pfcandidateArr->Clear(); electronBr->GetEntry(ientry); muonBr->GetEntry(ientry); pfcandidateBr->GetEntry(ientry); //******************************************************** //Low Met Requirement //******************************************************** TVector3 met; if(info->pfMEx!=0 || info->pfMEy!=0) { met.SetXYZ(info->pfMEx, info->pfMEy, 0); } if (met.Pt() > 25) continue; //******************************************************** //Loop over TAG electrons //******************************************************** for(Int_t i=0; i<electronArr->GetEntriesFast(); i++) { const higgsana::TElectron *tag = (higgsana::TElectron*)((*electronArr)[i]); if(matchGen) { Bool_t match1 = (higgsana::deltaR(tag->eta, tag->phi, gen->eta_1, gen->phi_1) < 0.5); Bool_t match2 = (higgsana::deltaR(tag->eta, tag->phi, gen->eta_2, gen->phi_2) < 0.5); if(!match1 && !match2) continue; } if(tag->pt < 20) continue; if(fabs(tag->scEta) > 2.5) continue; if (!PassEleSimpleCutsVeryTight(tag,pfcandidateArr,rhoEleIso,EleEAEra)) continue; if(dataType == 0 && !((info->triggerBits & kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) && (tag->hltMatchBits & kHLTObject_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT)) && !((info->triggerBits & kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) && (tag->hltMatchBits & kHLTObject_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT)) && !((info->triggerBits & kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) && (tag->hltMatchBits & kHLTObject_Ele32_CaloIdL_CaloIsoVL)) && !((info->triggerBits & kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) && (tag->hltMatchBits & kHLTObject_Ele32_CaloIdT_CaloIsoT_TrkIdT_TrkIsoT)) && !((info->triggerBits & kHLT_Ele17_CaloIdL_CaloIsoVL) && (tag->hltMatchBits & kHLTObject_Ele17_CaloIdL_CaloIsoVL)) ) continue; if (dataType == 1) { if(dataType == 1 && !((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && (tag->hltMatchBits & kHLTObject_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && tag->pt > 30) && !((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && (tag->hltMatchBits & kHLTObject_Ele32_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && tag->pt > 35) && !((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && (tag->hltMatchBits & kHLTObject_Ele52_CaloIdVT_TrkIdT) && tag->pt > 60) && !((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && (tag->hltMatchBits & kHLTObject_Ele27_WP80) && tag->pt > 30) && !((info->triggerBits & kHLT_Ele27_CaloIdVT_CaloIsoT_TrkIdT_TrkIsoT) && (tag->hltMatchBits & kHLTObject_Ele32_WP70) && tag->pt > 35) ) continue; } const Double_t m = 0.000511; TLorentzVector vtag; vtag.SetPtEtaPhiM(tag->pt, tag->eta, tag->phi, m); for(Int_t j=0; j<electronArr->GetEntriesFast(); j++) { if(i==j) continue; const higgsana::TElectron *probe = (higgsana::TElectron*)((*electronArr)[j]); if(probe->q == tag->q) continue; // if(typev[ifile]==eDiEl && // !((info->triggerBits & kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) && (probe->hltMatchBits & kHLTObject_SC8)) && // !((info->triggerBits & kHLT_Ele17_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC8_Mass30) && (probe->hltMatchBits & kHLTObject_Ele8)) && // !((info->triggerBits & kHLT_Ele32_CaloIdL_CaloIsoVL_SC17) && (probe->hltMatchBits & kHLTObject_SC17))) // continue; if(matchGen) { Bool_t match1 = (higgsana::deltaR(probe->eta, probe->phi, gen->eta_1, gen->phi_1) < 0.5); Bool_t match2 = (higgsana::deltaR(probe->eta, probe->phi, gen->eta_2, gen->phi_2) < 0.5); if(!match1 && !match2) continue; } if(fabs(probe->scEta) > 2.5) continue; TLorentzVector vprobe; vprobe.SetPtEtaPhiM(probe->pt, probe->eta, probe->phi, m); TLorentzVector vdielectron = vtag + vprobe; if((vdielectron.M()<massLo) || (vdielectron.M()>massHi)) continue; //for probes with pT < 10, require the Ele20_SC4 trigger if (probe->pt < 10) { if(dataType == 0) { if (!((info->triggerBits & kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) == kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50)) continue; if (!((info->triggerBits & kHLT_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT_SC4_Mass50) && (tag->hltMatchBits & kHLTObject_Ele20_CaloIdVT_CaloIsoVT_TrkIdT_TrkIsoVT))) continue; } } nProbes++; Bool_t passID = (PassEleHZZ4lPreselection(probe) && PassEleHZZ4lICHEP2012ID(probe, eleIDMVA)); vector<const higgsana::TPFCandidate*> photonsToVeto; Bool_t passIsolation = PassEleHZZ4lICHEP2012Iso(probe,j,pfcandidateArr,rhoEleIso,EleEAEra,photonsToVeto); if (!passIsolation) continue; //****************** //PASS //****************** Bool_t pass = passID && passIsolation; // Fill tree data.mass = vdielectron.M(); data.pt = probe->pt; data.eta = probe->scEta; data.phi = probe->phi; data.weight = weight; data.q = probe->q; data.npv = info->nPV0; data.npu = info->nPUEvents; data.pass = (pass) ? 1 : 0; data.rho = rhoEleIso; data.runNum = info->runNum; data.lumiSec = info->lumiSec; data.evtNum = info->evtNum; outTree->Fill(); } } } delete infile; infile=0, eventTree=0; delete info; delete gen; delete electronArr; //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== cout << "*" << endl; cout << "* SUMMARY" << endl; cout << "*--------------------------------------------------" << endl; cout << endl; cout << " Number of probes selected: " << nProbes << endl; outFile->Write(); outFile->Close(); delete outFile; cout << endl; cout << " <> Output saved in " << outputfile << endl; cout << endl; gBenchmark->Show("selectEleLHEffTP"); }
Bool_t MuMu_Analysis::Process(Long64_t entry) { GetAllBranches(entry); totalEventCount++; double totalevents=9.66875e+06; if((int)(100*totalEventCount)%(int)(totalevents) ==0) std::cout << totalEventCount << "\t\tEvents processed \tca. " << (int) totalEventCount/totalevents* 100 << "%" << std::endl; TString DataType; DataType="def"; DataType=(TString)*(dataType->begin()); bool isData=c_step0.isData(DataType); bool b_step1=false; bool b_step2=false; bool b_step3=false; bool b_step4=false; bool b_step5=false; bool b_step6=false; bool b_step7=false; bool b_step8=false; bool b_step9=false; //loop over leptons bool rescale=true; float isocutmuons = 0.2;//0.3;//0.2; //0.2; //0.2;//0.2; pf // 0.15 comb float isocutelecs = 0.17; //0.3;//0.17;//0.17; //0.17; //0.17;//0.17; bool pfIso = true; float leptontype = 1; // 1 muon -1 electron TString dataset; if(leptontype==1) dataset="mumu"; else dataset = "ee"; bool oppocharge=true; float globalElecEnergyScale=1.0; //if(DataType == "ee_200rereco.root" || DataType == "ee_800prompt.root" ) globalElecEnergyScale=1.005; //just play around bool probefirst=true; //SET SWITCH ALSO DOWN IN terminate()! float tempiso=100; std::vector<float> VLepPt; std::vector<float> VLepEta, VLepPhi, VLepE, VLepPx, VLepPy, VLepPz, VLepPfIso, VLepCombIso; std::vector<int> VLepQ, VLepType; //h_lepMulti0.fill(DataType, (int)lepPt->size(), PUweight); int CheckCharge=100; if(probefirst){ CheckCharge=*(lepQ->begin()); // take first leading lepton VLepPt.push_back(*(lepPt->begin())); VLepEta.push_back(*(lepEta->begin())); VLepCombIso.push_back(*(lepCombIso->begin())); VLepPfIso.push_back(*(lepPfIso->begin())); VLepE.push_back(*(lepE->begin())); VLepPx.push_back(*(lepPx->begin())); VLepPy.push_back(*(lepPy->begin())); VLepPz.push_back(*(lepPz->begin())); VLepQ.push_back(*(lepQ->begin())); VLepType.push_back(*(lepType->begin())); VLepPhi.push_back(*(lepPhi->begin())); //new } int k=0; for(unsigned int i=0; i<lepPt->size(); i++){ //isocut and chargecut -> builds leptonvectors start with the second leading pt lepton!!! if(pfIso) tempiso=*(lepPfIso->begin()+i); else tempiso=*(lepCombIso->begin()+i); k++; if(tempiso < isocutmuons && *(lepType->begin()+i) == 1 && *(lepQ->begin()+i) != CheckCharge){ // VLepPt.push_back(*(lepPt->begin()+i)); VLepEta.push_back(*(lepEta->begin()+i)); VLepCombIso.push_back(*(lepCombIso->begin()+i)); VLepPfIso.push_back(*(lepPfIso->begin()+i)); VLepE.push_back(*(lepE->begin()+i)); VLepPx.push_back(*(lepPx->begin()+i)); VLepPy.push_back(*(lepPy->begin()+i)); VLepPz.push_back(*(lepPz->begin()+i)); VLepQ.push_back(*(lepQ->begin()+i)); VLepType.push_back(*(lepType->begin()+i)); VLepPhi.push_back(*(lepPhi->begin()+i)); CheckCharge=VLepQ[0]; //new break; //new } else if(tempiso < isocutelecs && *(lepType->begin()+i) == -1 && *(lepQ->begin()+i) != CheckCharge){ // VLepPt.push_back(*(lepPt->begin()+i)*globalElecEnergyScale); VLepEta.push_back(*(lepEta->begin()+i)); VLepCombIso.push_back(*(lepCombIso->begin()+i)); VLepPfIso.push_back(*(lepPfIso->begin()+i)); VLepE.push_back(*(lepE->begin()+i)*globalElecEnergyScale); VLepPx.push_back(*(lepPx->begin()+i)*globalElecEnergyScale); VLepPy.push_back(*(lepPy->begin()+i)*globalElecEnergyScale); VLepPz.push_back(*(lepPz->begin()+i)*globalElecEnergyScale); VLepQ.push_back(*(lepQ->begin()+i)); VLepType.push_back(*(lepType->begin()+i)); VLepPhi.push_back(*(lepPhi->begin()+i)); CheckCharge=VLepQ[0]; //new break; //new } //if(VLepType.size()==1 && oppocharge) CheckCharge=VLepQ[0]; //else if(VLepType.size()==1 && !oppocharge) CheckCharge= - VLepQ[0]; } //second leading probe lep if(!probefirst){ for(unsigned int i=0; i<lepPt->size(); i++){ //isocut and chargecut -> builds leptonvectors start with the second leading pt lepton!!! if(pfIso) tempiso=*(lepPfIso->begin()+i); else tempiso=*(lepCombIso->begin()+i); k++; if( *(lepType->begin()+i) == 1 && *(lepQ->begin()+i) != CheckCharge){ // VLepPt.push_back(*(lepPt->begin()+i)); VLepEta.push_back(*(lepEta->begin()+i)); VLepCombIso.push_back(*(lepCombIso->begin()+i)); VLepPfIso.push_back(*(lepPfIso->begin()+i)); VLepE.push_back(*(lepE->begin()+i)); VLepPx.push_back(*(lepPx->begin()+i)); VLepPy.push_back(*(lepPy->begin()+i)); VLepPz.push_back(*(lepPz->begin()+i)); VLepQ.push_back(*(lepQ->begin()+i)); VLepType.push_back(*(lepType->begin()+i)); VLepPhi.push_back(*(lepPhi->begin()+i)); break; //new } else if( *(lepType->begin()+i) == -1 && *(lepQ->begin()+i) != CheckCharge){ // VLepPt.push_back(*(lepPt->begin()+i)*globalElecEnergyScale); VLepEta.push_back(*(lepEta->begin()+i)); VLepCombIso.push_back(*(lepCombIso->begin()+i)); VLepPfIso.push_back(*(lepPfIso->begin()+i)); VLepE.push_back(*(lepE->begin()+i)*globalElecEnergyScale); VLepPx.push_back(*(lepPx->begin()+i)*globalElecEnergyScale); VLepPy.push_back(*(lepPy->begin()+i)*globalElecEnergyScale); VLepPz.push_back(*(lepPz->begin()+i)*globalElecEnergyScale); VLepQ.push_back(*(lepQ->begin()+i)); VLepType.push_back(*(lepType->begin()+i)); VLepPhi.push_back(*(lepPhi->begin()+i)); break; //new } } } double dimass=-1; if(VLepPt.size() > 1){ //two isolated leptons create dimass out of highest pt pair TLorentzVector diLepVector = TLorentzVector(VLepPx[0] + VLepPx[1], VLepPy[0] + VLepPy[1], VLepPz[0] + VLepPz[1], VLepE[0] + VLepE[1]); dimass=diLepVector.M(); b_step1=true; testcounter++; if(VLepType[0] == leptontype && VLepType[1] == leptontype) b_step2=true; if(dimass > 12) b_step3=true; if((dimass < 76.0 || dimass > 106.0)) b_step4=true; //dimass > 50 && if(jetMulti>0) b_step5=true; if(jetMulti>1) b_step6=true; if(*(metEt->begin()) > 30) b_step7=true; } if(b_step1 && b_step2 && b_step3 && !b_step4 && b_step6){ // select Z peak int lepno; if(probefirst) lepno=0; else lepno=1; if(isData) IsoStudiesData0->Fill(VLepPt[lepno]); // Fill histo pt dependent with first lepton if(DataType== dataset+"_dy"+dataset+"50inf.root") IsoStudiesZMC0->Fill(VLepPt[lepno]); if(DataType== dataset+"_ttbarsignal.root" || DataType== dataset+" _ttbarviatau.root") IsoStudiesttMC0->Fill(VLepPt[lepno]); //Fill pt dep for Z MC if(VLepPfIso[lepno]<isocutmuons){ //new if(isData) IsoStudiesData1->Fill(VLepPt[lepno]); if(DataType== dataset+"_dy"+dataset+"50inf.root") IsoStudiesZMC1->Fill(VLepPt[lepno]); if(DataType== dataset+"_ttbarsignal.root" || DataType== dataset+" _ttbarviatau.root") IsoStudiesttMC1->Fill(VLepPt[lepno]); } } double btagWPM=3.3; double btagWP=1.7; int btagmultiM=0; int btagmulti=0; for(std::vector<double>::const_iterator ajetTCHE = jetBTagTCHE->begin(); ajetTCHE < jetBTagTCHE->end(); ajetTCHE++){ if(*ajetTCHE > btagWPM) btagmultiM++; if(*ajetTCHE > btagWP) btagmulti++; } if(btagmulti > 0) b_step8=true; if(btagmultiM > 0) b_step9=true; return kTRUE; }
void swaps::Loop() { gROOT->ProcessLine(".x /home/gcowan/lhcb/lhcbStyle.C"); if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TH1D * mKK = new TH1D("mKK", "mKK", 100, 0.99, 1.050); TH1D * mKpi = new TH1D("mKpi", "mKpi", 100, 0.826, 0.966); TH1D * mKp = new TH1D("mKp", "mKp", 50, 1.45, 1.55); TH1D * massHisto = new TH1D("mJpsiKK_DTF", "mJpsiKK_DTF", 100, 5.20, 5.55); TH1D * mBs = new TH1D("mJpsiKK", "mJpsiKK", 100, 5.20, 5.55); TH1D * mBsVeto = new TH1D("mJpsiKKveto", "mJpsiKKveto", 100, 5.20, 5.55); //TH1D * mBsKpi = new TH1D("upper_Bs_sideband", "mJpsiKpi", 40, 5.21, 5.41); //TH1D * mBspiK = new TH1D("lower_Bs_sideband", "mJpsipiK", 40, 5.04, 5.24); TH1D * mBsKpi = new TH1D("upper_Bs_sideband", "mJpsiKpi", 40, 5.51, 5.71); TH1D * mBspiK = new TH1D("lower_Bs_sideband", "mJpsipiK", 40, 5.34, 5.54); TH1D * mJpsi_ = new TH1D("mJpsi", "mJpsi", 100, 3.03, 3.15); TH1D * mJpsi_constr = new TH1D("mJpsi_constr", "mJpsi", 100, 3.03, 3.15); Long64_t nbytes = 0, nb = 0; TFile * file = TFile::Open("reflection_upper_sideband.root", "RECREATE"); TNtuple * tuple = new TNtuple("DecayTree","DecayTree", "mass"); for (Long64_t jentry=0; jentry<nentries;jentry++) { //for (Long64_t jentry=0; jentry<1000;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if ( !(sel_cleantail==1&&sel==1&&(triggerDecisionUnbiased==1||triggerDecisionBiasedExcl==1)&&time>.3&&time<14&&sigmat>0&&sigmat<0.12 // &&(Kplus_pidK-Kplus_pidp)>-5 // &&(Kminus_pidK-Kminus_pidp)>-5 ) ) continue; //double mpi = 139.57018; double mK = 493.68; double mmu = 105.658; double mJpsi = 3096.916; double mpi = 938.27; TLorentzVector Kplus(Kplus_PX, Kplus_PY, Kplus_PZ, sqrt(Kplus_PX*Kplus_PX+Kplus_PY*Kplus_PY+Kplus_PZ*Kplus_PZ + mK*mK)); TLorentzVector Kminus(Kminus_PX, Kminus_PY, Kminus_PZ, sqrt(Kminus_PX*Kminus_PX+Kminus_PY*Kminus_PY+Kminus_PZ*Kminus_PZ + mK*mK)); TLorentzVector KplusWrong(Kplus_PX, Kplus_PY, Kplus_PZ, sqrt(Kplus_PX*Kplus_PX+Kplus_PY*Kplus_PY+Kplus_PZ*Kplus_PZ + mpi*mpi)); TLorentzVector KminusWrong(Kminus_PX, Kminus_PY, Kminus_PZ, sqrt(Kminus_PX*Kminus_PX+Kminus_PY*Kminus_PY+Kminus_PZ*Kminus_PZ + mpi*mpi)); TLorentzVector muplus(muplus_PX, muplus_PY, muplus_PZ, sqrt(muplus_P*muplus_P + mmu*mmu)); TLorentzVector muminus(muminus_PX, muminus_PY, muminus_PZ, sqrt(muminus_P*muminus_P + mmu*mmu)); TLorentzVector Jpsi = muplus + muminus; TLorentzVector Jpsi_constr(muminus_PX+muplus_PX, muminus_PY+muplus_PY, muminus_PZ+muplus_PZ, sqrt(Jpsi.P()*Jpsi.P() + mJpsi*mJpsi)); TLorentzVector KK = Kplus + Kminus; TLorentzVector Kpi = Kplus + KminusWrong; TLorentzVector piK = KplusWrong + Kminus; TLorentzVector B = Jpsi_constr + KK; TLorentzVector BKpi = Jpsi_constr + Kpi; TLorentzVector BpiK = Jpsi_constr + piK; //if ( ((BpiK.M() > 5600 && BpiK.M() < 5640) || (BKpi.M() > 5600 && BKpi.M() < 5640)) ) mBsVeto->Fill(mass/1000.); //if ( ( Kpi.M() > 1490 && Kpi.M() < 1550 ) || ( piK.M() > 1490 && piK.M() < 1550 ) ) continue;//mBsVeto->Fill(mass/1000.); mKK->Fill(KK.M()/1000.); mKp->Fill(Kpi.M()/1000.); mKp->Fill(piK.M()/1000.); mBs->Fill(B.M()/1000.); massHisto->Fill(mass/1000.); mJpsi_->Fill(Jpsi.M()/1000.); mJpsi_constr->Fill(Jpsi_constr.M()/1000.); if (mass > 5420) mBsKpi->Fill(BKpi.M()/1000.); if (mass > 5420) mBsKpi->Fill(BpiK.M()/1000.); if (mass < 5330) mBspiK->Fill(BKpi.M()/1000.); if (mass < 5330) mBspiK->Fill(BpiK.M()/1000.); if (mass > 5400) tuple->Fill(BKpi.M()); if (mass > 5400) tuple->Fill(BpiK.M()); } tuple->Write(); file->Close(); std::cout << "Number of B candidates " << mBs->GetEntries() << std::endl; std::cout << "Number of B candidates after Lambda_b veto" << mBsVeto->GetEntries() << std::endl; gROOT->SetStyle("Plain"); TCanvas * c = new TCanvas("c","c",1600,1200); c->Divide(3,2); c->cd(1); mKK->Draw(); mKK->SetTitle(""); mKK->GetXaxis()->SetTitle("m(KK) [GeV/c^{2}]"); c->cd(2); mJpsi_->Draw(); mJpsi_->SetTitle(""); mJpsi_->GetXaxis()->SetTitle("m(#mu#mu) [GeV/c^{2}]"); c->cd(3); //mKp->Draw(); mKp->SetTitle(""); mKp->GetXaxis()->SetTitle("m(Kp) [GeV/c^{2}]"); c->cd(4); massHisto->Draw(); //massHisto->SetMaximum(1500); mBs->SetLineColor(kRed); mBs->Draw("same"); mBsVeto->SetLineColor(kOrange); mBsVeto->Draw("same"); massHisto->SetTitle(""); massHisto->GetXaxis()->SetTitle("DTF m(J/#psi K^{+}K^{-}) [GeV/c^{2}]"); c->cd(5); mBspiK->Draw(); mBspiK->SetTitle(""); //mBspiK->GetXaxis()->SetTitle("m(J/#psi K#pi) [GeV/c^{2}]"); mBspiK->GetXaxis()->SetTitle("m(J/#psi Kp) [GeV/c^{2}]"); c->cd(6); mBsKpi->Draw(); mBsKpi->SetTitle(""); //mBsKpi->GetXaxis()->SetTitle("m(J/#psi K#pi) [GeV/c^{2}]"); mBsKpi->GetXaxis()->SetTitle("m(J/#psi Kp) [GeV/c^{2}]"); c->SaveAs("plots_swaps.pdf"); }
void newReduceTree(){ // -- define tuple file name, tuple name and cuts to apply // -- and also the name of the output file const std::string filename = "/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/Lb2chicpK_MC_2011_2012_signal_cut.root";//change const std::string treename = "DecayTree"; const std::string cuts = ""; const std::string outFile = "/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/reduced_Lb2chicpK_MC_2011_2012_signal.root");//change TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need tree->SetBranchStatus("*", 0); tree->SetBranchStatus("chi_c_M",1); tree->SetBranchStatus("chi_c_P",1); tree->SetBranchStatus("chi_c_PE",1); tree->SetBranchStatus("chi_c_PT",1); tree->SetBranchStatus("chi_c_PX",1); tree->SetBranchStatus("chi_c_PY",1); tree->SetBranchStatus("chi_c_PZ",1); tree->SetBranchStatus("chi_c_ETA",1); tree->SetBranchStatus("kaon_M",1); tree->SetBranchStatus("kaon_P",1); tree->SetBranchStatus("kaon_PE",1); tree->SetBranchStatus("kaon_PT",1); tree->SetBranchStatus("kaon_PX",1); tree->SetBranchStatus("kaon_PY",1); tree->SetBranchStatus("kaon_PZ",1); tree->SetBranchStatus("kaon_ETA",1); tree->SetBranchStatus("kaon_IPCHI2_OWNPV",1); tree->SetBranchStatus("kaon_TRACK_GhostProb",1); tree->SetBranchStatus("kaon_ProbNNp",1); tree->SetBranchStatus("kaon_ProbNNk",1); tree->SetBranchStatus("proton_M",1); tree->SetBranchStatus("proton_P",1); tree->SetBranchStatus("proton_PE",1); tree->SetBranchStatus("proton_PT",1); tree->SetBranchStatus("proton_PX",1); tree->SetBranchStatus("proton_PY",1); tree->SetBranchStatus("proton_PZ",1); tree->SetBranchStatus("proton_ETA",1); tree->SetBranchStatus("proton_IPCHI2_OWNPV",1); tree->SetBranchStatus("proton_TRACK_GhostProb",1); tree->SetBranchStatus("proton_ProbNNp",1); tree->SetBranchStatus("proton_ProbNNk",1); tree->SetBranchStatus("Jpsi_M",1); tree->SetBranchStatus("Jpsi_P",1); tree->SetBranchStatus("Jpsi_PE",1); tree->SetBranchStatus("Jpsi_PT",1); tree->SetBranchStatus("Jpsi_PX",1); tree->SetBranchStatus("Jpsi_PY",1); tree->SetBranchStatus("Jpsi_PZ",1); tree->SetBranchStatus("Jpsi_ETA",1); tree->SetBranchStatus("gamma_M",1); tree->SetBranchStatus("gamma_P",1); tree->SetBranchStatus("gamma_PE",1); tree->SetBranchStatus("gamma_PT",1); tree->SetBranchStatus("gamma_PX",1); tree->SetBranchStatus("gamma_PY",1); tree->SetBranchStatus("gamma_PZ",1); tree->SetBranchStatus("gamma_CL",1); tree->SetBranchStatus("gamma_ETA",1); tree->SetBranchStatus("muminus_M",1); tree->SetBranchStatus("muminus_P",1); tree->SetBranchStatus("muminus_PE",1); tree->SetBranchStatus("muminus_PT",1); tree->SetBranchStatus("muminus_PX",1); tree->SetBranchStatus("muminus_PY",1); tree->SetBranchStatus("muminus_PZ",1); tree->SetBranchStatus("muminus_ETA",1); tree->SetBranchStatus("muminus_ProbNNmu",1); tree->SetBranchStatus("muminus_TRACK_GhostProb",1); tree->SetBranchStatus("muplus_M",1); tree->SetBranchStatus("muplus_P",1); tree->SetBranchStatus("muplus_PE",1); tree->SetBranchStatus("muplus_PT",1); tree->SetBranchStatus("muplus_PX",1); tree->SetBranchStatus("muplus_PY",1); tree->SetBranchStatus("muplus_PZ",1); tree->SetBranchStatus("muplus_ETA",1); tree->SetBranchStatus("muplus_ProbNNmu",1); tree->SetBranchStatus("muplus_TRACK_GhostProb",1); tree->SetBranchStatus("Lambda_b0_DTF_MASS_constr1",1); tree->SetBranchStatus("Lambda_b0_DTF_MASS_constr2",1); tree->SetBranchStatus("Lambda_b0_DTF_CHI2NDOF",1); tree->SetBranchStatus("Lambda_b0_IPCHI2_OWNPV",1); tree->SetBranchStatus("Lambda_b0_FDS",1); tree->SetBranchStatus("Lambda_b0_L0MuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_L0DiMuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1TrackMuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1TrackAllL0Decision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_pi0veto",1); tree->SetBranchStatus("Lambda_b0_PT",1); //for MC only // tree->SetBranchStatus("chi_c_BKGCAT",1); // tree->SetBranchStatus("Jpsi_BKGCAT",1); // tree->SetBranchStatus("Lambda_b0_BKGCAT",1); // // -- this file is just here to make the 'CopyTree' happy TFile* dummyFile = new TFile("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree(cuts.c_str()); double chi_c_M, chi_c_P, chi_c_PE, chi_c_PT, chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_ETA; double kaon_M, kaon_P, kaon_PE, kaon_PX, kaon_PT, kaon_PY, kaon_PZ, kaon_ETA; double proton_M, proton_P, proton_PE, proton_PT, proton_PX, proton_PY, proton_PZ, proton_ETA; double Jpsi_M, Jpsi_P, Jpsi_PE, Jpsi_PT, Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_ETA; double gamma_M, gamma_P, gamma_PE, gamma_PT, gamma_PX, gamma_PY, gamma_PZ, gamma_ETA, gamma_CL; double muminus_M, muminus_P, muminus_PE, muminus_PT, muminus_PX, muminus_PY, muminus_PZ, muminus_ETA, muminus_ProbNNmu, muminus_TRACK_GhostProb; double muplus_M, muplus_P, muplus_PE, muplus_PT, muplus_PX, muplus_PY, muplus_PZ, muplus_ETA, muplus_ProbNNmu, muplus_TRACK_GhostProb; double kaon_IPCHI2_OWNPV, kaon_TRACK_GhostProb, kaon_ProbNNp, kaon_ProbNNk; double proton_IPCHI2_OWNPV, proton_TRACK_GhostProb, proton_ProbNNp, proton_ProbNNk; double Lambda_b0_DTF_MASS_constr1, Lambda_b0_DTF_MASS_constr2, Lambda_b0_DTF_CHI2NDOF, Lambda_b0_IPCHI2_OWNPV; double Lambda_b0_FDS, Lambda_b0_pi0veto, Lambda_b0_PT; bool Lambda_b0_L0MuonDecision_TOS, Lambda_b0_L0DiMuonDecision_TOS; bool Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, Lambda_b0_Hlt1DiMuonLowMassDecision_TOS; bool Lambda_b0_Hlt1TrackMuonDecision_TOS, Lambda_b0_Hlt1TrackAllL0Decision_TOS; bool Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedDecision_TOS; bool Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS; rTree1->SetBranchAddress("chi_c_M", &chi_c_M); rTree1->SetBranchAddress("chi_c_P", &chi_c_P); rTree1->SetBranchAddress("chi_c_PE", &chi_c_PE); rTree1->SetBranchAddress("chi_c_PT", &chi_c_PT); rTree1->SetBranchAddress("chi_c_PX", &chi_c_PX); rTree1->SetBranchAddress("chi_c_PY", &chi_c_PY); rTree1->SetBranchAddress("chi_c_PZ", &chi_c_PZ); rTree1->SetBranchAddress("chi_c_ETA", &chi_c_ETA); rTree1->SetBranchAddress("kaon_M", &kaon_M); rTree1->SetBranchAddress("kaon_P", &kaon_P); rTree1->SetBranchAddress("kaon_PE", &kaon_PE); rTree1->SetBranchAddress("kaon_PX", &kaon_PX); rTree1->SetBranchAddress("kaon_PT", &kaon_PT); rTree1->SetBranchAddress("kaon_PY", &kaon_PY); rTree1->SetBranchAddress("kaon_PZ", &kaon_PZ); rTree1->SetBranchAddress("kaon_ETA", &kaon_ETA); rTree1->SetBranchAddress("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV); rTree1->SetBranchAddress("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb); rTree1->SetBranchAddress("kaon_ProbNNp", &kaon_ProbNNp); rTree1->SetBranchAddress("kaon_ProbNNk", &kaon_ProbNNk); rTree1->SetBranchAddress("proton_M", &proton_M); rTree1->SetBranchAddress("proton_P", &proton_P); rTree1->SetBranchAddress("proton_PE", &proton_PE); rTree1->SetBranchAddress("proton_PT", &proton_PT); rTree1->SetBranchAddress("proton_PX", &proton_PX); rTree1->SetBranchAddress("proton_PY", &proton_PY); rTree1->SetBranchAddress("proton_PZ", &proton_PZ); rTree1->SetBranchAddress("proton_ETA", &proton_ETA); rTree1->SetBranchAddress("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV); rTree1->SetBranchAddress("proton_TRACK_GhostProb", &proton_TRACK_GhostProb); rTree1->SetBranchAddress("proton_ProbNNp", &proton_ProbNNp); rTree1->SetBranchAddress("proton_ProbNNk", &proton_ProbNNk); rTree1->SetBranchAddress("Jpsi_M", &Jpsi_M); rTree1->SetBranchAddress("Jpsi_P", &Jpsi_P); rTree1->SetBranchAddress("Jpsi_PE", &Jpsi_PE); rTree1->SetBranchAddress("Jpsi_PT", &Jpsi_PT); rTree1->SetBranchAddress("Jpsi_PX", &Jpsi_PX); rTree1->SetBranchAddress("Jpsi_PY", &Jpsi_PY); rTree1->SetBranchAddress("Jpsi_PZ", &Jpsi_PZ); rTree1->SetBranchAddress("Jpsi_ETA", &Jpsi_ETA); rTree1->SetBranchAddress("gamma_M", &gamma_M); rTree1->SetBranchAddress("gamma_P", &gamma_P); rTree1->SetBranchAddress("gamma_PE", &gamma_PE); rTree1->SetBranchAddress("gamma_PT", &gamma_PT); rTree1->SetBranchAddress("gamma_PX", &gamma_PX); rTree1->SetBranchAddress("gamma_PY", &gamma_PY); rTree1->SetBranchAddress("gamma_PZ", &gamma_PZ); rTree1->SetBranchAddress("gamma_ETA", &gamma_ETA); rTree1->SetBranchAddress("gamma_CL", &gamma_CL); rTree1->SetBranchAddress("muminus_M", &muminus_M); rTree1->SetBranchAddress("muminus_P", &muminus_P); rTree1->SetBranchAddress("muminus_PE", &muminus_PE); rTree1->SetBranchAddress("muminus_PT", &muminus_PT); rTree1->SetBranchAddress("muminus_PX", &muminus_PX); rTree1->SetBranchAddress("muminus_PY", &muminus_PY); rTree1->SetBranchAddress("muminus_PZ", &muminus_PZ); rTree1->SetBranchAddress("muminus_ETA", &muminus_ETA); rTree1->SetBranchAddress("muminus_ProbNNmu", &muminus_ProbNNmu); rTree1->SetBranchAddress("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb); rTree1->SetBranchAddress("muplus_M", &muplus_M); rTree1->SetBranchAddress("muplus_P", &muplus_P); rTree1->SetBranchAddress("muplus_PE", &muplus_PE); rTree1->SetBranchAddress("muplus_PT", &muplus_PT); rTree1->SetBranchAddress("muplus_PX", &muplus_PX); rTree1->SetBranchAddress("muplus_PY", &muplus_PY); rTree1->SetBranchAddress("muplus_PZ", &muplus_PZ); rTree1->SetBranchAddress("muplus_ETA", &muplus_ETA); rTree1->SetBranchAddress("muplus_ProbNNmu", &muplus_ProbNNmu); rTree1->SetBranchAddress("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr2", &Lambda_b0_DTF_MASS_constr2); rTree1->SetBranchAddress("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF); rTree1->SetBranchAddress("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV); rTree1->SetBranchAddress("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_FDS", &Lambda_b0_FDS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_pi0veto", &Lambda_b0_pi0veto); rTree1->SetBranchAddress("Lambda_b0_PT", &Lambda_b0_PT); //for MC only // int chi_c_BKGCAT, Jpsi_BKGCAT, Lambda_b0_BKGCAT; // rTree1->SetBranchAddress("chi_c_BKGCAT", &chi_c_BKGCAT); // rTree1->SetBranchAddress("Jpsi_BKGCAT", &Jpsi_BKGCAT); // rTree1->SetBranchAddress("Lambda_b0_BKGCAT", &Lambda_b0_BKGCAT); // TFile* rFile = new TFile( outFile.c_str() ,"RECREATE"); TTree* rTree2 = new TTree(); rTree2->SetName("DecayTree"); rTree2->Branch("chi_c_M", &chi_c_M, "chi_c_M/D"); rTree2->Branch("chi_c_P", &chi_c_P, "chi_c_P/D"); rTree2->Branch("chi_c_PE", &chi_c_PE, "chi_c_PE/D"); rTree2->Branch("chi_c_PT", &chi_c_PT, "chi_c_PT/D"); rTree2->Branch("chi_c_PX", &chi_c_PX, "chi_c_PX/D"); rTree2->Branch("chi_c_PY", &chi_c_PY, "chi_c_PY/D"); rTree2->Branch("chi_c_PZ", &chi_c_PZ, "chi_c_PZ/D"); rTree2->Branch("chi_c_ETA", &chi_c_ETA, "chi_c_ETA/D"); rTree2->Branch("kaon_M", &kaon_M, "kaon_M/D"); rTree2->Branch("kaon_P", &kaon_P, "kaon_P/D"); rTree2->Branch("kaon_PE", &kaon_PE, "kaon_PE/D"); rTree2->Branch("kaon_PX", &kaon_PX, "kaon_PX/D"); rTree2->Branch("kaon_PT", &kaon_PT, "kaon_PT/D"); rTree2->Branch("kaon_PY", &kaon_PY, "kaon_PY/D"); rTree2->Branch("kaon_PZ", &kaon_PZ, "kaon_PZ/D"); rTree2->Branch("kaon_ETA", &kaon_ETA, "kaon_ETA/D"); rTree2->Branch("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV, "kaon_IPCHI2_OWNPV/D"); rTree2->Branch("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb, "kaon_TRACK_GhostProb/D"); rTree2->Branch("kaon_ProbNNp", &kaon_ProbNNp, "kaon_ProbNNp/D"); rTree2->Branch("kaon_ProbNNk", &kaon_ProbNNk, "kaon_ProbNNk/D"); rTree2->Branch("proton_M", &proton_M, "proton_M/D"); rTree2->Branch("proton_P", &proton_P, "proton_P/D"); rTree2->Branch("proton_PE", &proton_PE, "proton_PE/D"); rTree2->Branch("proton_PT", &proton_PT, "proton_PT/D"); rTree2->Branch("proton_PX", &proton_PX, "proton_PX/D"); rTree2->Branch("proton_PY", &proton_PY, "proton_PY/D"); rTree2->Branch("proton_PZ", &proton_PZ, "proton_PZ/D"); rTree2->Branch("proton_ETA", &proton_ETA, "proton_ETA/D"); rTree2->Branch("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV, "proton_IPCHI2_OWNPV/D"); rTree2->Branch("proton_TRACK_GhostProb", &proton_TRACK_GhostProb, "proton_TRACK_GhostProb/D"); rTree2->Branch("proton_ProbNNp", &proton_ProbNNp, "proton_ProbNNp/D"); rTree2->Branch("proton_ProbNNk", &proton_ProbNNk, "proton_ProbNNk/D"); rTree2->Branch("Jpsi_M", &Jpsi_M, "Jpsi_M/D"); rTree2->Branch("Jpsi_P", &Jpsi_P, "Jpsi_P/D"); rTree2->Branch("Jpsi_PE", &Jpsi_PE, "Jpsi_PE/D"); rTree2->Branch("Jpsi_PT", &Jpsi_PT, "Jpsi_PT/D"); rTree2->Branch("Jpsi_PX", &Jpsi_PX, "Jpsi_PX/D"); rTree2->Branch("Jpsi_PY", &Jpsi_PY, "Jpsi_PY/D"); rTree2->Branch("Jpsi_PZ", &Jpsi_PZ, "Jpsi_PZ/D"); rTree2->Branch("Jpsi_ETA", &Jpsi_ETA, "Jpsi_ETA/D"); rTree2->Branch("gamma_M", &gamma_M, "gamma_M/D"); rTree2->Branch("gamma_P", &gamma_P, "gamma_P/D"); rTree2->Branch("gamma_PE", &gamma_PE, "gamma_PE/D"); rTree2->Branch("gamma_PT", &gamma_PT, "gamma_PT/D"); rTree2->Branch("gamma_PX", &gamma_PX, "gamma_PX/D"); rTree2->Branch("gamma_PY", &gamma_PY, "gamma_PY/D"); rTree2->Branch("gamma_PZ", &gamma_PZ, "gamma_PZ/D"); rTree2->Branch("gamma_ETA", &gamma_ETA, "gamma_ETA/D"); rTree2->Branch("gamma_CL", &gamma_CL, "gamma_CL/D"); rTree2->Branch("muminus_M", &muminus_M, "muminus_M/D"); rTree2->Branch("muminus_P", &muminus_P, "muminus_P/D"); rTree2->Branch("muminus_PE", &muminus_PE, "muminus_PE/D"); rTree2->Branch("muminus_PT", &muminus_PT, "muminus_PT/D"); rTree2->Branch("muminus_PX", &muminus_PX, "muminus_PX/D"); rTree2->Branch("muminus_PY", &muminus_PY, "muminus_PY/D"); rTree2->Branch("muminus_PZ", &muminus_PZ, "muminus_PZ/D"); rTree2->Branch("muminus_ETA", &muminus_ETA, "muminus_ETA/D"); rTree2->Branch("muminus_ProbNNmu", &muminus_ProbNNmu, "muminus_ProbNNmu/D"); rTree2->Branch("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb, "muminus_TRACK_GhostProb/D"); rTree2->Branch("muplus_M", &muplus_M, "muplus_M/D"); rTree2->Branch("muplus_P", &muplus_P, "muplus_P/D"); rTree2->Branch("muplus_PE", &muplus_PE, "muplus_PE/D"); rTree2->Branch("muplus_PT", &muplus_PT, "muplus_PT/D"); rTree2->Branch("muplus_PX", &muplus_PX, "muplus_PX/D"); rTree2->Branch("muplus_PY", &muplus_PY, "muplus_PY/D"); rTree2->Branch("muplus_PZ", &muplus_PZ, "muplus_PZ/D"); rTree2->Branch("muplus_ETA", &muplus_ETA, "muplus_ETA/D"); rTree2->Branch("muplus_ProbNNmu", &muplus_ProbNNmu, "muplus_ProbNNmu/D"); rTree2->Branch("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb, "muplus_TRACK_GhostProb/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1, "Lambda_b0_DTF_MASS_constr1/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr2", &Lambda_b0_DTF_MASS_constr2, "Lambda_b0_DTF_MASS_constr2/D"); rTree2->Branch("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF, "Lambda_b0_DTF_CHI2NDOF/D"); rTree2->Branch("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV, "Lambda_b0_IPCHI2_OWNPV/D"); rTree2->Branch("Lambda_b0_L0DiMuonDecision_TOS",&Lambda_b0_L0DiMuonDecision_TOS,"Lambda_b0_L0DiMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS, "Lambda_b0_L0MuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_FDS", &Lambda_b0_FDS, "Lambda_b0_FDS/D"); rTree2->Branch("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, "Lambda_b0_Hlt1DiMuonHighMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS, "Lambda_b0_Hlt1DiMuonLowMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS, "Lambda_b0_Hlt1TrackMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS, "Lambda_b0_Hlt1TrackAllL0Decision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, "Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS/B"); rTree2->Branch("Lambda_b0_pi0veto", &Lambda_b0_pi0veto, "Lambda_b0_pi0veto/D"); rTree2->Branch("Lambda_b0_PT", &Lambda_b0_PT, "Lambda_b0_PT/D"); //for MC only // rTree2->Branch("chi_c_BKGCAT", &chi_c_BKGCAT, "chi_c_BKGCAT/I"); // rTree2->Branch("Jpsi_BKGCAT", &Jpsi_BKGCAT, "Jpsi_BKGCAT/I"); // rTree2->Branch("Lambda_b0_BKGCAT", &Lambda_b0_BKGCAT, "Lambda_b0_BKGCAT/I"); // //----------------------------------------------------------------------------------- const double mK(493.677); const double mpi(139.57); const double mp(938.27); double m_pK, m_chicp; double proton_as_kaon_M, proton_as_pion_M, proton_as_proton_M; double m_chicpK_proton_as_kaon, m_chicpK_proton_as_pion, m_chicpK_proton_as_proton; double m_JpsipK; rTree2->Branch("m_JpsipK", &m_JpsipK, "m_JpsipK/D"); rTree2->Branch("m_chicp", &m_chicp, "m_chicp/D"); rTree2->Branch("m_pK", &m_pK, "m_pK/D"); rTree2->Branch("proton_as_kaon_M", &proton_as_kaon_M, "proton_as_kaon_M/D"); rTree2->Branch("proton_as_pion_M", &proton_as_pion_M, "proton_as_pion_M/D"); rTree2->Branch("proton_as_proton_M", &proton_as_proton_M, "proton_as_proton_M/D"); rTree2->Branch("m_chicpK_proton_as_kaon", &m_chicpK_proton_as_kaon, "m_chicpK_proton_as_kaon/D"); rTree2->Branch("m_chicpK_proton_as_pion", &m_chicpK_proton_as_pion, "m_chicpK_proton_as_pion/D"); rTree2->Branch("m_chicpK_proton_as_proton", &m_chicpK_proton_as_proton, "m_chicpK_proton_as_proton/D"); int percentCounter = 1; for(int i = 0; i < rTree1->GetEntries(); ++i){ const int percent = (int)(rTree1->GetEntries()/100.0); if( i == percent*percentCounter ){ std::cout << percentCounter << " %" << std::endl; percentCounter++; } rTree1->GetEntry(i); double proton_P = sqrt(proton_PX*proton_PX + proton_PY*proton_PY + proton_PZ*proton_PZ) ; TLorentzVector proton_as_kaon( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mK*mK)); TLorentzVector proton_as_pion( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mpi*mpi)); TLorentzVector proton_as_proton( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + proton_M*proton_M)); TLorentzVector kaon( kaon_PX, kaon_PY, kaon_PZ, kaon_PE); TLorentzVector chic( chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_PE); TLorentzVector proton(proton_PX, proton_PY, proton_PZ, proton_PE); TLorentzVector Jpsi( Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_PE); proton_as_kaon_M = proton_as_kaon.M(); proton_as_pion_M = proton_as_pion.M(); proton_as_proton_M = proton_as_proton.M(); TLorentzVector chic_PasK_K = chic + kaon + proton_as_kaon; TLorentzVector chic_PasPi_K = chic + kaon + proton_as_pion; TLorentzVector chic_PasP_K = chic + kaon + proton_as_proton; m_chicpK_proton_as_kaon = chic_PasK_K.M(); m_chicpK_proton_as_pion = chic_PasPi_K.M(); m_chicpK_proton_as_proton = chic_PasP_K.M(); TLorentzVector JpsipK = Jpsi + proton + kaon; TLorentzVector chicp = chic + proton; TLorentzVector pK = proton + kaon; m_JpsipK = JpsipK.M(); m_chicp = chicp.M(); m_pK = pK.M(); rTree2->Fill(); } rTree2->Print(); rTree2->Write(); rFile->Save(); }