// This is the pt corrected delta phi between the 2 leptons // P and L2 are the 4-vectors for the 2 hemispheres, or in you case, // the two leptons - setting mass to 0 should be fine // MET 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::CalcDeltaPhiRFRAME(){ // first calculate pt-corrected MR float mymrnew = CalcMRNEW(); // Now, boost lepton system to rest in z // (approximate accounting for longitudinal boost) TVector3 BL = L1.Vect()+L2.Vect(); BL.SetX(0.0); BL.SetY(0.0); BL = (1./(L1.P()+L2.P()))*BL; L1.Boost(-BL); L2.Boost(-BL); // Next, calculate the transverse Lorentz transformation // to go to Higgs approximate rest frame TVector3 B = L1.Vect()+L2.Vect()+MET; B.SetZ(0.0); B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B; L1.Boost(B); L2.Boost(B); //Now, re-calculate the delta phi // in the new reference frame: return L1.DeltaPhi(L2); }
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; }
// This is the pt corrected MR - here, we assume the pt // of the Higgs is (MET+Pt+Qt); // L1 and L2 are the 4-vectors for the 2 hemispheres, or in you case, // the two leptons - setting mass to 0 should be fine // MET is the MET 3 vector (don't forget to set the z-component of // MET to 0) // Also, 2 times this variable should give you the Higgs mass double HWWKinematics::CalcMRNEW(){ TVector3 vI = MET+L1.Vect()+L2.Vect(); vI.SetZ(0.0); double L1pL2 = CalcMR(); //Note - this calls the old MR function double vptx = (L1+L2).Px(); double vpty = (L1+L2).Py(); TVector3 vpt; vpt.SetXYZ(vptx,vpty,0.0); float MR2 = 0.5*(L1pL2*L1pL2-vpt.Dot(vI)+L1pL2*sqrt(L1pL2*L1pL2+vI.Dot(vI)-2.*vI.Dot(vpt))); return sqrt(MR2); }
// M is the MET 3 vector (don't forget to set the z-component of // MET to 0) double HWWKinematics::CalcMRNEW(TLorentzVector P, TLorentzVector Q, TVector3 M){ TVector3 vI = M+P.Vect()+Q.Vect(); vI.SetZ(0.0); double PpQ = CalcMR(P,Q); //Note - this calls the old MR function double vptx = (P+Q).Px(); double vpty = (P+Q).Py(); TVector3 vpt; vpt.SetXYZ(vptx,vpty,0.0); float MR2 = 0.5*(PpQ*PpQ-vpt.Dot(vI)+PpQ*sqrt(PpQ*PpQ+vI.Dot(vI)-2.*vI.Dot(vpt))); return sqrt(MR2); }
Path::Path(const TLorentzVector& p4, const TVector3& origin, double field) : m_unitDirection(p4.Vect().Unit()), m_speed(p4.Beta() * gconstc), m_origin(origin.X(), origin.Y(), origin.Z()), m_field(field) { m_points[papas::Position::kVertex] = m_origin; }
// 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); }
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; }
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; }
//////////////////////////////////////////////////////////////////////// // Calculates theta and phi in HX frame //////////////////////////////////////////////////////////////////////// pair<double, double> GetAngles_HX( TLorentzVector a, TLorentzVector b) { TLorentzVector c = a+b; // JPsi momentum in lab frame TVector3 bv = c.BoostVector(); TLorentzVector p1(0., 0., 1380., 1380.); // beam momentum in lab frame TLorentzVector p2(0., 0., -1380., 1380.); // beam momentum in lab frame p1.Boost(-bv); p2.Boost(-bv); TVector3 beam1 = p1.Vect().Unit(); // beam direction in JPsi rest frame TVector3 beam2 = p2.Vect().Unit(); // beam direction in JPsi rest frame TVector3 Z = c.Vect().Unit(); // JPsi direction in lab frame TVector3 Y = beam1.Cross( beam2 ).Unit(); // the production plane normal TVector3 X = Y.Cross(Z).Unit(); // completes the right-handed coordinate a.Boost(-bv); // muon+ momentum in JPsi rest frame TVector3 mu(a.Vect().Dot(X), a.Vect().Dot(Y), a.Vect().Dot(Z)); // transform to new coordinate pair<double, double> angles; angles.first = mu.Theta(); angles.second = mu.Phi()>0. ? mu.Phi() : mu.Phi()+2.*TMath::Pi(); return angles; }
// This is the deltaphi between the di-lepton system and the Higgs // boost in the approximate Higgs rest frame, or R-FRAME // L1 and L2 are the 4-vectors for the 2 hemispheres, or in you case, // the two leptons - setting mass to 0 should be fine // MET 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::CalcDoubleDphiRFRAME(){ // first calculate pt-corrected MR float mymrnew = CalcMRNEW(); TVector3 BL = L1.Vect()+L2.Vect(); BL.SetX(0.0); BL.SetY(0.0); BL = (1./(L1.P()+L2.P()))*BL; L1.Boost(-BL); L2.Boost(-BL); //Next, calculate the transverse Lorentz transformation TVector3 B = L1.Vect()+L2.Vect()+MET; B.SetZ(0.0); B = (-1./(sqrt(4.*mymrnew*mymrnew+B.Dot(B))))*B; L1.Boost(B); L2.Boost(B); // Now, calculate the delta phi // between di-lepton axis and boost // in new reference frame return B.DeltaPhi(L1.Vect()+L2.Vect()); }
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()); }
void gravitonPythia(){ gStyle->SetOptStat(0); TreeReader data("pythia8_RS_WW.root"); TH1F* h_cosTh = new TH1F("h_cosTh","RS Graviton by Pythia8",100,-1,1); h_cosTh->SetMinimum(0); h_cosTh->Sumw2(); TH1F *h_cosThStar = (TH1F*)h_cosTh->Clone("h_cosThStar"); for(Long64_t ev = 0 ; ev < data.GetEntriesFast(); ev++){ data.GetEntry(ev); Int_t nGenPar = data.GetInt("nGenPar"); Int_t* genParId = data.GetPtrInt("genParId"); Int_t* genParSt = data.GetPtrInt("genParSt"); Float_t* genParPt = data.GetPtrFloat("genParPt"); Float_t* genParEta = data.GetPtrFloat("genParEta"); Float_t* genParPhi = data.GetPtrFloat("genParPhi"); Float_t* genParM = data.GetPtrFloat("genParM"); // cos#theta_1 in the W rest frame Int_t chgLepID = -1; Int_t neuLepID = -1; TLorentzVector chgLep(0,0,0,0); TLorentzVector neuLep(0,0,0,0); for(Int_t i = 0; i < nGenPar; i++){ if( genParSt[i] != 23 ) continue; if( abs(genParId[i]) == 11 || abs(genParId[i]) == 13 || abs(genParId[i]) == 15 ) chgLepID = i; if( abs(genParId[i]) == 12 || abs(genParId[i]) == 14 || abs(genParId[i]) == 16 ) neuLepID = i; } chgLep.SetPtEtaPhiM(genParPt[chgLepID], genParEta[chgLepID], genParPhi[chgLepID], genParM[chgLepID]); neuLep.SetPtEtaPhiM(genParPt[neuLepID], genParEta[neuLepID], genParPhi[neuLepID], genParM[neuLepID]); TLorentzVector Wb = chgLep + neuLep; TVector3 WbP = Wb.Vect(); TVector3 bv = -Wb.BoostVector(); chgLep.Boost(bv); TVector3 chgLepP = chgLep.Vect(); Double_t cosTh = TMath::Cos(chgLepP.Angle(WbP)); h_cosTh->Fill(cosTh); // cos#theta* in the RSG rest frame Int_t WplusID = -1; Int_t WminusID = -1; TLorentzVector Wplus(0,0,0,0); TLorentzVector Wminus(0,0,0,0); for(Int_t i = 0; i < nGenPar; i++){ if( genParSt[i] != 22 ) continue; if( genParId[i] == +24 ) WplusID = i; if( genParId[i] == -24 ) WminusID = i; } Wplus.SetPtEtaPhiM(genParPt[WplusID], genParEta[WplusID], genParPhi[WplusID], genParM[WplusID]); Wplus.SetPtEtaPhiM(genParPt[WminusID], genParEta[WminusID], genParPhi[WminusID], genParM[WminusID]); TLorentzVector RSG = Wplus + Wminus; TVector3 RSGP = RSG.Vect(); TVector3 gv = -RSG.BoostVector(); Wplus.Boost(gv); TVector3 WplusP = Wplus.Vect(); Double_t cosThStar = TMath::Cos(WplusP.Angle(RSGP)); h_cosThStar->Fill(cosThStar); } TCanvas* c[2]; c[0] = new TCanvas("c0","",0,0,800,600); c[1] = new TCanvas("c1","",0,0,800,600); c[0]->cd(); h_cosTh->SetXTitle("cos#theta_1 in the W rest frame"); h_cosTh->Draw(); c[1]->cd(); h_cosThStar->SetXTitle("cos#theta* in the RSG rest frame"); h_cosThStar->Draw(); c[0]->Print("RSgravitonPythia.pdf("); c[1]->Print("RSgravitonPythia.pdf)"); }
void acceptance(const char* file = "upsilonGun.root", const char* outputName = "acceptance.root") { Int_t genUpsSize; Float_t genUpsPt[NMAX]; Float_t genUpsEta[NMAX]; Float_t genUpsPhi[NMAX]; Float_t genUpsRapidity[NMAX]; Int_t genMuSize; Float_t genMuPt[NMAX]; Float_t genMuEta[NMAX]; Float_t genMuPhi[NMAX]; Int_t genMuCharge[NMAX]; Int_t recoMuSize; Float_t recoMuPt[NMAX]; Float_t recoMuEta[NMAX]; Float_t recoMuPhi[NMAX]; Int_t recoMuCharge[NMAX]; TFile* f1 = new TFile(file); TTree* t = (TTree*)f1->Get("UpsTree"); t->SetBranchAddress("genUpsSize",&genUpsSize); t->SetBranchAddress("genUpsPt",genUpsPt); t->SetBranchAddress("genUpsEta",genUpsEta); t->SetBranchAddress("genUpsPhi",genUpsPhi); t->SetBranchAddress("genUpsRapidity",genUpsRapidity); t->SetBranchAddress("genMuSize",&genMuSize); t->SetBranchAddress("genMuPt",genMuPt); t->SetBranchAddress("genMuEta",genMuEta); t->SetBranchAddress("genMuPhi",genMuPhi); t->SetBranchAddress("genMuCharge",genMuCharge); t->SetBranchAddress("recoMuSize",&recoMuSize); t->SetBranchAddress("recoMuPt",recoMuPt); t->SetBranchAddress("recoMuEta",recoMuEta); t->SetBranchAddress("recoMuPhi",recoMuPhi); t->SetBranchAddress("recoMuCharge",recoMuCharge); TH2F* genPtRap = new TH2F("genUps","",4,0,20,4,-2,2); TH1F* genPt = new TH1F("genUps1D","",4,0,20); genPtRap->Sumw2(); genPt->Sumw2(); genPtRap->SetTitle(";Upsilon pT (GeV/c);Upsilon Rapidity;"); genPt->SetTitle(";Upsilon pT (GeV/c);Acceptance;"); TH2F* recoPtRap = (TH2F*)genPtRap->Clone("recoUps"); TH1F* recoPt = (TH1F*)genPt->Clone("recoUps1D"); recoPtRap->Sumw2(); recoPt->Sumw2(); for(int i=0; i<t->GetEntries(); i++){ if(i%100000 == 0) std::cout<<i<<std::endl; t->GetEntry(i); // calculate cosTheta TLorentzVector genUps; genUps.SetPtEtaPhiM(genUpsPt[0], genUpsEta[0], genUpsPhi[0], 9.46); TLorentzRotation boost(-genUps.BoostVector()); int mp = genMuCharge[0]>0 ? 0 : 1; TLorentzVector genMuPlus; genMuPlus.SetPtEtaPhiM(genMuPt[mp], genMuEta[mp], genMuPhi[mp], 0.106); genMuPlus *= boost; Float_t cosThetaStar = genMuPlus.Vect().Dot(genUps.Vect())/genMuPlus.Vect().Mag()/genUps.Vect().Mag(); // set the weight Float_t weight = 1; genPtRap->Fill( genUpsPt[0], genUpsRapidity[0], weight ); genPt->Fill( genUpsPt[0], weight ); Float_t recoUpsPt = 0; Float_t recoUpsRapidity = 0; double minDeltaM = 1000; for(int tr1=0; tr1<recoMuSize; tr1++){ for(int tr2=tr1+1; tr2<recoMuSize; tr2++){ if ( recoMuCharge[tr1]*recoMuCharge[tr2] == -1 && recoMuPt[tr1] >= 3.5 && recoMuPt[tr2] >= 3.5 && fabs(recoMuEta[tr1]) < 2.1 && fabs(recoMuEta[tr2]) < 2.1 ){ TLorentzVector mu1; mu1.SetPtEtaPhiM(recoMuPt[tr1], recoMuEta[tr1], recoMuPhi[tr1], 0.106); TLorentzVector mu2; mu2.SetPtEtaPhiM(recoMuPt[tr2], recoMuEta[tr2], recoMuPhi[tr2], 0.106); TLorentzVector recoUps(mu1 + mu2); double deltaM = fabs(recoUps.M()-9.46); if( deltaM < minDeltaM ){ recoUpsPt = recoUps.Pt(); recoUpsRapidity = recoUps.Rapidity(); minDeltaM = deltaM; } } } } if( minDeltaM < 1.0 ){ recoPtRap->Fill( recoUpsPt, recoUpsRapidity, weight ); recoPt->Fill( recoUpsPt, weight ); } } TFile out(outputName,"recreate"); TH2F* acc = (TH2F*)genPtRap->Clone("acceptance"); TH1F* acc1D = (TH1F*)genPt->Clone("acceptance1D"); acc->Sumw2(); acc1D->Sumw2(); acc->Divide(recoPtRap,genPtRap,1,1,"B"); acc1D->Divide(recoPt,genPt,1,1,"B"); acc->Write(); acc1D->Write(); out.Close(); }
int main (int argc, char ** argv) { if(argc < 3) { cout << "Usage: " << argv[0] << " input.lhe output.lhe" << endl ; return -1; } std::ifstream ifs (argv[1]) ; LHEF::Reader reader (ifs) ; ofstream outputStream (argv[2]) ; LHEF::Writer writer (outputStream) ; writer.headerBlock () << reader.headerBlock ; writer.initComments () << reader.initComments ; writer.heprup = reader.heprup ; writer.init () ; //PG mu massless in phantom // float k2 = 0.1056583715 * 0.1056583715 - 1.77682 * 1.77682 ; // GeV -3.14592562093 float k2 = 0. - 1.77682 * 1.77682 ; // GeV -3.14592562093 int count = 0 ; //PG loop over input events while (reader.readEvent ()) { ++count ; if ( reader.outsideBlock.length ()) std::cout << reader.outsideBlock; // loop over particles in the event for (int iPart = 0 ; iPart < reader.hepeup.IDUP.size (); ++iPart) { // outgoing particles if (reader.hepeup.ISTUP.at (iPart) == 1) { if (abs (reader.hepeup.IDUP.at (iPart)) == 13) { TLorentzVector dummy ( reader.hepeup.PUP.at (iPart).at (0), // px reader.hepeup.PUP.at (iPart).at (1), // py reader.hepeup.PUP.at (iPart).at (2), // pz reader.hepeup.PUP.at (iPart).at (3) // E ) ; float p2 = dummy.Vect ().Mag2 () ; float scale = sqrt (1 + k2 / p2) ; if (p2 < (-1 * k2)) { cout << "warning: p2 is smaller than the mass difference " << p2 << endl ; scale = 1 ; } reader.hepeup.PUP.at (iPart).at (0) *= scale ; // px reader.hepeup.PUP.at (iPart).at (1) *= scale ; // px reader.hepeup.PUP.at (iPart).at (2) *= scale ; // px if (reader.hepeup.IDUP.at (iPart) == 13) reader.hepeup.IDUP.at (iPart) = 15 ; if (reader.hepeup.IDUP.at (iPart) == -13) reader.hepeup.IDUP.at (iPart) = -15 ; } if (reader.hepeup.IDUP.at (iPart) == 14) reader.hepeup.IDUP.at (iPart) = 16 ; if (reader.hepeup.IDUP.at (iPart) == -14) reader.hepeup.IDUP.at (iPart) = -16 ; } // outgoing particles } // loop over particles in the event writer.eventComments () << reader.eventComments ; writer.hepeup = reader.hepeup ; bool written = writer.writeEvent () ; if (!written) { cout << "warning: event " << count << " not written" << endl ; } } //PG loop over input events cout << "end loop over " << count << " events" << endl ; return 0 ; }
void fillUdstDataIntoMassBins_example(const string& inFileNamePattern = "fillUdstDataIntoMassBins_example.root", const string& dirName = "./test", const long int maxNmbEvents = -1, const unsigned int nmbMassBins = 50, const double massBinWidth = 40, // [MeV/c^2] const double massRangeMin = 500, // [MeV/c^2] const string& uDstTreeName = "pwaDataTree", const string& pwaTreeName = "rootPwaEvtTree", const long int treeCacheSize = 25000000, // 25 MByte ROOT tree read cache const bool debug = false) { const string prodKinPartNamesObjName = "prodKinParticles"; const string prodKinMomentaLeafName = "prodKinMomenta"; const string decayKinPartNamesObjName = "decayKinParticles"; const string decayKinMomentaLeafName = "decayKinMomenta"; TStopwatch timer; timer.Start(); printInfo << "reading uDST file(s) '" << inFileNamePattern << "'" << endl << " writing " << nmbMassBins << " mass bins in mass interval " << "[" << massRangeMin << ", " << massRangeMin + nmbMassBins * massBinWidth << "] " << "MeV/c^2 to '" << dirName << "'" << endl << " reading uDST data from tree '" << uDstTreeName << "'" << endl << " writing PWA data to tree '" << pwaTreeName << "'" << endl; // create chain and connect tree leaf variables to branches TChain uDstChain(uDstTreeName.c_str()); if (uDstChain.Add(inFileNamePattern.c_str()) < 1) printWarn << "no events in uDST input file(s) '" << inFileNamePattern << "'" << endl; const long int nmbEventsUdstChain = uDstChain.GetEntries(); uDstChain.GetListOfFiles()->ls(); // !!! <channel-dependent part> !!! // connect tree leafs TLorentzVector* photons[4] = {0, 0, 0, 0}; TLorentzVector* piMinus = 0; TLorentzVector* beam = 0; TLorentzVector* recoil = 0; uDstChain.SetBranchAddress("gamma1", &(photons[0])); uDstChain.SetBranchAddress("gamma2", &(photons[1])); uDstChain.SetBranchAddress("gamma3", &(photons[2])); uDstChain.SetBranchAddress("gamma4", &(photons[3])); uDstChain.SetBranchAddress("pi_out", &piMinus); uDstChain.SetBranchAddress("pi_in", &beam); uDstChain.SetBranchAddress("proton", &recoil); uDstChain.SetCacheSize(treeCacheSize); uDstChain.AddBranchToCache("gamma1", true); uDstChain.AddBranchToCache("gamma2", true); uDstChain.AddBranchToCache("gamma3", true); uDstChain.AddBranchToCache("gamma4", true); uDstChain.AddBranchToCache("pi_out", true); uDstChain.AddBranchToCache("pi_in", true); uDstChain.AddBranchToCache("proton", true); uDstChain.StopCacheLearningPhase(); // !!! </channel-dependent part> !!! // create directories and .root files vector<TFile*> pwaDataFiles; vector<TTree*> pwaDataTrees; if (not createMassBinFiles(pwaDataFiles, pwaDataTrees, dirName, nmbMassBins, massBinWidth, massRangeMin, pwaTreeName)) { printErr << "there were problems creating the mass bin directories/files. aborting." << endl; return; } printSucc << "created " << pwaDataFiles.size() << " directories/files" << endl; // write arrays with production and decay particle names to root files { TClonesArray prodKinPartNames ("TObjString", 1); TClonesArray decayKinPartNames("TObjString", 3); // !!! <channel-dependent part> !!! new (prodKinPartNames [0]) TObjString("pi-"); // beam particle new (decayKinPartNames[0]) TObjString("pi0"); new (decayKinPartNames[1]) TObjString("pi0"); new (decayKinPartNames[2]) TObjString("pi-"); // !!! </channel-dependent part> !!! for (unsigned int i = 0; i < pwaDataFiles.size(); ++i) { pwaDataFiles[i]->cd(); prodKinPartNames.Write (prodKinPartNamesObjName.c_str (), TObject::kSingleKey); decayKinPartNames.Write(decayKinPartNamesObjName.c_str(), TObject::kSingleKey); } printSucc << "wrote particle name arrays to all files. " << "beam = 'pi-', decay = {'pi0', 'pi0', 'pi-'}." << endl; } // create tree leafs { TClonesArray* prodKinMomenta = new TClonesArray("TVector3"); TClonesArray* decayKinMomenta = new TClonesArray("TVector3"); const int splitLevel = 99; const int bufSize = 256000; for (unsigned int i = 0; i < pwaDataTrees.size(); ++i) { pwaDataTrees[i]->Branch(prodKinMomentaLeafName.c_str(), "TClonesArray", &prodKinMomenta, bufSize, splitLevel); pwaDataTrees[i]->Branch(decayKinMomentaLeafName.c_str(), "TClonesArray", &decayKinMomenta, bufSize, splitLevel); } printSucc << "created branches for all trees" << endl; } // loop over events const long int nmbEvents = ((maxNmbEvents > 0) ? maxNmbEvents : nmbEventsUdstChain); printInfo << "writing events into mass bin files" << endl << " looping over " << nmbEvents << " tree entries" << endl; unsigned long int countEvWritten = 0; progress_display progressIndicator(nmbEvents, cout, ""); for (long int eventIndex = 0; eventIndex < nmbEvents; ++eventIndex) { ++progressIndicator; if ((uDstChain.LoadTree(eventIndex) < 0) or (uDstChain.GetEntry(eventIndex) == 0)) { printWarn << "error reading event " << eventIndex << " from tree. skipping." << endl; continue; } // !!! <channel-dependent part> !!! // now just make some minor calculations before // construct two pi0s const TLorentzVector piZeros[2] = {*(photons[0]) + *(photons[1]), *(photons[2]) + *(photons[3])}; // construct intermediate state X const TLorentzVector X = piZeros[0] + piZeros[1] + *piMinus; // calculate t' const double t = (*beam - X) * (*beam - X); const double tPrime = fabs(t) - fabs((X.M() * X.M() - beam->M() * beam->M())*(X.M() * X.M() - beam->M() * beam->M()) / (4 * (beam->Vect() * beam->Vect()))); // cut on t' if ((tPrime < 0.1) or (tPrime > 1.0)) continue; // write out PWA data const double fsEnergy = X.E() + recoil->E() - recoil->M(); // measured total energy of final state const double scaleFactor = fsEnergy / beam->E(); const TLorentzVector beamScaled(beam->Vect() * scaleFactor, fsEnergy); if (writeEvent(pwaDataTrees, beamScaled, piZeros[0], piZeros[1], *piMinus, X.M(), nmbMassBins, massBinWidth, massRangeMin, prodKinMomentaLeafName, decayKinMomentaLeafName, debug)) ++countEvWritten; // !!! </channel-dependent part> !!! } // write trees long unsigned int countTreeEvents = 0; for (unsigned int i = 0; i < nmbMassBins; ++i) { pwaDataTrees[i]->GetCurrentFile()->Write(); long unsigned int nmbEvents = pwaDataTrees[i]->GetEntries(); printSucc << "written " << setw(10) << nmbEvents << " events to file " << "'" << pwaDataTrees[i]->GetCurrentFile()->GetName() << "'" << endl; countTreeEvents += nmbEvents; pwaDataTrees[i]->GetCurrentFile()->Close(); } pwaDataFiles.clear(); pwaDataTrees.clear(); printInfo << "wrote " << min(countEvWritten, countTreeEvents) << " out of " << nmbEvents << " events" <<endl; timer.Stop(); printInfo << "this job consumed: "; timer.Print(); }
// fills event data into correct mass bin bool writeEvent(vector<TTree*>& pwaTrees, const TLorentzVector& beamLv, // !!! <channel-dependent part> !!! const TLorentzVector& piZero0, const TLorentzVector& piZero1, const TLorentzVector& piMinus, // !!! </channel-dependent part> !!! const double XMass, // [GeV/c^2] const unsigned int nmbMassBins = 50, const double massBinWidth = 50, // [MeV/c^2] const double massRangeMin = 500, // [MeV/c^2] const string& prodKinMomentaLeafName = "prodKinMomenta", const string& decayKinMomentaLeafName = "decayKinMomenta", const bool debug = false) { const double mass = 1000 * XMass; // convert from GeV/c^2 to MeV/c^2 // make sure that mass is in range if ((mass < massRangeMin) or (mass > (massRangeMin + nmbMassBins * massBinWidth))) return false; const unsigned int bin = (unsigned int) ((mass - massRangeMin) / massBinWidth); if (not pwaTrees[bin]) { printWarn << "null pointer for tree for mass bin [" << massRangeMin + bin * massBinWidth << ", " << massRangeMin + (bin + 1) * massBinWidth << "]" << endl; return false; } // fill tree if (debug) printDebug << "filling tree for bin " << bin << " = [" << massRangeMin + bin * massBinWidth << ", " << massRangeMin + (bin + 1) * massBinWidth << "] MeV/c^2" << endl; // create tree leafs static TClonesArray* prodKinMomenta = new TClonesArray("TVector3"); static TClonesArray* decayKinMomenta = new TClonesArray("TVector3"); // connect leaf variables to tree branches or create branches, if they don't exist yet TTree* outTree = pwaTrees[bin]; if (outTree->SetBranchAddress(prodKinMomentaLeafName.c_str(), &prodKinMomenta) < 0) { printWarn << "could not connect variable to branch '" << prodKinMomentaLeafName << "'. " << "skipping." << endl; return false; } if (outTree->SetBranchAddress(decayKinMomentaLeafName.c_str(), &decayKinMomenta) < 0) { printWarn << "could not connect variable to branch '" << prodKinMomentaLeafName << "'. " << "skipping." << endl; return false; } // clear arrays prodKinMomenta->Clear (); decayKinMomenta->Clear(); // set leaf variables // beam particle new ((*prodKinMomenta)[0]) TVector3(beamLv.Vect()); // !!! <channel-dependent part> !!! // for target particle elastic scattering is assumed // outgoing hadrons new ((*decayKinMomenta)[0]) TVector3(piZero0.Vect()); new ((*decayKinMomenta)[1]) TVector3(piZero1.Vect()); new ((*decayKinMomenta)[2]) TVector3(piMinus.Vect()); // !!! </channel-dependent part> !!! // fill tree outTree->Fill(); return true; }
void UpsilonMassFit_PolWeights(int iSpec = 3, int PutWeight=1) { double PtCut=4; //minbias integrated, |y|<1.2 and |y|\in[1.2,2.4], centrality [0,10][10,20][20,100]%, pt [0,6.5], [6.5, 10] [10,20] gROOT->SetStyle("Plain"); gStyle->SetPalette(1); gStyle->SetFrameBorderMode(0); gStyle->SetFrameFillColor(0); gStyle->SetCanvasColor(0); gStyle->SetTitleFillColor(0); gStyle->SetStatColor(0); gStyle->SetPadBorderSize(0); gStyle->SetCanvasBorderSize(0); gStyle->SetOptTitle(1); // at least most of the time gStyle->SetOptStat(1); // most of the time, sometimes "nemriou" might be useful to display name, //number of entries, mean, rms, integral, overflow and underflow gStyle->SetOptFit(1); // set to 1 only if you want to display fit results //==================================== Define Histograms==================================================== ofstream dataFile(Form("Eff_Upsilon.txt")); TH1D *diMuonsInvMass_Gen = new TH1D("diMuonsInvMass_Gen","diMuonsInvMass_Gen", 100,8.0,12.0); TH1D *diMuonsPt_Gen = new TH1D("diMuonsPt_Gen","diMuonsPt_Gen", 100,0,30); //Rapidity Gen TH1D *diMuonsRap_Gen0 = new TH1D("diMuonsRap_Gen0","diMuonsRap_Gen0", 100,-5,5); TH1D *diMuonsRap_Gen1 = new TH1D("diMuonsRap_Gen1","diMuonsRap_Gen1", 100,-5,5); TH1D *diMuonsRap_Gen2 = new TH1D("diMuonsRap_Gen2","diMuonsRap_Gen2", 100,-5,5); TH1D *diMuonsRap_Gen3 = new TH1D("diMuonsRap_Gen3","diMuonsRap_Gen3", 100,-5,5); TH1D *diMuonsRap_Gen4 = new TH1D("diMuonsRap_Gen4","diMuonsRap_Gen4", 100,-5,5); TH1D *diMuonsRap_Gen5 = new TH1D("diMuonsRap_Gen5","diMuonsRap_Gen5", 100,-5,5); ////Rapidity Reco TH1D *diMuonsRap_Rec0 = new TH1D("diMuonsRap_Rec0","diMuonsRap_Rec0", 100,-5,5); diMuonsRap_Rec0->SetLineColor(2); TH1D *diMuonsRap_Rec1 = new TH1D("diMuonsRap_Rec1","diMuonsRap_Rec1", 100,-5,5); diMuonsRap_Rec1->SetLineColor(2); TH1D *diMuonsRap_Rec2 = new TH1D("diMuonsRap_Rec2","diMuonsRap_Rec2", 100,-5,5); diMuonsRap_Rec2->SetLineColor(2); TH1D *diMuonsRap_Rec3 = new TH1D("diMuonsRap_Rec3","diMuonsRap_Rec3", 100,-5,5); diMuonsRap_Rec3->SetLineColor(2); TH1D *diMuonsRap_Rec4 = new TH1D("diMuonsRap_Rec4","diMuonsRap_Rec4", 100,-5,5); diMuonsRap_Rec4->SetLineColor(2); TH1D *diMuonsRap_Rec5 = new TH1D("diMuonsRap_Rec5","diMuonsRap_Rec5", 100,-5,5); diMuonsRap_Rec5->SetLineColor(2); TH1D *Bin_Gen = new TH1D("Bin_Gen","Bin_Gen", 40,0,40); //==============================================Define AccEff Stuff here=========================================== // Pt bin sizes int Nptbin=1; double pt_bound[100] = {0}; if(iSpec == 1) { Nptbin = 5; pt_bound[0] = 0; pt_bound[1] = 20.0; pt_bound[2] = 0.0; pt_bound[3] = 6.5; pt_bound[4] = 10.0; pt_bound[5] = 20.0; pt_bound[6] = 30.0; pt_bound[7] = 35; pt_bound[8] = 40; pt_bound[9] = 45; pt_bound[10] = 50; } if(iSpec == 2) { Nptbin = 2; pt_bound[0] = 0.0; pt_bound[1] = 1.2; pt_bound[2] = 2.4; pt_bound[3] = 0.0; pt_bound[4] = 0.8; pt_bound[5] = 1.8; //pt_bound[7] = 2.0; pt_bound[6] = 2.4; } if(iSpec == 3) { Nptbin = 3; //for plots pt_bound[0] = 0.0;//0 pt_bound[1] = 4.0;//10 pt_bound[2] = 8.0;//20 pt_bound[3] = 40.0;//100 //pt_bound[4] = 16.0;//50 //pt_bound[5] = 20.0;//100 //pt_bound[6] = 24.0; //pt_bound[7] = 32.0; //pt_bound[8] = 40.0; //pt_bound[9] = 40.0; } //X Axis error on Eff graph double PT[100], DelPT[100], mom_err[100]; for (Int_t ih = 0; ih < Nptbin; ih++) { PT[ih] = (pt_bound[ih] + pt_bound[ih+1])/2.0; DelPT[ih] = pt_bound[ih+1] - pt_bound[ih]; mom_err[ih] = DelPT[ih]/2.0; } double genError, recError; double gen_pt[100]={0}, gen_ptError[100]={0}; double rec_pt[100]={0}, rec_ptError[100]={0}; double Eff_cat_1[100]={0},Err_Eff_cat_1[100]={0}; // Histogram arrays TH1D *diMuonsInvMass_GenA[10][1000]; TH1D *diMuonsInvMass_RecA[10][1000]; TH1D *diMuonsPt_GenA[10][1000]; TH1D *diMuonsPt_RecA[10][1000]; char nameGen[10][500], nameRec[10][500], nameGenPt[10][500], nameRecPt[10][500]; for (int ifile = 0; ifile <= 5; ifile++) { for (Int_t ih = 0; ih < Nptbin; ih++) { sprintf(nameGen[ifile],"DiMuonMassGen_pt_%d_%d",ih,ifile); sprintf(nameRec[ifile],"DiMuonMassRec_pt_%d_%d",ih,ifile); sprintf(nameGenPt[ifile],"DiMuonPtGen_pt_%d_%d",ih,ifile); sprintf(nameRecPt[ifile],"DiMuonPtRec_pt_%d_%d",ih,ifile); diMuonsInvMass_GenA[ifile][ih]= new TH1D(nameGen[ifile],nameGen[ifile], 100,8.0,12.0); //for eff Gen; diMuonsInvMass_GenA[ifile][ih]->Sumw2(); diMuonsInvMass_GenA[ifile][ih]->SetMarkerStyle(7); diMuonsInvMass_GenA[ifile][ih]->SetMarkerColor(4); diMuonsInvMass_GenA[ifile][ih]->SetLineColor(4); diMuonsInvMass_RecA[ifile][ih] = new TH1D(nameRec[ifile],nameRec[ifile], 100,8.0,12.0); //for eff Rec; diMuonsInvMass_RecA[ifile][ih]->Sumw2(); diMuonsInvMass_RecA[ifile][ih]->SetMarkerStyle(8); diMuonsInvMass_RecA[ifile][ih]->SetMarkerColor(4); diMuonsInvMass_RecA[ifile][ih]->SetLineColor(4); diMuonsPt_GenA[ifile][ih]= new TH1D(nameGenPt[ifile],nameGenPt[ifile], 100,0,40); //for eff Gen; diMuonsPt_RecA[ifile][ih]= new TH1D(nameRecPt[ifile],nameRecPt[ifile], 100,0,40); //for eff Rec; } } //===========================================Input Root File============================================================ char fileName[10][500]; //0.0380228 0.0480769 0.0293255 0.0125156 0.00336587 0.00276319*2/5 = 0.001105276 //Scales double scale[10]={0}; scale[0]=(6.8802); // pT [0-3] scale[1]=(8.6995); // pT [3-6] scale[2]=(5.3065); // pT [6-9] scale[3]=(2.2647); // pT [9-12] scale[4]=(3.0453); // pT [12-15] scale[5]=(1.0000); // pT [15-30] sprintf(fileName[0],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt03_N.root"); sprintf(fileName[1],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt36_N.root"); sprintf(fileName[2],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt69_N.root"); sprintf(fileName[3],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt912_N.root"); sprintf(fileName[4],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt1215_N.root"); sprintf(fileName[5],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt1530_N.root"); //double scale[10]={0}; //scale[0]=(0.0380228/0.001105276); //scale[1]=(0.0480769/0.001105276); //scale[2]=(0.0293255/0.001105276); //scale[3]=(0.0125156/0.001105276); //scale[4]=(0.00336587/0.001105276); //scale[5]=(0.001105276/0.001105276); //34.55 , 43.70 , 26.65 , 11.37 , 3.05 , 1 //sprintf(fileName[0],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt03.root"); //sprintf(fileName[1],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt36.root"); //sprintf(fileName[2],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt69.root"); //sprintf(fileName[3],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt912.root"); //sprintf(fileName[4],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt1215.root"); //sprintf(fileName[5],"/home/vineet/HiData/UpsilonData/UpsilonEff/DimuonOnia2Dplots_UpsilonPt1530.root"); TFile *infile; TTree *tree; TTree *gentree; //===========File loop ====================== for(int ifile =0; ifile<=5; ifile++){ infile=new TFile(fileName[ifile],"R"); tree=(TTree*)infile->Get("SingleMuonTree"); gentree=(TTree*)infile->Get("SingleGenMuonTree"); //Event variables int eventNb,runNb,lumiBlock, gbin, rbin; //Jpsi Variables Double_t JpsiMass,JpsiPt,JpsiPx,JpsiPy,JpsiPz,JpsiRap, JpsiCharge,JpsiE; Double_t JpsiVprob; //2.) muon variables RECO double muPosPx, muPosPy, muPosPz, muPosEta, muPosPt,muPosP,muPosPhi; double muNegPx, muNegPy, muNegPz, muNegEta, muNegPt,muNegP,muNegPhi; //(1).Positive Muon double muPos_nchi2In, muPos_dxy, muPos_dz, muPos_nchi2Gl; int muPos_found, muPos_pixeLayers, muPos_nValidMuHits,muPos_arbitrated; bool muPos_matches,muPos_tracker; //(2).Negative Muon double muNeg_nchi2In, muNeg_dxy, muNeg_dz, muNeg_nchi2Gl; int muNeg_found, muNeg_pixeLayers, muNeg_nValidMuHits,muNeg_arbitrated; bool muNeg_matches,muNeg_tracker; //Gen Level variables //Gen JPsi Variables double GenJpsiMass, GenJpsiPt, GenJpsiRap; double GenJpsiPx, GenJpsiPy, GenJpsiPz, GenJpsiE; //2.) Gen muon variables double GenmuPosPx, GenmuPosPy, GenmuPosPz, GenmuPosEta, GenmuPosPt, GenmuPosPhi; double GenmuNegPx, GenmuNegPy, GenmuNegPz, GenmuNegEta, GenmuNegPt, GenmuNegPhi; //Event variables tree->SetBranchAddress("eventNb",&eventNb); tree->SetBranchAddress("runNb",&runNb); tree->SetBranchAddress("lumiBlock",&lumiBlock); //Jpsi Variables tree->SetBranchAddress("JpsiCharge",&JpsiCharge); tree->SetBranchAddress("JpsiMass",&JpsiMass); tree->SetBranchAddress("JpsiPt",&JpsiPt); tree->SetBranchAddress("JpsiPx",&JpsiPx); tree->SetBranchAddress("JpsiPy",&JpsiPy); tree->SetBranchAddress("JpsiPz",&JpsiPz); tree->SetBranchAddress("JpsiRap",&JpsiRap); tree->SetBranchAddress("JpsiVprob",&JpsiVprob); tree->SetBranchAddress("rbin",&rbin); //muon variable tree->SetBranchAddress("muPosPx",&muPosPx); tree->SetBranchAddress("muPosPy",&muPosPy); tree->SetBranchAddress("muPosPz",&muPosPz); tree->SetBranchAddress("muPosEta",&muPosEta); tree->SetBranchAddress("muPosPhi",&muPosPhi); tree->SetBranchAddress("muNegPx", &muNegPx); tree->SetBranchAddress("muNegPy", &muNegPy); tree->SetBranchAddress("muNegPz", &muNegPz); tree->SetBranchAddress("muNegEta", &muNegEta); tree->SetBranchAddress("muNegPhi", &muNegPhi); //1). Positive Muon tree->SetBranchAddress("muPos_nchi2In", &muPos_nchi2In); tree->SetBranchAddress("muPos_dxy", &muPos_dxy); tree->SetBranchAddress("muPos_dz", &muPos_dz); tree->SetBranchAddress("muPos_nchi2Gl", &muPos_nchi2Gl); tree->SetBranchAddress("muPos_found", &muPos_found); tree->SetBranchAddress("muPos_pixeLayers", &muPos_pixeLayers); tree->SetBranchAddress("muPos_nValidMuHits", &muPos_nValidMuHits); tree->SetBranchAddress("muPos_matches", &muPos_matches); tree->SetBranchAddress("muPos_tracker", &muPos_tracker); tree->SetBranchAddress("muPos_arbitrated", &muPos_arbitrated); //2). Negative Muon tree->SetBranchAddress("muNeg_nchi2In", &muNeg_nchi2In); tree->SetBranchAddress("muNeg_dxy", &muNeg_dxy); tree->SetBranchAddress("muNeg_dz", &muNeg_dz); tree->SetBranchAddress("muNeg_nchi2Gl", &muNeg_nchi2Gl); tree->SetBranchAddress("muNeg_found", &muNeg_found); tree->SetBranchAddress("muNeg_pixeLayers", &muNeg_pixeLayers); tree->SetBranchAddress("muNeg_nValidMuHits", &muNeg_nValidMuHits); tree->SetBranchAddress("muNeg_matches", &muNeg_matches); tree->SetBranchAddress("muNeg_tracker", &muNeg_tracker); tree->SetBranchAddress("muNeg_arbitrated", &muNeg_arbitrated); //====================================Gen Variables========================================================= //Gen Jpsi Variables gentree->SetBranchAddress("GenJpsiMass", &GenJpsiMass); gentree->SetBranchAddress("GenJpsiPt", &GenJpsiPt); gentree->SetBranchAddress("GenJpsiRap", &GenJpsiRap); gentree->SetBranchAddress("GenJpsiPx", &GenJpsiPx); gentree->SetBranchAddress("GenJpsiPy", &GenJpsiPy); gentree->SetBranchAddress("GenJpsiPz", &GenJpsiPz); gentree->SetBranchAddress("gbin",&gbin); //muon variable gentree->SetBranchAddress("GenmuPosPx", &GenmuPosPx); gentree->SetBranchAddress("GenmuPosPy", &GenmuPosPy); gentree->SetBranchAddress("GenmuPosPz", &GenmuPosPz); gentree->SetBranchAddress("GenmuPosEta", &GenmuPosEta); gentree->SetBranchAddress("GenmuPosPhi", &GenmuPosPhi); gentree->SetBranchAddress("GenmuNegPx", &GenmuNegPx); gentree->SetBranchAddress("GenmuNegPy", &GenmuNegPy); gentree->SetBranchAddress("GenmuNegPz", &GenmuNegPz); gentree->SetBranchAddress("GenmuNegEta", &GenmuNegEta); gentree->SetBranchAddress("GenmuNegPhi", &GenmuNegPhi); //====================================================== Gen tree loop ================================================ int NAccep=0; int nGenEntries=gentree->GetEntries(); cout<<" Total Entries in GenLevel Tree for pT range: "<<fileName[ifile]<<" "<< nGenEntries<< " ========="<<endl; //dataFile<<" Total Entries in GenLevel Tree for pT range: "<<fileName[ifile]<<" "<< nGenEntries<< " ====="<<endl; for(int i=0; i< nGenEntries; i++) { gentree->GetEntry(i); if(i%1000==0){ cout<<" processing record "<<i<<endl; cout<<" Mass "<< GenJpsiMass<< " pT "<< GenJpsiPt << " Y " <<GenJpsiRap<<endl; } bool GenPosIn=0, GenNegIn=0,GenPosPass=0,GenNegPass=0; GenmuPosPt= TMath::Sqrt(GenmuPosPx*GenmuPosPx + GenmuPosPy*GenmuPosPy); GenmuNegPt= TMath::Sqrt(GenmuNegPx*GenmuNegPx + GenmuNegPy*GenmuNegPy); GenJpsiE= TMath::Sqrt( GenJpsiPx*GenJpsiPx+GenJpsiPy*GenJpsiPy+GenJpsiPz*GenJpsiPz + 9.46*9.46); //============================ calculate Pol weight ========================================================================================= // Float_t w1,w2,w3,w4,w5; // this is the beam energy: 2760GeV->/2->1380GeV each beam // the mp=0.938272 is the mass of the proton, as we are looking at p+p collisions double E=1380; double pz = sqrt(E*E - 0.938272*0.938272); TLorentzVector h1; // beam 1 TLorentzVector h2; // beam 2 TLorentzVector genJpsi; // generated upsilon (mother of the single muons) --> if you look at jpsi-> genJpsi (prompt or non-prompt) TLorentzVector genMuPlus,genMuMinus; // generator positive muon (charge=+1) //int mp; Float_t cosThetaStarHel; // cosTheta in the Helicity frame Float_t cosThetaStarCS; // cosTheta in the Collins-Soper frame TVector3 zCS; // collins-soper variable // put the coordinates of the parent in a TLorentzVector // ATTENTION: the last coordinate is the MASS of the parent, which in this case, since it's about Upsilon, it's 9.46 // when you'll do this for Jpsi, this value has to change to m_jpsi=3.097 genJpsi.SetPxPyPzE(GenJpsiPx, GenJpsiPy, GenJpsiPz, GenJpsiE); TLorentzRotation boost(-genJpsi.BoostVector()); // boost it // put the muon in a LorentzVector genMuPlus.SetPtEtaPhiM(GenmuPosPt, GenmuPosEta, GenmuPosPhi, 0.106); genMuPlus *= boost; // boost it //genMuMinus.SetPtEtaPhiM(GenmuNegPt, GenmuNegEta, GenmuNegPhi, 0.106); //genMuMinus *= boost; // boost it //and get the cosTheta in the helicity frame cosThetaStarHel = genMuPlus.Vect().Dot(genJpsi.Vect())/(genMuPlus.Vect().Mag()*genJpsi.Vect().Mag()); //int genMuCharge = 1; //int mp = genMuCharge>0 ? 0 : 1; //cout << genMuCharge << " " << mp << endl; h1.SetPxPyPzE(0,0,pz,E); // TLorentzVector for beam 1 h2.SetPxPyPzE(0,0,-pz,E); // TLorentzVector for beam 2 h1*=boost; h2*=boost; // calculate cosTheta CS zCS = ( h1.Vect().Unit() - h2.Vect().Unit() ).Unit(); cosThetaStarCS = genMuPlus.Vect().Dot(zCS)/genMuPlus.Vect().Mag(); // setup the weights w1 = 1; w2 = 1 + cosThetaStarHel*cosThetaStarHel; w3 = 1 - cosThetaStarHel*cosThetaStarHel; w4 = 1 + cosThetaStarCS*cosThetaStarCS; w5 = 1 - cosThetaStarCS*cosThetaStarCS; //w5=1; // cout<<" gen "<<w2<<" "<<w3<<" "<<w4<<" "<<w5<<endl; //==============================================================================================================================================// diMuonsInvMass_Gen->Fill(GenJpsiMass); diMuonsPt_Gen->Fill(GenJpsiPt); if(IsAccept(GenmuPosPt, GenmuPosEta)) {GenPosIn=1;} if(IsAccept(GenmuNegPt, GenmuNegEta)) {GenNegIn=1;} if(GenPosIn && GenNegIn ) NAccep++; if(GenPosIn==1 && GenmuPosPt>PtCut ) {GenPosPass=1;} if(GenNegIn==1 && GenmuNegPt>PtCut ) {GenNegPass=1;} double GenCenWeight=0,GenWeight=0; GenCenWeight=FindCenWeight(gbin); Bin_Gen->Fill(gbin); GenWeight=GenCenWeight*scale[ifile]; if(PutWeight==0){GenWeight=1;} if(GenPosIn && GenNegIn){ if(ifile==0){diMuonsRap_Gen0->Fill(GenJpsiRap);} if(ifile==1){diMuonsRap_Gen1->Fill(GenJpsiRap);} if(ifile==2){diMuonsRap_Gen2->Fill(GenJpsiRap);} if(ifile==3){diMuonsRap_Gen3->Fill(GenJpsiRap);} if(ifile==4){diMuonsRap_Gen4->Fill(GenJpsiRap);} if(ifile==5){diMuonsRap_Gen5->Fill(GenJpsiRap);} } for (Int_t ih = 0; ih < Nptbin; ih++) { //adding pT of all pt bins to see diss is cont if(iSpec == 1) if( (GenPosPass==1 && GenNegPass==1) && (TMath::Abs(GenJpsiRap)<2.4 ) && (GenJpsiPt>pt_bound[ih] && GenJpsiPt<=pt_bound[ih+1])){diMuonsPt_GenA[ifile][ih]->Fill(GenJpsiPt,GenWeight*w5);} if(iSpec == 1) if( (GenPosPass==1 && GenNegPass==1) && (TMath::Abs(GenJpsiRap)<2.4 )&&(GenJpsiPt>pt_bound[ih] && GenJpsiPt<=pt_bound[ih+1])){diMuonsInvMass_GenA[ifile][ih]->Fill(GenJpsiMass,GenWeight*w5);} if(iSpec == 2) if((GenPosPass==1 && GenNegPass==1) && (GenJpsiPt<20.0) && (TMath::Abs(GenJpsiRap) > pt_bound[ih] && TMath::Abs(GenJpsiRap) <=pt_bound[ih+1] )){diMuonsInvMass_GenA[ifile][ih]->Fill(GenJpsiMass,GenWeight*w5);} if(iSpec == 3) if( (GenPosPass==1 && GenNegPass==1) && (GenJpsiPt < 20.0) && (TMath::Abs(GenJpsiRap)<2.4 ) && (gbin>=pt_bound[ih] && gbin<pt_bound[ih+1])){diMuonsInvMass_GenA[ifile][ih]->Fill(GenJpsiMass,GenWeight*w5);} } }//gen loop end cout<<" accepted no "<< NAccep<<endl; //dataFile<<" accepted no "<< NAccep<<endl; // new TCanvas; //diMuonsInvMass_Gen->Draw(); //gPad->Print("plots/diMuonsInvMass_Gen.png"); //new TCanvas; //diMuonsPt_Gen->Draw(); //gPad->Print("plots/diMuonsPt_Gen.png"); //new TCanvas; //diMuonsRap_Gen0->Draw(); //sprintf(PlotName,"plots/diMuonsRap_Gen_%d.pdf",ifile); //gPad->Print(PlotName); //new TCanvas; //Bin_Gen->Draw(); //gPad->Print("plots/Bin_Gen.png"); //=============== Rec Tree Loop ============================================================================== int nRecEntries=tree->GetEntries(); cout<<"Total Entries in reconstructed Tree for pT range "<<fileName[ifile]<<" "<<nRecEntries<< "====="<<endl; //dataFile<<"Total Entries in reconstructed Tree for pT range "<<fileName[ifile]<<" "<<nRecEntries<<endl; for(int i=0; i<nRecEntries; i++) { tree->GetEntry(i); if(i%100000==0){ cout<<" processing record "<<i<<endl; cout<<" processing Run " <<runNb <<" event "<<eventNb<<" lum block "<<lumiBlock<<endl; cout<<" Mass "<< JpsiMass<< " pT "<< JpsiPt << " Y " <<JpsiRap<<" "<<JpsiVprob<<" charge "<<JpsiCharge<<endl; } bool PosPass=0, NegPass=0, AllCut=0 ,PosIn=0, NegIn=0; muPosPt= TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy); muPosP = TMath::Sqrt(muPosPx*muPosPx + muPosPy*muPosPy+ muPosPz*muPosPz); muNegPt= TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy); muNegP = TMath::Sqrt(muNegPx*muNegPx + muNegPy*muNegPy +muNegPz*muNegPz); JpsiE= TMath::Sqrt(JpsiPx*JpsiPx+JpsiPy*JpsiPy+JpsiPz*JpsiPz + JpsiMass*JpsiMass); //============================ calculate Pol weight rec ========================================================================================= // Float_t w1=0,w2=0,w3=0,w4=0,w5=0; double E=1380; double pz = sqrt(E*E - 0.938272*0.938272); TLorentzVector h1; // beam 1 TLorentzVector h2; // beam 2 TLorentzVector Jpsi; TLorentzVector MuPlus; Float_t cosThetaStarHel; // cosTheta in the Helicity frame Float_t cosThetaStarCS; // cosTheta in the Collins-Soper frame TVector3 zCS; // collins-soper variable Jpsi.SetPxPyPzE(JpsiPx, JpsiPy, JpsiPz, JpsiE); TLorentzRotation boost(-Jpsi.BoostVector()); // boost it // put the muon in a LorentzVector MuPlus.SetPtEtaPhiM(muPosPt, muPosEta, muPosPhi, 0.106); MuPlus *= boost; // boost it //and get the cosTheta in the helicity frame cosThetaStarHel = MuPlus.Vect().Dot(Jpsi.Vect())/(MuPlus.Vect().Mag()*Jpsi.Vect().Mag()); h1.SetPxPyPzE(0,0,pz,E); // TLorentzVector for beam 1 h2.SetPxPyPzE(0,0,-pz,E); // TLorentzVector for beam 2 h1*=boost; h2*=boost; zCS = ( h1.Vect().Unit() - h2.Vect().Unit() ).Unit(); cosThetaStarCS = MuPlus.Vect().Dot(zCS)/MuPlus.Vect().Mag(); // setup the weights w1 = 1; w2 = 1 + cosThetaStarHel*cosThetaStarHel; w3 = 1 - cosThetaStarHel*cosThetaStarHel; w4 = 1 + cosThetaStarCS*cosThetaStarCS; w5 = 1 - cosThetaStarCS*cosThetaStarCS; //w5=1; //cout<<" rec "<<w2<<" "<<w3<<" "<<w4<<" "<<w5<<endl; //================================================== Pol weights ===============================================================================// if(IsAccept(muPosPt, muPosEta)){PosIn=1;} if(IsAccept(muNegPt, muNegEta)){NegIn=1;} if(muPos_found > 10 && muPos_pixeLayers > 0 && muPos_nchi2In < 4.0 && muPos_dxy < 3 && muPos_dz < 15 && muPos_nchi2Gl < 20 && muPos_arbitrated==1 && muPos_tracker==1){PosPass=1;} if(muNeg_found >10 && muNeg_pixeLayers >0 && muNeg_nchi2In <4.0 && muNeg_dxy < 3 && muNeg_dz < 15 && muNeg_nchi2Gl < 20 && muNeg_arbitrated==1 && muNeg_tracker==1){NegPass=1;} // cout<<muPos_matches<<" "<<muNeg_matches<<endl; if((muPosPt > PtCut && muNegPt > PtCut) && (muPos_matches==1 && muNeg_matches==1) && (PosIn==1 && NegIn==1 ) && (PosPass==1 && NegPass==1)){AllCut=1;} double RecCenWeight=0,RecWeight=0; RecCenWeight=FindCenWeight(rbin); RecWeight=RecCenWeight*scale[ifile]; if(PutWeight==0){RecWeight=1;} if(i%100000==0){ cout<<" eff loop for reco "<<endl; } if(AllCut==1){ if(ifile==0){diMuonsRap_Rec0->Fill(JpsiRap);} if(ifile==1){diMuonsRap_Rec1->Fill(JpsiRap);} if(ifile==2){diMuonsRap_Rec2->Fill(JpsiRap);} if(ifile==3){diMuonsRap_Rec3->Fill(JpsiRap);} if(ifile==4){diMuonsRap_Rec4->Fill(JpsiRap);} if(ifile==5){diMuonsRap_Rec5->Fill(JpsiRap);} } //Eff loop for reco if((JpsiCharge == 0) && (JpsiVprob > 0.01)) { for (Int_t ih = 0; ih < Nptbin; ih++) { //to see cont reco pT if(iSpec == 1)if((AllCut==1) && (TMath::Abs(JpsiRap) < 2.4) && (JpsiPt>pt_bound[ih] && JpsiPt<=pt_bound[ih+1])) {diMuonsPt_RecA[ifile][ih]->Fill(JpsiPt,RecWeight*w5);} if(iSpec == 1)if((AllCut==1) && (TMath::Abs(JpsiRap)<2.4 ) && (JpsiPt > pt_bound[ih] && JpsiPt <=pt_bound[ih+1])){diMuonsInvMass_RecA[ifile][ih]->Fill(JpsiMass, RecWeight*w5);} if(iSpec == 2) if( (AllCut==1) && (JpsiPt<20.0) && (TMath::Abs(JpsiRap) > pt_bound[ih] && TMath::Abs(JpsiRap) <=pt_bound[ih+1])){diMuonsInvMass_RecA[ifile][ih]->Fill(JpsiMass,RecWeight*w5);} if(iSpec == 3) if((AllCut==1) && (JpsiPt<20.0) && (TMath::Abs(JpsiRap) < 2.4) && (rbin>=pt_bound[ih] && rbin < pt_bound[ih+1])){diMuonsInvMass_RecA[ifile][ih]->Fill(JpsiMass,RecWeight*w5);} } } } /* new TCanvas; if(ifile==0){diMuonsRap_Gen0->Draw();new TCanvas; diMuonsRap_Rec0->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen0.png");} if(ifile==1){diMuonsRap_Gen1->Draw();new TCanvas; diMuonsRap_Rec1->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen1.png");} if(ifile==2){diMuonsRap_Gen2->Draw();new TCanvas; diMuonsRap_Rec2->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen2.png");} if(ifile==3){diMuonsRap_Gen3->Draw();new TCanvas; diMuonsRap_Rec3->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen3.png");} if(ifile==4){diMuonsRap_Gen4->Draw();new TCanvas; diMuonsRap_Rec4->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen4.png");} if(ifile==5){diMuonsRap_Gen5->Draw();new TCanvas; diMuonsRap_Rec5->Draw(); gPad->Print("plots/NPdiMuonsRap_Gen5.png");} */ } // file loop ends /////////////////////////////////////////////////////////////////// cout<< " adding "<<endl; TH1D *diMuonsInvMass_RecA1[100]; TH1D *diMuonsInvMass_GenA1[100]; TH1D *diMuonsPt_GenA1[100]; TH1D *diMuonsPt_RecA1[100]; TF1 *backfun_1; char namePt_1B[500];//for bkg func for(Int_t ih = 0; ih < Nptbin; ih++){ diMuonsInvMass_RecA1[ih] = diMuonsInvMass_RecA[0][ih]; diMuonsInvMass_GenA1[ih] = diMuonsInvMass_GenA[0][ih]; diMuonsPt_GenA1[ih] = diMuonsPt_GenA[0][ih]; diMuonsPt_RecA1[ih] = diMuonsPt_RecA[0][ih]; for (int ifile = 1; ifile <= 5; ifile++) { diMuonsInvMass_RecA1[ih]->Add(diMuonsInvMass_RecA[ifile][ih]); diMuonsInvMass_GenA1[ih]->Add(diMuonsInvMass_GenA[ifile][ih]); diMuonsPt_GenA1[ih]->Add(diMuonsPt_GenA[ifile][ih]); diMuonsPt_RecA1[ih]->Add(diMuonsPt_RecA[ifile][ih]); } } //===========================Fitting===================================================================// // Fit ranges double mass_low, mass_high; double MassUpsilon, WeidthUpsilon; // Low mass range upsilon width 54 KeV MassUpsilon = 9.46; WeidthUpsilon = 0.055; //MassUpsilon = 9.46; WeidthUpsilon = 0.068; mass_low = 9.0; mass_high = 10.0; // Fit ranges // Fit Function crystall ball TF1 *GAUSPOL = new TF1("GAUSPOL",CrystalBall,8.0,12.0,6); GAUSPOL->SetParNames("Yield (#Upsilon)","BinWidth","Mean","Sigma","#alpha","n"); GAUSPOL->SetParameter(2, MassUpsilon); GAUSPOL->SetParameter(3, WeidthUpsilon); //GAUSPOL->SetParLimits(3, 0.1*WeidthUpsilon,2.0*WeidthUpsilon); GAUSPOL->SetParameter(4, 1.0); GAUSPOL->SetParameter(5, 20.0); GAUSPOL->SetLineWidth(2.0); GAUSPOL->SetLineColor(2); //=====================Loop for eff=========================================================== double GenNo[100]={0}; double Eff[100]={0}; double GenError[100]={0}; double RecError[100]={0}; double errEff_cat_S1[100]={0}; double errEff_cat_S2[100]={0}; double errEff_cat_S1_1[100]={0},errEff_cat_S1_2[100]={0}; double errEff_cat_S2_1[100]={0},errEff_cat_S2_2[100]={0}; char PlotName[500],PlotName1[500], PlotName2[500]; char GPlotName[500],GPlotName1[500], GPlotName2[500]; for (Int_t ih = 0; ih < Nptbin; ih++) { cout<<" no of gen dimuons from diMuons Pt histo "<<diMuonsPt_GenA1[ih]->Integral(1,100)<<endl; cout<<" no of gen dimuons from diMuons Mass histo "<<diMuonsInvMass_GenA1[ih]->Integral(1,100)<<endl; //from pT histogram //gen_pt[ih] =diMuonsPt_GenA1[ih]->IntegralAndError(1,100,genError); gen_pt[ih] = diMuonsInvMass_GenA1[ih]->IntegralAndError(1,100,genError); gen_ptError[ih]= genError; if(iSpec==1) sprintf(PlotName,"plots/DiMuonMass_PtBin_%d.png",ih); if(iSpec==2) sprintf(PlotName,"plots/DiMuonMass_RapBin_%d.png",ih); if(iSpec==3) sprintf(PlotName,"plots/DiMuonMass_CentBin_%d.png",ih); if(iSpec==1) sprintf(PlotName1,"plots/DiMuonMass_PtBin_%d.pdf",ih); if(iSpec==2) sprintf(PlotName1,"plots/DiMuonMass_RapBin_%d.pdf",ih); if(iSpec==3) sprintf(PlotName1,"plots/DiMuonMass_CentBin_%d.pdf",ih); if(iSpec==1) sprintf(PlotName2,"plots/DiMuonMass_PtBin_%d.eps",ih); if(iSpec==2) sprintf(PlotName2,"plots/DiMuonMass_RapBin_%d.eps",ih); if(iSpec==3) sprintf(PlotName2,"plots/DiMuonMass_CentBin_%d.eps",ih); //giving inetial value for crystall ball fourth parameter diMuonsInvMass_RecA1[ih]->Rebin(2); GAUSPOL->SetParameter(0, diMuonsInvMass_RecA1[ih]->Integral(0,50)); GAUSPOL->FixParameter(1, diMuonsInvMass_RecA1[ih]->GetBinWidth(1)); new TCanvas; diMuonsInvMass_RecA1[ih]->Fit("GAUSPOL","LLMERQ", "", mass_low, mass_high); double UpsilonMass = GAUSPOL->GetParameter(2); double UpsilonWidth = GAUSPOL->GetParameter(3); double UpsilonYield = GAUSPOL->GetParameter(0); double UpsilonYieldError = GAUSPOL->GetParError(0); double par[20]; GAUSPOL->GetParameters(par); sprintf(namePt_1B,"pt_1B_%d",ih); backfun_1 = new TF1(namePt_1B, Pol2, mass_low, mass_high, 3); backfun_1->SetParameters(&par[4]); double MassLow=(UpsilonMass-3*UpsilonWidth); double MassHigh=(UpsilonMass+3*UpsilonWidth); int binlow =diMuonsInvMass_RecA1[ih]->GetXaxis()->FindBin(MassLow); int binhi =diMuonsInvMass_RecA1[ih]->GetXaxis()->FindBin(MassHigh); double binwidth=diMuonsInvMass_RecA1[ih]->GetBinWidth(1); //yield by function //rec_pt[ih] = UpsilonYield; //rec_ptError[ih]= UpsilonYieldError; cout<<"Rec diMuons from Pt histo "<<diMuonsPt_RecA1[ih]->Integral(1,100)<<endl; cout<<"Rec dimuons from mass "<<diMuonsInvMass_RecA1[ih]->Integral(1,100)<<endl; //from pT histo //rec_pt[ih]=diMuonsPt_RecA1[ih]->IntegralAndError(1, 100,recError); //yield by histogram integral rec_pt[ih] = diMuonsInvMass_RecA1[ih]->IntegralAndError(binlow, binhi,recError); rec_ptError[ih]= recError; //Cal eff Eff_cat_1[ih] = rec_pt[ih]/gen_pt[ih]; //calculate error on eff GenNo[ih]=gen_pt[ih]; Eff[ih]= Eff_cat_1[ih]; GenError[ih]=gen_ptError[ih]; RecError[ih]=rec_ptError[ih]; //error errEff_cat_S1_1[ih]= ( (Eff[ih] * Eff[ih]) /(GenNo[ih] * GenNo[ih]) ); errEff_cat_S1_2[ih]= (RecError[ih] * RecError[ih]); errEff_cat_S1[ih]= (errEff_cat_S1_1[ih] * errEff_cat_S1_2[ih]); errEff_cat_S2_1[ih]= ( (1 - Eff[ih])* (1 - Eff[ih]) ) / ( GenNo[ih] * GenNo[ih]); errEff_cat_S2_2[ih]= (GenError[ih] * GenError[ih] ) - ( RecError[ih] * RecError[ih] ); errEff_cat_S2[ih]=errEff_cat_S2_1[ih]*errEff_cat_S2_2[ih]; Err_Eff_cat_1[ih]=sqrt(errEff_cat_S1[ih] + errEff_cat_S2[ih]); //error for no weights //Err_Eff_cat_1[ih]= Eff_cat_1[ih]*TMath::Sqrt(gen_ptError[ih]*gen_ptError[ih]/(gen_pt[ih]*gen_pt[ih]) + rec_ptError[ih]*rec_ptError[ih]/(rec_pt[ih]* rec_pt[ih])); cout<<"Upsilon Yield by integral of histo: "<< diMuonsInvMass_RecA1[ih]->IntegralAndError(binlow, binhi,recError) <<" error "<< rec_ptError[ih]<<endl; cout<<"UpsilonYield by Gauss yield det: "<< UpsilonYield << " UpsilonWidth "<< UpsilonWidth<<" UpsilonMass "<<UpsilonMass <<endl; cout<<"Upsilon Yield by Function integral: "<< GAUSPOL->Integral(MassLow,MassHigh)/binwidth <<endl; cout<<" rec_pt[ih] "<< rec_pt[ih] <<" gen_pt[ih] "<<gen_pt[ih]<<endl; //dataFile<<" rec_pt[ih] "<< rec_pt[ih] <<" gen_pt[ih] "<<gen_pt[ih]<<endl; cout<<" eff "<< Eff_cat_1[ih]<<" error "<<Err_Eff_cat_1[ih]<<endl; dataFile<<"ih " <<ih<<" eff "<< Eff_cat_1[ih]<<" error "<<Err_Eff_cat_1[ih]<<endl; if(iSpec==1) sprintf(GPlotName,"plots/GenDiMuonMass_PtBin_%d.png",ih); if(iSpec==2) sprintf(GPlotName,"plots/GenDiMuonMass_RapBin_%d.png",ih); if(iSpec==3) sprintf(GPlotName,"plots/GenDiMuonMass_CentBin_%d.png",ih); if(iSpec==1) sprintf(GPlotName1,"plots/GenDiMuonMass_PtBin_%d.pdf",ih); if(iSpec==2) sprintf(GPlotName1,"plots/GenDiMuonMass_RapBin_%d.pdf",ih); if(iSpec==3) sprintf(GPlotName1,"plots/GenDiMuonMass_CentBin_%d.pdf",ih); if(iSpec==1) sprintf(GPlotName2,"plots/GenDiMuonMass_PtBin_%d.eps",ih); if(iSpec==2) sprintf(GPlotName2,"plots/GenDiMuonMass_RapBin_%d.eps",ih); if(iSpec==3) sprintf(GPlotName2,"plots/GenDiMuonMass_CentBin_%d.eps",ih); backfun_1->SetLineColor(4); backfun_1->SetLineWidth(1); //backfun_1->Draw("same"); gPad->Print(PlotName); gPad->Print(PlotName1); gPad->Print(PlotName2); new TCanvas; diMuonsInvMass_GenA1[ih]->Draw(); gPad->Print(GPlotName); gPad->Print(GPlotName1); gPad->Print(GPlotName2); //new TCanvas; //diMuonsPt_GenA1[ih]->Draw(); //new TCanvas; //diMuonsPt_RecA1[ih]->Draw(); } dataFile.close(); TGraphErrors *Eff_Upsilon = new TGraphErrors(Nptbin, PT, Eff_cat_1, mom_err,Err_Eff_cat_1); Eff_Upsilon->SetMarkerStyle(21); Eff_Upsilon->SetMarkerColor(2); Eff_Upsilon->GetYaxis()->SetTitle("Reco Eff"); if(iSpec==1) Eff_Upsilon->GetXaxis()->SetTitle("#Upsilon pT (GeV/c^{2})"); if(iSpec==2) Eff_Upsilon->GetXaxis()->SetTitle("#Upsilon rapidity"); if(iSpec==3) Eff_Upsilon->GetXaxis()->SetTitle("bin"); Eff_Upsilon->GetYaxis()->SetRangeUser(0,1.0); TLegend *legend_GP = new TLegend( 0.50,0.79,0.80,0.89); legend_GP->SetBorderSize(0); legend_GP->SetFillStyle(0); legend_GP->SetFillColor(0); legend_GP->SetTextSize(0.032); legend_GP->AddEntry(Eff_Upsilon,"PythiaEvtGen + HydjetBass", "P"); new TCanvas; Eff_Upsilon->Draw("AP"); legend_GP->Draw("Same"); if(iSpec==1){ gPad->Print("plots/Eff_Upsilon_Pt.pdf");gPad->Print("plots/Eff_Upsilon_Pt.png");gPad->Print("plots/Eff_Upsilon_Pt.eps");} if(iSpec==2){ gPad->Print("plots/Eff_Upsilon_Rap.pdf");gPad->Print("plots/Eff_Upsilon_Rap.png"); gPad->Print("plots/Eff_Upsilon_Rap.eps");} if(iSpec==3){ gPad->Print("plots/Eff_Upsilon_Cent.pdf");gPad->Print("plots/Eff_Upsilon_Cent.png"); gPad->Print("plots/Eff_Upsilon_Cent.eps"); } }
void ztree::ffgammajet(std::string outfname, int centmin, int centmax, float phoetmin, float phoetmax, std::string gen) { string tag = outfname; string s_alpha = gen; if (fChain == 0) return; Long64_t nentries = fChain->GetEntriesFast(); TFile * fout = new TFile(Form("%s_%s_%s_%d_%d.root",outfname.data(),tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),"recreate"); TH2D * hsubept = new TH2D(Form("hsubept_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100); TH2D * hsubept_refcone = new TH2D(Form("hsubept_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),100,-0.5,99.5,100,0,100); TH1D * hjetpt = new TH1D(Form("hjetpt_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";jet p_{T};"),20,0,500); TH1D * hjetgendphi = new TH1D(Form("hjetgendphi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#DeltaR_{gen,reco};"),20,0,0.1); TH1D * hgammaff = new TH1D(Form("hgammaff_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";z;"),20,0,1); TH1D * hgammaffxi = new TH1D(Form("hgammaffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaffxi_refcone = new TH1D(Form("hgammaffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaphoffxi = new TH1D(Form("hgammaphoffxi_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); TH1D * hgammaphoffxi_refcone = new TH1D(Form("hgammaphoffxi_refcone_%s_%s_%d_%d",tag.data(),s_alpha.data(),abs(centmin),abs(centmax)),Form(";#xi=ln(1/z);"),10,0,5); Long64_t nbytes = 0, nb = 0; cout<<phoetmin<<" "<<phoetmax<<endl; for (Long64_t jentry=0; jentry<nentries;jentry++) { if(jentry%10000==0) { cout<<jentry<<"/"<<nentries<<endl; } Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; // cout<<njet<<endl; // if(jentry > 10000) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(hiBin < centmin || hiBin >= centmax) continue; //centrality cut if(nPho!=1) continue; // if(phoEt[0]<phoetmin || phoEt[0]>phoetmax) continue; if(weight==0) weight=1; // cout<<njet<<endl; if(gen.compare("gen")==0) { for (int ijet = 0; ijet < njet; ijet++) { if(mcEt[pho_genMatchedIndex[0]]<phoetmin || mcEt[pho_genMatchedIndex[0]]>phoetmax) continue; if( nPho==2 ) continue; if( jetpt[ijet]<40 ) continue; //jet pt Cut if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone if( jetID[ijet]==0 ) continue; //redundant in this skim (all true) if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue; hjetpt->Fill(jetpt[ijet]); float denrecodphi = acos(cos(jetphi[ijet] - gjetphi[ijet])); hjetgendphi->Fill(denrecodphi); TLorentzVector vjet; vjet.SetPtEtaPhiM(gjetpt[ijet],gjeteta[ijet],gjetphi[ijet],0); for(int igen = 0 ; igen < mult ; ++igen) { if(!(abs(pdg[igen])==11 || abs(pdg[igen])==13 || abs(pdg[igen])==211 || abs(pdg[igen])==2212 || abs(pdg[igen])==321)) continue; if(sube[igen] != 0) continue; float dr = genjettrk_dr(igen,ijet); float dr_refcone = genrefconetrk_dr(igen,ijet); if(dr<0.3) { TLorentzVector vtrack; vtrack.SetPtEtaPhiM(pt[igen],eta[igen],phi[igen],0); float angle = vjet.Angle(vtrack.Vect()); float z = pt[igen]*cos(angle)/gjetpt[ijet]; float zpho = pt[igen]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaff->Fill(z); hgammaffxi->Fill(xi); hgammaphoffxi->Fill(xipho); hsubept->Fill(sube[igen],pt[igen]); // cout<<jetpt[ijet]<<endl; } if(dr_refcone<0.3) { float z = pt[igen]/gjetpt[ijet]; float zpho = pt[igen]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaffxi_refcone->Fill(xi); hgammaphoffxi_refcone->Fill(xipho); hsubept_refcone->Fill(sube[igen],pt[igen]); } } } } else { for (int ijet = 0; ijet < njet; ijet++) { if( nPho==2 ) continue; if( phoEt[0]*phoCorr[0]<phoetmin || phoEt[0]*phoCorr[0]>phoetmax) continue; if( jetpt[ijet]<40 ) continue; //jet pt Cut if( fabs(jeteta[ijet]) > 1.6) continue; //jeteta Cut if( fabs(jeteta[ijet]) < 0.3) continue; //jeteta Cut for reflected cone if( jetID[ijet]==0 ) continue; //redundant in this skim (all true) if( acos(cos(jetphi[ijet] - phoPhi[0])) < 7 * pi / 8 ) continue; hjetpt->Fill(jetpt[ijet]); TLorentzVector vjet; vjet.SetPtEtaPhiM(jetpt[ijet],jeteta[ijet],jetphi[ijet],0); for (int itrk = 0; itrk < nTrk; itrk++) { float dr = jettrk_dr(itrk,ijet); // float dr = genjetrecotrk_dr(itrk,ijet); float dr_refcone = refconetrk_dr(itrk,ijet); // float dr_refcone = genrefconerecotrk_dr(itrk,ijet); if(dr<0.3) { TLorentzVector vtrack; vtrack.SetPtEtaPhiM(trkPt[itrk],trkEta[itrk],trkPhi[itrk],0); float angle = vjet.Angle(vtrack.Vect()); float z = trkPt[itrk]*cos(angle)/jetpt[ijet]; float zpho = trkPt[itrk]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaff->Fill(z,trkWeight[itrk]); hgammaffxi->Fill(xi,trkWeight[itrk]); hgammaphoffxi->Fill(xipho,trkWeight[itrk]); // hgammaff->Fill(z); // hgammaffxi->Fill(xi); // hgammaphoffxi->Fill(xipho); // cout<<jetpt[ijet]<<endl; } if(dr_refcone<0.3) { float z = trkPt[itrk]/jetpt[ijet]; float zpho = trkPt[itrk]/phoEt[0]; float xi = log(1.0/z); float xipho = log(1.0/zpho); hgammaffxi_refcone->Fill(xi,trkWeight[itrk]); hgammaphoffxi_refcone->Fill(xipho,trkWeight[itrk]); // hgammaffxi_refcone->Fill(xi); // hgammaphoffxi_refcone->Fill(xipho); } } // photons: normal mode power mode // pho 40 trigger // photon spike cuts etc // phoet > 35 // phoet > 40 after correction // haven't made it yet // phoeta < 1.44 // sumiso < 1 GeV // h/em < 0.1 // sigmaetaeta < 0.01 // jets: // some pt // jeteta < 1.6 // some id cuts // none yet but we'll add some // ak3pupf jets // delphi > 7 pi / 8 } } /* */ } fout->Write(); fout->Close(); }
void pgsAnalysis::Loop() { double tHrec, tZ1m, tZ2m, tcosthetaStar, tPhi, tPhi1, tcostheta1, tcostheta2,tHrec_constr,tZ1m_constr, tZ2m_constr; string ttype; hists->Branch("Hrec", &tHrec); hists->Branch("Z1m", &tZ1m); hists->Branch("Z2m", &tZ2m); hists->Branch("costhetaStar", &tcosthetaStar); hists->Branch("Phi", &tPhi); hists->Branch("Phi1", &tPhi1); hists->Branch("costheta1", &tcostheta1); hists->Branch("costheta2", &tcostheta2); hists->Branch("type", &ttype); //event type!! int eeee, xxxx, eexx, xxee; double Zmass = 91.19; double vZmass; if (pairing == 0){ vZmass = 91.19; } else{ vZmass = 45.; } TVectorT<double> elSum(4); TVectorT<double> muSum(4); //electrons array vector<int> el; int elC = 0; //muons array vector<int> mu; int muC = 0; //antielectrons array vector<int> antiel; int antielC = 0; //antimuons array vector<int> antimu; int antimuC = 0; vector<TVector3> leptons; TVector3 lep1,lep2,lep3,lep4; TVector3 Za, Zb, Zc, Zd, H; int lCounter = 0; int totaLlCounter = 0; int goodEventCounter = 0; int histCounter = 0; if (fChain == 0) return; int nentries = n; // cout << " nentries are "<<nentries<<endl; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; el.clear(); antiel.clear(); mu.clear(); antimu.clear(); lCounter = 0; eeee = 0; xxxx = 0; eexx = 0; xxee = 0; //particles identified by type, ntrk for (int inst = 0; inst < npart; inst++){ // inst from "instance" on the scan tree // cout<< " instance "<< inst <<endl; // cout<< pT[inst]<< endl; //fill el mu vectors if ( typ[inst] == 1 && ntrk[inst] == -1){ el.push_back(inst); elC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 1 && ntrk[inst] == 1){ antiel.push_back(inst); antielC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 2 && ntrk[inst] == -1){ mu.push_back(inst); muC++; lCounter++; totaLlCounter++; } if ( typ[inst] == 2 && ntrk[inst] == 1){ antimu.push_back(inst); antimuC++; lCounter++; totaLlCounter++; } if ( (typ[inst] == 4 && jmas[inst] > 10. )|| (typ[inst] == 6 && pT[inst] > 10. )){ lCounter = 0; //dont count the event } }//end instance loop (particles in an event // cout<< "leptons in the event are "<< lCounter<<endl; // if (lCounter == 4) { fillFlag = false; // If else if loops reconstructing the particles according to the type 4e,4mu, 2e2mu if (el.size() == 1 && mu.size() == 1 && antiel.size() == 1 && antimu.size() == 1){ //2e2m goodEventCounter++; lep1.SetPtEtaPhi( pT[el[0]], eta[el[0]] , phi[el[0]]); //set up of lepton four-vectors lep2.SetPtEtaPhi( pT[antiel[0]], eta[antiel[0]] , phi[antiel[0]]); lep3.SetPtEtaPhi( pT[mu[0]], eta[mu[0]] , phi[mu[0]]); lep4.SetPtEtaPhi( pT[antimu[0]], eta[antimu[0]] , phi[antimu[0]]); Za = lep1 + lep2; Zb = lep3 + lep4; mZ1 = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); // reconstruct z masses mZ2 = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); //select leading Z if(mZ1 > mZ2) { Z1.SetVectM( Za, mZ1); Z2.SetVectM(Zb,mZ2); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());eexx++;} //to set the highest mass the z else { Z2.SetVectM( Za, mZ1); Z1.SetVectM(Zb,mZ2); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());xxee++;} fillFlag = true; } else if (el.size() == 2 && mu.size() == 0 && antiel.size() == 2 && antimu.size() == 0){ //4e goodEventCounter++; lep1.SetPtEtaPhi( pT[el[0]], eta[el[0]] , phi[el[0]]); lep2.SetPtEtaPhi( pT[antiel[0]], eta[antiel[0]] , phi[antiel[0]]); lep3.SetPtEtaPhi( pT[el[1]], eta[el[1]] , phi[el[1]]); lep4.SetPtEtaPhi( pT[antiel[1]], eta[antiel[1]] , phi[antiel[1]]); Za = lep1 + lep2; Zb = lep3 + lep4; Zc = lep1 + lep4; Zd = lep3 + lep2; double mZa = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); double mZb = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); double mZc = sqrt(pow(lep1.Mag()+lep4.Mag(),2)-Zc.Mag2()); double mZd = sqrt(pow(lep2.Mag()+lep3.Mag(),2)-Zd.Mag2()); double s1a; double s1b; double s2a; double s2b; if ( pairing == 0){ s1a = pow(mZa-vZmass,2) + pow(mZb-Zmass,2); s1b = pow(mZa-Zmass,2) + pow(mZb-vZmass,2); s2a = pow(mZc-vZmass,2) + pow(mZd-Zmass,2); s2b = pow(mZc-Zmass,2) + pow(mZd-vZmass,2); } else{ s1a = fabs(mZb-Zmass); s1b = fabs(mZa-Zmass); s2a = fabs(mZd-Zmass); s2b = fabs(mZc-Zmass); } elSum[0] = s1a; elSum[1] = s1b; elSum[2] = s2a; elSum[3] = s2b; int min = TMath::LocMin(4, &elSum[0]); if( (min == 0 || min == 1) ){ if(mZa > mZb) { Z1.SetVectM( Za, mZa); Z2.SetVectM(Zb,mZb); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} //to set the highest mass the z else { Z2.SetVectM( Za, mZa); Z1.SetVectM(Zb,mZb); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} } else if( (min == 2 || min == 3) ){ if(mZc > mZd) { Z1.SetVectM( Zc, mZc); Z2.SetVectM(Zd,mZd); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} //to set the highest mass the z else { Z2.SetVectM( Zc, mZc); Z1.SetVectM(Zd,mZd); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} } eeee++; fillFlag = true; } else if(el.size() == 0 && mu.size() == 2 && antiel.size() == 0 && antimu.size() == 2 ) { //4m goodEventCounter++; lep1.SetPtEtaPhi( pT[mu[0]], eta[mu[0]] , phi[mu[0]]); lep2.SetPtEtaPhi( pT[antimu[0]], eta[antimu[0]] , phi[antimu[0]]); lep3.SetPtEtaPhi( pT[mu[1]], eta[mu[1]] , phi[mu[1]]); lep4.SetPtEtaPhi( pT[antimu[1]], eta[antimu[1]] , phi[antimu[1]]); Za = lep1 + lep2; Zb = lep3 + lep4; Zc = lep1 + lep4; Zd = lep3 + lep2; double mZa = sqrt(pow(lep1.Mag()+lep2.Mag(),2)-Za.Mag2()); double mZb = sqrt(pow(lep3.Mag()+lep4.Mag(),2)-Zb.Mag2()); double mZc = sqrt(pow(lep1.Mag()+lep4.Mag(),2)-Zc.Mag2()); double mZd = sqrt(pow(lep2.Mag()+lep3.Mag(),2)-Zd.Mag2()); double s1a; double s1b; double s2a; double s2b; if ( pairing == 0){ s1a = pow(mZa-vZmass,2) + pow(mZb-Zmass,2); s1b = pow(mZa-Zmass,2) + pow(mZb-vZmass,2); s2a = pow(mZc-vZmass,2) + pow(mZd-Zmass,2); s2b = pow(mZc-Zmass,2) + pow(mZd-vZmass,2); } else{ s1a = fabs(mZb-Zmass); s1b = fabs(mZa-Zmass); s2a = fabs(mZd-Zmass); s2b = fabs(mZc-Zmass); } muSum[0] = s1a; muSum[1] = s1b; muSum[2] = s2a; muSum[3] = s2b; int min = TMath::LocMin(4, &muSum[0]); if( (min == 0 || min == 1) ){ if(mZa > mZb) { Z1.SetVectM( Za, mZa); Z2.SetVectM(Zb,mZb); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} //to set the highest mass the z else { Z2.SetVectM( Za, mZa); Z1.SetVectM(Zb,mZb); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag());} } else if( (min == 2 || min == 3) ){ if(mZc > mZd) { Z1.SetVectM( Zc, mZc); Z2.SetVectM(Zd,mZd); lep_min1.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus1.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min2.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus2.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} //to set the highest mass the z else { Z2.SetVectM( Zc, mZc); Z1.SetVectM(Zd,mZd); lep_min2.SetPtEtaPhiE(lep1.Pt(),lep1.Eta(), lep1.Phi(),lep1.Mag()); lep_plus2.SetPtEtaPhiE(lep4.Pt(),lep4.Eta(), lep4.Phi(),lep4.Mag()); lep_min1.SetPtEtaPhiE(lep3.Pt(),lep3.Eta(), lep3.Phi(),lep3.Mag()); lep_plus1.SetPtEtaPhiE(lep2.Pt(),lep2.Eta(), lep2.Phi(),lep2.Mag());} } xxxx++; fillFlag = true; } if ( fillFlag == true && goodEventCounter < 25001) { //if it fullfills the specs then fill and find angles rec_H = Z1 + Z2; double Hmass = rec_H.M(); tHrec = Hmass; // cout<<tHrec<<endl; double Z1mass = Z1.M(); tZ1m = Z1mass; double Z2mass = Z2.M(); tZ2m = Z2mass; double ptlepp1 = lep_plus1.Pt(); double ptlepm1 = lep_min1.Pt(); double ptlepp2 = lep_plus2.Pt(); double ptlepm2 = lep_min2.Pt(); double dR1 = sqrt(pow(fabs(lep_min1.Eta() - lep_plus1.Eta()),2)+pow(fabs(lep_min1.DeltaPhi(lep_plus1)),2)); double dR2 = sqrt(pow(fabs(lep_min2.Eta() - lep_plus2.Eta()),2)+pow(fabs(lep_min2.DeltaPhi(lep_plus2)),2)); // if ( /*Hmass<120 || Hmass>130 || */Z1mass < 49 || Z1mass>107 || Z2mass < 12 || Z2mass> 115 ){continue;} //constrains //filling the simple histogram values h_Z1_m -> Fill(Z1.M()); h_Z1_E -> Fill(Z1.E()); h_Z1_Pt -> Fill(Z1.Pt()); h_Z1_eta -> Fill(Z1.Eta()); h_Z1_phi -> Fill(Z1.Phi()); h_Z2_m -> Fill(Z2.M()); h_Z2_E -> Fill(Z2.E()); h_Z2_Pt -> Fill(Z2.Pt()); h_Z2_eta -> Fill(Z2.Eta()); h_Z2_phi -> Fill(Z2.Phi()); h_rec_H_m -> Fill(Hmass); h_rec_H_E -> Fill(rec_H.E()); h_rec_H_Pt -> Fill(rec_H.Pt()); h_rec_H_eta -> Fill(rec_H.Eta()); h_rec_H_phi -> Fill(rec_H.Phi()); h_lep_plus1_E -> Fill(lep_plus1.E()); h_lep_plus1_Pt -> Fill(ptlepp1); h_lep_plus1_eta -> Fill(lep_plus1.Eta()); h_lep_plus1_phi -> Fill(lep_plus1.Phi()); h_lep_min1_E -> Fill(lep_min1.E()); h_lep_min1_Pt -> Fill(ptlepm1); h_lep_min1_eta -> Fill(lep_min1.Eta()); h_lep_min1_phi -> Fill(lep_min1.Phi()); h_lep_plus2_E -> Fill(lep_plus2.E()); h_lep_plus2_Pt -> Fill(ptlepp2); h_lep_plus2_eta -> Fill(lep_plus2.Eta()); h_lep_plus2_phi -> Fill(lep_plus2.Phi()); h_lep_min2_E -> Fill(lep_min2.E()); h_lep_min2_Pt -> Fill(ptlepm2); h_lep_min2_eta -> Fill(lep_min2.Eta()); h_lep_min2_phi -> Fill(lep_min2.Phi()); //reconstructing the two lepton pairs Lorentz vectors lpair1 = lep_plus1 + lep_min1; lpair2 = lep_plus2 + lep_min2; //constructing 3-vectors in the lab frame lep_plus1_lab = lep_plus1.Vect(); lep_plus2_lab = lep_plus2.Vect(); //.Vect() gives 3 vector from 4vector lep_min1_lab = lep_min1.Vect(); lep_min2_lab = lep_min2.Vect(); lpair1_lab = lep_plus1_lab.Cross(lep_min1_lab); lpair2_lab = lep_plus2_lab.Cross(lep_min2_lab); // cout << " pt of lepton pair1 on rest frame is: "<< lpair1.Perp()<<endl; //Filling up Histograms with angles defined in the lab frame h_angle_lab_pair1 -> Fill(lep_plus1_lab.Angle(lep_min1_lab)); h_angle_lab_pair2 -> Fill(lep_plus2_lab.Angle(lep_min2_lab)); //Filling up histograms with variables from articles h_angle_lab_deleta1 -> Fill(fabs(lep_min1.Eta() - lep_plus1.Eta())); h_angle_lab_delphi1 -> Fill(fabs(lep_min1.DeltaPhi(lep_plus1))); h_angle_lab_deleta2 -> Fill(fabs(lep_min2.Eta() - lep_plus2.Eta())); h_angle_lab_delphi2 -> Fill(fabs(lep_min2.DeltaPhi(lep_plus2))); //Looking at the Higgs rest frame TVector3 boost_rH = -rec_H.BoostVector(); //NOTE the minus sign! WHY - sign??? TVector3 boost_rZ1 = -Z1.BoostVector(); TVector3 boost_rZ2 = -Z2.BoostVector(); Higgs_rest = rec_H; Z1_rH = Z1; Z2_rH = Z2; lep_p1_rH = lep_plus1; // lep_m1_rH = lep_min1; lep_p2_rH = lep_plus2; lep_m2_rH = lep_min2; lep_p1_rZ1 = lep_plus1; lep_m2_rZ2 = lep_min2; lep_p2_rZ2 = lep_plus2; lep_m1_rZ1 = lep_min1; //Boosting vectors to the Higgs rest frame Higgs_rest.Boost(boost_rH); Z1_rH.Boost(boost_rH); Z2_rH.Boost(boost_rH); lep_p1_rH.Boost(boost_rH); lep_m1_rH.Boost(boost_rH); lep_p2_rH.Boost(boost_rH); lep_m2_rH.Boost(boost_rH); //Boosting leptons to Z rest frames lep_p1_rZ1.Boost(boost_rZ1); lep_m1_rZ1.Boost(boost_rZ1); lep_p2_rZ2.Boost(boost_rZ2); lep_m2_rZ2.Boost(boost_rZ2); //Setting 3Vectors in Higgs rest frame Z3_1_rH = Z1_rH.Vect(); Z3_2_rH = Z2_rH.Vect(); lep3_plus1_rH = lep_p1_rH.Vect(); lep3_min1_rH = lep_m1_rH.Vect(); lep3_plus2_rH = lep_p2_rH.Vect(); lep3_min2_rH = lep_m2_rH.Vect(); TVector3 Z3_1plane_rH = lep3_plus1_rH.Cross(lep3_min1_rH); //wrong? TVector3 Z3_2plane_rH = lep3_plus2_rH.Cross(lep3_min2_rH); //Setting 3Vectors in Z1/Z2 rest frame lep3_plus1_rZ1 = lep_p1_rZ1.Vect(); lep3_plus2_rZ2 = lep_p2_rZ2.Vect(); lep3_min1_rZ1 = lep_m1_rZ1.Vect(); lep3_min2_rZ2 = lep_m2_rZ2.Vect(); //Filling up histogram for the phi angle distribution //pairnoume ta monadiaia dianysmata twn kathetwn pediwn, prwta ypologizoume to metro tous, meta eswteriko ginomeno, meta tokso tou costheta tous double metro1 = sqrt((pow(Z3_1plane_rH.X(),2))+(pow(Z3_1plane_rH.Y(),2))+(pow(Z3_1plane_rH.Z(),2))); double metro2 = sqrt((pow(Z3_2plane_rH.X(),2))+(pow(Z3_2plane_rH.Y(),2))+(pow(Z3_2plane_rH.Z(),2))); TVector3 Z3_1plane_rH_un = Z3_1plane_rH.Unit(); TVector3 Z3_2plane_rH_un = Z3_2plane_rH.Unit(); TVector3 drtPlane = Z3_1plane_rH_un.Cross(Z3_2plane_rH_un); double phi = acos(-Z3_1plane_rH_un.Dot(Z3_2plane_rH_un))*(Z3_1_rH.Dot(skata))/fabs(Z3_1_rH.Dot(skata)); h_angle_rH_phi -> Fill( phi ); tPhi = phi; //****Phi one angle , same procedure as before. Now the plane is the first Z boson vector with beam axis, so they form a plane, phi1 is angle between this plane and the Z1 plane (apo to decay twn 2 leptoniwn) TVector3 niScatter_un = (beamAxis.Cross(Z3_1_rH)).Unit(); TVector3 drtPlane2 = Z3_1plane_rH_un.Cross(niScatter_un); double phiOne = acos(Z3_1plane_rH_un.Dot(niScatter_un))*(Z3_1_rH.Dot(skata2))/fabs(Z3_1_rH.Dot(skata2)); h_angle_rH_phiOne -> Fill( phiOne ); tPhi1 = phiOne; //Filling up histogram for theta* angle: Z1/Z2 with Higgs boost vector h_angle_rH_thetaZ2 -> Fill(Z3_2_rH.CosTheta()); double cosThetaStar = Z3_1_rH.CosTheta(); h_angle_rH_thetaZ1 -> Fill(cosThetaStar); tcosthetaStar = cosThetaStar; // boosting the z to the other z frame TLorentzVector Z_1_rZ2 = Z1; Z_1_rZ2.Boost(boost_rZ2); TVector3 Z3_1_rZ2 = Z_1_rZ2.Vect(); TLorentzVector Z_2_rZ1 = Z2; Z_2_rZ1.Boost(boost_rZ1); TVector3 Z3_2_rZ1 = Z_2_rZ1.Vect(); double cosTheta1 = cos(lep3_min1_rZ1.Angle(-Z3_2_rZ1)); double cosTheta2 = cos(lep3_min2_rZ2.Angle(-Z3_1_rZ2)); h_angle_rZ1_lp1Z1 -> Fill(cos(lep3_plus1_rZ1.Angle(-Z3_2_rZ1))); h_angle_rZ1_lm1Z1 -> Fill(cosTheta1); // theta1 h_angle_rZ2_lp2Z2 -> Fill(cos(lep3_plus2_rZ2.Angle(-Z3_1_rZ2))); h_angle_rZ2_lm2Z2 -> Fill(cosTheta2); // theta2 tcostheta1 = cosTheta1; tcostheta2 = cosTheta2; h_angle_rH_delphi1 -> Fill(fabs(lep_p1_rH.DeltaPhi(lep_m1_rH))); h_angle_rH_delphi2 -> Fill(fabs(lep_p2_rH.DeltaPhi(lep_m2_rH))); h_mZ1mZ2 -> Fill(Z1.M(),Z2.M()); h_mVsPtZ1 -> Fill(Z1.M(),Z1.Pt()); h_delphi1VsPtZ1_lab -> Fill(Z1.Pt(),fabs(lep_min1.DeltaPhi(lep_plus1))); h_delphi2VsPtZ2_lab -> Fill(Z2.Pt(),fabs(lep_min2.DeltaPhi(lep_plus2))); if (eexx ==1){ttype = "eexx";} else if(xxee ==1){ttype = "xxee";} else if(eeee ==1){ttype = "eeee";} else if(xxxx ==1){ttype = "xxxx";} hists->Fill(); histCounter++; hists->Close(); } //end if fill ////////////// fill out the decay type // filling the TTree }//end entries loop (events) //some regular reports cout<<endl; cout<<" good events are "<<goodEventCounter<<endl; cout<<" we see % "<< (double) goodEventCounter/n <<endl; cout<<endl; cout<<" histogram fills are "<<histCounter<<endl; // cout<<" we see % "<< (double) goodEventCounter/n <<endl; }//end loop void
void NewVariables(){ const double protonmass = 938.272013; //MeV const double pionmass = 139.57018; //MeV const double kaonmass = 493.677; //MeV //const double muonmass = 105.6583715; //MeV TStopwatch *clock = new TStopwatch(); clock->Start(1); double p_PT, p_ETA, p_PHI; double K_PT, K_ETA, K_PHI; double pi_PT, pi_ETA, pi_PHI; double Xb_OWNPV_X, Xb_OWNPV_Y, Xb_OWNPV_Z; double Xb_ENDVERTEX_X, Xb_ENDVERTEX_Y, Xb_ENDVERTEX_Z; double Xb_PT, Xb_ETA, Xb_PHI, Xb_M; double Xc_PT, Xc_ETA, Xc_PHI, Xc_M; float Added_H_PT[200], Added_H_ETA[200], Added_H_PHI[200]; int Added_n_Particles; gErrorIgnoreLevel = kError; TFile *fSLBS = new TFile("/auto/data/mstahl/SLBaryonSpectroscopy/SLBaryonSpectroscopyStrp21.root","read"); TTree *Xic_tree = (TTree*)gDirectory->Get("Xib02XicMuNu/Xic2pKpi/DecayTree"); gErrorIgnoreLevel = kPrint; Xic_tree->SetBranchStatus("*",0); //disable all branches //now switch on the ones we need (saves a lot of time) Xic_tree->SetBranchStatus("Xib_M",1); Xic_tree->SetBranchStatus("Xib_PT",1); Xic_tree->SetBranchStatus("Xib_ETA",1); Xic_tree->SetBranchStatus("Xib_PHI",1); Xic_tree->SetBranchStatus("Xib_OWNPV_X",1); Xic_tree->SetBranchStatus("Xib_OWNPV_Y",1); Xic_tree->SetBranchStatus("Xib_OWNPV_Z",1); Xic_tree->SetBranchStatus("Xib_ENDVERTEX_X",1); Xic_tree->SetBranchStatus("Xib_ENDVERTEX_Y",1); Xic_tree->SetBranchStatus("Xib_ENDVERTEX_Z",1); Xic_tree->SetBranchStatus("Xic_M",1); Xic_tree->SetBranchStatus("Xic_PT",1); Xic_tree->SetBranchStatus("Xic_ETA",1); Xic_tree->SetBranchStatus("Xic_PHI",1); Xic_tree->SetBranchStatus("Added_n_Particles",1); Xic_tree->SetBranchStatus("Added_H_PT",1); Xic_tree->SetBranchStatus("Added_H_ETA",1); Xic_tree->SetBranchStatus("Added_H_PHI",1); Xic_tree->SetBranchStatus("p_PT",1); Xic_tree->SetBranchStatus("p_ETA",1); Xic_tree->SetBranchStatus("p_PHI",1); Xic_tree->SetBranchStatus("K_PT",1); Xic_tree->SetBranchStatus("K_ETA",1); Xic_tree->SetBranchStatus("K_PHI",1); Xic_tree->SetBranchStatus("pi_PT",1); Xic_tree->SetBranchStatus("pi_ETA",1); Xic_tree->SetBranchStatus("pi_PHI",1); //set the branch addresses Xic_tree->SetBranchAddress("Xib_M",&Xb_M); Xic_tree->SetBranchAddress("Xib_PT",&Xb_PT); Xic_tree->SetBranchAddress("Xib_ETA",&Xb_ETA); Xic_tree->SetBranchAddress("Xib_PHI",&Xb_PHI); Xic_tree->SetBranchAddress("Xib_OWNPV_X",&Xb_OWNPV_X); Xic_tree->SetBranchAddress("Xib_OWNPV_Y",&Xb_OWNPV_Y); Xic_tree->SetBranchAddress("Xib_OWNPV_Z",&Xb_OWNPV_Z); Xic_tree->SetBranchAddress("Xib_ENDVERTEX_X",&Xb_ENDVERTEX_X); Xic_tree->SetBranchAddress("Xib_ENDVERTEX_Y",&Xb_ENDVERTEX_Y); Xic_tree->SetBranchAddress("Xib_ENDVERTEX_Z",&Xb_ENDVERTEX_Z); Xic_tree->SetBranchAddress("Xic_M",&Xc_M); Xic_tree->SetBranchAddress("Xic_PT",&Xc_PT); Xic_tree->SetBranchAddress("Xic_ETA",&Xc_ETA); Xic_tree->SetBranchAddress("Xic_PHI",&Xc_PHI); Xic_tree->SetBranchAddress("Added_n_Particles",&Added_n_Particles); Xic_tree->SetBranchAddress("Added_H_PT",&Added_H_PT); Xic_tree->SetBranchAddress("Added_H_ETA",&Added_H_ETA); Xic_tree->SetBranchAddress("Added_H_PHI",&Added_H_PHI); Xic_tree->SetBranchAddress("p_PT",&p_PT); Xic_tree->SetBranchAddress("p_ETA",&p_ETA); Xic_tree->SetBranchAddress("p_PHI",&p_PHI); Xic_tree->SetBranchAddress("K_PT",&K_PT); Xic_tree->SetBranchAddress("K_ETA",&K_ETA); Xic_tree->SetBranchAddress("K_PHI",&K_PHI); Xic_tree->SetBranchAddress("pi_PT",&pi_PT); Xic_tree->SetBranchAddress("pi_ETA",&pi_ETA); Xic_tree->SetBranchAddress("pi_PHI",&pi_PHI); //SLBS_tree->AddBranchToCache("*"); //SLBS_tree->LoadBaskets(1000000000);//Load baskets up to 1 GB to memory double Xb_CorrM, p_beta, K_beta, pi_beta; float Xcpi_CosTheta[200],XcK_CosTheta[200],Xcp_CosTheta[200]; double p_as_piKpi_M, p_as_KKpi_M, pK_as_pipi_M, pK_as_ppi_M, pKpi_as_K_M, pKpi_as_p_M; TFile *f1 = new TFile("/auto/data/mstahl/SLBaryonSpectroscopy/SLBaryonSpectroscopyStrp21_friend.root","RECREATE"); //f1->mkdir("Xib02XicMuNu/Xic2pKpi"); //f1->cd("Xib02XicMuNu/Xic2pKpi"); TTree added_Xic_tree("Xic2pKpi","Xic2pKpi"); added_Xic_tree.Branch("Xib_CorrM", &Xb_CorrM, "Xib_CorrM/D"); added_Xic_tree.Branch("p_beta", &p_beta, "p_beta/D"); added_Xic_tree.Branch("K_beta", &K_beta, "K_beta/D"); added_Xic_tree.Branch("pi_beta", &pi_beta, "pi_beta/D"); added_Xic_tree.Branch("Added_n_Particles", &Added_n_Particles, "Added_n_Particles/I"); added_Xic_tree.Branch("Xcpi_CosTheta", &Xcpi_CosTheta, "Xcpi_CosTheta[Added_n_Particles]/F"); added_Xic_tree.Branch("XcK_CosTheta", &XcK_CosTheta, "XcK_CosTheta[Added_n_Particles]/F"); added_Xic_tree.Branch("Xcp_CosTheta", &Xcp_CosTheta, "Xcp_CosTheta[Added_n_Particles]/F"); added_Xic_tree.Branch("p_as_piKpi_M", &p_as_piKpi_M, "p_as_piKpi_M/D"); added_Xic_tree.Branch("p_as_KKpi_M", &p_as_KKpi_M, "p_as_KKpi_M/D"); added_Xic_tree.Branch("pK_as_pipi_M", &pK_as_pipi_M, "pK_as_pipi_M/D"); added_Xic_tree.Branch("pK_as_ppi_M", &pK_as_ppi_M, "pK_as_ppi_M/D"); added_Xic_tree.Branch("pKpi_as_K_M", &pKpi_as_K_M, "pKpi_as_K_M/D"); added_Xic_tree.Branch("pKpi_as_p_M", &pKpi_as_p_M, "pKpi_as_p_M/D"); UInt_t Xic_nevents = Xic_tree->GetEntries(); cout << "Entries in Xic tree: " << Xic_nevents << endl; for (UInt_t evt = 0; evt < Xic_nevents;evt++) { Xic_tree->GetEntry(evt); TVector3 dir(Xb_ENDVERTEX_X-Xb_OWNPV_X,Xb_ENDVERTEX_Y-Xb_OWNPV_Y,Xb_ENDVERTEX_Z-Xb_OWNPV_Z); TVector3 mom; mom.SetPtEtaPhi(Xb_PT,Xb_ETA,Xb_PHI); double dmag2 = dir.Mag2(); double ptprime = 0; if ( 0 == dmag2 ) ptprime = mom.Mag(); else ptprime = (mom - dir * ( mom.Dot( dir ) / dmag2 )).Mag() ; Xb_CorrM = sqrt(Xb_M*Xb_M + ptprime*ptprime) + ptprime; TLorentzVector Xb; Xb.SetPtEtaPhiM(Xb_PT,Xb_ETA,Xb_PHI,Xb_CorrM); TLorentzVector Xc; Xc.SetPtEtaPhiM(Xc_PT,Xc_ETA,Xc_PHI,Xc_M); for(int i = 0; i < Added_n_Particles; i++){ TLorentzVector Hpi; Hpi.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],pionmass); TLorentzVector HK; HK.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],kaonmass); TLorentzVector Hp; Hp.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],protonmass); TLorentzVector Xcpi = Hpi + Xc; TLorentzVector XcK = HK + Xc; TLorentzVector Xcp = Hp + Xc; Xcpi.Boost(-Xb.BoostVector()); Xcpi_CosTheta[i] = cos(Xcpi.Angle(Xb.Vect())); XcK.Boost(-Xb.BoostVector()); XcK_CosTheta[i] = cos(XcK.Angle(Xb.Vect())); Xcp.Boost(-Xb.BoostVector()); Xcp_CosTheta[i] = cos(Xcp.Angle(Xb.Vect())); } TLorentzVector proton; proton.SetPtEtaPhiM(p_PT,p_ETA,p_PHI,protonmass); TLorentzVector kaon; kaon.SetPtEtaPhiM(K_PT,K_ETA,K_PHI,kaonmass); TLorentzVector pion; pion.SetPtEtaPhiM(pi_PT,pi_ETA,pi_PHI,pionmass); p_beta = (-proton.P()+kaon.P()+pion.P())/(proton.P()+kaon.P()+pion.P()); K_beta = ( proton.P()-kaon.P()+pion.P())/(proton.P()+kaon.P()+pion.P()); pi_beta = ( proton.P()+kaon.P()-pion.P())/(proton.P()+kaon.P()+pion.P()); TLorentzVector p_as_pi; p_as_pi.SetVectM(proton.Vect(),pionmass); TLorentzVector p_as_K; p_as_K.SetVectM(proton.Vect(),kaonmass); TLorentzVector K_as_pi; K_as_pi.SetVectM(kaon.Vect(),pionmass); TLorentzVector K_as_p; K_as_p.SetVectM(kaon.Vect(),protonmass); TLorentzVector pi_as_K; pi_as_K.SetVectM(pion.Vect(),kaonmass); TLorentzVector pi_as_p; pi_as_p.SetVectM(pion.Vect(),protonmass); p_as_piKpi_M = (p_as_pi + kaon + pion).M(); p_as_KKpi_M = (p_as_K + kaon + pion).M(); pK_as_pipi_M = (proton + K_as_pi + pion).M(); pK_as_ppi_M = (proton + K_as_p + pion).M(); pKpi_as_K_M = (proton + kaon + pi_as_K).M(); pKpi_as_p_M = (proton + kaon + pi_as_p).M(); added_Xic_tree.Fill(); } Xic_tree->SetDirectory(0); added_Xic_tree.Write(); fSLBS->cd(); TTree *Xic0_tree = (TTree*)gDirectory->Get("Xib2Xic0MuNu/Xic02pKKpi/DecayTree"); double p_P, SSK1_P, SSK2_P, pi_P; double SSK1_PT, SSK2_PT, SSK1_ETA, SSK2_ETA, SSK1_PHI, SSK2_PHI; Xic0_tree->SetBranchStatus("*",0); //disable all branches //now switch on the ones we need (saves a lot of time) Xic0_tree->SetBranchStatus("Xib_M",1); Xic0_tree->SetBranchStatus("Xib_PT",1); Xic0_tree->SetBranchStatus("Xib_ETA",1); Xic0_tree->SetBranchStatus("Xib_PHI",1); Xic0_tree->SetBranchStatus("Xib_OWNPV_X",1); Xic0_tree->SetBranchStatus("Xib_OWNPV_Y",1); Xic0_tree->SetBranchStatus("Xib_OWNPV_Z",1); Xic0_tree->SetBranchStatus("Xib_ENDVERTEX_X",1); Xic0_tree->SetBranchStatus("Xib_ENDVERTEX_Y",1); Xic0_tree->SetBranchStatus("Xib_ENDVERTEX_Z",1); Xic0_tree->SetBranchStatus("Xic_M",1); Xic0_tree->SetBranchStatus("Xic_PT",1); Xic0_tree->SetBranchStatus("Xic_ETA",1); Xic0_tree->SetBranchStatus("Xic_PHI",1); Xic0_tree->SetBranchStatus("Added_n_Particles",1); Xic0_tree->SetBranchStatus("Added_H_PT",1); Xic0_tree->SetBranchStatus("Added_H_ETA",1); Xic0_tree->SetBranchStatus("Added_H_PHI",1); Xic0_tree->SetBranchStatus("p_P",1); Xic0_tree->SetBranchStatus("SSK1_P",1); Xic0_tree->SetBranchStatus("SSK2_P",1); Xic0_tree->SetBranchStatus("pi_P",1); Xic0_tree->SetBranchStatus("p_PT",1); Xic0_tree->SetBranchStatus("p_ETA",1); Xic0_tree->SetBranchStatus("p_PHI",1); Xic0_tree->SetBranchStatus("SSK1_PT",1); Xic0_tree->SetBranchStatus("SSK1_ETA",1); Xic0_tree->SetBranchStatus("SSK1_PHI",1); Xic0_tree->SetBranchStatus("SSK2_PT",1); Xic0_tree->SetBranchStatus("SSK2_ETA",1); Xic0_tree->SetBranchStatus("SSK2_PHI",1); Xic0_tree->SetBranchStatus("pi_PT",1); Xic0_tree->SetBranchStatus("pi_ETA",1); Xic0_tree->SetBranchStatus("pi_PHI",1); //set the branch addresses Xic0_tree->SetBranchAddress("Xib_M",&Xb_M); Xic0_tree->SetBranchAddress("Xib_PT",&Xb_PT); Xic0_tree->SetBranchAddress("Xib_ETA",&Xb_ETA); Xic0_tree->SetBranchAddress("Xib_PHI",&Xb_PHI); Xic0_tree->SetBranchAddress("Xib_OWNPV_X",&Xb_OWNPV_X); Xic0_tree->SetBranchAddress("Xib_OWNPV_Y",&Xb_OWNPV_Y); Xic0_tree->SetBranchAddress("Xib_OWNPV_Z",&Xb_OWNPV_Z); Xic0_tree->SetBranchAddress("Xib_ENDVERTEX_X",&Xb_ENDVERTEX_X); Xic0_tree->SetBranchAddress("Xib_ENDVERTEX_Y",&Xb_ENDVERTEX_Y); Xic0_tree->SetBranchAddress("Xib_ENDVERTEX_Z",&Xb_ENDVERTEX_Z); Xic0_tree->SetBranchAddress("Xic_M",&Xc_M); Xic0_tree->SetBranchAddress("Xic_PT",&Xc_PT); Xic0_tree->SetBranchAddress("Xic_ETA",&Xc_ETA); Xic0_tree->SetBranchAddress("Xic_PHI",&Xc_PHI); Xic0_tree->SetBranchAddress("Added_n_Particles",&Added_n_Particles); Xic0_tree->SetBranchAddress("Added_H_PT",&Added_H_PT); Xic0_tree->SetBranchAddress("Added_H_ETA",&Added_H_ETA); Xic0_tree->SetBranchAddress("Added_H_PHI",&Added_H_PHI); Xic0_tree->SetBranchAddress("p_P",&p_P); Xic0_tree->SetBranchAddress("SSK1_P",&SSK1_P); Xic0_tree->SetBranchAddress("SSK2_P",&SSK2_P); Xic0_tree->SetBranchAddress("pi_P",&pi_P); Xic0_tree->SetBranchAddress("p_PT",&p_PT); Xic0_tree->SetBranchAddress("SSK1_PT",&SSK1_PT); Xic0_tree->SetBranchAddress("SSK2_PT",&SSK2_PT); Xic0_tree->SetBranchAddress("pi_PT",&pi_PT); Xic0_tree->SetBranchAddress("p_ETA",&p_ETA); Xic0_tree->SetBranchAddress("SSK1_ETA",&SSK1_ETA); Xic0_tree->SetBranchAddress("SSK2_ETA",&SSK2_ETA); Xic0_tree->SetBranchAddress("pi_ETA",&pi_ETA); Xic0_tree->SetBranchAddress("p_PHI",&p_PHI); Xic0_tree->SetBranchAddress("SSK1_PHI",&SSK1_PHI); Xic0_tree->SetBranchAddress("SSK2_PHI",&SSK2_PHI); Xic0_tree->SetBranchAddress("pi_PHI",&pi_PHI); double SSK1_beta, SSK2_beta; f1->cd(); //f1->mkdir("Xib2Xic0MuNu/Xic02pKKpi"); //f1->cd("Xib2Xic0MuNu/Xic02pKKpi"); TTree added_Xic0_tree("Xic02pKKpi","Xic02pKKpi"); added_Xic0_tree.Branch("Xib_CorrM", &Xb_CorrM, "Xib_CorrM/D"); added_Xic0_tree.Branch("p_beta", &p_beta, "p_beta/D"); added_Xic0_tree.Branch("SSK1_beta", &SSK1_beta, "SSK1_beta/D"); added_Xic0_tree.Branch("SSK2_beta", &SSK2_beta, "SSK2_beta/D"); added_Xic0_tree.Branch("pi_beta", &pi_beta, "pi_beta/D"); added_Xic0_tree.Branch("Added_n_Particles", &Added_n_Particles, "Added_n_Particles/I"); added_Xic0_tree.Branch("Xcpi_CosTheta", &Xcpi_CosTheta, "Xcpi_CosTheta[Added_n_Particles]/F"); added_Xic0_tree.Branch("XcK_CosTheta", &XcK_CosTheta, "XcK_CosTheta[Added_n_Particles]/F"); added_Xic0_tree.Branch("Xcp_CosTheta", &Xcp_CosTheta, "Xcp_CosTheta[Added_n_Particles]/F"); added_Xic0_tree.Branch("p_as_piKKpi_M", &p_as_piKpi_M, "p_as_piKKpi_M/D"); added_Xic0_tree.Branch("p_as_KKKpi_M", &p_as_KKpi_M, "p_as_KKKpi_M/D"); UInt_t Xic0_nevents = Xic0_tree->GetEntries(); cout << "Entries in Xic0 tree: " << Xic0_nevents << endl; for (UInt_t evt = 0; evt < Xic0_nevents;evt++) { Xic0_tree->GetEntry(evt); TVector3 dir(Xb_ENDVERTEX_X-Xb_OWNPV_X,Xb_ENDVERTEX_Y-Xb_OWNPV_Y,Xb_ENDVERTEX_Z-Xb_OWNPV_Z); TVector3 mom; mom.SetPtEtaPhi(Xb_PT,Xb_ETA,Xb_PHI); double dmag2 = dir.Mag2(); double ptprime = 0; if ( 0 == dmag2 ) ptprime = mom.Mag(); else ptprime = (mom - dir * ( mom.Dot( dir ) / dmag2 )).Mag() ; Xb_CorrM = sqrt(Xb_M*Xb_M + ptprime*ptprime) + ptprime; TLorentzVector Xb; Xb.SetPtEtaPhiM(Xb_PT,Xb_ETA,Xb_PHI,Xb_CorrM); TLorentzVector Xc; Xc.SetPtEtaPhiM(Xc_PT,Xc_ETA,Xc_PHI,Xc_M); for(int i = 0; i < Added_n_Particles; i++){ TLorentzVector Hpi; Hpi.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],pionmass); TLorentzVector HK; HK.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],kaonmass); TLorentzVector Hp; Hp.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],protonmass); TLorentzVector Xcpi = Hpi + Xc; TLorentzVector XcK = HK + Xc; TLorentzVector Xcp = Hp + Xc; Xcpi.Boost(-Xb.BoostVector()); Xcpi_CosTheta[i] = cos(Xcpi.Angle(Xb.Vect())); XcK.Boost(-Xb.BoostVector()); XcK_CosTheta[i] = cos(XcK.Angle(Xb.Vect())); Xcp.Boost(-Xb.BoostVector()); Xcp_CosTheta[i] = cos(Xcp.Angle(Xb.Vect())); } p_beta = (-p_P+SSK1_P+SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); SSK1_beta = ( p_P-SSK1_P+SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); SSK2_beta = ( p_P+SSK1_P-SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); pi_beta = ( p_P+SSK1_P+SSK2_P-pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); TLorentzVector proton; proton.SetPtEtaPhiM(p_PT,p_ETA,p_PHI,protonmass); TLorentzVector kaon1; kaon1.SetPtEtaPhiM(SSK1_PT,SSK1_ETA,SSK1_PHI,kaonmass); TLorentzVector kaon2; kaon2.SetPtEtaPhiM(SSK2_PT,SSK2_ETA,SSK2_PHI,kaonmass); TLorentzVector pion; pion.SetPtEtaPhiM(pi_PT,pi_ETA,pi_PHI,pionmass); TLorentzVector p_as_pi; p_as_pi.SetVectM(proton.Vect(),pionmass); TLorentzVector p_as_K; p_as_K.SetVectM(proton.Vect(),kaonmass); p_as_piKpi_M = (p_as_pi + kaon1 + kaon2 + pion).M(); p_as_KKpi_M = (p_as_K + kaon1 + kaon2 + pion).M(); added_Xic0_tree.Fill(); } added_Xic0_tree.Write(); fSLBS->cd(); TTree *Omegac_tree = (TTree*)gDirectory->Get("Omegab2Omegac0MuNu/Omegac2pKKpi/DecayTree"); Omegac_tree->SetBranchStatus("*",0); //disable all branches //now switch on the ones we need (saves a lot of time) Omegac_tree->SetBranchStatus("Omegab_M",1); Omegac_tree->SetBranchStatus("Omegab_PT",1); Omegac_tree->SetBranchStatus("Omegab_ETA",1); Omegac_tree->SetBranchStatus("Omegab_PHI",1); Omegac_tree->SetBranchStatus("Omegab_OWNPV_X",1); Omegac_tree->SetBranchStatus("Omegab_OWNPV_Y",1); Omegac_tree->SetBranchStatus("Omegab_OWNPV_Z",1); Omegac_tree->SetBranchStatus("Omegab_ENDVERTEX_X",1); Omegac_tree->SetBranchStatus("Omegab_ENDVERTEX_Y",1); Omegac_tree->SetBranchStatus("Omegab_ENDVERTEX_Z",1); Omegac_tree->SetBranchStatus("Omegac_M",1); Omegac_tree->SetBranchStatus("Omegac_PT",1); Omegac_tree->SetBranchStatus("Omegac_ETA",1); Omegac_tree->SetBranchStatus("Omegac_PHI",1); Omegac_tree->SetBranchStatus("Added_n_Particles",1); Omegac_tree->SetBranchStatus("Added_H_PT",1); Omegac_tree->SetBranchStatus("Added_H_ETA",1); Omegac_tree->SetBranchStatus("Added_H_PHI",1); Omegac_tree->SetBranchStatus("p_P",1); Omegac_tree->SetBranchStatus("SSK1_P",1); Omegac_tree->SetBranchStatus("SSK2_P",1); Omegac_tree->SetBranchStatus("pi_P",1); //set the branch addresses Omegac_tree->SetBranchAddress("Omegab_M",&Xb_M); Omegac_tree->SetBranchAddress("Omegab_PT",&Xb_PT); Omegac_tree->SetBranchAddress("Omegab_ETA",&Xb_ETA); Omegac_tree->SetBranchAddress("Omegab_PHI",&Xb_PHI); Omegac_tree->SetBranchAddress("Omegab_OWNPV_X",&Xb_OWNPV_X); Omegac_tree->SetBranchAddress("Omegab_OWNPV_Y",&Xb_OWNPV_Y); Omegac_tree->SetBranchAddress("Omegab_OWNPV_Z",&Xb_OWNPV_Z); Omegac_tree->SetBranchAddress("Omegab_ENDVERTEX_X",&Xb_ENDVERTEX_X); Omegac_tree->SetBranchAddress("Omegab_ENDVERTEX_Y",&Xb_ENDVERTEX_Y); Omegac_tree->SetBranchAddress("Omegab_ENDVERTEX_Z",&Xb_ENDVERTEX_Z); Omegac_tree->SetBranchAddress("Omegac_M",&Xc_M); Omegac_tree->SetBranchAddress("Omegac_PT",&Xc_PT); Omegac_tree->SetBranchAddress("Omegac_ETA",&Xc_ETA); Omegac_tree->SetBranchAddress("Omegac_PHI",&Xc_PHI); Omegac_tree->SetBranchAddress("Added_n_Particles",&Added_n_Particles); Omegac_tree->SetBranchAddress("Added_H_PT",&Added_H_PT); Omegac_tree->SetBranchAddress("Added_H_ETA",&Added_H_ETA); Omegac_tree->SetBranchAddress("Added_H_PHI",&Added_H_PHI); Omegac_tree->SetBranchAddress("p_P",&p_P); Omegac_tree->SetBranchAddress("SSK1_P",&SSK1_P); Omegac_tree->SetBranchAddress("SSK2_P",&SSK2_P); Omegac_tree->SetBranchAddress("pi_P",&pi_P); f1->cd(); //f1->mkdir("Omegab2Omegac0MuNu/Omegac2pKKpi"); //f1->cd("Omegab2Omegac0MuNu/Omegac2pKKpi"); TTree added_Omegac_tree("Omegac2pKKpi","Omegac2pKKpi"); added_Omegac_tree.Branch("Omegab_CorrM", &Xb_CorrM, "Omegab_CorrM/D"); added_Omegac_tree.Branch("p_beta", &p_beta, "p_beta/D"); added_Omegac_tree.Branch("SSK1_beta", &SSK1_beta, "SSK1_beta/D"); added_Omegac_tree.Branch("SSK2_beta", &SSK2_beta, "SSK2_beta/D"); added_Omegac_tree.Branch("pi_beta", &pi_beta, "pi_beta/D"); added_Omegac_tree.Branch("Added_n_Particles", &Added_n_Particles, "Added_n_Particles/I"); added_Omegac_tree.Branch("Xcpi_CosTheta", &Xcpi_CosTheta, "Xcpi_CosTheta[Added_n_Particles]/F"); added_Omegac_tree.Branch("XcK_CosTheta", &XcK_CosTheta, "XcK_CosTheta[Added_n_Particles]/F"); added_Omegac_tree.Branch("Xcp_CosTheta", &Xcp_CosTheta, "Xcp_CosTheta[Added_n_Particles]/F"); UInt_t Omegac_nevents = Omegac_tree->GetEntries(); cout << "Entries in Omegac tree: " << Omegac_nevents << endl; for (UInt_t evt = 0; evt < Omegac_nevents;evt++) { Omegac_tree->GetEntry(evt); TVector3 dir(Xb_ENDVERTEX_X-Xb_OWNPV_X,Xb_ENDVERTEX_Y-Xb_OWNPV_Y,Xb_ENDVERTEX_Z-Xb_OWNPV_Z); TVector3 mom; mom.SetPtEtaPhi(Xb_PT,Xb_ETA,Xb_PHI); double dmag2 = dir.Mag2(); double ptprime = 0; if ( 0 == dmag2 ) ptprime = mom.Mag(); else ptprime = (mom - dir * ( mom.Dot( dir ) / dmag2 )).Mag() ; Xb_CorrM = sqrt(Xb_M*Xb_M + ptprime*ptprime) + ptprime; TLorentzVector Xb; Xb.SetPtEtaPhiM(Xb_PT,Xb_ETA,Xb_PHI,Xb_CorrM); TLorentzVector Xc; Xc.SetPtEtaPhiM(Xc_PT,Xc_ETA,Xc_PHI,Xc_M); for(int i = 0; i < Added_n_Particles; i++){ TLorentzVector Hpi; Hpi.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],pionmass); TLorentzVector HK; HK.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],kaonmass); TLorentzVector Hp; Hp.SetPtEtaPhiM(Added_H_PT[i],Added_H_ETA[i],Added_H_PHI[i],protonmass); TLorentzVector Xcpi = Hpi + Xc; TLorentzVector XcK = HK + Xc; TLorentzVector Xcp = Hp + Xc; Xcpi.Boost(-Xb.BoostVector()); Xcpi_CosTheta[i] = cos(Xcpi.Angle(Xb.Vect())); XcK.Boost(-Xb.BoostVector()); XcK_CosTheta[i] = cos(XcK.Angle(Xb.Vect())); Xcp.Boost(-Xb.BoostVector()); Xcp_CosTheta[i] = cos(Xcp.Angle(Xb.Vect())); } p_beta = (-p_P+SSK1_P+SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); SSK1_beta = ( p_P-SSK1_P+SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); SSK2_beta = ( p_P+SSK1_P-SSK2_P+pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); pi_beta = ( p_P+SSK1_P+SSK2_P-pi_P)/(p_P+SSK1_P+SSK2_P+pi_P); added_Omegac_tree.Fill(); } added_Omegac_tree.Write(); clock->Stop();clock->Print();delete clock; return; }
Int_t dieleAna(TString inputlist, TString outfile, Int_t nev=-1, Int_t whichweight = 0) { TH1::SetDefaultSumw2(); TH3F *p3DEffEle[6][NWEIGHTS+1]; // mult bins, MLP weights + HC TH3F *p3DEffPos[6][NWEIGHTS+1]; TH3F *p3DAccEle[6][NWEIGHTS+1]; TH3F *p3DAccPos[6][NWEIGHTS+1]; readAccEffMatrices(p3DAccEle, p3DAccPos, p3DEffEle, p3DEffPos); TH2F *smear_ele, *smear_pos; TFile *file_smear = new TFile("smearing_matrix.root","read"); smear_ele = (TH2F*)file_smear->Get("smear_ele"); smear_pos = (TH2F*)file_smear->Get("smear_pos"); TRandom random; /* TFile *pEffFile; pEffFile = new TFile("Input/EffMatrixMVA2RefAccNewCP_100Mio.root"); if (pEffFile) { pEffFile->cd(); for(Int_t i = 0 ; i < 5 ; i++){ p3DEffEle[i][6] = (TH3F*) pEffFile->Get(Form("hHistEff3DMult%iNeg",i)); p3DEffPos[i][6] = (TH3F*) pEffFile->Get(Form("hHistEff3DMult%iPos",i)); // p3DEffEle[i] = (TH3F*) pEffFile->Get("hHistEff3DNeg"); // p3DEffPos[i] = (TH3F*) pEffFile->Get("hHistEff3DPos"); } } else { Error("DrawFromNtuple constructor","pointer to eff matrix file is NULL"); for(Int_t i = 0 ; i < 5 ; i++){ p3DEffEle[i][6] = NULL; p3DEffPos[i][6] = NULL; } } */ TH1F *pEventClass; TH1F *pEventClass_recur; TFile *pEventClassFile; // pEventClassFile = new TFile("eventClass_mult_nonempty_4secmult_200fpj_wait.root"); // pEventClassFile = new TFile("eventClass_target_mult_rplane_nonempty_4secmult.root"); pEventClassFile = new TFile("eventClass_target_mult_rplane_minmom_nmix_w6.root"); if (pEventClassFile) { pEventClass = (TH1F*)pEventClassFile->Get("eventClass"); pEventClass_recur = (TH1F*)pEventClassFile->Get("eventClass_recur"); if (pEventClass == NULL || pEventClass_recur == NULL) { Error("DrawFromNtuple constructor","Histogram not found in the event class file"); exit (-1); } } else { Error("DrawFromNtuple constructor","Event class file not found"); exit (-1); } HLoop* loop = new HLoop(kTRUE); // kTRUE : create Hades (needed to work with standard eventstructure) TString readCategories = ""; if (inputlist.EndsWith(".list")) { loop->addFilesList(inputlist); } else { loop->addMultFiles(inputlist); } if(!loop->setInput(readCategories)) { exit(1); } loop->printCategories(); loop->readSectorFileList("FileListLepton.list"); int sectors[6]; HGeantKine *kine1; HGeantKine *kine2; HCategory* kineCat = (HCategory*)HCategoryManager::getCategory(catGeantKine); HHistMap hM(outfile.Data()); hM.setSilentFail(kTRUE); //------------------------------------------------------------------ //--------------- begin histo booking ----------------------------------------------------- //------------------------------------------------------------------------------------------ const Int_t nbins = 26; Double_t xAxis1[nbins+1] = {0, 0.010, 0.020, 0.030, 0.040, 0.050, 0.060, 0.070, 0.080, 0.090, 0.110, 0.130, 0.150, 0.170, 0.200, 0.250, 0.300, 0.350, 0.400, 0.450, 0.500, 0.550, 0.600, 0.700, 0.800, 0.900, 1.}; hM.addHist(new TH1F(TString("hmassNP"),TString("hmassNP"),nbins,xAxis1)); hM.addHist(new TH1F(TString("hmassPP"),TString("hmassPP"),nbins,xAxis1)); hM.addHist(new TH1F(TString("hmassNN"),TString("hmassNN"),nbins,xAxis1)); hM.addHist(new TH1F(TString("hoAngleNP"),TString("hoAngleNP"),2000,0,200)); hM.addHist(new TH1F(TString("hoAnglePP"),TString("hoAnglePP"),2000,0,200)); hM.addHist(new TH1F(TString("hoAngleNN"),TString("hoAngleNN"),2000,0,200)); hM.addHist(new TH1F(TString("hyNP"),TString("hyNP"),100,0,2)); hM.addHist(new TH1F(TString("hyPP"),TString("hyPP"),100,0,2)); hM.addHist(new TH1F(TString("hyNN"),TString("hyNN"),100,0,2)); hM.addHist(new TH1F(TString("hptNP"),TString("hptNP"),100,0,1000)); hM.addHist(new TH1F(TString("hptPP"),TString("hptPP"),100,0,1000)); hM.addHist(new TH1F(TString("hptNN"),TString("hptNN"),100,0,1000)); hM.addHist(new TH2F(TString("hoAnglemassNP"),TString("hoAnglemassNP"),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAnglemassPP"),TString("hoAnglemassPP"),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAnglemassNN"),TString("hoAnglemassNN"),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAngleptNP"),TString("hoAngleptNP"),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleptPP"),TString("hoAngleptPP"),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleptNN"),TString("hoAngleptNN"),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hmassptNP"),TString("hmassptNP"),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hmassptPP"),TString("hmassptPP"),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hmassptNN"),TString("hmassptNN"),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleyNP"),TString("hoAngleyNP"),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hoAngleyPP"),TString("hoAngleyPP"),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hoAngleyNN"),TString("hoAngleyNN"),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hmassyNP"),TString("hmassyNP"),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hmassyPP"),TString("hmassyPP"),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hmassyNN"),TString("hmassyNN"),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hptyNP"),TString("hptyNP"),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hptyPP"),TString("hptyPP"),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hptyNN"),TString("hptyNN"),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hth1th2NP"),TString("hth1th2NP"),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hth1th2PP"),TString("hth1th2PP"),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hth1th2NN"),TString("hth1th2NN"),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hp1p2NP"),TString("hp1p2NP"),100,0,1100,100,0,1100)); hM.addHist(new TH2F(TString("hp1p2PP"),TString("hp1p2PP"),100,0,1100,100,0,1100)); hM.addHist(new TH2F(TString("hp1p2NN"),TString("hp1p2NN"),100,0,1100,100,0,1100)); for (int i = 0; i < 5; ++i) { hM.addHist(new TH1F(TString("hmassNP_eff_multbin")+TString::Itoa(i,10),TString("hmassNP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1)); hM.addHist(new TH1F(TString("hmassPP_eff_multbin")+TString::Itoa(i,10),TString("hmassPP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1)); hM.addHist(new TH1F(TString("hmassNN_eff_multbin")+TString::Itoa(i,10),TString("hmassNN_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1)); hM.addHist(new TH1F(TString("hoAngleNP_eff_multbin")+TString::Itoa(i,10),TString("hoAngleNP_eff_multbin")+TString::Itoa(i,10),2000,0,200)); hM.addHist(new TH1F(TString("hoAnglePP_eff_multbin")+TString::Itoa(i,10),TString("hoAnglePP_eff_multbin")+TString::Itoa(i,10),2000,0,200)); hM.addHist(new TH1F(TString("hoAngleNN_eff_multbin")+TString::Itoa(i,10),TString("hoAngleNN_eff_multbin")+TString::Itoa(i,10),2000,0,200)); hM.addHist(new TH1F(TString("hyNP_eff_multbin")+TString::Itoa(i,10),TString("hyNP_eff_multbin")+TString::Itoa(i,10),100,0,2)); hM.addHist(new TH1F(TString("hyPP_eff_multbin")+TString::Itoa(i,10),TString("hyPP_eff_multbin")+TString::Itoa(i,10),100,0,2)); hM.addHist(new TH1F(TString("hyNN_eff_multbin")+TString::Itoa(i,10),TString("hyNN_eff_multbin")+TString::Itoa(i,10),100,0,2)); hM.addHist(new TH1F(TString("hptNP_eff_multbin")+TString::Itoa(i,10),TString("hptNP_eff_multbin")+TString::Itoa(i,10),100,0,1000)); hM.addHist(new TH1F(TString("hptPP_eff_multbin")+TString::Itoa(i,10),TString("hptPP_eff_multbin")+TString::Itoa(i,10),100,0,1000)); hM.addHist(new TH1F(TString("hptNN_eff_multbin")+TString::Itoa(i,10),TString("hptNN_eff_multbin")+TString::Itoa(i,10),100,0,1000)); hM.addHist(new TH2F(TString("hoAnglemassNP_eff_multbin")+TString::Itoa(i,10),TString("hoAnglemassNP_eff_multbin")+TString::Itoa(i,10),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAnglemassPP_eff_multbin")+TString::Itoa(i,10),TString("hoAnglemassPP_eff_multbin")+TString::Itoa(i,10),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAnglemassNN_eff_multbin")+TString::Itoa(i,10),TString("hoAnglemassNN_eff_multbin")+TString::Itoa(i,10),90,0,180,nbins,xAxis1)); hM.addHist(new TH2F(TString("hoAngleptNP_eff_multbin")+TString::Itoa(i,10),TString("hoAngleptNP_eff_multbin")+TString::Itoa(i,10),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleptPP_eff_multbin")+TString::Itoa(i,10),TString("hoAngleptPP_eff_multbin")+TString::Itoa(i,10),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleptNN_eff_multbin")+TString::Itoa(i,10),TString("hoAngleptNN_eff_multbin")+TString::Itoa(i,10),90,0,180,120,0,1200)); hM.addHist(new TH2F(TString("hmassptNP_eff_multbin")+TString::Itoa(i,10),TString("hmassptNP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hmassptPP_eff_multbin")+TString::Itoa(i,10),TString("hmassptPP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hmassptNN_eff_multbin")+TString::Itoa(i,10),TString("hmassptNN_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,120,0,1200)); hM.addHist(new TH2F(TString("hoAngleyNP_eff_multbin")+TString::Itoa(i,10),TString("hoAngleyNP_eff_multbin")+TString::Itoa(i,10),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hoAngleyPP_eff_multbin")+TString::Itoa(i,10),TString("hoAngleyPP_eff_multbin")+TString::Itoa(i,10),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hoAngleyNN_eff_multbin")+TString::Itoa(i,10),TString("hoAngleyNN_eff_multbin")+TString::Itoa(i,10),90,0,180,100,0,2)); hM.addHist(new TH2F(TString("hmassyNP_eff_multbin")+TString::Itoa(i,10),TString("hmassyNP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hmassyPP_eff_multbin")+TString::Itoa(i,10),TString("hmassyPP_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hmassyNN_eff_multbin")+TString::Itoa(i,10),TString("hmassyNN_eff_multbin")+TString::Itoa(i,10),nbins,xAxis1,100,0,2)); hM.addHist(new TH2F(TString("hptyNP_eff_multbin")+TString::Itoa(i,10),TString("hptyNP_eff_multbin")+TString::Itoa(i,10),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hptyPP_eff_multbin")+TString::Itoa(i,10),TString("hptyPP_eff_multbin")+TString::Itoa(i,10),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hptyNN_eff_multbin")+TString::Itoa(i,10),TString("hptyNN_eff_multbin")+TString::Itoa(i,10),120,0,1200,100,0,2)); hM.addHist(new TH2F(TString("hth1th2NP_eff_multbin")+TString::Itoa(i,10),TString("hth1th2NP_eff_multbin")+TString::Itoa(i,10),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hth1th2PP_eff_multbin")+TString::Itoa(i,10),TString("hth1th2PP_eff_multbin")+TString::Itoa(i,10),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hth1th2NN_eff_multbin")+TString::Itoa(i,10),TString("hth1th2NN_eff_multbin")+TString::Itoa(i,10),90,0,90,90,0,90)); hM.addHist(new TH2F(TString("hp1p2NP_eff_multbin")+TString::Itoa(i,10),TString("hp1p2NP_eff_multbin")+TString::Itoa(i,10),100,0,1100,100,0,1100)); hM.addHist(new TH2F(TString("hp1p2PP_eff_multbin")+TString::Itoa(i,10),TString("hp1p2PP_eff_multbin")+TString::Itoa(i,10),100,0,1100,100,0,1100)); hM.addHist(new TH2F(TString("hp1p2NN_eff_multbin")+TString::Itoa(i,10),TString("hp1p2NN_eff_multbin")+TString::Itoa(i,10),100,0,1100,100,0,1100)); } //--------------- end histo booking ----------------------------------------------------- HGenericEventMixer<HGeantKine> eventmixer; eventmixer.setPIDs(2,3,1); eventmixer.setBuffSize(80); //eventmixer.setBuffSize(2); HGenericEventMixer<HGeantKine> eventmixer_eff[5]; for (int mb = 0; mb < 5; ++mb) { eventmixer_eff[mb].setPIDs(2,3,1); eventmixer_eff[mb].setBuffSize(80); //eventmixer_eff[mb].setBuffSize(2); } TStopwatch timer; timer.Reset(); timer.Start(); Float_t impB = -1.; Float_t impB_bins[] = {9.3, 8.1, 6.6, 4.7, 0.}; Int_t evtsInFile = loop->getEntries(); if(nev < 0 || nev > evtsInFile ) nev = evtsInFile; for(Int_t i = 1; i < nev; i++) { //----------break if last event is reached------------- //if(!gHades->eventLoop(1)) break; if(loop->nextEvent(i) <= 0) { cout<<" end recieved "<<endl; break; } // last event reached HTool::printProgress(i,nev,1,"Analyze :"); loop->getSectors(sectors); HPartialEvent *fSimul = ((HRecEvent*)gHades->getCurrentEvent())->getPartialEvent(catSimul); HGeantHeader *fSubHeader = (HGeantHeader*)(fSimul->getSubHeader()); impB = fSubHeader->getImpactParameter(); Int_t multbin = 0; if (impB >= impB_bins[4] && impB <= impB_bins[3]) {multbin=1;} // most central if (impB > impB_bins[3] && impB <= impB_bins[2]) {multbin=2;} if (impB > impB_bins[2] && impB <= impB_bins[1]) {multbin=3;} if (impB > impB_bins[1] && impB <= impB_bins[0]) {multbin=4;} // most peripheral if (impB > impB_bins[0]) {multbin=5;} /* HParticleEvtInfo* evtinfo; evtinfo = HCategoryManager::getObject(evtinfo,catParticleEvtInfo,0); Int_t multbin = 0; Int_t mult_meta = evtinfo->getSumTofMultCut() + evtinfo->getSumRpcMultHitCut(); if (mult_meta > 60 && mult_meta <= 88) multbin = 4; // most peripheral if (mult_meta > 88 && mult_meta <= 121) multbin = 3; if (mult_meta > 121 && mult_meta <= 160) multbin = 2; if (mult_meta > 160 && mult_meta <= 250) multbin = 1; // most central if (mult_meta > 250) multbin = 5; */ if (multbin == 0 || multbin == 5) continue; Int_t size = kineCat->getEntries(); // Additional loop to fill vector vector<HGeantKine *> vep; vector<HGeantKine *> vem; vector<HGeantKine *> vep_eff; vector<HGeantKine *> vem_eff; vector<HGeantKine *> vep_eff_multbin; vector<HGeantKine *> vem_eff_multbin; for(Int_t j = 0; j < size; j ++){ kine1 = HCategoryManager::getObject(kine1,kineCat,j); Float_t vx,vy,vz; kine1->getVertex(vx,vy,vz); Float_t vr = TMath::Sqrt(vx*vx+vy*vy); if (vz < -60 || vz > 0) continue; if (vr > 2) continue; Int_t mamaNum = kine1->getParentTrack(); if (kine1->isInAcceptance()) { if (kine1->getTotalMomentum() > 100 && kine1->getTotalMomentum() < 1000) { Float_t px,py,pz; kine1->getMomentum(px,py,pz); TH2F *smear_matr; if (kine1->getID() == 2) { smear_matr = smear_pos; } else { smear_matr = smear_ele; } Float_t mom_ideal = kine1->getTotalMomentum(); Float_t mom_reco = smear(mom_ideal,smear_matr,random); Float_t reco_over_ideal = mom_reco / mom_ideal; kine1->setMomentum(px*reco_over_ideal,py*reco_over_ideal,pz*reco_over_ideal); TLorentzVector vec; HParticleTool::getTLorentzVector(kine1,vec,kine1->getID()); Float_t mom = vec.Vect().Mag(); Float_t the = vec.Theta()*TMath::RadToDeg(); Float_t phi = (vec.Phi()+TMath::Pi())*TMath::RadToDeg(); Float_t chg = (kine1->getID() == 2) ? 1 : -1; if (kine1->getID() == 3) { vem.push_back(new HGeantKine(*kine1)); } if (kine1->getID() == 2) { vep.push_back(new HGeantKine(*kine1)); } Float_t eff = 1./getEfficiencyFactor(p3DEffEle[0][6],p3DEffPos[0][6],mom_ideal,the,phi,chg,false,false); // don't debug, don't check min value if (isinf(eff) || isnan(eff)) eff = 0.; if (random.Uniform(1) > eff) { if (kine1->getID() == 3) { vem_eff.push_back(new HGeantKine(*kine1)); } if (kine1->getID() == 2) { vep_eff.push_back(new HGeantKine(*kine1)); } } Float_t eff_multbin = 1./getEfficiencyFactor(p3DEffEle[multbin][6],p3DEffPos[multbin][6],mom,the,phi,chg,false,false); if (isinf(eff_multbin) || isnan(eff_multbin)) eff_multbin = 0.; if (random.Uniform(1) > eff_multbin) { if (kine1->getID() == 3) { vem_eff_multbin.push_back(new HGeantKine(*kine1)); } if (kine1->getID() == 2) { vep_eff_multbin.push_back(new HGeantKine(*kine1)); } } } } } eventmixer.nextEvent(); eventmixer.addVector(vep,2); eventmixer.addVector(vem,3); vector<pair<HGeantKine *, HGeantKine* > >& pairsVec_acc = eventmixer.getMixedVector(); eventmixer_eff[0].nextEvent(); eventmixer_eff[0].addVector(vep_eff,2); eventmixer_eff[0].addVector(vem_eff,3); vector<pair<HGeantKine *, HGeantKine* > >& pairsVec_eff = eventmixer_eff[0].getMixedVector(); eventmixer_eff[multbin].nextEvent(); eventmixer_eff[multbin].addVector(vep_eff,2); eventmixer_eff[multbin].addVector(vem_eff,3); vector<pair<HGeantKine *, HGeantKine* > >& pairsVec_eff_multbin = eventmixer_eff[multbin].getMixedVector(); for (int imix = 0; imix < 3; ++imix) { vector<pair<HGeantKine *, HGeantKine* > > pairsVec; TString suffix; switch (imix) { case 0: pairsVec = pairsVec_acc; suffix = TString(""); break; case 1: pairsVec = pairsVec_eff; suffix = TString("_eff_multbin0"); break; case 2: pairsVec = pairsVec_eff_multbin; suffix = TString("_eff_multbin")+TString::Itoa(multbin,10); break; } size = pairsVec.size(); for (Int_t j = 0; j < size; j ++) { pair<HGeantKine*,HGeantKine*>& pair = pairsVec[j]; kine1 = pair.first; kine2 = pair.second; TLorentzVector vec1, vec2; HParticleTool::getTLorentzVector(kine1,vec1,kine1->getID()); HParticleTool::getTLorentzVector(kine2,vec2,kine2->getID()); Float_t mom1 = vec1.Vect().Mag(); Float_t the1 = vec1.Theta()*TMath::RadToDeg(); Float_t mom2 = vec2.Vect().Mag(); Float_t the2 = vec2.Theta()*TMath::RadToDeg(); TLorentzVector dilep = vec1 + vec2; Float_t oAngle = vec1.Angle(vec2.Vect())*TMath::RadToDeg(); Float_t mass = dilep.M()/1000; Float_t pt = dilep.Perp(); Float_t y = dilep.Rapidity(); Float_t mbinw = hM.get("hmassNP")->GetBinWidth(hM.get("hmassNP")->FindBin(mass)); if (oAngle < 9) continue; TString chg = "NP"; if (kine1->getID() == kine2->getID()) { if (kine1->getID() == 2) chg = "PP"; if (kine1->getID() == 3) chg = "NN"; } hM.get( TString("hmass") +chg+suffix)->Fill(mass, 1./mbinw); hM.get( TString("hoAngle") +chg+suffix)->Fill(oAngle ); hM.get( TString("hy") +chg+suffix)->Fill(y ); hM.get( TString("hpt") +chg+suffix)->Fill(pt ); hM.get2(TString("hoAnglemass")+chg+suffix)->Fill(oAngle,mass,1./mbinw); hM.get2(TString("hoAnglept") +chg+suffix)->Fill(oAngle,pt ); hM.get2(TString("hmasspt") +chg+suffix)->Fill(mass,pt, 1./mbinw); hM.get2(TString("hoAngley") +chg+suffix)->Fill(oAngle,y ); hM.get2(TString("hmassy") +chg+suffix)->Fill(mass,y, 1./mbinw); hM.get2(TString("hpty") +chg+suffix)->Fill(pt,y ); hM.get2(TString("hth1th2") +chg+suffix)->Fill(the1,the2 ); hM.get2(TString("hp1p2") +chg+suffix)->Fill(mom1,mom2 ); } } //#define DELETE_MIX #ifdef DELETE_MIX vector <HGeantKine *>* toDel = eventmixer.getObjectsToDelete(); for (unsigned int ii = 0; ii < toDel->size(); ++ii) { delete toDel->at(ii); } toDel->clear(); delete toDel; vector <HGeantKine *>* toDel_eff = eventmixer_eff[0].getObjectsToDelete(); for (unsigned int ii = 0; ii < toDel_eff->size(); ++ii) { delete toDel_eff->at(ii); } toDel_eff->clear(); delete toDel_eff; vector <HGeantKine *>* toDel_eff_multbin = eventmixer_eff[multbin].getObjectsToDelete(); for (unsigned int ii = 0; ii < toDel_eff_multbin->size(); ++ii) { delete toDel_eff_multbin->at(ii); } toDel_eff_multbin->clear(); delete toDel_eff_multbin; #endif } // end event loop timer.Stop(); hM.getFile()->cd(); TMacro m1(__DIELEANA_FILE__); m1.Write(); hM.writeHists("nomap"); cout<<"####################################################"<<endl; return 0; }
void PlotTheta( TString inputfilename, TString outputfilename = "output.root"){ // infile= new TFile("../PATGrid.SM.10k.root","READ"); infile = new TFile(inputfilename, "READ"); tree = (TTree*)infile->Get("Event"); outputFile = new TFile(outputfilename, "RECREATE"); outTree = new TTree("MyTree","Untersuchung der RekoObjekte"); //TH2::SetDefaultSumw2(); histogram__CosThetaDiff = new TH1D("histogram__CosThetaDiff", "Differenz CosTheta gen-reko", 400, -2, 2); histogram__CosTheta_GenReko = new TH2D("histogram__CosTheta_GenReko", "Reko-cos(theta) gegen Gen-cos(theta)", 50, -1, 1, 50, -1, 1); histogram__gen_A = new TH2D("histogram__gen_A", "histogram__gen_A", 5, -1, 1, 5, -1, 1); histogram__gen_N = new TH2D("histogram__gen_N", "histogram__gen_N", 5, -1, 1, 5, -1, 1); histogram__gen_LL = new TH2D("histogram__gen_LL", "histogram__gen_LL", 5, -1, 1, 5, -1, 1); histogram__gen_LR = new TH2D("histogram__gen_LR", "histogram__gen_LR", 5, -1, 1, 5, -1, 1); histogram__gen_RR = new TH2D("histogram__gen_RR", "histogram__gen_RR", 5, -1, 1, 5, -1, 1); histogram__gen_RL = new TH2D("histogram__gen_RL", "histogram__gen_RL", 5, -1, 1, 5, -1, 1); histogram__gen_Correlation = new TH2D("histogram__gen_Correlation", "histogram__gen_Correlation", 5, -1, 1, 5, -1, 1); histogram__A = new TH2D("histogram__A", "histogram__A", 5, -1, 1, 5, -1, 1); histogram__N = new TH2D("histogram__N", "histogram__N", 5, -1, 1, 5, -1, 1); histogram__Correlation = new TH2D("histogram__Correlation", "histogram__Correlation", 5, -1, 1, 5, -1, 1); histogram__Correlation_L15_B50_T1 = new TH2D("histogram__Correlation_L15_B50_T1", "histogram__Correlation_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__A_L15_B50_T1 = new TH2D("histogram__A_L15_B50_T1", "histogram__A_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__N_L15_B50_T1 = new TH2D("histogram__N_L15_B50_T1", "histogram__N_L15_B50_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20 = new TH2D("histogram__Correlation_L20", "histogram__Correlation_L20", 5, -1, 1, 5, -1, 1); histogram__A_L20 = new TH2D("histogram__A_L20", "histogram__A_L20", 5, -1, 1, 5, -1, 1); histogram__N_L20 = new TH2D("histogram__N_L20", "histogram__N_L20", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B40 = new TH2D("histogram__Correlation_L20_B40", "histogram__Correlation_L20_B40", 5, -1, 1, 5, -1, 1); histogram__A_L20_B40 = new TH2D("histogram__A_L20_B40", "histogram__A_L20_B40", 5, -1, 1, 5, -1, 1); histogram__N_L20_B40 = new TH2D("histogram__N_L20_B40", "histogram__N_L20_B40", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B30_T1 = new TH2D("histogram__Correlation_L20_B30_T1", "histogram__Correlation_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__A_L20_B30_T1 = new TH2D("histogram__A_L20_B30_T1", "histogram__A_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__N_L20_B30_T1 = new TH2D("histogram__N_L20_B30_T1", "histogram__N_L20_B30_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_L20_B40_T1 = new TH2D("histogram__Correlation_L20_B40_T1", "histogram__Correlation_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__A_L20_B40_T1 = new TH2D("histogram__A_L20_B40_T1", "histogram__A_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__N_L20_B40_T1 = new TH2D("histogram__N_L20_B40_T1", "histogram__N_L20_B40_T1", 5, -1, 1, 5, -1, 1); histogram__Correlation_T1 = new TH2D("histogram__Correlation_T1", "histogram__Correlation_T1", 5, -1, 1, 5, -1, 1); histogram__A_T1 = new TH2D("histogram__A_T1", "histogram__A_T1", 5, -1, 1, 5, -1, 1); histogram__N_T1 = new TH2D("histogram__N_T1", "histogram__N_T1", 5, -1, 1, 5, -1, 1); histogram__CosThetaDiff_TTbarPt = new TH2D("histogram__CosThetaDiff_TTbarPt", "histogram__CosThetaDiff_TTbarPt", 100, 0, 1000, 400, -2, 2); histogram__LeptonRelIso = new TH1D("histogram__LeptonRelIso", "histogram__LeptonRelIso", 101, 0, 1.01); histogram__semilepton_BLeptonMinus = new TH1D("histogram__semilepton_BLeptonMinus","histogram__semilepton_BLeptonMinus", 200, -1, 1); histogram__semilepton_BLeptonPlus = new TH1D("histogram__semilepton_BLeptonPlus","histogram__semilepton_BLeptonPlus", 200, -1, 1); histogram_nupx_gen_reco = new TH2D(" histogram_nupx_gen_reco", " histogram_nupx_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nupy_gen_reco = new TH2D(" histogram_nupy_gen_reco", " histogram_nupy_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nupz_gen_reco = new TH2D(" histogram_nupz_gen_reco", " histogram_nupz_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpx_gen_reco = new TH2D(" histogram_nubpx_gen_reco", " histogram_nubpx_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpy_gen_reco = new TH2D(" histogram_nubpy_gen_reco", " histogram_nubpy_gen_reco", 600, -300, 300, 600, -300, 300); histogram_nubpz_gen_reco = new TH2D(" histogram_nubpz_gen_reco", " histogram_nubpz_gen_reco", 600, -300, 300, 600, -300, 300); outTree->Branch("EventIsGood", &EventIsGood, "Event ist rekonstruiert/I"); outTree->Branch("numberOfJets", &numberOfJets, "Anzahl der Jets/I"); outTree->Branch("numberOfGoodJets", &numberOfGoodJets, "Anzahl der guten Jets/I"); outTree->Branch("CosThetaDiff" ,&CosThetaDiff ,"Differenz im cosTheta Reko zu Gen/D"); outTree->Branch("CosThetaPlus" ,&CosThetaPlus ,"cosTheta LeptonPlus/D"); outTree->Branch("CosThetaMinus" ,&CosThetaMinus ,"cosTheta LeptonMinus/D"); outTree->Branch("RekoCosThetaPlus" ,&RekoCosThetaPlus ,"cosTheta RekoLeptonPlus/D"); outTree->Branch("RekoCosThetaMinus" ,&RekoCosThetaMinus ,"cosTheta RekoLeptonMinus/D"); outTree->Branch("CosLeptonAngleD", &CosLeptonAngleD, "CosinusLeptonWinkel D/D"); outTree->Branch("CosRekoLeptonAngleD", &CosRekoLeptonAngleD, "CosinusRekoLeptonWinkel D/D"); outTree->Branch("TTbar_Pt", &TTbar_Pt, "Pt des TTbarsystems Generator/D"); outTree->Branch("RekoTTbar_Pt", &RekoTTbar_Pt, "Pt des TTbarsystems Reko/D"); outTree->Branch("TTbar_M", &TTbar_M, "Masse des TTbarsystems Generator/D"); outTree->Branch("RekoTTbar_M", &RekoTTbar_M, "Masse des TTbarsystems Reko/D"); outTree->Branch("Top_Pt", &Top_Pt, "Pt des Tops Generator/D"); outTree->Branch("Top_M", &Top_M, "M des Tops Generator/D"); outTree->Branch("AntiTop_Pt", &AntiTop_Pt, "Pt des AntiTops Generator/D"); outTree->Branch("AntiTop_M", &AntiTop_M, "M des AntiTops Generator/D"); outTree->Branch("RekoTop_Pt", &RekoTop_Pt, "Pt des Tops Reko/D"); outTree->Branch("RekoAntiTop_Pt", &RekoAntiTop_Pt, "Pt des AntiTops Reko/D"); outTree->Branch("RekoTop_M", &RekoTop_M, "M des Tops Reko/D"); outTree->Branch("RekoAntiTop_M", &RekoAntiTop_M, "M des AntiTops Reko/D"); outTree->Branch("Nu_Px", &Nu_Px, "Px des Neutrinos Generator/D"); outTree->Branch("Nu_Py", &Nu_Py, "Py des Neutrinos Generator/D"); outTree->Branch("Nu_Pz", &Nu_Pz, "Pz des Neutrinos Generator/D"); outTree->Branch("AntiNu_Px", &AntiNu_Px, "Px des AntiNeutrinos Generator/D"); outTree->Branch("AntiNu_Py", &AntiNu_Py, "Py des AntiNeutrinos Generator/D"); outTree->Branch("AntiNu_Pz", &AntiNu_Pz, "Pz des AntiNeutrinos Generator/D"); outTree->Branch("RekoNu_Px", &RekoNu_Px, "Px des Neutrinos Reko/D"); outTree->Branch("RekoNu_Py", &RekoNu_Py, "Py des Neutrinos Reko/D"); outTree->Branch("RekoNu_Pz", &RekoNu_Pz, "Pz des Neutrinos Reko/D"); outTree->Branch("RekoAntiNu_Px", &RekoAntiNu_Px, "Px des AntiNeutrinos Reko/D"); outTree->Branch("RekoAntiNu_Py", &RekoAntiNu_Py, "Py des AntiNeutrinos Reko/D"); outTree->Branch("RekoAntiNu_Pz", &RekoAntiNu_Pz, "Pz des AntiNeutrinos Reko/D"); outTree->Branch("BestNu_Px", &BestNu_Px, "Px des Neutrinos Best/D"); outTree->Branch("BestNu_Py", &BestNu_Py, "Py des Neutrinos Best/D"); outTree->Branch("BestNu_Pz", &BestNu_Pz, "Pz des Neutrinos Best/D"); outTree->Branch("BestAntiNu_Px", &BestAntiNu_Px, "Px des AntiNeutrinos Best/D"); outTree->Branch("BestAntiNu_Py", &BestAntiNu_Py, "Py des AntiNeutrinos Best/D"); outTree->Branch("BestAntiNu_Pz", &BestAntiNu_Pz, "Pz des AntiNeutrinos Best/D"); outTree->Branch("Lepton_Pt", &Lepton_Pt, "kleineres Pt der beiden gewaehlten Leptonen/D"); outTree->Branch("BJet_Et", &BJet_Et,"niedrigieres Et der BJets/D"); outTree->Branch("BJet_Tag_TrkCount", &BJet_Tag_TrkCount,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Tag_SVsimple", &BJet_Tag_SVsimple,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Tag_SVcomb", &BJet_Tag_SVcomb,"niedrigierer BTag der BJets/D"); outTree->Branch("BJet_Disc", &BJet_Disc,"niedrigierer Discriminator der BJets/D"); outTree->Branch("Lepton1_Id", &Lepton1_Id, "PdgId des ersten Leptons/I"); outTree->Branch("Lepton2_Id", &Lepton2_Id, "PdgId des zweiten Leptons/I"); outTree->Branch("Lepton_Mass", &Lepton_Mass, "inv. Masse der beiden Leptonen/D"); outTree->Branch("BJet_Angle", &BJet_Angle, "Winkel bJet zu Quark/D"); outTree->Branch("BbarJet_Angle", &BbarJet_Angle, "Winkel bbarJet zu Quark/D"); outTree->Branch("LeptonPlus_Angle", &LeptonPlus_Angle, "Winkel LeptonPlus zu Lepton Gen /D"); outTree->Branch("LeptonMinus_Angle", &LeptonMinus_Angle, "Winkel LeptonMinus zu Lepton Gen /D"); outTree->Branch("RekoNu_Angle", &RekoNu_Angle, "Winkel RekoNu zu GenNu/D"); outTree->Branch("RekoAntiNu_Angle", &RekoAntiNu_Angle, "Winkel RekoAntiNu zu GenAntiNu/D"); outTree->Branch("BestNu_Angle", &BestNu_Angle, "Winkel BestNu zu GenNu/D"); outTree->Branch("BestAntiNu_Angle", &BestAntiNu_Angle, "Winkel BestAntiNu zu GenAntiNu/D"); histogram__gen_Correlation->Sumw2(); histogram__Correlation->Sumw2(); histogram__gen_A->Sumw2(); histogram__A->Sumw2(); histogram__gen_N->Sumw2(); histogram__N->Sumw2(); double PatJetsPx[50]; double PatJetsPy[50]; double PatJetsPz[50]; double PatJetsE[50]; double PatJetsEt[50]; double PatLeptonsPx[20]; double PatLeptonsPy[20]; double PatLeptonsPz[20]; double PatLeptonsPt[20]; double PatLeptonsE[20]; int PatLeptonsCharge[20]; int PatLeptonsPdgId[20]; double PatLeptonsTrkIso[20]; double PatLeptonsCaloIso[20]; double PatJetsBTag_TrkCount[50]; double PatJetsBTag_SVsimple[50]; double PatJetsBTag_SVcomb[50]; double PatJetsCharge[50]; double PatJetsBQuarkDeltaR[50]; double PatJetsBbarQuarkDeltaR[50]; int numberOfPatMuons; int numberOfPatElectrons; int numberOfPatLeptons; int numberOfPatJets; int numberOfLeptons; TLorentzVector *pTop; //FROM TREE TLorentzVector *pAntiTop; //FROM TREE TLorentzVector *pLeptonPlus; //FROM TREE TLorentzVector *pLeptonMinus; //FROM TREE TLorentzVector *pBQuark; //FROM TREE TLorentzVector *pBbarQuark; //FROM TREE TLorentzVector* pGenNu; //FROM TREE TLorentzVector* pGenAntiNu; //FROM TREE TLorentzVector *pTTbar; TLorentzVector *pTopBoosted; TLorentzVector *pAntiTopBoosted; TLorentzVector *pLeptonPlusBoosted; TLorentzVector *pLeptonMinusBoosted; TLorentzVector *pJet[50]; TLorentzVector *pBJet1; TLorentzVector *pBJet2; TLorentzVector *pRekoNu1; TLorentzVector *pRekoAntiNu1; TLorentzVector *pRekoNu2; TLorentzVector *pRekoAntiNu2; TLorentzVector *pRekoLeptonPlus; TLorentzVector *pRekoLeptonMinus; TLorentzVector *pBJet; TLorentzVector *pBbarJet; TLorentzVector *pRekoNu; TLorentzVector *pRekoAntiNu; TLorentzVector *pBestNu; TLorentzVector *pBestAntiNu; TLorentzVector *pBestNu2; TLorentzVector *pBestAntiNu2; TLorentzVector *pRekoTop; TLorentzVector *pRekoAntiTop; TLorentzVector *pRekoTTbar; TLorentzVector *pRekoTopBoosted; TLorentzVector *pRekoAntiTopBoosted; TLorentzVector *pRekoLeptonPlusBoosted; TLorentzVector *pRekoLeptonMinusBoosted; TLorentzVector *pNu; TLorentzVector *pAntiNu; TLorentzVector *pBBoosted; TLorentzVector *pBbarBoosted; pTop = new TLorentzVector(0,0,0,0); pAntiTop = new TLorentzVector(0,0,0,0); pLeptonPlus = new TLorentzVector(0,0,0,0); pLeptonMinus = new TLorentzVector(0,0,0,0); pBQuark = new TLorentzVector(0,0,0,0); pBbarQuark = new TLorentzVector(0,0,0,0); pGenNu = new TLorentzVector(0,0,0,0); pGenAntiNu = new TLorentzVector(0,0,0,0); pTTbar = new TLorentzVector(0,0,0,0); pTopBoosted = new TLorentzVector(0,0,0,0); pAntiTopBoosted = new TLorentzVector(0,0,0,0); pLeptonPlusBoosted = new TLorentzVector(0,0,0,0); pLeptonMinusBoosted = new TLorentzVector(0,0,0,0); pRekoTop = new TLorentzVector(0,0,0,0); pRekoAntiTop = new TLorentzVector(0,0,0,0); pRekoLeptonPlus = new TLorentzVector(0,0,0,0); pRekoLeptonMinus = new TLorentzVector(0,0,0,0); pRekoNu = new TLorentzVector(0,0,0,0); pRekoAntiNu = new TLorentzVector(0,0,0,0); pBestNu = new TLorentzVector(0,0,0,0); pBestAntiNu = new TLorentzVector(0,0,0,0); pBestNu2 = new TLorentzVector(0,0,0,0); pBestAntiNu2 = new TLorentzVector(0,0,0,0); pRekoTTbar = new TLorentzVector(0,0,0,0); pRekoTopBoosted = new TLorentzVector(0,0,0,0); pRekoAntiTopBoosted = new TLorentzVector(0,0,0,0); pRekoLeptonPlusBoosted = new TLorentzVector(0,0,0,0); pRekoLeptonMinusBoosted = new TLorentzVector(0,0,0,0); pNu = new TLorentzVector(0,0,0,0); pAntiNu = new TLorentzVector(0,0,0,0); pBJet1 = new TLorentzVector(0,0,0,0); pBJet2 = new TLorentzVector(0,0,0,0); pRekoNu1 = new TLorentzVector(0,0,0,0); pRekoAntiNu1 = new TLorentzVector(0,0,0,0); pRekoNu2 = new TLorentzVector(0,0,0,0); pRekoAntiNu2 = new TLorentzVector(0,0,0,0); pBJet = new TLorentzVector(0,0,0,0); pBbarJet = new TLorentzVector(0,0,0,0); pBBoosted = new TLorentzVector(0,0,0,0); pBbarBoosted = new TLorentzVector(0,0,0,0); for(int i=0; i<50;i++) pJet[i] = new TLorentzVector(0,0,0,0); double mass_a = 170.0; double mass_b = 175.0; calc Poly(mass_a, mass_b, outputFile); tree->SetBranchAddress("pTop", &pTop); tree->SetBranchAddress("pAntiTop", &pAntiTop); tree->SetBranchAddress("pLeptonPlus", &pLeptonPlus); tree->SetBranchAddress("pLeptonMinus", &pLeptonMinus); tree->SetBranchAddress("pBQuark", &pBQuark); tree->SetBranchAddress("pBbarQuark", &pBbarQuark); tree->SetBranchAddress("PatLeptonsPx", PatLeptonsPx); tree->SetBranchAddress("PatLeptonsPy", PatLeptonsPy); tree->SetBranchAddress("PatLeptonsPz", PatLeptonsPz); tree->SetBranchAddress("PatLeptonsPt", PatLeptonsPt); tree->SetBranchAddress("PatLeptonsE", PatLeptonsE); tree->SetBranchAddress("PatLeptonsCharge", PatLeptonsCharge); tree->SetBranchAddress("PatLeptonsPdgId", PatLeptonsPdgId); tree->SetBranchAddress("PatLeptonsTrkIso", PatLeptonsTrkIso); tree->SetBranchAddress("PatLeptonsCaloIso", PatLeptonsCaloIso); tree->SetBranchAddress("PatJetsPx", PatJetsPx); tree->SetBranchAddress("PatJetsPy", PatJetsPy); tree->SetBranchAddress("PatJetsPz", PatJetsPz); tree->SetBranchAddress("PatJetsE", PatJetsE); tree->SetBranchAddress("PatJetsEt", PatJetsEt); tree->SetBranchAddress("PatJetsCharge", PatJetsCharge); tree->SetBranchAddress("PatJetsBTag_TrkCount", PatJetsBTag_TrkCount); tree->SetBranchAddress("PatJetsBTag_SVsimple", PatJetsBTag_SVsimple); tree->SetBranchAddress("PatJetsBTag_SVcomb", PatJetsBTag_SVcomb); tree->SetBranchAddress("PatJetsBQuarkDeltaR", PatJetsBQuarkDeltaR); tree->SetBranchAddress("PatJetsBbarQuarkDeltaR", PatJetsBbarQuarkDeltaR); tree->SetBranchAddress("numberOfPatMuons", &numberOfPatMuons); tree->SetBranchAddress("numberOfPatElectrons", &numberOfPatElectrons); tree->SetBranchAddress("numberOfPatLeptons", &numberOfPatLeptons); tree->SetBranchAddress("numberOfPatJets", &numberOfPatJets); tree->SetBranchAddress("numberOfLeptons", &numberOfLeptons); tree->SetBranchAddress("pGenNu", &pGenNu); tree->SetBranchAddress("pGenAntiNu", &pGenAntiNu); int nEvents = (int)tree->GetEntries(); //nEvents = 5000; int EventCounter = 0; cout << "Anzahl Ereignisse: " << nEvents << endl; for(int iEvent=1; iEvent<nEvents;iEvent++){ tree->GetEntry(iEvent); EventCounter++; if(iEvent%10000 == 1) { cout << "Event " << iEvent << endl; } EventIsGood = 0; // GENERATOR THETA w_A = 0; w_N = 0; *pTTbar=(*pTop+*pAntiTop); *pTopBoosted = *pTop; *pAntiTopBoosted = *pAntiTop; *pLeptonPlusBoosted = *pLeptonPlus; *pLeptonMinusBoosted = *pLeptonMinus; *pBBoosted = *pBQuark; *pBbarBoosted = *pBbarQuark; pAntiTopBoosted->Boost(-pTTbar->BoostVector()); pTopBoosted->Boost(-pTTbar->BoostVector()); pLeptonPlusBoosted->Boost(-pTop->BoostVector()); pLeptonMinusBoosted->Boost(-pAntiTop->BoostVector()); CosThetaPlus = cos(pLeptonPlusBoosted->Angle(pTopBoosted->Vect())); CosThetaMinus = cos(pLeptonMinusBoosted->Angle(pAntiTopBoosted->Vect())); pBBoosted->Boost(-pTop->BoostVector()); pBbarBoosted->Boost(-pAntiTop->BoostVector()); CosLeptonAngleD = cos(pLeptonPlusBoosted->Angle(pLeptonMinusBoosted->Vect())); double Nenner = 1 - 0.256*CosThetaPlus*CosThetaMinus; w_A = (-CosThetaPlus*CosThetaMinus)/Nenner; w_N = 1./Nenner; w_LL = (1-CosThetaPlus*CosThetaMinus-CosThetaPlus+CosThetaMinus)/Nenner; w_LR = (1+CosThetaPlus*CosThetaMinus-CosThetaPlus-CosThetaMinus)/Nenner; w_RR = (1-CosThetaPlus*CosThetaMinus+CosThetaPlus-CosThetaMinus)/Nenner; w_RL = (1+CosThetaPlus*CosThetaMinus+CosThetaPlus+CosThetaMinus)/Nenner; histogram__gen_A->Fill(CosThetaPlus, CosThetaMinus, w_A); histogram__gen_N->Fill(CosThetaPlus, CosThetaMinus, w_N); histogram__gen_LL->Fill(CosThetaPlus, CosThetaMinus, w_LL); histogram__gen_LR->Fill(CosThetaPlus, CosThetaMinus, w_LR); histogram__gen_RR->Fill(CosThetaPlus, CosThetaMinus, w_RR); histogram__gen_RL->Fill(CosThetaPlus, CosThetaMinus, w_RL); histogram__gen_Correlation->Fill(CosThetaPlus, CosThetaMinus); if(numberOfLeptons == 2) { if(pLeptonMinus->Px() != 0) histogram__semilepton_BLeptonMinus->Fill( cos(pLeptonMinusBoosted->Angle(pBBoosted->Vect())) ); if(pLeptonPlus->Px() != 0) histogram__semilepton_BLeptonPlus->Fill( cos(pLeptonPlusBoosted->Angle(pBbarBoosted->Vect())) ); } numberOfJets = numberOfPatJets; if(numberOfPatLeptons>=2 && numberOfPatJets >=2) { RekoNu_Px = -10000; RekoNu_Py= -10000; RekoNu_Pz= -10000; RekoAntiNu_Px= -10000; RekoAntiNu_Py= -10000; RekoAntiNu_Pz= -10000; RekoTop_M = -10; RekoAntiTop_M = -10; RekoTop_Pt = -10; RekoAntiTop_Pt = -10; // REKO THETA pBJet1->SetPxPyPzE(0.,0.,0.,0.); pBJet2->SetPxPyPzE(0.,0.,0.,0.); pRekoLeptonPlus->SetPxPyPzE(0.,0.,0.,0.); pRekoLeptonMinus->SetPxPyPzE(0.,0.,0.,0.); pBJet->SetPxPyPzE(0.,0.,0.,0.); pBbarJet->SetPxPyPzE(0.,0.,0.,0.); pRekoNu->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu->SetPxPyPzE(0.,0.,0.,-10000.); pBestNu->SetPxPyPzE(0.,0.,0.,-10000.); pBestAntiNu->SetPxPyPzE(0.,0.,0.,-10000.); pRekoNu1->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu1->SetPxPyPzE(0.,0.,0.,-10000.); pRekoNu2->SetPxPyPzE(0.,0.,0.,-10000.); pRekoAntiNu2->SetPxPyPzE(0.,0.,0.,-10000.); int LeptonIndex[20]; int BTagTrkCountIndex[50]; int BTagSVsimpleIndex[50]; int BTagSVcombIndex[50]; int BJetsEIndex[50]; int BJetDeltaRIndex[50]; int BbarJetDeltaRIndex[50]; TMath::Sort(20,PatLeptonsE,LeptonIndex); TMath::Sort(50,PatJetsBTag_TrkCount, BTagTrkCountIndex); TMath::Sort(50,PatJetsBTag_SVsimple, BTagSVsimpleIndex); TMath::Sort(50,PatJetsBTag_SVcomb, BTagSVcombIndex); TMath::Sort(50, PatJetsE, BJetsEIndex); TMath::Sort(50, PatJetsBQuarkDeltaR, BJetDeltaRIndex); TMath::Sort(50, PatJetsBbarQuarkDeltaR, BbarJetDeltaRIndex); // Leptonen auswaehlen int OtherLepton = -1; for(int j=0; PatLeptonsCharge[LeptonIndex[0]]==PatLeptonsCharge[LeptonIndex[j]] && j<20; j++){ OtherLepton=j+1; } // if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==0) std::cout<<"Only Leptons of same Charge in Event " << iEvent << "!!"<<std::endl; if(PatLeptonsCharge[LeptonIndex[OtherLepton]]!=0){ // Leptonen zuordnen if(PatLeptonsCharge[LeptonIndex[0]]==-1){ pRekoLeptonMinus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[0]], PatLeptonsPy[LeptonIndex[0]], PatLeptonsPz[LeptonIndex[0]], PatLeptonsE[LeptonIndex[0]] ); } if(PatLeptonsCharge[LeptonIndex[0]]==+1){ pRekoLeptonPlus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[0]], PatLeptonsPy[LeptonIndex[0]], PatLeptonsPz[LeptonIndex[0]], PatLeptonsE[LeptonIndex[0]] ); } if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==-1){ pRekoLeptonMinus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[OtherLepton]], PatLeptonsPy[LeptonIndex[OtherLepton]], PatLeptonsPz[LeptonIndex[OtherLepton]],PatLeptonsE[LeptonIndex[OtherLepton]] ); } if(PatLeptonsCharge[LeptonIndex[OtherLepton]]==+1){ pRekoLeptonPlus->SetPxPyPzE(PatLeptonsPx[LeptonIndex[OtherLepton]], PatLeptonsPy[LeptonIndex[OtherLepton]], PatLeptonsPz[LeptonIndex[OtherLepton]], PatLeptonsE[LeptonIndex[OtherLepton]] ); } //cout << "Leptonen ausgewaehlt" << endl; Lepton_Mass = ((*pRekoLeptonPlus) + (*pRekoLeptonMinus)).M(); if( TMath::Abs( Lepton_Mass - 90.0 ) > 10 || PatLeptonsPdgId[LeptonIndex[0]] + PatLeptonsPdgId[LeptonIndex[OtherLepton]] !=0 ) { double JetDisc[50]; numberOfGoodJets = 0; for(int j=0; j<50; j++){ JetDisc[j] = 0.; if(j<numberOfPatJets){ //JetDisc[j] = PatJetsBTag_TrkCount[j] * PatJetsEt[j]; if(PatJetsBTag_TrkCount[j]>1. && PatJetsEt[j]>20){ pJet[j]->SetPxPyPzE(PatJetsPx[j],PatJetsPy[j], PatJetsPz[j], PatJetsE[j]); if(TMath::Min(pJet[j]->Angle(pRekoLeptonPlus->Vect()), pJet[j]->Angle(pRekoLeptonMinus->Vect())) >0.1){ numberOfGoodJets++; JetDisc[j] = PatJetsBTag_TrkCount[j] * PatJetsEt[j]; } } if(j<numberOfPatLeptons){ histogram__LeptonRelIso->Fill(PatLeptonsPt[j]/(PatLeptonsPt[j]+PatLeptonsTrkIso[j]+PatLeptonsCaloIso[j])); } } } int JetDiscIndex[50]; TMath::Sort(50, JetDisc, JetDiscIndex); // Jets auswaehlen // verbesserte Auswahl (BTag*ET) pBJet1->SetPxPyPzE(PatJetsPx[JetDiscIndex[0]],PatJetsPy[JetDiscIndex[0]],PatJetsPz[JetDiscIndex[0]],PatJetsE[JetDiscIndex[0]]); pBJet2->SetPxPyPzE(PatJetsPx[JetDiscIndex[1]],PatJetsPy[JetDiscIndex[1]],PatJetsPz[JetDiscIndex[1]],PatJetsE[JetDiscIndex[1]]); //pBJet1->SetPxPyPzE(PatJetsPx[BTagTrkCountIndex[0]],PatJetsPy[BTagTrkCountIndex[0]],PatJetsPz[BTagTrkCountIndex[0]],PatJetsE[BTagTrkCountIndex[0]]); //pBJet2->SetPxPyPzE(PatJetsPx[BTagTrkCountIndex[1]],PatJetsPy[BTagTrkCountIndex[1]],PatJetsPz[BTagTrkCountIndex[1]],PatJetsE[BTagTrkCountIndex[1]]); //cout << "Jets gewaehlt" << endl; // Neutrinos berechnen //Generator-Werte setzen fuer Vergleich mit Berechnung pNu->SetPxPyPzE(pGenNu->Px(),pGenNu->Py(),pGenNu->Pz(),pGenNu->E()); pAntiNu->SetPxPyPzE(pGenAntiNu->Px(),pGenAntiNu->Py(),pGenAntiNu->Pz(),pGenAntiNu->E()); Poly.Init(pRekoLeptonPlus, pRekoLeptonMinus, pBJet1, pBJet2, pNu, pAntiNu); // BJet1 = b, BJet2 = bbar Poly.Solve(170.0,171.0 , iEvent, pRekoNu1, pRekoAntiNu1, pBestNu, pBestAntiNu); Poly.Init(pRekoLeptonPlus, pRekoLeptonMinus, pBJet2, pBJet1, pNu, pAntiNu); // BJet1 = bbar, BJet2 = b Poly.Solve(170.0,171.0 , iEvent, pRekoNu2, pRekoAntiNu2, pBestNu2, pBestAntiNu2); //cout << "Neutrinos berechnet" << endl; // Abfrage, ob Neutrinoloesung ungleich -10000 !!! if(pRekoAntiNu1->Pz() != -10000 && pRekoAntiNu2->Pz() != -10000){ if(TMath::Abs( ((*pRekoLeptonPlus)+(*pRekoNu1)+(*pBJet1)).M() + ((*pRekoLeptonMinus)+(*pRekoAntiNu1)+(*pBJet2)).M() - 2*173.2) < TMath::Abs(((*pRekoLeptonPlus)+(*pRekoNu2)+(*pBJet2)).M() + ((*pRekoLeptonMinus)+(*pRekoAntiNu2)+(*pBJet1)).M() - 2*173.2) ){ *pBJet = *pBJet1; *pBbarJet = *pBJet2; *pRekoNu = *pRekoNu1; *pRekoAntiNu = *pRekoAntiNu1; } else { *pBJet = *pBJet2; *pBbarJet = *pBJet1; *pRekoNu = *pRekoNu2; *pRekoAntiNu = *pRekoAntiNu2; *pBestNu = *pBestNu2; *pBestAntiNu = *pBestAntiNu2; } } else if(pRekoAntiNu1->Pz() != -10000){ *pBJet = *pBJet1; *pBbarJet = *pBJet2; *pRekoNu = *pRekoNu1; *pRekoAntiNu = *pRekoAntiNu1; } else if(pRekoAntiNu2->Pz() != -10000){ *pBJet = *pBJet2; *pBbarJet = *pBJet1; *pRekoNu = *pRekoNu2; *pRekoAntiNu = *pRekoAntiNu2; *pBestNu = *pBestNu2; *pBestAntiNu = *pBestAntiNu2; } else{ pRekoNu->SetPxPyPzE(0,0,-10000, 10000); pRekoAntiNu->SetPxPyPzE(0,0,-10000, 10000); pBestNu->SetPxPyPzE(0,0,-10000, 10000); pBestAntiNu->SetPxPyPzE(0,0,-10000, 10000); pBJet->SetPxPyPzE(0,0,-10000, 10000); pBbarJet->SetPxPyPzE(0,0,-10000, 10000); } TTbar_Pt = pTTbar->Pt(); TTbar_M = pTTbar->M(); Top_Pt = pTop->Pt(); AntiTop_Pt = pAntiTop->Pt(); Top_M = pTop->M(); AntiTop_M = pAntiTop->M(); Nu_Px = pNu->Px(); Nu_Py = pNu->Py(); Nu_Pz = pNu->Pz(); AntiNu_Px = pAntiNu->Px(); AntiNu_Py = pAntiNu->Py(); AntiNu_Pz = pAntiNu->Pz(); Lepton_Pt = TMath::Min(pRekoLeptonPlus->Pt(), pRekoLeptonMinus->Pt()); BJet_Et = TMath::Min(pBJet->Et(), pBbarJet->Et()); BJet_Tag_SVsimple = PatJetsBTag_SVsimple[BTagSVsimpleIndex[1]]; BJet_Tag_SVcomb = PatJetsBTag_SVcomb[BTagSVcombIndex[1]]; BJet_Tag_TrkCount = PatJetsBTag_TrkCount[BTagTrkCountIndex[1]]; BJet_Disc = JetDisc[JetDiscIndex[1]]; Lepton1_Id = PatLeptonsPdgId[LeptonIndex[0]]; Lepton2_Id = PatLeptonsPdgId[LeptonIndex[OtherLepton]]; LeptonPlus_Angle = -10.; LeptonMinus_Angle = -10.; BJet_Angle = -10.; BbarJet_Angle = -10.; RekoNu_Angle = -10.; RekoAntiNu_Angle = -10.; BestNu_Angle = -10.; BestAntiNu_Angle = -10.; //cout << "Werte gesetzt" << endl; if(pRekoAntiNu->Pz() > -10000){ histogram_nupx_gen_reco->Fill(pGenNu->Px(), pRekoNu->Px()); histogram_nubpx_gen_reco->Fill(pGenAntiNu->Px(), pRekoAntiNu->Px()); histogram_nupy_gen_reco->Fill(pGenNu->Py(), pRekoNu->Py()); histogram_nubpy_gen_reco->Fill(pGenAntiNu->Py(), pRekoAntiNu->Py()); histogram_nupz_gen_reco->Fill(pGenNu->Pz(), pRekoNu->Pz()); histogram_nubpz_gen_reco->Fill(pGenAntiNu->Pz(), pRekoAntiNu->Pz()); if(pLeptonPlus->E() != 0 && pLeptonMinus->E() != 0 && pBQuark->E() != 0 ){ BJet_Angle = pBJet->DeltaR(*pBQuark); BbarJet_Angle = pBbarJet->DeltaR(*pBbarQuark); LeptonPlus_Angle = pRekoLeptonPlus->DeltaR(*pLeptonPlus); LeptonMinus_Angle = pRekoLeptonMinus->DeltaR(*pLeptonMinus); RekoNu_Angle = pRekoNu->DeltaR(*pNu); RekoAntiNu_Angle = pRekoAntiNu->DeltaR(*pAntiNu); BestNu_Angle = pBestNu->DeltaR(*pNu); BestAntiNu_Angle = pBestAntiNu->DeltaR(*pAntiNu); } RekoNu_Px = pRekoNu->Px(); RekoNu_Py = pRekoNu->Py(); RekoNu_Pz = pRekoNu->Pz(); RekoAntiNu_Px = pRekoAntiNu->Px(); RekoAntiNu_Py = pRekoAntiNu->Py(); RekoAntiNu_Pz = pRekoAntiNu->Pz(); BestNu_Px = pBestNu->Px(); BestNu_Py = pBestNu->Py(); BestNu_Pz = pBestNu->Pz(); BestAntiNu_Px = pBestAntiNu->Px(); BestAntiNu_Py = pBestAntiNu->Py(); BestAntiNu_Pz = pBestAntiNu->Pz(); if(pRekoLeptonPlus->E()!=0 && pRekoLeptonMinus->E()!=0 && pBJet->E()!=0 && pBbarJet->E()!=0){ EventIsGood = 1; *pRekoTop = (*pRekoLeptonPlus) + (*pBJet) + (*pRekoNu); *pRekoAntiTop = (*pRekoLeptonMinus) + (*pBbarJet) + (*pRekoAntiNu); *pRekoTTbar = (*pRekoTop) + (*pRekoAntiTop); *pRekoTopBoosted = *pRekoTop; *pRekoAntiTopBoosted = *pRekoAntiTop; *pRekoLeptonPlusBoosted = *pRekoLeptonPlus; *pRekoLeptonMinusBoosted = *pRekoLeptonMinus; pRekoAntiTopBoosted->Boost(-pRekoTTbar->BoostVector()); pRekoTopBoosted->Boost(-pRekoTTbar->BoostVector()); pRekoLeptonPlusBoosted->Boost(-pRekoTop->BoostVector()); pRekoLeptonMinusBoosted->Boost(-pRekoAntiTop->BoostVector()); RekoCosThetaPlus = cos(pRekoLeptonPlusBoosted->Angle(pRekoTopBoosted->Vect())); RekoCosThetaMinus = cos(pRekoLeptonMinusBoosted->Angle(pRekoAntiTopBoosted->Vect())); //cout << "Cos(Theta) Gen-Reko: " << CosThetaPlus - RekoCosThetaPlus << endl; CosThetaDiff = RekoCosThetaPlus - CosThetaPlus; CosRekoLeptonAngleD = cos(pRekoLeptonPlusBoosted->Angle(pRekoLeptonMinusBoosted->Vect())); RekoTTbar_Pt = pRekoTTbar->Pt(); RekoTTbar_M = pRekoTTbar->M(); RekoTop_Pt = pRekoTop->Pt(); RekoAntiTop_Pt = pRekoAntiTop->Pt(); RekoTop_M = pRekoTop->M(); RekoAntiTop_M = pRekoAntiTop->M(); histogram__A->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); histogram__Correlation->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__CosThetaDiff->Fill( CosThetaPlus - RekoCosThetaPlus ); histogram__CosThetaDiff->Fill( CosThetaMinus - RekoCosThetaMinus ); histogram__CosTheta_GenReko->Fill(CosThetaPlus, RekoCosThetaPlus); histogram__CosThetaDiff_TTbarPt->Fill(pTTbar->Pt(), CosThetaPlus - RekoCosThetaPlus); if(BJet_Tag_TrkCount > 1.0){ histogram__Correlation_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pRekoLeptonPlus->Pt()>15 && pRekoLeptonMinus->Pt()>15 && pBJet->Et()>50 && pBbarJet->Et()>50 && PatJetsBTag_TrkCount[BTagTrkCountIndex[1]]>1 ){ histogram__Correlation_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L15_B50_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pRekoLeptonPlus->Pt()>20 && pRekoLeptonMinus->Pt()>20){ histogram__Correlation_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); if(pBJet->Et() > 30 && pBbarJet->Et() > 30 && PatJetsBTag_TrkCount[BTagTrkCountIndex[1]] > 1){ histogram__Correlation_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B30_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } if(pBJet->Et() > 40 && pBbarJet->Et() > 40){ histogram__Correlation_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B40->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); if(PatJetsBTag_TrkCount[BTagTrkCountIndex[1]] > 1 ){ histogram__Correlation_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus); histogram__A_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_A); histogram__N_L20_B40_T1->Fill(RekoCosThetaPlus, RekoCosThetaMinus, w_N); } } } } // Leptonen und B != 0 } // Neutrino-Pz != -10000 } // inv. Masse der Leptonen != Z-Masse+-10 }// abfrage auf 2 Leptonen unterschiedlicher Ladung //cout << "Tree wird gefuellt: "; //cout << " und ist fertig" << endl; } outTree->Fill(); } // EventLoop cout << "gezaehlte Ereignisse: " << EventCounter << endl; cout << "Rekonstruierte Ereignisse: " << histogram__Correlation->Integral() << endl; outputFile->cd(""); outputFile->Write(); outputFile->Close(); delete outputFile; }
bool leptonic_fitter_algebraic::fit( const TLorentzVector& B, const TH1& BITF, const TF1& Beff, const TLorentzVector& lep, double MEX, double MEY, const TF1& dnuPDF ) { if( _dbg > 19 ) cout<<"DBG20 Entered leptonic_fitter_algebraic::fit with B mass: "<<B.M()<<", l_m:"<<lep.M()<<", MET: "<<MEX<<" "<<MEY<<endl; if( B.M() <= 0 ) throw std::runtime_error( "leptonic_fitter_algebraic was given a b-jet with an illegal (non-positive) mass!"); if( lep.M() < 0 ) throw std::runtime_error( "leptonic_fitter_algebraic was given a lepton with an illegal (negative) mass!"); _converged = _swapped = false; _obsB = B; _obsL = lep; _BITF = &BITF; _Beff = &Beff; _dnuPDF = dnuPDF; _b_m2 = B.M2(); double lep_b_angle = lep.Angle( B.Vect() ); double cos_lep_b = TMath::Cos( lep_b_angle ); double sin_lep_b = TMath::Sin( lep_b_angle ); double b_p = B.P(); double b_e = B.E(); _denom = b_e - cos_lep_b * b_p; _lep_p = lep.P(); _x0 = - _W_m2 / ( 2 * _lep_p ); _y1 = - sin_lep_b * _x0 * b_p / _denom; _x1_0 = _x0 * b_e / _denom - _y1*_y1 / _x0; _Z2_0 = _x0*_x0 - _W_m2 - _y1*_y1; if( _dbg > 219 ) cout<<"DBG220 lfa updated lepton with: "<<lv2str( lep )<<" -> x0:"<<_x0<<", y1: "<<_y1<<", x1_0: "<<_x1_0<<", Z2_0: "<<_Z2_0<<endl; static double bnums[3]; bnums[0] = B.X(); bnums[1] = B.Y(); bnums[2] = B.Z(); TMatrixD bXYZ( 3, 1, bnums ); _R_T = rotation( 2, lep.Phi() ); // R_z^T _R_T *= rotation( 1, lep.Theta() - 0.5*TMath::Pi() ); // R_z^T R_y^T TMatrixD rotation_vect( _R_T, TMatrixD::kTransposeMult, bXYZ ); // R_y R_z double* rotation_array = rotation_vect.GetMatrixArray(); double phi_x = - TMath::ATan2( rotation_array[2], rotation_array[1] ); if( _dbg > 99 ) cout<<"DBG100 lfa x rotation vector is:"<<rotation_array[0]<<" "<<rotation_array[1]<<" "<<rotation_array[2]<<" -> phi_x:"<<phi_x<<endl; _R_T *= rotation( 0, - phi_x ); // R_z^T R_y^T R_x^T // set up _Nu's non-zero elements so that \vec{nu} = Nu \vec{t} for any \vec{t} (since only t's 3nd component is used, and its always 1). _Nu[0][2] = MEX; _Nu[1][2] = MEY; double iVarMET = TMath::Power( TMath::Max( 1., dnuPDF.GetHistogram()->GetRMS() ), -2 ); _invFlatVar[0][0] = _invFlatVar[1][1] = iVarMET; // set up the chi^2 distance with the right order of magnitude (generalizes to rotated covariance matrix) if( _dbg > 209 ) cout<<"DBG210 lfa "<<dnuPDF.GetName()<<" --> iVarMET:"<<iVarMET<<endl; // (re)define fit parameter, so all fits start off on an equal footing _mini->SetPrintLevel( _minimizer_print_level ); _mini->Clear(); _mini->SetFunction( _functor ); leptonic_fitter_algebraic_object = this; // set the function in the functor pointing back to this object. Doubtfull that all this redirection is needed... _mini->SetTolerance( _tolerance ); bool OK = _mini->SetLimitedVariable( 0, "sB", 1.0, 0.4, 0.1, 6.0 ); //bool OK = _mini->SetVariable( 0, "sB", 1.0, 0.4 ); if( ! OK ) {cerr<<"minimizer (@lfa) failed to SetVariable."<<endl; return false;} // define 1 sigma in terms of the function _mini->SetErrorDef( 0.5 ); // since this is a likelihood fit // do the minimization OK = _mini->Minimize(); if( _dbg > 19 && ( ! OK || _dbg > 59 ) ) cout<<"DBG INFO: initial fit @lfa returned OK: "<<OK<<", has status: "<<_mini->Status()<<endl; _converged = OK; // use status somehow? depends on fitter? // read parameters const double *xs = _mini->X(); for( int ip = 0; ip < 1; ++ip ) _params[ ip ] = xs[ ip ]; // return all intermediate results to the minimum, in particular, the discriminant calc_MLL( _params, true ); TMatrixD nu_vec( _Emat, TMatrixD::kMult, _tvec ); update_nu_and_decay_chain( nu_vec ); if( _dbg > 203 ) cout<<"DBG204 lfa finalized _genN: "<<lv2str(_genN)<<", _W: "<<lv2str(_W)<<", & _t: "<<lv2str(_T)<<endl; _MLL = _mini->MinValue(); return true; }
void polGen(double rapdilepton_min = 1, double rapdilepton_max = 1, double pTdilepton_min = 1, double pTdilepton_max = 1, double mass_signal_peak = 1, double mass_signal_sigma = 1, double n_sigmas_signal = 1, int n_events = 50000, double f_BG = 0.5, double lambda_theta_sig=1, double lambda_phi_sig=1, double lambda_thetaphi_sig=1, double lambda_theta_bkg=1, double lambda_phi_bkg=1, double lambda_thetaphi_bkg=1, int frameSig=1,//CS...1, HX...2, PX...3 int frameBkg=1,//CS...1, HX...2, PX...3 int nGen=1, Char_t *dirstruct = "ToyDirectory_Default" ){ char frameSigName[200]; if(frameSig==1)sprintf(frameSigName,"CS"); if(frameSig==2)sprintf(frameSigName,"HX"); if(frameSig==3)sprintf(frameSigName,"PX"); char frameBkgName[200]; if(frameBkg==1)sprintf(frameBkgName,"CS"); if(frameBkg==2)sprintf(frameBkgName,"HX"); if(frameBkg==3)sprintf(frameBkgName,"PX"); if(frameSig==2) HX_is_natural_sig=true; if(frameSig==3) PX_is_natural_sig=true; //else CS is the natural frame by default if(frameBkg==2) HX_is_natural_bkg=true; if(frameBkg==3) PX_is_natural_bkg=true; //else CS is the natural frame by default cout<<"Number of Events to be generated ........... "<<n_events<<endl; cout<<"pT min ..................................... "<<pTdilepton_min<<endl; cout<<"pT max ..................................... "<<pTdilepton_max<<endl; cout<<"Rapidity min ............................... "<<rapdilepton_min<<endl; cout<<"Rapidity max ............................... "<<rapdilepton_max<<endl; cout<<"Background Fraction ........................ "<<f_BG<<endl; cout<<"Injected lambda_theta Signal ............... "<<lambda_theta_sig<<" , in the "<<frameSigName<<" frame"<<endl; cout<<"Injected lambda_phi Signal ................. "<<lambda_phi_sig<<" , in the "<<frameSigName<<" frame"<<endl; cout<<"Injected lambda_thetaphi Signal ............ "<<lambda_thetaphi_sig<<" , in the "<<frameSigName<<" frame"<<endl; cout<<"Injected lambda_theta Background............ "<<lambda_theta_bkg<<" , in the "<<frameBkgName<<" frame"<<endl; cout<<"Injected lambda_phi Background ............. "<<lambda_phi_bkg<<" , in the "<<frameBkgName<<" frame"<<endl; cout<<"Injected lambda_thetaphi Background ........ "<<lambda_thetaphi_bkg<<" , in the "<<frameBkgName<<" frame"<<endl; cout<<"Number of Generation ....................... "<<nGen<<endl; cout<<"Directory Structure of Output .............. "<<dirstruct<<endl; double mass_min = mass_signal_peak - n_sigmas_signal*mass_signal_sigma; double mass_max = mass_signal_peak + n_sigmas_signal*mass_signal_sigma; char outfilename [500]; sprintf(outfilename,"%s/genData.root",dirstruct); gROOT->Reset(); delete gRandom; gRandom = new TRandom3(0); TF1* pT_distr = new TF1("pT_distr",func_pT_gen,pTdilepton_min,pTdilepton_max,0); TF1* rap_distr = new TF1("rap_distr",func_rap_gen,rapdilepton_min,rapdilepton_max,0); TFile* hfileout = new TFile(outfilename, "RECREATE", "genData"); TTree* genData = new TTree("genData","genData"); // Structure of output ntuple TLorentzVector* lepP = new TLorentzVector(0.,0.,0.,0.); genData->Branch("lepP","TLorentzVector",&lepP); TLorentzVector* lepN = new TLorentzVector(0.,0.,0.,0.); genData->Branch("lepN","TLorentzVector",&lepN); double costh_CS; genData->Branch("costh_CS", &costh_CS, "costh_CS/D"); double phi_CS; genData->Branch("phi_CS", &phi_CS, "phi_CS/D" ); double phith_CS; genData->Branch("phith_CS", &phith_CS, "phith_CS/D"); double costh_HX; genData->Branch("costh_HX", &costh_HX, "costh_HX/D"); double phi_HX; genData->Branch("phi_HX", &phi_HX, "phi_HX/D" ); double phith_HX; genData->Branch("phith_HX", &phith_HX, "phith_HX/D"); double costh_PX; genData->Branch("costh_PX", &costh_PX, "costh_PX/D"); double phi_PX; genData->Branch("phi_PX", &phi_PX, "phi_PX/D" ); double phith_PX; genData->Branch("phith_PX", &phith_PX, "phith_PX/D"); double cosalpha; genData->Branch("cosalpha", &cosalpha, "cosalpha/D"); double pT; genData->Branch("pT", &pT, "pT/D" ); double rap; genData->Branch("rap", &rap, "rap/D" ); double mass; genData->Branch("mass", &mass, "mass/D"); double deltaHXCS; genData->Branch("deltaHXCS", &deltaHXCS, "deltaHXCS/D"); int isBG; genData->Branch("isBG", &isBG, "isBG/I"); // extremes and binning of lambda_gen extraction histos const double l_min = -1; const double l_max = 1; const double l_step_1D = 0.02; TH1D* h_costh2_CS = new TH1D( "h_costh2_CS", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_cos2ph_CS = new TH1D( "h_cos2ph_CS", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_sin2thcosph_CS = new TH1D( "h_sin2thcosph_CS", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_costh2_HX = new TH1D( "h_costh2_HX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_cos2ph_HX = new TH1D( "h_cos2ph_HX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_sin2thcosph_HX = new TH1D( "h_sin2thcosph_HX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_costh2_PX = new TH1D( "h_costh2_PX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_cos2ph_PX = new TH1D( "h_cos2ph_PX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); TH1D* h_sin2thcosph_PX = new TH1D( "h_sin2thcosph_PX", "", int((l_max-l_min)/l_step_1D), l_min, l_max ); double costh2; double cos2ph; double sin2thcosph; double Phi; const int n_step = n_events/5; int n_step_=1; cout << endl; cout << "Generating " << n_events << " dilepton events"<< endl; cout << "------------------------------------------------------------" << endl; cout << "Progress: "<<endl; /////////////////// CYCLE OF EVENTS //////////////////////// for(int i_event = 1; i_event <= n_events; i_event++){ if (i_event%n_step == 0) {cout << n_step_*20 <<" % "<<endl; n_step_++;} // generation of dilepton in the pp event in the pp CM // mass isBG = 0; if ( gRandom->Uniform() < f_BG ) { mass = gRandom->Uniform(mass_min, mass_max); isBG = 1; } else { do { mass = gRandom->Gaus(mass_signal_peak, mass_signal_sigma); } while ( mass < mass_min || mass > mass_max ); } // pT: pT = pT_distr->GetRandom(); // pL: double rap_sign = gRandom->Uniform(-1., 1.); rap_sign /= TMath::Abs(rap_sign); rap = rap_distr->GetRandom() * rap_sign; double mT = sqrt( mass*mass + pT*pT ); double pL1 = 0.5 *mT * exp(rap); double pL2 = - 0.5 *mT * exp(-rap); double pL = pL1 + pL2; // Phi: double Phi = 2. * gPI * gRandom->Uniform(1.); // 4-vector: TLorentzVector dilepton; dilepton.SetXYZM( pT * cos(Phi) , pT * sin(Phi), pL, mass ); // generation of polarization (generic reference frame) double lambda_theta = lambda_theta_sig; double lambda_phi = lambda_phi_sig; double lambda_thetaphi = lambda_thetaphi_sig; bool HX_is_natural = HX_is_natural_sig; bool PX_is_natural = PX_is_natural_sig; if ( isBG ) { lambda_theta = lambda_theta_bkg; lambda_phi = lambda_phi_bkg; lambda_thetaphi = lambda_thetaphi_bkg; HX_is_natural = HX_is_natural_bkg; PX_is_natural = PX_is_natural_bkg; } double costhphidistr_max = 1. + TMath::Abs(lambda_phi) + TMath::Abs(lambda_thetaphi); double costhphidistr_rnd; double costhphidistr; double costh_gen; double sinth_gen; double phi_gen; if ( lambda_theta > 0. ) costhphidistr_max += lambda_theta; do { costh_gen = -1. + 2. * gRandom->Uniform(1.); phi_gen = 2. * gPI * gRandom->Uniform(1.); sinth_gen = sqrt( 1. - costh_gen*costh_gen ); costhphidistr_rnd = costhphidistr_max * gRandom->Uniform(1.); costhphidistr = 1. + lambda_theta * costh_gen*costh_gen + lambda_phi * sinth_gen*sinth_gen * cos(2.*phi_gen) + lambda_thetaphi * 2.* sinth_gen*costh_gen * cos(phi_gen); } while ( costhphidistr_rnd > costhphidistr ); // lepton momentum in the dilepton rest frame: double p_lepton_DILEP = sqrt( 0.25*mass*mass - Mlepton*Mlepton ); TLorentzVector lepton_DILEP; lepton_DILEP.SetXYZM( p_lepton_DILEP * sinth_gen * cos(phi_gen), p_lepton_DILEP * sinth_gen * sin(phi_gen), p_lepton_DILEP * costh_gen, Mlepton ); // reference directions to calculate angles: TVector3 lab_to_dilep = -dilepton.BoostVector(); TLorentzVector beam1_DILEP = beam1_LAB; beam1_DILEP.Boost(lab_to_dilep); // beam1 in the dilepton rest frame TLorentzVector beam2_DILEP = beam2_LAB; beam2_DILEP.Boost(lab_to_dilep); // beam2 in the dilepton rest frame TVector3 beam1_direction = beam1_DILEP.Vect().Unit(); TVector3 beam2_direction = beam2_DILEP.Vect().Unit(); TVector3 dilep_direction = dilepton.Vect().Unit(); TVector3 beam1_beam2_bisect = ( beam1_direction - beam2_direction ).Unit(); deltaHXCS = dilep_direction.Angle(beam1_beam2_bisect) * 180./gPI; // all polarization frames have the same Y axis = the normal to the plane formed by // the directions of the colliding hadrons TVector3 Yaxis = ( beam1_direction.Cross( beam2_direction ) ).Unit(); // flip of y axis with rapidity if ( rap < 0 ) Yaxis = - Yaxis; TVector3 perpendicular_to_beam = ( beam1_beam2_bisect.Cross( Yaxis ) ).Unit(); // step 1: transform (rotation) lepton momentum components from generation frame // to the frame with x,y,z axes as in the laboratory TVector3 oldZaxis = beam1_beam2_bisect; if ( HX_is_natural ) oldZaxis = dilep_direction; if ( PX_is_natural ) oldZaxis = perpendicular_to_beam; TVector3 oldYaxis = Yaxis; TVector3 oldXaxis = oldYaxis.Cross(oldZaxis); TRotation rotation; rotation.RotateAxes(oldXaxis, oldYaxis, oldZaxis); // transforms coordinates from the "old" frame to the "xyz" frame TLorentzVector lepton_DILEP_xyz = lepton_DILEP; lepton_DILEP_xyz.Transform(rotation); // lepton_DILEP_xyz is the lepton in the dilepton rest frame // wrt to the lab axes // lepton 4-vectors in the LAB frame: TVector3 dilep_to_lab = dilepton.BoostVector(); *lepP = lepton_DILEP_xyz; lepP->Boost(dilep_to_lab); lepN->SetPxPyPzE(-lepton_DILEP_xyz.Px(),-lepton_DILEP_xyz.Py(),-lepton_DILEP_xyz.Pz(),lepton_DILEP_xyz.E()); lepN->Boost(dilep_to_lab); ///////////////////////////////////////////////////////////////////// // CS frame TVector3 newZaxis = beam1_beam2_bisect; TVector3 newYaxis = Yaxis; TVector3 newXaxis = newYaxis.Cross( newZaxis ); rotation.SetToIdentity(); rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); rotation.Invert(); // transforms coordinates from the "xyz" frame to the new frame TVector3 lepton_DILEP_rotated = lepton_DILEP_xyz.Vect(); lepton_DILEP_rotated.Transform(rotation); costh_CS = lepton_DILEP_rotated.CosTheta(); phi_CS = lepton_DILEP_rotated.Phi() * 180. / gPI; if ( costh_CS < 0. ) phith_CS = phi_CS - 135.; if ( costh_CS > 0. ) phith_CS = phi_CS - 45.; if ( phith_CS < -180. ) phith_CS = 360. + phith_CS; ///////////////////////////////////////////////////////////////////// // HELICITY frame newZaxis = dilep_direction; newYaxis = Yaxis; newXaxis = newYaxis.Cross( newZaxis ); rotation.SetToIdentity(); rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); rotation.Invert(); lepton_DILEP_rotated = lepton_DILEP_xyz.Vect(); lepton_DILEP_rotated.Transform(rotation); costh_HX = lepton_DILEP_rotated.CosTheta(); phi_HX = lepton_DILEP_rotated.Phi() * 180. / gPI; if ( costh_HX < 0. ) phith_HX = phi_HX - 135.; if ( costh_HX > 0. ) phith_HX = phi_HX - 45.; if ( phith_HX < -180. ) phith_HX = 360. + phith_HX; ///////////////////////////////////////////////////////////////////// // PERPENDICULAR HELICITY frame newZaxis = perpendicular_to_beam; newYaxis = Yaxis; newXaxis = newYaxis.Cross( newZaxis ); rotation.SetToIdentity(); rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); rotation.Invert(); lepton_DILEP_rotated = lepton_DILEP_xyz.Vect(); lepton_DILEP_rotated.Transform(rotation); costh_PX = lepton_DILEP_rotated.CosTheta(); phi_PX = lepton_DILEP_rotated.Phi() * 180. / gPI; if ( costh_PX < 0. ) phith_PX = phi_PX - 135.; if ( costh_PX > 0. ) phith_PX = phi_PX - 45.; if ( phith_PX < -180. ) phith_PX = 360. + phith_PX; ///////////////////////////////////////////////////////////////////// // invariant polarization angle cosalpha = sqrt( 1. - pow(costh_PX, 2.) ) * sin( lepton_DILEP_rotated.Phi() ); ////// Filling Histograms of costh2, cos2ph and sin2thcosph for the extraction of the actual generated polarization if ( !isBG ){ costh2=pow(costh_CS,2.); Phi = phi_CS/180. * gPI ; cos2ph = cos(2.*Phi); sin2thcosph= sin(2.*acos(costh_CS))*cos(Phi); h_costh2_CS->Fill( costh2 ); h_cos2ph_CS->Fill( cos2ph ); h_sin2thcosph_CS->Fill( sin2thcosph ); costh2=pow(costh_HX,2.); Phi = phi_HX/180. * gPI ; cos2ph = cos(2.*Phi); sin2thcosph= sin(2.*acos(costh_HX))*cos(Phi); h_costh2_HX->Fill( costh2 ); h_cos2ph_HX->Fill( cos2ph ); h_sin2thcosph_HX->Fill( sin2thcosph ); costh2=pow(costh_PX,2.); Phi = phi_PX/180. * gPI ; cos2ph = cos(2.*Phi); sin2thcosph= sin(2.*acos(costh_PX))*cos(Phi); h_costh2_PX->Fill( costh2 ); h_cos2ph_PX->Fill( cos2ph ); h_sin2thcosph_PX->Fill( sin2thcosph ); } // filling of the ntuple: genData->Fill(); } // end of external loop (generated events) cout << endl; double lamth_CS; double lamph_CS; double lamtp_CS; costh2=h_costh2_CS->GetMean(); lamth_CS = (1. - 3. * costh2 ) / ( costh2 - 3./5. ); cos2ph=h_cos2ph_CS->GetMean(); lamph_CS = cos2ph * (3. + lamth_CS); sin2thcosph=h_sin2thcosph_CS->GetMean(); lamtp_CS = sin2thcosph * 5./4. * (3. + lamth_CS); double lamth_HX; double lamph_HX; double lamtp_HX; costh2=h_costh2_HX->GetMean(); lamth_HX = (1. - 3. * costh2 ) / ( costh2 - 3./5. ); cos2ph=h_cos2ph_HX->GetMean(); lamph_HX = cos2ph * (3. + lamth_HX); sin2thcosph=h_sin2thcosph_HX->GetMean(); lamtp_HX = sin2thcosph * 5./4. * (3. + lamth_HX); double lamth_PX; double lamph_PX; double lamtp_PX; costh2=h_costh2_PX->GetMean(); lamth_PX = (1. - 3. * costh2 ) / ( costh2 - 3./5. ); cos2ph=h_cos2ph_PX->GetMean(); lamph_PX = cos2ph * (3. + lamth_PX); sin2thcosph=h_sin2thcosph_PX->GetMean(); lamtp_PX = sin2thcosph * 5./4. * (3. + lamth_PX); char resfilename[200]; sprintf(resfilename,"%s/GenResults.root",dirstruct); TFile* GenResultFile = new TFile(resfilename, "RECREATE", "GenResultFile"); TTree* GenResults = new TTree("GenResults","GenResults"); GenResults->Branch("lthCS", &lamth_CS, "lthCS/D"); GenResults->Branch("lphCS", &lamph_CS, "lphCS/D"); GenResults->Branch("ltpCS", &lamtp_CS, "ltpCS/D"); GenResults->Branch("lthHX", &lamth_HX, "lthHX/D"); GenResults->Branch("lphHX", &lamph_HX, "lphHX/D"); GenResults->Branch("ltpHX", &lamtp_HX, "ltpHX/D"); GenResults->Branch("lthPX", &lamth_PX, "lthPX/D"); GenResults->Branch("lphPX", &lamph_PX, "lphPX/D"); GenResults->Branch("ltpPX", &lamtp_PX, "ltpPX/D"); GenResults->Fill(); GenResultFile->Write(); GenResultFile->Close(); hfileout->Write(); hfileout->Close(); } // end of main
double KinUtils::doElasticRecoil(const TLorentzVector &chi, TLorentzVector &recoil, TLorentzVector &recoil_chi, const int &procID) { TVector3 v0, v1, v2; TVector3 p0, pr, pchi; double E0, Er, Echi; double Tr_max; //this is the maximum recoil KINETIC energy for this incoming chi double P0, Pr, Pchi; double ctheta_r, stheta_r, phi_r, sigma; int ii; E0 = chi.E(); P0 = chi.P(); p0 = chi.Vect(); /*1: extract the recoil total energy from the cross-section*/ ii = 0; ii = (int) (E0 / (Ebeam / nFunctionsElastic)); if (ii >= nFunctionsElastic) ii = nFunctionsElastic - 1; //should not happen!!! if (procID == Proc_Pelastic) { Tr_max = (2 * Mn * (E0 * E0 - Mchi * Mchi)) / (2 * E0 * Mn + Mn * Mn + Mchi * Mchi); //maximum energy transfer if (Tr_max < (Pthr + Pbinding)) return 0; //this event is not compatible with the threshold, it is useless to proceed further } else if (procID == Proc_Eelastic) { Tr_max = (2 * Me * (E0 * E0 - Mchi * Mchi)) / (2 * E0 * Me + Me * Me + Mchi * Mchi); //maximum energy transfer if (Tr_max < Ethr) { //cout<<"THR IS: "<<Ethr<<" "<<Tr_max<<" "<<E0<<endl; return 0; //this event is not compatible with the threshold, it is useless to proceed further } } else if (procID == Proc_Nuclelastic) { Tr_max = (2 * Mnucl * (E0 * E0 - Mchi * Mchi)) / (2 * E0 * Mnucl + Mnucl * Mnucl + Mchi * Mchi); //maximum energy transfer if (Tr_max < Nuclthr) { //cout<<"THR IS: "<<Ethr<<" "<<Tr_max<<" "<<E0<<endl; return 0; //this event is not compatible with the threshold, it is useless to proceed further } } if (procID == Proc_Pelastic) { Er = f_chipXsection[ii]->GetRandom(Pthr + Pbinding + Mn, Tr_max + Mn); } else if (procID == Proc_Eelastic) { Er = f_chieXsection[ii]->GetRandom(Ethr + Me, Tr_max + Me); } else if (procID == Proc_Nuclelastic) { Er = f_chinuclXsection[ii]->GetRandom(Nuclthr, Tr_max); //Here the variable is the KINETIC energy of the recoiling nucleus Er = Er + Mnucl; } /*1a: correct the proton energy for binding effects*/ if (procID == Proc_Pelastic) { Er = Er - Pbinding; /*Effective binding energy correction*/ } /*1b: compute x-section total . No time consuming, since integrals are cached!*/ if (procID == Proc_Pelastic) { sigma = f_chipXsection[ii]->Integral(Pthr + Pbinding + Mn, Tr_max + Mn); } else if (procID == Proc_Eelastic) { sigma = f_chieXsection[ii]->Integral(Ethr + Me, Tr_max + Me); } else if (procID == Proc_Nuclelastic) { sigma = f_chinuclXsection[ii]->Integral(Nuclthr, Tr_max); //Has to be integrated in this range since the variable is the KINETIC energy here (and not the total as before) } /*2: compute recoil chi TOTAL energy*/ if (procID == Proc_Pelastic) { Echi = E0 + Mn - Er; } else if (procID == Proc_Eelastic) { Echi = E0 + Me - Er; } else if (procID == Proc_Nuclelastic) { Echi = E0 + Mnucl - Er; } /*3: compute the momenta*/ Pchi = sqrt(Echi * Echi - Mchi * Mchi); if (procID == Proc_Pelastic) { Pr = sqrt(Er * Er - Mn * Mn); } else if (procID == Proc_Eelastic) { Pr = sqrt(Er * Er - Me * Me); } else if (procID == Proc_Nuclelastic) { Pr = sqrt(Er * Er - Mnucl * Mnucl); } /*4: compute the angle of the recoil nucleon wrt the initial chi momentum direction*/ if (procID == Proc_Pelastic) { ctheta_r = E0 * E0 - Echi * Echi + Er * Er - Mn * Mn; ctheta_r /= 2 * P0 * Pr; } else if (procID == Proc_Eelastic) { ctheta_r = E0 * E0 - Echi * Echi + Er * Er - Me * Me; ctheta_r /= 2 * P0 * Pr; } else if (procID == Proc_Nuclelastic) { ctheta_r = E0 * E0 - Echi * Echi + Er * Er - Mnucl * Mnucl; ctheta_r /= 2 * P0 * Pr; } if (ctheta_r > 1) ctheta_r = 1; if (ctheta_r < -1) ctheta_r = -1; stheta_r = sqrt(1 - ctheta_r * ctheta_r); /*5: The azimuthal angle (around the incoming chi momentum direction) is flat*/ phi_r = Rand.Uniform(-PI, PI); /*6: Now set the 4-vectors*/ /*6a: build an orthogonal coordinate system, with v0 along the initial chi momentum direction*/ v0 = chi.Vect().Unit(); v1 = v0.Orthogonal(); v1 = v1.Unit(); v2 = v0.Cross(v1); //v2 = v0 x v1 /*write the 3-momenta*/ pr = v0 * Pr * ctheta_r + v1 * Pr * stheta_r * sin(phi_r) + v2 * Pr * stheta_r * cos(phi_r); pchi = p0 - pr; /*6b:Set them */ recoil.SetVect(pr); recoil.SetE(Er); recoil_chi.SetVect(pchi); recoil_chi.SetE(Echi); return sigma; }
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 test_allEvt::ComputeAllVarPietro(TLorentzVector lepP,TLorentzVector lepN){ // Preliminary definitions: const double pbeam = 7000.; // exact number irrelevant as long as pbeam >> Mprot const double Mprot = 0.9382720; const double Mlepton = 0.10566; // (muon) const double gPI = TMath::Pi(); const double Ebeam = sqrt( pbeam*pbeam + Mprot*Mprot ); TLorentzVector beam1_LAB( 0., 0., pbeam, Ebeam ); TLorentzVector beam2_LAB( 0., 0., -pbeam, Ebeam ); // assuming that we have a TTree "data" (data ntuple) containing the 4-vectors lepP and lepN of lepton and antilepton // event by event (in some loop over dilepton events in the data ntuple): // data->GetEvent( i_event ); // double lepP_pT = lepP->Pt(); // double lepN_pT = lepN->Pt(); // double lepP_eta = lepP->PseudoRapidity(); // double lepN_eta = lepN->PseudoRapidity(); // dilepton 4-vector: TLorentzVector dilepton = lepP + lepN; double pT = dilepton.Pt(); double rap = dilepton.Rapidity(); double mass = dilepton.M(); // calculation of decay angles in three polarization frames // reference directions to calculate angles: TVector3 lab_to_dilep = -dilepton.BoostVector(); TLorentzVector beam1_DILEP = beam1_LAB; beam1_DILEP.Boost(lab_to_dilep); // beam1 in the dilepton rest frame TLorentzVector beam2_DILEP = beam2_LAB; beam2_DILEP.Boost(lab_to_dilep); // beam2 in the dilepton rest frame TVector3 beam1_direction = beam1_DILEP.Vect().Unit(); TVector3 beam2_direction = beam2_DILEP.Vect().Unit(); TVector3 dilep_direction = dilepton.Vect().Unit(); TVector3 beam1_beam2_bisect = ( beam1_direction - beam2_direction ).Unit(); // all polarization frames have the same Y axis = the normal to the plane formed by // the directions of the colliding hadrons: TVector3 Yaxis = ( beam1_direction.Cross( beam2_direction ) ).Unit(); // flip of y axis with rapidity: if ( rap < 0. ) Yaxis = - Yaxis; TVector3 perpendicular_to_beam = ( beam1_beam2_bisect.Cross( Yaxis ) ).Unit(); // positive lepton in the dilepton rest frame: TLorentzVector lepton_DILEP = lepP; lepton_DILEP.Boost(lab_to_dilep); // CS frame angles: TVector3 newZaxis = beam1_beam2_bisect; TVector3 newYaxis = Yaxis; TVector3 newXaxis = newYaxis.Cross( newZaxis ); TRotation rotation; rotation.SetToIdentity(); rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); rotation.Invert(); // transforms coordinates from the "xyz" frame to the new frame TVector3 lepton_DILEP_rotated = lepton_DILEP.Vect(); lepton_DILEP_rotated.Transform(rotation); /* double */ costh_CS = lepton_DILEP_rotated.CosTheta(); /* double */ phi_CS = lepton_DILEP_rotated.Phi() * 180. / gPI; double phith_CS; if ( costh_CS < 0. ) phith_CS = phi_CS - 135.; if ( costh_CS > 0. ) phith_CS = phi_CS - 45.; if ( phith_CS < -180. ) phith_CS = 360. + phith_CS; phi_CS = phi_CS / 180. * gPI; // HELICITY frame angles: newZaxis = dilep_direction; newYaxis = Yaxis; newXaxis = newYaxis.Cross( newZaxis ); rotation.SetToIdentity(); rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); rotation.Invert(); lepton_DILEP_rotated = lepton_DILEP.Vect(); lepton_DILEP_rotated.Transform(rotation); /* double */ costh_HX = lepton_DILEP_rotated.CosTheta(); /* double */ phi_HX = lepton_DILEP_rotated.Phi() * 180. / gPI; double phith_HX; if ( costh_HX < 0. ) phith_HX = phi_HX - 135.; if ( costh_HX > 0. ) phith_HX = phi_HX - 45.; if ( phith_HX < -180. ) phith_HX = 360. + phith_HX; phi_HX = phi_HX / 180. * gPI; // // PERPENDICULAR HELICITY frame angles: // newZaxis = perpendicular_to_beam; // newYaxis = Yaxis; // newXaxis = newYaxis.Cross( newZaxis ); // rotation.SetToIdentity(); // rotation.RotateAxes( newXaxis, newYaxis, newZaxis ); // rotation.Invert(); // lepton_DILEP_rotated = lepton_DILEP.Vect(); // lepton_DILEP_rotated.Transform(rotation); // double costh_PX = lepton_DILEP_rotated.CosTheta(); // double phi_PX = lepton_DILEP_rotated.Phi() * 180. / gPI; // double phith_PX; // if ( costh_PX < 0. ) phith_PX = phi_PX - 135.; // if ( costh_PX > 0. ) phith_PX = phi_PX - 45.; // if ( phith_PX < -180. ) phith_PX = 360. + phith_PX; // phi_PX = phi_PX / 180. * gPI; }