// ----------------------------------------------------------------------------- // void test() { time_t start = TTimeStamp().GetSec(); set_plot_style(); bool draw = true; //bool debug = true; // Define analysis configuration PSet ps; defaultPSet(ps); // Response plots if (false) { //xSectDistr(ps); responseProfile(); return; } // Print configuration std::stringstream ss; printPSet(ps,ss); std::cout << ss.str() << std::endl; // Params to store DoubleVV ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err; IntV length; clear( ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); init( ps, ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); // Loop through Meff bins int loop = 0; int nloops = ps.nmeff; for ( int imeff = 0; imeff < ps.nmeff; ++imeff ) { // Generate numbers in (x1,x2) plane DoubleVV dalitz; generateTruth( ps, imeff, dalitz, true ); // Integrate across dalitz plane integrate( ps, imeff, dalitz, ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); // Labeling std::stringstream ss; ss << "Meff" << int( ps.meff_bins[imeff] ); // New canvas for plots TCanvas* c1 = 0; if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" ); // Pad for cross-section plot TPad* pad = 0; if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.); if (pad) { pad->SetGrid(); pad->Draw(); pad->cd(); pad->SetLogz(); } TH1F* hr = 0; if (draw) hr = pad->DrawFrame(ps.min,ps.min,ps.max,ps.max); // Histo title if (hr) { std::stringstream sss; sss << "M_{eff}=" << ps.meff_bins[imeff] << " GeV" << ", p_{T1}=" << dr(ps.pt1_bins[imeff],1) << " GeV" << ", p_{T2}=" << dr(ps.pt2_bins[imeff],1) << " GeV" << ", p_{T3}=" << dr(ps.pt3_bins[imeff],1) << " GeV"; hr->SetTitle( sss.str().c_str() ); hr->GetXaxis()->SetTitle( "x_{2}" ); hr->GetYaxis()->SetTitle( "x_{1}" ); } // Create 2D cross-section plot TH2D* his = 0; if (draw) his = new TH2D(TString("Histo"+ss.str()),"", ps.nbins,ps.min,ps.max, ps.nbins,ps.min,ps.max); //double x3 = ( 2. * ps.pt3_bins[imeff] ) / ( ps.meff_bins[imeff] + ps.pt3_bins[imeff] ); // Fill 2D cross-section plot for ( int x2_bin = 0; x2_bin < ps.nbins; ++x2_bin ) { for ( int x1_bin = 0; x1_bin < ps.nbins; ++x1_bin ) { // std::cout << " Fill:" // << " x2_bin: " << x2_bin // << " x2: " << val(x2_bin,nbins) // << " x1_bin: " << x1_bin // << " x1: " << val(x1_bin,nbins) // << " val: " << dalitz[x2_bin][x1_bin] // << std::endl; if (his) his->Fill( val(x2_bin,ps)+ps.width/2., val(x1_bin,ps)+ps.width/2., dalitz[x2_bin][x1_bin] ); } } // Draw 2D cross-section plot gStyle->SetPalette(1); if (his) { //his->SetMaximum( his->GetMaximum()*10. ); //his->SetMinimum( his->GetMinimum(1.e-12)*0.1 ); // his->SetMaximum( 1.e9 ); // his->SetMinimum( 1.e0 ); his->Draw("COLZsame"); } // Pad for AlphaT contours if (c1) c1->cd(); TPad* overlay = 0; if (draw) overlay = new TPad(TString("Overlay"+ss.str()),"",0.,0.,1.,1.); if (overlay) { overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); } //TH1F* hframe = 0; if (draw) overlay->DrawFrame(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymax()); // Graphs of AlphaT contours TMultiGraph* mg = 0; if (draw) { mg = new TMultiGraph(); for ( Int_t icut = 0; icut < (int)ps.cutValues.size(); icut++ ) { Double_t alpha_t = ps.cutValues[icut]; const Int_t n = ps.nbins; DoubleV x1(n,0.); DoubleV x2(n,0.); for ( Int_t x2_bin = 0; x2_bin < ps.nbins; x2_bin++ ) { x2[x2_bin] = x2_bin * ps.width; x1[x2_bin] = cutAlgoInverse(ps.cutValues[icut],x2[x2_bin],ALGO_TYPE); } TGraph* gr = new TGraph(n,&x2.front(),&x1.front()); mg->Add(gr,"l"); } mg->Draw(); } if (c1) c1->cd(); if (c1) c1->SaveAs(TString(ss.str()+".png")); if (c1) c1->SaveAs(TString(ss.str()+".pdf")); if (c1) c1->SaveAs(TString(ss.str()+".C")); } // Canvas for ratio vs Meff if (false) { TCanvas* c2 = new TCanvas( "c2", "" ); c2->SetRightMargin(0.2); c2->SetLogy(); c2->cd(); TMultiGraph* mg2 = new TMultiGraph(); DoubleV err( ps.nmeff, 0. ); for ( Int_t icut = 0; icut < (int)ps.cutValues.size(); icut++ ) { if ( length[icut] == 0 ) { continue; } // TGraphAsymmErrors* gr = new TGraphAsymmErrors( length[icut], // &ps.meff_bins.front(), // &err.front(), // &err.front(), // &ratio[icut].front(), // &ratio_errl[icut].front(), // &ratio_errh[icut].front() ); TGraph* gr = new TGraphAsymmErrors( length[icut], &ps.meff_bins.front(), &ratio[icut].front() ); std::stringstream ss; ss << "a_{T}=" << ps.cutValues[icut]; // << " Meff=" << meff_bins[imeff] // << ", p_{T3}=" << pt3_bins[imeff]; mg2->Add(gr,"lp"); gr->SetTitle(TString(ss.str())); gr->SetLineColor(2+icut); gr->SetLineWidth(2); gr->SetMarkerStyle(20+icut); gr->SetMarkerColor(2+icut); gr->SetMarkerSize(1.5); } mg2->Draw("a"); mg2->GetYaxis()->SetRangeUser(1.e-6,1.e0); c2->Update(); c2->BuildLegend(0.81,0.1,0.99,0.9); // Save canvases c2->cd(); c2->SaveAs("RatioVsMeff.png"); c2->SaveAs("RatioVsMeff.pdf"); c2->SaveAs("RatioVsMeff.C"); } time_t stop = TTimeStamp().GetSec(); std::cout << " Time taken: " << stop - start << " seconds" << std::endl; }
void composeTrackAnalysisbyAssociator(string FileListName, int FileNumber) { if(debug) cout << FileListName << endl; string theFileName; ifstream composeFileList; composeFileList.open(FileListName.c_str()); string OutputPlotNamepreFix = FileListName + "_"; string OutputPlotNameFix = ".png"; unsigned int EventNumber; unsigned int trackingParticleMatch; double recTrackPurity; double recTrackrefMomentum; double recTrackrefPhi; double recTrackrefEta; double recTrackinnerMomentum; double recTrackinnerPhi; double recTrackinnerEta; unsigned int recTrackinnerValid; double recTrackouterMomentum; double recTrackouterPhi; double recTrackouterEta; unsigned int recTrackouterValid; double simTrackinnerMomentum; double simTrackinnerPhi; double simTrackinnerEta; unsigned int simTrackinnerMatch; double simTrackouterMomentum; double simTrackouterPhi; double simTrackouterEta; unsigned int simTrackouterMatch; double recTrackinnerMomentumofTSOS; double recTrackinnerPhiofTSOS; double recTrackinnerEtaofTSOS; unsigned int recTrackinnerValidofTSOS; double recTrackouterMomentumofTSOS; double recTrackouterPhiofTSOS; double recTrackouterEtaofTSOS; unsigned int recTrackouterValidofTSOS; double recTrackimpactMomentumofTSOS; double recTrackimpactPhiofTSOS; double recTrackimpactEtaofTSOS; unsigned int recTrackimpactValidofTSOS; int recTrackCharge; double simTrackMomentumPt; double simTrackPhi; double simTrackEta; int simTrackCharge; TObjArray* myEfficiencyHist = new TObjArray(); TObjArray* myParticleHist = new TObjArray(); TObjArray* mySTAHist = new TObjArray(); TObjArray* myChargeCheckHist = new TObjArray(); TObjArray* myDeltaPtHist = new TObjArray(); TObjArray* myDeltaPhiHist = new TObjArray(); TObjArray* myDeltaEtaHist = new TObjArray(); vector<string> TypeName; TypeName.clear(); for(int Index = 0; Index < FileNumber; Index++) { getline(composeFileList, theFileName); TypeName.push_back(theFileName); string fullFileName = "data/"+ theFileName + ".root"; if(debug) cout << theFileName << endl; TFile* RootFile = TFile::Open(fullFileName.c_str()); TTree* T1 = (TTree*)RootFile->Get("ExTree"); T1->SetBranchAddress("EventNumber", &EventNumber); T1->SetBranchAddress("trackingParticleMatch", &trackingParticleMatch); T1->SetBranchAddress("recTrackPurity", &recTrackPurity); T1->SetBranchAddress("recTrackrefMomentum", &recTrackrefMomentum); T1->SetBranchAddress("recTrackrefPhi", &recTrackrefPhi); T1->SetBranchAddress("recTrackrefEta", &recTrackrefEta); T1->SetBranchAddress("recTrackinnerMomentum", &recTrackinnerMomentum); T1->SetBranchAddress("recTrackinnerPhi", &recTrackinnerPhi); T1->SetBranchAddress("recTrackinnerEta", &recTrackinnerEta); T1->SetBranchAddress("recTrackinnerValid", &recTrackinnerValid); T1->SetBranchAddress("recTrackouterMomentum", &recTrackouterMomentum); T1->SetBranchAddress("recTrackouterPhi", &recTrackouterPhi); T1->SetBranchAddress("recTrackouterEta", &recTrackouterEta); T1->SetBranchAddress("recTrackouterValid", &recTrackouterValid); T1->SetBranchAddress("simTrackinnerMomentum", &simTrackinnerMomentum); T1->SetBranchAddress("simTrackinnerPhi", &simTrackinnerPhi); T1->SetBranchAddress("simTrackinnerEta", &simTrackinnerEta); T1->SetBranchAddress("simTrackinnerMatch", &simTrackinnerMatch); T1->SetBranchAddress("simTrackouterMomentum", &simTrackouterMomentum); T1->SetBranchAddress("simTrackouterPhi", &simTrackouterPhi); T1->SetBranchAddress("simTrackouterEta", &simTrackouterEta); T1->SetBranchAddress("simTrackouterMatch", &simTrackouterMatch); T1->SetBranchAddress("recTrackinnerMomentumofTSOS", &recTrackinnerMomentumofTSOS); T1->SetBranchAddress("recTrackinnerPhiofTSOS", &recTrackinnerPhiofTSOS); T1->SetBranchAddress("recTrackinnerEtaofTSOS", &recTrackinnerEtaofTSOS); T1->SetBranchAddress("recTrackinnerValidofTSOS", &recTrackinnerValidofTSOS); T1->SetBranchAddress("recTrackouterMomentumofTSOS", &recTrackouterMomentumofTSOS); T1->SetBranchAddress("recTrackouterPhiofTSOS", &recTrackouterPhiofTSOS); T1->SetBranchAddress("recTrackouterEtaofTSOS", &recTrackouterEtaofTSOS); T1->SetBranchAddress("recTrackouterValidofTSOS", &recTrackouterValidofTSOS); T1->SetBranchAddress("recTrackimpactMomentumofTSOS", &recTrackimpactMomentumofTSOS); T1->SetBranchAddress("recTrackimpactPhiofTSOS", &recTrackimpactPhiofTSOS); T1->SetBranchAddress("recTrackimpactEtaofTSOS", &recTrackimpactEtaofTSOS); T1->SetBranchAddress("recTrackimpactValidofTSOS", &recTrackimpactValidofTSOS); T1->SetBranchAddress("recTrackCharge", &recTrackCharge); T1->SetBranchAddress("simTrackMomentumPt", &simTrackMomentumPt); T1->SetBranchAddress("simTrackPhi", &simTrackPhi); T1->SetBranchAddress("simTrackEta", &simTrackEta); T1->SetBranchAddress("simTrackCharge", &simTrackCharge); string TempHistName; TempHistName = theFileName + "_Efficiency2simPt"; TH1D* Efficiency2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_Particle2simPt"; TH1D* Particle2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_STA2simPt"; TH1D* STA2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_InverseChargeRato2simPt"; TH1D* InverseChargeRato2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPt2simPt"; TH1D* DeltaPt2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPhi2simPt"; TH1D* DeltaPhi2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaEta2simPt"; TH1D* DeltaEta2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_MaxPurity2simPt"; TH2D* MaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 6, 0., 1.2); TempHistName = theFileName + "_Multiplicity2simPt"; TH2D* Multiplicity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 10, 0., 10.); TempHistName = theFileName + "_ChargeCheck2simPt"; TH2D* ChargeCheck2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 5, -2.5, 2.5); TempHistName = theFileName + "_simTrackMomentumPtmaxPurity2simPt"; TH2D* simTrackMomentumPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_simTrackPhimaxPurity2simPt"; TH2D* simTrackPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_simTrackEtamaxPurity2simPt"; TH2D* simTrackEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); TempHistName = theFileName + "_recTrackimpactMomentumofTSOSmaxPurity2simPt"; TH2D* recTrackimpactMomentumofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_recTrackimpactPhiofTSOSmaxPurity2simPt"; TH2D* recTrackimpactPhiofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_recTrackimpactEtaofTSOSmaxPurity2simPt"; TH2D* recTrackimpactEtaofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 600, -3.0, 3.0); TempHistName = theFileName + "_recTrackimpactValidofTSOSmaxPurity2simPt"; TH2D* recTrackimpactValidofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 2, 0., 2.); TempHistName = theFileName + "_DeltaPtmaxPurity2simPt"; TH2D* DeltaPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, -1.*PtScale, PtScale); TempHistName = theFileName + "_DeltaPhimaxPurity2simPt"; TH2D* DeltaPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_DeltaEtamaxPurity2simPt"; TH2D* DeltaEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); unsigned int trackingParticleMatch_temp; unsigned int efficiency_temp; double recTrackPurity_temp; double recTrackrefMomentum_temp; double recTrackrefPhi_temp; double recTrackrefEta_temp; double recTrackinnerMomentum_temp; double recTrackinnerPhi_temp; double recTrackinnerEta_temp; unsigned int recTrackinnerValid_temp; double recTrackouterMomentum_temp; double recTrackouterPhi_temp; double recTrackouterEta_temp; unsigned int recTrackouterValid_temp; double simTrackinnerMomentum_temp; double simTrackinnerPhi_temp; double simTrackinnerEta_temp; unsigned int simTrackinnerMatch_temp; double simTrackouterMomentum_temp; double simTrackouterPhi_temp; double simTrackouterEta_temp; unsigned int simTrackouterMatch_temp; double recTrackinnerMomentumofTSOS_temp; double recTrackinnerPhiofTSOS_temp; double recTrackinnerEtaofTSOS_temp; unsigned int recTrackinnerValidofTSOS_temp; double recTrackouterMomentumofTSOS_temp; double recTrackouterPhiofTSOS_temp; double recTrackouterEtaofTSOS_temp; unsigned int recTrackouterValidofTSOS_temp; double recTrackimpactMomentumofTSOS_temp; double recTrackimpactPhiofTSOS_temp; double recTrackimpactEtaofTSOS_temp; unsigned int recTrackimpactValidofTSOS_temp; int recTrackCharge_temp; double simTrackMomentumPt_temp; double simTrackPhi_temp; double simTrackEta_temp; int simTrackCharge_temp; int Nentries = T1->GetEntries(); for(int i = 0; i < Nentries; i++) { T1->GetEntry(i); if(trackingParticleMatch == 0) { MaxPurity2simPtHist->Fill(simTrackMomentumPt, 0); Multiplicity2simPtHist->Fill(simTrackMomentumPt, 0); int tempParticleBinNumber = Particle2simPtHist->FindBin(simTrackMomentumPt); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); } else { efficiency_temp = 1; trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; bool nextStep = true; while(nextStep) { i++; T1->GetEntry(i); if(trackingParticleMatch <= trackingParticleMatch_temp) nextStep = false; else trackingParticleMatch_temp = trackingParticleMatch; if(nextStep == true && recTrackPurity_temp < recTrackPurity) { if(debug) cout << "step another match, trackingParticleMatch_temp: " << trackingParticleMatch_temp << endl; //trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; } } i--; //if(debug) cout << "Filling Multiplicity " << trackingParticleMatch_temp << endl; MaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackPurity_temp); Multiplicity2simPtHist->Fill(simTrackMomentumPt_temp, trackingParticleMatch_temp); ChargeCheck2simPtHist->Fill(simTrackMomentumPt_temp, simTrackCharge_temp*recTrackCharge_temp); simTrackMomentumPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackMomentumPt_temp); simTrackPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackPhi_temp); simTrackEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackEta_temp); recTrackimpactMomentumofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactMomentumofTSOS_temp); recTrackimpactPhiofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp); recTrackimpactEtaofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp); recTrackimpactValidofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactValidofTSOS_temp); DeltaPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, (recTrackimpactMomentumofTSOS_temp-simTrackMomentumPt_temp)/simTrackMomentumPt_temp); DeltaPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp-simTrackPhi_temp); DeltaEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp-simTrackEta_temp); int tempParticleBinNumber = STA2simPtHist->FindBin(simTrackMomentumPt_temp); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); double tempSTABinValue = STA2simPtHist->GetBinContent(tempParticleBinNumber); tempSTABinValue += 1.; STA2simPtHist->SetBinContent(tempParticleBinNumber, tempSTABinValue); } } for(int PtIndex = 1; PtIndex <= (int)(PtScale/2); PtIndex++) { double ParticleBinValue = Particle2simPtHist->GetBinContent(PtIndex); double STABinValue = STA2simPtHist->GetBinContent(PtIndex); if(ParticleBinValue == 0.) ParticleBinValue += 1.; double EfficiencyBinValue = STABinValue / ParticleBinValue * 100.; double EfficiencyBinError = sqrt(EfficiencyBinValue * (100. - EfficiencyBinValue) / ParticleBinValue); cout << ParticleBinValue << ", " << STABinValue << ", " << EfficiencyBinValue << endl; Efficiency2simPtHist->SetBinContent(PtIndex, EfficiencyBinValue); Efficiency2simPtHist->SetBinError(PtIndex, EfficiencyBinError); TH1D* ChargeCheckHist = ChargeCheck2simPtHist->ProjectionY("ChargeCheck", PtIndex, PtIndex, "o"); double ReverseChargeBinValue = ChargeCheckHist->GetBinContent(2); double CoverseChargeBinValue = ChargeCheckHist->GetBinContent(4); double TotalChargeBinValue = ReverseChargeBinValue + CoverseChargeBinValue; if(TotalChargeBinValue == 0.); TotalChargeBinValue += 1.; double ReverseChargeRato = ReverseChargeBinValue / TotalChargeBinValue; InverseChargeRato2simPtHist->SetBinContent(PtIndex, ReverseChargeRato); TH1D* DeltaPtHist = DeltaPtmaxPurity2simPtHist->ProjectionY("DeltaPt", PtIndex, PtIndex, "o"); double DeltaPtMean = DeltaPtHist->GetMean(); double DeltaPtRMS = DeltaPtHist->GetRMS(); DeltaPt2simPtHist->SetBinContent(PtIndex, DeltaPtMean); DeltaPt2simPtHist->SetBinError(PtIndex, DeltaPtRMS); TH1D* DeltaPhiHist = DeltaPhimaxPurity2simPtHist->ProjectionY("DeltaPhi", PtIndex, PtIndex, "o"); double DeltaPhiMean = DeltaPhiHist->GetMean(); double DeltaPhiRMS = DeltaPhiHist->GetRMS(); DeltaPhi2simPtHist->SetBinContent(PtIndex, DeltaPhiMean); DeltaPhi2simPtHist->SetBinError(PtIndex, DeltaPhiRMS); TH1D* DeltaEtaHist = DeltaEtamaxPurity2simPtHist->ProjectionY("DeltaEta", PtIndex, PtIndex, "o"); double DeltaEtaMean = DeltaEtaHist->GetMean(); double DeltaEtaRMS = DeltaEtaHist->GetRMS(); DeltaEta2simPtHist->SetBinContent(PtIndex, DeltaEtaMean); DeltaEta2simPtHist->SetBinError(PtIndex, DeltaEtaRMS); } myEfficiencyHist->AddLast(Efficiency2simPtHist); myParticleHist->AddLast(Particle2simPtHist); mySTAHist->AddLast(STA2simPtHist); myChargeCheckHist->AddLast(InverseChargeRato2simPtHist); myDeltaPtHist->AddLast(DeltaPt2simPtHist); } double minX = 0; double minY = 0; double maxX = 110; double maxY = 40; TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600); myCanvas->cd(); TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1); myPad->Draw(); myPad->cd(); ((TH1D*)(myParticleHist->At(0)))->SetStats(0); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myParticleHist->At(0)))->Draw(); for(int Index = 0; Index < FileNumber; Index++) { ((TH1D*)(mySTAHist->At(Index)))->SetStats(0); ((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(mySTAHist->At(Index)))->Draw("same"); } TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3); STALeg->SetBorderSize(1); TString LegKey = "ParticleTrack"; STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf"); for(int Index = 0; Index < FileNumber; Index++) { LegKey = TypeName[Index]; STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf"); } STALeg->Draw(); string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); myPad->Clear(); myPad->Update(); double YScale = myPad->GetUymax() / 110.; ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah"); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah"); } myPad->Update(); if(debug) cout << "Y: " << myPad->GetUymax() << endl; double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin(); double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax(); int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins(); TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R"); YAxis->SetLineColor(kGreen); YAxis->SetLabelColor(kGreen); YAxis->SetTitle("Efficiency of STA for simPts"); YAxis->CenterTitle(1); YAxis->Draw(); double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin(); double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax(); int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins(); TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L"); XAxis->SetTitle("simPt/Gev"); XAxis->CenterTitle(1); XAxis->Draw(); TLegend *EffLeg = new TLegend(0.1,0.9,0.4,1.0); EffLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; EffLeg->AddEntry(myEfficiencyHist->At(Index), LegKey, "lpf"); } EffLeg->Draw(); string SaveName = OutputPlotNamepreFix + "_Eff2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); ((TH1D*)(myDeltaPtHist->At(0)))->SetStats(0); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->SetTitle("deltPt/simPt"); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myDeltaPtHist->At(0)))->Draw(""); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myDeltaPtHist->At(Index)))->SetStats(0); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->SetTitle("simPt/Gev"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->CenterTitle(1); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->SetTitle("deltPt/simPt"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myDeltaPtHist->At(Index)))->Draw("same"); //SaveName = OutputPlotNamepreFix + TypeName[Index] + "DeltaPt" + OutputPlotNameFix; //myCanvas->SaveAs(SaveName.c_str()); } TLegend *PtLeg = new TLegend(0.6,0.8,0.9,0.9); PtLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; PtLeg->AddEntry(myDeltaPtHist->At(Index), LegKey, "lpf"); } PtLeg->Draw(); SaveName = OutputPlotNamepreFix + "_DeltaPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); }
// ----------------------------------------------------------------------------- // void talk() { time_t start = TTimeStamp().GetSec(); bool draw = true; bool debug = true; // Binning int xbins = 100; int ybins = 100; double xmin = 0.0; double xmax = 1.0; double ymin = 0.0; double ymax = 1.0; double xbin_centre = ( ( xmax - xmin ) / xbins ) / 2.; double ybin_centre = ( ( ymax - ymin ) / ybins ) / 2.; // AlphaT values const int nat = 1; double at[nat]; for ( int ii = 0; ii < nat; ++ii ) { at[ii] = 0.55 + ii * 0.001; } // HT regions const int nht = 3; double ht_min[nht] = { 250., 300., 350. }; // Jet pT thresholds double pt1_min[nht] = { 71.4, 85.7, 100. }; double pt2_min[nht] = { 71.4, 85.7, 100. }; double pt3_min[nht] = { 35.7, 42.9., 50. }; // x fractions double x1_min[nht]; double x2_min[nht]; double x3_max[nht]; for ( int ii = 0; ii < nht; ++ii ) { x1_min[ii] = ( 2. * pt1_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } for ( int ii = 0; ii < nht; ++ii ) { x2_min[ii] = ( 2. * pt2_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } for ( int ii = 0; ii < nht; ++ii ) { x3_max[ii] = ( 2. * pt3_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } // Loop through bins int loop = 0; int nloops = nht; for ( int iht = 0; iht < nht; ++iht ) { std::cout << "Completed " << 100.*float(loop)/float(nloops) << "%..." << std::endl; loop++; // Labeling std::stringstream ss; ss << "HT" << int(ht_min[iht]); // New canvas for plots TCanvas* c1 = 0; if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" ); // Pad for cross-section plot TPad* pad = 0; if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.); if (pad) { pad->SetGrid(); pad->Draw(); pad->cd(); pad->SetLogz(); } TH1F* hr = 0; if (draw) hr = pad->DrawFrame(0.,0.,1.,1.); // Histo title if (hr) { std::stringstream sss; sss << "H_{T}=" << ht_min[iht] << "(p_{T1},p_{T2},p_{T3})=" << pt1_min[iht] << "," << pt2_min[iht] << "," << pt3_min[iht] << ")" << ", (x_{1},x_{2},x_{3})=" << x1_min[iht] << "," << x2_min[iht] << "," << x3_max[iht] << ")"; hr->SetTitle( sss.str().c_str() ); hr->GetXaxis()->SetTitle( "x_{2}" ); hr->GetYaxis()->SetTitle( "x_{1}" ); } // Create 2D cross-section plot TH2D* his = 0; if (draw) his = new TH2D(TString("Histo"+ss.str()),"", xbins,xmin,xmax, ybins,ymin,ymax); // Fill 2D cross-section plot for ( int xbin = 0; xbin < xbins; ++xbin ) { for ( int ybin = 0; ybin < ybins; ++ybin ) { double x2 = ( ( xmax - xmin ) / xbins ) * xbin + xmin; double x1 = ( ( ymax - ymin ) / ybins ) * ybin + ymin; double val = ( x1*x1 + x2*x2 ) / ( ( 1 - x1 ) * ( 1 - x2 ) ); if ( !constrain( x1, x2, x3 ) ) { continue; } if ( x1 < x1_cut[ix1] ) { continue; } double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) ); if (his) his->Fill( x2+xbin_centre, x1+ybin_centre, val ); } } // Draw 2D cross-section plot gStyle->SetPalette(1); if (his) { his->SetMaximum( his->GetMaximum() ); his->SetMinimum( his->GetMinimum(1.e-12) ); his->Draw("COLZsame"); } // Pad for AlphaT contours if (c1) c1->cd(); TPad* overlay = 0; if (draw) overlay = new TPad(TString("Overlay"+ss.str()),"",0.,0.,1.,1.); if (overlay) { overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); } TH1F* hframe = 0; if (draw) overlay->DrawFrame(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymax()); // Graphs of AlphaT contours TMultiGraph* mg = 0; if (draw) { mg = new TMultiGraph(); for ( Int_t iat = 0; iat < nat; iat++ ) { Double_t alpha_t = at[iat]; const Int_t n_ = 100; Double_t x1_[n_]; Double_t x2_[n_]; for ( Int_t j = 0; j < 100; j++ ) { x2_[j] = j*0.01; Double_t temp = ( x2_[j] - 2. * alpha_t * alpha_t ) / ( 2. * alpha_t ); x1_[j] = temp * temp + 1 - alpha_t * alpha_t; } TGraph* gr = new TGraph(n_,x2_,x1_); mg->Add(gr,"l"); } mg->Draw(); } if (c1) c1->cd(); if (c1) c1->SaveAs(TString(ss.str()+".png")); } }