void dR(){ gROOT->Reset(); gStyle->SetOptStat(1); ifstream dataphi; ifstream dataeta; float etaRPC; float etaCSC; float phiRPC; float phiCSC; dataphi.open("phi.txt"); dataeta.open("eta.txt"); std::string name = "dR"; float pi = 3.14159265; float dphi = 0; float deta = 0; TH1F * histo = new TH1F("histo",name.c_str(),1000,0,0.5); TH2F * histo2D = new TH2F("histo2D",name.c_str(),400,-0.2,0.2,400,-0.2,0.2); while(!dataphi.eof()){ dataphi >>phiRPC>>phiCSC; dataeta >>etaRPC>>etaCSC; dphi = phiRPC-phiCSC; deta = etaRPC-etaCSC; histo->Fill(sqrt(dphi*dphi+deta*deta)); histo2D->Fill(dphi,deta); } TFile * theFile = new TFile("dR.root","RECREATE"); theFile->cd(); TCanvas * Ca0 = new TCanvas("Ca0","Canvas",1200,800); /* histo->SetLineWidth(3); histo->Draw(); histo->SetMaximum(histo->GetMaximumStored()); histo->GetXaxis()->SetTitle(name.c_str());*/ gStyle->SetPalette(1); histo2D->GetXaxis()->SetTitle("dPhi"); histo2D->GetYaxis()->SetTitle("dEta"); histo2D->Draw(); histo2D->SetDrawOption("color"); histo2D->Write(); Ca0->SaveAs((name+".png").c_str()); theFile->Save(); theFile->Close(); }
void scatterPloteta(){ gROOT->Reset(); gStyle->SetOptStat(1); ifstream data; float valueX; float valueY; string name = "eta"; data.open((name+".txt").c_str()); TH2F * histo = new TH2F("histo",name.c_str(),1000,-2.4,2.4,100,-2.4,2.4); //eta TH1F * histo1D = new TH1F("histo1D",name.c_str(),1000,-2.4,2.4); //eta // float pi = 3.14159265; // TH2F * histo = new TH2F("histo",name.c_str(),1000,-1*pi,pi,1000,-1*pi,pi); //phi // TH1F * histo1D = new TH1F("histo1D",name.c_str(),1000,-1*pi,pi); //phi while(!data.eof()){ data >>valueX>>valueY; cout<<valueX<<" "<<valueY<<endl; histo->Fill(valueX,valueY); histo1D->Fill(valueX-valueY); } TCanvas * Ca0 = new TCanvas("Ca0","Canvas",1200,800); histo->SetLineWidth(3); TFile * theFile = new TFile("eta.root","RECREATE"); theFile->cd(); histo->Draw(); histo1D->DrawNormalized("same"); histo->GetXaxis()->SetTitle(("RPC"+name).c_str()); histo->GetYaxis()->SetTitle(("CSC"+name).c_str()); Ca0->SaveAs((name+".png").c_str()); histo1D->Write(); histo->Write(); theFile->Save(); theFile->Close(); }
void DalitzplotXi1820_XiPlus_lambda_k(){ //*** Data input TString inputFile = "/home/ikp1/puetz/panda/mysimulations/analysis/XiPlus_Lambda_K/output_ana.root"; TFile * data = new TFile(inputFile, "READ"); TString outPath = "/home/ikp1/puetz/panda/mysimulations/analysis/XiPlus_Lambda_K/plots"; TFile * out = new TFile(outPath+"/root-files/Dalitzplot_MC.root", "RECREATE"); TTree * sim = (TTree*) data->Get("ntpMC"); int nevents = sim->GetEntriesFast(); TH2D * dalitz_Xilk = new TH2D("dalitz_Xilk", "Dalitz plot for MC; m^{2}(#Lambda^{0},K^{-})/GeV^{2}/c^{4}; m^{2}(#bar{#Xi}, K^{-})/GeV^{2}/c^{4}", 150,2.5,3.8,150,3.2,4.8); gStyle->SetOptStat(0); TLorentzVector lXi, lk, lla, lXi1820; TLorentzVector PXiK, PlaK, PXil; for (int n=0; n<nevents; n++){ sim->GetEntry(n); double Eaxi = sim->GetLeaf("e")->GetValue(xi); double Ek = sim->GetLeaf("e")->GetValue(kaon); double Ela = sim->GetLeaf("e")->GetValue(lambda0); double Pxaxi = sim->GetLeaf("px")->GetValue(xi); double Pxk = sim->GetLeaf("px")->GetValue(kaon); double Pxla = sim->GetLeaf("px")->GetValue(lambda0); double Pyaxi = sim->GetLeaf("py")->GetValue(xi); double Pyk = sim->GetLeaf("py")->GetValue(kaon); double Pyla = sim->GetLeaf("py")->GetValue(lambda0); double Pzaxi = sim->GetLeaf("pz")->GetValue(xi); double Pzk = sim->GetLeaf("pz")->GetValue(kaon); double Pzla = sim->GetLeaf("pz")->GetValue(lambda0); lXi.SetPxPyPzE(Pxaxi, Pyaxi, Pzaxi, Eaxi); lk.SetPxPyPzE(Pxk, Pyk, Pzk, Ek); lla.SetPxPyPzE(Pxla, Pyla, Pzla, Ela); PXiK = lXi + lk; PlaK = lla + lk; PXil = lXi + lla; dalitz_Xilk->Fill(PlaK.M2(),PXiK.M2()); } setPandaStyle(); out->cd(); dalitz_Xilk->Write(); out->Save(); TCanvas * c = new TCanvas("c", "Dalitz plot PHSP model", 0,0,1500,1000); dalitz_Xilk->Draw("COLZ"); PandaSmartLabel("L"); //****write histograms c->Print(outPath+"/png-files/Dalitzplots_MC.png"); c->Print(outPath+"/pdf-files/Dalitzplots_MC.pdf"); }
void analysis_pbarp_Xi_test(int nevts=0){ TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888); TStopwatch timer; //Output File TString Path = "/private/puetz/mysimulations/analysis/pbarp_Xiplus_Ximinus/idealtracking/10000_events/"; TString outPath = Path; TString OutputFile = outPath + "analysis_output_test.root"; //Input simulation Files TString inPIDFile = Path + "pid_complete.root"; TString inParFile = Path + "simparams.root"; TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par"; //Initialization FairLogger::GetLogger()->SetLogToFile(kFALSE); FairRunAna* RunAna = new FairRunAna(); FairRuntimeDb* rtdb = RunAna->GetRuntimeDb(); RunAna->SetInputFile(inPIDFile); //setup parameter database FairParRootFileIo* parIo = new FairParRootFileIo(); parIo->open(inParFile); FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo(); parIoPID->open(PIDParFile.Data(),"in"); rtdb->setFirstInput(parIo); rtdb->setSecondInput(parIoPID); rtdb->setOutput(parIo); RunAna->SetOutputFile(OutputFile); RunAna->Init(); //*** create tuples RhoTuple * ntpMC = new RhoTuple("ntpMC", "MCTruth info"); RhoTuple * ntpPiMinus = new RhoTuple("ntpPiMinus", "PiMinus info"); RhoTuple * ntpPiPlus = new RhoTuple("ntpPiPlus", "PiPlus info"); RhoTuple * ntpProton = new RhoTuple("ntpProton", "Proton info"); RhoTuple * ntpAntiProton = new RhoTuple("ntpAntiProton", "Antiproton info"); RhoTuple * ntpLambda0 = new RhoTuple("ntpLambda0", "Lambda0 info"); RhoTuple * ntpAntiLambda0 = new RhoTuple("ntpAntiLambda0", "AntiLambda0 info"); RhoTuple * ntpXiMinus = new RhoTuple("ntpXiMinus", "XiMinus info"); RhoTuple * ntpXiPlus = new RhoTuple("ntpXiPlus", "XiPlus info"); RhoTuple * ntpXiSys = new RhoTuple("ntpXiSys", "XiMinus XiPlus system info"); //Create output file TFile *out = TFile::Open(outPath+"output_ana_test.root","RECREATE"); // data reader Object PndAnalysis* theAnalysis = new PndAnalysis(); if (nevts==0) nevts = theAnalysis->GetEntries(); //RhoCandLists for analysis RhoCandList piplus, piminus, lambda0, antiLambda0, proton, antiProton, xiplus, ximinus, xiSys; RhoCandList NotCombinedPiMinus, CombinedPiMinus, CombinedPiPlus, NotCombinedPiPlus; RhoCandList SelectedProton, SelectedAntiProton, SelectedPiMinus, SelectedPiPlus; RhoCandList Lambda0Fit, AntiLambda0Fit, XiMinusFit, XiPlusFit; RhoCandList mclist, all; //Dummy RhoCandidate RhoCandidate * dummyCand = new RhoCandidate(); //***Mass selector double m0_lambda0= TDatabasePDG::Instance()->GetParticle("Lambda0")->Mass(); cout<<"Mass of Lambda0: "<<m0_lambda0<<endl; RhoMassParticleSelector * lambdaMassSelector = new RhoMassParticleSelector("lambda0", m0_lambda0, 0.3); double m0_Xi = TDatabasePDG::Instance()->GetParticle("Xi-")->Mass(); cout<<"Mass of Xi-: "<<m0_Xi<<endl; RhoMassParticleSelector * xiMassSelector = new RhoMassParticleSelector("Xi-", m0_Xi, 0.3); double m0_pbarpsystem = TDatabasePDG::Instance()->GetParticle("pbarpSystem")->Mass(); double pbarmom = 2.7; double p_m0 = TDatabasePDG::Instance()->GetParticle("proton")->Mass(); TLorentzVector ini (0,0, pbarmom, sqrt(p_m0*p_m0+ pbarmom*pbarmom)+p_m0); TVector3 beamBoost = ini.BoostVector(); PndRhoTupleQA qa(theAnalysis, pbarmom); int evt=-1; int index=0; while (theAnalysis->GetEvent() && ++evt<nevts){ if ((evt%100)==0) cout << "evt "<< evt <<endl; cout << "Running event " << evt << endl; //***get MC list and store info theAnalysis->FillList(mclist, "McTruth"); qa.qaMcList("", mclist, ntpMC); ntpMC->DumpData(); //if you want to print the hole MCTree uncomment the following /* for (int j=0;j<mclist.GetLength();++j) { RhoCandidate *mcmother = mclist[j]->TheMother(); // mother of mc particle int muid = (mcmother==0x0) ? -1 : mcmother->GetTrackNumber(); // track ID of mother, if existing cout << "Track "<< mclist[j]->GetTrackNumber()<<" (PDG:"<<mclist[j]->PdgCode() <<") has mother "<<muid; if (mclist[j]->NDaughters()>0) cout <<" and daughter(s) "; for (k=0;k<mclist[j]->NDaughters();++k) cout <<mclist[j]->Daughter(k)->GetTrackNumber()<<" "; cout<<endl; }*/ //***Setup event shape object TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc"; theAnalysis->FillList(all, "All", PidSelection); PndEventShape evsh(all, ini, 0.05, 0.1); //***Selection with no PID info theAnalysis->FillList(piminus, "PionAllMinus", PidSelection); // theAnalysis->FillList(NotCombinedPiMinus, "PionAllMinus", PidSelection); // theAnalysis->FillList(NotCombinedPiPlus, "PionAllPlus", PidSelection); theAnalysis->FillList(piplus, "PionAllPlus", PidSelection); theAnalysis->FillList(proton, "ProtonAllPlus", PidSelection); theAnalysis->FillList(antiProton, "ProtonAllMinus", PidSelection); for (int pip=0; pip<piplus.GetLength(); ++pip){ ntpPiPlus->Column("ev", (Float_t) evt); ntpPiPlus->Column("cand", (Float_t) pip); ntpPiPlus->Column("ncand", (Float_t) piplus.GetLength()); ntpPiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piplus[pip])); qa.qaP4("PiPlus_", piplus[pip]->P4(), ntpPiPlus); qa.qaCand("PiPlus_", piplus[pip], ntpPiPlus); jenny::numberOfHitsInSubdetector("PiPlus_", piplus[pip], ntpPiPlus); jenny::tagNHits("PiPlus_", piplus[pip], ntpPiPlus); int tag = jenny::tagHits(piplus[pip]); RhoCandidate * mother_pip = piplus[pip]->GetMcTruth()->TheMother(); int moth_pip = (0x0==mother_pip)? 88888 : mother_pip->PdgCode(); ntpPiPlus->Column("Mother", (Float_t) moth_pip); ntpPiPlus->Column("PiPlus_CosTheta", (Float_t) piplus[pip]->GetMomentum().CosTheta()); qa.qaP4("PiPlus_MC_", piplus[pip]->GetMcTruth()->P4(), ntpPiPlus); qa.qaCand("PiPlus_MC_", piplus[pip]->GetMcTruth(), ntpPiPlus); ntpPiPlus->Column("PiPlus_MC_CosTheta", (Float_t) piplus[pip]->GetMcTruth()->GetMomentum().CosTheta()); if(tag==1){ SelectedPiPlus.Append(piplus[pip]); NotCombinedPiPlus.Append(piplus[pip]); } ntpPiPlus->DumpData(); } for (int pim=0; pim<piminus.GetLength(); ++pim){ ntpPiMinus->Column("ev", (Float_t) evt); ntpPiMinus->Column("cand", (Float_t) pim); ntpPiMinus->Column("ncand", (Float_t) piminus.GetLength()); ntpPiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(piminus[pim])); qa.qaP4("piminus_", piminus[pim]->P4(), ntpPiMinus); qa.qaCand("piminus_", piminus[pim], ntpPiMinus); jenny::numberOfHitsInSubdetector("piminus_", piminus[pim], ntpPiMinus); jenny::tagNHits("piminus_", piminus[pim], ntpPiMinus); int tag = jenny::tagHits(piminus[pim]); RhoCandidate * mother_pim = piminus[pim]->GetMcTruth()->TheMother(); int moth_pim = (0x0==mother_pim)? 88888 : mother_pim->PdgCode(); ntpPiMinus->Column("Mother", (Float_t) moth_pim); ntpPiMinus->Column("PiMinus_CosTheta", (Float_t) piminus[pim]->GetMomentum().CosTheta()); qa.qaP4("piminus_MC_", piminus[pim]->GetMcTruth()->P4(), ntpPiMinus); qa.qaCand("piminus_MC_", piminus[pim]->GetMcTruth(), ntpPiMinus); ntpPiMinus->Column("piminus_MC_CosTheta", (Float_t) piminus[pim]->GetMcTruth()->GetMomentum().CosTheta()); ntpPiMinus->DumpData(); if(tag==1){ SelectedPiMinus.Append(piminus[pim]); NotCombinedPiMinus.Append(piminus[pim]); } } for (int prot=0; prot<proton.GetLength(); ++prot){ ntpProton->Column("ev", (Float_t) evt); ntpProton->Column("cand", (Float_t) prot); ntpProton->Column("ncand", (Float_t) proton.GetLength()); ntpProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(proton[prot])); qa.qaP4("proton_", proton[prot]->P4(), ntpProton); qa.qaCand("proton_", proton[prot], ntpProton); jenny::numberOfHitsInSubdetector("proton_", proton[prot], ntpProton); // jenny::tagNHits("proton_", proton[prot], ntpProton); int tag = jenny::tagHits(proton[prot]); RhoCandidate * mother_prot = proton[prot]->GetMcTruth()->TheMother(); int moth_prot = (0x0==mother_prot)? 88888 : mother_prot->PdgCode(); ntpProton->Column("Mother", (Float_t) moth_prot); ntpProton->Column("proton_CosTheta", (Float_t) proton[prot]->GetMomentum().CosTheta()); qa.qaP4("proton_MC_", proton[prot]->GetMcTruth()->P4(), ntpProton); qa.qaCand("proton_", proton[prot]->GetMcTruth(), ntpProton); ntpProton->Column("proton_MC_CosTheta", (Float_t) proton[prot]->GetMcTruth()->GetMomentum().CosTheta()); ntpProton->DumpData(); if(tag==1) SelectedProton.Append(proton[prot]); } for (int aProt=0; aProt<antiProton.GetLength(); ++aProt){ ntpAntiProton->Column("ev", (Float_t) evt); ntpAntiProton->Column("cand", (Float_t) aProt); ntpAntiProton->Column("ncand", (Float_t) antiProton.GetLength()); ntpAntiProton->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiProton[aProt])); qa.qaP4("antiProton_", antiProton[aProt]->P4(), ntpAntiProton); qa.qaCand("antiProton_", antiProton[aProt], ntpAntiProton); jenny::numberOfHitsInSubdetector("antiProton_", antiProton[aProt], ntpAntiProton); // jenny::tagNHits("antiProton_", antiProton[aProt], ntpAntiProton); int tag = jenny::tagHits(antiProton[aProt]); RhoCandidate * mother_aProt = antiProton[aProt]->GetMcTruth()->TheMother(); int moth_aProt = (0x0==mother_aProt)? 88888 : mother_aProt->PdgCode(); ntpAntiProton->Column("Mother", (Float_t) moth_aProt); ntpAntiProton->Column("antiProton_CosTheta", (Float_t) antiProton[aProt]->GetMomentum().CosTheta()); qa.qaP4("antiProton_MC_", antiProton[aProt]->GetMcTruth()->P4(), ntpAntiProton); qa.qaCand("antiProton_", antiProton[aProt]->GetMcTruth(), ntpAntiProton); ntpAntiProton->Column("antiProton_MC_CosTheta", (Float_t) antiProton[aProt]->GetMcTruth()->GetMomentum().CosTheta()); ntpAntiProton->DumpData(); if(tag==1) SelectedAntiProton.Append(antiProton[aProt]); } //***Lambda0 -> PiMinus + Proton lambda0.Combine(SelectedPiMinus,SelectedProton); lambda0.Select(lambdaMassSelector); lambda0.SetType(kl0); std::map<int,int> bestVtxFitLambda0, bestMassFitLambda0; bestVtxFitLambda0 = jenny::VertexQaIndex(&lambda0); bestMassFitLambda0 = jenny::MassFitQaIndex(&lambda0, m0_lambda0); for (int j=0; j<lambda0.GetLength(); ++j){ //general info about event ntpLambda0->Column("ev", (Float_t) evt); ntpLambda0->Column("cand", (Float_t) j); ntpLambda0->Column("ncand", (Float_t) lambda0.GetLength()); ntpLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(lambda0[j])); ntpLambda0->Column("Lambda0_Pdg", (Float_t) lambda0[j]->PdgCode()); RhoCandidate * mother = lambda0[j]->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpLambda0->Column("Mother", (Float_t) moth); qa.qaP4("Lambda0_", lambda0[j]->P4(), ntpLambda0); qa.qaComp("Lambda0_", lambda0[j], ntpLambda0); // do vertex fit PndKinVtxFitter vertexfitterLambda0 (lambda0[j]); vertexfitterLambda0.Fit(); RhoCandidate * lambda0Fit = lambda0[j]->GetFit(); // store info of vertex fit qa.qaFitter("VtxFit_", &vertexfitterLambda0, ntpLambda0); ntpLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitLambda0[j]); qa.qaVtx("VtxFit_", lambda0Fit, ntpLambda0); // differenz to MCTruth qa.qaMcDiff("fvtxMcDiff_", lambda0Fit, ntpLambda0); // do mass fit PndKinFitter massFitterLambda0(lambda0Fit); massFitterLambda0.AddMassConstraint(m0_lambda0); massFitterLambda0.Fit(); RhoCandidate * lambda0Fit_mass = lambda0Fit->GetFit(); qa.qaFitter("MassFit_", &massFitterLambda0, ntpLambda0); ntpLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitLambda0[j]); RhoCandidate * truth = lambda0[j]->GetMcTruth(); RhoCandidate * truthDaughter = lambda0[j]->Daughter(0)->GetMcTruth(); TLorentzVector l; TVector3 dl; if(0x0 != truth){ l = truth->P4(); qa.qaVtx("McTruth_", truth, ntpLambda0); dl = truth->Daughter(0)->Pos(); } else{ qa.qaVtx("McTruth_", dummyCand, ntpLambda0); } jenny::qaP3("McTruth_", dl, ntpLambda0); qa.qaP4("McTruth_", l, ntpLambda0); //*** use for Xi only bestChi2Cand if (bestVtxFitLambda0[j]==1 && bestMassFitLambda0[j]>0){ Lambda0Fit.Append(lambda0Fit); jenny::CombinedList(lambda0Fit, &CombinedPiMinus, -211); } //***information of boosted particle lambda0Fit->Boost(-beamBoost); qa.qaComp("boost_", lambda0Fit, ntpLambda0); ntpLambda0->DumpData(); } jenny::GetNotCombinedList(CombinedPiMinus, &NotCombinedPiMinus); // Lambda0Fit.Cleanup(); CombinedPiMinus.Cleanup(); SelectedPiMinus.Cleanup(); SelectedProton.Cleanup(); // NotCombinedPiMinus.Cleanup(); bestVtxFitLambda0.clear(); bestMassFitLambda0.clear(); //***AntiLambda0 -> PiPlus + AntiProton antiLambda0.Combine(SelectedPiPlus,SelectedAntiProton); antiLambda0.Select(lambdaMassSelector); antiLambda0.SetType(kal0); std::map<int,int> bestVtxFitAntiLambda0, bestMassFitAntiLambda0; bestVtxFitAntiLambda0 = jenny::VertexQaIndex(&antiLambda0); bestMassFitAntiLambda0 = jenny::MassFitQaIndex(&antiLambda0, m0_lambda0); for (int j=0; j<antiLambda0.GetLength(); ++j){ //general info about event ntpAntiLambda0->Column("ev", (Float_t) evt); ntpAntiLambda0->Column("cand", (Float_t) j); ntpAntiLambda0->Column("ncand", (Float_t) antiLambda0.GetLength()); ntpAntiLambda0->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(antiLambda0[j])); ntpAntiLambda0->Column("AntiLambda0_Pdg", (Float_t) antiLambda0[j]->PdgCode()); RhoCandidate * mother = antiLambda0[j]->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpAntiLambda0->Column("Mother", (Float_t) moth); qa.qaP4("AntiLambda0_", antiLambda0[j]->P4(), ntpAntiLambda0); qa.qaComp("AntiLambda0_", antiLambda0[j], ntpAntiLambda0); // do vertex fit PndKinVtxFitter vertexfitterAntiLambda0 (antiLambda0[j]); vertexfitterAntiLambda0.Fit(); RhoCandidate * antiLambda0Fit = antiLambda0[j]->GetFit(); // store info of vertex fit qa.qaFitter("VtxFit_", &vertexfitterAntiLambda0, ntpAntiLambda0); qa.qaVtx("VtxFit_", antiLambda0Fit, ntpAntiLambda0); ntpAntiLambda0->Column("VtxFit_HowGood", (Int_t) bestVtxFitAntiLambda0[j]); // do mass fit PndKinFitter massFitterAntiLambda0(antiLambda0Fit); massFitterAntiLambda0.AddMassConstraint(m0_lambda0); massFitterAntiLambda0.Fit(); RhoCandidate * antiLambda0Fit_mass = antiLambda0Fit->GetFit(); qa.qaFitter("MassFit_", &massFitterAntiLambda0, ntpAntiLambda0); ntpAntiLambda0->Column("MassFit_HowGood", (Int_t) bestMassFitAntiLambda0[j]); RhoCandidate * truth = antiLambda0[j]->GetMcTruth(); TLorentzVector l; if(0x0 != truth){ l = truth->P4(); qa.qaVtx("MCTruth_", truth, ntpAntiLambda0); } else{ qa.qaVtx("McTruth_", dummyCand, ntpAntiLambda0); } qa.qaP4("MCTruth_", l, ntpAntiLambda0); //***information of boosted particle antiLambda0Fit->Boost(-beamBoost); qa.qaComp("boost_", antiLambda0Fit, ntpAntiLambda0); if(bestVtxFitAntiLambda0[j]==1 && bestMassFitAntiLambda0[j]>0){ AntiLambda0Fit.Append(antiLambda0Fit); jenny::CombinedList(antiLambda0Fit, &CombinedPiPlus, 211); } ntpAntiLambda0->DumpData(); } jenny::GetNotCombinedList(CombinedPiPlus, &NotCombinedPiPlus); CombinedPiPlus.Cleanup(); SelectedPiPlus.Cleanup(); SelectedAntiProton.Cleanup(); bestVtxFitAntiLambda0.clear(); bestMassFitAntiLambda0.clear(); //*** Xi- -> Lambda0 + Pi- ximinus.Combine(Lambda0Fit, NotCombinedPiMinus); ximinus.Select(xiMassSelector); ximinus.SetType(kXim); std::map<int,int> BestVtxFitXiMinus, BestMassFitXiMinus; BestVtxFitXiMinus = jenny::VertexQaIndex(&ximinus); BestMassFitXiMinus = jenny::MassFitQaIndex(&ximinus, m0_Xi); for (int j=0; j<ximinus.GetLength(); ++j){ //general info about event ntpXiMinus->Column("ev", (Float_t) evt); ntpXiMinus->Column("cand", (Float_t) j); ntpXiMinus->Column("ncand", (Float_t) ximinus.GetLength()); ntpXiMinus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(ximinus[j])); ntpXiMinus->Column("XiMinus_Pdg", (Float_t) ximinus[j]->PdgCode()); RhoCandidate * mother = ximinus[j]->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpXiMinus->Column("Mother", (Float_t) moth); qa.qaP4("XiMinus_", ximinus[j]->P4(), ntpXiMinus); qa.qaComp("XiMinus_", ximinus[j], ntpXiMinus); qa.qaPoca("XiMinus_", ximinus[j], ntpXiMinus); // do vertex-fit PndKinVtxFitter vertexfitterXiMinus (ximinus[j]); vertexfitterXiMinus.Fit(); RhoCandidate * ximinusFit = ximinus[j]->GetFit(); // store info of vertex-fit qa.qaFitter("VtxFit_", &vertexfitterXiMinus, ntpXiMinus); ntpXiMinus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiMinus[j]); qa.qaVtx("VtxFit_", ximinusFit, ntpXiMinus); // qa.Cand("VtxFit_", ximinusFit, ntpXiMinus); // difference to MCTruth qa.qaMcDiff("VtxFit_", ximinusFit, ntpXiMinus); // do mass fit PndKinFitter massFitterXiMinus(ximinusFit); massFitterXiMinus.AddMassConstraint(m0_lambda0); massFitterXiMinus.Fit(); RhoCandidate * ximinusFit_mass = ximinusFit->GetFit(); qa.qaFitter("MassFit_", &massFitterXiMinus, ntpXiMinus); ntpXiMinus->Column("MassFit_HowGood", (Int_t) BestMassFitXiMinus[j]); qa.qaMcDiff("MassFit_", ximinusFit_mass, ntpXiMinus); RhoCandidate * truth = ximinus[j]->GetMcTruth(); TLorentzVector l; if(0x0 != truth){ l = truth->P4(); qa.qaVtx("MCTruth_", truth, ntpXiMinus); } else{ qa.qaVtx("MCTruth_", dummyCand, ntpXiMinus); } qa.qaP4("MCTruth_", l, ntpXiMinus); if (BestVtxFitXiMinus[j]==1 && BestMassFitXiMinus[j]>0){ XiMinusFit.Append(ximinusFit); } //***information of boosted particle ximinusFit->Boost(-beamBoost); qa.qaComp("boost_", ximinusFit, ntpXiMinus); ntpXiMinus->DumpData(); } Lambda0Fit.Cleanup(); NotCombinedPiMinus.Cleanup(); BestVtxFitXiMinus.clear(); BestMassFitXiMinus.clear(); //*** Xi+ -> AntiLambda0 + Pi+ xiplus.Combine(AntiLambda0Fit,piplus); xiplus.Select(xiMassSelector); xiplus.SetType(kaXip); std::map<int,int> BestVtxFitXiPlus, BestMassFitXiPlus; BestVtxFitXiPlus = jenny::VertexQaIndex(&xiplus); BestMassFitXiPlus = jenny::MassFitQaIndex(&xiplus, m0_Xi); for (int j=0; j<xiplus.GetLength(); ++j){ //general info about event ntpXiPlus->Column("ev", (Float_t) evt); ntpXiPlus->Column("cand", (Float_t) j); ntpXiPlus->Column("ncand", (Float_t) xiplus.GetLength()); ntpXiPlus->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiplus[j])); RhoCandidate * mother = xiplus[j]->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpXiPlus->Column("Mother", (Float_t) moth); qa.qaP4("Xiplus_", xiplus[j]->P4(), ntpXiPlus); qa.qaComp("Xiplus_", xiplus[j], ntpXiPlus); // int tag = 0; // int dtag[2] = {0,0}; // // for (int dau=0; dau<xiplus[j]->NDaughters(); dau++){ // // RhoCandidate * daughter = xiplus[j]->Daughter(dau); // if(daughter->IsComposite()){ // int dtag1 = jenny::tagHits(daughter->Daughter(0)); // int dtag2 = jenny::tagHits(daughter->Daughter(1)); // if(dtag1==1 && dtag2==1) dtag[dau]=1; // } // else{ // dtag[dau] = jenny::tagHits(daughter); // } // } // // if(dtag[0]==1 && dtag[1]==1) tag=1; // // ntpXiPlus->Column("XiPlus_HitTag", (Int_t) tag); //******** do vertex-fit PndKinVtxFitter vertexfitterxiplus (xiplus[j]); vertexfitterxiplus.Fit(); RhoCandidate * xiplusFit = xiplus[j]->GetFit(); // store info of vertex-fit qa.qaFitter("VtxFit_", &vertexfitterxiplus, ntpXiPlus); ntpXiPlus->Column("VtxFit_HowGood", (Int_t) BestVtxFitXiPlus[j]); qa.qaVtx("VtxFit_", xiplusFit, ntpXiPlus); // difference to MCTruth qa.qaMcDiff("VtxFit_", xiplusFit, ntpXiPlus); //****** do mass fit PndKinFitter massFitterxiplus(xiplusFit); massFitterxiplus.AddMassConstraint(m0_lambda0); massFitterxiplus.Fit(); RhoCandidate * xiplusFit_mass = xiplusFit->GetFit(); qa.qaFitter("MassFit_", &massFitterxiplus, ntpXiPlus); ntpXiPlus->Column("MassFit_HowGood", (float) BestMassFitXiPlus[j]); qa.qaVtx("MassFit_", xiplusFit_mass, ntpXiPlus); qa.qaMcDiff("MassFit_", xiplusFit_mass, ntpXiPlus); RhoCandidate * truth = xiplus[j]->GetMcTruth(); TLorentzVector l; if(0x0 != truth){ l = truth->P4(); qa.qaVtx("MCTruth_", truth, ntpXiPlus); } else{ qa.qaVtx("MCTruth_", dummyCand, ntpXiPlus); } qa.qaP4("MCTruth_", l, ntpXiPlus); if(BestVtxFitXiPlus[j]==1 && BestMassFitXiPlus[j]>0){ XiPlusFit.Append(xiplusFit); } //***information of boosted particle xiplusFit->Boost(-beamBoost); qa.qaComp("boost_", xiplusFit, ntpXiPlus); ntpXiPlus->DumpData(); } AntiLambda0Fit.Cleanup(); // BestCandAntiLambda0.Cleanup(); BestVtxFitXiPlus.clear(); BestMassFitXiPlus.clear(); //******* Xi+ Xi- System***************************** xiSys.Combine(XiPlusFit, XiMinusFit); xiSys.SetType(88888); for (int syscand=0; syscand<xiSys.GetLength(); ++syscand){ ntpXiSys->Column("ev", (Float_t) evt); ntpXiSys->Column("cand", (Float_t) j); ntpXiSys->Column("ncand", (Float_t) ximinus.GetLength()); ntpXiSys->Column("McTruthMatch", (bool) theAnalysis->McTruthMatch(xiSys[syscand])); RhoCandidate * mother = xiSys[syscand]->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpXiSys->Column("Mother", (Float_t) moth); qa.qaP4("XiSys_", xiSys[syscand]->P4(), ntpXiSys); qa.qaComp("XiSys_", xiSys[syscand], ntpXiSys); qa.qaPoca("XiSys_", xiSys[syscand], ntpXiSys); RhoCandidate * truth = xiSys[syscand]->GetMcTruth(); TLorentzVector l; if (truth != 0x0){ // qa.qaComp("McTruth_", truth, ntpXiSys); qa.qaVtx("McTruth_", truth, ntpXiSys); l = truth->P4(); } else{ // qa.qaComp("McTruth_", dummyCand, ntpXiSys); qa.qaVtx("McTruth_", dummyCand, ntpXiSys); } qa.qaP4("McTruth_", l, ntpXiSys); //4C-Fitter PndKinFitter fitter4c (xiSys[syscand]); fitter4c.Add4MomConstraint(ini); fitter4c.Fit(); RhoCandidate * xiSysFit4c = xiSys[syscand]->GetFit(); qa.qaFitter("4CFit_", &fitter4c, ntpXiSys); qa.qaComp("4cFit_", xiSysFit4c, ntpXiSys); qa.qaVtx("4CFit_", xiSysFit4c, ntpXiSys); ntpXiSys->DumpData(); } XiMinusFit.Cleanup(); XiPlusFit.Cleanup(); } //Write output out->cd(); ntpMC -> GetInternalTree()->Write(); ntpPiMinus ->GetInternalTree()->Write(); ntpPiPlus->GetInternalTree()->Write(); ntpProton->GetInternalTree()->Write(); ntpAntiProton->GetInternalTree()->Write(); ntpLambda0->GetInternalTree()->Write(); ntpAntiLambda0->GetInternalTree()->Write(); ntpXiMinus->GetInternalTree()->Write(); ntpXiPlus->GetInternalTree()->Write(); ntpXiSys->GetInternalTree()->Write(); out->Save(); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout<<endl<<endl; cout<<"Macro finisched successfully."<<endl; cout<<"Realtime: "<<rtime<<" s, CPU time: "<<ctime<<" s"<<endl; cout<<endl; exit(0); }
void number_of_particles_leaving_GEM_hits_boxgen(TString pre="", int nevts=0, double mom=4.1){ TDatabasePDG::Instance()-> AddParticle("pbarpSystem","pbarpSystem", 1.9, kFALSE, 0.1, 0,"", 88888); TStopwatch timer; if (pre==""){ //Output File TString OutputFile = "test_analysis_output.root"; TString outPath = ""; //Input simulation Files TString inPIDFile = "pid_complete.root"; TString inParFile = "simparams.root"; } else { //Output File TString outPath = pre + "_"; TString OutputFile = pre + "_test_analysis_output.root"; //Input simulation Files TString inPIDFile = pre + "_pid_complete.root"; TString inParFile = pre + "_simparams.root"; } TString PIDParFile = TString( gSystem->Getenv("VMCWORKDIR")) + "/macro/params/all.par"; //Initialization FairLogger::GetLogger()->SetLogToFile(kFALSE); FairRunAna* RunAna = new FairRunAna(); FairRuntimeDb* rtdb = RunAna->GetRuntimeDb(); RunAna->SetInputFile(inPIDFile); //setup parameter database FairParRootFileIo* parIo = new FairParRootFileIo(); parIo->open(inParFile); FairParAsciiFileIo* parIoPID = new FairParAsciiFileIo(); parIoPID->open(PIDParFile.Data(),"in"); rtdb->setFirstInput(parIo); rtdb->setSecondInput(parIoPID); rtdb->setOutput(parIo); RunAna->SetOutputFile(OutputFile); RunAna->Init(); /************************************************************************* * Create new ntuple and fill them with information ************************************************************************/ //*** create tuples RhoTuple * ntpPiMinus = new RhoTuple("ntpPiMinus", "PiMinus info"); RhoTuple * ntpPiPlus = new RhoTuple("ntpPiPlus", "PiPlus info"); RhoTuple * ntpKaonMinus = new RhoTuple("ntpKaonMinus", "KaonMinus info"); RhoTuple * ntpKaonPlus = new RhoTuple("ntpKaonPlus", "KaonPlus info"); RhoTuple * ntpProton = new RhoTuple("ntpProton", "Proton info"); RhoTuple * ntpAntiProton = new RhoTuple("ntpAntiProton", "Antiproton info"); //Create output file TFile *out = TFile::Open(outPath+"test_output_ana.root","RECREATE"); // data reader Object PndAnalysis* theAnalysis = new PndAnalysis(); if (nevts==0) nevts = theAnalysis->GetEntries(); //RhoCandLists for analysis RhoCandList piplus, piminus, proton, antiproton, kaonminus, kaonplus; RhoCandidate * dummyCand = new RhoCandidate(); //dummy candidate for empty candidate usage double p_m0 = TDatabasePDG::Instance()->GetParticle("proton")->Mass(); TLorentzVector ini (0,0, mom, sqrt(p_m0*p_m0+ mom*mom)+p_m0); TVector3 beamBoost = ini.BoostVector(); PndRhoTupleQA qa(theAnalysis, mom); int evt=-1; while (theAnalysis->GetEvent() && ++evt<nevts){ if ((evt%100)==0) cout << "evt "<< evt <<endl; TString PidSelection = "PidAlgoIdealCharged";//"PidAlgoMvd;PidAlgoStt;PidAlgoDrc"; to change from ideal PID to realistic PID uncomment this! //***Selection with no PID info theAnalysis->FillList(piminus, "PionBestMinus", PidSelection); theAnalysis->FillList(piplus, "PionBestPlus", PidSelection); theAnalysis->FillList(kaonminus, "KaonBestMinus", PidSelection); theAnalysis->FillList(kaonplus, "KaonBestPlus", PidSelection); theAnalysis->FillList(proton, "ProtonBestPlus", PidSelection); theAnalysis->FillList(antiproton, "ProtonBestMinus", PidSelection); //Get piminus information ntpPiMinus->Column("ev", (Float_t) evt); for (int j=0; j<piminus.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = piminus[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpPiMinus->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(piminus[j]); ntpPiMinus->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(piminus[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpPiMinus->Column("GemHit", (int) count, 0); } ntpPiMinus->DumpData(); //Get PiPlus information ntpPiPlus->Column("ev", (int) evt); for (int j=0; j<piplus.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = piplus[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpPiPlus->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(piplus[j]); ntpPiPlus->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(piplus[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpPiPlus->Column("GemHit", (int) count, 0); } ntpPiPlus->DumpData(); ntpKaonMinus->Column("ev", (int) evt); for (int j=0; j<kaonminus.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = kaonminus[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpKaonMinus->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(kaonminus[j]); ntpKaonMinus->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(kaonminus[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpKaonMinus->Column("GemHit", (int) count, 0); } ntpKaonMinus->DumpData(); ntpKaonPlus->Column("ev", (int) evt); for (int j=0; j<kaonplus.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = kaonplus[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpKaonPlus->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(kaonplus[j]); ntpKaonPlus->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(kaonplus[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpKaonPlus->Column("GemHit", (int) count, 0); } ntpKaonPlus->DumpData(); // Get Proton information ntpProton->Column("ev", (int) evt); for (int j=0; j<proton.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = proton[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpProton->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(proton[j]); ntpProton->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(proton[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpProton->Column("GemHit", (int) count, 0); } ntpProton->DumpData(); // Get Antiproton ntpAntiProton->Column("ev", (int) evt); for (int j=0; j<antiproton.GetLength(); ++j){ //information about the mother and MCTruth Candidate TLorentzVector l; float costheta = -999.; RhoCandidate * truth = antiproton[j]->GetMcTruth(); RhoCandidate * mother; if (truth) mother = truth->TheMother(); int moth = (mother==0x0) ? 88888 : mother->PdgCode(); ntpAntiProton->Column("Mother", (Int_t) moth); bool truthmatch = theAnalysis->McTruthMatch(antiproton[j]); ntpAntiProton->Column("MCTruthMatch", (bool) truthmatch); int gemhit = GemHits(antiproton[j]); int count = 0; if (moth==88888 && gemhit==1 && truthmatch==1) count=1; ntpAntiProton->Column("GemHit", (int) count, 0); } ntpAntiProton->DumpData(); } //Write output out->cd(); ntpPiMinus ->GetInternalTree()->Write(); ntpPiPlus->GetInternalTree()->Write(); ntpKaonMinus ->GetInternalTree()->Write(); ntpKaonPlus->GetInternalTree()->Write(); ntpProton->GetInternalTree()->Write(); ntpAntiProton->GetInternalTree()->Write(); out->Save(); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout<<"Macro finisched successfully."<<endl; cout<<"Realtime: "<<rtime<<" s, CPU time: "<<ctime<<" s"<<endl; cout<<endl; exit(0); }
void vbf_bbbb_select(const TString confname="test_vbf.txt", const Float_t xsec=1.0, const Float_t totalEvents=100, const TString outputfile="test.root") { // declare constants const Int_t B_ID_CODE = 5; const Int_t H_ID_CODE = 25; const Float_t MAX_MATCH_DIST = 0.5; // read input input file TChain chain("Delphes"); TString inputfile; ifstream ifs; ifs.open(confname); assert(ifs.is_open()); string line; while (getline(ifs, line)) { stringstream ss(line);; ss >> inputfile; chain.Add(inputfile); } ifs.close(); ExRootTreeReader *treeReader = new ExRootTreeReader(&chain); Long64_t numberOfEntries = treeReader->GetEntries(); TClonesArray *branchJet = treeReader->UseBranch("Jet"); TClonesArray *branchGenJet = treeReader->UseBranch("GenJet"); TClonesArray *branchParticle = treeReader->UseBranch("Particle"); //set up loop variables GenParticle *genParticle=0; Jet *genJet=0; Jet *jet=0; // set up storage variables Jet *jetB1=0, *jetB2=0, *jetB3=0, *jetB4=0; Jet *jet1=0, *jet2=0; GenParticle *genB1=0, *genB2=0, *genB3=0, *genB4=0; GenParticle *genH1=0, *genH2=0; Jet *genJetB1=0, *genJetB2=0, *genJetB3=0, *genJetB4=0; Jet *genJetVBF1=0, *genJetVBF2=0; Int_t iB1=-1, iB2=-1, iB3=-1, iB4=-1; Int_t iH1=-1, iH2=-1; Int_t iJet1=-1, iJet2=-1; Int_t iGenB1=-1, iGenB2=-1, iGenB3=-1, iGenB4=-1; Int_t iGenJetB1=-1, iGenJetB2=-1, iGenJetB3=-1, iGenJetB4=-1; Int_t iGenJetVBF1=-1, iGenJetVBF2=-1; Int_t iHmatch1=-1, iHmatch2=-1, iHmatch3=-1, iHmatch4=-1; LorentzVector *sRecoB1=0, *sRecoB2=0, *sRecoB3=0, *sRecoB4=0; LorentzVector *sGenJetB1=0, *sGenJetB2=0, *sGenJetB3=0, *sGenJetB4=0; LorentzVector *sGenJetVBF1=0, *sGenJetVBF2=0; LorentzVector *sGenB1=0, *sGenB2=0, *sGenB3=0, *sGenB4=0; LorentzVector *sGenH1=0, *sGenH2=0; LorentzVector *sRecoJet1=0, *sRecoJet2=0; TFile *outFile = new TFile(outputfile, "RECREATE"); // tree to hold information about selected events TTree *outTree = new TTree("Events", "Events"); outTree->Branch("iHmatch1", &iHmatch1, "iHmatch1/i"); // which Higgs does b-jet 1 come from outTree->Branch("iHmatch2", &iHmatch2, "iHmatch2/i"); // which Higgs does b-jet 2 come from outTree->Branch("iHmatch3", &iHmatch3, "iHmatch3/i"); // which Higgs does b-jet 3 come from outTree->Branch("iHmatch4", &iHmatch4, "iHmatch4/i"); // which Higgs does b-jet 4 come from outTree->Branch("sGenB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB1); // 4-vector for generator leading b-jet outTree->Branch("sGenB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB2); // 4-vector for generator b-jet outTree->Branch("sGenB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB3); // 4-vector for generator b-jet outTree->Branch("sGenB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenB4); // 4-vector for generator b-jet outTree->Branch("sGenH1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH1); // 4-vector for generator higgs outTree->Branch("sGenH2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenH2); // 4-vector for generator higgs outTree->Branch("sGenJetB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB2); // 4-vector for generator b-jet outTree->Branch("sGenJetB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB3); // 4-vector for generator b-jet outTree->Branch("sGenJetB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetB4); // 4-vector for generator b-jet outTree->Branch("sGenJetVBF1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF1); // 4-vector for generator leading b-jet outTree->Branch("sGenJetVBF2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sGenJetVBF2); // 4-vector for generator b-jet outTree->Branch("sRecoB1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB1); // 4-vector for reconstructed leading b-jet outTree->Branch("sRecoB2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB2); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB3", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB3); // 4-vector for reconstructed b-jet outTree->Branch("sRecoB4", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoB4); // 4-vector for reconstructed b-jet outTree->Branch("sRecoJet1", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet1); // 4-vector for reconstructed leading forward-jet outTree->Branch("sRecoJet2", "ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> >", &sRecoJet2); // 4-vector for reconstructed second forward-jet // define placeholder vector for things that don't exist LorentzVector nothing(-999,-999,0,-999); Int_t iMatched=0; Int_t iNot=0; Int_t iTwo=0; Int_t nM=0; for (Int_t iEntry=0; iEntry<numberOfEntries; iEntry++) { // entry loop treeReader->ReadEntry(iEntry); // ******************** // RESET // ******************** iB1=-1; iB2=-1; iB3=-1; iB4=-1; iGenB1=-1; iGenB2=-1; iGenB3=-1; iGenB4=-1; iGenJetB1=-1; iGenJetB2=-1; iGenJetB3=-1; iGenJetB4=-1; iGenJetVBF1=-1; iGenJetVBF2=-1; iH1=-1; iH2=-1; iJet1=-1; iJet2=-1; iHmatch1=-1; iHmatch2=-1; iHmatch3=-1; iHmatch4=-1; jet1=0; jet2=0; jetB1=0; jetB2=0; jetB3=0; jetB4=0; genB1=0; genB2=0; genB3=0; genB4=0; genJetB1=0; genJetB2=0; genJetB3=0; genJetB4=0; genJetVBF1=0; genJetVBF2=0; sGenB1=0; sGenB2=0; sGenB3=0; sGenB4=0; sGenJetB1=0; sGenJetB2=0; sGenJetB3=0; sGenJetB4=0; sGenJetVBF1=0; sGenJetVBF2=0; sGenH1=0; sGenH2=0; nM=0; for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.0) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if (jet->BTag==0) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iB1==-1) { iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (jet->PT > jetB1->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iB1; jetB2 = (Jet*) branchJet->At(iB2); iB1=iJet; jetB1 = (Jet*) branchJet->At(iB1); } else if (iB2==-1) { iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (jet->PT > jetB2->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); iB2=iJet; jetB2 = (Jet*) branchJet->At(iB2); } else if (iB3==-1) { iB3=iJet; jetB3 = (Jet*) branchJet->At(iB3); } else if (jet->PT > jetB3->PT) { iB4=iB3; jetB4 = (Jet*) branchJet->At(iB4); iB3=iB2; jetB3 = (Jet*) branchJet->At(iB3); } else if (iB4==-1) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } else if (jet->PT > jetB4->PT) { iB4=iJet; jetB4 = (Jet*) branchJet->At(iB4); } } // end reco jet loop // get VBF jets for (Int_t iJet=0; iJet<branchJet->GetEntries(); iJet++) { // reconstructed jet loop jet = (Jet*) branchJet->At(iJet); if (fabs(jet->Eta)>4.7) continue; if (jet->PT<30) continue; if (puJetID(jet->Eta, jet->MeanSqDeltaR, jet->BetaStar)==1) continue; if ((jetB1)&&(deltaR(jet->Eta, jetB1->Eta, jet->Phi, jetB1->Phi) < MAX_MATCH_DIST)) continue; if ((jetB2)&&(deltaR(jet->Eta, jetB2->Eta, jet->Phi, jetB2->Phi) < MAX_MATCH_DIST)) continue; if ((jetB3)&&(deltaR(jet->Eta, jetB3->Eta, jet->Phi, jetB3->Phi) < MAX_MATCH_DIST)) continue; if ((jetB4)&&(deltaR(jet->Eta, jetB4->Eta, jet->Phi, jetB4->Phi) < MAX_MATCH_DIST)) continue; if (iJet1==-1) { iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (jet->PT > jet1->PT) { iJet2=iJet1; jet2 = (Jet*) branchJet->At(iJet2); iJet1=iJet; jet1 = (Jet*) branchJet->At(iJet1); } else if (iJet2==-1) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } else if (jet->PT > jet2->PT) { iJet2=iJet; jet2 = (Jet*) branchJet->At(iJet2); } } if ( (!jetB1) || (!jetB2) || (!jetB3) || (!jetB4) || (!jet1) || (!jet2) ) continue; /* cout << "stored jets" << endl; if (jetB1) cout << "1 " << jetB1->PT << " " << jetB1->Eta << endl; if (jetB2) cout << "2 " << jetB2->PT << " " << jetB2->Eta << endl; if (jetB3) cout << "3 " << jetB3->PT << " " << jetB3->Eta << endl; if (jetB4) cout << "4 " << jetB4->PT << " " << jetB4->Eta << endl; if (jet1) cout << "V1 " << jet1->PT << " " << jet1->Eta << endl; if (jet2) cout << "V2 " << jet2->PT << " " << jet2->Eta << endl; cout << endl;*/ // fill 4-vector for leading b-jet LorentzVector vRecoB1(0,0,0,0); if (jetB1) { vRecoB1.SetPt(jetB1->PT); vRecoB1.SetEta(jetB1->Eta); vRecoB1.SetPhi(jetB1->Phi); vRecoB1.SetM(jetB1->Mass); sRecoB1 = &vRecoB1; } else sRecoB1 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB2(0,0,0,0); if (jetB2) { vRecoB2.SetPt(jetB2->PT); vRecoB2.SetEta(jetB2->Eta); vRecoB2.SetPhi(jetB2->Phi); vRecoB2.SetM(jetB2->Mass); sRecoB2 = &vRecoB2; } else sRecoB2 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB3(0,0,0,0); if (jetB3) { vRecoB3.SetPt(jetB3->PT); vRecoB3.SetEta(jetB3->Eta); vRecoB3.SetPhi(jetB3->Phi); vRecoB3.SetM(jetB3->Mass); sRecoB3 = &vRecoB3; } else sRecoB3 = ¬hing; // fill 4-vector for b-jet LorentzVector vRecoB4(0,0,0,0); if (jetB4) { vRecoB4.SetPt(jetB4->PT); vRecoB4.SetEta(jetB4->Eta); vRecoB4.SetPhi(jetB4->Phi); vRecoB4.SetM(jetB4->Mass); sRecoB4 = &vRecoB4; } else sRecoB4 = ¬hing; // ******************** // GEN PARTICLES // ******************** //cout << "B-QUARKS: " << endl; for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if ( fabs(genParticle->PID) != B_ID_CODE ) continue; if (genParticle->Status != 3) continue; //cout << genParticle->PT << " " << genParticle->Eta << " " << genParticle->Phi << " " << genParticle->Status << endl; if ( deltaR(genParticle->Eta, vRecoB1.Eta(), genParticle->Phi, vRecoB1.Phi()) < MAX_MATCH_DIST ) { iGenB1 = iParticle; genB1 = (GenParticle*) branchParticle->At(iGenB1); } else if ( deltaR(genParticle->Eta, vRecoB2.Eta(), genParticle->Phi, vRecoB2.Phi()) < MAX_MATCH_DIST ) { iGenB2 = iParticle; genB2 = (GenParticle*) branchParticle->At(iGenB2); } else if ( deltaR(genParticle->Eta, vRecoB3.Eta(), genParticle->Phi, vRecoB3.Phi()) < MAX_MATCH_DIST ) { iGenB3 = iParticle; genB3 = (GenParticle*) branchParticle->At(iGenB3); } else if ( deltaR(genParticle->Eta, vRecoB4.Eta(), genParticle->Phi, vRecoB4.Phi()) < MAX_MATCH_DIST ) { iGenB4 = iParticle; genB4 = (GenParticle*) branchParticle->At(iGenB4); } } /* cout << "Gen Particles " << endl; if (genB1) cout << "1 " << genB1->PT << " " << genB1->Eta << endl; if (genB2) cout << "2 " << genB2->PT << " " << genB2->Eta << endl; if (genB3) cout << "3 " << genB3->PT << " " << genB3->Eta << endl; if (genB4) cout << "4 " << genB4->PT << " " << genB4->Eta << endl; */ for (Int_t iParticle=0; iParticle<branchParticle->GetEntries(); iParticle++) { // generator particle loop genParticle = (GenParticle*) branchParticle->At(iParticle); if (fabs(genParticle->PID) != H_ID_CODE) continue; if (iH1==-1) { iH1 = iParticle; genH1 = (GenParticle*) branchParticle->At(iH1); } else if (iH2==-1) { iH2 = iParticle; genH2 = (GenParticle*) branchParticle->At(iH2); } } /* if (genH1) cout << "H1 " << genH1->PT << " " << genH1->Eta << " " << genH1->Phi << endl; if (genH2) cout << "H2 " << genH2->PT << " " << genH2->Eta << " " << genH2->Phi << endl; cout << endl;*/ LorentzVector vGenB1(0,0,0,0); if (genB1) { vGenB1.SetPt(genB1->PT); vGenB1.SetEta(genB1->Eta); vGenB1.SetPhi(genB1->Phi); vGenB1.SetM(genB1->Mass); sGenB1 = &vGenB1; } else sGenB1 = ¬hing; LorentzVector vGenB2(0,0,0,0); if (genB2) { vGenB2.SetPt(genB2->PT); vGenB2.SetEta(genB2->Eta); vGenB2.SetPhi(genB2->Phi); vGenB2.SetM(genB2->Mass); sGenB2 = &vGenB2; } else sGenB2 = ¬hing; LorentzVector vGenB3(0,0,0,0); if (genB3) { vGenB3.SetPt(genB3->PT); vGenB3.SetEta(genB3->Eta); vGenB3.SetPhi(genB3->Phi); vGenB3.SetM(genB3->Mass); sGenB3 = &vGenB3; } else sGenB3 = ¬hing; LorentzVector vGenB4(0,0,0,0); if (genB4) { vGenB4.SetPt(genB4->PT); vGenB4.SetEta(genB4->Eta); vGenB4.SetPhi(genB4->Phi); vGenB4.SetM(genB4->Mass); sGenB4 = &vGenB4; } else sGenB4 = ¬hing; LorentzVector vGenH1(0,0,0,0); if (genH1) { vGenH1.SetPt(genH1->PT); vGenH1.SetEta(genH1->Eta); vGenH1.SetPhi(genH1->Phi); vGenH1.SetM(genH1->Mass); sGenH1 = &vGenH1; } else sGenH1 = ¬hing; LorentzVector vGenH2(0,0,0,0); if (genH2) { vGenH2.SetPt(genH2->PT); vGenH2.SetEta(genH2->Eta); vGenH2.SetPhi(genH2->Phi); vGenH2.SetM(genH2->Mass); sGenH2 = &vGenH2; } else sGenH2 = ¬hing; LorentzVector vTestBB1=vGenB1+vGenB2; LorentzVector vTestBB2=vGenB3+vGenB4; //cout << "test1 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test1 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; cout << "---" << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=1; iHmatch3=2; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=2; iHmatch3=1; iHmatch4=1; } vTestBB1=vGenB1+vGenB3; vTestBB2=vGenB2+vGenB4; //cout << "test2 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test2 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=1; iHmatch4=2; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=2; iHmatch4=1; } vTestBB1=vGenB1+vGenB4; vTestBB2=vGenB3+vGenB2; //cout << "test3 " << vTestBB1.Pt() << " " << vTestBB1.Eta() << " " << vTestBB1.Phi() << endl; //cout << "test3 " << vTestBB2.Pt() << " " << vTestBB2.Eta() << " " << vTestBB2.Phi() << endl; if ( (deltaR(vTestBB1.Eta(), vGenH1.Eta(), vTestBB1.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB2.Eta(), vGenH2.Eta(), vTestBB2.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=1; iHmatch2=2; iHmatch3=2; iHmatch4=1; } else if ( (deltaR(vTestBB2.Eta(), vGenH1.Eta(), vTestBB2.Phi(), vGenH1.Phi()) < MAX_MATCH_DIST) && (deltaR(vTestBB1.Eta(), vGenH2.Eta(), vTestBB1.Phi(), vGenH2.Phi()) < MAX_MATCH_DIST) ) { cout << "H matched " << endl; nM++; iHmatch1=2; iHmatch2=1; iHmatch3=1; iHmatch4=2; } if (iHmatch1==-1) { iHmatch1=0; iHmatch2=0; iHmatch3=0; iHmatch4=0; } //cout << iHmatch1 << " " << iHmatch2 << " " << iHmatch3 << " " << iHmatch4 << endl; //cout << endl; if (nM==0) iNot++; else if (nM==1) iMatched++; else if (nM>1) iTwo++; // match gen jets to reco jets for (Int_t iJet=0; iJet<branchGenJet->GetEntries(); iJet++) { // generator level jet loop genJet = (Jet*) branchGenJet->At(iJet); if ((jetB1) && (deltaR(genJet->Eta, jetB1->Eta, genJet->Phi, jetB1->Phi) < MAX_MATCH_DIST) ) { iGenJetB1=iJet; genJetB1 = (Jet*) branchGenJet->At(iGenJetB1); } else if ((jetB2) && (deltaR(genJet->Eta, jetB2->Eta, genJet->Phi, jetB2->Phi) < MAX_MATCH_DIST) ) { iGenJetB2=iJet; genJetB2 = (Jet*) branchGenJet->At(iGenJetB2); } else if ((jetB3) && (deltaR(genJet->Eta, jetB3->Eta, genJet->Phi, jetB3->Phi) < MAX_MATCH_DIST) ) { iGenJetB3=iJet; genJetB3 = (Jet*) branchGenJet->At(iGenJetB3); } else if ((jetB4) && (deltaR(genJet->Eta, jetB4->Eta, genJet->Phi, jetB4->Phi) < MAX_MATCH_DIST) ) { iGenJetB4=iJet; genJetB4 = (Jet*) branchGenJet->At(iGenJetB4); } else if ((jet1) && (deltaR(genJet->Eta, jet1->Eta, genJet->Phi, jet1->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF1=iJet; genJetVBF1 = (Jet*) branchGenJet->At(iGenJetVBF1); } else if ((jet2) && (deltaR(genJet->Eta, jet2->Eta, genJet->Phi, jet2->Phi) < MAX_MATCH_DIST) ) { iGenJetVBF2=iJet; genJetVBF2 = (Jet*) branchGenJet->At(iGenJetVBF2); } } LorentzVector vGenJetB1(0,0,0,0); if (genJetB1) { vGenJetB1.SetPt(genJetB1->PT); vGenJetB1.SetEta(genJetB1->Eta); vGenJetB1.SetPhi(genJetB1->Phi); vGenJetB1.SetM(genJetB1->Mass); sGenJetB1 = &vGenJetB1; } else sGenJetB1 = ¬hing; LorentzVector vGenJetB2(0,0,0,0); if (genJetB2) { vGenJetB2.SetPt(genJetB2->PT); vGenJetB2.SetEta(genJetB2->Eta); vGenJetB2.SetPhi(genJetB2->Phi); vGenJetB2.SetM(genJetB2->Mass); sGenJetB2 = &vGenJetB2; } else sGenJetB2 = ¬hing; LorentzVector vGenJetB3(0,0,0,0); if (genJetB3) { vGenJetB3.SetPt(genJetB3->PT); vGenJetB3.SetEta(genJetB3->Eta); vGenJetB3.SetPhi(genJetB3->Phi); vGenJetB3.SetM(genJetB3->Mass); sGenJetB3 = &vGenJetB3; } else sGenJetB3 = ¬hing; LorentzVector vGenJetB4(0,0,0,0); if (genJetB4) { vGenJetB4.SetPt(genJetB4->PT); vGenJetB4.SetEta(genJetB4->Eta); vGenJetB4.SetPhi(genJetB4->Phi); vGenJetB4.SetM(genJetB4->Mass); sGenJetB4 = &vGenJetB4; } else sGenJetB4 = ¬hing; LorentzVector vGenJetVBF1(0,0,0,0); if (genJetVBF1) { vGenJetVBF1.SetPt(genJetVBF1->PT); vGenJetVBF1.SetEta(genJetVBF1->Eta); vGenJetVBF1.SetPhi(genJetVBF1->Phi); vGenJetVBF1.SetM(genJetVBF1->Mass); sGenJetVBF1 = &vGenJetVBF1; } else sGenJetVBF1 = ¬hing; LorentzVector vGenJetVBF2(0,0,0,0); if (genJetVBF2) { vGenJetVBF2.SetPt(genJetVBF2->PT); vGenJetVBF2.SetEta(genJetVBF2->Eta); vGenJetVBF2.SetPhi(genJetVBF2->Phi); vGenJetVBF2.SetM(genJetVBF2->Mass); sGenJetVBF2 = &vGenJetVBF2; } else sGenJetVBF2 = ¬hing; /* cout << "Gen Jets " << endl; if (genJetB1) cout << "1 " << genJetB1->PT << " " << genJetB1->Eta << endl; if (genJetB2) cout << "2 " << genJetB2->PT << " " << genJetB2->Eta << endl; if (genJetB3) cout << "3 " << genJetB3->PT << " " << genJetB3->Eta << endl; if (genJetB4) cout << "4 " << genJetB4->PT << " " << genJetB4->Eta << endl; if (genJetVBF1) cout << "V1 " << genJetVBF1->PT << " " << genJetVBF1->Eta << endl; if (genJetVBF2) cout << "V2 " << genJetVBF2->PT << " " << genJetVBF2->Eta << endl; cout << endl; */ outTree->Fill(); } // end event loop outFile->Write(); outFile->Save(); cout << endl; cout << "matched : " << iMatched << endl; cout << "not : " << iNot << endl; cout << "too much : " << iTwo << endl; cout << "total : " << iMatched+iNot+iTwo << endl; }
void sidebandSelection() { // -- define tuple file name, tuple name and cuts to apply // -- and also the name of the output file const std::string filename = "~/cern/ntuples/Lb2chicpK_2011_2012_signal_fixed.root"; const std::string treename("MyTuple"); // SIDEBAND /* const std::string cuts = "m_b_DTF_jpsi_chic1_constr > 5.66 && m_b_DTF_jpsi_chic1_constr < 5.70 && dtf_b < 7 && dtf_b > 0 && c2ip_b < 25 && dls_b > 10 && c2ip_kminus > 4 && c2ip_pplus > 4 && minCl_gamma > 0.03 && m_chic > 3.4 && m_chic < 3.7 && trig_b_l0tos_tos == 1 && trig_b_l1tos_tos == 1 && trig_b_l2tos_tos == 1 && trgh_track[0] < 0.3 && trgh_track[1] < 0.3 && trgh_track[2] < 0.3 && trgh_track[3] < 0.3 && K_ProbNNk > 0.15 && minann_mu > 0.1" ; const std::string outFilename("~/cern/ntuples/sideband.root"); */ // SIGNAL const std::string cuts = "m_b_DTF_jpsi_chic1_constr > 5.61 && m_b_DTF_jpsi_chic1_constr < 5.63 && dtf_b < 7 && dtf_b > 0 && c2ip_b < 25 && dls_b > 10 && c2ip_kminus > 4 && c2ip_pplus > 4 && minCl_gamma > 0.03 && m_chic > 3.4 && m_chic < 3.7 && trig_b_l0tos_tos == 1 && trig_b_l1tos_tos == 1 && trig_b_l2tos_tos == 1 && trgh_track[0] < 0.3 && trgh_track[1] < 0.3 && trgh_track[2] < 0.3 && trgh_track[3] < 0.3 && K_ProbNNk > 0.15 && minann_mu > 0.1" ; const std::string outFilename("~/cern/ntuples/signal.root"); TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need tree->SetBranchStatus("*", 0); tree->SetBranchStatus("m_b_DTF_jpsi_chic1_constr",1); tree->SetBranchStatus("dtf_b",1); tree->SetBranchStatus("c2ip_b",1); tree->SetBranchStatus("dls_b",1); tree->SetBranchStatus("c2ip_kminus",1); tree->SetBranchStatus("c2ip_pplus",1); tree->SetBranchStatus("minCl_gamma",1); tree->SetBranchStatus("m_chic",1); tree->SetBranchStatus("trig_b_l0tos_tos",1); tree->SetBranchStatus("trig_b_l1tos_tos",1); tree->SetBranchStatus("trig_b_l2tos_tos",1); tree->SetBranchStatus("trgh_track",1); tree->SetBranchStatus("ann_kaon",1); tree->SetBranchStatus("K_ProbNNk",1); tree->SetBranchStatus("ann_proton",1); tree->SetBranchStatus("P_ProbNNp",1); tree->SetBranchStatus("ann_mu",1); tree->SetBranchStatus("minann_mu",1); tree->SetBranchStatus("m_chicp",1); tree->SetBranchStatus("m_pK",1); tree->SetBranchStatus("m_jpsi",1); // -- this file is just here to make the 'CopyTree' happy TFile* dummyFile = new TFile("~/cern/ntuples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree( cuts.c_str() ); float mass, mass_chicp, mass_pK, mass_jpsi, mass_chic, dtf_b, c2ip_b, dls_b, c2ip_kminus, c2ip_pplus, minCl_gamma, trgh_track, ann_kaon, K_ProbNNk, ann_proton, P_ProbNNp, ann_mu, minann_mu; float trig_b_l0tos_tos, trig_b_l1tos_tos, trig_b_l2tos_tos; rTree1->SetBranchAddress("m_b_DTF_jpsi_chic1_constr", &mass); rTree1->SetBranchAddress("m_chicp", &mass_chicp); rTree1->SetBranchAddress("m_pK", &mass_pK); rTree1->SetBranchAddress("m_jpsi", &mass_jpsi); rTree1->SetBranchAddress("m_chic", &mass_chic); rTree1->SetBranchAddress("dtf_b", &dtf_b); rTree1->SetBranchAddress("c2ip_b", &c2ip_b); rTree1->SetBranchAddress("dls_b", &dls_b); rTree1->SetBranchAddress("c2ip_kminus", &c2ip_kminus); rTree1->SetBranchAddress("c2ip_pplus", &c2ip_pplus); rTree1->SetBranchAddress("minCl_gamma", &minCl_gamma); rTree1->SetBranchAddress("trig_b_l0tos_tos", &trig_b_l0tos_tos); rTree1->SetBranchAddress("trig_b_l1tos_tos", &trig_b_l1tos_tos); rTree1->SetBranchAddress("trig_b_l2tos_tos", &trig_b_l2tos_tos); rTree1->SetBranchAddress("trgh_track", &trgh_track); rTree1->SetBranchAddress("ann_kaon", &ann_kaon); rTree1->SetBranchAddress("K_ProbNNk", &K_ProbNNk); rTree1->SetBranchAddress("ann_proton", &ann_proton); rTree1->SetBranchAddress("P_ProbNNp", &P_ProbNNp); rTree1->SetBranchAddress("ann_mu", &ann_mu); rTree1->SetBranchAddress("minann_mu", &minann_mu); TFile* rFile = new TFile( outFilename.c_str() ,"RECREATE"); TTree* rTree2 = new TTree(); //rTree2->SetName("sideband"); rTree2->SetName("signal"); rTree2->Branch("mass", &mass, "mass"); rTree2->Branch("mass_chicp", &mass_chicp, "mass_chicp/F"); rTree2->Branch("mass_pK", &mass_pK, "mass_pK/F"); rTree2->Branch("mass_jpsi", &mass_jpsi, "mass_jpsi/F"); rTree2->Branch("mass_chic", &mass_chic, "mass_chic/F"); rTree2->Branch("dtf_b", &dtf_b, "dtf_b/F"); rTree2->Branch("c2ip_b", &c2ip_b, "c2ip_b/F"); rTree2->Branch("dls_b", &dls_b, "dls_b/F"); rTree2->Branch("c2ip_kminus", &c2ip_kminus, "c2ip_kminus/F"); rTree2->Branch("c2ip_pplus", &c2ip_pplus, "c2ip_pplus/F"); rTree2->Branch("minCl_gamma", &minCl_gamma, "minCl_gamma/F"); rTree2->Branch("trig_b_l0tos_tos", &trig_b_l0tos_tos, "trig_b_l0tos_tos/F"); rTree2->Branch("trig_b_l1tos_tos", &trig_b_l1tos_tos, "trig_b_l1tos_tos/F"); rTree2->Branch("trig_b_l2tos_tos", &trig_b_l2tos_tos, "trig_b_l2tos_tos/F"); rTree2->Branch("trgh_track", &trgh_track, "trgh_track/F"); rTree2->Branch("ann_kaon", &ann_kaon, "ann_kaon/F"); rTree2->Branch("K_ProbNNk", &K_ProbNNk, "K_ProbNNk/F"); rTree2->Branch("ann_proton", &ann_proton, "ann_proton/F"); rTree2->Branch("P_ProbNNp", &P_ProbNNp, "P_ProbNNp/F"); rTree2->Branch("ann_mu", &ann_mu, "ann_mu/F"); rTree2->Branch("minann_mu", &minann_mu, "minann_mu/F"); int percentCounter = 1; for(int i = 0; i < rTree1->GetEntries(); ++i) { const int percent = (int)(rTree1->GetEntries()/100.0); if( i == percent*percentCounter ) { //std::cout << percentCounter << " %" << std::endl; percentCounter++; } rTree1->GetEntry(i); rTree2->Fill(); //std::cout << mass << std::endl; } rTree2->Print(); rTree2->Write(); rFile->Save(); }
void effCalc(){ // -- define tuple file name, tuple name and cuts to apply // -- and also the name of the output file const std::string filename = "/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/Lb2chicpK_MC_2011_2012_signal_withbdt.root"; //const std::string outFilename("/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/"); const std::string treename("withbdt"); const std::string outfile = "~/cern/new_plots/signal_MC_gamma_PT_cut.pdf"; const std::string xaxis = "m(#chi_{c1}pK^{-}) (MeV/c^{2})"; const std::string yaxis = "Events / 2 MeV/c^{2}"; const std::string cuts("gamma_PT > 500. "); //TStopwatch sw; //sw.Start(); std::cout << "Opening file: " << filename.c_str() << endl; TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need tree->SetBranchStatus("*", 1); //double n_pre = tree->GetEntries("bdtg>=0.85"); //std::cout << "# of events in original tree = " << n_pre << endl; // -- this file is just here to make the 'CopyTree' happy std::cout << "Copying tree: " << treename.c_str() << endl; TFile* newFile = new TFile("/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree( cuts.c_str() ); //rTree1->Print(); rTree1->Write(); newFile->Save(); double n_post = rTree1->GetEntries(); // Including the LHCb name, formatting lhcbName = new TPaveText(gStyle->GetPadLeftMargin() + 0.65, 0.87 - gStyle->GetPadTopMargin(), gStyle->GetPadLeftMargin() + 0.75, 0.95 - gStyle->GetPadTopMargin(), "BRNDC"); lhcbName->AddText("LHCb"); lhcbName->SetFillColor(0); lhcbName->SetTextAlign(12); lhcbName->SetBorderSize(0); gStyle->SetOptStat(0); /* titleBox = new TPaveText(gStyle->GetPadLeftMargin() + 0.3, 0.98 - gStyle->GetPadTopMargin(), 0.98 - gStyle->GetPadLeftMargin(), 0.83 - gStyle->GetPadTopMargin(), "BRNDC"); titleBox->AddText(title.c_str()); titleBox->SetFillColor(0); titleBox->SetTextAlign(12); titleBox->SetBorderSize(0); */ // plotting ------------------------------------------------------------------- // Define the histograms TH1D* h1 = new TH1D ("h1", "Effect of cutting #gamma pT on simulated sample post-selection", 100, 5500., 5700.); TH1D* h2 = new TH1D ("h2", "Effect of cutting #gamma pT on simulated sample post-selection", 100, 5500., 5700.); // Differentiating the two histos from each other //h1->Sumw2(); //h2->Sumw2(); //h1->SetMarkerStyle(kFullDotLarge); h1->SetMarkerSize(0.7); h2->SetMarkerColor(kRed); //h2->SetMarkerStyle(kFullDotLarge); h2->SetMarkerSize(0.7); h2->SetLineColor(kRed); // Draw the histograms rTree1->Draw("Lambda_b0_DTF_MASS_constr1>>h1", "", "goff"); tree->Draw("Lambda_b0_DTF_MASS_constr1>>h2", "", "goff"); // Setting up canvas TCanvas* c1 = new TCanvas(); c1->Divide(1,1); c1->cd(1); // Plotting h2->Draw(); h1->Draw("same"); //h1->SetTitle( title.c_str() ); h2->GetXaxis()->SetTitle( xaxis.c_str() ); h2->GetYaxis()->SetTitle( yaxis.c_str() ); h2->GetXaxis()->SetLabelSize(0.04); h2->GetYaxis()->SetLabelSize(0.035); h2->GetXaxis()->SetTitleSize(0.04); h2->GetYaxis()->SetTitleSize(0.04); //lhcbName->Draw(); //titleBox->Draw(); leg = new TLegend(0.75,0.8,0.9,0.9); //leg->SetHeader("The Legend Title"); leg->AddEntry(h2,"before cut","l"); leg->AddEntry(h1,"after cut","l"); leg->Draw(); //int Nhisto1 = t1->GetEntries(""); //c1->SaveAs( outfile.c_str() ); //sw.Stop(); double n_pre = h2->Integral(); double efficiency = n_post/n_pre; double error = sqrt(efficiency*(1.-efficiency)/n_pre); std::cout << "# of events in the tree before cut applied = " << n_pre << endl; std::cout << "Efficiency = " << efficiency << endl; std::cout << "Error = " << error << endl; //std::cout << "Total time elapsed: "; sw.Print(); }
void computeSummary(string fileName_="",string payloadName_=""){ if (fileName_==""){cout<<"No file specified."<<endl; return;} TFile * f = new TFile(saveFile.c_str(),"UPDATE"); TTree * t = (TTree*)f->Get("payloadSummary"); if (!t)return; float MPV[5]; float Gain[5]; gROOT->ProcessLine("#include <iostream>"); string *payloadName = new string; payloadName->assign(payloadName_); t->SetBranchAddress("MPV" ,&MPV[0] ); t->SetBranchAddress("Gain" ,&Gain[0] ); t->SetBranchAddress("MPV_TIB" ,&MPV[1] ); t->SetBranchAddress("MPV_TID" ,&MPV[2] ); t->SetBranchAddress("MPV_TOB" ,&MPV[3] ); t->SetBranchAddress("MPV_TEC" ,&MPV[4] ); t->SetBranchAddress("Gain_TIB" ,&Gain[1] ); t->SetBranchAddress("Gain_TID" ,&Gain[2] ); t->SetBranchAddress("Gain_TOB" ,&Gain[3] ); t->SetBranchAddress("Gain_TEC" ,&Gain[4] ); t->SetBranchAddress("PayloadName",&payloadName ); float NAPV[5]; for(int i=0; i<5; i++){MPV[i]=0; Gain[i]=0; NAPV[i]=0;} TFile * f2 = new TFile(fileName_.c_str()); TTree * t2 = (TTree*) f2->Get("SiStripCalib/APVGain"); float MPV_origin; double Gain_origin; UChar_t subDet; bool isMasked; t2->SetBranchAddress("FitMPV" ,&MPV_origin ); t2->SetBranchAddress("Gain" ,&Gain_origin); t2->SetBranchAddress("SubDet" ,&subDet ); t2->SetBranchAddress("isMasked",&isMasked ); //Looping over tree... printf("Progressing Bar :0%% 20%% 40%% 60%% 80%% 100%%\n"); printf("Looping on the Tree :"); int TreeStep = t2->GetEntries()/50;if(TreeStep==0)TreeStep=1; for (unsigned int ientry = 0; ientry < t2->GetEntries(); ientry++) { if(ientry%TreeStep==0){printf(".");fflush(stdout);} t2->GetEntry(ientry); if(subDet>2 && Gain_origin > 0 && MPV_origin > 0 && ! isMasked){ NAPV[subDet-2]++; NAPV[0]++; Gain[0]+=Gain_origin; MPV[0]+=MPV_origin; Gain[subDet-2]+=Gain_origin; MPV [subDet-2]+=MPV_origin; } } cout<<endl; f2->Close(); for (int i=0; i<5; i++){MPV[i]/=NAPV[i]; Gain[i]/=NAPV[i];} f->cd(); t->Fill(); t->Write(); f->Save(); delete payloadName; f->Close(); }
void ana_complete(int nevts=0) { TDatabasePDG::Instance()->AddParticle("pbarpSystem","pbarpSystem",1.9,kFALSE,0.1,0,"",88888); TStopwatch fTimer; // *** some variables int i=0,j=0, k=0, l=0; gStyle->SetOptFit(1011); // *** the output file for FairRunAna TString OutFile="output.root"; // *** the files coming from the simulation TString inPidFile = "psi2s_jpsi2pi_jpsi_mumu_pid.root"; // this file contains the PndPidCandidates and McTruth TString inParFile = "psi2s_jpsi2pi_jpsi_mumu_par.root"; // *** PID table with selection thresholds; can be modified by the user TString pidParFile = TString(gSystem->Getenv("VMCWORKDIR"))+"/macro/params/all_day1.par"; // *** initialization FairLogger::GetLogger()->SetLogToFile(kFALSE); FairRunAna* fRun = new FairRunAna(); FairRuntimeDb* rtdb = fRun->GetRuntimeDb(); fRun->SetInputFile(inPidFile); // *** setup parameter database FairParRootFileIo* parIO = new FairParRootFileIo(); parIO->open(inParFile); FairParAsciiFileIo* parIOPid = new FairParAsciiFileIo(); parIOPid->open(pidParFile.Data(),"in"); rtdb->setFirstInput(parIO); rtdb->setSecondInput(parIOPid); rtdb->setOutput(parIO); fRun->SetOutputFile(OutFile); fRun->Init(); // *** create an output file for all histograms TFile *out = TFile::Open("output_ana.root","RECREATE"); // *** create some histograms TH1F *hmomtrk = new TH1F("hmomtrk","track momentum (all)",200,0,5); TH1F *hthttrk = new TH1F("hthttrk","track theta (all)",200,0,3.1415); TH1F *hjpsim_all = new TH1F("hjpsim_all","J/#psi mass (all)",200,0,4.5); TH1F *hpsim_all = new TH1F("hpsim_all","#psi(2S) mass (all)",200,0,5); TH1F *hjpsim_lpid = new TH1F("hjpsim_lpid","J/#psi mass (loose pid)",200,0,4.5); TH1F *hpsim_lpid = new TH1F("hpsim_lpid","#psi(2S) mass (loose pid)",200,0,5); TH1F *hjpsim_tpid = new TH1F("hjpsim_tpid","J/#psi mass (tight pid)",200,0,4.5); TH1F *hpsim_tpid = new TH1F("hpsim_tpid","#psi(2S) mass (tight pid)",200,0,5); TH1F *hjpsim_trpid = new TH1F("hjpsim_trpid","J/#psi mass (true pid)",200,0,4.5); TH1F *hpsim_trpid = new TH1F("hpsim_trpid","#psi(2S) mass (true pid)",200,0,5); TH1F *hjpsim_ftm = new TH1F("hjpsim_ftm","J/#psi mass (full truth match)",200,0,4.5); TH1F *hpsim_ftm = new TH1F("hpsim_ftm","#psi(2S) mass (full truth match)",200,0,5); TH1F *hjpsim_nm = new TH1F("hjpsim_nm","J/#psi mass (no truth match)",200,0,4.5); TH1F *hpsim_nm = new TH1F("hpsim_nm","#psi(2S) mass (no truth match)",200,0,5); TH1F *hjpsim_diff = new TH1F("hjpsim_diff","J/#psi mass diff to truth",100,-2,2); TH1F *hpsim_diff = new TH1F("hpsim_diff","#psi(2S) mass diff to truth",100,-2,2); TH1F *hjpsim_vf = new TH1F("hjpsim_vf","J/#psi mass (vertex fit)",200,0,4.5); TH1F *hjpsim_4cf = new TH1F("hjpsim_4cf","J/#psi mass (4C fit)",200,0,4.5); TH1F *hjpsim_mcf = new TH1F("hjpsim_mcf","J/#psi mass (mass constraint fit)",200,0,4.5); TH1F *hjpsi_chi2_vf = new TH1F("hjpsi_chi2_vf", "J/#psi: #chi^{2} vertex fit",100,0,10); TH1F *hpsi_chi2_4c = new TH1F("hpsi_chi2_4c", "#psi(2S): #chi^{2} 4C fit",100,0,250); TH1F *hjpsi_chi2_mf = new TH1F("hjpsi_chi2_mf", "J/#psi: #chi^{2} mass fit",100,0,10); TH1F *hjpsi_prob_vf = new TH1F("hjpsi_prob_vf", "J/#psi: Prob vertex fit",100,0,1); TH1F *hpsi_prob_4c = new TH1F("hpsi_prob_4c", "#psi(2S): Prob 4C fit",100,0,1); TH1F *hjpsi_prob_mf = new TH1F("hjpsi_prob_mf", "J/#psi: Prob mass fit",100,0,1); TH2F *hvpos = new TH2F("hvpos","(x,y) projection of fitted decay vertex",100,-2,2,100,-2,2); // // Now the analysis stuff comes... // // *** the data reader object PndAnalysis* theAnalysis = new PndAnalysis(); if (nevts==0) nevts= theAnalysis->GetEntries(); // *** RhoCandLists for the analysis RhoCandList chrg, muplus, muminus, piplus, piminus, jpsi, psi2s; // *** Mass selector for the jpsi cands double m0_jpsi = TDatabasePDG::Instance()->GetParticle("J/psi")->Mass(); // Get nominal PDG mass of the J/psi RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",m0_jpsi,1.0); // *** the lorentz vector of the initial psi(2S) TLorentzVector ini(0, 0, 6.231552, 7.240065); // *** // the event loop // *** int cntdbltrk=0, cntdblmc=0, cntdblboth=0, cnttrk=0, cnt_dbl_jpsi=0, cnt_dbl_psip=0; while (theAnalysis->GetEvent() && i++<nevts) { if ((i%100)==0) cout<<"evt " << i << endl; // *** Select with no PID info ('All'); type and mass are set theAnalysis->FillList(chrg, "Charged"); theAnalysis->FillList(muplus, "MuonAllPlus"); theAnalysis->FillList(muminus, "MuonAllMinus"); theAnalysis->FillList(piplus, "PionAllPlus"); theAnalysis->FillList(piminus, "PionAllMinus"); // *** momentum and theta histograms for (j=0;j<muplus.GetLength();++j) { hmomtrk->Fill(muplus[j]->P()); hthttrk->Fill(muplus[j]->P4().Theta()); } for (j=0;j<muminus.GetLength();++j) { hmomtrk->Fill(muminus[j]->P()); hthttrk->Fill(muminus[j]->P4().Theta()); } cnttrk += chrg.GetLength(); int n1, n2, n3; countDoubles(chrg,n1,n2,n3); cntdbltrk += n1; cntdblmc += n2; cntdblboth += n3; // *** combinatorics for J/psi -> mu+ mu- jpsi.Combine(muplus, muminus); // *** // *** do the TRUTH MATCH for jpsi // *** jpsi.SetType(443); int nm = 0; for (j=0;j<jpsi.GetLength();++j) { hjpsim_all->Fill( jpsi[j]->M() ); if (theAnalysis->McTruthMatch(jpsi[j])) { nm++; hjpsim_ftm->Fill( jpsi[j]->M() ); hjpsim_diff->Fill( jpsi[j]->GetMcTruth()->M() - jpsi[j]->M() ); } else hjpsim_nm->Fill( jpsi[j]->M() ); } if (nm>1) cnt_dbl_jpsi++; // *** // *** do VERTEX FIT (J/psi) // *** for (j=0;j<jpsi.GetLength();++j) { PndKinVtxFitter vtxfitter(jpsi[j]); // instantiate a vertex fitter vtxfitter.Fit(); double chi2_vtx = vtxfitter.GetChi2(); // access chi2 of fit double prob_vtx = vtxfitter.GetProb(); // access probability of fit hjpsi_chi2_vf->Fill(chi2_vtx); hjpsi_prob_vf->Fill(prob_vtx); if ( prob_vtx > 0.01 ) // when good enough, fill some histos { RhoCandidate *jfit = jpsi[j]->GetFit(); // access the fitted cand TVector3 jVtx=jfit->Pos(); // and the decay vertex position hjpsim_vf->Fill(jfit->M()); hvpos->Fill(jVtx.X(),jVtx.Y()); } } // *** some rough mass selection jpsi.Select(jpsiMassSel); // *** combinatorics for psi(2S) -> J/psi pi+ pi- psi2s.Combine(jpsi, piplus, piminus); // *** // *** do the TRUTH MATCH for psi(2S) // *** psi2s.SetType(88888); nm = 0; for (j=0;j<psi2s.GetLength();++j) { hpsim_all->Fill( psi2s[j]->M() ); if (theAnalysis->McTruthMatch(psi2s[j])) { nm++; hpsim_ftm->Fill( psi2s[j]->M() ); hpsim_diff->Fill( psi2s[j]->GetMcTruth()->M() - psi2s[j]->M() ); } else hpsim_nm->Fill( psi2s[j]->M() ); } if (nm>1) cnt_dbl_psip++; // *** // *** do 4C FIT (initial psi(2S) system) // *** for (j=0;j<psi2s.GetLength();++j) { PndKinFitter fitter(psi2s[j]); // instantiate the kin fitter in psi(2S) fitter.Add4MomConstraint(ini); // set 4 constraint fitter.Fit(); // do fit double chi2_4c = fitter.GetChi2(); // get chi2 of fit double prob_4c = fitter.GetProb(); // access probability of fit hpsi_chi2_4c->Fill(chi2_4c); hpsi_prob_4c->Fill(prob_4c); if ( prob_4c > 0.01 ) // when good enough, fill some histo { RhoCandidate *jfit = psi2s[j]->Daughter(0)->GetFit(); // get fitted J/psi hjpsim_4cf->Fill(jfit->M()); } } // *** // *** do MASS CONSTRAINT FIT (J/psi) // *** for (j=0;j<jpsi.GetLength();++j) { PndKinFitter mfitter(jpsi[j]); // instantiate the PndKinFitter in psi(2S) mfitter.AddMassConstraint(m0_jpsi); // add the mass constraint mfitter.Fit(); // do fit double chi2_m = mfitter.GetChi2(); // get chi2 of fit double prob_m = mfitter.GetProb(); // access probability of fit hjpsi_chi2_mf->Fill(chi2_m); hjpsi_prob_mf->Fill(prob_m); if ( prob_m > 0.01 ) // when good enough, fill some histo { RhoCandidate *jfit = jpsi[j]->GetFit(); // access the fitted cand hjpsim_mcf->Fill(jfit->M()); } } // *** // *** TRUE PID combinatorics // *** // *** do MC truth match for PID type SelectTruePid(theAnalysis, muplus); SelectTruePid(theAnalysis, muminus); SelectTruePid(theAnalysis, piplus); SelectTruePid(theAnalysis, piminus); // *** all combinatorics again with true PID jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_trpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_trpid->Fill( psi2s[j]->M() ); // *** // *** LOOSE PID combinatorics // *** // *** and again with PidAlgoMvd;PidAlgoStt;PidAlgoDrc and loose selection theAnalysis->FillList(muplus, "MuonLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc;PidAlgoMdtHardCuts"); theAnalysis->FillList(muminus, "MuonLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc;PidAlgoMdtHardCuts"); theAnalysis->FillList(piplus, "PionLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_lpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_lpid->Fill( psi2s[j]->M() ); // *** // *** TIGHT PID combinatorics // *** // *** and again with PidAlgoMvd;PidAlgoStt and tight selection theAnalysis->FillList(muplus, "MuonTightPlus", "PidAlgoMdtHardCuts"); theAnalysis->FillList(muminus, "MuonTightMinus", "PidAlgoMdtHardCuts"); theAnalysis->FillList(piplus, "PionLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_tpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_tpid->Fill( psi2s[j]->M() ); } // *** write out all the histos out->cd(); hmomtrk->Write(); hthttrk->Write(); hjpsim_all->Write(); hpsim_all->Write(); hjpsim_lpid->Write(); hpsim_lpid->Write(); hjpsim_tpid->Write(); hpsim_tpid->Write(); hjpsim_trpid->Write(); hpsim_trpid->Write(); hjpsim_ftm->Write(); hpsim_ftm->Write(); hjpsim_nm->Write(); hpsim_nm->Write(); hpsim_diff->Write(); hjpsim_diff->Write(); hjpsim_vf->Write(); hjpsim_4cf->Write(); hjpsim_mcf->Write(); hjpsi_chi2_vf->Write(); hpsi_chi2_4c->Write(); hjpsi_chi2_mf->Write(); hjpsi_prob_vf->Write(); hpsi_prob_4c->Write(); hjpsi_prob_mf->Write(); hvpos->Write(); out->Save(); // Extract the maximal used memory an add is as Dart measurement // This line is filtered by CTest and the value send to CDash FairSystemInfo sysInfo; Float_t maxMemory=sysInfo.GetMaxMemory(); cout << "<DartMeasurement name=\"MaxMemory\" type=\"numeric/double\">"; cout << maxMemory; cout << "</DartMeasurement>" << endl; fTimer.Stop(); Double_t rtime = fTimer.RealTime(); Double_t ctime = fTimer.CpuTime(); Float_t cpuUsage=ctime/rtime; cout << "<DartMeasurement name=\"CpuLoad\" type=\"numeric/double\">"; cout << cpuUsage; cout << "</DartMeasurement>" << endl; cout << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << "s" << endl; cout << "CPU usage " << cpuUsage*100. << "%" << endl; cout << "Max Memory " << maxMemory << " MB" << endl; cout << "Macro finished successfully." << endl; exit(0); }
void select(const TString sample="", const TString tempinput="bacon_sample.root", const Double_t xsec = 1, const Int_t eosflag = 2) { TString input; if(eosflag==2) input = "/afs/cern.ch/work/a/ariostas/public/CP-Higgs/" + tempinput; else if(eosflag==1) input = "root://eoscms.cern.ch//store/user/arapyan/higgs_cp_samples/" + sample + "/Bacon/" + tempinput; else input = "/afs/cern.ch/work/a/arapyan/public/forMarkus/higgs_cp_samples/" + sample + "/" + tempinput; TString output = "/afs/cern.ch/work/a/ariostas/private/CP-Higgs_temp/" + sample + "/" + tempinput; TChain chain("Events"); chain.Add(input); const Double_t DR=0.4; // Data structures to store info from TTrees TGenEventInfo *info = new TGenEventInfo(); TClonesArray *jet = new TClonesArray("baconhep::TGenJet"); TClonesArray *part = new TClonesArray("baconhep::TGenParticle"); chain.SetBranchAddress("GenEvtInfo", &info); TBranch *infoBr = chain.GetBranch("GenEvtInfo"); chain.SetBranchAddress("GenJet" , &jet ); TBranch *jetBr = chain.GetBranch("GenJet"); chain.SetBranchAddress("GenParticle", &part); TBranch *partBr = chain.GetBranch("GenParticle"); // Output file and trees TFile *outfile = new TFile(output, "RECREATE"); TTree *infoTree = new TTree("Count", "Count"); Long64_t n = chain.GetEntries(); infoTree->Branch("n", &n, "n/i"); infoTree->Fill(); TTree *outtree = new TTree("Events", "Events"); Double_t eventWeight; UInt_t ncpions1=0, ncpions2=0, nnpions1=0, nnpions2=0, nLeptons=0; Int_t zToLep=0; // Jets matched to gen taus Double_t jetTau1_pt, jetTau2_pt; Double_t jetTau1_eta, jetTau2_eta; Double_t jetTau1_phi, jetTau2_phi; Double_t jetTau1_mass, jetTau2_mass; // Gen taus Double_t genTau1_pt, genTau2_pt; Double_t genTau1_eta, genTau2_eta; Double_t genTau1_phi, genTau2_phi; Double_t genTau1_mass, genTau2_mass; // Visible taus (taus minus neutrino) Double_t visTau1_pt, visTau2_pt; Double_t visTau1_eta, visTau2_eta; Double_t visTau1_phi, visTau2_phi; Double_t visTau1_mass, visTau2_mass; // Charged pions coming from taus Double_t cpions1_pt, cpions2_pt; Double_t cpions1_eta, cpions2_eta; Double_t cpions1_phi, cpions2_phi; Double_t cpions1_mass, cpions2_mass; // Neutral pions coming from taus Double_t npions1_pt, npions2_pt; Double_t npions1_eta, npions2_eta; Double_t npions1_phi, npions2_phi; Double_t npions1_mass, npions2_mass; // Particles/jets from Z Double_t z1_pt, z2_pt; Double_t z1_eta, z2_eta; Double_t z1_phi, z2_phi; Double_t z1_mass, z2_mass; // Z Double_t z_pt, z_eta, z_phi, z_mass; // Reco Z Double_t recoz_pt, recoz_eta, recoz_phi, recoz_mass; outtree->Branch("eventWeight", &eventWeight, "eventWeight/D"); // event weight from cross-section and Event->Weight outtree->Branch("nLeptons", &nLeptons, "nLeptons/i"); // number of leptons outtree->Branch("ncpions1", &ncpions1, "ncpions1/i"); outtree->Branch("ncpions2", &ncpions2, "ncpions2/i"); outtree->Branch("nnpions1", &nnpions1, "nnpions1/i"); outtree->Branch("nnpions2", &nnpions2, "nnpions2/i"); outtree->Branch("zToLep", &zToLep, "zToLep/I"); outtree->Branch("jetTau1_pt", &jetTau1_pt, "jetTau1_pt/D"); // pt(Tau1) outtree->Branch("jetTau1_eta", &jetTau1_eta, "jetTau1_eta/D"); // eta(Tau1) outtree->Branch("jetTau1_phi", &jetTau1_phi, "jetTau1_phi/D"); // phi(Tau1) outtree->Branch("jetTau1_mass", &jetTau1_mass, "jetTau1_mass/D"); // m(Tau1) outtree->Branch("jetTau2_pt", &jetTau2_pt, "jetTau2_pt/D"); // pt(Tau2) outtree->Branch("jetTau2_eta", &jetTau2_eta, "jetTau2_eta/D"); // eta(Tau2) outtree->Branch("jetTau2_phi", &jetTau2_phi, "jetTau2_phi/D"); // phi(Tau2) outtree->Branch("jetTau2_mass", &jetTau2_mass, "jetTau2_mass/D"); // m(Tau2) outtree->Branch("genTau1_pt", &genTau1_pt, "genTau1_pt/D"); // pt(Tau1) outtree->Branch("genTau1_eta", &genTau1_eta, "genTau1_eta/D"); // eta(Tau1) outtree->Branch("genTau1_phi", &genTau1_phi, "genTau1_phi/D"); // phi(Tau1) outtree->Branch("genTau1_mass", &genTau1_mass, "genTau1_mass/D"); // m(Tau1) outtree->Branch("genTau2_pt", &genTau2_pt, "genTau2_pt/D"); // pt(Tau2) outtree->Branch("genTau2_eta", &genTau2_eta, "genTau2_eta/D"); // eta(Tau2) outtree->Branch("genTau2_phi", &genTau2_phi, "genTau2_phi/D"); // phi(Tau2) outtree->Branch("genTau2_mass", &genTau2_mass, "genTau2_mass/D"); // m(Tau2) outtree->Branch("visTau1_pt", &visTau1_pt, "visTau1_pt/D"); // pt(Tau1) outtree->Branch("visTau1_eta", &visTau1_eta, "visTau1_eta/D"); // eta(Tau1) outtree->Branch("visTau1_phi", &visTau1_phi, "visTau1_phi/D"); // phi(Tau1) outtree->Branch("visTau1_mass", &visTau1_mass, "visTau1_mass/D"); // m(Tau1) outtree->Branch("visTau2_pt", &visTau2_pt, "visTau2_pt/D"); // pt(Tau2) outtree->Branch("visTau2_eta", &visTau2_eta, "visTau2_eta/D"); // eta(Tau2) outtree->Branch("visTau2_phi", &visTau2_phi, "visTau2_phi/D"); // phi(Tau2) outtree->Branch("visTau2_mass", &visTau2_mass, "visTau2_mass/D"); // m(Tau2) outtree->Branch("cpions1_pt", &cpions1_pt, "cpions1_pt/D"); outtree->Branch("cpions1_eta", &cpions1_eta, "cpions1_eta/D"); outtree->Branch("cpions1_phi", &cpions1_phi, "cpions1_phi/D"); outtree->Branch("cpions1_mass", &cpions1_mass, "cpions1_mass/D"); outtree->Branch("cpions2_pt", &cpions2_pt, "pions2_pt/D"); outtree->Branch("cpions2_eta", &cpions2_eta, "pions2_eta/D"); outtree->Branch("cpions2_phi", &cpions2_phi, "pions2_phi/D"); outtree->Branch("cpions2_mass", &cpions2_mass, "pions2_mass/D"); outtree->Branch("npions1_pt", &npions1_pt, "npions1_pt/D"); outtree->Branch("npions1_eta", &npions1_eta, "npions1_eta/D"); outtree->Branch("npions1_phi", &npions1_phi, "npions1_phi/D"); outtree->Branch("npions1_mass", &npions1_mass, "npions1_mass/D"); outtree->Branch("npions2_pt", &npions2_pt, "npions2_pt/D"); outtree->Branch("npions2_eta", &npions2_eta, "npions2_eta/D"); outtree->Branch("npions2_phi", &npions2_phi, "npions2_phi/D"); outtree->Branch("npions2_mass", &npions2_mass, "npions2_mass/D"); outtree->Branch("z1_pt", &z1_pt, "z1_pt/D"); outtree->Branch("z1_eta", &z1_eta, "z1_eta/D"); outtree->Branch("z1_phi", &z1_phi, "z1_phi/D"); outtree->Branch("z1_mass", &z1_mass, "z1_mass/D"); outtree->Branch("z2_pt", &z2_pt, "z2_pt/D"); outtree->Branch("z2_eta", &z2_eta, "z2_eta/D"); outtree->Branch("z2_phi", &z2_phi, "z2_phi/D"); outtree->Branch("z2_mass", &z2_mass, "z2_mass/D"); outtree->Branch("z_pt", &z_pt, "z_pt/D"); outtree->Branch("z_eta", &z_eta, "z_eta/D"); outtree->Branch("z_phi", &z_phi, "z_phi/D"); outtree->Branch("z_mass", &z_mass, "z_mass/D"); outtree->Branch("recoz_pt", &recoz_pt, "recoz_pt/D"); outtree->Branch("recoz_eta", &recoz_eta, "recoz_eta/D"); outtree->Branch("recoz_phi", &recoz_phi, "recoz_phi/D"); outtree->Branch("recoz_mass", &recoz_mass, "recoz_mass/D"); for (Int_t i=0; i<chain.GetEntries(); i++) { if(i==0 || (i+1)%1000==0) cout << "Processing event " << i+1 << endl; infoBr->GetEntry(i); part->Clear(); partBr->GetEntry(i); jet->Clear(); //jetBr->GetEntry(i); if (part->GetEntries()==0) continue; Int_t iTau1=-1, iTau2=-1; Int_t iT1=-1, iT2=-1; Int_t iZ1=-1, iZ2=-1; Int_t ijetZ1=-1, ijetZ2=-1; Int_t iZ=-1; // Reset variables nLeptons=ncpions1=ncpions2=nnpions1=nnpions2=zToLep=0; jetTau1_pt=jetTau1_eta=jetTau1_phi=jetTau1_mass=0; jetTau2_pt=jetTau2_eta=jetTau2_phi=jetTau2_mass=0; genTau1_pt=genTau1_eta=genTau1_phi=genTau1_mass=0; genTau2_pt=genTau2_eta=genTau2_phi=genTau2_mass=0; visTau1_pt=visTau1_eta=visTau1_phi=visTau1_mass=0; visTau2_pt=visTau2_eta=visTau2_phi=visTau2_mass=0; cpions1_pt=cpions1_eta=cpions1_phi=cpions1_mass=0; cpions2_pt=cpions2_eta=cpions2_phi=cpions2_mass=0; npions1_pt=npions1_eta=npions1_phi=npions1_mass=0; npions2_pt=npions2_eta=npions2_phi=npions2_mass=0; z1_pt=z1_eta=z1_phi=z1_mass=0; z2_pt=z2_eta=z2_phi=z2_mass=0; z_pt=z_eta=z_phi=z_mass=0; recoz_pt=recoz_eta=recoz_phi=recoz_mass=0; eventWeight=xsec*1000.0; bool hasH=false, hasZ=false; for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); if(abs(genloop->pdgId)==25) hasH = true; if(abs(genloop->pdgId)==23) hasZ = true; } Int_t tausParent=-1; for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); Int_t parentPdg=abs(dynamic_cast<TGenParticle *>(part->At(genloop->parent>-1 ? genloop->parent : 0))->pdgId); if(hasH){ if (abs(genloop->pdgId)==15) { if (iTau1==-1 && parentPdg==25) { iTau1=j; tausParent=genloop->parent; } else if (genloop->parent==iTau1) { iTau1=j; } else if (iTau2==-1 && parentPdg==25 && tausParent==genloop->parent) { iTau2=j; } else if (genloop->parent==iTau2) { iTau2=j; } } } else if(hasZ){ if (abs(genloop->pdgId)==15) { if (iTau1==-1 && parentPdg==23) { iTau1=j; tausParent=genloop->parent; } else if (genloop->parent==iTau1) { iTau1=j; } else if (iTau2==-1 && parentPdg==23 && tausParent==genloop->parent) { iTau2=j; } else if (genloop->parent==iTau2) { iTau2=j; } } } else{ if (abs(genloop->pdgId)==15) { if (iTau1==-1) { iTau1=j; tausParent=genloop->parent; } else if (genloop->parent==iTau1) { iTau1=j; } else if (iTau2==-1 && tausParent==genloop->parent) { iTau2=j; } else if (genloop->parent==iTau2) { iTau2=j; } } } } if (iTau1==-1 || iTau2==-1) continue; Int_t isLep=0; for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); Int_t parentPdg=abs(dynamic_cast<TGenParticle *>(part->At(genloop->parent>-1 ? genloop->parent : 0))->pdgId); if (genloop->parent != iTau1 && genloop->parent != iTau2) continue; if ((abs(genloop->pdgId)==13||abs(genloop->pdgId)==11)){ isLep=1; } } if (isLep!=0) continue; if(dynamic_cast<TGenParticle *>(part->At(iTau1))->pdgId==15 && dynamic_cast<TGenParticle *>(part->At(iTau2))->pdgId==-15) { Int_t temp=iTau1; iTau1=iTau2; iTau2=temp; } else if(dynamic_cast<TGenParticle *>(part->At(iTau1))->pdgId==-15 && dynamic_cast<TGenParticle *>(part->At(iTau2))->pdgId==15) { } else { cout << "Ignoring event." << endl; continue; } for (Int_t j=0; j<part->GetEntries(); j++) { TGenParticle* genloop = (TGenParticle*) ((*part)[j]); Int_t pdg=abs(genloop->pdgId); Int_t parent=genloop->parent; if(pdg==23){ if(iZ==-1){ iZ=j; } else if(parent==iZ){ iZ=j; } } } TLorentzVector cpions1, cpions2, npions1, npions2; cpions1.SetPxPyPzE(0,0,0,0); cpions2.SetPxPyPzE(0,0,0,0); npions1.SetPxPyPzE(0,0,0,0); npions2.SetPxPyPzE(0,0,0,0); for (Int_t j=0; j<part->GetEntries(); j++) { TGenParticle* genloop = (TGenParticle*) ((*part)[j]); Int_t pdg=abs(genloop->pdgId); Int_t parent=genloop->parent; if(pdg!=211 && pdg!=111) continue; Int_t parentTau=0; if(parent==iTau1) parentTau=1; else if(parent==iTau2) parentTau=2; if(parentTau==0) continue; TLorentzVector vTemp; vTemp.SetPtEtaPhiM(genloop->pt, genloop->eta, genloop->phi, genloop->mass); if(parentTau==1) { if(pdg==211){ cpions1+=vTemp; ncpions1++; } else{ npions1+=vTemp; nnpions1++; } } else { if(pdg==211){ cpions2+=vTemp; ncpions2++; } else{ npions2+=vTemp; nnpions2++; } } } TLorentzVector vRecoZ; vRecoZ.SetPxPyPzE(0,0,0,0); for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); if (fabs(genloop->pdgId)==12 || fabs(genloop->pdgId)==14 || fabs(genloop->pdgId)==14) continue; if(fabs(genloop->eta) > 5. || genloop->status!=1) continue; if(deltaR(genloop->eta, cpions1.Eta(), genloop->phi, cpions1.Phi()) < DR) continue; if(deltaR(genloop->eta, cpions2.Eta(), genloop->phi, cpions2.Phi()) < DR) continue; if(deltaR(genloop->eta, npions1.Eta(), genloop->phi, npions1.Phi()) < DR) continue; if(deltaR(genloop->eta, npions2.Eta(), genloop->phi, npions2.Phi()) < DR) continue; TLorentzVector vTemp; vTemp.SetPtEtaPhiM(genloop->pt, genloop->eta, genloop->phi, genloop->mass); vRecoZ+=vTemp; } const TGenParticle* genTau1 = (TGenParticle*) ((*part)[iTau1]); TLorentzVector vGenTau1; vGenTau1.SetPtEtaPhiM(genTau1->pt, genTau1->eta, genTau1->phi, genTau1->mass); const TGenParticle* genTau2 = (TGenParticle*) ((*part)[iTau2]); TLorentzVector vGenTau2; vGenTau2.SetPtEtaPhiM(genTau2->pt, genTau2->eta, genTau2->phi, genTau2->mass); TLorentzVector vVisTau1, vVisTau2; if (deltaR(genTau1->eta, genTau2->eta, genTau1->phi, genTau2->phi)<DR) continue; for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); if (fabs(genloop->pdgId)!=16) continue; TLorentzVector vTemp; vTemp.SetPtEtaPhiM(genloop->pt, genloop->eta, genloop->phi, 0); if (genloop->parent==iTau1) { vVisTau1=vGenTau1-vTemp; } if (genloop->parent==iTau2) { vVisTau2=vGenTau2-vTemp; } } for (Int_t j=0; j<jet->GetEntries(); j++) { const TGenJet* loop = (TGenJet*) ((*jet)[j]); if(loop->pt < 10) continue; if (iT1==-1) { if(deltaR(loop->eta,vVisTau1.Eta(),loop->phi,vVisTau1.Phi())<DR){ iT1=j; continue; } } if(iT1!=-1 && ((TGenJet*) ((*jet)[iT1]))->pt < loop->pt){ if(deltaR(loop->eta,vVisTau1.Eta(),loop->phi,vVisTau1.Phi())<DR){ iT1=j; continue; } } if (iT2==-1) { if(deltaR(loop->eta,vVisTau2.Eta(),loop->phi,vVisTau2.Phi())<DR){ iT2=j; continue; } } if(iT2!=-1 && ((TGenJet*) ((*jet)[iT2]))->pt < loop->pt){ if(deltaR(loop->eta,vVisTau2.Eta(),loop->phi,vVisTau2.Phi())<DR){ iT2=j; continue; } } } for (Int_t j=0; j<jet->GetEntries(); j++) { const TGenJet* loop = (TGenJet*) ((*jet)[j]); if(loop->pt < 20) continue; if(deltaR(vVisTau1.Eta(), loop->eta, vVisTau1.Phi(), loop->phi)<DR+0.5) continue; if(deltaR(vVisTau2.Eta(), loop->eta, vVisTau2.Phi(), loop->phi)<DR+0.5) continue; if (ijetZ1==-1) { ijetZ1=j; } else if(((TGenJet*) ((*jet)[ijetZ1]))->pt < loop->pt){ ijetZ2=ijetZ1; ijetZ1=j; } else if (ijetZ2==-1) { ijetZ2=j; } else if(((TGenJet*) ((*jet)[ijetZ2]))->pt < loop->pt){ ijetZ2=j; } } if(ijetZ1==-1 || ijetZ2==-1) zToLep=1; if(zToLep==1){ for (Int_t j=0; j<part->GetEntries(); j++) { TGenParticle *genloop = (TGenParticle*) ((*part)[j]); Int_t pdg=abs(genloop->pdgId); Int_t parent=genloop->parent; if(pdg!=11 && pdg!= 13) continue; if(genloop->pt < 20) continue; if(deltaR(vVisTau1.Eta(), genloop->eta, vVisTau1.Phi(), genloop->phi)<DR+0.5) continue; if(deltaR(vVisTau2.Eta(), genloop->eta, vVisTau2.Phi(), genloop->phi)<DR+0.5) continue; if (iZ1==-1) { iZ1=j; } else if(((TGenParticle*) ((*part)[iZ1]))->pt < genloop->pt){ iZ1=j; } } if(iZ1!=-1){ for (Int_t j=0; j<part->GetEntries(); j++) { TGenParticle* genloop = (TGenParticle*) ((*part)[j]); Int_t pdg=abs(genloop->pdgId); Int_t parent=genloop->parent; if(pdg!=11 && pdg!= 13) continue; if(genloop->pt < 30) continue; if(iZ1==j) continue; if(pdg!=abs(((TGenParticle*) ((*part)[iZ1]))->pdgId)) continue; if(deltaR(vVisTau1.Eta(), genloop->eta, vVisTau1.Phi(), genloop->phi)<DR+0.5) continue; if(deltaR(vVisTau2.Eta(), genloop->eta, vVisTau2.Phi(), genloop->phi)<DR+0.5) continue; if (iZ2==-1) { iZ2=j; } else if(((TGenParticle*) ((*part)[iZ2]))->pt < genloop->pt){ iZ2=j; } } } } if(zToLep==1 && (iZ1==-1 || iZ2==-1)) zToLep=-1; if(iZ==-1 && (iZ1==-1 || iZ2==-1) && (ijetZ1==-1 || ijetZ2==-1)) continue; if(zToLep==0){ const TGenJet *jetZ1, *jetZ2; jetZ1 = (TGenJet*) ((*jet)[ijetZ1]); jetZ2 = (TGenJet*) ((*jet)[ijetZ2]); z1_pt=jetZ1->pt; z1_eta=jetZ1->eta; z1_phi=jetZ1->phi; z1_mass=jetZ1->mass; z2_pt=jetZ2->pt; z2_eta=jetZ2->eta; z2_phi=jetZ2->phi; z2_mass=jetZ2->mass; } if(zToLep==1){ const TGenParticle *z1, *z2; z1 = (TGenParticle*) ((*part)[iZ1]); z2 = (TGenParticle*) ((*part)[iZ2]); z1_pt=z1->pt; z1_eta=z1->eta; z1_phi=z1->phi; z1_mass=z1->mass; z2_pt=z2->pt; z2_eta=z2->eta; z2_phi=z2->phi; z2_mass=z2->mass; } if(iZ!=-1){ const TGenParticle *parZ = (TGenParticle*) ((*part)[iZ]); z_pt = parZ->pt; z_eta = parZ->eta; z_phi = parZ->phi; z_mass = parZ->mass; } recoz_pt = vRecoZ.Pt(); recoz_eta = vRecoZ.Eta(); recoz_phi = vRecoZ.Phi(); recoz_mass = vRecoZ.M(); if(iT1!=-1 && iT2!=-1){ const TGenJet *taujet1, *taujet2; taujet1 = (TGenJet*) ((*jet)[iT1]); taujet2 = (TGenJet*) ((*jet)[iT2]); jetTau1_pt=taujet1->pt; jetTau1_eta=taujet1->eta; jetTau1_phi=taujet1->phi; jetTau1_mass=taujet1->mass; jetTau2_pt=taujet2->pt; jetTau2_eta=taujet2->eta; jetTau2_phi=taujet2->phi; jetTau2_mass=taujet2->mass; } genTau1_pt=genTau1->pt; genTau1_eta=genTau1->eta; genTau1_phi=genTau1->phi; genTau1_mass=genTau1->mass; genTau2_pt=genTau2->pt; genTau2_eta=genTau2->eta; genTau2_phi=genTau2->phi; genTau2_mass=genTau2->mass; visTau1_pt=vVisTau1.Pt(); visTau1_eta=vVisTau1.Eta(); visTau1_phi=vVisTau1.Phi(); visTau1_mass=vVisTau1.M(); visTau2_pt=vVisTau2.Pt(); visTau2_eta=vVisTau2.Eta(); visTau2_phi=vVisTau2.Phi(); visTau2_mass=vVisTau2.M(); cpions1_pt=cpions1.Pt(); cpions1_eta=cpions1.Eta(); cpions1_phi=cpions1.Phi(); cpions1_mass=cpions1.M(); cpions2_pt=cpions2.Pt(); cpions2_eta=cpions2.Eta(); cpions2_phi=cpions2.Phi(); cpions2_mass=cpions2.M(); npions1_pt=npions1.Pt(); npions1_eta=npions1.Eta(); npions1_phi=npions1.Phi(); npions1_mass=npions1.M(); npions2_pt=npions2.Pt(); npions2_eta=npions2.Eta(); npions2_phi=npions2.Phi(); npions2_mass=npions2.M(); for (Int_t j=0; j<part->GetEntries(); j++) { const TGenParticle* genloop = (TGenParticle*) ((*part)[j]); if ( genloop->pt<20) continue; if ( abs(genloop->pdgId)!=13 && abs(genloop->pdgId)!=11 ) continue; nLeptons++; } outtree->Fill(); } outfile->Write(); outfile->Save(); }
void combinefiles(const TString input="temp.txt", const TString outputfile="test.root") { // read input file TChain *eventChain = new TChain("Events"); TChain *countChain = new TChain("Count"); ifstream ifs; ifs.open(input.Data()); assert(ifs.is_open()); string line; getline(ifs,line); while(getline(ifs,line)) { eventChain->Add(TString(line)); countChain->Add(TString(line)); } ifs.close(); Int_t iHmatch1=-1, iHmatch2=-1, iHmatch3=-1, iHmatch4=-1; Int_t eventType; Int_t genInfo; Float_t eventWeight; Int_t sampleNo; Int_t isBBTT; Int_t isBBGG; Int_t isBBBB; Int_t isVBFTT; Int_t isVBF4B; Float_t met, metPhi; Float_t ppMet, ppMetPhi; Float_t pileupMet, pileupMetPhi; Int_t nCentral=0, nBtag=0; Int_t centB=0; Int_t nJets=0; Int_t tauCat1=0, tauCat2=0; Int_t bTag1=0, bTag2=0, bTag3=0, bTag4=0; Int_t jbTag_tt1=0, jbTag_tt2=0, jbTag_6j1=0, jbTag_6j2=0; Double_t mt2=0; Double_t mt2puppi=0; Double_t mt2pileup=0; Double_t m_sv=0; Double_t m_svpileup=0; Double_t m_svpuppi=0; Float_t ptTau1, ptTau2, ptTrk1, ptTrk2, ptB1, ptB2, ptB3, ptB4, ptG1, ptG2, ptJet_tt1, ptJet_tt2, ptJet_6j1, ptJet_6j2, tauIso1, tauIso2; Float_t etaTau1, etaTau2, etaTrk1, etaTrk2, etaB1, etaB2, etaB3, etaB4, etaG1, etaG2, etaJet_tt1, etaJet_tt2, etaJet_6j1, etaJet_6j2; Float_t phiTau1, phiTau2, phiTrk1, phiTrk2, phiB1, phiB2, phiB3, phiB4, phiG1, phiG2, phiJet_tt1, phiJet_tt2, phiJet_6j1, phiJet_6j2; Float_t mTau1, mTau2, mTrk1, mTrk2, mB1, mB2, mB3, mB4, eG1, eG2, mJet_tt1, mJet_tt2, mJet_6j1, mJet_6j2; Float_t ptTau1_gen, ptTau2_gen, ptB1_gen, ptB2_gen, ptB3_gen, ptB4_gen, ptG1_gen, ptG2_gen, ptJet_tt1_gen, ptJet_tt2_gen, ptJet_6j1_gen, ptJet_6j2_gen; Float_t etaTau1_gen, etaTau2_gen, etaB1_gen, etaB2_gen, etaB3_gen, etaB4_gen, etaG1_gen, etaG2_gen, etaJet_tt1_gen, etaJet_tt2_gen, etaJet_6j1_gen, etaJet_6j2_gen; Float_t phiTau1_gen, phiTau2_gen, phiB1_gen, phiB2_gen, phiB3_gen, phiB4_gen, phiG1_gen, phiG2_gen, phiJet_tt1_gen, phiJet_tt2_gen, phiJet_6j1_gen, phiJet_6j2_gen; Float_t mTau1_gen, mTau2_gen, mB1_gen, mB2_gen, mB3_gen, mB4_gen, eG1_gen, eG2_gen, mJet_tt1_gen, mJet_tt2_gen, mJet_6j1_gen, mJet_6j2_gen; Float_t gamIso1, gamIso2; Float_t ptH1_gen, etaH1_gen, phiH1_gen, mH1_gen; Float_t ptH2_gen, etaH2_gen, phiH2_gen, mH2_gen; Float_t ptTau1_genJet, ptTau2_genJet, etaTau1_genJet, etaTau2_genJet, phiTau1_genJet, phiTau2_genJet, mTau1_genJet, mTau2_genJet; Float_t ptTT, ptBB1, ptBB2, ptGG, ptJJ_tt, ptJJ_6j, ptHH; Float_t etaTT, etaBB1, etaBB2, etaGG, etaJJ_tt, etaJJ_6j, etaHH; Float_t phiTT, phiBB1, phiBB2, phiGG, phiJJ_tt, phiJJ_6j, phiHH; Float_t mTT, mBB1, mBB2, mGG, mJJ_tt, mJJ_6j, mHH; Float_t dEta_tt=0, dEta_6j=0; Int_t n; Float_t rho_0=0, rho_1=0, rho_2=0; Float_t dEtaBB1=0, dEtaTT=0, dEtaHH=0; Float_t dPhiBB1=0, dPhiTT=0, dPhiHH=0; Float_t dRBB1=0, dRTT=0, dRHH=0; Float_t bdtVal=0; Float_t chi2=0, corrMet=0, corrMetPhi=0; Int_t conv=-999; TFile *outFile = new TFile(outputfile, "RECREATE"); countChain->SetBranchAddress("n", &n); Int_t nevents=0; for (Int_t i=0; i<countChain->GetEntries(); i++) { countChain->GetEntry(i); nevents+=n; } cout << nevents << endl; eventChain->SetBranchAddress("eventWeight", &eventWeight); eventChain->SetBranchAddress("sampleNo", &sampleNo); eventChain->SetBranchAddress("genInfo", &genInfo); eventChain->SetBranchAddress("isBBTT", &isBBTT); eventChain->SetBranchAddress("isBBGG", &isBBGG); eventChain->SetBranchAddress("isBBBB", &isBBBB); eventChain->SetBranchAddress("isVBFTT", &isVBFTT); eventChain->SetBranchAddress("isVBF4B", &isVBF4B); eventChain->SetBranchAddress("eventType", &eventType); eventChain->SetBranchAddress("met", &met); eventChain->SetBranchAddress("metPhi", &metPhi); eventChain->SetBranchAddress("pileupmet", &pileupMet); eventChain->SetBranchAddress("pileupmetPhi", &pileupMetPhi); eventChain->SetBranchAddress("puppiMet", &ppMet); eventChain->SetBranchAddress("puppiMetPhi", &ppMetPhi); eventChain->SetBranchAddress("ptTau1", &ptTau1); eventChain->SetBranchAddress("etaTau1", &etaTau1); eventChain->SetBranchAddress("phiTau1", &phiTau1); eventChain->SetBranchAddress("mTau1", &mTau1); eventChain->SetBranchAddress("tauCat1", &tauCat1); eventChain->SetBranchAddress("tauIso1", &tauIso1); eventChain->SetBranchAddress("ptTau2", &ptTau2); eventChain->SetBranchAddress("etaTau2", &etaTau2); eventChain->SetBranchAddress("phiTau2", &phiTau2); eventChain->SetBranchAddress("mTau2", &mTau2); eventChain->SetBranchAddress("tauCat2", &tauCat2); eventChain->SetBranchAddress("tauIso2", &tauIso2); eventChain->SetBranchAddress("ptTrk1", &ptTrk1); eventChain->SetBranchAddress("etaTrk1", &etaTrk1); eventChain->SetBranchAddress("phiTrk1", &phiTrk1); eventChain->SetBranchAddress("mTrk1", &mTrk1); eventChain->SetBranchAddress("ptTrk2", &ptTrk2); eventChain->SetBranchAddress("etaTrk2", &etaTrk2); eventChain->SetBranchAddress("phiTrk2", &phiTrk2); eventChain->SetBranchAddress("mTrk2", &mTrk2); eventChain->SetBranchAddress("ptG1", &ptG1); eventChain->SetBranchAddress("etaG1", &etaG1); eventChain->SetBranchAddress("phiG1", &phiG1); eventChain->SetBranchAddress("eG1", &eG1); //eventChain->SetBranchAddress("gamIso1", &gamIso1); eventChain->SetBranchAddress("ptG2", &ptG2); eventChain->SetBranchAddress("etaG2", &etaG2); eventChain->SetBranchAddress("phiG2", &phiG2); eventChain->SetBranchAddress("eG2", &eG2); //eventChain->SetBranchAddress("gamIso2", &gamIso2); eventChain->SetBranchAddress("ptB1", &ptB1); eventChain->SetBranchAddress("etaB1", &etaB1); eventChain->SetBranchAddress("phiB1", &phiB1); eventChain->SetBranchAddress("mB1", &mB1); eventChain->SetBranchAddress("bTag1", &bTag1); eventChain->SetBranchAddress("ptB2", &ptB2); eventChain->SetBranchAddress("etaB2", &etaB2); eventChain->SetBranchAddress("phiB2", &phiB2); eventChain->SetBranchAddress("mB2", &mB2); eventChain->SetBranchAddress("bTag2", &bTag2); eventChain->SetBranchAddress("ptB3", &ptB3); eventChain->SetBranchAddress("etaB3", &etaB3); eventChain->SetBranchAddress("phiB3", &phiB3); eventChain->SetBranchAddress("mB3", &mB3); eventChain->SetBranchAddress("bTag3", &bTag3); eventChain->SetBranchAddress("ptB4", &ptB4); eventChain->SetBranchAddress("etaB4", &etaB4); eventChain->SetBranchAddress("phiB4", &phiB4); eventChain->SetBranchAddress("mB4", &mB4); eventChain->SetBranchAddress("bTag4", &bTag4); eventChain->SetBranchAddress("ptJet_tt1", &ptJet_tt1); eventChain->SetBranchAddress("etaJet_tt1", &etaJet_tt1); eventChain->SetBranchAddress("phiJet_tt1", &phiJet_tt1); eventChain->SetBranchAddress("mJet_tt1", &mJet_tt1); eventChain->SetBranchAddress("jbTag_tt1", &jbTag_tt1); eventChain->SetBranchAddress("ptJet_tt2", &ptJet_tt2); eventChain->SetBranchAddress("etaJet_tt2", &etaJet_tt2); eventChain->SetBranchAddress("phiJet_tt2", &phiJet_tt2); eventChain->SetBranchAddress("mJet_tt2", &mJet_tt2); eventChain->SetBranchAddress("jbTag_tt2", &jbTag_tt2); eventChain->SetBranchAddress("ptJet_6j1", &ptJet_6j1); eventChain->SetBranchAddress("etaJet_6j1", &etaJet_6j1); eventChain->SetBranchAddress("phiJet_6j1", &phiJet_6j1); eventChain->SetBranchAddress("mJet_6j1", &mJet_6j1); eventChain->SetBranchAddress("jbTag_6j1", &jbTag_6j1); eventChain->SetBranchAddress("ptJet_6j2", &ptJet_6j2); eventChain->SetBranchAddress("etaJet_6j2", &etaJet_6j2); eventChain->SetBranchAddress("phiJet_6j2", &phiJet_6j2); eventChain->SetBranchAddress("mJet_6j2", &mJet_6j2); eventChain->SetBranchAddress("jbTag_6j2", &jbTag_6j2); eventChain->SetBranchAddress("ptTau1_gen", &ptTau1_gen); eventChain->SetBranchAddress("etaTau1_gen", &etaTau1_gen); eventChain->SetBranchAddress("phiTau1_gen", &phiTau1_gen); eventChain->SetBranchAddress("mTau1_gen", &mTau1_gen); eventChain->SetBranchAddress("ptTau2_gen", &ptTau2_gen); eventChain->SetBranchAddress("etaTau2_gen", &etaTau2_gen); eventChain->SetBranchAddress("phiTau2_gen", &phiTau2_gen); eventChain->SetBranchAddress("mTau2_gen", &mTau2_gen); eventChain->SetBranchAddress("ptTau1_genJet", &ptTau1_genJet); eventChain->SetBranchAddress("etaTau1_genJet", &etaTau1_genJet); eventChain->SetBranchAddress("phiTau1_genJet", &phiTau1_genJet); eventChain->SetBranchAddress("mTau1_genJet", &mTau1_genJet); eventChain->SetBranchAddress("ptTau2_genJet", &ptTau2_genJet); eventChain->SetBranchAddress("etaTau2_genJet", &etaTau2_genJet); eventChain->SetBranchAddress("phiTau2_genJet", &phiTau2_genJet); eventChain->SetBranchAddress("mTau2_genJet", &mTau2_genJet); eventChain->SetBranchAddress("ptG1_gen", &ptG1_gen); eventChain->SetBranchAddress("etaG1_gen", &etaG1_gen); eventChain->SetBranchAddress("phiG1_gen", &phiG1_gen); eventChain->SetBranchAddress("eG1_gen", &eG1_gen); eventChain->SetBranchAddress("ptG2_gen", &ptG2_gen); eventChain->SetBranchAddress("etaG2_gen", &etaG2_gen); eventChain->SetBranchAddress("phiG2_gen", &phiG2_gen); eventChain->SetBranchAddress("eG2_gen", &eG2_gen); eventChain->SetBranchAddress("ptB1_gen", &ptB1_gen); eventChain->SetBranchAddress("etaB1_gen", &etaB1_gen); eventChain->SetBranchAddress("phiB1_gen", &phiB1_gen); eventChain->SetBranchAddress("mB1_gen", &mB1_gen); eventChain->SetBranchAddress("iHmatch1", &iHmatch1); eventChain->SetBranchAddress("ptB2_gen", &ptB2_gen); eventChain->SetBranchAddress("etaB2_gen", &etaB2_gen); eventChain->SetBranchAddress("phiB2_gen", &phiB2_gen); eventChain->SetBranchAddress("mB2_gen", &mB2_gen); eventChain->SetBranchAddress("iHmatch2", &iHmatch2); eventChain->SetBranchAddress("ptB3_gen", &ptB3_gen); eventChain->SetBranchAddress("etaB3_gen", &etaB3_gen); eventChain->SetBranchAddress("phiB3_gen", &phiB3_gen); eventChain->SetBranchAddress("mB3_gen", &mB3_gen); eventChain->SetBranchAddress("iHmatch3", &iHmatch3); eventChain->SetBranchAddress("ptB4_gen", &ptB4_gen); eventChain->SetBranchAddress("etaB4_gen", &etaB4_gen); eventChain->SetBranchAddress("phiB4_gen", &phiB4_gen); eventChain->SetBranchAddress("mB4_gen", &mB4_gen); eventChain->SetBranchAddress("iHmatch4", &iHmatch4); eventChain->SetBranchAddress("ptH1_gen", &ptH1_gen); eventChain->SetBranchAddress("etaH1_gen", &etaH1_gen); eventChain->SetBranchAddress("phiH1_gen", &phiH1_gen); eventChain->SetBranchAddress("mH1_gen", &mH1_gen); eventChain->SetBranchAddress("ptH2_gen", &ptH2_gen); eventChain->SetBranchAddress("etaH2_gen", &etaH2_gen); eventChain->SetBranchAddress("phiH2_gen", &phiH2_gen); eventChain->SetBranchAddress("mH2_gen", &mH2_gen); eventChain->SetBranchAddress("ptJet_tt1_gen", &ptJet_tt1_gen); eventChain->SetBranchAddress("etaJet_tt1_gen", &etaJet_tt1_gen); eventChain->SetBranchAddress("phiJet_tt1_gen", &phiJet_tt1_gen); eventChain->SetBranchAddress("mJet_tt1_gen", &mJet_tt1_gen); eventChain->SetBranchAddress("ptJet_tt2_gen", &ptJet_tt2_gen); eventChain->SetBranchAddress("etaJet_tt2_gen", &etaJet_tt2_gen); eventChain->SetBranchAddress("phiJet_tt2_gen", &phiJet_tt2_gen); eventChain->SetBranchAddress("mJet_tt2_gen", &mJet_tt2_gen); eventChain->SetBranchAddress("ptJet_6j1_gen", &ptJet_6j1_gen); eventChain->SetBranchAddress("etaJet_6j1_gen", &etaJet_6j1_gen); eventChain->SetBranchAddress("phiJet_6j1_gen", &phiJet_6j1_gen); eventChain->SetBranchAddress("mJet_6j1_gen", &mJet_6j1_gen); eventChain->SetBranchAddress("ptJet_6j2_gen", &ptJet_6j2_gen); eventChain->SetBranchAddress("etaJet_6j2_gen", &etaJet_6j2_gen); eventChain->SetBranchAddress("phiJet_6j2_gen", &phiJet_6j2_gen); eventChain->SetBranchAddress("mJet_6j2_gen", &mJet_6j2_gen); eventChain->SetBranchAddress("ptTT", &ptTT); eventChain->SetBranchAddress("etaTT", &etaTT); eventChain->SetBranchAddress("phiTT", &phiTT); eventChain->SetBranchAddress("mTT", &mTT); eventChain->SetBranchAddress("ptBB1", &ptBB1); eventChain->SetBranchAddress("etaBB1", &etaBB1); eventChain->SetBranchAddress("phiBB1", &phiBB1); eventChain->SetBranchAddress("mBB1", &mBB1); eventChain->SetBranchAddress("ptBB2", &ptBB2); eventChain->SetBranchAddress("etaBB2", &etaBB2); eventChain->SetBranchAddress("phiBB2", &phiBB2); eventChain->SetBranchAddress("mBB2", &mBB2); eventChain->SetBranchAddress("ptGG", &ptGG); eventChain->SetBranchAddress("etaGG", &etaGG); eventChain->SetBranchAddress("phiGG", &phiGG); eventChain->SetBranchAddress("mGG", &mGG); eventChain->SetBranchAddress("ptJJ_tt", &ptJJ_tt); eventChain->SetBranchAddress("etaJJ_tt", &etaJJ_tt); eventChain->SetBranchAddress("phiJJ_tt", &phiJJ_tt); eventChain->SetBranchAddress("mJJ_tt", &mJJ_tt); eventChain->SetBranchAddress("ptJJ_6j", &ptJJ_6j); eventChain->SetBranchAddress("etaJJ_6j", &etaJJ_6j); eventChain->SetBranchAddress("phiJJ_6j", &phiJJ_6j); eventChain->SetBranchAddress("mJJ_6j", &mJJ_6j); eventChain->SetBranchAddress("ptHH", &ptHH); eventChain->SetBranchAddress("etaHH", &etaHH); eventChain->SetBranchAddress("phiHH", &phiHH); eventChain->SetBranchAddress("mHH", &mHH); eventChain->SetBranchAddress("mt2", &mt2); eventChain->SetBranchAddress("mt2puppi", &mt2puppi); eventChain->SetBranchAddress("mt2pileup", &mt2pileup); eventChain->SetBranchAddress("m_sv", &m_sv); eventChain->SetBranchAddress("m_svpileup", &m_svpileup); eventChain->SetBranchAddress("m_svpuppi", &m_svpuppi); eventChain->SetBranchAddress("nBtag", &nBtag); eventChain->SetBranchAddress("nCentral", &nCentral); eventChain->SetBranchAddress("centB", ¢B); eventChain->SetBranchAddress("nJets", &nJets); eventChain->SetBranchAddress("dEta_tt", &dEta_tt); eventChain->SetBranchAddress("dEta_6j", &dEta_6j); eventChain->SetBranchAddress("rho_0", &rho_0); eventChain->SetBranchAddress("rho_1", &rho_1); eventChain->SetBranchAddress("rho_2", &rho_2); eventChain->SetBranchAddress("dEtaBB1", &dEtaBB1); eventChain->SetBranchAddress("dPhiBB1", &dPhiBB1); eventChain->SetBranchAddress("dRBB1", &dRBB1); eventChain->SetBranchAddress("dEtaTT", &dEtaTT); eventChain->SetBranchAddress("dPhiTT", &dPhiTT); eventChain->SetBranchAddress("dRTT", &dRTT); eventChain->SetBranchAddress("dEtaHH", &dEtaHH); eventChain->SetBranchAddress("dPhiHH", &dPhiHH); eventChain->SetBranchAddress("dRHH", &dRHH); eventChain->GetEntry(0); TTree *outTree=(TTree*)eventChain->GetTree()->CloneTree(0); outTree->Branch("bdtVal", &bdtVal, "bdtVal/f"); outTree->Branch("chi2", &chi2, "chi2/f"); outTree->Branch("corrMet", &corrMet, "corrMet/f"); outTree->Branch("corrMetPhi", &corrMetPhi, "corrMetPhi/f"); outTree->Branch("conv", &conv, "conv/i"); //hhMVA::MVAType why1=hhMVA::kTauTau; hhMVA::MVAType why2=hhMVA::kMuTau; hhMVA::MVAType why3=hhMVA::kElTau; hhMVA::MVAType why4=hhMVA::kElMu; //hhMVA *ttMVA = new hhMVA(); hhMVA *mtMVA = new hhMVA(); hhMVA *etMVA = new hhMVA(); hhMVA *emMVA = new hhMVA(); //ttMVA->Intialize(why1); mtMVA->Intialize(why2); etMVA->Intialize(why3); emMVA->Intialize(why4); for (Int_t i=0; i<eventChain->GetEntries(); i++) { eventChain->GetEntry(i); eventWeight/=float(nevents); bdtVal=999; // hack to fix modified SM samples //if (sampleNo>95 && sampleNo<100) eventWeight=2.92/float(nevents); if (isBBTT!=1) continue; if (ptB1<30 || ptB2<30) continue; //if (TMath::Sqrt((etaTau1-etaTau2)*(etaTau1-etaTau2)+(phiTau1-phiTau2)*(phiTau1-phiTau2))<0.4) continue; /* TLorentzVector v1; TLorentzVector v2; v1.SetPtEtaPhiM(ptB1, etaB1, phiB1, mB1); v2.SetPtEtaPhiM(ptB2, etaB2, phiB2, mB2); TMatrixD m1(3,3); TMatrixD m2(3,3); m1.Zero(); m2.Zero(); m1(0,0) = ErrEt (v1.Et(), v1.Eta()); // et m1(1,1) = ErrEta(v1.Et(), v1.Eta()); // eta m1(2,2) = ErrPhi(v1.Et(), v1.Eta()); // phi m2(0,0) = ErrEt (v2.Et(), v2.Eta()); // et m2(1,1) = ErrEta(v2.Et(), v2.Eta()); // eta m2(2,2) = ErrPhi(v2.Et(), v2.Eta()); // phi TFitParticleEtEtaPhi *jet1 = new TFitParticleEtEtaPhi( "Jet1", "Jet1", &v1, &m1 ); TFitParticleEtEtaPhi *jet2 = new TFitParticleEtEtaPhi( "Jet2", "Jet2", &v2, &m2 ); TFitConstraintM *mCons1 = new TFitConstraintM( "HMassConstraint", "HMass-Constraint", 0, 0 , 125.); mCons1->addParticles1( jet1, jet2 ); TKinFitter* fitter = new TKinFitter("fitter", "fitter"); fitter->addMeasParticle( jet1 ); fitter->addMeasParticle( jet2 ); fitter->addConstraint( mCons1 ); //Set convergence criteria fitter->setMaxNbIter( 30 ); fitter->setMaxDeltaS( 1e-2 ); fitter->setMaxF( 1e-1 ); fitter->setVerbosity(1); TVector2 b1_i; b1_i.SetMagPhi(fitter->get4Vec(0)->Pt(), fitter->get4Vec(0)->Phi()); TVector2 b2_i; b2_i.SetMagPhi(fitter->get4Vec(1)->Pt(), fitter->get4Vec(1)->Phi()); //Perform the fit conv=fitter->fit(); chi2=fitter->getS(); TVector2 metTemp; metTemp.SetMagPhi(pileupMet,pileupMetPhi); TVector2 b1_f; b1_f.SetMagPhi(fitter->get4Vec(0)->Pt(), fitter->get4Vec(0)->Phi()); TVector2 b2_f; b2_f.SetMagPhi(fitter->get4Vec(1)->Pt(), fitter->get4Vec(1)->Phi()); metTemp=metTemp+b1_i+b2_i-b1_f-b2_f; corrMet=metTemp.Mod(); corrMetPhi=metTemp.Phi(); */ if (tauCat1==1 && tauCat2==1 && ptTau1>45 && ptTau2>45) { bdtVal=999;//ttMVA->GetBDTValue(mTT, ptTT, mBB1, ptBB1, dRBB1, dRTT); } else if (tauCat1==1 && tauCat2==3 && ptTau1>30 && ptTau2>20) { bdtVal=mtMVA->GetBDTValue(mTT, ptTT, mBB1, ptBB1, mHH, ptHH, mt2pileup, dRBB1, dRTT, dRHH); } else if (tauCat1==1 && tauCat2==2 && ptTau1>30 && ptTau2>20) { bdtVal=etMVA->GetBDTValue(mTT, ptTT, mBB1, ptBB1, mHH, ptHH, mt2pileup, dRBB1, dRTT, dRHH); } else if (tauCat1==3 && tauCat2==2 && ptTau1>20 && ptTau2>20) { bdtVal=emMVA->GetBDTValue(mTT, ptTT, mBB1, ptBB1, mHH, ptHH, mt2pileup, dRBB1, dRTT, dRHH); } else continue; outTree->Fill(); } outFile->Write(); outFile->Save(); }
void Select_CC1pip(char const *InpFileName, char const *OupFileName, bool db = false) { TFile *inpF = new TFile(InpFileName); if (!inpF || !inpF->IsOpen()) { std::cerr << "[ERROR]: Could not open input file: " << InpFileName << std::endl; exit(1); } TTree *stdhep = static_cast<TTree *>(inpF->Get("giRooTracker")); if (!stdhep) { std::cerr << "[ERROR]: Could not read TTree (\"giRooTracker\") from input file: " << InpFileName << std::endl; exit(1); } Double_t EvtWght; Int_t GiStdHepN; Int_t GiStdHepPdg[100]; Int_t GiStdHepStatus[100]; Double_t GiStdHepP4[100][4]; stdhep->SetBranchAddress("EvtWght", &EvtWght); stdhep->SetBranchAddress("StdHepN", &GiStdHepN); stdhep->SetBranchAddress("StdHepPdg", GiStdHepPdg); stdhep->SetBranchAddress("StdHepP4", GiStdHepP4); stdhep->SetBranchAddress("StdHepStatus", GiStdHepStatus); TFile *oupF = new TFile(OupFileName, "RECREATE"); TTree *oupT = new TTree("CC1PipQ2", ""); Float_t Q2; oupT->Branch("Q2", &Q2); oupT->Branch("EvtWght", &EvtWght); Long64_t nentries = stdhep->GetEntries(); for (Long64_t evt = 0; evt < nentries; ++evt) { stdhep->GetEntry(evt); TLorentzVector pnu(0, 0, 0, 0); TLorentzVector pmu(0, 0, 0, 0); Int_t NPiPlus = 0; Int_t NOtherPi = 0; if (db) { std::cout << "Ev[" << evt << "] ------- " << std::endl; } // Loop through particle stack for (Int_t prt = 0; prt < GiStdHepN; ++prt) { // Inital numu if ((GiStdHepStatus[prt] == 0) && (GiStdHepPdg[prt] == 14)) { pnu = TLorentzVector(GiStdHepP4[prt][0], GiStdHepP4[prt][1], GiStdHepP4[prt][2], GiStdHepP4[prt][3]); if (db) { std::cout << "\tFound nu at " << prt << " Mom: (" << GiStdHepP4[prt][0] << ", " << GiStdHepP4[prt][1] << ", " << GiStdHepP4[prt][2] << ", " << GiStdHepP4[prt][3] << ") " << std::endl; } } // Final mu if ((GiStdHepStatus[prt] == 1) && (GiStdHepPdg[prt] == 13)) { pmu = TLorentzVector(GiStdHepP4[prt][0], GiStdHepP4[prt][1], GiStdHepP4[prt][2], GiStdHepP4[prt][3]); if (db) { std::cout << "\tFound mu at " << prt << " Mom: (" << GiStdHepP4[prt][0] << ", " << GiStdHepP4[prt][1] << ", " << GiStdHepP4[prt][2] << ", " << GiStdHepP4[prt][3] << ") " << std::endl; } } // Final pi+ if ((GiStdHepStatus[prt] == 1) && (GiStdHepPdg[prt] == 211)) { NPiPlus++; } // Final other pi if ((GiStdHepStatus[prt] == 1) && ((GiStdHepPdg[prt] == 111) || (GiStdHepPdg[prt] == -211))) { NOtherPi++; } } // cc1pip selection if ((NPiPlus == 1) && (NOtherPi == 0) && (pnu.Vect().Mag2() > 0) && (pmu.Vect().Mag2() > 0)) { Q2 = -1. * (pnu - pmu).Mag2(); if (db) { std::cout << "Ev[" << evt << "] -- Q2: " << Q2 << ", pnu.Mag(): " << pnu.Vect().Mag() << ", pmu.Mag(): " << pmu.Vect().Mag() << std::endl; } oupT->Fill(); } if (db) { std::cout << "====================" << std::endl; } } oupT->Write(); oupF->Write(); oupF->Save(); }
void newReduceTree(){ // -- define tuple file name, tuple name and cuts to apply // -- and also the name of the output file const std::string filename = "/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/Lb2chicpK_MC_2011_2012_signal_cut.root";//change const std::string treename = "DecayTree"; const std::string cuts = ""; const std::string outFile = "/afs/cern.ch/work/a/apmorris/public/Lb2chicpK/signal_samples/reduced_Lb2chicpK_MC_2011_2012_signal.root");//change TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need tree->SetBranchStatus("*", 0); tree->SetBranchStatus("chi_c_M",1); tree->SetBranchStatus("chi_c_P",1); tree->SetBranchStatus("chi_c_PE",1); tree->SetBranchStatus("chi_c_PT",1); tree->SetBranchStatus("chi_c_PX",1); tree->SetBranchStatus("chi_c_PY",1); tree->SetBranchStatus("chi_c_PZ",1); tree->SetBranchStatus("chi_c_ETA",1); tree->SetBranchStatus("kaon_M",1); tree->SetBranchStatus("kaon_P",1); tree->SetBranchStatus("kaon_PE",1); tree->SetBranchStatus("kaon_PT",1); tree->SetBranchStatus("kaon_PX",1); tree->SetBranchStatus("kaon_PY",1); tree->SetBranchStatus("kaon_PZ",1); tree->SetBranchStatus("kaon_ETA",1); tree->SetBranchStatus("kaon_IPCHI2_OWNPV",1); tree->SetBranchStatus("kaon_TRACK_GhostProb",1); tree->SetBranchStatus("kaon_ProbNNp",1); tree->SetBranchStatus("kaon_ProbNNk",1); tree->SetBranchStatus("proton_M",1); tree->SetBranchStatus("proton_P",1); tree->SetBranchStatus("proton_PE",1); tree->SetBranchStatus("proton_PT",1); tree->SetBranchStatus("proton_PX",1); tree->SetBranchStatus("proton_PY",1); tree->SetBranchStatus("proton_PZ",1); tree->SetBranchStatus("proton_ETA",1); tree->SetBranchStatus("proton_IPCHI2_OWNPV",1); tree->SetBranchStatus("proton_TRACK_GhostProb",1); tree->SetBranchStatus("proton_ProbNNp",1); tree->SetBranchStatus("proton_ProbNNk",1); tree->SetBranchStatus("Jpsi_M",1); tree->SetBranchStatus("Jpsi_P",1); tree->SetBranchStatus("Jpsi_PE",1); tree->SetBranchStatus("Jpsi_PT",1); tree->SetBranchStatus("Jpsi_PX",1); tree->SetBranchStatus("Jpsi_PY",1); tree->SetBranchStatus("Jpsi_PZ",1); tree->SetBranchStatus("Jpsi_ETA",1); tree->SetBranchStatus("gamma_M",1); tree->SetBranchStatus("gamma_P",1); tree->SetBranchStatus("gamma_PE",1); tree->SetBranchStatus("gamma_PT",1); tree->SetBranchStatus("gamma_PX",1); tree->SetBranchStatus("gamma_PY",1); tree->SetBranchStatus("gamma_PZ",1); tree->SetBranchStatus("gamma_CL",1); tree->SetBranchStatus("gamma_ETA",1); tree->SetBranchStatus("muminus_M",1); tree->SetBranchStatus("muminus_P",1); tree->SetBranchStatus("muminus_PE",1); tree->SetBranchStatus("muminus_PT",1); tree->SetBranchStatus("muminus_PX",1); tree->SetBranchStatus("muminus_PY",1); tree->SetBranchStatus("muminus_PZ",1); tree->SetBranchStatus("muminus_ETA",1); tree->SetBranchStatus("muminus_ProbNNmu",1); tree->SetBranchStatus("muminus_TRACK_GhostProb",1); tree->SetBranchStatus("muplus_M",1); tree->SetBranchStatus("muplus_P",1); tree->SetBranchStatus("muplus_PE",1); tree->SetBranchStatus("muplus_PT",1); tree->SetBranchStatus("muplus_PX",1); tree->SetBranchStatus("muplus_PY",1); tree->SetBranchStatus("muplus_PZ",1); tree->SetBranchStatus("muplus_ETA",1); tree->SetBranchStatus("muplus_ProbNNmu",1); tree->SetBranchStatus("muplus_TRACK_GhostProb",1); tree->SetBranchStatus("Lambda_b0_DTF_MASS_constr1",1); tree->SetBranchStatus("Lambda_b0_DTF_MASS_constr2",1); tree->SetBranchStatus("Lambda_b0_DTF_CHI2NDOF",1); tree->SetBranchStatus("Lambda_b0_IPCHI2_OWNPV",1); tree->SetBranchStatus("Lambda_b0_FDS",1); tree->SetBranchStatus("Lambda_b0_L0MuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_L0DiMuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1TrackMuonDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1TrackAllL0Decision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS",1); tree->SetBranchStatus("Lambda_b0_pi0veto",1); tree->SetBranchStatus("Lambda_b0_PT",1); //for MC only // tree->SetBranchStatus("chi_c_BKGCAT",1); // tree->SetBranchStatus("Jpsi_BKGCAT",1); // tree->SetBranchStatus("Lambda_b0_BKGCAT",1); // // -- this file is just here to make the 'CopyTree' happy TFile* dummyFile = new TFile("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree(cuts.c_str()); double chi_c_M, chi_c_P, chi_c_PE, chi_c_PT, chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_ETA; double kaon_M, kaon_P, kaon_PE, kaon_PX, kaon_PT, kaon_PY, kaon_PZ, kaon_ETA; double proton_M, proton_P, proton_PE, proton_PT, proton_PX, proton_PY, proton_PZ, proton_ETA; double Jpsi_M, Jpsi_P, Jpsi_PE, Jpsi_PT, Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_ETA; double gamma_M, gamma_P, gamma_PE, gamma_PT, gamma_PX, gamma_PY, gamma_PZ, gamma_ETA, gamma_CL; double muminus_M, muminus_P, muminus_PE, muminus_PT, muminus_PX, muminus_PY, muminus_PZ, muminus_ETA, muminus_ProbNNmu, muminus_TRACK_GhostProb; double muplus_M, muplus_P, muplus_PE, muplus_PT, muplus_PX, muplus_PY, muplus_PZ, muplus_ETA, muplus_ProbNNmu, muplus_TRACK_GhostProb; double kaon_IPCHI2_OWNPV, kaon_TRACK_GhostProb, kaon_ProbNNp, kaon_ProbNNk; double proton_IPCHI2_OWNPV, proton_TRACK_GhostProb, proton_ProbNNp, proton_ProbNNk; double Lambda_b0_DTF_MASS_constr1, Lambda_b0_DTF_MASS_constr2, Lambda_b0_DTF_CHI2NDOF, Lambda_b0_IPCHI2_OWNPV; double Lambda_b0_FDS, Lambda_b0_pi0veto, Lambda_b0_PT; bool Lambda_b0_L0MuonDecision_TOS, Lambda_b0_L0DiMuonDecision_TOS; bool Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, Lambda_b0_Hlt1DiMuonLowMassDecision_TOS; bool Lambda_b0_Hlt1TrackMuonDecision_TOS, Lambda_b0_Hlt1TrackAllL0Decision_TOS; bool Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedDecision_TOS; bool Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS; rTree1->SetBranchAddress("chi_c_M", &chi_c_M); rTree1->SetBranchAddress("chi_c_P", &chi_c_P); rTree1->SetBranchAddress("chi_c_PE", &chi_c_PE); rTree1->SetBranchAddress("chi_c_PT", &chi_c_PT); rTree1->SetBranchAddress("chi_c_PX", &chi_c_PX); rTree1->SetBranchAddress("chi_c_PY", &chi_c_PY); rTree1->SetBranchAddress("chi_c_PZ", &chi_c_PZ); rTree1->SetBranchAddress("chi_c_ETA", &chi_c_ETA); rTree1->SetBranchAddress("kaon_M", &kaon_M); rTree1->SetBranchAddress("kaon_P", &kaon_P); rTree1->SetBranchAddress("kaon_PE", &kaon_PE); rTree1->SetBranchAddress("kaon_PX", &kaon_PX); rTree1->SetBranchAddress("kaon_PT", &kaon_PT); rTree1->SetBranchAddress("kaon_PY", &kaon_PY); rTree1->SetBranchAddress("kaon_PZ", &kaon_PZ); rTree1->SetBranchAddress("kaon_ETA", &kaon_ETA); rTree1->SetBranchAddress("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV); rTree1->SetBranchAddress("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb); rTree1->SetBranchAddress("kaon_ProbNNp", &kaon_ProbNNp); rTree1->SetBranchAddress("kaon_ProbNNk", &kaon_ProbNNk); rTree1->SetBranchAddress("proton_M", &proton_M); rTree1->SetBranchAddress("proton_P", &proton_P); rTree1->SetBranchAddress("proton_PE", &proton_PE); rTree1->SetBranchAddress("proton_PT", &proton_PT); rTree1->SetBranchAddress("proton_PX", &proton_PX); rTree1->SetBranchAddress("proton_PY", &proton_PY); rTree1->SetBranchAddress("proton_PZ", &proton_PZ); rTree1->SetBranchAddress("proton_ETA", &proton_ETA); rTree1->SetBranchAddress("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV); rTree1->SetBranchAddress("proton_TRACK_GhostProb", &proton_TRACK_GhostProb); rTree1->SetBranchAddress("proton_ProbNNp", &proton_ProbNNp); rTree1->SetBranchAddress("proton_ProbNNk", &proton_ProbNNk); rTree1->SetBranchAddress("Jpsi_M", &Jpsi_M); rTree1->SetBranchAddress("Jpsi_P", &Jpsi_P); rTree1->SetBranchAddress("Jpsi_PE", &Jpsi_PE); rTree1->SetBranchAddress("Jpsi_PT", &Jpsi_PT); rTree1->SetBranchAddress("Jpsi_PX", &Jpsi_PX); rTree1->SetBranchAddress("Jpsi_PY", &Jpsi_PY); rTree1->SetBranchAddress("Jpsi_PZ", &Jpsi_PZ); rTree1->SetBranchAddress("Jpsi_ETA", &Jpsi_ETA); rTree1->SetBranchAddress("gamma_M", &gamma_M); rTree1->SetBranchAddress("gamma_P", &gamma_P); rTree1->SetBranchAddress("gamma_PE", &gamma_PE); rTree1->SetBranchAddress("gamma_PT", &gamma_PT); rTree1->SetBranchAddress("gamma_PX", &gamma_PX); rTree1->SetBranchAddress("gamma_PY", &gamma_PY); rTree1->SetBranchAddress("gamma_PZ", &gamma_PZ); rTree1->SetBranchAddress("gamma_ETA", &gamma_ETA); rTree1->SetBranchAddress("gamma_CL", &gamma_CL); rTree1->SetBranchAddress("muminus_M", &muminus_M); rTree1->SetBranchAddress("muminus_P", &muminus_P); rTree1->SetBranchAddress("muminus_PE", &muminus_PE); rTree1->SetBranchAddress("muminus_PT", &muminus_PT); rTree1->SetBranchAddress("muminus_PX", &muminus_PX); rTree1->SetBranchAddress("muminus_PY", &muminus_PY); rTree1->SetBranchAddress("muminus_PZ", &muminus_PZ); rTree1->SetBranchAddress("muminus_ETA", &muminus_ETA); rTree1->SetBranchAddress("muminus_ProbNNmu", &muminus_ProbNNmu); rTree1->SetBranchAddress("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb); rTree1->SetBranchAddress("muplus_M", &muplus_M); rTree1->SetBranchAddress("muplus_P", &muplus_P); rTree1->SetBranchAddress("muplus_PE", &muplus_PE); rTree1->SetBranchAddress("muplus_PT", &muplus_PT); rTree1->SetBranchAddress("muplus_PX", &muplus_PX); rTree1->SetBranchAddress("muplus_PY", &muplus_PY); rTree1->SetBranchAddress("muplus_PZ", &muplus_PZ); rTree1->SetBranchAddress("muplus_ETA", &muplus_ETA); rTree1->SetBranchAddress("muplus_ProbNNmu", &muplus_ProbNNmu); rTree1->SetBranchAddress("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr2", &Lambda_b0_DTF_MASS_constr2); rTree1->SetBranchAddress("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF); rTree1->SetBranchAddress("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV); rTree1->SetBranchAddress("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_FDS", &Lambda_b0_FDS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_pi0veto", &Lambda_b0_pi0veto); rTree1->SetBranchAddress("Lambda_b0_PT", &Lambda_b0_PT); //for MC only // int chi_c_BKGCAT, Jpsi_BKGCAT, Lambda_b0_BKGCAT; // rTree1->SetBranchAddress("chi_c_BKGCAT", &chi_c_BKGCAT); // rTree1->SetBranchAddress("Jpsi_BKGCAT", &Jpsi_BKGCAT); // rTree1->SetBranchAddress("Lambda_b0_BKGCAT", &Lambda_b0_BKGCAT); // TFile* rFile = new TFile( outFile.c_str() ,"RECREATE"); TTree* rTree2 = new TTree(); rTree2->SetName("DecayTree"); rTree2->Branch("chi_c_M", &chi_c_M, "chi_c_M/D"); rTree2->Branch("chi_c_P", &chi_c_P, "chi_c_P/D"); rTree2->Branch("chi_c_PE", &chi_c_PE, "chi_c_PE/D"); rTree2->Branch("chi_c_PT", &chi_c_PT, "chi_c_PT/D"); rTree2->Branch("chi_c_PX", &chi_c_PX, "chi_c_PX/D"); rTree2->Branch("chi_c_PY", &chi_c_PY, "chi_c_PY/D"); rTree2->Branch("chi_c_PZ", &chi_c_PZ, "chi_c_PZ/D"); rTree2->Branch("chi_c_ETA", &chi_c_ETA, "chi_c_ETA/D"); rTree2->Branch("kaon_M", &kaon_M, "kaon_M/D"); rTree2->Branch("kaon_P", &kaon_P, "kaon_P/D"); rTree2->Branch("kaon_PE", &kaon_PE, "kaon_PE/D"); rTree2->Branch("kaon_PX", &kaon_PX, "kaon_PX/D"); rTree2->Branch("kaon_PT", &kaon_PT, "kaon_PT/D"); rTree2->Branch("kaon_PY", &kaon_PY, "kaon_PY/D"); rTree2->Branch("kaon_PZ", &kaon_PZ, "kaon_PZ/D"); rTree2->Branch("kaon_ETA", &kaon_ETA, "kaon_ETA/D"); rTree2->Branch("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV, "kaon_IPCHI2_OWNPV/D"); rTree2->Branch("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb, "kaon_TRACK_GhostProb/D"); rTree2->Branch("kaon_ProbNNp", &kaon_ProbNNp, "kaon_ProbNNp/D"); rTree2->Branch("kaon_ProbNNk", &kaon_ProbNNk, "kaon_ProbNNk/D"); rTree2->Branch("proton_M", &proton_M, "proton_M/D"); rTree2->Branch("proton_P", &proton_P, "proton_P/D"); rTree2->Branch("proton_PE", &proton_PE, "proton_PE/D"); rTree2->Branch("proton_PT", &proton_PT, "proton_PT/D"); rTree2->Branch("proton_PX", &proton_PX, "proton_PX/D"); rTree2->Branch("proton_PY", &proton_PY, "proton_PY/D"); rTree2->Branch("proton_PZ", &proton_PZ, "proton_PZ/D"); rTree2->Branch("proton_ETA", &proton_ETA, "proton_ETA/D"); rTree2->Branch("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV, "proton_IPCHI2_OWNPV/D"); rTree2->Branch("proton_TRACK_GhostProb", &proton_TRACK_GhostProb, "proton_TRACK_GhostProb/D"); rTree2->Branch("proton_ProbNNp", &proton_ProbNNp, "proton_ProbNNp/D"); rTree2->Branch("proton_ProbNNk", &proton_ProbNNk, "proton_ProbNNk/D"); rTree2->Branch("Jpsi_M", &Jpsi_M, "Jpsi_M/D"); rTree2->Branch("Jpsi_P", &Jpsi_P, "Jpsi_P/D"); rTree2->Branch("Jpsi_PE", &Jpsi_PE, "Jpsi_PE/D"); rTree2->Branch("Jpsi_PT", &Jpsi_PT, "Jpsi_PT/D"); rTree2->Branch("Jpsi_PX", &Jpsi_PX, "Jpsi_PX/D"); rTree2->Branch("Jpsi_PY", &Jpsi_PY, "Jpsi_PY/D"); rTree2->Branch("Jpsi_PZ", &Jpsi_PZ, "Jpsi_PZ/D"); rTree2->Branch("Jpsi_ETA", &Jpsi_ETA, "Jpsi_ETA/D"); rTree2->Branch("gamma_M", &gamma_M, "gamma_M/D"); rTree2->Branch("gamma_P", &gamma_P, "gamma_P/D"); rTree2->Branch("gamma_PE", &gamma_PE, "gamma_PE/D"); rTree2->Branch("gamma_PT", &gamma_PT, "gamma_PT/D"); rTree2->Branch("gamma_PX", &gamma_PX, "gamma_PX/D"); rTree2->Branch("gamma_PY", &gamma_PY, "gamma_PY/D"); rTree2->Branch("gamma_PZ", &gamma_PZ, "gamma_PZ/D"); rTree2->Branch("gamma_ETA", &gamma_ETA, "gamma_ETA/D"); rTree2->Branch("gamma_CL", &gamma_CL, "gamma_CL/D"); rTree2->Branch("muminus_M", &muminus_M, "muminus_M/D"); rTree2->Branch("muminus_P", &muminus_P, "muminus_P/D"); rTree2->Branch("muminus_PE", &muminus_PE, "muminus_PE/D"); rTree2->Branch("muminus_PT", &muminus_PT, "muminus_PT/D"); rTree2->Branch("muminus_PX", &muminus_PX, "muminus_PX/D"); rTree2->Branch("muminus_PY", &muminus_PY, "muminus_PY/D"); rTree2->Branch("muminus_PZ", &muminus_PZ, "muminus_PZ/D"); rTree2->Branch("muminus_ETA", &muminus_ETA, "muminus_ETA/D"); rTree2->Branch("muminus_ProbNNmu", &muminus_ProbNNmu, "muminus_ProbNNmu/D"); rTree2->Branch("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb, "muminus_TRACK_GhostProb/D"); rTree2->Branch("muplus_M", &muplus_M, "muplus_M/D"); rTree2->Branch("muplus_P", &muplus_P, "muplus_P/D"); rTree2->Branch("muplus_PE", &muplus_PE, "muplus_PE/D"); rTree2->Branch("muplus_PT", &muplus_PT, "muplus_PT/D"); rTree2->Branch("muplus_PX", &muplus_PX, "muplus_PX/D"); rTree2->Branch("muplus_PY", &muplus_PY, "muplus_PY/D"); rTree2->Branch("muplus_PZ", &muplus_PZ, "muplus_PZ/D"); rTree2->Branch("muplus_ETA", &muplus_ETA, "muplus_ETA/D"); rTree2->Branch("muplus_ProbNNmu", &muplus_ProbNNmu, "muplus_ProbNNmu/D"); rTree2->Branch("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb, "muplus_TRACK_GhostProb/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1, "Lambda_b0_DTF_MASS_constr1/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr2", &Lambda_b0_DTF_MASS_constr2, "Lambda_b0_DTF_MASS_constr2/D"); rTree2->Branch("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF, "Lambda_b0_DTF_CHI2NDOF/D"); rTree2->Branch("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV, "Lambda_b0_IPCHI2_OWNPV/D"); rTree2->Branch("Lambda_b0_L0DiMuonDecision_TOS",&Lambda_b0_L0DiMuonDecision_TOS,"Lambda_b0_L0DiMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS, "Lambda_b0_L0MuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_FDS", &Lambda_b0_FDS, "Lambda_b0_FDS/D"); rTree2->Branch("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, "Lambda_b0_Hlt1DiMuonHighMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS, "Lambda_b0_Hlt1DiMuonLowMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS, "Lambda_b0_Hlt1TrackMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS, "Lambda_b0_Hlt1TrackAllL0Decision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, "Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedJPsiDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS/B"); rTree2->Branch("Lambda_b0_pi0veto", &Lambda_b0_pi0veto, "Lambda_b0_pi0veto/D"); rTree2->Branch("Lambda_b0_PT", &Lambda_b0_PT, "Lambda_b0_PT/D"); //for MC only // rTree2->Branch("chi_c_BKGCAT", &chi_c_BKGCAT, "chi_c_BKGCAT/I"); // rTree2->Branch("Jpsi_BKGCAT", &Jpsi_BKGCAT, "Jpsi_BKGCAT/I"); // rTree2->Branch("Lambda_b0_BKGCAT", &Lambda_b0_BKGCAT, "Lambda_b0_BKGCAT/I"); // //----------------------------------------------------------------------------------- const double mK(493.677); const double mpi(139.57); const double mp(938.27); double m_pK, m_chicp; double proton_as_kaon_M, proton_as_pion_M, proton_as_proton_M; double m_chicpK_proton_as_kaon, m_chicpK_proton_as_pion, m_chicpK_proton_as_proton; double m_JpsipK; rTree2->Branch("m_JpsipK", &m_JpsipK, "m_JpsipK/D"); rTree2->Branch("m_chicp", &m_chicp, "m_chicp/D"); rTree2->Branch("m_pK", &m_pK, "m_pK/D"); rTree2->Branch("proton_as_kaon_M", &proton_as_kaon_M, "proton_as_kaon_M/D"); rTree2->Branch("proton_as_pion_M", &proton_as_pion_M, "proton_as_pion_M/D"); rTree2->Branch("proton_as_proton_M", &proton_as_proton_M, "proton_as_proton_M/D"); rTree2->Branch("m_chicpK_proton_as_kaon", &m_chicpK_proton_as_kaon, "m_chicpK_proton_as_kaon/D"); rTree2->Branch("m_chicpK_proton_as_pion", &m_chicpK_proton_as_pion, "m_chicpK_proton_as_pion/D"); rTree2->Branch("m_chicpK_proton_as_proton", &m_chicpK_proton_as_proton, "m_chicpK_proton_as_proton/D"); int percentCounter = 1; for(int i = 0; i < rTree1->GetEntries(); ++i){ const int percent = (int)(rTree1->GetEntries()/100.0); if( i == percent*percentCounter ){ std::cout << percentCounter << " %" << std::endl; percentCounter++; } rTree1->GetEntry(i); double proton_P = sqrt(proton_PX*proton_PX + proton_PY*proton_PY + proton_PZ*proton_PZ) ; TLorentzVector proton_as_kaon( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mK*mK)); TLorentzVector proton_as_pion( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mpi*mpi)); TLorentzVector proton_as_proton( proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + proton_M*proton_M)); TLorentzVector kaon( kaon_PX, kaon_PY, kaon_PZ, kaon_PE); TLorentzVector chic( chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_PE); TLorentzVector proton(proton_PX, proton_PY, proton_PZ, proton_PE); TLorentzVector Jpsi( Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_PE); proton_as_kaon_M = proton_as_kaon.M(); proton_as_pion_M = proton_as_pion.M(); proton_as_proton_M = proton_as_proton.M(); TLorentzVector chic_PasK_K = chic + kaon + proton_as_kaon; TLorentzVector chic_PasPi_K = chic + kaon + proton_as_pion; TLorentzVector chic_PasP_K = chic + kaon + proton_as_proton; m_chicpK_proton_as_kaon = chic_PasK_K.M(); m_chicpK_proton_as_pion = chic_PasPi_K.M(); m_chicpK_proton_as_proton = chic_PasP_K.M(); TLorentzVector JpsipK = Jpsi + proton + kaon; TLorentzVector chicp = chic + proton; TLorentzVector pK = proton + kaon; m_JpsipK = JpsipK.M(); m_chicp = chicp.M(); m_pK = pK.M(); rTree2->Fill(); } rTree2->Print(); rTree2->Write(); rFile->Save(); }
void anatup( Double_t pBeam=3.3077729, Int_t Did=19) // Analyse ee events, and write tuples { gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); rootlogon(); FILE *fp; Int_t NTmax=100000; // Int_t NFmax=10; // max number of files // Int_t NTmax=100; // max number per file Int_t NEVcount=0; // max number per file // Int_t NTmax=10000; // Int_t NTmax=200; Int_t ip=0; Int_t iPart=3; Double_t mProt= 0.938272; Double_t mElec= 0.000511; Double_t mMuon= 0.105658; Double_t mPion= 0.139570; Double_t mZero= 0.134977; Double_t mZeroFit= 0.13; // Double_t mZeroCut= 0.06; Double_t mZeroCut= 0.02; // Double_t pBeam=4.00000; Double_t eBeam=sqrt(pBeam*pBeam+mProt*mProt); Double_t eSystem=eBeam+mProt; Double_t mElec2 = mElec*mElec; Double_t mZero2= mZero*mZero; Double_t radeg=180./3.1415926535; // electroncuts // Double_t EmcCUT=0.8; // Double_t SttCUT=0.5; Double_t EmcCUT=0.5; Double_t SttCUT=0.5; Double_t DiscCUT=0.5; Double_t DrcCUT=0.5; Double_t MuonCUT=0.5; Double_t MvdCUT=0.5; Double_t TOTCUT=0.50; Double_t TOT90CUT=0.90; Double_t TOT95CUT=0.95; Double_t TOT98CUT=0.98; Double_t TOT99CUT=0.99; // Set up the Lorentzvectors of the system TLorentzVector target(0.0, 0.0, 0.0, mProt); Double_t eBeam=sqrt(pBeam*pBeam+mProt*mProt); TLorentzVector beam(0.0, 0.0, pBeam, eBeam); TLorentzVector W = beam + target; TVector3 bSigma(0,0,-W.Pz()/W.E()); // Construct filenames TString Directory[]={"rfiles3/","rootfiles/" // vandewie ,"ee01/","ee02/","ee03/","ee04/","ee05/" // gosia + photos ,"ee06/","ee07/","ee08/","ee09/","ee10/" ,"ee11/","ee12/","ee13/","ee14/","ee15/" ,"ee16/","ee17/" ,"eeno01/","eeno02/","eeno03/","eeno04/" // gosia + nophotos }; TString name = "_complete.root"; TString inRecoFile = Directory[Did]+"reco"+name; TString inDigiFile = Directory[Did]+"digi"+name; TString inSimFile = Directory[Did]+"sim"+name; TString inPidFile = Directory[Did]+"pid"+name; TString outAnaFile = Directory[Did]+"ana"+name; TFile *out = TFile::Open(outAnaFile,"RECREATE"); TNtuple* NTev = new TNtuple("NTev","NTev", "p1MC:th1MC:ph1MC:p2MC:th2MC:ph2MC:costhMC:Q2:p1:th1:ph1:EMC1:NX1:pEMC1:pSTT1:pDIS1:pDRC1:pMVD1:pCOM1:p2:th2:ph2:EMC2:NX2:pEMC2:pSTT2:pDIS2:pDRC2:pMVD2:pCOM2:bestTH:bestPH:bestCOST",68000); Float_t atuple[33]; cout << "filename:" << inPidFile << endl; TFile *inFile = TFile::Open(inPidFile,"READ"); TTree *lhe=(TTree *) inFile->Get("cbmsim") ; TFile *outFile = TFile::Open(outAnaFile,"new"); // adding other files as friends lhe->AddFriend("cbmsim",inSimFile); lhe->AddFriend("cbmsim",inDigiFile); PndEmcMapper::Init(6); // get the data (correspondage with Inspect in TBrowser) TClonesArray* cCand_array=new TClonesArray("PndPidCandidate"); lhe->SetBranchAddress("PidChargedCand", &cCand_array); TClonesArray* nCand_array=new TClonesArray("PndPidCandidate"); lhe->SetBranchAddress("PidNeutralCand", &nCand_array); TClonesArray* mc_array=new TClonesArray("PndMCTrack"); lhe->SetBranchAddress("MCTrack", &mc_array); TClonesArray* stthit_array=new TClonesArray("PndSttHit"); lhe->SetBranchAddress("STTHit", &stthit_array); TClonesArray* sttpoint_array=new TClonesArray("PndSttPoint"); lhe->SetBranchAddress("STTPoint", &sttpoint_array); TClonesArray* cluster_array=new TClonesArray("PndEmcCluster"); lhe->SetBranchAddress("EmcCluster",&cluster_array); TClonesArray* digi_array=new TClonesArray("PndEmcSharedDigi"); lhe->SetBranchAddress("EmcSharedDigi",&digi_array); TClonesArray* bump_array=new TClonesArray("PndEmcBump"); lhe->SetBranchAddress("EmcBump",&bump_array); TClonesArray* drc_array=new TClonesArray("PndPidProbability"); lhe->SetBranchAddress("PidAlgoDrc", &drc_array); TClonesArray* disc_array=new TClonesArray("PndPidProbability"); lhe->SetBranchAddress("PidAlgoDisc", &disc_array); TClonesArray* mvd_array=new TClonesArray("PndPidProbability"); lhe->SetBranchAddress("PidAlgoMvd", &mvd_array); TClonesArray* stt_array=new TClonesArray("PndPidProbability"); lhe->SetBranchAddress("PidAlgoStt", &stt_array); TClonesArray* emcb_array=new TClonesArray("PndPidProbability"); lhe->SetBranchAddress("PidAlgoEmcBayes", &emcb_array); // canvas and stuff gStyle->SetLabelSize(0.05,"X"); gStyle->SetLabelSize(0.05,"Y"); gStyle->SetLineWidth(2); gStyle->SetHistLineWidth(2); gStyle->SetLabelSize(0.05,"X"); gStyle->SetLabelSize(0.05,"Y"); gStyle->SetPalette(1); int off=32; int start=250; cMA = new TCanvas("cMA","cMA",200,0, 1000, 1000); cMA->Divide(3,3); // cMCelec1 = new TCanvas("cMCelec1","cMCelec1",250,0, 1200, 1000); // cMCelec1->Divide(3,2); // histos TH1F *h_costheta_mc = new TH1F("h_costheta_mc","cos_theta_ep",20,-1,1); TH1F *h_costheta = new TH1F("h_costheta","cos_theta_ep",20,-1,1); TH1F *h_costheta_sel = new TH1F("h_costheta_sel","cos_theta_ep",20,-1,1); TH1F *h_efficiency = new TH1F("h_efficiency","efficiency",20,-1,1); TH1F *h_theta = new TH1F("h_theta","theta_ep",400,-400,400); TH1F *h_dtheta = new TH1F("h_dtheta","dtheta_ep",100,170,190); TH1F *h_dphi = new TH1F("h_dphi","dphi_ep",100,170,190); TH1D* hcutE = new TH1D("hcutE" ,"hcutE",50,-eSystem,eSystem); TH1D* hcutx = new TH1D("hcutx" ,"hcutx",50,-1,1); TH1D* hcuty = new TH1D("hcuty" ,"hcuty",50,-1,1); TH1D* hcutz = new TH1D("hcutz" ,"hcutz",50,-1,1); TH1D* hMCz = new TH1D("hMCz" ,"hMCz",50,0,eSystem); TH1D* hpt2 = new TH1D("hpt2" ,"hpt2",50,0,4); TH1D* hpair = new TH1D("hpair" ,"hpair",11,-0.5,10.5); cout << " finished histos " << endl; // process the data // Lorentz vectors MV TLorentzVector mcTrack[4]; TLorentzVector QQ_MC; // loop over events Double_t MCEnergy, MCTheta, MCPhi; Double_t MC1Energy, MC1Theta, MC1Phi; Double_t MC2Energy, MC2Theta, MC2Phi; NTevents=lhe->GetEntriesFast(); cout << "NTevents: " << NTevents << endl; if(NTevents>NTmax) NTevents=NTmax; for (Int_t j=0; j< NTevents ; j++) { lhe->GetEntry(j); // kinematics NEVcount++; if(j%1000 == 0) cout << "event: " << j << endl; // cout << "processing event: " << j<< endl ; Int_t nmc = mc_array->GetEntriesFast(); Int_t ncCand=cCand_array->GetEntriesFast(); Int_t nnCand=nCand_array->GetEntriesFast(); if(j<5) { cout << " nMC: " << mc_array->GetEntriesFast() ; cout << " ncCand: " << cCand_array->GetEntriesFast() << endl; cout << " nnCand: " << nCand_array->GetEntriesFast() << endl; } // Loop over electron tracks, store in mcTrack[0,1], pizero_MC, QQ_MC Float_t mc_pp = 0, mc_E = 0, mc_mass = 0; Float_t mc_px = 0, mc_py = 0, mc_pz = 0; Int_t mc_pdg; Int_t nepi=0; Int_t mc0=0, mc1=1; if(Did>1) {mc0=1; mc1=2;} // positron PndMCTrack *mctrack = (PndMCTrack*)mc_array->At(mc0); // Int_t MotherID = mctrack->GetMotherID(); // mc_pdg = (int) (mctrack->GetPdgCode()); mc_pp = mctrack->GetMomentum().Mag(); mc_px = mctrack->GetMomentum().Px(); mc_py = mctrack->GetMomentum().Py(); mc_pz = mctrack->GetMomentum().Pz(); mc_E=TMath::Sqrt(mc_pp*mc_pp+mElec2); mcTrack[0].SetPxPyPzE(mc_px,mc_py,mc_pz,mc_E); // electron PndMCTrack *mctrack = (PndMCTrack*)mc_array->At(mc1); // Int_t MotherID = mctrack->GetMotherID(); // mc_pdg = (int) (mctrack->GetPdgCode()); mc_pp = mctrack->GetMomentum().Mag(); mc_px = mctrack->GetMomentum().Px(); mc_py = mctrack->GetMomentum().Py(); mc_pz = mctrack->GetMomentum().Pz(); mc_E=TMath::Sqrt(mc_pp*mc_pp+mElec2); mcTrack[1].SetPxPyPzE(mc_px,mc_py,mc_pz,mc_E); // elec1 MC1Energy = mcTrack[0].E(); MC1Theta = radeg*(mcTrack[0].Theta()); MC1Phi = radeg*(mcTrack[0].Phi()); // hmc1E->Fill(MC1Energy); // hmc1TH->Fill(MC1Theta); // hmc1PH->Fill(MC1Phi); // elec2 MC2Energy = mcTrack[1].E(); MC2Theta = radeg*(mcTrack[1].Theta()); MC2Phi = radeg*(mcTrack[1].Phi()); // hmc1E->Fill(MC2Energy); // hmc1TH->Fill(MC2Theta); // hmc1PH->Fill(MC2Phi); // quadrivecteur double elecMC=mcTrack[0].Angle(mcTrack[1].Vect()); // double Q2=4*mcTrack[0].E()*mcTrack[1].E()*(sin(elecMC/2))*(sin(elecMC/2)); QQ_MC=mcTrack[0]+mcTrack[1]; double Q2=QQ_MC.M2(); // hmcQ2->Fill(Q2); TLorentzVector *elecMC0 = new TLorentzVector(mcTrack[0].Px(), mcTrack[0].Py(), mcTrack[0].Pz(), mcTrack[0].E()); TLorentzVector *elecMC1 = new TLorentzVector(mcTrack[1].Px(), mcTrack[1].Py(), mcTrack[1].Pz(), mcTrack[1].E()); // boost elecMC0->Boost(bSigma); elecMC1->Boost(bSigma); Double_t THMC0=radeg*(elecMC0->Theta()); Double_t THMC1=radeg*(elecMC1->Theta()); Double_t THtot=THMC0+THMC1; Double_t COSTMC=TMath::Cos(elecMC0->Theta()); h_costheta_mc-> Fill(COSTMC); // print some event data if(j<5) { cout << "event:" << j << endl; cout << "MC-eepi:" << MC1Energy << " " << MC2Energy << endl; cout << "theta:" << MC1Theta << " " << MC2Theta << endl; cout << "phi:" << MC1Phi << " " << MC2Phi << endl; cout << "THMC0:" << THMC0 << "THMC1:" << THMC1 << endl; cout << "THtot:" << THtot << " Q2:" << Q2 << endl; } // fill tuple atuple[0]=MC1Energy; atuple[1]=MC1Theta; atuple[2]=MC1Phi; atuple[3]=MC2Energy; atuple[4]=MC2Theta; atuple[5]=MC2Phi; atuple[6]=COSTMC; atuple[7]=Q2; // print some event data if(j<5) { cout << "event:" << j << endl; cout << "MC-eepi:" << MC1Energy << " " << MC2Energy << " " << MCEnergy << endl; cout << "theta:" << MC1Theta << " " << MC2Theta << " " << MCTheta << endl; cout << "phi:" << MC1Phi << " " << MC2Phi << " " << MCPhi << endl; cout << "COSTMC:" << COSTMC << " Q2:" << Q2 << endl; } // Analysis starts here // loop over charged candidate tracks Float_t cc_pp = 0, cc_E = 0, cc_mass = 0, cc_TH = 0; Float_t cc_px = 0, cc_py = 0, cc_pz = 0; TLorentzVector reTrack[4], QQ_RE; Int_t nelec_pair = 0; Double_t bestTH=-999; Double_t bestPH=-999; Double_t bestCOST=-999; Int_t ix=-1, iy=-1; for (Int_t nc1 = 0; nc1 < ncCand; nc1++) { PndPidCandidate *pc1 = (PndPidCandidate*)cCand_array->At(nc1); Int_t Charge1 = pc1->GetCharge(); if (Charge1<0) continue; cc_pp = pc1->GetMomentum().Mag(); // if (cc_pp>eSystem) continue; cc_px = pc1->GetMomentum().Px(); cc_py = pc1->GetMomentum().Py(); cc_pz = pc1->GetMomentum().Pz(); cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2); reTrack[0].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E); for (Int_t nc2 = 0; nc2 < ncCand; nc2++) { PndPidCandidate *pc2 = (PndPidCandidate*)cCand_array->At(nc2); Int_t Charge2 = pc2->GetCharge(); if (Charge2>0) continue; cc_pp = pc2->GetMomentum().Mag(); // if (cc_pp>eSystem) continue; cc_px = pc2->GetMomentum().Px(); cc_py = pc2->GetMomentum().Py(); cc_pz = pc2->GetMomentum().Pz(); cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2); reTrack[1].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E); nelec_pair++; // selection on best kinematics // elec1 RE1Energy = reTrack[0].E(); RE1Theta = radeg*(reTrack[0].Theta()); RE1Phi = radeg*(reTrack[0].Phi()); // elec2 RE2Energy = reTrack[1].E(); RE2Theta = radeg*(reTrack[1].Theta()); RE2Phi = radeg*(reTrack[1].Phi()); // quadrivecteur double elecRE=reTrack[0].Angle(reTrack[1].Vect()); // double Q2=4*mcTrack[0].E()*mcTrack[1].E()*(sin(elecMC/2))*(sin(elecMC/2)); QQ_RE=reTrack[0]+reTrack[1]; double Q2=QQ_RE.M2(); // Center of mass angle of electrons // boost vector TLorentzVector *elecRE0 = new TLorentzVector(reTrack[0].Px(), reTrack[0].Py(), reTrack[0].Pz(), reTrack[0].E()); TLorentzVector *elecRE1 = new TLorentzVector(reTrack[1].Px(), reTrack[1].Py(), reTrack[1].Pz(), reTrack[1].E()); elecRE0->Boost(bSigma); elecRE1->Boost(bSigma); Double_t THRE0=radeg*(elecRE0->Theta()); Double_t COSTRE=TMath::Cos(elecRE0->Theta()); Double_t THRE1=radeg*(elecRE1->Theta()); Double_t PHRE0=radeg*(elecRE0->Phi()); Double_t PHRE1=radeg*(elecRE1->Phi()); Double_t THtot=THRE0+THRE1; Double_t PHtot=PHRE0-PHRE1; if(PHtot< -90) PHtot+360; if(abs(THtot-180) < abs(bestTH-180)) { bestTH=THtot; bestPH=PHtot; bestCOST=COSTRE; ix=nc1; iy=nc2; } // print some event data if(j<5) { cout << "event:" << j << endl; cout << "RE-eepi:" << RE1Energy << " " << RE2Energy << endl; cout << "theta:" << RE1Theta << " " << RE2Theta << endl; cout << "phi:" << RE1Phi << " " << RE2Phi << endl; cout << "THRE0:" << THRE0 << "THRE1:" << THRE1 << endl; cout << "THtot:" << THtot << " Q2:" << Q2 << endl; cout << "PHtot:" << PHtot << endl; } } // nc2 } // nc1 h_costheta-> Fill(COSTRE); h_dtheta->Fill(bestTH); h_dphi->Fill(bestPH); hpair->Fill((double) nelec_pair); // Rebelotte with the best solution if(nelec_pair<1) continue; // PndPidCandidate *pc1 = (PndPidCandidate*)cCand_array->At(ix); PndPidCandidate *pc2 = (PndPidCandidate*)cCand_array->At(iy); // positron cc_pp = pc1->GetMomentum().Mag(); cc_px = pc1->GetMomentum().Px(); cc_py = pc1->GetMomentum().Py(); cc_pz = pc1->GetMomentum().Pz(); cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2); reTrack[0].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E); // electron cc_pp = pc2->GetMomentum().Mag(); cc_px = pc2->GetMomentum().Px(); cc_py = pc2->GetMomentum().Py(); cc_pz = pc2->GetMomentum().Pz(); cc_E=TMath::Sqrt(cc_pp*cc_pp+mElec2); reTrack[1].SetPxPyPzE(cc_px,cc_py,cc_pz,cc_E); // elec1 // detector data PndPidProbability *drc_ele = (PndPidProbability *)drc_array->At(ix); PndPidProbability *disc_ele = (PndPidProbability *)disc_array->At(ix); PndPidProbability *mvd_ele = (PndPidProbability *)mvd_array->At(ix); PndPidProbability *stt_ele = (PndPidProbability *)stt_array->At(ix); PndPidProbability *emcb_ele = (PndPidProbability *)emcb_array->At(ix); Double_t k_drc_e = drc_ele->GetElectronPidProb(); Double_t k_disc_e = disc_ele->GetElectronPidProb(); Double_t k_mvd_e = mvd_ele->GetElectronPidProb(); Double_t k_stt_e = stt_ele->GetElectronPidProb(); Double_t k_emcb_e = emcb_ele->GetElectronPidProb(); Double_t xx_e = (k_drc_e/(1-k_drc_e))*(k_disc_e/(1-k_disc_e)) *(k_mvd_e/(1-k_mvd_e))*(k_stt_e/(1-k_stt_e)) *(k_emcb_e/(1-k_emcb_e)); Double_t k_comb_e = xx_e/(xx_e+1); atuple[ 8]=reTrack[0].P(); atuple[ 9]=reTrack[0].Theta(); atuple[10]=reTrack[0].Phi(); atuple[11]=pc1->GetEmcRawEnergy(); atuple[12]=pc1->GetEmcNumberOfCrystals(); atuple[13]=k_emcb_e; atuple[14]=k_stt_e; atuple[15]=k_disc_e; atuple[16]=k_drc_e; atuple[17]=k_mvd_e; atuple[18]=k_comb_e; // elec2 PndPidProbability *drc_posi = (PndPidProbability *)drc_array->At(iy); PndPidProbability *disc_posi = (PndPidProbability *)disc_array->At(iy); PndPidProbability *mvd_posi = (PndPidProbability *)mvd_array->At(iy); PndPidProbability *stt_posi = (PndPidProbability *)stt_array->At(iy); PndPidProbability *emcb_posi = (PndPidProbability *)emcb_array->At(iy); Double_t k_drc_p = drc_posi->GetElectronPidProb(); Double_t k_disc_p = disc_posi->GetElectronPidProb(); Double_t k_mvd_p = mvd_posi->GetElectronPidProb(); Double_t k_stt_p = stt_posi->GetElectronPidProb(); Double_t k_emcb_p = emcb_posi->GetElectronPidProb(); Double_t xx_p = (k_drc_p/(1-k_drc_p))*(k_disc_p/(1-k_disc_p)) *(k_mvd_p/(1-k_mvd_p))*(k_stt_p/(1-k_stt_p)) *(k_emcb_p/(1-k_emcb_p)); Double_t k_comb_p = xx_p/(xx_p+1); atuple[19]=reTrack[1].P(); atuple[20]=reTrack[1].Theta(); atuple[21]=reTrack[1].Phi(); atuple[22]=pc2->GetEmcRawEnergy(); atuple[23]=pc2->GetEmcNumberOfCrystals(); atuple[24]=k_emcb_p; atuple[25]=k_stt_p; atuple[26]=k_disc_p; atuple[27]=k_drc_p; atuple[28]=k_mvd_p; atuple[29]=k_comb_p; atuple[30]=bestTH; atuple[31]=bestPH; atuple[32]=bestCOST; NTev->Fill(atuple); if(j<5) { cout << "k_comb_e:" << k_comb_e<< " k_comb_p:" << k_comb_p << endl; } // standard cuts for histos Bool_t com_ele_1 = drc_ele->GetElectronPidProb() > 0.05 && disc_ele->GetElectronPidProb() > 0.05 && mvd_ele->GetElectronPidProb() > 0.05 && stt_ele->GetElectronPidProb() > 0.05 && emcb_ele->GetElectronPidProb() > 0.05; Bool_t com_ele_2 = k_comb_e > 0.9; Bool_t com_ele_3 = pc1->GetEmcNumberOfCrystals() > 5; Bool_t com_ele_4 = bestTH >=178. && bestTH <= 182.; Bool_t com_ele_5 = bestPH >=178. && bestPH <= 182.; Bool_t com_posi_1 = drc_posi->GetElectronPidProb() > 0.05 && disc_posi->GetElectronPidProb() > 0.05 && mvd_posi->GetElectronPidProb() > 0.05 && stt_posi->GetElectronPidProb() > 0.05 && emcb_posi->GetElectronPidProb() > 0.05; Bool_t com_posi_2 = k_comb_p > 0.9; Bool_t com_posi_3 = pc2->GetEmcNumberOfCrystals() > 5; if(j<5) { cout << com_ele_1 << com_ele_2 << com_ele_3 << com_ele_4 << com_ele_4 << com_posi_1 << com_posi_2 << com_posi_3 << endl; } if (com_ele_1&&com_ele_2&&com_ele_3&&com_ele_4 &&com_ele_5&&com_posi_1&&com_posi_2&&com_posi_3) { h_costheta_sel->Fill(bestCOST); } } // loop j over events cout << " NEVcount: " << NEVcount << endl; h_efficiency->Divide(h_costheta_sel,h_costheta_mc,1,1,"B"); // output cMA->cd(1);gPad->SetLogy(); h_costheta_mc->Draw(); cMA->cd(2);gPad->SetLogy(); h_costheta->Draw(); cMA->cd(3);gPad->SetLogy(); h_costheta_sel->Draw(); cMA->cd(4);gPad->SetLogy(); h_efficiency->Draw(); cMA->cd(5);gPad->SetLogy(); h_dtheta->Draw(); cMA->cd(6);gPad->SetLogy(); h_dphi->Draw(); cMA->cd(7); hpair->Draw(); cMA->cd(0); out->cd(); hpair->Write(); h_costheta_mc->Write(); h_costheta->Write(); h_costheta_sel->Write(); h_efficiency->Write(); h_dtheta->Write(); h_dphi->Write(); NTev->Write(); out->Save(); cout << " Yahoo! " << endl; }
void PID_misidentification() { // -- define tuple file name, tuple name and cuts to apply----------------------- // -- and also the name of the output file const std::string filename = "/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/background_MC_samples/Bs2JpsiX_MC_2012_signal_withbdt.root"; const std::string treename = "withbdt"; const std::string outFilename("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/new_tuples/background_MC_samples/Bs2JpsiX_MC_2012_signal_withbdt_misidentification.root"); TFile* file = TFile::Open( filename.c_str() ); if( !file ) std::cout << "file " << filename << " does not exist" << std::endl; TTree* tree = (TTree*)file->Get( treename.c_str() ); if( !tree ) std::cout << "tree " << treename << " does not exist" << std::endl; // -- activate the branches you need--------------------------------------------- tree->SetBranchStatus("*", 1); // -- this file is just here to make the 'CopyTree' happy TFile* dummyFile = new TFile("/afs/cern.ch/work/a/apmorris/private/cern/ntuples/dummy.root","RECREATE"); TTree* rTree1 = tree->CopyTree("bdtg>=0.85"); double chi_c_M, chi_c_P, chi_c_PE, chi_c_PT, chi_c_PX, chi_c_PY, chi_c_PZ, chi_c_ETA; double kaon_M, kaon_P, kaon_PE, kaon_PX, kaon_PT, kaon_PY, kaon_PZ, kaon_ETA, kaon_IPCHI2_OWNPV, kaon_TRACK_GhostProb, kaon_ProbNNp, kaon_ProbNNk; double proton_M, proton_P, proton_PE, proton_PT, proton_PX, proton_PY, proton_PZ, proton_ETA, proton_IPCHI2_OWNPV, proton_TRACK_GhostProb, proton_ProbNNp, proton_ProbNNk; double Jpsi_M, Jpsi_P, Jpsi_PE, Jpsi_PT, Jpsi_PX, Jpsi_PY, Jpsi_PZ, Jpsi_ETA; double gamma_M, gamma_P, gamma_PE, gamma_PT, gamma_PX, gamma_PY, gamma_PZ, gamma_ETA, gamma_CL; double muminus_M, muminus_P, muminus_PE, muminus_PT, muminus_PX, muminus_PY, muminus_PZ, muminus_ETA, muminus_ProbNNmu, muminus_TRACK_GhostProb; double muplus_M, muplus_P, muplus_PE, muplus_PT, muplus_PX, muplus_PY, muplus_PZ, muplus_ETA, muplus_ProbNNmu, muplus_TRACK_GhostProb; double Lambda_b0_DTF_MASS_constr1, Lambda_b0_DTF_CHI2NDOF, Lambda_b0_IPCHI2_OWNPV; double Lambda_b0_FDS, Lambda_b0_pi0veto, Lambda_b0_PT; float bdtg; bool Lambda_b0_L0MuonDecision_TOS, Lambda_b0_L0DiMuonDecision_TOS; bool Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, Lambda_b0_Hlt1DiMuonLowMassDecision_TOS; bool Lambda_b0_Hlt1TrackMuonDecision_TOS, Lambda_b0_Hlt1TrackAllL0Decision_TOS; bool Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, Lambda_b0_Hlt2DiMuonDetachedDecision_TOS; bool Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS; rTree1->SetBranchAddress("chi_c_M", &chi_c_M); rTree1->SetBranchAddress("chi_c_P", &chi_c_P); rTree1->SetBranchAddress("chi_c_PE", &chi_c_PE); rTree1->SetBranchAddress("chi_c_PT", &chi_c_PT); rTree1->SetBranchAddress("chi_c_PX", &chi_c_PX); rTree1->SetBranchAddress("chi_c_PY", &chi_c_PY); rTree1->SetBranchAddress("chi_c_PZ", &chi_c_PZ); //rTree1->SetBranchAddress("chi_c_ETA", &chi_c_ETA); rTree1->SetBranchAddress("kaon_M", &kaon_M); rTree1->SetBranchAddress("kaon_P", &kaon_P); rTree1->SetBranchAddress("kaon_PE", &kaon_PE); rTree1->SetBranchAddress("kaon_PX", &kaon_PX); rTree1->SetBranchAddress("kaon_PT", &kaon_PT); rTree1->SetBranchAddress("kaon_PY", &kaon_PY); rTree1->SetBranchAddress("kaon_PZ", &kaon_PZ); //rTree1->SetBranchAddress("kaon_ETA", &kaon_ETA); rTree1->SetBranchAddress("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV); rTree1->SetBranchAddress("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb); rTree1->SetBranchAddress("kaon_ProbNNp", &kaon_ProbNNp); rTree1->SetBranchAddress("kaon_ProbNNk", &kaon_ProbNNk); rTree1->SetBranchAddress("proton_M", &proton_M); rTree1->SetBranchAddress("proton_P", &proton_P); rTree1->SetBranchAddress("proton_PE", &proton_PE); rTree1->SetBranchAddress("proton_PT", &proton_PT); rTree1->SetBranchAddress("proton_PX", &proton_PX); rTree1->SetBranchAddress("proton_PY", &proton_PY); rTree1->SetBranchAddress("proton_PZ", &proton_PZ); //rTree1->SetBranchAddress("proton_ETA", &proton_ETA); rTree1->SetBranchAddress("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV); rTree1->SetBranchAddress("proton_TRACK_GhostProb", &proton_TRACK_GhostProb); rTree1->SetBranchAddress("proton_ProbNNp", &proton_ProbNNp); rTree1->SetBranchAddress("proton_ProbNNk", &proton_ProbNNk); rTree1->SetBranchAddress("Jpsi_M", &Jpsi_M); rTree1->SetBranchAddress("Jpsi_P", &Jpsi_P); rTree1->SetBranchAddress("Jpsi_PE", &Jpsi_PE); rTree1->SetBranchAddress("Jpsi_PT", &Jpsi_PT); rTree1->SetBranchAddress("Jpsi_PX", &Jpsi_PX); rTree1->SetBranchAddress("Jpsi_PY", &Jpsi_PY); rTree1->SetBranchAddress("Jpsi_PZ", &Jpsi_PZ); //rTree1->SetBranchAddress("Jpsi_ETA", &Jpsi_ETA); rTree1->SetBranchAddress("gamma_M", &gamma_M); rTree1->SetBranchAddress("gamma_P", &gamma_P); rTree1->SetBranchAddress("gamma_PE", &gamma_PE); rTree1->SetBranchAddress("gamma_PT", &gamma_PT); rTree1->SetBranchAddress("gamma_PX", &gamma_PX); rTree1->SetBranchAddress("gamma_PY", &gamma_PY); rTree1->SetBranchAddress("gamma_PZ", &gamma_PZ); //rTree1->SetBranchAddress("gamma_ETA", &gamma_ETA); rTree1->SetBranchAddress("gamma_CL", &gamma_CL); rTree1->SetBranchAddress("muminus_M", &muminus_M); rTree1->SetBranchAddress("muminus_P", &muminus_P); rTree1->SetBranchAddress("muminus_PE", &muminus_PE); rTree1->SetBranchAddress("muminus_PT", &muminus_PT); rTree1->SetBranchAddress("muminus_PX", &muminus_PX); rTree1->SetBranchAddress("muminus_PY", &muminus_PY); rTree1->SetBranchAddress("muminus_PZ", &muminus_PZ); //rTree1->SetBranchAddress("muminus_ETA", &muminus_ETA); rTree1->SetBranchAddress("muminus_ProbNNmu", &muminus_ProbNNmu); rTree1->SetBranchAddress("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb); rTree1->SetBranchAddress("muplus_M", &muplus_M); rTree1->SetBranchAddress("muplus_P", &muplus_P); rTree1->SetBranchAddress("muplus_PE", &muplus_PE); rTree1->SetBranchAddress("muplus_PT", &muplus_PT); rTree1->SetBranchAddress("muplus_PX", &muplus_PX); rTree1->SetBranchAddress("muplus_PY", &muplus_PY); rTree1->SetBranchAddress("muplus_PZ", &muplus_PZ); //rTree1->SetBranchAddress("muplus_ETA", &muplus_ETA); rTree1->SetBranchAddress("muplus_ProbNNmu", &muplus_ProbNNmu); rTree1->SetBranchAddress("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb); rTree1->SetBranchAddress("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1); rTree1->SetBranchAddress("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF); rTree1->SetBranchAddress("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV); rTree1->SetBranchAddress("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_FDS", &Lambda_b0_FDS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS); rTree1->SetBranchAddress("Lambda_b0_pi0veto", &Lambda_b0_pi0veto); rTree1->SetBranchAddress("Lambda_b0_PT", &Lambda_b0_PT); rTree1->SetBranchAddress("bdtg", &bdtg); //------------------------------------------------------------------------------- TFile* rFile = new TFile( outFilename.c_str() ,"RECREATE"); TTree* rTree2 = new TTree(); rTree2->SetName("withbdt"); rTree2->Branch("chi_c_M", &chi_c_M, "chi_c_M/D"); rTree2->Branch("chi_c_P", &chi_c_P, "chi_c_P/D"); rTree2->Branch("chi_c_PE", &chi_c_PE, "chi_c_PE/D"); rTree2->Branch("chi_c_PT", &chi_c_PT, "chi_c_PT/D"); rTree2->Branch("chi_c_PX", &chi_c_PX, "chi_c_PX/D"); rTree2->Branch("chi_c_PY", &chi_c_PY, "chi_c_PY/D"); rTree2->Branch("chi_c_PZ", &chi_c_PZ, "chi_c_PZ/D"); //rTree2->Branch("chi_c_ETA", &chi_c_ETA, "chi_c_ETA/D"); rTree2->Branch("kaon_M", &kaon_M, "kaon_M/D"); rTree2->Branch("kaon_P", &kaon_P, "kaon_P/D"); rTree2->Branch("kaon_PE", &kaon_PE, "kaon_PE/D"); rTree2->Branch("kaon_PX", &kaon_PX, "kaon_PX/D"); rTree2->Branch("kaon_PT", &kaon_PT, "kaon_PT/D"); rTree2->Branch("kaon_PY", &kaon_PY, "kaon_PY/D"); rTree2->Branch("kaon_PZ", &kaon_PZ, "kaon_PZ/D"); //rTree2->Branch("kaon_ETA", &kaon_ETA, "kaon_ETA/D"); rTree2->Branch("kaon_IPCHI2_OWNPV", &kaon_IPCHI2_OWNPV, "kaon_IPCHI2_OWNPV/D"); rTree2->Branch("kaon_TRACK_GhostProb", &kaon_TRACK_GhostProb, "kaon_TRACK_GhostProb/D"); rTree2->Branch("kaon_ProbNNp", &kaon_ProbNNp, "kaon_ProbNNp/D"); rTree2->Branch("kaon_ProbNNk", &kaon_ProbNNk, "kaon_ProbNNk/D"); rTree2->Branch("proton_M", &proton_M, "proton_M/D"); rTree2->Branch("proton_P", &proton_P, "proton_P/D"); rTree2->Branch("proton_PE", &proton_PE, "proton_PE/D"); rTree2->Branch("proton_PT", &proton_PT, "proton_PT/D"); rTree2->Branch("proton_PX", &proton_PX, "proton_PX/D"); rTree2->Branch("proton_PY", &proton_PY, "proton_PY/D"); rTree2->Branch("proton_PZ", &proton_PZ, "proton_PZ/D"); //rTree2->Branch("proton_ETA", &proton_ETA, "proton_ETA/D"); rTree2->Branch("proton_IPCHI2_OWNPV", &proton_IPCHI2_OWNPV, "proton_IPCHI2_OWNPV/D"); rTree2->Branch("proton_TRACK_GhostProb", &proton_TRACK_GhostProb, "proton_TRACK_GhostProb/D"); rTree2->Branch("proton_ProbNNp", &proton_ProbNNp, "proton_ProbNNp/D"); rTree2->Branch("proton_ProbNNk", &proton_ProbNNk, "proton_ProbNNk/D"); rTree2->Branch("Jpsi_M", &Jpsi_M, "Jpsi_M/D"); rTree2->Branch("Jpsi_P", &Jpsi_P, "Jpsi_P/D"); rTree2->Branch("Jpsi_PE", &Jpsi_PE, "Jpsi_PE/D"); rTree2->Branch("Jpsi_PT", &Jpsi_PT, "Jpsi_PT/D"); rTree2->Branch("Jpsi_PX", &Jpsi_PX, "Jpsi_PX/D"); rTree2->Branch("Jpsi_PY", &Jpsi_PY, "Jpsi_PY/D"); rTree2->Branch("Jpsi_PZ", &Jpsi_PZ, "Jpsi_PZ/D"); //rTree2->Branch("Jpsi_ETA", &Jpsi_ETA, "Jpsi_ETA/D"); rTree2->Branch("gamma_M", &gamma_M, "gamma_M/D"); rTree2->Branch("gamma_P", &gamma_P, "gamma_P/D"); rTree2->Branch("gamma_PE", &gamma_PE, "gamma_PE/D"); rTree2->Branch("gamma_PT", &gamma_PT, "gamma_PT/D"); rTree2->Branch("gamma_PX", &gamma_PX, "gamma_PX/D"); rTree2->Branch("gamma_PY", &gamma_PY, "gamma_PY/D"); rTree2->Branch("gamma_PZ", &gamma_PZ, "gamma_PZ/D"); //rTree2->Branch("gamma_ETA", &gamma_ETA, "gamma_ETA/D"); rTree2->Branch("gamma_CL", &gamma_CL, "gamma_CL/D"); rTree2->Branch("muminus_M", &muminus_M, "muminus_M/D"); rTree2->Branch("muminus_P", &muminus_P, "muminus_P/D"); rTree2->Branch("muminus_PE", &muminus_PE, "muminus_PE/D"); rTree2->Branch("muminus_PT", &muminus_PT, "muminus_PT/D"); rTree2->Branch("muminus_PX", &muminus_PX, "muminus_PX/D"); rTree2->Branch("muminus_PY", &muminus_PY, "muminus_PY/D"); rTree2->Branch("muminus_PZ", &muminus_PZ, "muminus_PZ/D"); //rTree2->Branch("muminus_ETA", &muminus_ETA, "muminus_ETA/D"); rTree2->Branch("muminus_ProbNNmu", &muminus_ProbNNmu, "muminus_ProbNNmu/D"); rTree2->Branch("muminus_TRACK_GhostProb", &muminus_TRACK_GhostProb, "muminus_TRACK_GhostProb/D"); rTree2->Branch("muplus_M", &muplus_M, "muplus_M/D"); rTree2->Branch("muplus_P", &muplus_P, "muplus_P/D"); rTree2->Branch("muplus_PE", &muplus_PE, "muplus_PE/D"); rTree2->Branch("muplus_PT", &muplus_PT, "muplus_PT/D"); rTree2->Branch("muplus_PX", &muplus_PX, "muplus_PX/D"); rTree2->Branch("muplus_PY", &muplus_PY, "muplus_PY/D"); rTree2->Branch("muplus_PZ", &muplus_PZ, "muplus_PZ/D"); //rTree2->Branch("muplus_ETA", &muplus_ETA, "muplus_ETA/D"); rTree2->Branch("muplus_ProbNNmu", &muplus_ProbNNmu, "muplus_ProbNNmu/D"); rTree2->Branch("muplus_TRACK_GhostProb", &muplus_TRACK_GhostProb, "muplus_TRACK_GhostProb/D"); rTree2->Branch("Lambda_b0_DTF_MASS_constr1", &Lambda_b0_DTF_MASS_constr1, "Lambda_b0_DTF_MASS_constr1/D"); rTree2->Branch("Lambda_b0_DTF_CHI2NDOF", &Lambda_b0_DTF_CHI2NDOF, "Lambda_b0_DTF_CHI2NDOF/D"); rTree2->Branch("Lambda_b0_IPCHI2_OWNPV", &Lambda_b0_IPCHI2_OWNPV, "Lambda_b0_IPCHI2_OWNPV/D"); rTree2->Branch("Lambda_b0_L0DiMuonDecision_TOS", &Lambda_b0_L0DiMuonDecision_TOS, "Lambda_b0_L0DiMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_L0MuonDecision_TOS", &Lambda_b0_L0MuonDecision_TOS, "Lambda_b0_L0MuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_FDS", &Lambda_b0_FDS, "Lambda_b0_FDS/D"); rTree2->Branch("Lambda_b0_Hlt1DiMuonHighMassDecision_TOS", &Lambda_b0_Hlt1DiMuonHighMassDecision_TOS, "Lambda_b0_Hlt1DiMuonHighMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1DiMuonLowMassDecision_TOS", &Lambda_b0_Hlt1DiMuonLowMassDecision_TOS, "Lambda_b0_Hlt1DiMuonLowMassDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackMuonDecision_TOS", &Lambda_b0_Hlt1TrackMuonDecision_TOS, "Lambda_b0_Hlt1TrackMuonDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1TrackAllL0Decision_TOS", &Lambda_b0_Hlt1TrackAllL0Decision_TOS, "Lambda_b0_Hlt1TrackAllL0Decision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS", &Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS, "Lambda_b0_Hlt1SingleMuonHighPTDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedDecision_TOS/B"); rTree2->Branch("Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS", &Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS, "Lambda_b0_Hlt2DiMuonDetachedHeavyDecision_TOS/B"); rTree2->Branch("Lambda_b0_pi0veto", &Lambda_b0_pi0veto, "Lambda_b0_pi0veto/D"); rTree2->Branch("Lambda_b0_PT", &Lambda_b0_PT, "Lambda_b0_PT/D"); rTree2->Branch("bdtg", &bdtg, "bdtg/F"); //This is where the misidentification is calculated for P and K--------------------------- const double mK(0.493677); double mass_proton_as_proton, mass_proton_as_kaon, mass_kaon_as_kaon; rTree2->Branch("mass_proton_as_proton", &mass_proton_as_proton, "mass_proton_as_proton/D"); rTree2->Branch("mass_proton_as_kaon", &mass_proton_as_kaon, "mass_proton_as_kaon/D"); rTree2->Branch("mass_kaon_as_kaon", &mass_kaon_as_kaon, "mass_kaon_as_kaon/D"); double proton_P = sqrt(proton_PX*proton_PX + proton_PY*proton_PY + proton_PZ*proton_PZ) ; for(int i = 0; i < rTree1->GetEntries(); ++i){ //for event in tree rTree1->GetEntry(i); TLorentzVector * proton = new TLorentzVector(proton_PX, proton_PY, proton_PZ, proton_PE); TLorentzVector * proton_as_kaon = new TLorentzVector(proton_PX, proton_PY, proton_PZ, sqrt(proton_P*proton_P + mK*mK)); TLorentzVector * kaon = new TLorentzVector(kaon_PX, kaon_PY, kaon_PZ, kaon_PE); mass_proton_as_proton = proton->M(); mass_proton_as_kaon = proton_as_kaon->M(); mass_kaon_as_kaon = kaon->M(); rTree2->Fill(); } rTree2->Print(); rTree2->Write(); rFile->Save(); }
void ana_complete(int nevts=0) { //-----User Settings:------------------------------------------------------ TString parAsciiFile = "all.par"; TString prefix = "evtcomplete"; TString input = "psi2s_Jpsi2pi_Jpsi_mumu.dec"; TString output = "ana"; TString friend1 = "pid"; TString friend2 = ""; TString friend3 = ""; TString friend4 = ""; // ----- Initial Settings -------------------------------------------- PndMasterRunAna *fRun= new PndMasterRunAna(); fRun->SetInput(input); fRun->SetOutput(output); fRun->SetFriend1(friend1); fRun->SetFriend2(friend2); fRun->SetFriend3(friend3); fRun->SetFriend4(friend4); fRun->SetParamAsciiFile(parAsciiFile); fRun->Setup(prefix); // *** some variables int i=0,j=0, k=0, l=0; gStyle->SetOptFit(1011); fRun->Init(); // *** create an output file for all histograms TFile *out = TFile::Open(prefix+"_output_ana.root","RECREATE"); // *** create some histograms TH1F *hmomtrk = new TH1F("hmomtrk","track momentum (all)",200,0,5); TH1F *hthttrk = new TH1F("hthttrk","track theta (all)",200,0,3.1415); TH1F *hjpsim_all = new TH1F("hjpsim_all","J/#psi mass (all)",200,0,4.5); TH1F *hpsim_all = new TH1F("hpsim_all","#psi(2S) mass (all)",200,0,5); TH1F *hjpsim_lpid = new TH1F("hjpsim_lpid","J/#psi mass (loose pid)",200,0,4.5); TH1F *hpsim_lpid = new TH1F("hpsim_lpid","#psi(2S) mass (loose pid)",200,0,5); TH1F *hjpsim_tpid = new TH1F("hjpsim_tpid","J/#psi mass (tight pid)",200,0,4.5); TH1F *hpsim_tpid = new TH1F("hpsim_tpid","#psi(2S) mass (tight pid)",200,0,5); TH1F *hjpsim_trpid = new TH1F("hjpsim_trpid","J/#psi mass (true pid)",200,0,4.5); TH1F *hpsim_trpid = new TH1F("hpsim_trpid","#psi(2S) mass (true pid)",200,0,5); TH1F *hjpsim_ftm = new TH1F("hjpsim_ftm","J/#psi mass (full truth match)",200,0,4.5); TH1F *hpsim_ftm = new TH1F("hpsim_ftm","#psi(2S) mass (full truth match)",200,0,5); TH1F *hjpsim_nm = new TH1F("hjpsim_nm","J/#psi mass (no truth match)",200,0,4.5); TH1F *hpsim_nm = new TH1F("hpsim_nm","#psi(2S) mass (no truth match)",200,0,5); TH1F *hjpsim_diff = new TH1F("hjpsim_diff","J/#psi mass diff to truth",100,-2,2); TH1F *hpsim_diff = new TH1F("hpsim_diff","#psi(2S) mass diff to truth",100,-2,2); TH1F *hjpsim_vf = new TH1F("hjpsim_vf","J/#psi mass (vertex fit)",200,0,4.5); TH1F *hjpsim_4cf = new TH1F("hjpsim_4cf","J/#psi mass (4C fit)",200,0,4.5); TH1F *hjpsim_mcf = new TH1F("hjpsim_mcf","J/#psi mass (mass constraint fit)",200,0,4.5); TH1F *hjpsi_chi2_vf = new TH1F("hjpsi_chi2_vf", "J/#psi: #chi^{2} vertex fit",100,0,10); TH1F *hpsi_chi2_4c = new TH1F("hpsi_chi2_4c", "#psi(2S): #chi^{2} 4C fit",100,0,250); TH1F *hjpsi_chi2_mf = new TH1F("hjpsi_chi2_mf", "J/#psi: #chi^{2} mass fit",100,0,10); TH1F *hjpsi_prob_vf = new TH1F("hjpsi_prob_vf", "J/#psi: Prob vertex fit",100,0,1); TH1F *hpsi_prob_4c = new TH1F("hpsi_prob_4c", "#psi(2S): Prob 4C fit",100,0,1); TH1F *hjpsi_prob_mf = new TH1F("hjpsi_prob_mf", "J/#psi: Prob mass fit",100,0,1); TH2F *hvpos = new TH2F("hvpos","(x,y) projection of fitted decay vertex",100,-2,2,100,-2,2); // // Now the analysis stuff comes... // // *** the data reader object PndAnalysis* theAnalysis = new PndAnalysis(); if (nevts==0) nevts= theAnalysis->GetEntries(); // *** RhoCandLists for the analysis RhoCandList chrg, muplus, muminus, piplus, piminus, jpsi, psi2s; // *** Mass selector for the jpsi cands double m0_jpsi = TDatabasePDG::Instance()->GetParticle("J/psi")->Mass(); // Get nominal PDG mass of the J/psi RhoMassParticleSelector *jpsiMassSel=new RhoMassParticleSelector("jpsi",m0_jpsi,1.0); // *** the lorentz vector of the initial psi(2S) TLorentzVector ini(0, 0, 6.231552, 7.240065); // *** // the event loop // *** int cntdbltrk=0, cntdblmc=0, cntdblboth=0, cnttrk=0, cnt_dbl_jpsi=0, cnt_dbl_psip=0; while (theAnalysis->GetEvent() && i++<nevts) { if ((i%100)==0) cout<<"evt " << i << endl; // *** Select with no PID info ('All'); type and mass are set theAnalysis->FillList(chrg, "Charged"); theAnalysis->FillList(muplus, "MuonAllPlus"); theAnalysis->FillList(muminus, "MuonAllMinus"); theAnalysis->FillList(piplus, "PionAllPlus"); theAnalysis->FillList(piminus, "PionAllMinus"); // *** momentum and theta histograms for (j=0;j<muplus.GetLength();++j) { hmomtrk->Fill(muplus[j]->P()); hthttrk->Fill(muplus[j]->P4().Theta()); } for (j=0;j<muminus.GetLength();++j) { hmomtrk->Fill(muminus[j]->P()); hthttrk->Fill(muminus[j]->P4().Theta()); } cnttrk += chrg.GetLength(); int n1, n2, n3; countDoubles(chrg,n1,n2,n3); cntdbltrk += n1; cntdblmc += n2; cntdblboth += n3; // *** combinatorics for J/psi -> mu+ mu- jpsi.Combine(muplus, muminus); // *** // *** do the TRUTH MATCH for jpsi // *** jpsi.SetType(443); int nm = 0; for (j=0;j<jpsi.GetLength();++j) { hjpsim_all->Fill( jpsi[j]->M() ); if (theAnalysis->McTruthMatch(jpsi[j])) { nm++; hjpsim_ftm->Fill( jpsi[j]->M() ); hjpsim_diff->Fill( jpsi[j]->GetMcTruth()->M() - jpsi[j]->M() ); } else hjpsim_nm->Fill( jpsi[j]->M() ); } if (nm>1) cnt_dbl_jpsi++; // *** // *** do VERTEX FIT (J/psi) // *** for (j=0;j<jpsi.GetLength();++j) { PndKinVtxFitter vtxfitter(jpsi[j]); // instantiate a vertex fitter vtxfitter.Fit(); double chi2_vtx = vtxfitter.GetChi2(); // access chi2 of fit double prob_vtx = vtxfitter.GetProb(); // access probability of fit hjpsi_chi2_vf->Fill(chi2_vtx); hjpsi_prob_vf->Fill(prob_vtx); if ( prob_vtx > 0.01 ) // when good enough, fill some histos { RhoCandidate *jfit = jpsi[j]->GetFit(); // access the fitted cand TVector3 jVtx=jfit->Pos(); // and the decay vertex position hjpsim_vf->Fill(jfit->M()); hvpos->Fill(jVtx.X(),jVtx.Y()); } } // *** some rough mass selection jpsi.Select(jpsiMassSel); // *** combinatorics for psi(2S) -> J/psi pi+ pi- psi2s.Combine(jpsi, piplus, piminus); // *** // *** do the TRUTH MATCH for psi(2S) // *** psi2s.SetType(88888); nm = 0; for (j=0;j<psi2s.GetLength();++j) { hpsim_all->Fill( psi2s[j]->M() ); if (theAnalysis->McTruthMatch(psi2s[j])) { nm++; hpsim_ftm->Fill( psi2s[j]->M() ); hpsim_diff->Fill( psi2s[j]->GetMcTruth()->M() - psi2s[j]->M() ); } else hpsim_nm->Fill( psi2s[j]->M() ); } if (nm>1) cnt_dbl_psip++; // *** // *** do 4C FIT (initial psi(2S) system) // *** for (j=0;j<psi2s.GetLength();++j) { PndKinFitter fitter(psi2s[j]); // instantiate the kin fitter in psi(2S) fitter.Add4MomConstraint(ini); // set 4 constraint fitter.Fit(); // do fit double chi2_4c = fitter.GetChi2(); // get chi2 of fit double prob_4c = fitter.GetProb(); // access probability of fit hpsi_chi2_4c->Fill(chi2_4c); hpsi_prob_4c->Fill(prob_4c); if ( prob_4c > 0.01 ) // when good enough, fill some histo { RhoCandidate *jfit = psi2s[j]->Daughter(0)->GetFit(); // get fitted J/psi hjpsim_4cf->Fill(jfit->M()); } } // *** // *** do MASS CONSTRAINT FIT (J/psi) // *** for (j=0;j<jpsi.GetLength();++j) { PndKinFitter mfitter(jpsi[j]); // instantiate the PndKinFitter in psi(2S) mfitter.AddMassConstraint(m0_jpsi); // add the mass constraint mfitter.Fit(); // do fit double chi2_m = mfitter.GetChi2(); // get chi2 of fit double prob_m = mfitter.GetProb(); // access probability of fit hjpsi_chi2_mf->Fill(chi2_m); hjpsi_prob_mf->Fill(prob_m); if ( prob_m > 0.01 ) // when good enough, fill some histo { RhoCandidate *jfit = jpsi[j]->GetFit(); // access the fitted cand hjpsim_mcf->Fill(jfit->M()); } } // *** // *** TRUE PID combinatorics // *** // *** do MC truth match for PID type SelectTruePid(theAnalysis, muplus); SelectTruePid(theAnalysis, muminus); SelectTruePid(theAnalysis, piplus); SelectTruePid(theAnalysis, piminus); // *** all combinatorics again with true PID jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_trpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_trpid->Fill( psi2s[j]->M() ); // *** // *** LOOSE PID combinatorics // *** // *** and again with PidAlgoMvd;PidAlgoStt;PidAlgoDrc and loose selection theAnalysis->FillList(muplus, "MuonLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(muminus, "MuonLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(piplus, "PionLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_lpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_lpid->Fill( psi2s[j]->M() ); // *** // *** TIGHT PID combinatorics // *** // *** and again with PidAlgoMvd;PidAlgoStt and tight selection theAnalysis->FillList(muplus, "MuonTightPlus", "PidAlgoMdtHardCuts"); theAnalysis->FillList(muminus, "MuonTightMinus", "PidAlgoMdtHardCuts"); theAnalysis->FillList(piplus, "PionLoosePlus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); theAnalysis->FillList(piminus, "PionLooseMinus", "PidAlgoMvd;PidAlgoStt;PidAlgoDrc"); jpsi.Combine(muplus, muminus); for (j=0;j<jpsi.GetLength();++j) hjpsim_tpid->Fill( jpsi[j]->M() ); jpsi.Select(jpsiMassSel); psi2s.Combine(jpsi, piplus, piminus); for (j=0;j<psi2s.GetLength();++j) hpsim_tpid->Fill( psi2s[j]->M() ); } // *** write out all the histos out->cd(); hmomtrk->Write(); hthttrk->Write(); hjpsim_all->Write(); hpsim_all->Write(); hjpsim_lpid->Write(); hpsim_lpid->Write(); hjpsim_tpid->Write(); hpsim_tpid->Write(); hjpsim_trpid->Write(); hpsim_trpid->Write(); hjpsim_ftm->Write(); hpsim_ftm->Write(); hjpsim_nm->Write(); hpsim_nm->Write(); hpsim_diff->Write(); hjpsim_diff->Write(); hjpsim_vf->Write(); hjpsim_4cf->Write(); hjpsim_mcf->Write(); hjpsi_chi2_vf->Write(); hpsi_chi2_4c->Write(); hjpsi_chi2_mf->Write(); hjpsi_prob_vf->Write(); hpsi_prob_4c->Write(); hjpsi_prob_mf->Write(); hvpos->Write(); out->Save(); fRun->Finish(); exit(0); }