//________________________________________________________ void GFHistManager::ColourStatsBoxes(GFHistArray *hists) const { // colours stats boxes like hists' line colors and moves the next to each other if (!hists) return; Double_t x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2; for (Int_t iH = 0; iH < hists->GetEntriesFast(); ++iH) { TH1 *h = hists->At(iH); if (!h) continue; TObject *statObj = h->GetListOfFunctions()->FindObject("stats"); if (statObj && statObj->InheritsFrom(TPaveStats::Class())) { TPaveStats *stats = static_cast<TPaveStats*>(statObj); stats->SetLineColor(hists->At(iH)->GetLineColor()); stats->SetTextColor(hists->At(iH)->GetLineColor()); stats->SetX1NDC(x1); stats->SetX2NDC(x2); stats->SetY1NDC(y1); stats->SetY2NDC(y2); y2 = y1 - 0.005; // shift down 2 y1 = y2 - (fStatsY2 - fStatsY1); // shift down 1 if (y1 < 0.) { y1 = fStatsY1; y2 = fStatsY2; // restart y-positions x2 = x1 - 0.005; // shift left 2 x1 = x2 - (fStatsX2 - fStatsX1); // shift left 1 if (x1 < 0.) { // give up, start again: x1 = fStatsX1, x2 = fStatsX2, y1 = fStatsY1, y2 = fStatsY2; } } } else if (gStyle->GetOptStat() != 0) { // failure in case changed in list via TExec.... this->Warning("ColourStatsBoxes", "No stats found for %s", hists->At(iH)->GetName()); } } }
// Resize any histograms (they all inherit from h1) stat box. Uses NDC coordinates (e.g. 0.65, 0.5) bool resizeStatBox( TCanvas *c1, TH1* h1, float x1, float y1, float x2=-1, float y2=-1, TString newname = "", int color = -1, TString oldname = "", int iDebug = 0 ) { if( !c1 || !h1 ) {cerr<<"Null pointer given to resizeStatBox!"<<endl; return 0;} c1->Update(); if( oldname.Length() <= 0 ) oldname = "stats"; if( iDebug > 20 ) print_list_of_functions( *h1 ); TPaveStats *stats = (TPaveStats*) h1->FindObject( oldname ); if( iDebug ) cout<<"Found old name (\""<<oldname<<"\"? "<<( stats != 0 )<<endl; if( (!stats) && newname.Length() > 0 ){ // maybe it was already renamed stats = (TPaveStats*) h1->FindObject( newname ); if( iDebug ) cout<<"Found new name (\""<<newname<<"\"? "<<(stats != 0)<<endl; } if( !stats ) {cerr<<"Can't find stat box"<<endl; return 0;} stats->SetX1NDC( x1 ); stats->SetY1NDC( y1 ); if( x2 >= 0 ) stats->SetX2NDC( x2 ); if( y2 >= 0 ) stats->SetY2NDC( y2 ); if( newname.Length() > 0 ) { stats->SetName( newname ); if( iDebug ) cout<<"SetName to "<<newname<<endl; } if( color != -1 ) stats->SetTextColor (color); stats->Draw(); // maybe, just maybe, this will finally make them appear every time, even with draw "same" return 1; }
// überladen: Statbox-Größen manuell eingeben void drawStatBox(int& step, TH1D* histo, int color = -1, double statboxHeight = 0.1, double statboxSpacing = 0.15){ TPaveStats* statBox = dynamic_cast<TPaveStats*>( histo->GetListOfFunctions()->FindObject("stats") ); if(color == -1) color = step+1; statBox->SetX1NDC(0.80); statBox->SetX2NDC(0.99); statBox->SetY2NDC(0.95-step*statboxSpacing); statBox->SetY1NDC(0.95-step*statboxSpacing-statboxHeight); statBox->SetTextColor(color); statBox->Draw(); step++; }
TPaveStats* SetStPadPos(TH1* hst,float x1,float x2,float y1,float y2, Int_t stl, Int_t col) { TPaveStats* pad = GetStPad(hst); if (!pad) return 0; pad->SetX1NDC( x1 ); pad->SetX2NDC( x2 ); pad->SetY1NDC( y1 ); pad->SetY2NDC( y2 ); if (stl>=0) pad->SetFillStyle(stl); if (col>=0) pad->SetTextColor(col); pad->SetFillColor(0); // gPad->Modified(); return pad; }
//------------------------------------------------------------------------------ void PlotAlignmentValidation::plotSubDetResiduals(bool plotNormHisto,unsigned int subDetId) { setNiceStyle(); gStyle->SetOptStat(11111); gStyle->SetOptFit(0000); TCanvas *c = new TCanvas("c", "c", 600,600); c->SetTopMargin(0.15); TString histoName= ""; if (plotNormHisto) {histoName= "h_NormXprime";} else histoName= "h_Xprime_"; switch (subDetId){ case 1 : histoName+="TPBBarrel_0";break; case 2 : histoName+="TPEendcap_1";break; case 3 : histoName+="TPEendcap_2";break; case 4 : histoName+="TIBBarrel_0";break; case 5 : histoName+="TIDEndcap_1";break; case 6 : histoName+="TIDEndcap_2";break; case 7 : histoName+="TOBBarrel_3";break; case 8 : histoName+="TECEndcap_4";break; case 9 : histoName+="TECEndcap_5";break; } int tmpcounter = 0; TH1 *sumHisto = 0; for(std::vector<TkOfflineVariables*>::iterator it = sourceList.begin(); it != sourceList.end(); ++it) { if (tmpcounter == 0 ) { TFile *f= (*it)->getFile(); sumHisto =(TH1*) f->FindKeyAny(histoName)->ReadObj();//FindObjectAny(histoName.Data()); sumHisto->SetLineColor(tmpcounter+1); sumHisto->SetLineStyle(tmpcounter+1); sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw); sumHisto->Draw(); //get statistic box coordinate to plot all boxes one below the other //gStyle->SetStatY(0.91); //gStyle->SetStatW(0.15); //gStyle->SetStatBorderSize(1); //gStyle->SetStatH(0.10); tmpcounter++; } else { sumHisto = (TH1*) (*it)->getFile()->FindObjectAny(histoName); sumHisto->SetLineColor(tmpcounter+1); sumHisto->SetLineStyle(tmpcounter+1); sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw); //hstack->Add(sumHisto); c->Update(); tmpcounter++; } TObject *statObj = sumHisto->GetListOfFunctions()->FindObject("stats"); if (statObj && statObj->InheritsFrom(TPaveStats::Class())) { TPaveStats *stats = static_cast<TPaveStats*>(statObj); stats->SetLineColor(tmpcounter+1); stats->SetTextColor(tmpcounter+1); stats->SetFillColor(10); stats->SetX1NDC(0.91-tmpcounter*0.1); stats->SetX2NDC(0.15); stats->SetY1NDC(1); stats->SetY2NDC(0.10); sumHisto->Draw("sames"); } } //hstack->Draw("nostack"); char PlotName[1000]; sprintf( PlotName, "%s/%s.eps", outputDir.c_str(), histoName.Data() ); c->Print(PlotName); //delete c; //c=0; }
void CompHist(TH1 *h1, TH1 *href, int run1, int runref) { if (!h1 || !href || h1->Integral()==0 || href->Integral()==0) return; // first check if both histograms are compatible Stat_t s[TH1F::kNstat]; h1->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights Double_t sumBinContent1 = s[0]; Double_t effEntries1 = (s[1] ? s[0] * s[0] / s[1] : 0.0); href->GetStats(s);// s[1] sum of squares of weights, s[0] sum of weights Double_t sumBinContent2 = s[0]; Double_t effEntries2 = (s[1] ? s[0] * s[0] / s[1] : 0.0); float pval_chi2=1, pval_ks=1,pval_ad=1; bool iswt = (sumBinContent1==0 || effEntries1==0 || sumBinContent2==0 || effEntries2==0 || TMath::Abs(sumBinContent1 - effEntries1) != 0 || TMath::Abs(sumBinContent2 - effEntries2) != 0); if (iswt) { // weighted histograms pval_chi2 = h1->Chi2Test(href,"WW"); // pval_ks = h1->KolmogorovTest(href); } else { // unweighted histograms pval_ks = h1->KolmogorovTest(href); pval_ad = h1->AndersonDarlingTest(href); // double int1 = h1->Integral(); // double intref = href->Integral(); // if (int1==0 || intref==0) return; // h1->Scale(1./int1); // href->Scale(1./intref); // pval_chi2 = h1->Chi2Test(href,"NORM UU"); } if (pval_chi2>minpval && pval_ks>minpval) return; // looks like we have a discrepancy! let's plot the histograms and print the output cout << h1->GetTitle() << ": p-val(chi2) = " << pval_chi2 << ", p-val(KS) = " << pval_ks << ", pval_ad = " << pval_ad << endl; TCanvas *c1 = new TCanvas(); href->SetLineColor(kRed); href->SetMarkerColor(kRed); if (!iswt) href->DrawNormalized(); else href->Draw(); c1->Update(); // Retrieve the stat box TPaveStats *ps = (TPaveStats*)c1->GetPrimitive("stats"); ps->SetName("statsref"); ps->SetTextColor(kRed); ps->SetX1NDC(0.8); ps->SetX2NDC(1.); ps->SetY1NDC(0.6); ps->SetY2NDC(0.8); h1->SetLineColor(kBlack); h1->SetMarkerColor(kBlack); if (!iswt) h1->DrawNormalized("sames"); else h1->Draw("sames"); c1->Update(); TPaveStats *psref = (TPaveStats*)c1->GetPrimitive("stats"); psref->SetName("stats1"); psref->SetX1NDC(0.8); psref->SetX2NDC(1.); psref->SetY1NDC(0.8); psref->SetY2NDC(1.); c1->Modified(); c1->Update(); TLatex *txt = new TLatex(); if (!iswt) txt->DrawLatexNDC(0.02,0.02,Form("p(KS) = %f, p(AD) = %f",pval_ks,pval_ad)); else txt->DrawLatexNDC(0.02,0.02,Form("p(#chi^{2}) = %f",pval_chi2)); c1->SaveAs(Form("%s_%i_%i.png",h1->GetName(),run1,runref)); delete c1; }
void FitDijetMass_Data() { TFile *inf = new TFile("MassResults_ak7calo.root"); TH1F *hCorMassDen = (TH1F*) inf->Get("DiJetMass"); hCorMassDen->SetXTitle("Corrected Dijet Mass (GeV)"); hCorMassDen->SetYTitle("Events/GeV"); hCorMassDen->GetYaxis()->SetTitleOffset(1.5); hCorMassDen->SetMarkerStyle(20); hCorMassDen->GetXaxis()->SetRangeUser(120.,900.); gROOT->ProcessLine(".L tdrstyle.C"); setTDRStyle(); tdrStyle->SetErrorX(0.5); tdrStyle->SetPadRightMargin(0.08); tdrStyle->SetLegendBorderSize(0); gStyle->SetOptFit(1111); tdrStyle->SetOptStat(0); TCanvas* c2 = new TCanvas("c2","DijetMass", 500, 500); /////// perform 4 parameters fit TF1 *func = new TF1("func", "[0]*((1-x/7000.+[3]*(x/7000)^2)^[1])/(x^[2])", 100., 1000.); func->SetParameter(0, 1.0e+08); func->SetParameter(1, -1.23); func->SetParameter(2, 4.13); func->SetParameter(3, 1.0); func->SetLineColor(4); func->SetLineWidth(3); TVirtualFitter::SetMaxIterations( 10000 ); TVirtualFitter *fitter; TMatrixDSym* cov_matrix; int fitStatus = hCorMassDen->Fit("func","LLI","",130.0, 800.0); // QCD fit TH1F *hFitUncertainty = hCorMassDen->Clone("hFitUncertainty"); hFitUncertainty->SetLineColor(5); hFitUncertainty->SetFillColor(5); hFitUncertainty->SetMarkerColor(5); if (fitStatus == 0) { fitter = TVirtualFitter::GetFitter(); double* m_elements = fitter->GetCovarianceMatrix(); cov_matrix = new TMatrixDSym( func->GetNumberFreeParameters(),m_elements); cov_matrix->Print(); double x, y, e; for(int i=0;i<hFitUncertainty->GetNbinsX();i++) { x = hFitUncertainty->GetBinCenter(i+1); y = func->Eval(x); e = QCDFitUncertainty( func, *cov_matrix, x); hFitUncertainty->SetBinContent(i+1,y); hFitUncertainty->SetBinError(i+1,e); } } hCorMassDen->Draw("ep"); gPad->Update(); TPaveStats *st = (TPaveStats*)hCorMassDen->FindObject("stats"); st->SetName("stats1"); st->SetX1NDC(0.3); //new x start position st->SetX2NDC(0.6); //new x end position st->SetTextColor(4); hCorMassDen->GetListOfFunctions()->Add(st); /////// perform 2 parameters fit TF1 *func2 = new TF1("func2", "[0]*(1-x/7000.)/(x^[1])", 100., 1000.); func2->SetParameter(0, 10000.); func2->SetParameter(1, 5.0); func2->SetLineWidth(3); fitStatus = hCorMassDen->Fit("func2","LLI","",130.0, 800.0); // QCD fit TH1F *hFitUncertainty2 = hCorMassDen->Clone("hFitUncertainty2"); hFitUncertainty2->SetLineColor(kGray); hFitUncertainty2->SetFillColor(kGray); hFitUncertainty2->SetMarkerColor(kGray); if (fitStatus == 0) { fitter = TVirtualFitter::GetFitter(); double* m_elements = fitter->GetCovarianceMatrix(); cov_matrix = new TMatrixDSym( func2->GetNumberFreeParameters(),m_elements); cov_matrix->Print(); double x, y, e; for(int i=0;i<hFitUncertainty2->GetNbinsX();i++) { x = hFitUncertainty2->GetBinCenter(i+1); y = func2->Eval(x); e = QCDFitUncertainty( func2, *cov_matrix, x); hFitUncertainty2->SetBinContent(i+1,y); hFitUncertainty2->SetBinError(i+1,e); } } hFitUncertainty->Draw("E3 same"); hCorMassDen->Draw("ep sames"); hFitUncertainty2->Draw("E3 same"); hCorMassDen->Draw("ep sames"); func2->Draw("same"); c2->SetLogy(1); /* TH1F *hCorMass = hCorMassDen->Clone("hCorMass"); for(int i=0; i<hCorMass->GetNbinsX(); i++){ hCorMass->SetBinContent(i+1, hCorMassDen->GetBinContent(i+1) * hCorMassDen->GetBinWidth(i+1)); hCorMass->SetBinError(i+1, hCorMassDen->GetBinError(i+1) * hCorMassDen->GetBinWidth(i+1)); } // Our observable is the invariant mass RooRealVar invMass("invMass", "Corrected dijet mass", 100., 1000.0, "GeV"); RooDataHist data( "data", "", invMass, hCorMass); ////////////////////////////////////////////// // make QCD model RooRealVar p0("p0", "# events", 600.0, 0.0, 10000000000.); RooRealVar p1("p1","p1", 3.975, -10., 10.) ; RooRealVar p2("p2","p2", 5.302, 4., 8.) ; RooRealVar p3("p3","p3", -1.51, -100., 100.) ; // // define QCD line shape RooGenericPdf qcdModel("qcdModel", "pow(1-@0/7000.+@3*(@0/7000.)*(@0/7000.),@1)*pow(@0/7000.,-@2)", RooArgList(invMass,p1,p2,p3)); // full model RooAddPdf model("model","qcd",RooArgList(qcdModel), RooArgList(p0)); //plot sig candidates, full model, and individual componenets // __ _ _ // / _(_) |_ // | |_| | __| // | _| | |_ // |_| |_|\__| // Important: fit integrating f(x) over ranges defined by X errors, rather // than taking point at center of bin RooFitResult* fit = model.fitTo(data, Minos(kFALSE), Extended(kTRUE), SumW2Error(kFALSE),Save(kTRUE), Range(130.,800.), Integrate(kTRUE) ); // to perform chi^2 minimization fit instead // RooFitResult* fit = model.chi2FitTo(data, Extended(kTRUE), // Save(),Range(50.,526.),Integrate(kTRUE) ); fit->Print(); //plot data TCanvas* cdataNull = new TCanvas("cdataNull","fit to dijet mass",500,500); RooPlot* frame1 = invMass.frame() ; data.plotOn(frame1, DataError(RooAbsData::SumW2) ) ; model.plotOn(frame1, LineColor(kBlue)) ; model.plotOn(frame1, VisualizeError(*fit, 1),FillColor(kYellow)) ; data.plotOn(frame1, DataError(RooAbsData::SumW2) ) ; model.plotOn(frame1, LineColor(kBlue)) ; model.paramOn(frame1, Layout(0.4, 0.85, 0.92)); TPaveText* dataPave = (TPaveText*) frame1->findObject("model_paramBox"); dataPave->SetY1(0.77); gPad->SetLogy(); frame1->GetYaxis()->SetNoExponent(); frame1->GetYaxis()->SetRangeUser(5E-2,5E+4); frame1->GetYaxis()->SetTitle("Events / bin"); frame1->GetYaxis()->SetTitleOffset(1.35); frame1->SetTitle("fit to data with QCD lineshape"); frame1->Draw() ; // S h o w r e s i d u a l a n d p u l l d i s t s // ------------------------------------------------------- //// Construct a histogram with the residuals of the data w.r.t. the curve RooHist* hresid = frame1->residHist() ; // Create a new frame to draw the residual distribution and add the distribution to the frame RooPlot* frame2 = invMass.frame(Title("Residual Distribution")) ; frame2->addPlotable(hresid,"P") ; ///// Construct a histogram with the pulls of the data w.r.t the curve RooHist* hpull = frame1->pullHist() ; //// Create a new frame to draw the pull distribution and add the distribution to the frame RooPlot* frame3 = invMass.frame(Title("Pull Distribution")) ; frame3->addPlotable(hpull,"P") ; TCanvas* cResidual = new TCanvas("cResidual","Residual Distribution",1000,500); cResidual->Divide(2) ; cResidual->cd(1) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame2->Draw() ; cResidual->cd(2) ; gPad->SetLeftMargin(0.15) ; frame1->GetYaxis()->SetTitleOffset(1.6) ; frame3->Draw() ; */ }
void JetEtaBC(void){ std::cout << "Hellowww!!" << std::endl; TFile *file1; file1 = TFile::Open("PF_second.root"); TH1F* f1 = (TH1F*)file1->FindObjectAny("JetEtaBC"); TFile *file2; file2 = TFile::Open("PAT_second.root"); TH1F* f2 = (TH1F*)file2->FindObjectAny("JetEtaBC"); TFile *file3; file3 = TFile::Open("PF_IC5_Jets_Corrected.root"); TH1F* f3 = (TH1F*)file3->FindObjectAny("JetEtaBC"); TFile *file4; file4 = TFile::Open("PF_ak5_tot.root"); TH1F* f4 = (TH1F*)file4->FindObjectAny("JetEtaBC"); TCanvas *c1 = new TCanvas("canvas","Plotting Canvas",150,10,990,660); c1->Range(-0.1486535,-622.7141,1.350808,5500.641); c1->SetFillColor(0); c1->SetBorderSize(2); c1->SetLogy(); c1->SetTickx(1); c1->SetTicky(1); f1->SetStats(kFALSE); f4->GetXaxis()->SetTitle("#eta"); f4->GetXaxis()->SetLabelFont(42); f4->GetXaxis()->SetTitleFont(42); f4->GetYaxis()->SetTitle("Events"); f4->GetYaxis()->SetLabelFont(42); f4->GetYaxis()->SetTitleOffset(1.19); f4->GetYaxis()->SetTitleFont(42); f4->SetLineWidth(4); f1->SetLineColor(1); f2->SetStats(kFALSE); f2->SetLineColor(2); f2->SetLineWidth(3); f3->SetStats(kFALSE); f3->SetLineColor(3); f3->SetLineWidth(2); f4->SetStats(kFALSE); f4->SetLineColor(4); f1->SetLineWidth(1); int entries = f1->GetEntries(); double mean = f1->GetMean(); double RMS = f1->GetRMS(); int entries1 = f2->GetEntries(); double mean1 = f2->GetMean(); double RMS1 = f2->GetRMS(); int entries2 = f3->GetEntries(); double mean2 = f3->GetMean(); double RMS2 = f3->GetRMS(); int entries3 = f4->GetEntries(); double mean3 = f4->GetMean(); double RMS3 = f4->GetRMS(); TPaveStats *ptstats = new TPaveStats(0.8314943,0.7488136,0.9926437,0.8877119,"brNDC"); ptstats->SetName("stats"); ptstats->SetBorderSize(1); ptstats->SetFillColor(0); ptstats->SetTextAlign(12); ptstats->SetTextFont(42); ptstats->SetTextColor(1); TPaveStats *ptstats1 = new TPaveStats(0.8314943,0.5988136,0.9926437,0.7377119,"brNDC"); ptstats1->SetName("stats"); ptstats1->SetBorderSize(1); ptstats1->SetFillColor(0); ptstats1->SetTextAlign(12); ptstats1->SetTextFont(42); ptstats1->SetTextColor(2); TPaveStats *ptstats2 = new TPaveStats(0.8314943,0.4488136,0.9926437,0.5877119,"brNDC"); ptstats2->SetName("stats"); ptstats2->SetBorderSize(1); ptstats2->SetFillColor(0); ptstats2->SetTextAlign(12); ptstats2->SetTextFont(42); ptstats2->SetTextColor(3); TPaveStats *ptstats3 = new TPaveStats(0.8314943,0.2988136,0.9926437,0.4377119,"brNDC"); ptstats3->SetName("stats"); ptstats3->SetBorderSize(1); ptstats3->SetFillColor(0); ptstats3->SetTextAlign(12); ptstats3->SetTextFont(42); ptstats3->SetTextColor(4); #include <sstream> std::string s,s1,s2; std::stringstream out,out1,out2; out << "Entries = " << entries << " "; out1 << "Mean = " << mean << " "; out2 << "RMS = " << RMS << " "; s = out.str(); s1 = out1.str(); s2 = out2.str(); std::string s_1,s1_1,s2_1; std::stringstream out_1,out1_1,out2_1; out_1 << "Entries = " << entries1 << " "; out1_1 << "Mean = " << mean1 << " "; out2_1 << "RMS = " << RMS1 << " "; s_1 = out_1.str(); s1_1 = out1_1.str(); s2_1 = out2_1.str(); std::string s_2,s1_2,s2_2; std::stringstream out_2,out1_2,out2_2; out_2 << "Entries = " << entries2 << " "; out1_2 << "Mean = " << mean2 << " "; out2_2 << "RMS = " << RMS2 << " "; s_2 = out_2.str(); s1_2 = out1_2.str(); s2_2 = out2_2.str(); std::string s_3,s1_3,s2_3; std::stringstream out_3,out1_3,out2_3; out_3 << "Entries = " << entries3 << " "; out1_3 << "Mean = " << mean3 << " "; out2_3 << "RMS = " << RMS3 << " "; s_3 = out_3.str(); s1_3 = out1_3.str(); s2_3 = out2_3.str(); TText *text = ptstats->AddText(s.c_str()); text = ptstats->AddText(s1.c_str()); text = ptstats->AddText(s2.c_str()); ptstats->SetOptStat(1110); ptstats->SetOptFit(0); TText *text1 = ptstats1->AddText(s_1.c_str()); text1 = ptstats1->AddText(s1_1.c_str()); text1 = ptstats1->AddText(s2_1.c_str()); ptstats1->SetOptStat(1110); ptstats1->SetOptFit(0); TText *text2 = ptstats2->AddText(s_2.c_str()); text2 = ptstats2->AddText(s1_2.c_str()); text2 = ptstats2->AddText(s2_2.c_str()); ptstats2->SetOptStat(1110); ptstats2->SetOptFit(0); TText *text3 = ptstats3->AddText(s_3.c_str()); text3 = ptstats3->AddText(s1_3.c_str()); text3 = ptstats3->AddText(s2_3.c_str()); ptstats3->SetOptStat(1110); ptstats3->SetOptFit(0); TPaveText *pt = new TPaveText(0.3066092,0.8061864,0.7255747,0.87055085,"blNDC"); pt->SetName("title"); pt->SetBorderSize(0); pt->SetTextFont(42); pt->SetFillColor(0); pt->SetTextColor(1); text = pt->AddText("PF Number of Jets before cuts"); text = pt->AddText("PF Jets Pt > 10 GeV Before Cuts"); TPaveText *pt1 = new TPaveText(0.3066092,0.7261864,0.7055747,0.77055085,"blNDC"); pt1->SetName("title"); pt1->SetBorderSize(0); pt1->SetTextFont(42); pt1->SetFillColor(0); pt1->SetTextColor(2); text1 = pt1->AddText("PAT Jets Eta Before Cuts"); TPaveText *pt2 = new TPaveText(0.3066092,0.6561864,0.7055747,0.70055085,"blNDC"); pt2->SetName("title"); pt2->SetBorderSize(0); pt2->SetTextFont(42); pt2->SetFillColor(0); pt2->SetTextColor(3); text2 = pt2->AddText("PF IC5 Pt > 0 GeV Jets Eta Before Cuts"); TPaveText *pt3 = new TPaveText(0.3266092,0.5861864,0.7055747,0.63055085,"blNDC"); pt3->SetName("title"); pt3->SetBorderSize(0); pt3->SetTextFont(42); pt3->SetFillColor(0); pt3->SetTextColor(4); text3 = pt3->AddText("PF ak5 Eta Before Cuts"); c1->Modified(); f4->Draw(); f2->Draw("SAME"); f3->Draw("SAME"); f1->Draw("SAME"); pt->Draw("SAME"); ptstats->Draw("SAME"); pt1->Draw("SAME"); ptstats1->Draw("SAME"); pt2->Draw("SAME"); ptstats2->Draw("SAME"); pt3->Draw("SAME"); ptstats3->Draw("SAME"); c1->SaveAs("JetEtaBeforeCutsComparisonAllIhaverightnow.gif"); return 0; };
//------------------------------------------------------------------------------------- void MoveStatsAndDraw (TH1 *data, TH1 *mc, char *dataTitle, char* mcTitle, char* firstline, char* secondline, int log, int col, bool stat, TString cut1, TString cut2, bool movepave){ c->SetLogy(log); mc->Draw(); data->Draw("pesames"); gStyle->SetOptStat(00000000); stat=0; if(stat) gStyle->SetOptStat(1111111111); /* TPaveText *TITLE = new TPaveText(0.2,0.65,0.55,0.9,"blNDC"); TITLE->SetFillStyle(4000); TITLE->SetFillColor(kWhite); TITLE->SetBorderSize(0.1); TITLE->SetTextFont(42); TITLE->AddText(firstline); TITLE->Draw(); */ if(!movepave) { TPaveText *title = new TPaveText(0.2,0.7,0.55,0.93,"blNDC"); } else { // TPaveText *title = new TPaveText(0.6,0.58,0.95,0.83,"blNDC"); TPaveText *title = new TPaveText(0.6,0.7,0.95,0.93,"blNDC"); } title->SetFillStyle(4000); title->SetFillColor(kWhite); title->SetBorderSize(0.1); title->SetTextFont(42); title->AddText(firstline); title->AddText(secondline); title->AddText(cut1); title->AddText(cut2); title->Draw(); if(!movepave) { TLegend *leg = new TLegend(0.65,0.83,1.,0.93); } else { TLegend *leg = new TLegend(0.65,0.60,1.,0.7); } leg->SetFillStyle(4000); leg->SetFillColor(kWhite); leg->SetBorderSize(0.1); leg->SetTextFont(42); leg->AddEntry(data,dataTitle,"p"); leg->AddEntry(mc,mcTitle,"f"); leg->Draw(); c->Modified(); c->Update(); if(stat){ TPaveStats * ps = (TPaveStats *) mc->GetListOfFunctions()->FindObject("stats"); TPaveStats * ps2 = (TPaveStats *) data->GetListOfFunctions()->FindObject("stats"); Int_t ci; ci = TColor::GetColor(col); if( ps ){ ps->SetTextColor(1); ps->SetLineColor(col); } else std::cout << "Null pointer to TPaveStats: " << ps << std::endl; ps->SetY1NDC(0.40); ps->SetY2NDC(0.68); if( ps2 ) ps2->SetTextColor(ci); else std::cout << "Null pointer to TPaveStats: " << ps2 << std::endl; } }
void SinglePi(const TString ref_vers, const TString val_vers, bool fastsim){ //Warning!!! This rootlogon hacks the root color pallate setColors(); TString ref_file = "pi50scan"+ref_vers+"_fullGeom_ECALHCAL_CaloTowers.root"; TString val_file = "pi50scan"+val_vers+"_fullGeom_ECALHCAL_CaloTowers.root"; TFile f1(ref_file); TFile f2(val_file); // service variables // //Profiles const int Nprof = 12; TProfile* f1_prof[Nprof]; TProfile* f2_prof[Nprof]; char labelp[Nprof][64]; //1D Histos const int Nhist1 = 7; TH1* f1_hist1[Nhist1]; TH1* f2_hist1[Nhist1]; char label1[Nhist1][64]; //Labels //Profiles sprintf(labelp[0], "CaloTowersTask_emean_vs_ieta_E1.gif"); sprintf(labelp[1], "CaloTowersTask_emean_vs_ieta_H1.gif"); sprintf(labelp[2], "CaloTowersTask_emean_vs_ieta_EH1.gif"); sprintf(labelp[3], "RecHitsTask_emean_vs_ieta_E.gif"); sprintf(labelp[4], "RecHitsTask_emean_vs_ieta_H.gif"); sprintf(labelp[5], "RecHitsTask_emean_vs_ieta_EH.gif"); if (!fastsim) { sprintf(labelp[6], "SimHitsTask_emean_vs_ieta_E.gif"); sprintf(labelp[7], "SimHitsTask_emean_vs_ieta_H.gif"); sprintf(labelp[8], "SimHitsTask_emean_vs_ieta_EH.gif"); } sprintf(labelp[9], "RecHitsTask_timing_vs_energy_profile_HB.gif"); sprintf(labelp[10], "RecHitsTask_timing_vs_energy_profile_HE.gif"); sprintf(labelp[11], "RecHitsTask_timing_vs_energy_profile_HF.gif"); //1D Histos sprintf(label1[0], "N_calotowers_HB.gif"); sprintf(label1[1], "N_calotowers_HE.gif"); sprintf(label1[2], "N_calotowers_HF.gif"); sprintf(label1[3], "RecHits_energy_HB.gif"); sprintf(label1[4], "RecHits_energy_HE.gif"); sprintf(label1[5], "RecHits_energy_HO.gif"); sprintf(label1[6], "RecHits_energy_HF.gif"); TDirectory *td = fileDirectory(&f1, "CaloTowersTask"); //f1.cd("DQMData/CaloTowersV/CaloTowersTask"); //gDirectory->pwd(); td->pwd(); f1_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1"); f1_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1"); f1_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1"); f1_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB"); f1_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE"); f1_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF"); td = fileDirectory(&f1, "HcalRecHitTask"); //f1.cd("DQMData/HcalRecHitsV/HcalRecHitTask"); f1_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E"); f1_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths"); f1_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH"); f1_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB"); f1_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE"); f1_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF"); f1_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB"); f1_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE"); f1_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO"); f1_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF"); if (!fastsim) { td = fileDirectory(&f1, "HcalSimHitTask"); //f1.cd("DQMData/HcalSimHitsV/HcalSimHitTask"); f1_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E"); f1_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths"); f1_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH"); } td = fileDirectory(&f2, "CaloTowersTask"); //f2.cd("DQMData/CaloTowersV/CaloTowersTask"); //gDirectory->pwd(); td->pwd(); f2_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1"); f2_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1"); f2_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1"); f2_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB"); f2_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE"); f2_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF"); td = fileDirectory(&f2, "HcalRecHitTask"); //f2.cd("DQMData/HcalRecHitsV/HcalRecHitTask"); f2_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E"); f2_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths"); f2_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH"); f2_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB"); f2_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE"); f2_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF"); f2_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB"); f2_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE"); f2_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO"); f2_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF"); if (!fastsim) { td = fileDirectory(&f2, "HcalSimHitTask"); //f2.cd("DQMData/HcalSimHitsV/HcalSimHitTask"); f2_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E"); f2_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths"); f2_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH"); } //Profiles f1_prof[0]->GetXaxis()->SetTitle("CaloTowers eE (GeV) vs ieta 1 Tower"); f1_prof[1]->GetXaxis()->SetTitle("CaloTowers hE (GeV) vs ieta 1 Tower"); f1_prof[2]->GetXaxis()->SetTitle("CaloTowers eE+hE (GeV) vs ieta 1 Tower"); f1_prof[3]->GetXaxis()->SetTitle("RecHits eE (GeV) vs ieta R = 0.3 Cone"); f1_prof[4]->GetXaxis()->SetTitle("RecHits hE (GeV) vs ieta R = 0.3 Cone"); f1_prof[5]->GetXaxis()->SetTitle("RecHits eE+hE (GeV) vs ieta R = 0.3 Cone"); if (!fastsim) { f1_prof[6]->GetXaxis()->SetTitle("SimHits eE (GeV) vs ieta R = 0.3 Cone"); f1_prof[7]->GetXaxis()->SetTitle("SimHits hE (GeV) vs ieta R = 0.3 Cone"); f1_prof[8]->GetXaxis()->SetTitle("SimHits eE+hE (GeV) vs ieta R = 0.3 Cone"); } f1_prof[9]->GetXaxis()->SetTitle("HB RecHits timing (ns) vs Energy (GeV)"); f1_prof[10]->GetXaxis()->SetTitle("HE RecHits timing (ns) vs Energy (GeV)"); f1_prof[11]->GetXaxis()->SetTitle("HF RecHits timing (ns) vs Energy (GeV)"); //1D Histos f1_hist1[0]->GetXaxis()->SetTitle("Number of HB CaloTowers"); f1_hist1[1]->GetXaxis()->SetTitle("Number of HE CaloTowers"); f1_hist1[2]->GetXaxis()->SetTitle("Number of HF CaloTowers"); f1_hist1[3]->GetXaxis()->SetTitle("HB RecHits energy (GeV)"); f1_hist1[4]->GetXaxis()->SetTitle("HE RecHits energy (GeV)"); f1_hist1[5]->GetXaxis()->SetTitle("HO RecHits energy (GeV)"); f1_hist1[6]->GetXaxis()->SetTitle("HF RecHits energy (GeV)"); // f1_prof[0]->SetMaximum(20.); f1_prof[1]->SetMaximum(40.); f1_prof[2]->SetMaximum(40.); f1_prof[4]->SetMaximum(50.); f1_prof[5]->SetMaximum(50.); f1_prof[0]->SetMinimum(0.); f1_prof[1]->SetMinimum(0.); f1_prof[2]->SetMinimum(0.); f1_prof[3]->SetMinimum(0.); f1_prof[4]->SetMinimum(0.); f1_prof[5]->SetMinimum(0.); if (!fastsim) { f1_prof[6]->SetMinimum(0.); f1_prof[7]->SetMinimum(0.); f1_prof[8]->SetMinimum(0.); } f1_prof[9]->GetXaxis()->SetRangeUser(0.,75.); f1_prof[10]->GetXaxis()->SetRangeUser(0.,75.); f1_prof[11]->GetXaxis()->SetRangeUser(0.,75.); /* f1_prof[9]->SetMinimum(0.); f1_prof[10]->SetMinimum(0.); f1_prof[11]->SetMinimum(0.); */ // f1_hist[2]->GetXaxis()->SetRangeUser(0.,1200.); // f1_hist[7]->GetXaxis()->SetRangeUser(0.,160.); // hist1->GetXaxis()->SetNdivisions(-21); // hist1->GetYaxis()->SetNdivisions(-1003); f1_hist1[0]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[0]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[1]->GetXaxis()->SetRangeUser(0.,150.); f2_hist1[1]->GetXaxis()->SetRangeUser(0.,150.); f1_hist1[2]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[2]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[3]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[3]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[4]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[4]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[5]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[5]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[6]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[6]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[3]->SetMaximum(1.e8); f1_hist1[4]->SetMaximum(1.e8); f1_hist1[5]->SetMaximum(1.e8); f1_hist1[6]->SetMaximum(1.e8); // 1D-histo for (int i = 0; i < Nhist1; i++){ TCanvas *myc = new TCanvas("myc","",800,600); gStyle->SetOptStat(1111); if(i > 2) myc->SetLogy(); f1_hist1[i]->SetStats(kTRUE); // stat box f2_hist1[i]->SetStats(kTRUE); f1_hist1[i]->SetTitle(""); f2_hist1[i]->SetTitle(""); f1_hist1[i]->SetLineWidth(2); f2_hist1[i]->SetLineWidth(2); // diffferent histo colors and styles f1_hist1[i]->SetLineColor(41); f1_hist1[i]->SetLineStyle(1); f2_hist1[i]->SetLineColor(43); f2_hist1[i]->SetLineStyle(2); //Set maximum to the larger of the two if (f1_hist1[i]->GetMaximum() < f2_hist1[i]->GetMaximum()) f1_hist1[i]->SetMaximum(1.05 * f2_hist1[i]->GetMaximum()); TLegend *leg = new TLegend(0.2, 0.91, 0.6, 0.99, "","brNDC"); leg->SetBorderSize(2); // leg->SetFillColor(51); // see new color definition above leg->SetFillStyle(1001); // leg->AddEntry(f1_hist1[i],"CMSSW_"+ref_vers,"l"); leg->AddEntry(f2_hist1[i],"CMSSW_"+val_vers,"l"); TPaveStats *ptstats = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC"); ptstats->SetTextColor(41); f1_hist1[i]->GetListOfFunctions()->Add(ptstats); ptstats->SetParent(f1_hist1[i]->GetListOfFunctions()); TPaveStats *ptstats2 = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC"); ptstats2->SetTextColor(43); f2_hist1[i]->GetListOfFunctions()->Add(ptstats2); ptstats2->SetParent(f2_hist1[i]->GetListOfFunctions()); f1_hist1[i]->Draw(""); // "stat" f2_hist1[i]->Draw("histsames"); leg->Draw(); myc->SaveAs(label1[i]); if(myc) delete myc; } // Profiles for (int i = 0; i < Nprof; i++){ TCanvas *myc = new TCanvas("myc","",800,600); bool skipHisto = false; if (fastsim && i>=6 && i<=8) skipHisto = true; if (!skipHisto) { f1_prof[i]->SetStats(kFALSE); f2_prof[i]->SetStats(kFALSE); f1_prof[i]->SetTitle(""); f2_prof[i]->SetTitle(""); f1_prof[i]->SetLineColor(41); f1_prof[i]->SetLineStyle(1); f1_prof[i]->SetLineWidth(1); f1_prof[i]->SetMarkerColor(41); f1_prof[i]->SetMarkerStyle(21); f1_prof[i]->SetMarkerSize(1.0); f2_prof[i]->SetLineColor(43); f2_prof[i]->SetLineStyle(1); f2_prof[i]->SetLineWidth(1); f2_prof[i]->SetMarkerColor(43); f2_prof[i]->SetMarkerStyle(20); f2_prof[i]->SetMarkerSize(0.8); if(i > 8 ) { f1_prof[i]->SetMarkerSize(0.1); f2_prof[i]->SetMarkerSize(0.3); } myc->SetGrid(); if( i <= 8) { f1_prof[i]->Draw("histpl"); f2_prof[i]->Draw("histplsame"); // esame } else { f1_prof[i]->Draw("pl"); f2_prof[i]->Draw("plsame"); // esame } TLegend *leg = new TLegend(0.40, 0.91, 0.74, 0.99, "","brNDC"); leg->SetBorderSize(2); leg->SetFillStyle(1001); leg->AddEntry(f1_prof[i],"CMSSW_"+ref_vers,"pl"); leg->AddEntry(f2_prof[i],"CMSSW_"+val_vers,"pl"); leg->Draw(""); myc->SaveAs(labelp[i]); } if(myc) delete myc; } TCanvas *myc = new TCanvas("myc","",800,600); TProfile* ratio1 = (TProfile*)f2_prof[2]->Clone(); ratio1->Divide(f1_prof[2]); ratio1->SetMaximum(1.2); ratio1->SetMinimum(0.8); myc->SetGrid(); ratio1->Draw("hist pl"); TLegend *leg = new TLegend(0.20, 0.91, 0.70, 0.99, "","brNDC"); leg->SetBorderSize(2); leg->SetFillStyle(1001); leg->AddEntry(ratio1,"CaloTowers scale (pi50) ratio "+val_vers+"/"+ref_vers+" vs ieta","pl"); leg->Draw(""); // f1_prof[2]->Draw(); myc->SaveAs("Ratio.gif"); // close ROOT files // f1.Close() ; f2.Close() ; return ; }
void many_plots2(int first = 5808, int last = 11688, int mask = 0x801E) { TH1D *h[12][2]; int i, j; char str[64]; TCanvas *cv[2]; TPaveStats *st; float y, dy; gROOT->SetStyle("Plain"); gStyle->SetOptStat(1000000); gStyle->SetOptFit(); TFile *fRoot = new TFile("many_plots.root", "RECREATE"); HPainter *p = new HPainter(mask, first, last); p->SetFile(fRoot); if (!p->IsOpen()) { printf("Something wrong with data files.\n"); return; } TCut cVeto("gtFromVeto > 60"); TCut cIso("(gtFromPrevious > 45 && gtToNext > 80 && EventsBetween == 0) || (gtFromPrevious == gtFromVeto)"); TCut cX("PositronX[0] < 0 || (PositronX[0] > 2 && PositronX[0] < 94)"); TCut cY("PositronX[1] < 0 || (PositronX[1] > 2 && PositronX[1] < 94)"); TCut cZ("PositronX[2] > 3.5 && PositronX[2] < 95.5"); TCut cXYZ = cX && cY && cZ; TCut cR("Distance < 100 && DistanceZ > -40 && DistanceZ < 40"); TCut cT10("gtDiff > 1"); TCut cT20("gtDiff > 2"); TCut cT200("gtDiff < 20"); // strong cut TCut cGamma("AnnihilationEnergy < 1.5 && AnnihilationGammas < 9"); TCut cPe("PositronEnergy > 1"); TCut cXY("PositronX[0]>=0 && PositronX[1]>=0"); TCut cN4("NeutronEnergy > 4 && NeutronHits >= 5"); for (i=0; i<2; i++) { sprintf(str, "hR%d", i); h[0][i] = new TH1D(str, "Distance between positron and neutron;R, cm;mHz", 40, 0, 160); sprintf(str, "hRZ%d", i); h[1][i] = new TH1D(str, "Distance between positron and neutron, projection Z;R_{z}, cm;mHz", 100, -100, 100); sprintf(str, "hT%d", i); h[2][i] = new TH1D(str, "Time between positron and neutron;T, us;mHz", 50, 0, 50); sprintf(str, "hX%d", i); h[3][i] = new TH1D(str, "Positron vertex X;X, cm;mHz", 25, 0, 100); sprintf(str, "hY%d", i); h[4][i] = new TH1D(str, "Positron vertex Y;Y, cm;mHz", 25, 0, 100); sprintf(str, "hZ%d", i); h[5][i] = new TH1D(str, "Positron vertex Z;Z, cm;mHz", 100, 0, 100); sprintf(str, "hNE%d", i); h[6][i] = new TH1D(str, "Energy detected in neutron capture;E_{n}, MeV;mHz", 50, 0, 10); sprintf(str, "hNN%d", i); h[7][i] = new TH1D(str, "Number of hits in SiPM for neutron capture;N_{n};mHz", 20, 0, 20); sprintf(str, "hGE%d", i); h[8][i] = new TH1D(str, "Energy beyond positron cluster;E_{#gamma}, MeV;mHz", 15, 0, 3); sprintf(str, "hGN%d", i); h[9][i] = new TH1D(str, "Number of SiPM hits out of positron cluster;N_{#gamma};mHz", 10, 0, 10); sprintf(str, "hE%d", i); h[10][i] = new TH1D(str, "Positorn kinetic energy;E, MeV;mHz", 40, 0, 8); sprintf(str, "hEC%d", i); h[11][i] = new TH1D(str, "Positorn kinetic energy, strong background cuts;E, MeV;mHz", 40, 0, 8); } printf("Histograms are created\n"); p->Project(h[0][0], "Distance", cVeto && cIso && cT20 && cGamma && cPe && cXYZ); p->Project(h[0][1], "Distance", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ); printf("Distance.\n"); p->Project(h[1][0], "DistanceZ", cVeto && cIso && cT20 && cGamma && cPe && cXYZ); p->Project(h[1][1], "DistanceZ", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ); printf("DistanceZ.\n"); p->Project(h[2][0], "gtDiff", cVeto && cIso && cT10 && cGamma && cPe && cXYZ && cR); p->Project(h[2][1], "gtDiff", !cVeto && cIso && cT10 && cGamma && cPe && cXYZ && cR); printf("gtDiff.\n"); p->Project(h[3][0], "PositronX[0]+2", cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR && "PositronX[0] >= 0"); p->Project(h[3][1], "PositronX[0]+2", !cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR && "PositronX[0] >= 0"); printf("X.\n"); p->Project(h[4][0], "PositronX[1]+2", cVeto && cIso && cT20 && cGamma && cPe && cX && cZ && cR && "PositronX[1] >= 0"); p->Project(h[4][1], "PositronX[1]+2", !cVeto && cIso && cT20 && cGamma && cPe && cX && cZ && cR && "PositronX[1] >= 0"); printf("Y.\n"); p->Project(h[5][0], "PositronX[2]+0.5", cVeto && cIso && cT20 && cGamma && cPe && cX && cY && cR); p->Project(h[5][1], "PositronX[2]+0.5", !cVeto && cIso && cT20 && cGamma && cPe && cX && cY && cR); printf("Z.\n"); p->Project(h[6][0], "NeutronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR); p->Project(h[6][1], "NeutronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cY && cZ && cR); printf("NE.\n"); p->Project(h[7][0], "NeutronHits", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR); p->Project(h[7][1], "NeutronHits", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR); printf("NN.\n"); p->Project(h[8][0], "AnnihilationEnergy", cVeto && cIso && cT20 && cPe && cXYZ && cR); p->Project(h[8][1], "AnnihilationEnergy", !cVeto && cIso && cT20 && cPe && cXYZ && cR); printf("AE.\n"); p->Project(h[9][0], "AnnihilationGammas", cVeto && cIso && cT20 && cPe && cXYZ && cR); p->Project(h[9][1], "AnnihilationGammas", !cVeto && cIso && cT20 && cPe && cXYZ && cR); printf("AG.\n"); p->Project(h[10][0], "PositronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR); p->Project(h[10][1], "PositronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR); p->Project(h[11][0], "PositronEnergy", cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR && cN4 && cT200); p->Project(h[11][1], "PositronEnergy", !cVeto && cIso && cT20 && cGamma && cPe && cXYZ && cR && cN4 && cT200); printf("Projections are done\n"); for (i=0; i<12; i++) { for (j=0; j<2; j++) h[i][j]->SetLineWidth(4); h[i][0]->SetLineColor(kGreen); h[i][1]->SetLineColor(kRed); h[i][0]->SetMinimum(0); h[i][1]->SetMinimum(0); } // h[1][0]->Fit("gaus", "0"); // h[1][1]->Fit("gaus", "0"); // TF1 *fdec = new TF1("FDEC", "[0]*(exp(-x/[1]) - exp(-x/[2]))", 3); // fdec->SetParNames("Const", "t_{CAPTURE}", "t_{THERM}"); // fdec->SetParameters(h[2][0]->Integral()/4, 15, 5); // h[2][0]->Fit("FDEC", "0", "", 2, 50); for (i=0; i<2; i++) { sprintf(str, "CV%d", i); cv[i] = new TCanvas(str, "Plots", 1800, 1200); cv[i]->Divide(3, 2); for (j=0; j<6; j++) { cv[i]->cd(j+1); h[6*i+j][0]->Draw(); h[6*i+j][1]->Draw("sames"); gPad->Update(); if (i == 0 && j == 1) { st = (TPaveStats *) h[6*i+j][0]->FindObject("stats"); st->SetOptStat(1100); st->SetLineColor(kGreen); st->SetTextColor(kGreen); y = st->GetY1NDC(); dy = st->GetY2NDC() - y; st->SetX1NDC(0.72); st = (TPaveStats *) h[6*i+j][1]->FindObject("stats"); st->SetOptStat(1100); st->SetLineColor(kRed); st->SetTextColor(kRed); st->SetX1NDC(0.72); st->SetY2NDC(y); st->SetY1NDC(y - dy); } else { st = (TPaveStats *) h[6*i+j][0]->FindObject("stats"); st->SetLineColor(kGreen); st->SetTextColor(kGreen); y = st->GetY1NDC(); dy = st->GetY2NDC() - y; st->SetX1NDC(0.72); st->SetY1NDC(y + dy/2); st = (TPaveStats *) h[6*i+j][1]->FindObject("stats"); st->SetLineColor(kRed); st->SetTextColor(kRed); st->SetX1NDC(0.72); st->SetY2NDC(y + dy/2); } if (h[6*i+j][0]->GetMaximum() > h[6*i+j][1]->GetMaximum()) { h[6*i+j][0]->Draw(); h[6*i+j][1]->Draw("sames"); } else { h[6*i+j][1]->Draw(); h[6*i+j][0]->Draw("sames"); } gPad->Update(); } cv[i]->Update(); } fRoot->cd(); for (i=0; i<12; i++) for (j=0; j<2; j++) h[i][j]->Write(); fRoot->Close(); }