void first() { TCanvas *nut = new TCanvas("nut", "FirstSession",100,10,700,900); nut->Range(0,0,20,24); nut->SetFillColor(10); nut->SetBorderSize(2); TPaveLabel *pl = new TPaveLabel(3,22,17,23.7, "My first ROOT interactive session","br"); pl->SetFillColor(18); pl->Draw(); TText t(0,0,"a"); t.SetTextFont(62); t.SetTextSize(0.025); t.SetTextAlign(12); t.DrawText(2,20.3,"ROOT is based on CINT, a powerful C/C++ interpreter."); t.DrawText(2,19.3,"Blocks of lines can be entered within {...}."); t.DrawText(2,18.3,"Previous typed lines can be recalled."); t.SetTextFont(72); t.SetTextSize(0.026); t.DrawText(3,17,"Root > float x=5; float y=7;"); t.DrawText(3,16,"Root > x*sqrt(y)"); t.DrawText(3,14, "Root > for (int i=2;i<7;i++) printf(\"sqrt(%d) = %f\\n\",i,sqrt(i));"); t.DrawText(3,10,"Root > TF1 f1(\"f1\",\"sin(x)/x\",0,10)"); t.DrawText(3, 9,"Root > f1.Draw()"); t.SetTextFont(81); t.SetTextSize(0.018); t.DrawText(4,15,"(float) 13.2288f"); t.DrawText(4,13.3,"sqrt(2) = 1.414214"); t.DrawText(4,12.7,"sqrt(3) = 1.732051"); t.DrawText(4,12.1,"sqrt(4) = 2.000000"); t.DrawText(4,11.5,"sqrt(5) = 2.236068"); t.DrawText(4,10.9,"sqrt(6) = 2.449490"); TPad *pad = new TPad("pad","pad",.2,.05,.8,.35); pad->Draw(); pad->cd(); pad->SetGrid(); TF1 *f1 = new TF1("f1","sin(x)/x",0,10); f1->Draw(); }
void DrawGrid() { Int_t ncol = 100; Int_t nrow = 200; TPad *grid = new TPad("grid","",0,0,1,1); grid->Draw(); grid->cd(); grid->SetGrid(); grid->SetFillStyle(4000); grid->SetFrameFillStyle(0); TH2 *hgrid = new TH2C("hgrid","", ncol+1, -5, ncol+5, nrow, -5, nrow-1+5); hgrid->Draw(); hgrid->GetXaxis()->SetNdivisions(6,100); hgrid->GetYaxis()->SetNdivisions(200); hgrid->GetYaxis()->SetLabelOffset(999.); hgrid->GetXaxis()->SetLabelOffset(999.); }
void GE11sEfficiencyPlots_3Sector_DividerCurrent() { // Input Files ifstream File1, File2, File3, File4; File1.open("EfficiencyData_R1592_R1646_Lat17_GE11_IV.txt"); File2.open("SWAPHV_EfficiencyData_R2065_R2123_Lat17_GE11_IV.txt"); File3.open("SWAP_EfficiencyData_R1868_R1906_Lat18_GE11_IV.txt"); File4.open("EfficiencyData_R1313_R1397_Lat17_GE11_IV_GIF.txt"); // Name of Detector const char* Detector1 = "#left(i#eta,i#phi#right)=#left(5,2#right); #sigma_{eff} #times 4"; const char* Detector2 = "#left(i#eta,i#phi#right)=#left(1,2#right); #sigma_{eff} #times 4"; const char* Detector3 = "#left(i#eta,i#phi#right)=#left(8,2#right); #sigma_{eff} #times 4"; const char* Detector4 = "#left(i#eta,i#phi#right)=#left(5,2#right); #sigma_{eff} #times 4"; const char* RunRange = "Threshold = 1.2 fC"; // 15 VFAT units"; const char* BeamType = "Beam: Muon"; const char* MSPL = ""; const char* Threshold = ""; const char* GasUsed = ""; const char* ClockMode = ""; const char* EtaPhiSector = ""; const char* CanvasName = "Efficiency_wrt_DividerCurrent"; const char* pdfFile = "EfficiencyPlot_wrt_DividerCurrent_wError4times_2gas.pdf"; const char* pngFile = "EfficiencyPlot_wrt_DividerCurrent_wError4times_2gas.png"; TFile *f = new TFile( "Efficiency_wrt_DividerCurrent_2gas_3Sector.root","RECREATE"); TGaxis::SetMaxDigits(3); //const char* GraphTitle = "Efficiency For Run Range 306 To 407: 2014H2B"; const char* GraphTitle = ""; // Set TDR Style setTDRStyle(); gStyle->SetOptFit(0); writeExtraText = true; // if extra text extraText = "#italic{Preliminary}"; // default extra text is "Preliminary" int iPeriod = 0; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV, 0=free form (uses lumi_sqrtS) TNtuple *NT_Detector1 = new TNtuple("EtaPhi52_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error"); TNtuple *NT_Detector2 = new TNtuple("EtaPhi12_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error"); TNtuple *NT_Detector3 = new TNtuple("EtaPhi82_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error"); TNtuple *NT_Detector4 = new TNtuple("EtaPhi52_ArCO2", "Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error"); Int_t nlines = 0; vector<double> NT_Detector1_HV,NT_Detector1_Eff,NT_Detector1_EffErr,NT_Detector2_HV,NT_Detector2_Eff,NT_Detector2_EffErr,NT_Detector3_HV,NT_Detector3_Eff,NT_Detector3_EffErr, NT_Detector1_Gain, NT_Detector2_Gain, NT_Detector3_Gain, NT_Detector4_Gain, NT_Detector4_HV,NT_Detector4_Eff,NT_Detector4_EffErr; double current, eff, efferr; while (1) { File1 >> current >> eff >> efferr; cout<<"1==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl; if (!File1.good()) break; NT_Detector1_HV.push_back(current); NT_Detector1_Eff.push_back(eff); NT_Detector1_EffErr.push_back(efferr); NT_Detector1->Fill(current,eff,efferr); nlines++; } while (1) { File2 >> current >> eff >> efferr; cout<<"2==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl; if (!File2.good()) break; NT_Detector2_HV.push_back(current); NT_Detector2_Eff.push_back(eff); NT_Detector2_EffErr.push_back(efferr); NT_Detector2->Fill(current,eff,efferr); nlines++; } while (1) { File3 >> current >> eff >> efferr; cout<<"3==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl; if (!File3.good()) break; NT_Detector3_HV.push_back(current); NT_Detector3_Eff.push_back(eff); NT_Detector3_EffErr.push_back(efferr); NT_Detector3->Fill(current,eff,efferr); nlines++; } while (1) { File4 >> current >> eff >> efferr; cout<<"4==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl; if (!File4.good()) break; NT_Detector4_HV.push_back(current); NT_Detector4_Eff.push_back(eff); NT_Detector4_EffErr.push_back(efferr); NT_Detector4->Fill(current,eff,efferr); nlines++; } File1.close(); File2.close(); File3.close(); File4.close(); TCanvas* c1 = new TCanvas("c1","",1); c1->Range(0,0,1,1); TPad *pad = new TPad("pad","",0,0,1,1); pad->SetGrid(); pad->Draw(); pad->cd(); TF1 *f1 = new TF1("f1","[0]+(0.989)/([1]+exp(-[2]*(x-697.3)))",650,815); TF1 *f2 = new TF1("f2","(0.968)/([1]+exp(-[2]*(x-713)))",650,815); TF1 *f3 = new TF1("f3","(0.973)/([1]+exp(-[2]*(x-725)))",650,820); TF1 *f4 = new TF1("f4","(0.985)/([1]+exp(-[2]*(x-614)))",565,720); // f3->SetParameters(1.,1.,1.); // create first graph TGraphErrors *gr1 = new TGraphErrors(NT_Detector1_HV.size()); for(unsigned int i=0;i<NT_Detector1_HV.size();i++) { gr1->SetPoint(i,NT_Detector1_HV[i],NT_Detector1_Eff[i]); gr1->SetPointError(i,0,4*NT_Detector1_EffErr[i]); } gr1->SetMarkerColor(kGreen+3); gr1->SetLineColor(kGreen+3); gr1->SetMarkerStyle(21); gr1->GetXaxis()->SetTitle("Current Supplied To HV Divider (#mu A)"); gr1->GetYaxis()->SetTitle("Efficiency"); gr1->SetTitle(GraphTitle); f1->SetLineColor(kGreen+3); gr1->Fit("f1","R"); // create first graph TGraphErrors *gr5 = new TGraphErrors(NT_Detector2_HV.size()); for(unsigned int i=0;i<NT_Detector2_HV.size();i++) { gr5->SetPoint(i,NT_Detector2_HV[i],NT_Detector2_Eff[i]); gr5->SetPointError(i,0,4*NT_Detector2_EffErr[i]); } gr5->SetMarkerColor(kBlack); gr5->SetLineColor(kBlack); gr5->SetMarkerStyle(22); gr5->GetXaxis()->SetTitle("Current Supplied To HV Divider (#mu A)"); gr5->GetYaxis()->SetTitle("Efficiency"); f2->SetLineColor(kBlack); gr5->Fit("f2","R"); // create first graph TGraphErrors *gr8 = new TGraphErrors(NT_Detector3_HV.size()); for(unsigned int i=0;i<NT_Detector3_HV.size();i++) { gr8->SetPoint(i,NT_Detector3_HV[i],NT_Detector3_Eff[i]); gr8->SetPointError(i,0,4*NT_Detector3_EffErr[i]); } gr8->SetMarkerColor(kBlue); gr8->SetLineColor(kBlue); gr8->SetMarkerStyle(24); gr8->GetXaxis()->SetTitle("Current Supplied To HV Divider (uA)"); gr8->GetYaxis()->SetTitle("Efficiency"); gr8->SetTitle(GraphTitle); f3->SetLineColor(kBlue); gr8->Fit("f3","R"); // create first graph TGraphErrors *gr9 = new TGraphErrors(NT_Detector4_HV.size()); for(unsigned int i=0;i<NT_Detector4_HV.size();i++) { gr9->SetPoint(i,NT_Detector4_HV[i],NT_Detector4_Eff[i]); gr9->SetPointError(i,0,4*NT_Detector4_EffErr[i]); } gr9->SetMarkerColor(kMagenta+2); gr9->SetLineColor(kMagenta+2); gr9->SetMarkerStyle(20); gr9->GetXaxis()->SetTitle("Current Supplied To HV Divider (uA)"); gr9->GetYaxis()->SetTitle("Efficiency"); f4->SetLineColor(kMagenta+2); gr9->Fit("f4","R"); TMultiGraph *mg = new TMultiGraph("mg",";Current Supplied to HV Divider (#mu A);Efficiency"); mg->Add(gr1); mg->Add(gr5); mg->Add(gr8); mg->Add(gr9); mg->SetMaximum(1.01); mg->SetMinimum(0.0); //mg->GetYaxis()->SetRangeUser(570.,820.); mg->Draw("AP"); mg->GetXaxis()->SetLimits(560,890); mg->GetYaxis()->SetDecimals(1); //Draw the Legend TLegend *leg = new TLegend(0.55,0.400,0.80,0.50); TLegend *leg2 = new TLegend(0.55,0.150,0.80,0.30); leg2->SetTextSize(0.05); leg2->SetTextFont(42); leg->SetTextSize(0.05); leg->SetTextFont(42); //leg->AddEntry(gr1,"(i#eta,i#phi)=(1,2)","LPE"); //leg->AddEntry(gr5,"(i#eta,i#phi)=(5,2)","LPE"); //leg->AddEntry(gr8,"(i#eta,i#phi)=(8.2)","LPE"); leg->AddEntry(gr9,Detector4,"PE"); leg2->AddEntry(gr5,Detector2,"PE"); leg2->AddEntry(gr1,Detector1,"PE"); leg2->AddEntry(gr8,Detector3,"PE"); leg->Draw("same"); leg2->Draw("same"); TLatex *text1 = new TLatex(750,0.74,RunRange); TLatex *text2 = new TLatex(750,0.66,BeamType); TLatex *text5 = new TLatex(750,0.58,"Gap Config: 3/1/2/1 mm"); TLatex *text3 = new TLatex(750,0.48,"Gas: Ar/CO2 (70/30)"); TLatex *text4 = new TLatex(750,0.28,"Gas: Ar/CO2/CF4 (45/15/40)"); // TLatex *text5 = new TLatex(81050,0.64,ClockMode); TLatex *text6 = new TLatex(3150,0.56,EtaPhiSector); TLatex *text7 = new TLatex(3250,0.48,GasUsed); text1->SetTextFont(42); text2->SetTextFont(42); text3->SetTextFont(42); text5->SetTextFont(42); //text3->SetTextAngle(50); //text4->SetTextAngle(50); // text3->SetTextColor(kMagenta); text4->SetTextFont(42); text1->SetTextSize(0.04); text2->SetTextSize(0.04); text3->SetTextSize(0.04); text4->SetTextSize(0.04); text5->SetTextSize(0.04); TLatex *cmsprem = new TLatex(560,1.015,"CMS #it{Preliminary}"); //TLatex *cmsprem = new TLatex(58.5,1.03,"#it{Preliminary}"); //TLatex *cmsprem = new TLatex(58.5,1.03,"CMS #it{Preliminary}"); TLatex *gen = new TLatex(855,1.015,"GE1/1"); // cmsprem->SetTextFont(42); // cmsprem->SetTextSize(0.05); // gen->SetTextFont(42); // gen->SetTextSize(0.05); // cmsprem->SetTextSize(0.04); text1->Draw("same"); text2->Draw("same"); text3->Draw("same"); text4->Draw("same"); text5->Draw("same"); text6->Draw("same"); text7->Draw("same"); cmsprem->Draw("same"); gen->Draw("same"); // //// CMS_lumi( c1, iPeriod, 0 ); // // Float_t rightmax = 1.1*gr1->GetMaximum(); //draw an axis on the right side // TGaxis *axis = new TGaxis(gPad->GetUxmin(),gPad->GetUymin(), // gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L"); // TGaxis *axis = new TGaxis(104,1.01,23211,1.01,3370,4252,15,"-"); // cout<<"GetUxmax = "<<gPad->GetUxmin()<<"\tGetUymin = "<<gPad->GetUxmax()<<endl; // cout<<"GetUxmax = "<<gPad->GetUymin()<<"\tGetUymin = "<<gPad->GetUymax()<<endl; // axis->SetTitle("V_Drift (volts)"); // // axis->SetTitleSize(2.5); // axis->SetTitleFont(42); // axis->SetTitleColor(1); // //axis->SetTitleFontSize(0.05); // axis->SetLineColor(kBlack); // axis->SetLabelColor(kBlack); // axis->Draw("sames"); c1->Update(); c1->SaveAs(pdfFile); c1->SaveAs(pngFile); //c1->SaveAs(); c1->Write(); f->Write(); }
// ----------------------------------------------------------------------------- // 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 probabilityDirection(){ int _vertex = 0; int _pdg[MAXN]; float _probability[MAXN]; float _chi2[MAXN]; int _generation[MAXN]; gStyle->SetCanvasPreferGL(kTRUE); TCanvas * c1 = new TCanvas("c1", "The 3d view",0,0,1000,500); gStyle->SetCanvasColor(kWhite); gStyle->SetPadColor(kWhite); TPad *boxPad = new TPad("box", "box", 0.02, 0.02, 0.48, 0.92); TPad *box1Pad = new TPad("box1", "box1", 0.52, 0.02, 0.98, 0.92); boxPad->Draw(); box1Pad->Draw(); int nbin = 40; TH1F * probhist = new TH1F("Phi","Phi",nbin,0,1.01 ); TH1F * probhist_non = new TH1F("Teta","Teta",nbin,0,1.01 ); probhist_non->Sumw2(); TH1F * chihist= new TH1F("PhiD","PhiD",40,0,30 ); TH1F * chihist_non = new TH1F("TetaD","TetaD",40,0,30 ); chihist_non->Sumw2(); TChain* T = new TChain("TaggedVertices"); T->Add("TrashRecoTest.root"); TChain* T2 = new TChain("Stats"); T2->Add("TrashMCTest.root"); int mTotalNumberOfEvents = T->GetEntries(); T->SetBranchAddress("numberOfTagged", &_vertex); T->SetBranchAddress("PDG", _pdg); T->SetBranchAddress("generation", _generation); T->SetBranchAddress("chi2", _chi2); T->SetBranchAddress("probability", _probability); int _btotalnumber = 0; int _bbartotalnumber = 0; int _bnumber = 0; int _bbarnumber = 0; float _bdistance = 0.0; float _bbardistance = 0.0; float _bIPdistance = 0.0; float _bbarIPdistance = 0.0; T2->SetBranchAddress("btotalnumber", &_btotalnumber); T2->SetBranchAddress("bbartotalnumber", &_bbartotalnumber); T2->SetBranchAddress("bnumber", &_bnumber); T2->SetBranchAddress("bbarnumber", &_bbarnumber); T2->SetBranchAddress("bdistance", &_bdistance); T2->SetBranchAddress("bbardistance", &_bbardistance); T2->SetBranchAddress("bIPdistance", &_bIPdistance); T2->SetBranchAddress("bbarIPdistance", &_bbarIPdistance); cout << "mTotalNumberOfEvents: " << mTotalNumberOfEvents << '\n'; int counter = 0; int totalcounter = 0; int num = 2; float distcut = .5; for (unsigned int i = 0; i < mTotalNumberOfEvents; i += 1) { T->GetEntry(i); T2->GetEntry(i); vector<int> bs; vector<int> bbars; for (int j = 0; j < _vertex; j++) { if (_pdg[j] == 5) { bs.push_back(j); } else//if (_pdg[j] == -5) { bbars.push_back(j); } } for (int k = 0; k < bbars.size(); k++) { /*if ( _bbarIPdistance < 0.50 || _bbartotalnumber > 5 || _bbartotalnumber < 3 || _bbarnumber < 2 || _bbartotalnumber - _bbarnumber < 2 ) { continue; }*/ if (bbars.size() > 1) { std::cout << "Nb: " << i << '\n'; probhist->Fill(_probability[bbars[k]]); chihist->Fill(_chi2[bbars[k]]); } else { probhist_non->Fill(_probability[bbars[0]]); chihist_non->Fill(_chi2[bbars[0]]); } } for (int m = 0; m < bs.size(); m++) { /*if ( _bIPdistance < 0.50 || _btotalnumber > 5 //|| _btotalnumber < 3 || _bnumber < 2 || _btotalnumber - _bnumber < 2 ) { continue; }*/ if (bs.size() > 1) { probhist->Fill(_probability[bs[m]]); chihist->Fill(_chi2[bs[m]]); } else { probhist_non->Fill(_probability[bs[0]]); chihist_non->Fill(_chi2[bs[0]]); } } if ( bbars.size() > 0) { totalcounter++; } if ( bs.size() > 0) { totalcounter++; } } boxPad->cd(); probhist_non->SetMarkerStyle(20); chihist_non->SetMarkerStyle(20); chihist_non->SetMarkerColor(kBlack); chihist_non->SetMarkerSize(0.7); chihist_non->GetXaxis()->SetTitle("#chi^2"); chihist->SetFillColor(kYellow); chihist->GetXaxis()->SetTitle("#chi^{2}"); probhist_non->SetMarkerColor(kBlack); probhist_non->SetMarkerSize(0.7); probhist_non->GetXaxis()->SetTitle("P(V)"); //probhist->GetYaxis()->SetRange(0,0.1); //probhist_non->GetYaxis()->SetRange(0,0.1); probhist->SetMaximum(2000); probhist_non->SetMaximum(2000); probhist_non->SetMinimum(0); probhist->SetMinimum(0); probhist->SetFillColor(kYellow); probhist->GetXaxis()->SetTitle("P(V)"); probhist->DrawNormalized("same"); probhist_non->DrawNormalized("ex0psame"); boxPad->SetGrid(); box1Pad->cd(); box1Pad->SetLogy(); chihist->DrawNormalized(""); chihist_non->DrawNormalized("ex0psame",1); box1Pad->SetGrid(); box1Pad->Modified(); boxPad->Modified(); std::cout << "Statistics: " << probhist->GetEntries() << " with ternary; " << probhist_non->GetEntries() << " without ternary; " << totalcounter << " total; " << counter << " discarded\n"; std::cout << "Mean: " << probhist->GetMean() << " with ternary; " << probhist_non->GetMean() << " without ternary;\n"; }
// ----------------------------------------------------------------------------- // 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")); } }
void plotFinal() { double yPos, xPos, theta, energy = 0.; // NOTE: theta comes in degrees int numHit, pID = 0; TFile* file = new TFile("complete.root"); TTree* Hits_Info = (TTree *)file->Get("Signal"); Hits_Info->SetBranchAddress("numHits", &numHit); Hits_Info->SetBranchAddress("energyTot", &energy); Hits_Info->SetBranchAddress("XPosition", &xPos); Hits_Info->SetBranchAddress("YPosition", &yPos); Hits_Info->SetBranchAddress("Particle_ID", &pID); Hits_Info->SetBranchAddress("Theta", &theta); // Initialize histograms double nEnergyMin = 10; // MeV double nEnergyMax = 510; // MeV int nEnergyBins = 50; double dEnergyBinSize = (double)(nEnergyMax - nEnergyMin) / (double)nEnergyBins; double nThetaMin = 52; // mrad double nThetaMax = 70; // mrad int nThetaBins = 50; double dThetaBinSize = (nThetaMax - nThetaMin) / nThetaBins; double nM2Min = -1000; // MeV double nM2Max = 1000; // MeV int nM2Bins = 100; double dM2BinSize = (nM2Max - nM2Min)/nM2Bins; TH1D* hgammaEnergy = new TH1D("Energy" , // plot label "Gamma Energy Distribution", // title nEnergyBins, // x number of bins nEnergyMin, // x lower bound nEnergyMax); // x upper bound TH1D* hgammaTheta = new TH1D("#theta" , // plot label "Gamma #theta Distribution", // title nThetaBins, // x number of bins nThetaMin, // x lower bound nThetaMax); // x upper bound TH1D* hm2 = new TH1D("M_{A'}^{2}" , // plot label "Missing Mass Squared", // title nM2Bins, // x number of bins nM2Min, // x lower bound nM2Max); // x upper bound TH2F* henergytheta = new TH2F("scatter", // plot label "#theta vs Energy", // title nThetaBins, // x num of bins nThetaMin, // x min nThetaMax, // x max nEnergyBins, // y num of bins nEnergyMin, // y min nEnergyMax); // y max // go through all entries and fill the histograms int nentries = Hits_Info->GetEntries(); for (int i=0; i<nentries; i++) { Hits_Info->GetEntry(i); if (pID == 22) { // gammas only theta*= TMath::Pi()/180; //radians hgammaEnergy->Fill(energy,BINNING_WEIGHT / dEnergyBinSize); hgammaTheta->Fill(theta*1000, BINNING_WEIGHT / dThetaBinSize); henergytheta->Fill(theta*1000, energy); hm2->Fill(mSquared(energy, theta), BINNING_WEIGHT / dM2BinSize); } } // create canvas and draw histogram TCanvas* canvas = new TCanvas("canvas", "canvas", 700, 700); canvas->Divide(3,2); TPad* p; p = (TPad*)canvas->cd(2); p->SetLogy(); p->SetGrid(); hgammaEnergy->SetFillColor(kBlue); hgammaEnergy->SetFillStyle(3001); hgammaEnergy->Draw(); hgammaEnergy->GetXaxis()->SetTitle("Energy (MeV)"); hgammaEnergy->GetYaxis()->SetTitle("Photons per MeV per Second (MeV^{-1} s^{-1})"); hgammaEnergy->GetXaxis()->CenterTitle(); hgammaEnergy->GetYaxis()->CenterTitle(); p = (TPad*)canvas->cd(5); p->SetLogy(); p->SetGrid(); hgammaTheta->SetFillColor(kBlue); hgammaTheta->SetFillStyle(3001); hgammaTheta->Draw(); hgammaTheta->GetXaxis()->SetTitle("#theta (mrad)"); hgammaTheta->GetXaxis()->CenterTitle(); hgammaTheta->GetYaxis()->SetTitle("Photons per mrad per Second (mrad^{-1} s^{-1})"); hgammaTheta->GetYaxis()->CenterTitle(); p = (TPad*)canvas->cd(1); p->SetGrid(); hm2->SetFillColor(kBlue); hm2->SetFillStyle(3001); hm2->GetXaxis()->SetTitle("M_{A'}^{2} (MeV^{2})"); hm2->GetYaxis()->SetTitle("Photons per MeV^{2} per Second (MeV^{-2} s^{-1})"); hm2->GetXaxis()->CenterTitle(); hm2->GetYaxis()->CenterTitle(); hm2->Draw(); p = (TPad*)canvas->cd(4); p->SetLogy(); p->SetGrid(); hm2->Draw(); p = (TPad*)canvas->cd(3); henergytheta->Draw(); henergytheta->GetYaxis()->SetTitle("Energy (MeV)"); henergytheta->GetXaxis()->SetTitle("#theta (mrad)"); henergytheta->GetXaxis()->CenterTitle(); henergytheta->GetYaxis()->CenterTitle(); }
void second() { TCanvas *nut = new TCanvas("nut", "Second Session",100,10,750,1000); nut->Range(0,0,20,24); nut->SetFillColor(18); TPaveLabel *pl = new TPaveLabel(3,22,17,23.7,"My second ROOT interactive session","br"); pl->SetFillColor(18); pl->Draw(); TText t(0,0,"a"); t.SetTextFont(62); t.SetTextSize(0.025); t.SetTextAlign(12); t.DrawText(2,21,"Very large C/C++ files can be interpreted (50,000 lines+)."); t.DrawText(2,20,"Functions in macros can reference other functions, etc."); t.DrawText(2,19,"Let's make a file \"graph.C\" with the following statements:"); TPaveText *macro = new TPaveText(2,11,18,18); macro->SetFillColor(10); macro->SetTextColor(kBlue); macro->SetBorderSize(6); macro->SetTextAlign(12); macro->SetTextFont(61); macro->AddText("{"); macro->AddText(" TCanvas *c1 = new TCanvas(\"c1\",\"A Simple Graph Example\",200,10,700,500);"); macro->AddText(" c1->Range(-0.5,-2,2.5,12);"); macro->AddText(" const Int_t n = 20"); macro->AddText(" Float_t x[n], y[n];"); macro->AddText(" for (Int_t i=0;i<n;i++) {"); macro->AddText(" x[i] = i*0.1;"); macro->AddText(" y[i] = 10*sin(x[i]+0.2);"); macro->AddText(" }"); macro->AddText(" gr = new TGraph(n,x,y);"); macro->AddText(" gr->Draw(\"AC*\");"); macro->AddText("}"); macro->AddText(" "); macro->Draw(); t.SetTextFont(72); t.SetTextColor(kRed); t.SetTextSize(0.026); t.DrawText(3,10,"Root > .x graph.C"); TPad *pad = new TPad("pad","pad",.15,.05,.85,.40); pad->SetFillColor(41); pad->SetFrameFillColor(33); pad->Draw(); pad->cd(); pad->SetGrid(); pad->Range(-0.5,-2,2.5,12); const Int_t n = 20; Float_t x[n], y[n]; for (Int_t i=0;i<n;i++) { x[i] = i*0.1; y[i] = 10*sin(x[i]+0.2); } gr = new TGraph(n,x,y); gr->Draw("AC*"); nut->cd(); }
void GE11sEfficiencyScan(int RunNumber, string RunName, string path) { ifstream InGE11_IV_GIF, InGE11_IV, InGE11_V; //string path = "/home/ramkrishna/TEMP/LogFiles_TB/LogFiles306To407"; string gif = path+"/Efficiency_LC1_"+std::to_string(RunNumber)+".log"; string IV = path+"/Efficiency_LC2_"+std::to_string(RunNumber)+".log"; string V = path+"/Efficiency_LC3_"+std::to_string(RunNumber)+".log"; cout<<"gif = "<<gif<<endl; InGE11_IV_GIF.open(gif); InGE11_IV.open(IV); InGE11_V.open(V); string rootFile = "Efficiency_Run"+std::to_string(RunNumber)+".root"; const char *CharrootFile = rootFile.c_str(); TFile *f = new TFile(CharrootFile,"RECREATE"); //TTree *tree = new TTree("Run306", "Detector info for Run 306"); TNtuple *GE11_IV_GIF = new TNtuple("GE11_IV_GIF","data from text file LC1","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); TNtuple *GE11_IV = new TNtuple("GE11_IV","data from text file LC2","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); TNtuple *GE11_V = new TNtuple("GE11_V","data from text file LC3","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); Int_t nlines = 0; vector<double> GIF_MeanPosOfSector, GIF_Efficiency, GIF_EfficiencyError; vector<unsigned int> GIF_Nevents; unsigned int temp_Nevents; double temp_MeanPosOfSector, temp_Efficiency, temp_EfficiencyError; vector<double> IV_MeanPosOfSector, IV_Efficiency, IV_EfficiencyError; vector<unsigned int> IV_Nevents; vector<double> V_MeanPosOfSector, V_Efficiency, V_EfficiencyError; vector<unsigned int> V_Nevents; string NameOfDet, xRange; while (1) { InGE11_IV_GIF >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_IV_GIF.good()) break; GIF_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); GIF_Efficiency.push_back(temp_Efficiency); GIF_EfficiencyError.push_back(temp_EfficiencyError); GIF_Nevents.push_back(temp_Nevents); GE11_IV_GIF->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; if (nlines > 20) { cout<<"Check the input text file for run number "<< RunNumber << endl; exit(EXIT_SUCCESS); } } InGE11_IV_GIF.close(); nlines=0; while (1) { InGE11_IV >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_IV.good()) break; IV_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); IV_Efficiency.push_back(temp_Efficiency); IV_EfficiencyError.push_back(temp_EfficiencyError); IV_Nevents.push_back(temp_Nevents); GE11_IV->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; } InGE11_IV.close(); nlines=0; while (1) { InGE11_V >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_V.good()) break; V_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); V_Efficiency.push_back(temp_Efficiency); V_EfficiencyError.push_back(temp_EfficiencyError); V_Nevents.push_back(temp_Nevents); GE11_V->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; } InGE11_V.close(); string CanvasName = "RunNumber"+std::to_string(RunNumber); const char * CharCanvasName = CanvasName.c_str(); TCanvas* c1 = new TCanvas(CharCanvasName,"Efficiency Scan Plot",200,10,700,500); TPad *pad = new TPad("pad","",0,0,1,1); //pad->SetFillColor(42); pad->SetGrid(); pad->Draw(); pad->cd(); // draw a frame to define the range TH1F *hr = pad->DrawFrame(0,-0.5,100,1.1); hr->SetXTitle("Detector Position (mm)"); hr->SetYTitle("Efficiency"); //pad->GetFrame()->SetFillColor(21); pad->GetFrame()->SetBorderSize(12); // create first graph TGraphErrors *gr_GIF = new TGraphErrors(V_Efficiency.size()); TGraphErrors *gr_IV = new TGraphErrors(V_Efficiency.size()); TGraphErrors *gr_V = new TGraphErrors(V_Efficiency.size()); for(unsigned int i=0;i<V_Efficiency.size();i++) { gr_GIF->SetPoint(i, GIF_MeanPosOfSector[i], GIF_Efficiency[i]); gr_GIF->SetPointError(i,0, GIF_EfficiencyError[i]); gr_IV->SetPoint(i, IV_MeanPosOfSector[i], IV_Efficiency[i]); gr_IV->SetPointError(i,0, IV_EfficiencyError[i]); gr_V->SetPoint(i, V_MeanPosOfSector[i], V_Efficiency[i]); gr_V->SetPointError(i,0, V_EfficiencyError[i]); } gr_GIF->SetMarkerColor(kBlue); gr_GIF->SetLineColor(kBlue); gr_GIF->SetMarkerStyle(21); gr_GIF->GetXaxis()->SetTitle("dist (mm)"); gr_GIF->GetYaxis()->SetTitle("Efficiency"); gr_GIF->GetYaxis()->SetRangeUser(0,1.2); gr_GIF->SetTitle("Efficiency Scan"); gr_GIF->Draw("ACP"); gr_IV->SetMarkerColor(kGreen-6); gr_IV->SetLineColor(kGreen); gr_IV->SetMarkerStyle(21); gr_IV->Draw("sameCP"); gr_V->SetMarkerColor(kBlack); gr_V->SetLineColor(kBlack); gr_V->SetMarkerStyle(21); gr_V->Draw("sameCP"); //create a transparent pad drawn on top of the main pad c1->cd(); TPad *overlay = new TPad("overlay","",0,0,1,1); overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); // create second graph //TGraphErrors* gr_GIF_Num = new TGraphErrors("data_noerror.dat","%lg %lg"); TGraphErrors *gr_GIF_Num = new TGraphErrors(GIF_Nevents.size()); TGraphErrors *gr_IV_Num = new TGraphErrors(IV_Nevents.size()); TGraphErrors *gr_V_Num = new TGraphErrors(V_Nevents.size()); for(unsigned int i=0;i<V_MeanPosOfSector.size();i++) { gr_GIF_Num->SetPoint(i,GIF_MeanPosOfSector[i],GIF_Nevents[i]); gr_IV_Num->SetPoint(i,IV_MeanPosOfSector[i],IV_Nevents[i]); gr_V_Num->SetPoint(i,V_MeanPosOfSector[i],V_Nevents[i]); } gr_GIF_Num->SetMarkerColor(kBlue); gr_GIF_Num->SetLineColor(kBlue); gr_GIF_Num->SetLineStyle(2); gr_GIF_Num->SetLineWidth(3); gr_GIF_Num->SetMarkerStyle(22); gr_GIF_Num->SetName("gr_GIF_Num"); gr_IV_Num->SetMarkerColor(kGreen-6); gr_IV_Num->SetLineColor(kGreen); gr_IV_Num->SetMarkerStyle(22); gr_IV_Num->SetLineStyle(2); gr_IV_Num->SetLineWidth(3); gr_IV_Num->SetName("gr_IV_Num"); gr_V_Num->SetMarkerColor(kBlack); gr_V_Num->SetLineColor(kBlack); gr_V_Num->SetMarkerStyle(22); gr_V_Num->SetLineStyle(2); gr_V_Num->SetLineWidth(3); gr_V_Num->SetName("gr_V_Num"); Double_t xmin = pad->GetUxmin(); Double_t ymin = 0; Double_t xmax = pad->GetUxmax(); Double_t ymax = 1550; TH1F *hframe = overlay->DrawFrame(xmin,ymin,xmax,ymax); hframe->GetXaxis()->SetLabelOffset(99); hframe->GetYaxis()->SetLabelOffset(99); hframe->Draw("Y+"); gr_GIF_Num->Draw("CPY+"); gr_IV_Num->Draw("CPY+"); gr_V_Num->Draw("CPY+"); //Draw the Legend TLegend *leg = new TLegend(0.10,0.732,0.40,0.90); leg->AddEntry(gr_GIF,"GE11_IV_GIF eff","LPE"); leg->AddEntry(gr_IV,"GE11_IV eff","LPE"); leg->AddEntry(gr_V,"GE11_V eff","LPE"); leg->AddEntry(gr_GIF_Num,"No of events_GE11_IV_GIF","LPE"); leg->AddEntry(gr_IV_Num,"No of events_GE11_IV","LPE"); leg->AddEntry(gr_V_Num,"No of events_GE11_V","LPE"); leg->Draw("same"); const char *runnum = RunName.c_str(); TLatex *t2a = new TLatex(0.00,0.94, runnum ); t2a->SetNDC(); t2a->SetTextFont(42); t2a->SetTextSize(0.033); t2a->SetTextAlign(13); t2a->Draw("same"); //Draw an axis on the right side TGaxis *axis = new TGaxis(xmax,ymin,xmax, ymax,ymin,ymax,510,"+L"); axis->SetLineColor(kRed); axis->SetLabelColor(kRed); axis->SetTitle("Approx. No. of Events"); axis->Draw(); string OutputFileName = "GE11_Efficiency_Scan_"+std::to_string(RunNumber)+".pdf"; const char *CharOutputFileName = OutputFileName.c_str(); c1->SaveAs(CharOutputFileName); c1->Write(); //tree->Write(); //tree->Write("", TObject::kOverwrite); f->Write(); }
// ----------------------------------------------------------------------------- // void rob() { // Binning int xbins = 100; int ybins = 100; double xmax = 1.0; double xmin = 0.0; // double xrange = xmax - xmin; // xmax += xrange / xbins / 2; // xmin -= xrange / xbins / 2; // //xbins++; double ymax = 1.0; double ymin = 0.0; // double yrange = ymax - ymin; // ymax += yrange / ybins / 2; // ymin -= yrange / ybins / 2; // //ybins++; std::cout << " Binning: " << " xbins: " << xbins << " ybins: " << xbins << " xmin: " << xmin << " xmax: " << xmax << " ymin: " << ymin << " ymax: " << ymax << std::endl; // Examples values of pt1, pt2, mht, x1, x2, x3, sigma and alpha_t // double pt1 = 50.; // double pt2 = 50.; // double mht = 50.; // double x1 = ( 2. * pt1 ) / ( pt1 + pt2 + mht ); // double x2 = ( 2. * pt2 ) / ( pt1 + pt2 + mht ); // double x3 = 2 - x1 - x2; // double sigma = ( x1*x1 + x2*x2 ) / ( (1-x1) * (1-x2) ); // double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) ); // std::cout << " pt1: " << pt1 // << " pt2: " << pt2 // << " mht: " << mht // << " x1: " << x1 // << " x2: " << x2 // << " x3: " << x3 // << " sigma: " << sigma // << " alpha_t: " << alpha_t // << std::endl; // Cross section TCanvas* c1 = new TCanvas( "Contours", "" ); //c1->SetGridx(1); //c1->SetGridy(1); TPad* pad = new TPad("pad","",0.,0.,1.,1.); pad->SetGrid(); pad->Draw(); pad->cd(); pad->SetLogz(1); TH1F* hr = pad->DrawFrame(0.,0.,1.,1.); const int nx = 3; const int ny = 10; double pt[nx] = { 30., 50., 100. }; double ht[ny]; for ( int ii = 0; ii < ny; ++ii ) { ht[ii] = 150. + ii * 50.; } double ratio[nx][ny]; double xbin_centre = ( ( xmax - xmin ) / xbins ) / 2.; double ybin_centre = ( ( ymax - ymin ) / ybins ) / 2.; TH2D* his = new TH2D("Contours","",xbins,xmin,xmax,ybins,ymin,ymax); for ( int ii = 0; ii < nx; ++ii ) { for ( int jj = 0; jj < ny; ++jj ) { double x3 = ( 2. * pt[ii] ) / ( ht[jj] + pt[ii] ); double n = 0.; double d = 0.; 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 ( x1 < x2 || // jet ordering by Pt x1 + x2 > 2. || // from relation "x1 + x2 + x3 = 2" x1 > 1.0 || // from "lost jet" and relation "xmiss = -x1 -x2" x1 + x2 < 1. // from "lost jet" and relation "xmiss = -x1 -x2" ) { continue; } if ( ( x1 + x2 ) < ( 2 - x3 ) ) { continue; } d += val; double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) ); if ( alpha_t > 0.5 ) n+= val; if ( ii == 2 && jj == 9 ) { his->Fill( x2+xbin_centre, x1+ybin_centre, val ); } } } double r = 0.; if ( d > 0. ) { r = n/d; } ratio[ii][jj] = r; std::cout << " Pt: " << pt[ii] << " ht: " << ht[jj] << " x3: " << x3 << " r: " << r << " n: " << n << " d: " << d << std::endl; } } gStyle->SetPalette(1); his->SetMaximum( his->GetMaximum() ); his->SetMinimum( his->GetMinimum(1.e-12) ); his->Draw("COLZsame"); // c1->cd(); // TPad* overlay = new TPad("overlay","",0.,0.,1.,1.); // overlay->SetFillStyle(4000); // overlay->SetFillColor(0); // overlay->SetFrameFillStyle(4000); // overlay->Draw(); // overlay->cd(); // Double_t pxmin = pad->GetUxmin(); // Double_t pymin = pad->GetUymin(); // Double_t pxmax = pad->GetUxmax(); // Double_t pymax = pad->GetUymax(); // TH1F* hframe = overlay->DrawFrame(pxmin,pymin,pxmax,pymax); // TMultiGraph* mg = new TMultiGraph(); // for ( Int_t i = 0; i < 10; i++ ) { // Double_t alpha_t = 0.5 + i*0.01; // 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(); // TCanvas* c2 = new TCanvas( "Contours1", "" ); // c2->cd(); // TMultiGraph* mg2 = new TMultiGraph(); // for ( Int_t ii = 0; ii < 3; ii++ ) { // TGraph* gr = new TGraph(ny,ht,ratio[ii]); // mg2->Add(gr,"l"); // } // mg2->Draw("a"); // c1->cd(); // c1->SaveAs("c1.png"); // c2->cd(); // c2->SaveAs("c2.png"); }