void Tran_to_cm(TLorentzVector e_vec, TLorentzVector d_vec, TLorentzVector &e_cm, TLorentzVector &d_cm){ //input: // e_vec - electron 4 vector in some frame // d_vec - ion 4 vector in some frame //output: // e_ft - electron 4 vector in center of mass frame // d_ft - ion 4 vector in center of mass frame e_cm = e_vec; d_cm = d_vec; TLorentzVector cm_vec = e_vec + d_vec; e_cm.Boost(-cm_vec.BoostVector()); d_cm.Boost(-cm_vec.BoostVector()); return; }
// This is the pt corrected delta phi between the 2 mega-jets // P and Q are the 4-vectors for the 2 hemispheres // M is the MET 3 vector (don't forget to set the z-component of // MET to 0) // This function will do the correct Lorentz transformations of the // leptons for you double HWWKinematics::CalcDeltaPhiNEW(TLorentzVector P, TLorentzVector Q, TVector3 M){ // first calculate pt-corrected MR float mymrnew = CalcMRNEW(L1,L2,MET); //Next, calculate the transverse Lorentz transformation TVector3 B = P.Vect()+Q.Vect()+MET; B.SetZ(0.0); B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B; P.Boost(B); Q.Boost(B); //Now, re-calculate the delta phi // in the new reference frame: return P.DeltaPhi(Q); }
void rochcor::momcor_mc( TLorentzVector& mu, float charge, float sysdev, int runopt){ //sysdev == num : deviation = num float ptmu = mu.Pt(); float muphi = mu.Phi(); float mueta = mu.Eta(); // same with mu.Eta() in Root float px = mu.Px(); float py = mu.Py(); float pz = mu.Pz(); float e = mu.E(); int mu_phibin = phibin(muphi); int mu_etabin = etabin(mueta); //float mptsys = sran.Gaus(0.0,sysdev); float dm = (mcor_bf[mu_phibin][mu_etabin] + mptsys_mc_dm[mu_phibin][mu_etabin]*mcor_bfer[mu_phibin][mu_etabin])/mmavg[mu_phibin][mu_etabin]; float da = mcor_ma[mu_phibin][mu_etabin] + mptsys_mc_da[mu_phibin][mu_etabin]*mcor_maer[mu_phibin][mu_etabin]; float cor = 1.0/(1.0 + dm + charge*da*ptmu); //for the momentum tuning - eta,phi,Q correction px *= cor; py *= cor; pz *= cor; e *= cor; float gscler = 0.0; float deltaer = 0.0; float sfer = 0.0; gscler = TMath::Sqrt( TMath::Power(mgscl_stat,2) + TMath::Power(mgscl_syst,2) ); deltaer = TMath::Sqrt( TMath::Power(delta_stat,2) + TMath::Power(delta_syst,2) ); sfer = TMath::Sqrt( TMath::Power(sf_stat,2) + TMath::Power(sf_syst,2) ); float tune = 1.0/(1.0 + (delta + sysdev*deltaer)*sqrt(px*px + py*py)*eran.Gaus(1.0,(sf + sysdev*sfer))); px *= (tune); py *= (tune); pz *= (tune); e *= (tune); float gscl = (genm_smr/mrecm); px *= (gscl + gscler_mc_dev*gscler); py *= (gscl + gscler_mc_dev*gscler); pz *= (gscl + gscler_mc_dev*gscler); e *= (gscl + gscler_mc_dev*gscler); mu.SetPxPyPzE(px,py,pz,e); }
void rochcor2012::momcor_mc( TLorentzVector& mu, float charge, float sysdev, int runopt, float& qter){ //sysdev == num : deviation = num float ptmu = mu.Pt(); float muphi = mu.Phi(); float mueta = mu.Eta(); // same with mu.Eta() in Root float px = mu.Px(); float py = mu.Py(); float pz = mu.Pz(); float e = mu.E(); int mu_phibin = phibin(muphi); int mu_etabin = etabin(mueta); //float mptsys = sran.Gaus(0.0,sysdev); float Mf = (mcor_bf[mu_phibin][mu_etabin] + mptsys_mc_dm[mu_phibin][mu_etabin]*mcor_bfer[mu_phibin][mu_etabin])/(mpavg[mu_phibin][mu_etabin]+mmavg[mu_phibin][mu_etabin]); float Af = ((mcor_ma[mu_phibin][mu_etabin]+mptsys_mc_da[mu_phibin][mu_etabin]*mcor_maer[mu_phibin][mu_etabin]) - Mf*(mpavg[mu_phibin][mu_etabin]-mmavg[mu_phibin][mu_etabin])); float cor = 1.0/(1.0 + 2.0*Mf + charge*Af*ptmu); //for the momentum tuning - eta,phi,Q correction px *= cor; py *= cor; pz *= cor; e *= cor; float gscler = mgscl_stat; float deltaer = delta_stat; float sfer = sf_stat; float gscl = (genm_smr/mrecm); px *= (gscl + gscler_mc_dev*gscler); py *= (gscl + gscler_mc_dev*gscler); pz *= (gscl + gscler_mc_dev*gscler); e *= (gscl + gscler_mc_dev*gscler); float momscl = sqrt(px*px + py*py)/ptmu; float tune = 1.0/(1.0 + (delta + sysdev*deltaer)*sqrt(px*px + py*py)*eran.Gaus(1.0,(sf + sysdev*sfer))); px *= (tune); py *= (tune); pz *= (tune); e *= (tune); qter *= (momscl*momscl + (1.0-tune)*(1.0-tune)); mu.SetPxPyPzE(px,py,pz,e); }
double HWWKinematics::CalcUnboostedMTR(TLorentzVector P, TLorentzVector Q, TVector3 M){ // first calculate pt-corrected MR float mymrnew = CalcMRNEW(L1,L2,MET); //Next, calculate the transverse Lorentz transformation TVector3 B = P.Vect()+Q.Vect()+MET; B.SetZ(0.0); B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B; P.Boost(B); Q.Boost(B); //Now, re-calculate MTR in the new reference frame: float mymtrnew = CalcMTRNEW(P, Q); //R is now just the ratio of mymrnew and mymtrnew; return mymtrnew; }
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 Delta(double pt1, double eta1, double phi1,double pt2, double eta2, double phi2,double t1pfmetPhi){ TLorentzVector fLorentzVec1; TLorentzVector fLorentzVec2; TLorentzVector fLorentzVecgg; // Fill TLorentzVector fLorentzVec1.SetPtEtaPhiM(pt1,eta1,phi1,0.); fLorentzVec2.SetPtEtaPhiM(pt2,eta2,phi2,0.); fLorentzVecgg = fLorentzVec1 + fLorentzVec2; double phigg= fLorentzVecgg.Phi(); double delta = phigg-t1pfmetPhi; if(delta>3.14){ delta-=6.28; } if(delta<-3.14){ delta+=6.28; } delta =fabs(delta); return delta; }
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 }
double Histogrammer::minDrPhoB(int PhoInd, EventTree* tree){ // find the closest b-jet TLorentzVector b; TLorentzVector bBar; int phoGen=-1; double mindr = 999.0; for( int mcI = 0; mcI < tree->nMC_; ++mcI){ if( tree->mcIndex->at(mcI) == tree->phoGenIndex_->at(PhoInd) ) phoGen=mcI; if( tree->mcPID->at(mcI) == 5) b.SetPtEtaPhiM(tree->mcPt->at(mcI), tree->mcEta->at(mcI), tree->mcPhi->at(mcI), tree->mcMass->at(mcI)); if( tree->mcPID->at(mcI) == -5) bBar.SetPtEtaPhiM(tree->mcPt->at(mcI), tree->mcEta->at(mcI), tree->mcPhi->at(mcI), tree->mcMass->at(mcI)); } if( phoGen > 0 && b.Pt() > 0.0001 && bBar.Pt() > 0.0001 ) { mindr = std::min(dR(tree->mcEta->at(phoGen), tree->mcPhi->at(phoGen), b.Eta(), b.Phi()), dR(tree->mcEta->at(phoGen), tree->mcPhi->at(phoGen), bBar.Eta(), bBar.Phi())); } return mindr; }
void Output_Delphes::AnalyseParticles(ExRootTreeBranch *branch, const HepMC::GenEvent& evt) { TRootC::GenParticle *element; TLorentzVector momentum; Double_t signPz; ReadStats(); for(int n=1; n<=evt.particles_size(); n++) { int mo1, mo2, da1, da2, status, pid; getStatsFromTuple(mo1,mo2,da1,da2,status,pid,n); element = static_cast<TRootC::GenParticle*>(branch->NewEntry()); element->PID = pid; element->Status = status; element->M1 = mo1 - 1; // added -1 as the numbering in the tree starts from 0 element->M2 = mo2 - 1; element->D1 = da1 - 1; element->D2 = da2 - 1; element->E = index_to_particle[n]->momentum().e(); element->Px = index_to_particle[n]->momentum().px(); element->Py = index_to_particle[n]->momentum().py(); element->Pz = index_to_particle[n]->momentum().pz(); element->PT = sqrt(pow(element->Px,2)+pow(element->Py,2)); momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E); signPz = (element->Pz >= 0.0) ? 1.0 : -1.0; element->Eta = element->PT < 1e-6 ? signPz*999.9 : momentum.Eta(); element->Phi = index_to_particle[n]->momentum().phi(); HepMC::GenVertex* vrtI = (index_to_particle[n])->production_vertex(); HepMC::GenVertex::particles_in_const_iterator partI; if(vrtI) { element->T = vrtI->position().t(); element->X = vrtI->position().x(); element->Y = vrtI->position().y(); element->Z = vrtI->position().z(); } else { element->T = 0.; element->X = 0.; element->Y = 0.; element->Z = 0.; } } }
//This is the function to determine the interaction point in case of a cylinder (case1), for BDXmini. //The cylinder is with the axis along y(vertical), center at x=0,y=0,z=ldet, radius is R,height is h double KinUtils::findInteractionPointCylinder1(const TLorentzVector &chi,double ldet,double h,double R,TVector3 &vin,TVector3 &vout,TVector3 &vhit){ double tIN,tOUT,t2,t3,t,L; double px=chi.Px(); double py=chi.Py(); double pz=chi.Pz(); double delta=pz*pz*ldet*ldet-(pz*pz+px*px)*(ldet*ldet-R*R); if (delta<0){ cout<<"KinUtils::findInteractionPointCylinder1 error, the delta is: "<<delta<<endl; return 0; } //entry point tIN = (pz*ldet - sqrt(delta))/(px*px+pz*pz); t2 = (pz*ldet + sqrt(delta))/(px*px+pz*pz); t3 = (h/2)/py; if ((t3>0)&&(t3<t2)&&(t3>tIN)){ tOUT=t3; }else{ tOUT=t2; } t=Rand.Uniform(tIN,tOUT); vin.SetXYZ(tIN*px,tIN*py,tIN*pz); vout.SetXYZ(tOUT*px,tOUT*py,tOUT*pz); vhit.SetXYZ(t*px,t*py,t*pz); L = (vout - vin).Mag(); return L; }
std::vector<double> CalculateDeltaEtaAndPhi(bool possibleMultW, bool possibleMultAntiW, int w1, TLorentzVector TL_munu){ //Don't take into account the events with multiple W's. Think of something double deltaphi, deltaeta; if(possibleMultW == false && possibleMultAntiW == false){ deltaphi = TMath::Abs(TVector2::Phi_mpi_pi(TL_munu.Phi() - genPhi[w1]) ); deltaeta = TMath::Abs(TL_munu.Eta() - genEta[w1] ); } else { deltaphi = 99.; deltaeta = 99.; } std::vector<double> EtaAndPhi; EtaAndPhi.push_back(deltaeta); EtaAndPhi.push_back(deltaphi); return EtaAndPhi; }
void getKinematics(TLorentzVector& b, double const mass) { float const pt = gRandom->Uniform(momentumRange.first, momentumRange.second); float const y = gRandom->Uniform(-acceptanceRapidity, acceptanceRapidity); float const phi = TMath::TwoPi() * gRandom->Rndm(); float const mT = sqrt(mass * mass + pt * pt); float const pz = mT * sinh(y); float const E = mT * cosh(y); b.SetPxPyPzE(pt * cos(phi), pt * sin(phi) , pz, E); }
// // // double analysisClass::RecoHLTdeltaRmin_SingleMu24Trigger( unsigned int iReco ){ TLorentzVector HLTLep; TLorentzVector RecoLep; double deltaRmin=999999.9; RecoLep.SetPtEtaPhiM( muPtcorr(iReco), MuonEta->at(iReco), MuonPhi->at(iReco), 0); // for(unsigned int ifilter=0; ifilter<HLTFilterName->size(); ifilter++){ // // HLT_Mu24_eta2p1_v* if( HLTFilterName->at(ifilter) == "hltL3fL1sMu16Eta2p1L1f0L2f16QL3Filtered24Q" //V3,V4,V5 ){ // // ----- extract TrigObject 4-vector ----- std::vector<std::vector<float> > * TrigObjectPt_TrigArray; vector<float> trigObjPtArray; float trigObjPt_; std::vector<std::vector<float> > * TrigObjectEta_TrigArray; vector<float> trigObjEtaArray; float trigObjEta_; std::vector<std::vector<float> > * TrigObjectPhi_TrigArray; vector<float> trigObjPhiArray; float trigObjPhi_; TrigObjectPt_TrigArray = HLTFilterObjPt; trigObjPtArray = (*TrigObjectPt_TrigArray)[ifilter]; TrigObjectEta_TrigArray = HLTFilterObjEta; trigObjEtaArray = (*TrigObjectEta_TrigArray)[ifilter]; TrigObjectPhi_TrigArray = HLTFilterObjPhi; trigObjPhiArray = (*TrigObjectPhi_TrigArray)[ifilter]; // ----- ----- ----- ----- ----- ----- ----- for(unsigned int iobj=0; iobj<trigObjPtArray.size(); iobj++){//loop over all trigObjects of selected Filter trigObjPt_ = (trigObjPtArray)[iobj]; trigObjEta_= (trigObjEtaArray)[iobj]; trigObjPhi_= (trigObjPhiArray)[iobj]; HLTLep.SetPtEtaPhiM( trigObjPt_, trigObjEta_, trigObjPhi_, 0 ); if(RecoLep.DeltaR(HLTLep)<deltaRmin) deltaRmin = RecoLep.DeltaR(HLTLep); } } } // return deltaRmin; }
double PTCut::HistResp(TLorentzVector tmpP, double respHCAL, double respECAL, double respEHHCAL, double respEHECAL) { double respSum = 0; // In case of inconsistensies in binning, the bins are checked explicitely int binHadrf = 0; int binEcalf = 0; double trueFracECAL = 0; double fE = 0; // H: all energy in HCAL; this is multiplied with HCAL response binHadrf = pfh->FindBin(tmpP.Perp()); respSum += (pfh->GetBinContent(binHadrf))*respHCAL; // E: energy only in ECAL, fraction multiplied with ECAL response binHadrf = pfe->FindBin(tmpP.Perp()); respSum += (pfe->GetBinContent(binHadrf))*respECAL; // pf0: nothing is added for the lost hadrons, effectively: // respSum += (pf0->GetBinContent(binHadrf))*0; // eH: energy in both ECAL and HCAL, mostly HCAL. Does not work // intuitively (compared to EH). First, approximate H by HCAL // resp. times tot energy - 0.3 GeV. Move 0.3 GeV to ECAL and // use response for this. binHadrf = pfe0h->FindBin(tmpP.Perp()); respSum += (pfe0h->GetBinContent(binHadrf))*( 0.3*(respECAL-1) + respHCAL ); // EH: energy in both ECAL and HCAL binHadrf = pfe1h->FindBin(tmpP.Perp()); binEcalf = pef1->FindBin(tmpP.Perp()); fE = pef1->GetBinContent(binEcalf); trueFracECAL = fE/((1-fE)*respEHECAL/respEHHCAL+1); respSum += (pfe1h->GetBinContent(binHadrf))*(trueFracECAL*respEHECAL +(1-trueFracECAL)*respEHHCAL); return respSum; }
HHKinFit2::HHKinFitMasterSingleHiggs::HHKinFitMasterSingleHiggs(TLorentzVector const& tauvis1, TLorentzVector const& tauvis2, TVector2 const& met, TMatrixD const& met_cov, bool istruth, TLorentzVector const& higgsgen) :m_MET_COV(TMatrixD(4,4)) { m_tauvis1 = HHLorentzVector(tauvis1.Px(), tauvis1.Py(), tauvis1.Pz(), tauvis1.E()); m_tauvis2 = HHLorentzVector(tauvis2.Px(), tauvis2.Py(), tauvis2.Pz(), tauvis2.E()); m_tauvis1.SetMkeepE(1.77682); m_tauvis2.SetMkeepE(1.77682); m_MET = met; m_MET_COV = met_cov; m_chi2_best = pow(10,10); m_bestHypo = 0; // if (istruth){ // TRandom3 r(0); // // HHLorentzVector recoil; // if(heavyhiggsgen != NULL){ // Double_t pxRecoil = r.Gaus(-(heavyhiggsgen->Px() ), 10.0); // Double_t pyRecoil = r.Gaus(-(heavyhiggsgen->Py() ), 10.0); // // recoil = HHLorentzVector(pxRecoil, pyRecoil, 0, // sqrt(pxRecoil*pxRecoil+pyRecoil*pyRecoil)); // } // else{ // recoil = HHLorentzVector(0,0,0,0); // std::cout << "WARNING! Truthinput mode active but no Heavy Higgs gen-information given! Setting Recoil to Zero!" << std::endl; // } // // TMatrixD recoilCov(2,2); // recoilCov(0,0)=100; recoilCov(0,1)=0; // recoilCov(1,0)=0; recoilCov(1,1)=100; // // HHLorentzVector recoHH = m_bjet1 + m_bjet2 + m_tauvis1 + m_tauvis2 + recoil; // m_MET = TVector2(-recoHH.Px(), -recoHH.Py() ); // // m_MET_COV = TMatrixD(2,2); // m_MET_COV = recoilCov + bjet1Cov + bjet2Cov; // // } }
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); }
bool KinUtils::intersectsCylinder1(const TLorentzVector &chi,double ldet,double h,double R){ double t1,y; double px=chi.Px(); double py=chi.Py(); double pz=chi.Pz(); double delta=pz*pz*ldet*ldet-(pz*pz+px*px)*(ldet*ldet-R*R); if (delta<0) return false; t1 = (pz*ldet - sqrt(delta))/(px*px+pz*pz); //this is where it enters y = t1*py; if ((y>h/2)||(y<-h/2)) return false; return true; }
void rochcor2012::momcor_data( TLorentzVector& mu, float charge, int runopt, float& qter){ float ptmu = mu.Pt(); float muphi = mu.Phi(); float mueta = mu.Eta(); // same with mu.Eta() in Root float px = mu.Px(); float py = mu.Py(); float pz = mu.Pz(); float e = mu.E(); int mu_phibin = phibin(muphi); int mu_etabin = etabin(mueta); float Mf = 0.0; float Af = 0.0; if(runopt==0){ Mf = (dcor_bf[mu_phibin][mu_etabin]+mptsys_da_dm[mu_phibin][mu_etabin]*dcor_bfer[mu_phibin][mu_etabin])/(dpavg[mu_phibin][mu_etabin]+dmavg[mu_phibin][mu_etabin]); Af = ((dcor_ma[mu_phibin][mu_etabin]+mptsys_da_da[mu_phibin][mu_etabin]*dcor_maer[mu_phibin][mu_etabin]) - Mf*(dpavg[mu_phibin][mu_etabin]-dmavg[mu_phibin][mu_etabin])); }else if(runopt==1){ Mf = (dcor_bfD[mu_phibin][mu_etabin]+mptsys_da_dm[mu_phibin][mu_etabin]*dcor_bfDer[mu_phibin][mu_etabin])/(dpavgD[mu_phibin][mu_etabin]+dmavgD[mu_phibin][mu_etabin]); Af = ((dcor_maD[mu_phibin][mu_etabin]+mptsys_da_da[mu_phibin][mu_etabin]*dcor_maDer[mu_phibin][mu_etabin]) - Mf*(dpavgD[mu_phibin][mu_etabin]-dmavgD[mu_phibin][mu_etabin])); } float cor = 1.0/(1.0 + 2.0*Mf + charge*Af*ptmu); px *= cor; py *= cor; pz *= cor; e *= cor; //after Z pt correction float gscler = dgscl_stat; float gscl = (genm_smr/drecm); px *= (gscl + gscler_da_dev*gscler); py *= (gscl + gscler_da_dev*gscler); pz *= (gscl + gscler_da_dev*gscler); e *= (gscl + gscler_da_dev*gscler); float momscl = sqrt(px*px + py*py)/ptmu; qter *= momscl; mu.SetPxPyPzE(px,py,pz,e); }
TLorentzVector muon_pog::Plotter::muonTk(const muon_pog::Muon & muon) { std::string & trackType = m_config.muon_trackType; TLorentzVector result; if (trackType == "PF") result.SetPtEtaPhiM(muon.pt,muon.eta,muon.phi,.10565); else if (trackType == "TUNEP") result.SetPtEtaPhiM(muon.pt_tuneP,muon.eta_tuneP,muon.phi_tuneP,.10565); else if (trackType == "GLB") result.SetPtEtaPhiM(muon.pt_global,muon.eta_global,muon.phi_global,.10565); else if (trackType == "INNER") result.SetPtEtaPhiM(muon.pt_tracker,muon.eta_tracker,muon.phi_tracker,.10565); else { std::cout << "[Plotter::muonTk]: Invalid track type: " << trackType << std::endl; exit(900); } return result; }
void countDoubles(RhoCandList &l, int &n1, int &n2, int &n3) { int n_smc = 0; int n_strk = 0; int n_both = 0; double d = 0.00001; for (int i=0;i<l.GetLength()-1;++i) { for (int j=i+1;j<l.GetLength();++j) { TLorentzVector dl = l[i]->P4() - l[j]->P4(); bool chkmc = (l[i]->GetMcTruth()==l[j]->GetMcTruth()); bool chktrk = (fabs(dl.X())<d) && (fabs(dl.Y())<d) && (fabs(dl.Z())<d) && (fabs(dl.E())<d); if (chkmc) n_smc++; if (chktrk) n_strk++; if (chktrk && chkmc) n_both++; } } n1 = n_strk; n2 = n_smc; n3 = n_both; }
TLorentzVector selectPhoton( const ZGConfig& cfg, const ZGTree& myTree, int index, const TLorentzVector& lept0, const TLorentzVector& lept1, EnergyScaleCorrection_class egcor ) { TLorentzVector photon; if( myTree.ngamma<=index ) { photon.SetPtEtaPhiM( 0.01, 0., 0., 0. ); return photon; } photon.SetPtEtaPhiM( myTree.gamma_pt[index], myTree.gamma_eta[index], myTree.gamma_phi[index], myTree.gamma_mass[index] ); // photon energy corrections/smearing if( !myTree.isData ) { if( cfg.smearing() ) { smearEmEnergy( egcor, photon, myTree, myTree.gamma_r9[0] ); } } else { if( cfg.smearing() ) { applyEmEnergyScale( egcor, photon, myTree, myTree.gamma_r9[0] ); } } bool goodPhoton = true; if( photon.Pt()<40. ) goodPhoton=false; if( fabs(photon.Eta())>1.4442 && fabs(photon.Eta())<1.566 ) goodPhoton=false; if( fabs(photon.Eta())>2.5 ) goodPhoton=false; if( myTree.gamma_idCutBased[index]==0 ) goodPhoton=false; if( myTree.gamma_chHadIso[index]>2.5 ) goodPhoton=false; if( fabs(myTree.gamma_eta[index])<1.44 ) { if( myTree.gamma_sigmaIetaIeta[index]>0.0102 ) goodPhoton=false; } else { if( myTree.gamma_sigmaIetaIeta[index]>0.0274 ) goodPhoton=false; } float deltaR_thresh = 0.4; if( photon.DeltaR(lept0)<deltaR_thresh || photon.DeltaR(lept1)<deltaR_thresh ) goodPhoton=false; if( !goodPhoton ) photon.SetPtEtaPhiM( 0.01, 0., 0., 0. ); return photon; }
double CosThetaStar(TLorentzVector p1, TLorentzVector p2){ TLorentzVector p = p1 + p2; TVector3 theBoost = p.BoostVector(); TVector3 bostDir; if ( theBoost.Mag() != 0 ) bostDir = theBoost.Unit(); // / theBoost.Mag()); else return -1; p1.Boost(-theBoost); if (p1.Vect().Mag()!=0) return p1.Vect().Dot(bostDir) / p1.Vect().Mag(); else return -1; }
inline float kinematics::cosThetaBoost( TLorentzVector* pa, float ca, TLorentzVector* pb, float cb ) { // http://xrootd.slac.stanford.edu/BFROOT/www/doc/workbook_backup_010108/analysis/analysis.html // A useful quantity in many analyses is the helicity angle. // In the reaction Y -> X -> a + b, the helicity angle of // particle a is the angle measured in the rest frame of the //decaying parent particle, X, between the direction of the // decay daughter a and the direction of the grandparent particle Y. TLorentzVector pTmp = (*pa)+(*pb); // this is the mumu system (Z) 4vector TVector3 ZboostVector = pTmp.BoostVector(); // this is the 3vector of the Z TLorentzVector p; // this is the muon 4vector if(ca<0) p.SetPxPyPzE(pa->Px(),pa->Py(),pa->Pz(),pa->E()); else if(cb<0) p.SetPxPyPzE(pb->Px(),pb->Py(),pb->Pz(),pb->E()); p.Boost( -ZboostVector ); // boost p to the dimuon CM (rest) frame float cosThetaB = p.Vect()*pTmp.Vect()/(p.P()*pTmp.P()); //if (ySystem(pa,pb) < 0) cosThetaB *= -1.; // reclassify ??? return cosThetaB; }
// Reset all private to false/zwwDefault/null vector/etc. void ZWW::reset(){ // For checker isAllOk_ = false; isLepOk_ = false; isJetOk_ = false; isMETOk_ = false; // For setter lepPt_. clear(); lepEta_.clear(); lepPhi_.clear(); lepFl_. clear(); lepCh_. clear(); lepId_. clear(); jetPt_. clear(); jetEta_.clear(); jetPhi_.clear(); jetM_. clear(); jetTag_.clear(); met_ = zwwDefault; metPhi_ = zwwDefault; njet_ = zwwDefault; nbjet_ = zwwDefault; st_ = zwwDefault; minMt_ = zwwDefault; minDeltaPhi_ = zwwDefault; // Buffer lepVec_.clear(); jetVec_.clear(); // TLorentzVector metVec_.SetXYZM(0.,0.,0.,0.); metVec_.SetXYZM(0.,0.,0.,0.); z0LepIdx_[0] = zwwDefault; z0LepIdx_[1] = zwwDefault; z1LepIdx_[0] = zwwDefault; z1LepIdx_[1] = zwwDefault; zaLepIdx_[0] = zwwDefault; zaLepIdx_[1] = zwwDefault; zbLepIdx_[0] = zwwDefault; zbLepIdx_[1] = zwwDefault; flagZ1SF_ = zwwDefault; // All other variables outPreSelection_ = false; }
void rochcor::momcor_data( TLorentzVector& mu, float charge, float sysdev, int runopt){ float ptmu = mu.Pt(); float muphi = mu.Phi(); float mueta = mu.Eta(); // same with mu.Eta() in Root float px = mu.Px(); float py = mu.Py(); float pz = mu.Pz(); float e = mu.E(); int mu_phibin = phibin(muphi); int mu_etabin = etabin(mueta); //float mptsys1 = sran.Gaus(0.0,sysdev); float dm = (dcor_bf[mu_phibin][mu_etabin] + mptsys_da_dm[mu_phibin][mu_etabin]*dcor_bfer[mu_phibin][mu_etabin])/dmavg[mu_phibin][mu_etabin]; float da = dcor_ma[mu_phibin][mu_etabin] + mptsys_da_da[mu_phibin][mu_etabin]*dcor_maer[mu_phibin][mu_etabin]; float cor = 1.0/(1.0 + dm + charge*da*ptmu); px *= cor; py *= cor; pz *= cor; e *= cor; //after Z pt correction float gscler = 0.0; gscler = TMath::Sqrt( TMath::Power(dgscl_stat,2) + TMath::Power(dgscl_syst,2) ); float gscl = (genm_smr/drecm); px *= (gscl + gscler_da_dev*gscler); py *= (gscl + gscler_da_dev*gscler); pz *= (gscl + gscler_da_dev*gscler); e *= (gscl + gscler_da_dev*gscler); mu.SetPxPyPzE(px,py,pz,e); }
void AnalyseParticles(LHEF::Reader *reader, ExRootTreeBranch *branch) { const LHEF::HEPEUP &hepeup = reader->hepeup; Int_t particle; Double_t signPz, cosTheta; TLorentzVector momentum; TRootLHEFParticle *element; for(particle = 0; particle < hepeup.NUP; ++particle) { element = (TRootLHEFParticle*) branch->NewEntry(); element->PID = hepeup.IDUP[particle]; element->Status = hepeup.ISTUP[particle]; element->Mother1 = hepeup.MOTHUP[particle].first; element->Mother2 = hepeup.MOTHUP[particle].second; element->ColorLine1 = hepeup.ICOLUP[particle].first; element->ColorLine2 = hepeup.ICOLUP[particle].second; element->Px = hepeup.PUP[particle][0]; element->Py = hepeup.PUP[particle][1]; element->Pz = hepeup.PUP[particle][2]; element->E = hepeup.PUP[particle][3]; element->M = hepeup.PUP[particle][4]; momentum.SetPxPyPzE(element->Px, element->Py, element->Pz, element->E); cosTheta = TMath::Abs(momentum.CosTheta()); signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; element->PT = momentum.Perp(); element->Eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); element->Phi = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); element->Rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); element->LifeTime = hepeup.VTIMUP[particle]; element->Spin = hepeup.SPINUP[particle]; } }
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; }
// // // bool analysisClass::isRecoTauMatchedTO( double genPt , double genEta , double genPhi , double dRcut ){ double deltaR=999; TLorentzVector RecoTau; TLorentzVector GenTau; GenTau.SetPtEtaPhiM( genPt, genEta, genPhi, 0 ); // for(unsigned int iTauR=0; iTauR<HPSTauPt->size(); iTauR++){ if( !tauRCheck( iTauR ) ) continue; RecoTau.SetPtEtaPhiM( tauPtcorr(iTauR) , HPSTauEta->at(iTauR) , HPSTauPhi->at(iTauR) , 0 ); if( fabs(RecoTau.DeltaR(GenTau))<deltaR ) deltaR=fabs(RecoTau.DeltaR(GenTau)); } // if( deltaR<dRcut ) return true; return false; }