TCanvas* pHitSpecPos( ) { TCanvas* c = new TCanvas("cHitSpecPos","cHitSpecPos",1000,1100); c->Divide(2,2); TVirtualPad* p; TH2D *h; TText t; t.SetTextColor(4); p =c->cd(1); p->SetLogy(); p->SetGrid(1,0); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarMinus"); h->GetYaxis()->SetRange(4,33); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.15, "BARREL MU MINUS"); p =c->cd(2); p->SetLogy(); p->SetGrid(1,0); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarPlus"); h->GetYaxis()->SetRange(4,32); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.15, "BARREL MU PLUS"); p =c->cd(3); p->SetLogy(); p->SetGrid(1,0); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndMinus"); h->GetYaxis()->SetRange(4,32); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.15, "ENDCAP MU MINUS"); p =c->cd(4); p->SetLogy(); p->SetGrid(1,0); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndPlus"); h->GetYaxis()->SetRange(4,32); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.15, "ENDCAP MU PLUS"); return c; }
void drawHistos(TCanvas * C, TString filename, TString category, TTree* Tmine, TTree* Tother,TString var, int nbins, float xmin, float xmax, TString selection, TString myGroup, TString myRootFile, TString group, TString groupRootFile,TString mySel="1",TString groupSel="1"){ TH1F* Hmine = new TH1F(TString("Hmine")+var,"",nbins,xmin,xmax); Hmine->GetYaxis()->SetTitle(category); Hmine->GetXaxis()->SetTitle(var); Hmine->SetLineColor(1); Hmine->SetStats(0); TH1F* Hother = new TH1F(TString("Hother")+var,"",nbins,xmin,xmax); Hother->GetYaxis()->SetTitle(category); Hother->GetXaxis()->SetTitle(var); Hother->SetLineColor(2); Hother->SetStats(0); TText TXmine; TXmine.SetTextColor(1); TXmine.SetTextSize(.04); TText TXother; TXother.SetTextColor(2); TXother.SetTextSize(.04); Tmine->Draw(var+">>"+Hmine->GetName(),selection+"*("+mySel+")"); Tother->Draw(var+">>"+Hother->GetName(),selection+"*("+groupSel+")"); ////Draw one histogram on top of the other C->Clear(); //Hmine->Scale(1./Hmine->Integral()); //Hother->Scale(1./Hother->Integral()); //Hother->Scale(968134./688134.); //GGH e-tau if(Hmine->GetMaximum()>Hother->GetMaximum()) Hmine->GetYaxis()->SetRangeUser(0,Hmine->GetMaximum()*1.1); else Hmine->GetYaxis()->SetRangeUser(0,Hother->GetMaximum()*1.1); Hmine->Draw("hist"); Hother->Draw("histsame"); // ///Draw the difference of the historgrams // TH1F*HDiff=(TH1F*)Hmine->Clone("HDiff"); // HDiff->Add(Hother,-1); // int max= abs(HDiff->GetMaximum())>abs( HDiff->GetMinimum()) ? abs(HDiff->GetMaximum()): abs( HDiff->GetMinimum()); // HDiff->GetYaxis()->SetRangeUser(-2*(max>0?max:1),2*(max>0?max:1)); // HDiff->Draw("hist"); // TLine line; // line.DrawLine(HDiff->GetXaxis()->GetXmin(),0,HDiff->GetXaxis()->GetXmax(),0); //Print the integrals of the histograms a the top //TXmine.DrawTextNDC(.2,.965,myGroup+"_"+myRootFile+": "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1))); //TXother.DrawTextNDC(.2,.93,group+"_"+groupRootFile+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1))); TXmine.DrawTextNDC(.2,.965,myGroup+" : "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1))); TXother.DrawTextNDC(.2,.93,group+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1))); C->Print(filename); delete Hmine; delete Hother; }
void printHighPtYield(TH1* ha,TH1* hb) { char buf[20]; TH1* h[2]; h[0]=ha; h[1]=hb; int minBin[2],maxBin[2],count(0); float min,max; float ptBins[]={4,4.5,5,5.5}; int nBin=4; TText* text = new TText; for(int iBin=0;iBin<nBin;iBin++){ count=0; for(int i=0; i<2; i++){ if(!h[i]) break; minBin[i] = h[i]->GetXaxis()->FindBin(ptBins[iBin]); maxBin[i] = h[i]->GetXaxis()->FindBin(ptBins[iBin]); float integral=h[i]->Integral(minBin[i],maxBin[i]); count += integral; if(i==0){ min=h[i]->GetXaxis()->GetBinLowEdge(minBin[i]); max=h[i]->GetXaxis()->GetBinUpEdge(maxBin[i]); } } sprintf(buf,"%.1f<pt<%.1f=%d",min,max,count); text->DrawTextNDC(0.55,0.8-iBin*0.1,buf); } }
void HistoCompare::printRes(TString theName, Double_t thePV, TText * te) { myte->DrawTextNDC(0.1,printresy,theName ); std::cout << "[Compatibility test] " << theName << std::endl; printresy+=-0.04; }
void Draw_KL_Test(){ TChain* ch = new TChain("Tree"); TChain* ch1 = new TChain("Tree"); TH1D* his = new TH1D("Klong6g","Klong6g",20,450,550); TH1D* his1 = new TH1D("Klong4g","Klong4g",20,450,550); TH1D* his2 = new TH1D("Klong4gAll","Klong4gAll",60,250,550); for( int i = 0; i< 68; i++){ ch->Add(Form("klongRootFile/kl%d.root" ,4162+i)); ch1->Add(Form("klongRootFile/ks%d.root",4162+i)); } ch->Project(his->GetName() ,"KlongMass[0]","CutCondition==0"); ch1->Project(his1->GetName(),"KlongMass[0]","CutCondition==0"); ch1->Project(his2->GetName(),"KlongMass[0]","CutCondition==0"); TF1* func = new TF1("func","gaus(0)+expo(3)",0,550); func->SetParameter(1,498); func->SetParameter(2,5); TF1* func2 = new TF1("func2","gaus(0)",0,550); func2->SetParameter(1,498); func2->SetParameter(2,5); TCanvas* can = new TCanvas("can","",1200,600); can->Divide(2,1); can->cd(1); his2->Fit(func->GetName(),"","",450,550); his2->Draw(); TF1* func1 = new TF1("Test","gaus",450,550); func1->SetParameter(0,func->GetParameter(0)); func1->SetParameter(1,func->GetParameter(1)); func1->SetParameter(2,func->GetParameter(2)); can->cd(2); his1->SetLineColor(2); his->Draw(); his->Fit(func2->GetName(),"","",450,550); func->Draw("same"); his1->Draw("same"); std::cout<< func2->GetParameter(0) << " " << func->GetParameter(0) << " " << func->GetParameter(0)/func2->GetParameter(0)<< std::endl; std::cout<< func2->Integral(450,550) << " " << func1->Integral(450,550) << " " << func1->Integral(450,550)/func2->Integral(450,550) << std::endl; //ch->Draw("KlongPt[0]:KlongMass[0]>>(400,200,600,50,0,20)","(CutCondition&(1|2|4|8))==0","colz"); gPad->SetLogz(); TText* text = new TText(0.5,0.5,""); TText* text1 = new TText(0.5,0.5,""); text->DrawTextNDC(0.5,0.5,Form("Integral:%2.3lf",func1->Integral(450,550))); text1->DrawTextNDC(0.5,0.6,Form("Integral:%2.3lf",func2->Integral(450,550))); }
void test(void){ TCanvas *c = new TCanvas("c","font test"); TH1D *h = new TH1D("h","h",10,0,10); TText *t = new TText(); h->SetTitle("Title"); h->GetXaxis()->SetTitle("X axis daze"); h->GetYaxis()->SetTitle("Y axis yade"); h->Draw(); t->DrawTextNDC(0.4, 0.4 ,"abcdef"); }
void plot_example(){ THStack *hs = new THStack("hs",""); TH1F *h1 = new TH1F("h1","test hstack",10,-4,4); h1->FillRandom("gaus",20000); h1->SetFillColor(kRed); hs->Add(h1); TH1F *h2 = new TH1F("h2","test hstack",10,-4,4); h2->FillRandom("gaus",15000); h2->SetFillColor(kBlue); hs->Add(h2); TH1F *h3 = new TH1F("h3","test hstack",10,-4,4); h3->FillRandom("gaus",10000); h3->SetFillColor(kGreen); hs->Add(h3); TCanvas *cs = new TCanvas("cs","cs",10,10,700,900); TText T; T.SetTextFont(42); T.SetTextAlign(21); cs->Divide(2,2); cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option"); cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\""); cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\""); cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\""); }
void HistoCompare::printRes(TString myName, Double_t mypv, TText * myte) { std::basic_stringstream<char> buf; std::string value; buf<<"PV="<<mypv<<std::endl; buf>>value; myte->DrawTextNDC(0.7,0.92, value.c_str()); std::cout << "[Compatibility test] " << myName << " PV = " << mypv << std::endl; }
void drawSignalDiff(TCanvas* C,TString Group1,TFile* F1,TString Group2,TFile* F2,TString channel,TString category,TString signal){ // drawSignalDiff( C, Group1, F1, Group2 ,F2, channel, "boost_high", "ggH"); C->Clear(); TGraph G1; TGraph G2; float max=0.; for(Int_t i=0;i<8;i++){ long mass=110+i*5; TH1F* H1 = (TH1F*) F1->Get(channel+"_"+category+"/"+signal+mass); TH1F* H2 = (TH1F*) F2->Get(channel+"_"+category+"/"+signal+mass); G1.SetPoint(i,mass,H1->Integral()); G2.SetPoint(i,mass,H2->Integral()); if(H1->Integral()>max)max=H1->Integral(); } G1.GetYaxis()->SetRangeUser(0.,max*1.1); G1.SetTitle(category+" "+signal); G1.GetYaxis()->SetTitle("signal yield"); G1.GetXaxis()->SetTitle("m_{H}"); G1.Draw("ap"); G2.SetLineColor(2); G2.Draw("lsame"); TText TXmine; TXmine.SetTextColor(1); TXmine.SetTextSize(.04); TXmine.DrawTextNDC(.25,.845,Group1); TText TXother; TXother.SetTextColor(2); TXother.SetTextSize(.04); TXother.DrawTextNDC(.25,.81,Group2); C->Print(TString(C->GetName())+".pdf"); }
TCanvas* pHitSpecDet(const std::string& s) { TCanvas* c = new TCanvas( ("HitSpecDet"+s).c_str(), ("HitSpecDet"+s).c_str(), -2); c->SetLogx(); TH2D* h = (TH2D*)gROOT->FindObject(s.c_str()); h->GetXaxis()->SetRange(4,32); std::stringstream str; str<<h->GetTitle(); TText t; t.SetTextColor(4); t.SetTextAlign(11); t.SetTextSize(0.035); h->DrawCopy("box"); t.DrawTextNDC(0.17,0.2, str.str().c_str()); return c; }
void FitHist(TH1F* hPR, TH1F* hAB, TH1F* hEP){ for(Int_t iC=4; iC<NCENT; iC++){ for(Int_t iY=0; iY<NYo; iY++){ for(Int_t iP=0; iP<NPt; iP++){ //18 chi=0.; if (hAB[iC][iY][iP].Integral(90.,180.) == 0 || hAB[iC][iY][iP].Integral(0.,180.)== 0 ){ chi = 0.; } else { chi = sqrt(-2.*TMath::Log(2.*(hAB[iC][iY][iP].Integral(90.,180.)/hAB[iC][iY][iP].Integral(0.,180.)))); for(Int_t i=0; i<4; i++){ Rv[i][iC] = getCorr(i+1,chi); }} //-global-evet-resolution-- for(Int_t i=0; i<4; i++){ ci[i] = Rv[i][iC]; } ci[4]=1.0; //-temporary-set-to-unity--because-it-is--not-yet-calculated-- ci[5]=1.0; Float_t summ = hPR[iC][iY][iP]->GetSumOfWeights(); Int_t phibins = hPR[iC][iY][iP]->GetXaxis()->GetNbins(); if( summ > 0 ){ hPR[iC][iY][iP]->Fit("flows"); Char_t ds[100]; TText txt; for(Int_t i=0; i<6; i++){ vi[i] = flows->GetParameter(i); ei[i] = flows->GetParError( i); sprintf(ds, "v%i=%+5.4f +/- %5.4f",i+1, vi[i]/ci[i], ei[i]/ci[i]); txt.DrawTextNDC(0.25, 0.36-0.05*i, ds); if(summ>12*100 ){ if(ci[i]>0.000001){ hv[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]); hv[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]); vsum[i][iC][iY][iP] = vi[i]/ci[i]; esum[i][iC][iY][iP] = ei[i]/ci[i]; //hs[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]); //hs[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]); } } } } } } } }
void drawHisto(TCanvas* C,TString Group1,TFile* F1,TString Group2,TFile* F2,TString channel,TString category,TString sample,bool PrintDiff){ C->Clear(); TH1F* H1 = (TH1F*) F1->Get(channel+"_"+category+"/"+sample); TH1F* H2 = (TH1F*) F2->Get(channel+"_"+category+"/"+sample); if(!H1||!H2||H1->Integral()!=H1->Integral()||H2->Integral()!=H2->Integral()){ if(H1&&H1->Integral()==H1->Integral())H1->Draw("histpe"); if(H2&&H2->Integral()==H2->Integral())H2->Draw("histpe"); TText cat; cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample); if(!H1||H1->Integral()!=H1->Integral()) cat.DrawTextNDC(.2,.4,Group1+" is missing or 0"); if(!H2||H2->Integral()!=H2->Integral()) cat.DrawTextNDC(.2,.4,Group2+" is missing or 0"); if(PrintDiff)printf("| %.1f ",100); C->Print(TString(C->GetName())+".pdf"); return; } // cout<<channel<<" "<<category<<" "<<sample<<endl; // cout<<H1->Integral()<<" "<<H2->Integral()<<endl; // TText cat; // cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample); // C->Print(TString(C->GetName())+".pdf"); // return; TPad pad1("pad1","",0,0.2,1,1); TPad pad2("pad2","",0,0,1,0.2); //////////////////////////////////////////// pad1.cd(); //H1->SetTitle(""); H1->SetTitle(channel+" "+category+" "+sample); H1->GetXaxis()->SetTitle("mass"); H1->GetYaxis()->SetTitle(""); H1->GetYaxis()->SetRangeUser(0,(H1->GetMaximum()>H2->GetMaximum() ? H1->GetMaximum() : H2->GetMaximum())*1.2); H1->SetLineWidth(3); H1->SetLineColor(1); H1->SetFillColor(0); H1->Draw("histpe"); H2->SetMarkerSize(0.01); H2->SetLineWidth(3); H2->SetLineColor(2); H2->SetFillColor(0); H2->Draw("histesame"); TText TXmine; TXmine.SetTextColor(1); TXmine.SetTextSize(.04); TText TXother; TXother.SetTextColor(2); TXother.SetTextSize(.04); TText TXdiff; TXdiff.SetTextColor(4); TXdiff.SetTextSize(.03); char yield1[100]; sprintf(yield1,"%.2f",H1->Integral(1,H1->GetNbinsX())); char yield2[100]; sprintf(yield2,"%.2f",H2->Integral(1,H2->GetNbinsX())); TXmine.DrawTextNDC(.55,.845,Group1+" : "+yield1); TXother.DrawTextNDC(.55,.81,Group2+" : "+yield2); char txt[100]; float diff=100*2*fabs(H1->Integral(1,H1->GetNbinsX())-H2->Integral(1,H2->GetNbinsX()))/(H1->Integral(1,H1->GetNbinsX())+H2->Integral(1,H2->GetNbinsX())); sprintf(txt,"Difference = %.1f",diff); TXdiff.DrawTextNDC(.25,.85,TString(txt)+"%"); //////////////////////////////////////////// pad2.cd(); ///Draw the ratio of the historgrams TH1F*HDiff=(TH1F*)H2->Clone("HDiff"); HDiff->Divide(H1); HDiff->GetYaxis()->SetRangeUser(0.8,1.2); HDiff->GetYaxis()->SetNdivisions(3); HDiff->GetYaxis()->SetLabelSize(0.1); HDiff->GetYaxis()->SetTitleSize(0.1); HDiff->GetYaxis()->SetTitleOffset(0.5); //HDiff->GetYaxis()->SetTitle(myGroup + " / " + group); HDiff->GetYaxis()->SetTitle("Ratio"); HDiff->GetXaxis()->SetNdivisions(-1); HDiff->GetXaxis()->SetTitle(""); HDiff->GetXaxis()->SetLabelSize(0.0001); HDiff->SetMarkerSize(0.1); HDiff->Draw("histpe"); TLine line; line.DrawLine(HDiff->GetXaxis()->GetXmin(),1,HDiff->GetXaxis()->GetXmax(),1); C->Clear(); pad1.Draw(); pad2.Draw(); //cout<<setiosflags(ios::fixed)<<precision(2); //cout<<"| "<<diff<<" "<<endl; //if(PrintDiff)printf("| %.1f ",diff); C->Print(TString(C->GetName())+".pdf"); //delete H1; //delete H2; delete HDiff; }
void plotauto(TString infilename) { TString plname = infilename+".ps"; TCanvas* cc = new TCanvas("validate","validate",500,370); cc->Print(plname+"["); TText tt; tt.SetTextColor(2); tt.SetTextSize(0.02); gStyle->SetMarkerSize(0.1); gStyle->SetTitleSize(0.15,"ff"); gStyle->SetTitleTextColor(4); std::vector < TString > vnames; vnames.push_back("Sim_HitEn"); vnames.push_back("Sim_HitTime"); vnames.push_back("Sim_posXY"); vnames.push_back("Sim_posXZ"); vnames.push_back("Sim_posYZ"); vnames.push_back("Sim_posRZ"); std::vector <TString> exts; exts.push_back(""); exts.push_back("_posZ"); exts.push_back("_negZ"); TH1F* h; TH2F* hh; TKey *key; TIter next; TKey *key2; TIter next2; TFile* infile = new TFile(infilename, "read"); // overall geometry TDirectory* td = (TDirectory*) infile->Get("ALLCollections"); cc->Clear(); cc->Divide(3,3); cc->cd(1); hh = (TH2F*) td->Get("ALLCollections_overallhitZR"); hh->Draw("box"); cc->cd(2); int icol=1; bool first=true; TLegend* tl = new TLegend(0., 0., 1, 1); next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL") ) continue; if ( hn.Contains("_Log") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; TString ss = hn.ReplaceAll( "_overallhitZR", ""); tl->AddEntry(hh, ss , "l"); } } // the legend cc->cd(3); tl->Draw(); cc->cd(4); hh = (TH2F*) td->Get("ALLCollections_Log_overallhitZR"); hh->Draw("box"); cc->cd(5); icol=1; first=true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL" ) ) continue; if ( ! hn.Contains("_Log_") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; } } cc->cd(7); hh = (TH2F*) td->Get("ALLCollections_LogLog_overallhitZR"); hh->Draw("box"); cc->cd(8); icol=1; first=true; next = td->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*)key->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("ALL" ) ) continue; if ( ! hn.Contains("_LogLog_") ) continue; hh->SetLineColor(icol); if ( first ) {hh->Draw("box"); first=false;} else hh->Draw("same;box"); icol++; if (icol==10) icol=1; } } cc->Print(plname); // now collection-by-collection next = infile->GetListOfKeys(); while ((key = (TKey*)next())) { TClass *cll = gROOT->GetClass(key->GetClassName()); if (cll->InheritsFrom("TDirectory")) { td = (TDirectory*)key->ReadObj(); TString dirname = td->GetName(); if ( dirname=="ALLCollections" ) continue; // is it an endcap collection? bool isEndcap = td->Get(dirname+"_hitXY_posZ"); // first overall geometry cc->Clear(); cc->Divide(3,2); cc->cd(1); ( (TH2F*) td->Get(dirname+"_hitEn"))->Draw("box"); cc->cd(4)->SetLogy(); ( (TH2F*) td->Get(dirname+"_hitTime"))->Draw("box"); if ( isEndcap ) { cc->cd(2); ( (TH2F*) td->Get(dirname+"_hitXY_posZ"))->Draw("box"); cc->cd(3); ( (TH2F*) td->Get(dirname+"_hitXY_negZ"))->Draw("box"); cc->cd(5); ((TH2F*) td->Get(dirname+"_hitZR_posZ"))->Draw("box"); cc->cd(6); ((TH2F*) td->Get(dirname+"_hitZR_negZ"))->Draw("box"); } else { cc->cd(2); ( (TH2F*) td->Get(dirname+"_hitXY"))->Draw("box"); cc->cd(3); ( (TH2F*) td->Get(dirname+"_hitZR"))->Draw("box"); } cc->Print(plname); // then the cell indices // work out how many indices/variables we're dealing with std::vector < TString > indices; std::vector < TString > variables; next2 = td->GetListOfKeys(); while ((key2 = (TKey*)next2())) { cll = gROOT->GetClass(key2->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*) key2->ReadObj(); TString hn = hh->GetName(); if ( hn.Contains("Indx") ) { TString ss = hn.ReplaceAll(dirname+"_", ""); TString asas = ((TObjString*) (ss.Tokenize("_") -> At(0)))->GetString(); if ( find( indices.begin(), indices.end(), asas )==indices.end() ) indices.push_back(asas); asas = ((TObjString*) (ss.Tokenize("_") -> At(1)))->GetString(); if ( find( variables.begin(), variables.end(), asas )==variables.end() ) variables.push_back(asas); } } } if ( indices.size()==0 || variables.size()==0 ) continue; for (int inp=0; inp<2; inp++) { if ( !isEndcap && inp==1 ) continue; cc->Clear(); cc->Divide(indices.size(), variables.size()); int ic=1; next2 = td->GetListOfKeys(); while ((key2 = (TKey*)next2())) { cll = gROOT->GetClass(key2->GetClassName()); if (cll->InheritsFrom("TH2F")) { hh = (TH2F*) key2->ReadObj(); TString hn = hh->GetName(); if ( isEndcap ) { if ( inp==0 && ! hn.Contains("posZ") ) continue; else if ( inp==1 && ! hn.Contains("negZ") ) continue; } if ( hn.Contains("Indx") ) { TString asas = ((TObjString*) (hn.Tokenize("_") -> At(1)))->GetString(); asas = asas(4,asas.Length()); cc->cd(ic++); hh->Draw("box"); } } } cc->cd(); for ( size_t k=0; k<variables.size(); k++) { tt.DrawTextNDC( 0.0, 0.9 - (1.0*k)/(variables.size()), variables[k] ); } for ( size_t k=0; k<indices.size(); k++) { tt.DrawTextNDC( 0.05 + (1.0*k)/(indices.size()), 0.02, indices[k].ReplaceAll("Indx","Indx_") ); } tt.DrawTextNDC( 0.1, 0.99, dirname); if ( isEndcap ) { if (inp==0 ) tt.DrawTextNDC( 0.35, 0.99, "posZ"); else tt.DrawTextNDC( 0.35, 0.99, "negZ"); } cc->Print(plname); } } } infile->Close(); cc->Print(plname+"]"); }
void invmasscomb::Loop() { // In a ROOT session, you can do: // Root > .L invmasscomb.C // Root > invmasscomb t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return; double maxE(10.); TH1D massPi0("massPi0","masspi0",100,0.,1.); TH1D massPi0_2("massPi0_2","masspi0_2",150,0.,.4); TH1D massPi0full("massPi0full","masspi0full",200,0.4,2.5); TH1D masseta("masseta","masseta",50,0.25,.75); TH1D massetafull("massetafull","massetafull",100,0.4,2.5); TH1D masseta3pi0("masseta3pi0","masseta",30,0.15,1.2); TH1D masseta3pi0full("masseta3pi0full","masseta",100,0.,3.); TH1D masspi01("masspi01","",50,0.,.4); TH1D masspi02("masspi02","",50,0.,.4); TH2D mp01mp02("mp01mp02","",50,0.,.4,50,0.,.4); TH1D distance("distance","distance",100,0.,50.); TH1D energypi0("energypi0","",50,0.,maxE*1.1); TH1D x("x","x",50,130.,140.); TH1D y("y","y",50,-20.,30.); TH1D z("z","z",50,50.,200.); TH2D yz("yz","yz",30,-30.,30.,30,0.,250.); TH2D yzeta("yzeta","yz",30,-30.,30.,30,0.,250.); TH2D yz3pi0("yz3pi0","yz",30,-30.,30.,30,0.,250.); TH1D phi("phi","phi",50,-.15,.15); TH1D eta("eta","eta",50,0.,1.4); TH2D massPi0vsE("massPi0vsE","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1); TH2D massPi0vsE1("massPi0vsE1","masspi0 vs E",150,0.,.4,15,0.,maxE*1.); TH2D massPi0vsE2("massPi0vsE2","masspi0 vs E",150,0.,.4,15,0.,maxE*1.); TH2D massPi0vsECE("massPi0vsECE","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1); TH2D massPi0vsEDF("massPi0vsEDF","masspi0 vs E",150,0.,.4,15,0.,maxE*1.1); TH2D massPi0vsE_2("massPi0vsE_2","masspi0 vs E",50,0.,1.,50,0.,maxE*1.1); TH2D massPi0vsdistance("massPi0vsdistance","masspi0 vs D",150,0.,.4,10,0.,70.); TH2D massPi0vsy("massPi0vsy","masspi0 vs y",150,0.,.4,20,-15.,25.); TH2D massPi0vsz("massPi0vsz","masspi0 vs z",150,0.,.4,20,80.,180.); TH2D xyA("xyA","xy A",100,-40.,40.,100,-40.,40.); TH2D xyB("xyB","xy B",100,-40.,40.,100,-40.,40.); TH1D Y1vsE("Y1vsE","yield1 vs E",15,0.,maxE*1.1); TH1D Y1vsEbis("Y1vsEbis","yield1 vs E",15,0.,maxE*1.1); TH1D Y1vsECE("Y1vsECE","yield1 vs E",15,0.,maxE*1.1); TH1D Y1vsEDF("Y1vsEDF","yield1 vs E",15,0.,maxE*1.1); TH1D Y2vsE("Y2vsE","yield2 vs E",15,0.,maxE*1.1); TH1D Y1vsE1("Y1vsE1","yield1 vs E1",15,0.,maxE*1.); TH1D Y1vsE2("Y1vsE2","yield1 vs E2",15,0.,maxE*1.); TH1D Y1vsdist("Y1vsdist","yield1 vs dist",10,0.,70.); TH1D Y2vsdist("Y2vsdist","yield2 vs dist",10,0.,70.); TH1D s1_1p("s1_1p","S1 ADC",100,0.,2000); TH1D s2_1p("s2_1p","S2 ADC",100,0.,2000); TH1D s1_2p("s1_2p","S1 ADC",100,0.,2000); TH1D s2_2p("s2_2p","S2 ADC",100,0.,2000); TH2D masss1("masss1","mass vs S1 ADC",150,0.,.4,100,0.,2000); TH2D masss2("masss2","mass vs S2 ADC",150,0.,.4,100,0.,2000); TH2D s1s2_1p("s1s2_1p","S1 vs S2 ADC",100,0.,2000,100,0.,2000); TH2D s1s2_2p("s1s2_2p","S1 vs S2 ADC",100,0.,2000,100,0.,2000); TH1D massPi0Pi0("massPi0Pi0","masspi0pi0",33,0.5,2.5); TH1D massPi0Pi0full("massPi0Pi0full","masspi0pi0",50,0.,3.); TH1D n_Pi0("n_Pi0","npi0",8,2.,10.0); Long64_t nentries = fChain->GetEntriesFast(); cout << nentries << endl; Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries; jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; // if (Cut(ientry) < 0) continue; int nPi0(0); double mpi01, mpi02; double px_pi0[100],py_pi0[100],pz_pi0[100],E_pi0[100]; int index1_pi0[100], index2_pi0[100]; if(nClu!=2) continue; // if(nClu<2) continue; double distance_pivot_target(270.3); //SELECT CHARGE EXCHANGE OR DIFFRACTION if (scint1>140. && scint2>220.) distance_pivot_target = 376.8; else if(scint2<110.) distance_pivot_target = 376.8; else if(scint1<140. && scint2>400.) distance_pivot_target = 376.8; else if(scint1<140. && scint2>100. && scint2<220.) distance_pivot_target = 270.3; else continue; for (int ii=0; ii<nClu; ii++) { for (int jj=0; jj<nClu; jj++) { if(jj>49) continue; if(ii>=jj) continue; if(amplClu[ii]<.025*maxE) continue; if(amplClu[jj]<.025*maxE) continue; // if(amplClu[ii]+amplClu[jj]<0.35*maxE) continue; if(nCryClu[ii]<7) continue; if(nCryClu[jj]<7) continue; double dist = sqrt(pow((xClu[ii]-xClu[jj]),2) + pow((yClu[ii]-yClu[jj]),2) + pow((zClu[ii]-zClu[jj]),2)); double x_pivot = 135.4; double y_pivot = 4.; double z_pivot = 135.; double distance_pivot = sqrt(pow(x_pivot,2)+pow(y_pivot,2)+pow(z_pivot,2)); double x_versor = x_pivot / distance_pivot; double y_versor = y_pivot / distance_pivot; double z_versor = z_pivot / distance_pivot; double newx0 = xClu[ii] + x_versor * distance_pivot_target; double newy0 = yClu[ii] + y_versor * distance_pivot_target; double newz0 = zClu[ii] + z_versor * distance_pivot_target; double newx1 = xClu[jj] + x_versor * distance_pivot_target; double newy1 = yClu[jj] + y_versor * distance_pivot_target; double newz1 = zClu[jj] + z_versor * distance_pivot_target; double cost = newx0 * newx1 + newy0 * newy1 + newz0 * newz1; cost = cost / (sqrt(pow(newx0,2)+pow(newy0,2)+pow(newz0,2)) * sqrt(pow(newx1,2)+pow(newy1,2)+pow(newz1,2))); double masspi0; masspi0 = sqrt(2*amplClu[ii]*amplClu[jj]*(1-cost)); double lenght0 = sqrt(pow(newx0,2)+pow(newy0,2)+pow(newz0,2)); double px0 = newx0 * amplClu[ii] / lenght0; double py0 = newy0 * amplClu[ii] / lenght0; double pz0 = newz0 * amplClu[ii] / lenght0; double lenght1 = sqrt(pow(newx1,2)+pow(newy1,2)+pow(newz1,2)); double px1 = newx1 * amplClu[jj] / lenght1; double py1 = newy1 * amplClu[jj] / lenght1; double pz1 = newz1 * amplClu[jj] / lenght1; double pxpi0 = px0+px1; double pypi0 = py0+py1; double pzpi0 = pz0+pz1; double ppi0 = sqrt(pow(pxpi0,2)+pow(pypi0,2)+pow(pzpi0,2)); double enepi0 = amplClu[ii] + amplClu[jj]; double xpi0 = pxpi0 / ppi0 * (distance_pivot_target + distance_pivot); double ypi0 = pypi0 / ppi0 * (distance_pivot_target + distance_pivot); double zpi0 = pzpi0 / ppi0 * (distance_pivot_target + distance_pivot); // double xpi0 = pxpi0 / ppi0; // double ypi0 = pypi0 / ppi0; // double zpi0 = pzpi0 / ppi0; // cout << "X = " << xpi0 << ", " <<newx0 << ", " << newx1 << " Y = " << ypi0 << ", " << newy0 << ", " << newy1 << " Z = " << zpi0 << ", " << newz0 << ", " << newz1 << endl; // cout << lenght0 << " " << lenght1 << " " << sqrt(pow(xpi0,2)+pow(ypi0,2)+pow(zpi0,2)) << endl; // if(!abs((lenght0 + lenght1)/2 - sqrt(pow(xpi0,2)+pow(ypi0,2)+pow(zpi0,2)))>5) continue; // if(!(x_wcA[0]>-20.&&x_wcA[0]<20.)) continue; // if(!(y_wcA[0]>-20.&&y_wcA[0]<20.)) continue; // if(!(x_wcB[0]>-20.&&x_wcB[0]<20.)) continue; // if(!(y_wcB[0]>-20.&&y_wcB[0]<20.)) continue; massPi0.Fill(masspi0); massPi0_2.Fill(masspi0); massPi0full.Fill(masspi0); if(amplClu[ii]+amplClu[jj]>0.55*maxE) { masseta.Fill(masspi0); massetafull.Fill(masspi0); } massPi0vsE.Fill(masspi0,amplClu[ii]+amplClu[jj]); massPi0vsE1.Fill(masspi0,amplClu[ii]); massPi0vsE2.Fill(masspi0,amplClu[jj]); if(distance_pivot_target == 273.8) massPi0vsECE.Fill(masspi0,amplClu[ii]+amplClu[jj]); else massPi0vsEDF.Fill(masspi0,amplClu[ii]+amplClu[jj]); massPi0vsE_2.Fill(masspi0,amplClu[ii]+amplClu[jj]); massPi0vsdistance.Fill(masspi0,dist); masss1.Fill(masspi0,scint1); masss2.Fill(masspi0,scint2); if(masspi0>0.104&&masspi0<0.176) { if(masspi0>0.120&&masspi0<0.145) { distance.Fill(dist); energypi0.Fill(amplClu[ii]+amplClu[jj]); x.Fill(xClu[ii]); y.Fill(yClu[ii]); z.Fill(zClu[ii]); yz.Fill(yClu[ii],zClu[ii]); x.Fill(xClu[jj]); y.Fill(yClu[jj]); z.Fill(zClu[jj]); yz.Fill(yClu[jj],zClu[jj]); phi.Fill(phiClu[ii]); phi.Fill(phiClu[jj]); eta.Fill(etaClu[ii]); eta.Fill(etaClu[jj]); xyA.Fill(x_wcA[0],y_wcA[0]); xyB.Fill(x_wcB[0],y_wcB[0]); s1_1p.Fill(scint1); s2_1p.Fill(scint2); s1s2_1p.Fill(scint1,scint2); px_pi0[nPi0] = pxpi0; py_pi0[nPi0] = pypi0; pz_pi0[nPi0] = pzpi0; index1_pi0[nPi0] = ii; index2_pi0[nPi0] = jj; E_pi0[nPi0] = amplClu[ii]+amplClu[jj]; nPi0++; if(nPi0==1) mpi01 = masspi0; if(nPi0==2) mpi02 = masspi0; } if(masspi0>0.150&&masspi0<0.170) { s1_2p.Fill(scint1); s2_2p.Fill(scint2); s1s2_2p.Fill(scint1,scint2); } } if(masspi0>0.500&&masspi0<0.560&&lClu[ii]+amplClu[jj]>0.55*maxE) { yzeta.Fill(yClu[ii],zClu[ii]); yzeta.Fill(yClu[jj],zClu[jj]); } } } if(nPi0==2) { masspi01.Fill(mpi01); masspi02.Fill(mpi02); mp01mp02.Fill(mpi01,mpi02); } n_Pi0.Fill(nPi0); // if(nPi0==2){ for(int yy=0; yy<nPi0; yy++) { for (int kk=0; kk<nPi0; kk++) { if(kk>99) continue; if(yy>=kk) continue; if(index1_pi0[yy] == index1_pi0[kk]) continue; if(index1_pi0[yy] == index2_pi0[kk]) continue; if(index2_pi0[yy] == index1_pi0[kk]) continue; double px_pp = px_pi0[yy] + px_pi0[kk]; double py_pp = py_pi0[yy] + py_pi0[kk]; double pz_pp = pz_pi0[yy] + pz_pi0[kk]; double p_pp = sqrt(pow(px_pp,2)+pow(py_pp,2)+pow(pz_pp,2)); double E_pp = E_pi0[yy] + E_pi0[kk]; double masspi0pi0 = sqrt(E_pp*E_pp - p_pp*p_pp); if(E_pi0[yy]<.05*maxE) continue; if(E_pi0[kk]<.05*maxE) continue; if(E_pp>.75*maxE) { massPi0Pi0.Fill(masspi0pi0); massPi0Pi0full.Fill(masspi0pi0); } // double m1 = sqrt(pow(E_pi0[yy],2)-pow(px_pi0[yy],2)-pow(py_pi0[yy],2)-pow(pz_pi0[yy],2)); // double m2 = sqrt(pow(E_pi0[kk],2)-pow(px_pi0[kk],2)-pow(py_pi0[kk],2)-pow(pz_pi0[kk],2)); // cout << m1 << " " << m2 << " " << sqrt(pow(px_pi0[yy],2)+pow(py_pi0[yy],2)+pow(pz_pi0[yy],2)) << " " << E_pi0[yy] << " " << sqrt(pow(px_pi0[kk],2)+pow(py_pi0[kk],2)+pow(pz_pi0[kk],2)) << " " << E_pi0[kk] << " " << p_pp << " " << E_pp << " " << p_pp << endl; } } // if(nPi0==3){ for(int yy=0; yy<nPi0; yy++) { for (int kk=0; kk<nPi0; kk++) { for (int ii=0; ii<nPi0; ii++) { if(kk>99) continue; if(yy>=kk) continue; if(kk>=ii) continue; if(index1_pi0[yy] == index1_pi0[kk]) continue; if(index1_pi0[yy] == index2_pi0[kk]) continue; if(index2_pi0[yy] == index1_pi0[kk]) continue; if(index1_pi0[yy] == index1_pi0[ii]) continue; if(index1_pi0[yy] == index2_pi0[ii]) continue; if(index2_pi0[yy] == index1_pi0[ii]) continue; if(index1_pi0[ii] == index1_pi0[kk]) continue; if(index1_pi0[ii] == index2_pi0[kk]) continue; if(index2_pi0[ii] == index1_pi0[kk]) continue; double px_pp = px_pi0[ii] +px_pi0[yy] + px_pi0[kk]; double py_pp = py_pi0[ii] +py_pi0[yy] + py_pi0[kk]; double pz_pp = pz_pi0[ii] +pz_pi0[yy] + pz_pi0[kk]; double p_pp = sqrt(pow(px_pp,2)+pow(py_pp,2)+pow(pz_pp,2)); double E_pp = E_pi0[ii] + E_pi0[yy] + E_pi0[kk]; double masspi0pi0pi0 = sqrt(E_pp*E_pp - p_pp*p_pp); if(E_pi0[yy]<.08*maxE) continue; if(E_pi0[kk]<.08*maxE) continue; if(E_pi0[ii]<.08*maxE) continue; if(E_pp>.55*maxE) { masseta3pi0.Fill(masspi0pi0pi0); masseta3pi0full.Fill(masspi0pi0pi0); if(masspi0pi0pi0<.65) { yz3pi0.Fill(yClu[index1_pi0[kk]],zClu[index1_pi0[kk]]); yz3pi0.Fill(yClu[index2_pi0[kk]],zClu[index2_pi0[kk]]); yz3pi0.Fill(yClu[index1_pi0[yy]],zClu[index1_pi0[yy]]); yz3pi0.Fill(yClu[index2_pi0[yy]],zClu[index2_pi0[yy]]); yz3pi0.Fill(yClu[index1_pi0[ii]],zClu[index1_pi0[ii]]); yz3pi0.Fill(yClu[index2_pi0[ii]],zClu[index2_pi0[ii]]); } } cout << masspi0pi0pi0 << " " << E_pi0[yy] << " " << E_pi0[kk] << " " << E_pi0[ii] << endl; } } } } TCanvas *c0 = new TCanvas("c1"," ",200,10,500,500); c0->Clear(); massPi0.SetXTitle("m(#pi^{0}) [GeV]"); massPi0.SetStats(0); massPi0.SetTitle(""); massPi0.Draw(); c0->SaveAs("masspi0.eps"); TF1 *gaussian_p; gaussian_p = new TF1("gaupoly2",gaup2,0.03,2.8, 9) ; gaussian_p->SetLineColor(kBlue); gaussian_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2"); gaussian_p->SetParameter(0, .132); gaussian_p->SetParLimits(0, 0.12,0.145); gaussian_p->SetParLimits(1, 0.003,0.015); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParLimits(6, 0.12,0.145); gaussian_p->SetParameter(7, .020); gaussian_p->SetParLimits(7, 0.015,0.1); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); massPi0_2.SetStats(0); massPi0_2.SetXTitle("m(#gamma#gamma) [GeV/c^{2}]"); massPi0_2.SetYTitle("events/2.7MeV/c^{2}"); massPi0_2.SetTitleOffset(1.8,"Y"); massPi0_2.SetTitle(""); // massPi0_2.SetMarkerSize(1.); massPi0_2.Fit ("gaupoly2","L","",.03,.4) ; // massPi0_2.SetAxisRange(.0,.35); // massPi0_2.Draw("pe"); double mpi0= gaussian_p->GetParameter(0); double errmpi0= gaussian_p->GetParError(0); double smpi0= gaussian_p->GetParameter(1); double errsmpi0= gaussian_p->GetParError(1); double events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); double errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); char line[100]; TText tl; tl.SetTextSize(.03); sprintf(line, "mass1 = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.5, 0.85, line); sprintf(line, "sigma1 = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.5, 0.79, line); sprintf(line, "N(ev1) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.5, 0.73, line); c0->SaveAs("masspi0_comb.eps"); massPi0_2.SetMarkerSize(1.); massPi0_2.SetAxisRange(.03,.4); massPi0_2.Draw("pe"); TF1 *gaussian3_p; gaussian3_p = new TF1("gaupoly3_p",gaup2,0.03,2.8, 9) ; gaussian3_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2"); gaussian3_p->SetParameter(0, .131); gaussian3_p->SetParameter(1, 1.); gaussian3_p->SetParameter(2, 0.); gaussian3_p->SetParameter(3, gaussian_p->GetParameter(3)); gaussian3_p->SetParameter(4, gaussian_p->GetParameter(4)); gaussian3_p->SetParameter(5, gaussian_p->GetParameter(5)); gaussian3_p->SetParameter(6, 0.); gaussian3_p->SetParameter(7, 0.); gaussian3_p->SetParameter(8, 0.); // gaussian3_p->SetLineStyle(3); // gaussian3_p->SetFillStyle(34); // gaussian3_p->SetFillColor(kRed); gaussian3_p->SetLineStyle(3); gaussian3_p->Draw("same"); TPad *npad = new TPad("npad", "", 0.45, 0.45, 0.89, 0.89); npad->Draw(); npad->cd(); masseta.SetYTitle("events/10MeV/c^{2}"); masseta.SetTitleSize(0.06,"X"); masseta.SetTitleSize(0.06,"Y"); masseta.SetTitleOffset(.8,"X"); masseta.SetTitleOffset(1.,"Y"); gaussian_p->SetParameter(0, .55); gaussian_p->SetParameter(1, .03); gaussian_p->SetParLimits(0, 0.5,0.6); gaussian_p->SetParLimits(1, 0.005,0.04); gaussian_p->SetParameter(6, .65); gaussian_p->SetParLimits(6, 0.55,0.7); gaussian_p->SetParameter(7, .03); gaussian_p->SetParLimits(7, 0.05,0.03); gaussian_p->FixParameter(8, 0.); masseta.SetXTitle("m(#gamma#gamma) [GeV/c^{2}]"); // masseta.SetTitleSize(.4); masseta.SetStats(0); masseta.SetMarkerSize(.8); masseta.SetTitle(""); masseta.SetAxisRange(.38,.72); masseta.Fit ("gaupoly2","L","",.38,.72) ; masseta.Draw("pe"); // gaussian_p->SetLineColor(kBlue); // gaussian_p->Draw("same"); c0->SaveAs("masspi0_times.eps"); gaussian_p->SetParameter(0, .131); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParameter(6, .159); gaussian_p->SetParameter(7, .008); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.12,0.145); gaussian_p->SetParLimits(6, 0.145,0.6); gaussian_p->FixParameter(6, .135); gaussian_p->FixParameter(7, .022); massPi0_2.SetXTitle("m(#pi^{0}) [GeV]"); massPi0_2.SetStats(0); massPi0_2.SetTitle(""); massPi0_2.Fit ("gaupoly2","L","",.05,.4) ; cout << massPi0_2.Integral() << endl; mpi0= gaussian_p->GetParameter(0); errmpi0= gaussian_p->GetParError(0); smpi0= gaussian_p->GetParameter(1); errsmpi0= gaussian_p->GetParError(1); double mpi1= gaussian_p->GetParameter(6); double errmpi1= gaussian_p->GetParError(6); double smpi1= gaussian_p->GetParameter(7); double errsmpi1= gaussian_p->GetParError(7); events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); double events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); double errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); tl.SetTextSize(.03); sprintf(line, "mass1 = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.5, 0.85, line); sprintf(line, "sigma1 = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.5, 0.79, line); sprintf(line, "N(ev1) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.5, 0.73, line); sprintf(line, "mass2 = (%7.1f +/- %5.1f) MeV", mpi1*1000, errmpi1*1000); tl.DrawTextNDC(.5, 0.67, line); sprintf(line, "sigma2 = (%7.1f +/- %5.1f) MeV", smpi1*1000, errsmpi1*1000); tl.DrawTextNDC(.5, 0.61, line); sprintf(line, "N(ev2) = %7.1f +/- %5.1f", events1, errevents1); tl.DrawTextNDC(.5, 0.55, line); c0->SaveAs("masspi0_2.eps"); for (int h=2; h<16; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsE.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); if(tmpmass.Integral(45,55)>2.) { Y1vsE.SetBinContent(h,events); Y1vsE.SetBinError(h,errevents); Y1vsEbis.SetBinContent(h,events); } else { Y1vsE.SetBinContent(h,0); Y1vsE.SetBinError(h,0); Y1vsEbis.SetBinError(h,0); } Y2vsE.SetBinContent(h,events1); Y2vsE.SetBinError(h,errevents1); char tempchar[100]; sprintf(tempchar,"%d%s",h,"masspi0_2.eps"); c0->SaveAs(tempchar); } for (int h=2; h<16; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsE1.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); if(tmpmass.Integral(45,55)>2.) { Y1vsE1.SetBinContent(h,events); Y1vsE1.SetBinError(h,errevents); } else { Y1vsE1.SetBinContent(h,0); Y1vsE1.SetBinError(h,0); } } for (int h=2; h<16; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsE2.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); if(tmpmass.Integral(45,55)>2.) { Y1vsE2.SetBinContent(h,events); Y1vsE2.SetBinError(h,errevents); } else { Y1vsE2.SetBinContent(h,0); Y1vsE2.SetBinError(h,0); } } for (int h=2; h<16; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsECE.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); if(tmpmass.Integral(45,55)>2.) { Y1vsECE.SetBinContent(h,events); Y1vsECE.SetBinError(h,errevents); } else { Y1vsECE.SetBinContent(h,0); Y1vsECE.SetBinError(h,0); } // char tempchar[100]; // sprintf(tempchar,"%d%s",h,"masspi0_2_CE.eps"); // c0->SaveAs(tempchar); } for (int h=2; h<16; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsEDF.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); if(tmpmass.Integral(45,55)>2.) { Y1vsEDF.SetBinContent(h,events); Y1vsEDF.SetBinError(h,errevents); } else { Y1vsEDF.SetBinContent(h,0); Y1vsEDF.SetBinError(h,0); } // char tempchar[100]; // sprintf(tempchar,"%d%s",h,"masspi0_2_CE.eps"); // c0->SaveAs(tempchar); } for (int h=1; h<11; h++) { TH1D tmpmass("tmpmass","mass",150,0.,.4); for (int j=1; j<150; j++) { tmpmass.SetBinContent(j,massPi0vsdistance.GetBinContent(j,h)); } gaussian_p->SetParameter(0, .132); gaussian_p->SetParameter(1, .008); gaussian_p->SetParameter(2, 10.); gaussian_p->SetParLimits(2, 0.,1000.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, 0.,1000.); gaussian_p->SetParLimits(4, -100.,100.); gaussian_p->SetParLimits(5, -100.,100.); gaussian_p->SetParameter(6, .132); gaussian_p->SetParameter(7, .020); gaussian_p->SetParameter(8, 10.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->SetParLimits(0, 0.125,0.14); gaussian_p->SetParLimits(1, 0.003,0.01); gaussian_p->SetParLimits(6, 0.125,0.14); gaussian_p->SetParLimits(7, 0.01,0.1); tmpmass.Fit ("gaupoly2","LQ","",.05,.4) ; events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); Y1vsdist.SetBinContent(h,events); Y1vsdist.SetBinError(h,errevents); Y2vsdist.SetBinContent(h,events1); Y2vsdist.SetBinError(h,errevents1); cout << "1 gauss " << events << "+/-" << errevents << endl; cout << "2 gauss " << events1 << "+/-" << errevents1 << endl; } // gaussian_p->FixParameter(0, .1305); // gaussian_p->FixParameter(6, .1595); // for (int h=2;h<12;h++){ // TH1D tmpmass("tmpmass","mass",150,0.,.4); // for (int j=1;j<150;j++){ // tmpmass.SetBinContent(j,massPi0vsE.GetBinContent(j,h)); // } // gaussian_p->FixParameter(1, .008); // gaussian_p->FixParameter(7, .009); // gaussian_p->SetParameter(2, 10.); // gaussian_p->SetParameter(3, 1.); // gaussian_p->SetParameter(4, 0.); // gaussian_p->SetParameter(5, 0.); // gaussian_p->SetParameter(8, 10.); // // gaussian_p->FixParameter(8, .0); // tmpmass.Fit ("gaupoly2","L","",.05,.4) ; // events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); // errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); // events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); // errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); // Y1vsE.SetBinContent(h,events); // Y1vsE.SetBinError(h,errevents); // Y2vsE.SetBinContent(h,events1); // Y2vsE.SetBinError(h,errevents1); // cout << "1 gauss " << events << "+/-" << errevents << endl; // cout << "2 gauss " << events1 << "+/-" << errevents1 << endl; // char tempchar[100]; // sprintf(tempchar,"%d%s",h,"masspi0_2.eps"); // c0->SaveAs(tempchar); // } // for (int h=1;h<11;h++){ // TH1D tmpmass("tmpmass","mass",150,0.,.4); // for (int j=1;j<150;j++){ // tmpmass.SetBinContent(j,massPi0vsdistance.GetBinContent(j,h)); // } // gaussian_p->FixParameter(1, .008); // gaussian_p->FixParameter(7, .009); // gaussian_p->SetParameter(2, 10.); // gaussian_p->SetParameter(3, 1.); // gaussian_p->SetParameter(4, 0.); // gaussian_p->SetParameter(5, 0.); // // gaussian_p->SetParameter(8, 10.); // tmpmass.Fit ("gaupoly2","L","",.05,.4) ; // events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1); // errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1); // events1= gaussian_p->GetParameter(8)/massPi0_2.GetBinWidth(1); // errevents1 = gaussian_p->GetParError(8)/massPi0_2.GetBinWidth(1); // Y1vsdist.SetBinContent(h,events); // Y1vsdist.SetBinError(h,errevents); // Y2vsdist.SetBinContent(h,events1); // Y2vsdist.SetBinError(h,errevents1); // cout << "1 gauss " << events << "+/-" << errevents << endl; // cout << "2 gauss " << events1 << "+/-" << errevents1 << endl; // } gaussian_p->SetParameter(0, .55); gaussian_p->SetParameter(1, .03); gaussian_p->SetParLimits(0, 0.5,0.6); gaussian_p->SetParLimits(1, 0.005,0.04); gaussian_p->SetParameter(6, .65); gaussian_p->SetParLimits(6, 0.55,0.7); gaussian_p->SetParameter(7, .03); gaussian_p->SetParLimits(7, 0.05,0.03); gaussian_p->FixParameter(8, 0.); masseta.SetXTitle("m(#eta) [GeV]"); masseta.SetStats(0); masseta.SetMarkerSize(1.); masseta.SetTitle(""); masseta.Fit ("gaupoly2","L","",.3,.68) ; masseta.Draw("pe"); cout << masseta.Integral() << endl; mpi0= gaussian_p->GetParameter(0); errmpi0= gaussian_p->GetParError(0); smpi0= gaussian_p->GetParameter(1); errsmpi0= gaussian_p->GetParError(1); events= gaussian_p->GetParameter(2)/masseta.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/masseta.GetBinWidth(1); tl.SetTextSize(.03); sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.13, 0.85, line); sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.13, 0.79, line); sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.13, 0.73, line); c0->SaveAs("masseta.eps"); gaussian_p->SetParLimits(8, 0.,1000.); masseta.Fit ("gaupoly2","L","",.3,.75) ; masseta.Draw("pe"); cout << masseta.Integral() << endl; mpi0= gaussian_p->GetParameter(0); errmpi0= gaussian_p->GetParError(0); smpi0= gaussian_p->GetParameter(1); errsmpi0= gaussian_p->GetParError(1); events= gaussian_p->GetParameter(2)/masseta.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/masseta.GetBinWidth(1); tl.SetTextSize(.03); sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.13, 0.85, line); sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.13, 0.79, line); sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.13, 0.73, line); c0->SaveAs("masseta2.eps"); gaussian_p->SetParLimits(1, 0.005,0.08); gaussian_p->SetParLimits(6, 0.4,0.9); gaussian_p->SetParameter(6, 0.7); gaussian_p->SetParLimits(7, .1,3.0); gaussian_p->SetParameter(7, 1.); gaussian_p->SetParLimits(8, 0.,1000.); gaussian_p->FixParameter(3, 0.); gaussian_p->FixParameter(4, 0.); gaussian_p->FixParameter(5, 0.); masseta3pi0.SetXTitle("m(#eta) [GeV]"); masseta3pi0.SetStats(0); masseta3pi0.SetMarkerSize(1.); masseta3pi0.SetTitle(""); masseta3pi0.Fit ("gaupoly2","L","",.35,1.2) ; masseta3pi0.Draw("pe"); mpi0= gaussian_p->GetParameter(0); errmpi0= gaussian_p->GetParError(0); smpi0= gaussian_p->GetParameter(1); errsmpi0= gaussian_p->GetParError(1); events= gaussian_p->GetParameter(2)/masseta3pi0.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/masseta3pi0.GetBinWidth(1); TF1 *gaussian2_p; gaussian2_p = new TF1("gaupoly2_@",gaup2,0.03,2.8, 9) ; gaussian2_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2"); gaussian2_p->SetParameter(0, .131); gaussian2_p->SetParameter(1, 1.); gaussian2_p->SetParameter(2, 0.); gaussian2_p->SetParameter(3, 0.); gaussian2_p->SetParameter(4, 0.); gaussian2_p->SetParameter(5, 0.); gaussian2_p->SetParameter(6, gaussian_p->GetParameter(6)); gaussian2_p->SetParameter(7, gaussian_p->GetParameter(7)); gaussian2_p->SetParameter(8, gaussian_p->GetParameter(8)); gaussian2_p->SetLineStyle(3); gaussian2_p->Draw("same"); tl.SetTextSize(.03); sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.53, 0.85, line); sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.53, 0.79, line); sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.53, 0.73, line); c0->SaveAs("masseta3pi0.eps"); masspi01.SetXTitle("m(#pi^{0}) [GeV]"); masspi01.SetStats(0); masspi01.SetTitle(""); masspi01.Fit ("gaupoly2","L","",.03,.4) ; c0->SaveAs("mpi01.eps"); masspi02.SetXTitle("m(#pi^{0}) [GeV]"); masspi02.SetStats(0); masspi02.SetTitle(""); masspi02.Fit ("gaupoly2","L","",.03,.4) ; c0->SaveAs("mpi02.eps"); mp01mp02.SetXTitle("m(#pi^{0})_{1} [GeV]"); mp01mp02.SetYTitle("m(#pi^{0})_{2} [GeV]"); mp01mp02.SetStats(0); mp01mp02.SetTitle(""); mp01mp02.Draw("colz") ; c0->SaveAs("mpi01mpi02.eps"); distance.SetXTitle("#Delta(clusters) [cm]"); distance.SetStats(0); distance.SetTitle(""); distance.Draw(); c0->SaveAs("distance.eps"); energypi0.SetXTitle("E(#pi^{0}) [GeV]"); energypi0.SetStats(0); energypi0.SetTitle(""); energypi0.Draw(); c0->SaveAs("energypi0.eps"); x.Draw(); c0->SaveAs("x.eps"); y.Draw(); c0->SaveAs("y.eps"); z.Draw(); c0->SaveAs("z.eps"); yz.Draw("colz"); c0->SaveAs("yz.eps"); yzeta.Draw("colz"); c0->SaveAs("yzeta.eps"); yz3pi0.Draw("colz"); c0->SaveAs("yz3pi0.eps"); phi.Draw(); c0->SaveAs("phi.eps"); eta.Draw(); c0->SaveAs("eta.eps"); xyA.Draw("box"); c0->SaveAs("xyA.eps"); xyB.Draw("box"); c0->SaveAs("xyB.eps"); massPi0vsE.SetStats(0); massPi0vsE.SetXTitle("m(#pi^{0}) [GeV]"); massPi0vsE.SetYTitle("E(#pi^{0}) [GeV]"); massPi0vsE.Draw("colz"); c0->SaveAs("massvsE.eps"); massPi0vsE_2.SetStats(0); massPi0vsE_2.SetXTitle("m(#pi^{0}) [GeV]"); massPi0vsE_2.SetYTitle("E(#pi^{0}) [GeV]"); massPi0vsE_2.Draw("colz"); c0->SaveAs("massvsE_2.eps"); massPi0vsdistance.SetStats(0); massPi0vsdistance.SetXTitle("m(#pi^{0}) [GeV]"); massPi0vsdistance.SetYTitle("distance [cm]"); massPi0vsdistance.Draw("colz"); c0->SaveAs("massvsdist.eps"); Y1vsE.SetMaximum(Y1vsE.GetMaximum()*1.3); Y1vsE.SetMinimum(0.); Y1vsE.SetMarkerSize(1.); Y1vsE.SetStats(0); Y1vsE.SetTitle(""); Y1vsE.SetXTitle("E(#pi^{0}) [GeV]"); Y1vsE.Draw("pe"); c0->SaveAs("Y1vsE.eps"); Y1vsECE.SetMaximum(Y1vsECE.GetMaximum()*1.3); Y1vsECE.SetMinimum(0.); Y1vsECE.SetMarkerSize(1.); Y1vsECE.SetStats(0); Y1vsECE.SetTitle(""); Y1vsECE.SetXTitle("E(#pi^{0}) [GeV]"); Y1vsECE.Draw("pe"); c0->SaveAs("Y1vsECE.eps"); Y1vsEDF.SetMaximum(Y1vsEDF.GetMaximum()*1.3); Y1vsEDF.SetMinimum(0.); Y1vsEDF.SetMarkerSize(1.); Y1vsEDF.SetStats(0); Y1vsEDF.SetTitle(""); Y1vsEDF.SetXTitle("E(#pi^{0}) [GeV]"); Y1vsEDF.Draw("pe"); c0->SaveAs("Y1vsEDF.eps"); Y1vsE.Draw("pe"); Y1vsECE.SetFillColor(38); Y1vsEbis.SetFillColor(38); Y1vsEbis.Draw("same"); Y1vsEDF.SetFillColor(kYellow); Y1vsEDF.Draw("same"); Y1vsE.Draw("pesame"); TLegendEntry *legge; TLegend *leg; leg = new TLegend(0.16,0.63,0.4,0.89); leg->SetFillStyle(0); leg->SetBorderSize(0.); leg->SetTextSize(0.06); leg->SetFillColor(0); legge = leg->AddEntry(&Y1vsECE, "charge ex.", "f"); legge = leg->AddEntry(&Y1vsEDF, "diffr.", "f"); legge = leg->AddEntry(&Y1vsE, "all", "p"); leg->Draw(); Y1vsE1.SetMaximum(Y1vsE1.GetMaximum()*1.3); Y1vsE1.SetMinimum(0.); Y1vsE1.SetMarkerSize(1.); Y1vsE1.SetStats(0); Y1vsE1.SetTitle(""); Y1vsE1.SetXTitle("E1(#gamma) [GeV]"); Y1vsE1.Draw("pe"); c0->SaveAs("Y1vsE1.eps"); Y1vsE2.SetMaximum(Y1vsE2.GetMaximum()*1.3); Y1vsE2.SetMinimum(0.); Y1vsE2.SetMarkerSize(1.); Y1vsE2.SetStats(0); Y1vsE2.SetTitle(""); Y1vsE2.SetXTitle("E2(#gamma) [GeV]"); Y1vsE2.Draw("pe"); c0->SaveAs("Y1vsE2.eps"); c0->SaveAs("Y1vsEcomb.eps"); Y2vsE.SetMaximum(Y2vsE.GetMaximum()*1.3); Y2vsE.SetMinimum(0.); Y2vsE.SetStats(0); Y2vsE.SetTitle(""); Y2vsE.SetMarkerSize(1.); Y2vsE.SetXTitle("E(#pi^{0}) [GeV]"); Y2vsE.Draw("pe"); c0->SaveAs("Y2vsE.eps"); Y1vsdist.SetMaximum(Y1vsdist.GetMaximum()*1.3); Y1vsdist.SetMinimum(0.); Y1vsdist.SetStats(0); Y1vsdist.SetTitle(""); Y1vsdist.SetMarkerSize(1.); Y1vsdist.SetXTitle("distance [cm]"); Y1vsdist.Draw("pe"); c0->SaveAs("Y1vsdist.eps"); Y2vsdist.SetMaximum(Y2vsdist.GetMaximum()*1.3); Y2vsdist.SetMinimum(0.); Y2vsdist.SetStats(0); Y2vsdist.SetTitle(""); Y2vsdist.SetMarkerSize(1.); Y2vsdist.SetXTitle("distance [cm]"); Y2vsdist.Draw("pe"); c0->SaveAs("Y2vsdist.eps"); s1_1p.SetXTitle("ADC counts"); s1_1p.Draw(); c0->SaveAs("s1_1p.eps"); s2_1p.SetXTitle("ADC counts"); s2_1p.Draw(); c0->SaveAs("s2_1p.eps"); s1_2p.SetXTitle("ADC counts"); s1_2p.Draw(); c0->SaveAs("s1_2p.eps"); s2_2p.SetXTitle("ADC counts"); s2_2p.Draw(); c0->SaveAs("s2_2p.eps"); masss1.SetXTitle("m(#pi^{0})_{1} [GeV]"); masss1.SetYTitle("S1 ADC counts"); masss1.SetStats(0); masss1.SetTitle(""); masss1.Draw("colz") ; c0->SaveAs("massvsS1.eps"); masss2.SetXTitle("m(#pi^{0})_{1} [GeV]"); masss2.SetYTitle("S2 ADC counts"); masss2.SetStats(0); masss2.SetTitle(""); masss2.Draw("colz") ; c0->SaveAs("massvsS2.eps"); s1s2_1p.SetXTitle("S1 ADC counts 1' peak"); s1s2_1p.SetYTitle("S2 ADC counts 1' peak"); // s1s2_1p.SetStats(0); s1s2_1p.SetTitle(""); s1s2_1p.Draw("colz") ; c0->SaveAs("s1s2_1p.eps"); s1s2_2p.SetXTitle("S1 ADC counts 2' peak"); s1s2_2p.SetYTitle("S2 ADC counts 2' peak"); // s1s2_2p.SetStats(0); s1s2_2p.SetTitle(""); s1s2_2p.Draw("colz") ; c0->SaveAs("s1s2_2p.eps"); gaussian_p->SetParameter(0, 1.27); gaussian_p->SetParameter(1, .1); gaussian_p->SetParameter(2, 1.); gaussian_p->SetParameter(3, 1.); gaussian_p->SetParameter(4, 0.); gaussian_p->SetParameter(5, 0.); gaussian_p->SetParLimits(3, -1000.,1000.); gaussian_p->SetParLimits(4, -1000.,1000.); gaussian_p->SetParLimits(5, -1000.,1000.); gaussian_p->SetParLimits(0, 1.2,1.4); gaussian_p->SetParLimits(1, 0.03,0.2); // gaussian_p->FixParameter(0, 1.27); // gaussian_p->FixParameter(1, .1); gaussian_p->FixParameter(6, 1.); gaussian_p->FixParameter(7, 1.); gaussian_p->FixParameter(8, 0.); massPi0Pi0.SetXTitle("m(#pi^{0}#pi^{0}) [GeV]"); massPi0Pi0.SetStats(0); massPi0Pi0.SetTitle(""); massPi0Pi0.SetMarkerSize(1.); massPi0Pi0.Fit ("gaupoly2","L","",.75,2.2) ; massPi0Pi0.Draw("pe"); mpi0= gaussian_p->GetParameter(0); errmpi0= gaussian_p->GetParError(0); smpi0= gaussian_p->GetParameter(1); errsmpi0= gaussian_p->GetParError(1); events= gaussian_p->GetParameter(2)/massPi0Pi0.GetBinWidth(1); errevents = gaussian_p->GetParError(2)/massPi0Pi0.GetBinWidth(1); tl.SetTextSize(.03); sprintf(line, "mass = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000); tl.DrawTextNDC(.5, 0.85, line); sprintf(line, "sigma = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000); tl.DrawTextNDC(.5, 0.79, line); sprintf(line, "N(ev) = %7.1f +/- %5.1f", events, errevents); tl.DrawTextNDC(.5, 0.73, line); c0->SaveAs("masspi0pi0.eps"); // massPi0Pi0.SetXTitle("m(#pi^{0}#pi^{0}) [GeV]"); // // massPi0Pi0.SetStats(0); // massPi0Pi0.SetTitle(""); // massPi0Pi0.Draw(); // c0->SaveAs("masspi0pi0.eps"); n_Pi0.SetXTitle("N(#pi^{0})"); n_Pi0.SetTitle(""); n_Pi0.Draw(); c0->SaveAs("nPi0.eps"); massPi0full.SetXTitle("m(#gamma #gamma) [GeV]"); massPi0full.SetStats(0); massPi0full.SetTitle(""); massPi0full.Draw("") ; c0->SaveAs("massPi0full.eps"); massPi0Pi0full.SetXTitle("m(#pi^{0} #pi^{0}) [GeV]"); massPi0Pi0full.SetStats(0); massPi0Pi0full.SetTitle(""); massPi0Pi0full.Draw("") ; c0->SaveAs("massPi0Pi0full.eps"); massetafull.SetXTitle("m(#gamma #gamma) [GeV]"); massetafull.SetStats(0); massetafull.SetTitle(""); massetafull.Draw("") ; c0->SaveAs("massetafull.eps"); masseta3pi0full.SetXTitle("m(#eta #rightarrow #pi^{0} #pi^{0} #pi^{0}) [GeV]"); masseta3pi0full.SetStats(0); masseta3pi0full.SetTitle(""); masseta3pi0full.Draw("") ; c0->SaveAs("masseta3pi0full.eps"); }
void crossfeeds_nondiag(TString title, TString bkgfile, TString epsfile, TString txtfile, Double_t alpha_, Double_t mass_, Double_t n_, Double_t sigma_ ) { RooRealVar mbc("mbc", "m_{BC}", 1.83, 1.89, "GeV"); RooRealVar ebeam("ebeam", "Ebeam", 0., 100., "GeV"); RooRealVar chg("chg", "Charge", -2, 2); RooCategory passed("passed", "Event should be used for plot"); passed.defineType("yes", 1); passed.defineType("no", 0); RooRealVar arg_cutoff ("arg_cutoff", "Argus cutoff", 1.8865, 1.885, 1.8875,"GeV"); RooRealVar arg_slope ("arg_slope", "Argus slope", -13, -100, 40); RooRealVar mbc_float ("mbc_float", "Floating D mass", mass_, "GeV"); RooRealVar sigma ("sigma", "CB width", sigma_, "GeV"); RooRealVar alpha("alpha", "CB shape cutoff", alpha_); RooRealVar n("n", "CB tail parameter", n_); RooCBShape cb_float ("cb_float", "Floating Crystal Barrel", mbc, mbc_float, sigma, alpha, n); RooArgusBG argus("argus", "Argus BG", mbc, arg_cutoff, arg_slope); RooRealVar yld("yield", "D yield", 0, -30, 100000); RooRealVar bkg("bkg", "Background", 20, 0, 40000); // Build pdf RooAddPdf sumpdf_float("sumpdf_float", "Generic D sum pdf", RooArgList(cb_float, argus), RooArgList(yld, bkg)); RooDataSet* dset = RooDataSet::read(bkgfile, RooArgList(mbc, ebeam, passed), "", ""); RooPlot* xframe = mbc.frame(); RooDataSet* dset2 = dset->reduce("passed==1"); dset2->plotOn(xframe); // RooFitResult* rv = sumpdf_float.fitTo(*dset2, Extended(kTRUE), Save(kTRUE), // Hesse(kTRUE), Verbose(kTRUE)); RooFitResult* rv = sumpdf_float.fitTo(*dset2, "ermh"); sumpdf_float.paramOn(xframe, dset2); if ((yld.getVal() < 0) && (-yld.getVal()/bkg.getVal() > 0.5)){ yld.setVal(0); bkg.setVal(1); } sumpdf_float.plotOn(xframe); sumpdf_float.plotOn(xframe, Components(RooArgSet(argus)), LineColor(kRed), LineStyle(kDashed)); TCanvas* c1 = new TCanvas("c1","Canvas", 2); xframe->SetTitleOffset(2.2, "Y"); xframe->SetTitleOffset(1.1, "X"); xframe->SetTitle(title); c1->SetLeftMargin(0.17); xframe->Draw(); if ( rv && rv->covQual() != 3){ // fit has failed TText *txt = new TText(); txt->SetTextSize(.08); txt->SetTextAlign(22); txt->SetTextAngle(30); txt->DrawTextNDC(0.5, 0.5, "FAILED"); } c1->Update(); c1->Print(epsfile); c1->Clear(); FILE* table = fopen(txtfile.Data(), "w+"); fprintf(table, "Name\t|| Value\t|| Error\n"); // fprintf(table, "yldsigma\t| %.10f\t| \n", yld.getVal()/yld.getError()); fprintf(table, "entries\t| %.10f\t| \n", dset->numEntries()); fprintf(table, "yld\t| %.10f\t| %.10f\n", yld.getVal(), yld.getError()); // fprintf(table, "ratio\t| %.10f\t| \n", yld.getVal()/dset->numEntries()); // fprintf(table, "ratioerr\t| %.10f\t| \n", yld.getError()/dset->numEntries()); fclose(table); cout << "Saved output as: " << txtfile << endl; rv->Delete(); }
// main method void LEDRef_evtdis(const int runno = 615, const int gainv = 0, /*0=low, 1=high*/ const int evtnum= -10, int ymax=1023, // set the scale of plots const int delay = 1) // -1=no delay, wait for input, X>=0 => sleep aprox. X sec. after making plot { // set ranges to plot const int strip_f = 0; // first const int strip_l = NSTRIPS - 1; const int nsamples = 65; // number of ADC time samples per channel and event const int saveplot = 0; const int numbering = 1; // 0: no numbering, 1: nubering on each plot const int dofit = 0; // 0: no fit, 1: try to fit the spectra const int debug = 0; const float gammaN = 2; // end of setup // Assume we are just interested in the 1st segment, _0.root below for fname* Char_t fname[256]; sprintf(fname, "/local/data/Run_%09d.Seq_1A.Stream_0.root",runno); cout << "TOTCHAN " << TOTCHAN << endl; // set up a raw reader of the data AliRawReader *rawReader = NULL; rawReader = new AliRawReaderRoot(fname); AliCaloRawStream *in = NULL; in = new AliCaloRawStream(rawReader,"EMCAL"); // set up histograms TH1F *hfit[TOTCHAN]; TF1 *f1[TOTCHAN]; char ch_label[TOTCHAN][100]; char buff1[100]; char name[80]; for(int i=0; i<TOTCHAN; i++) { sprintf(buff1,"hfit_%d",i); hfit[i] = new TH1F(buff1,"hfit", nsamples , -0.5, nsamples - 0.5); hfit[i]->SetDirectory(0); sprintf(name,"f1_%d",i); f1[i] = new TF1(name,fitfun,0,70,5); f1[i]->SetLineWidth(2); f1[i]->SetLineColor(2); // int idx = istrip + NSTRIPS * gain; // encoding used later int gain = i / (NSTRIPS); int istrip = i % NSTRIPS; sprintf(ch_label[i], "Strip%02d", istrip); } TCanvas *cc1 = new TCanvas("cc1","3 columns of 8 strips each",600,800); int numcol = NSETS; int numrow = NSTRIPS_IN_SET; cc1->Divide(numcol, numrow); TText *t = new TText; t->SetTextSize(0.17); int clr[2] = {4,2}; // colors // figure out which events we should look at int firstevent = evtnum; int lastevent = evtnum; if (evtnum < 0) { // get a bunch of events firstevent = 0; lastevent = - evtnum; } if (evtnum == 0) { // get all events firstevent = 0; lastevent = 1000000; } Int_t iev =0; AliRawEventHeaderBase *aliHeader=NULL; while ( rawReader->NextEvent() && iev < firstevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); iev++; } // loop over selected events while ( rawReader->NextEvent() && iev <= lastevent) { aliHeader = (AliRawEventHeaderBase*) rawReader->GetEventHeader(); int runNumber = aliHeader->Get("RunNb"); cout << "Found run number " << runNumber << endl; // reset histograms for(int i=0; i<TOTCHAN; i++) { hfit[i]->Reset(); } // get events (the "1" ensures that we actually select all events for now) if ( 1 || aliHeader->Get("Type") == AliRawEventHeaderBase::kPhysicsEvent ) { const UInt_t * evtId = aliHeader->GetP("Id"); int evno_raw = (int) evtId[0]; int timestamp = aliHeader->Get("Timestamp"); cout << " evno " << evno_raw << " size " << aliHeader->GetEventSize() << " type " << aliHeader->Get("Type") << " type name " << aliHeader->GetTypeName() << " timestamp " << timestamp << endl; /// process_event stream while ( in->Next() ) { int strip = in->GetColumn(); int gain = in->GetRow(); if (in->IsLEDMonData()) { int idx = strip + NSTRIPS*gain; //cout << "hist idx " << idx << endl; if (idx < 0 || idx > TOTCHAN) { cout << "Hist idx out of range: " << idx << endl; } else { // reasonable range of idx hfit[idx]->SetBinContent(in->GetTime(), in->GetSignal()); } } // LED Ref data only } // Raw data read // Next: let's actually plot the data.. for (Int_t strip = strip_f; strip <= strip_l; strip++) { int idx = strip + NSTRIPS*gainv; // which set/column does the strip belong in int iset = strip / NSTRIPS_IN_SET; int within_set = strip % NSTRIPS_IN_SET; // on which pad should we plot it? int pad_id = (NSTRIPS_IN_SET-1-within_set)*NSETS + iset + 1; cout << "strip " << strip << ". set="<< iset << ", within_set=" << within_set << ", pad=" << pad_id << endl; cc1->cd(pad_id); hfit[idx]->SetTitle(""); hfit[idx]->SetFillColor(5); hfit[idx]->SetMaximum(ymax); hfit[idx]->SetMinimum(0); // we may or may not decide to fit the data if (dofit) { f1[i]->SetParameter(0, 0); // initial guess; zero amplitude :=) hfit[idx]->Fit(f1[i]); } hfit[idx]->Draw(); if( numbering ) { t->SetTextColor(clr[gainv]); t->DrawTextNDC(0.65,0.65,ch_label[idx]); } } // add some extra text on the canvas // print a box showing run #, evt #, and timestamp cc1->cd(); // first draw transparent pad TPad *trans = new TPad("trans","",0,0,1,1); trans->SetFillStyle(4000); trans->Draw(); trans->cd(); // then draw text TPaveText *label = new TPaveText(.2,.11,.8,.14,"NDC"); // label->Clear(); label->SetBorderSize(1); label->SetFillColor(0); label->SetLineColor(clr[gainv]); label->SetTextColor(clr[gainv]); //label->SetFillStyle(0); TDatime d; d.Set(timestamp); sprintf(name,"Run %d, Event %d, Hist Max %d, %s",runno,iev,ymax,d.AsString()); label->AddText(name); label->Draw(); cc1->Update(); cout << "Done" << endl; // some shenanigans to hold the plotting, if requested if (firstevent != lastevent) { if (delay == -1) { // wait for character input before proceeding cout << " enter y to proceed " << endl; char dummy[2]; cin >> dummy; cout << " read " << dummy << endl; if (strcmp(dummy, "y")==0) { cout << " ok, continuing with event " << iev+1 << endl; } else { cout << " ok, exiting " << endl; //exit(1); } } else { cout << "Sleeping for " << delay * 500 << endl; gSystem->Sleep(delay * 500); } } // save plot, if setup/requested to do so char plotname[100]; if (saveplot==1) { sprintf(plotname,"Run_%d_LEDRef_Ev%d_Gain%d_MaxHist%d.gif", runno,iev,gainv,ymax); cout <<"SAVING plot:"<< plotname << endl; cc1->SaveAs(plotname); } } // event selection
void t1bbbb_pl_plots() { gStyle->SetPadGridX(1) ; gStyle->SetPadGridY(1) ; gStyle->SetOptStat(0.) ; gStyle->SetOptTitle(0) ; gStyle->SetPadRightMargin(0.20) ; gStyle->SetPadLeftMargin(0.15) ; gStyle->SetPadBottomMargin(0.15) ; gStyle->SetTitleOffset(1.4,"x") ; gStyle->SetTitleOffset(1.4,"y") ; gStyle->SetBarOffset(0.1) ; TText* text = new TText() ; TCanvas* cxsec = new TCanvas("cxsec","cxsec") ; gPad->SetLogz(1) ; TPaletteAxis* paxis(0x0) ; loadHist("an-11-257-v3-files/output-files/an-scanplot-unblind-t1bbbb-withcontam-ge1b-loose.root","ge1bloose" ) ; loadHist("an-11-257-v3-files/output-files/an-scanplot-unblind-t1bbbb-withcontam-ge1b-tight.root","ge1btight" ) ; loadHist("an-11-257-v3-files/output-files/an-scanplot-unblind-t1bbbb-withcontam-ge2b-loose.root","ge2bloose" ) ; loadHist("an-11-257-v3-files/output-files/an-scanplot-unblind-t1bbbb-withcontam-ge2b-tight.root","ge2btight" ) ; //-------- TH2F* hxsecul_ge1bloose = (TH2F*) gDirectory->FindObject("ge1bloose_hsusyscanXsecul") ; hxsecul_ge1bloose->SetXTitle("Gluino mass (GeV)") ; hxsecul_ge1bloose->SetYTitle("LSP mass (GeV)") ; hxsecul_ge1bloose->UseCurrentStyle() ; hxsecul_ge1bloose->SetMinimum(0.010) ; hxsecul_ge1bloose->SetMaximum(150) ; paxis = (TPaletteAxis*)hxsecul_ge1bloose->GetListOfFunctions()->FindObject("palette"); paxis->SetX1NDC(0.82) ; paxis->SetX2NDC(0.86) ; paxis->SetY1NDC(0.15) ; paxis->SetY2NDC(0.90) ; hxsecul_ge1bloose->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Maximum cross section [pb](PL 95% UL)" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge1bloose, PL cross section upper limit") ; cxsec->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-pl-xsecul-ge1bloose.png") ; //-------- TH2F* hxsecul_ge1btight = (TH2F*) gDirectory->FindObject("ge1btight_hsusyscanXsecul") ; hxsecul_ge1btight->SetXTitle("Gluino mass (GeV)") ; hxsecul_ge1btight->SetYTitle("LSP mass (GeV)") ; hxsecul_ge1btight->UseCurrentStyle() ; hxsecul_ge1btight->SetMinimum(0.010) ; hxsecul_ge1btight->SetMaximum(150) ; paxis = (TPaletteAxis*)hxsecul_ge1btight->GetListOfFunctions()->FindObject("palette"); paxis->SetX1NDC(0.82) ; paxis->SetX2NDC(0.86) ; paxis->SetY1NDC(0.15) ; paxis->SetY2NDC(0.90) ; hxsecul_ge1btight->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Maximum cross section [pb](PL 95% UL)" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge1btight, PL cross section upper limit") ; cxsec->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-pl-xsecul-ge1btight.png") ; //-------- TH2F* hxsecul_ge2bloose = (TH2F*) gDirectory->FindObject("ge2bloose_hsusyscanXsecul") ; hxsecul_ge2bloose->SetXTitle("Gluino mass (GeV)") ; hxsecul_ge2bloose->SetYTitle("LSP mass (GeV)") ; hxsecul_ge2bloose->UseCurrentStyle() ; hxsecul_ge2bloose->SetMinimum(0.010) ; hxsecul_ge2bloose->SetMaximum(150) ; paxis = (TPaletteAxis*)hxsecul_ge2bloose->GetListOfFunctions()->FindObject("palette"); paxis->SetX1NDC(0.82) ; paxis->SetX2NDC(0.86) ; paxis->SetY1NDC(0.15) ; paxis->SetY2NDC(0.90) ; hxsecul_ge2bloose->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Maximum cross section [pb](PL 95% UL)" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge2bloose, PL cross section upper limit") ; cxsec->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-pl-xsecul-ge2bloose.png") ; //-------- TH2F* hxsecul_ge2btight = (TH2F*) gDirectory->FindObject("ge2btight_hsusyscanXsecul") ; hxsecul_ge2btight->SetXTitle("Gluino mass (GeV)") ; hxsecul_ge2btight->SetYTitle("LSP mass (GeV)") ; hxsecul_ge2btight->UseCurrentStyle() ; hxsecul_ge2btight->SetMinimum(0.010) ; hxsecul_ge2btight->SetMaximum(150) ; paxis = (TPaletteAxis*)hxsecul_ge2btight->GetListOfFunctions()->FindObject("palette"); paxis->SetX1NDC(0.82) ; paxis->SetX2NDC(0.86) ; paxis->SetY1NDC(0.15) ; paxis->SetY2NDC(0.90) ; hxsecul_ge2btight->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Maximum cross section [pb](PL 95% UL)" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge2btight, PL cross section upper limit") ; cxsec->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-pl-xsecul-ge2btight.png") ; TCanvas* ceff = new TCanvas("ceff","ceff") ; gPad->SetLogz(0) ; //-------- TH2F* heff_ge1bloose = (TH2F*) gDirectory->FindObject("ge1bloose_hsusyscanEfficiency") ; cout << "heff_ge1bloose pointer: " << heff_ge1bloose << endl ; heff_ge1bloose->SetXTitle("Gluino mass (GeV)") ; heff_ge1bloose->SetYTitle("LSP mass (GeV)") ; heff_ge1bloose->UseCurrentStyle() ; heff_ge1bloose->SetMinimum(0.0) ; heff_ge1bloose->SetMaximum(0.6) ; heff_ge1bloose->DrawCopy("colz") ; heff_ge1bloose->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Efficiency" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge1bloose, Efficiency") ; ceff->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-eff-ge1bloose.png") ; //-------- TH2F* heff_ge1btight = (TH2F*) gDirectory->FindObject("ge1btight_hsusyscanEfficiency") ; cout << "heff_ge1btight pointer: " << heff_ge1btight << endl ; heff_ge1btight->SetXTitle("Gluino mass (GeV)") ; heff_ge1btight->SetYTitle("LSP mass (GeV)") ; heff_ge1btight->UseCurrentStyle() ; heff_ge1btight->SetMinimum(0.0) ; heff_ge1btight->SetMaximum(0.6) ; heff_ge1btight->DrawCopy("colz") ; heff_ge1btight->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Efficiency" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge1btight, Efficiency") ; ceff->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-eff-ge1btight.png") ; //-------- TH2F* heff_ge2bloose = (TH2F*) gDirectory->FindObject("ge2bloose_hsusyscanEfficiency") ; cout << "heff_ge2bloose pointer: " << heff_ge2bloose << endl ; heff_ge2bloose->SetXTitle("Gluino mass (GeV)") ; heff_ge2bloose->SetYTitle("LSP mass (GeV)") ; heff_ge2bloose->UseCurrentStyle() ; heff_ge2bloose->SetMinimum(0.0) ; heff_ge2bloose->SetMaximum(0.6) ; heff_ge2bloose->DrawCopy("colz") ; heff_ge2bloose->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Efficiency" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge2bloose, Efficiency") ; ceff->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-eff-ge2bloose.png") ; //-------- TH2F* heff_ge2btight = (TH2F*) gDirectory->FindObject("ge2btight_hsusyscanEfficiency") ; cout << "heff_ge2btight pointer: " << heff_ge2btight << endl ; heff_ge2btight->SetXTitle("Gluino mass (GeV)") ; heff_ge2btight->SetYTitle("LSP mass (GeV)") ; heff_ge2btight->UseCurrentStyle() ; heff_ge2btight->SetMinimum(0.0) ; heff_ge2btight->SetMaximum(0.6) ; heff_ge2btight->DrawCopy("colz") ; heff_ge2btight->DrawCopy("colz") ; text->SetTextAngle(90.) ; text->SetTextSize(0.04) ; text->DrawTextNDC( 0.95, 0.15, "Efficiency" ) ; text->SetTextAngle(0.) ; text->SetTextSize(0.045) ; text->DrawTextNDC( 0.15, 0.92, "T1bbbb: ge2btight, Efficiency") ; ceff->SaveAs("an-11-257-v3-files/output-files/an-t1bbbb-eff-ge2btight.png") ; }
void plotpurity() { Bool_t dolines = kFALSE; //Bool_t dolines = kTRUE; TString lines = ""; TString xn = ""; //TString xn = "_onlyQCD"; //TString xn = "_onlyGJ"; //TString xn = "_denominator"; if(dolines){lines="/lines";} std::vector<TString> rebins; rebins.push_back(""); // rebins.push_back("rebin1"); // rebins.push_back("rebin2"); // rebins.push_back("rebin3"); // rebins.push_back("rebin4"); // rebins.push_back("rebin5"); std::vector<TString> ptranges; // ptranges.push_back("90to120"); // ptranges.push_back("120to155"); // ptranges.push_back("155to175"); ptranges.push_back("175to190"); ptranges.push_back("190to250"); ptranges.push_back("250to400"); ptranges.push_back("400to700"); ptranges.push_back("700to1000"); ptranges.push_back("175to1000"); //ptranges.push_back("250to1000"); //ptranges.push_back("400to1000"); std::vector<TString> isovars; //isovars.push_back("wchiso"); isovars.push_back("chiso"); // isovars.push_back("sieieF5x5"); // isovars.push_back("sieipF5x5"); // isovars.push_back("sipipF5x5"); // isovars.push_back("rho"); // isovars.push_back("nVtx"); // isovars.push_back("phoet"); // isovars.push_back("pfMET"); std::vector<TString> cuts; cuts.push_back("a_idnc"); cuts.push_back("b_idnc_mL30"); cuts.push_back("c_idnc_trig"); cuts.push_back("d_idnc_mL30_trig"); cuts.push_back("e_idnc_t175"); cuts.push_back("f_idnc_mL30_t175"); cuts.push_back("g_idnc_t250"); cuts.push_back("h_idnc_mL30_t250"); cuts.push_back("i_idnc_mL30_allt"); // cuts.push_back("oldj"); TString inpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/analyzed"; TString outpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/plots"; TString wwwpath = "/afs/hep.wisc.edu/home/tperry/www/MonoPhoton/qcdPlots/Lire/purity"; TString inname_GJ = inpath+"/purity_GJets_Merged.root"; TString inname_QCD = inpath+"/purity_QCD_Merged.root"; // TString inname_GJ = inpath+"/purity_mrg4bins_GJets.root"; // TString inname_QCD = inpath+"/purity_mrg4bins_QCD.root"; //TString inname_GJ = inpath+"/purity_mrg3bins_GJets.root"; //TString inname_QCD = inpath+"/purity_mrg3bins_QCD.root"; TFile *infile_GJ = new TFile(inname_GJ); TFile *infile_QCD = new TFile(inname_QCD); ofstream log; ofstream log_latex; log.open (outpath+"/Purity_log"+xn+".txt"); log_latex.open (outpath+"/Purity_log_latex"+xn+".txt"); Int_t fillcolor = 3; gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetFrameLineWidth(3); gStyle->SetLineWidth(2); TCanvas* canvas = new TCanvas("canvas","canvas",900,100,500,500); gStyle->SetOptStat(0); gPad->SetTickx(); gPad->SetTicky(); gStyle->SetLineWidth(3); TText* title = new TText(1,1,"") ; title->SetTextSize(0.07); title->SetTextColor(kBlack); title->SetTextAlign(13); title->SetTextFont(62); TText* extra = new TText(1,1,"") ; extra->SetTextSize(0.05); extra->SetTextColor(kBlack); extra->SetTextAlign(13); extra->SetTextFont(52); TText* lumi = new TText(1,1,"") ; lumi->SetTextSize(0.05); lumi->SetTextColor(kBlack); lumi->SetTextAlign(31); lumi->SetTextFont(42); int c_sig = 4; int c_bkg = 2; int c_den = 8; int ls_cmb = 1; int ls_gj = 2; int ls_qcd = 3; //for(std::vector<TString>::iterator it = ptranges.begin(); it != ptranges.end(); ++it) { for(unsigned i=0; i<ptranges.size(); i++) { for(unsigned j=0; j<isovars.size(); j++) { for(unsigned k=0; k<cuts.size(); k++) { for(unsigned l=0; l<rebins.size(); l++) { TString ptrange = ptranges.at(i); TString isovar = isovars.at(j); TString cut = cuts.at(k); TString rebin = rebins.at(l); TString cutname; if(cut=="idnc"){cutname="ID";} if(cut=="idnc_mL30"){cutname="ID+MET";} if(cut=="idnc_trig"){cutname="ID+Trigger";} if(cut=="idnc_mL30_trig"){cutname="ID+MET+Trigger";} TString bwidth; if(rebin=="rebin1"){bwidth="width=0.5";} if(rebin=="rebin2"){bwidth="width=1.0";} if(rebin=="rebin3"){bwidth="width=1.5";} if(rebin=="rebin4"){bwidth="width=2.0";} if(rebin=="rebin5"){bwidth="width=2.5";} std::cout<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin<<std::endl; //Signal purity TH1F* h_Nsig_GJ = (TH1F*)infile_GJ->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut); TH1F* h_Nsig_QCD = (TH1F*)infile_QCD->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut); h_Nsig_GJ->Rebin(3); h_Nsig_QCD->Rebin(3); //h_Nsig_GJ->Rebin(l+1); h_Nsig_QCD->Rebin(l+1); //TH1F* h_Nsig = (TH1F*)h_Nsig_QCD->Clone("h_Nsig"); TH1F* h_Nsig = (TH1F*)h_Nsig_GJ->Clone("h_Nsig"); h_Nsig->Add(h_Nsig_QCD); h_Nsig->SetLineColor(c_sig); h_Nsig_GJ->SetLineColor(c_sig); h_Nsig_QCD->SetLineColor(c_sig); h_Nsig->SetLineStyle(ls_cmb); h_Nsig_GJ->SetLineStyle(ls_gj); h_Nsig_QCD->SetLineStyle(ls_qcd); h_Nsig->SetLineWidth(2); h_Nsig_GJ->SetLineWidth(2); h_Nsig_QCD->SetLineWidth(2); //Background purity TH1F* h_Nbkg_GJ = (TH1F*)infile_GJ->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut); TH1F* h_Nbkg_QCD = (TH1F*)infile_QCD->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut); h_Nbkg_GJ->Rebin(3); h_Nbkg_QCD->Rebin(3); //TH1F* h_Nbkg = (TH1F*)h_Nbkg_QCD->Clone("h_Nbkg"); TH1F* h_Nbkg = (TH1F*)h_Nbkg_GJ->Clone("h_Nbkg"); h_Nbkg->Add(h_Nbkg_QCD); h_Nbkg->SetLineColor(c_bkg); h_Nbkg_GJ->SetLineColor(c_bkg); h_Nbkg_QCD->SetLineColor(c_bkg); h_Nbkg->SetLineStyle(ls_cmb); h_Nbkg_GJ->SetLineStyle(ls_gj); h_Nbkg_QCD->SetLineStyle(ls_qcd); h_Nbkg->SetLineWidth(2); h_Nbkg_GJ->SetLineWidth(2); h_Nbkg_QCD->SetLineWidth(2); //Denominator TH1F* h_Deno_GJ = (TH1F*)h_Nsig_GJ->Clone("h_Deno_GJ"); h_Deno_GJ->Add(h_Nbkg_GJ); TH1F* h_Deno_QCD = (TH1F*)h_Nsig_QCD->Clone("h_Deno_QCD"); h_Deno_QCD->Add(h_Nbkg_QCD); // TH1F* h_Deno_GJ = (TH1F*)infile_GJ->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut); // TH1F* h_Deno_QCD = (TH1F*)infile_QCD->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut); // h_Deno_GJ->Rebin(3); h_Deno_QCD->Rebin(3); // //TH1F* h_Deno = (TH1F*)h_Deno_QCD->Clone("h_Deno"); TH1F* h_Deno = (TH1F*)h_Deno_GJ->Clone("h_Deno"); h_Deno->Add(h_Deno_QCD); h_Deno->SetLineColor(c_den); h_Deno_GJ->SetLineColor(c_den); h_Deno_QCD->SetLineColor(c_den); h_Deno->SetLineStyle(ls_cmb); h_Deno_GJ->SetLineStyle(ls_gj); h_Deno_QCD->SetLineStyle(ls_qcd); h_Deno->SetLineWidth(1); h_Deno_GJ->SetLineWidth(1); h_Deno_QCD->SetLineWidth(1); // should probably add these as last bin.. h_Nsig->ClearUnderflowAndOverflow(); h_Nbkg->ClearUnderflowAndOverflow(); h_Deno->ClearUnderflowAndOverflow(); //Define purity TGraphAsymmErrors *purity_signal = new TGraphAsymmErrors(h_Nsig,h_Deno,"n"); purity_signal->SetLineWidth(2); purity_signal->SetLineColor(4); purity_signal->SetMarkerColor(4); purity_signal->SetMarkerStyle(20); TGraphAsymmErrors *purity_background = new TGraphAsymmErrors(h_Nbkg,h_Deno,"n"); purity_background->SetLineWidth(2); purity_background->SetLineColor(2); purity_background->SetMarkerColor(2); purity_background->SetMarkerStyle(24); //----------------------------------------------------- // Calculations log<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin ; // Start lower bound calculation Int_t nbins; nbins = purity_background->GetN(); log<<boost::format("(%2i bins) \n") % nbins ; std::vector<Double_t> thresholds, xsatthresh, ysatthresh, xsatqt, avgpur; std::vector<Int_t> batthresh, batqt; thresholds.clear(); // purity thresholds xsatthresh.clear(); // x st. f(x) > thresh ysatthresh.clear(); // y = f(x)x at thresh batthresh.clear(); // bin corresponding to x batqt.clear(); // bin at upper threshold xsatqt.clear(); // x value at upper thresh avgpur.clear(); // average purity over range thresholds.push_back(0.50); thresholds.push_back(0.55); thresholds.push_back(0.60); thresholds.push_back(0.65); thresholds.push_back(0.70); Int_t nthreshs; nthreshs = thresholds.size(); // find purity lower bounds = x st. f(x)>thresh Double_t pointx, pointy; for(int m=0; m<nbins; ++m){ purity_background->GetPoint(m, pointx, pointy); //log<<boost::format(" %2i %2.2f %2.2f \n") % i % pointx % pointy; for(int n=0; n<nthreshs; ++n){ if(pointy > thresholds.at(n) && ysatthresh.size()==n ){ ysatthresh.push_back(pointy); xsatthresh.push_back(pointx); batthresh.push_back(h_Nsig->FindBin(pointx)); } } } // for thresholds never reached, fill with content of xmax purity_background->GetPoint(nbins-1,pointx,pointy); Int_t nrnpassthresh = 0; nrnpassthresh = nthreshs - ysatthresh.size(); for(int n=0; n<nrnpassthresh; ++n){ ysatthresh.push_back(pointy); xsatthresh.push_back(pointx); batthresh.push_back(h_Nsig->FindBin(pointx)); } //// dump lower bound threshold info //for(int n=0; n<nthreshs; ++n){ // log<<boost::format(" Threshold: %.2f %2i (%2.2f, %0.2f)\n") // % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n) ; //} log<<boost::format(" Threshold bin (xx.x,yy.y) TotalSize above|below\n"); // Start upper bound calculation Double_t fullsize = h_Nbkg->Integral(0,-1); for(int n=0; n<nthreshs; ++n){ Double_t sizedown = h_Nbkg->Integral(0,batthresh.at(n)-1); Double_t sizeup = h_Nbkg->Integral(batthresh.at(n),-1); log<<boost::format(" %7.2f %3i (%2.1f,%1.2f) %4.1f %6.1f|%6.1f \n") % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n) % fullsize % sizeup % sizedown ; } // upper bound calculation // keep adding contents of bins starting at threshbin // until sum > fraction (1/4) of full integral Double_t goalsize = fullsize / 4.; for(int n=0; n<nthreshs; ++n){ Double_t thissize = 0.; int thisbin = batthresh.at(n); while( thisbin < nbins+1 ){ thissize += h_Nbkg->GetBinContent(thisbin); if(thissize > goalsize){ break; } thisbin++; } batqt.push_back(thisbin); xsatqt.push_back(h_Nbkg->GetBinCenter(thisbin)); } log<<" Target Eventcount: "<<goalsize<<" = fullsize/4 = "<<fullsize<<"/4 \n"; log<<boost::format(" Threshold blo bhi (xlo,xhi) Int(blo,bhi) Int(blo,bhi+1) Int(blo,bhi-1)\n"); // find average purity over range // must weight each purity bin by nr. events in bin for(int n=0; n<nthreshs; ++n){ int nbins = batqt.at(n) - batthresh.at(n); //std::cout<<nbins<<" "<<batthresh.at(n)<<" "<<batqt.at(n)<<std::endl; Double_t sumpurs, sumweights; sumpurs = 0.; sumweights = 0.; for(int o=0; o<nbins+1; ++o){ int thisbin = batthresh.at(n) + o; int thispoint = thisbin - 1; // bin nr = point nr + 1 purity_background->GetPoint(thispoint, pointx,pointy); sumpurs += pointy*h_Nbkg->GetBinContent(thisbin); sumweights += h_Nbkg->GetBinContent(thisbin); //std::cout<<" "<<thispoint<<"|"<<pointy<<"|"<<h_Nbkg->GetBinContent(thisbin)<<" "<<std::endl;; } //std::cout<<std::endl; //std::cout<<sumpurs/sumweights<<std::endl<<std::endl;; avgpur.push_back( sumpurs/sumweights ); } log_latex<<"\\begin{tabular}{r|r|r|r|r|r|r|r}\n"; log_latex<<boost::format("\\multicolumn{2}{c|}{%8s} & \\multicolumn{2}{c|}{%15s} & \\multicolumn{2}{c|}{%7s} & \\multicolumn{2}{c|}{%7s} \\\\ \\hline \\hline \n") % ptrange % cutname % isovar % bwidth ; log_latex<<boost::format(" %10s & %5s & %5s & %10s & %5s & %8s & %15s & %10s \\\\ \\hline \n") % "Threshold" % "x lo" % "x hi" % "avg purity" % "err \\%" % "evts. tot." % "evts. > x lo" % "evts in rng." ; ///log_latex<<"\\begin{tabular}{r|r|r|r|r}\n"; ///log_latex<<boost::format("%8s & \\multicolumn{2}{c}{%15s} & %7s & %7s \\\\ \n \\hline \\hline \n") % ptrange % cutname % isovar % bwidth ; ///log_latex<<boost::format(" %10s & %5s & %5s & %10s & %5s \\\\ \n \\hline \n") /// % "Threshold" /// % "x lo" % "x hi" /// % "avg purity" /// % "err \\%" ; for(int n=0; n<nthreshs; ++n){ log<<boost::format(" %7.2f %3i %3i (%2.1f,%1.2f) %10.2f %10.2f %10.2f \n") % thresholds.at(n) % batthresh.at(n) %batqt.at(n) % xsatthresh.at(n) % xsatqt.at(n) % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)) % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)+1) % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)-1) ; Double_t nrevents, errevents, pcterr; nrevents = h_Nbkg->IntegralAndError(batthresh.at(n),batqt.at(n),errevents); pcterr = errevents/nrevents; log_latex<<boost::format(" %10.2f & %5.2f & %5.2f & %10.4f & %5.2f & %8.1f & %15.1f & %10.1f \\\\ \n") % thresholds.at(n) % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatthresh.at(n))) % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatqt.at(n) )) //% xsatthresh.at(n) % xsatqt.at(n) % avgpur.at(n) % (pcterr*100) % fullsize % h_Nbkg->Integral(batthresh.at(n),-1) % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)); ///log_latex<<boost::format(" %10.2f & %5.2f & %5.2f & %7.3f & %5.2f \\\\ \n") /// % thresholds.at(n) /// % xsatthresh.at(n) % xsatqt.at(n) /// % avgpur.at(n) /// % (pcterr*100) ; } log_latex<<"\\hline \n \\end{tabular}\n"; //----------------------------------------------------- // all set, now to start thinking about plotting //Make lower bound lines (purity) Double_t frac = 1./nthreshs; TLine *lgb_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac); TLine *lgb_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac); TLine *lgb_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac); TLine *lgb_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac); TLine *lgb_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac); TLine *lgc_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac); TLine *lgc_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac); TLine *lgc_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac); TLine *lgc_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac); TLine *lgc_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac); lgb_lo0->SetLineColor(1); lgb_lo1->SetLineColor(1); lgb_lo2->SetLineColor(1); lgb_lo3->SetLineColor(1); lgb_lo4->SetLineColor(1); lgc_lo0->SetLineColor(2); lgc_lo1->SetLineColor(3); lgc_lo2->SetLineColor(4); lgc_lo3->SetLineColor(5); lgc_lo4->SetLineColor(6); lgb_lo0->SetLineWidth(4); lgb_lo1->SetLineWidth(4); lgb_lo2->SetLineWidth(4); lgb_lo3->SetLineWidth(4); lgb_lo4->SetLineWidth(4); lgc_lo0->SetLineWidth(2); lgc_lo1->SetLineWidth(2); lgc_lo2->SetLineWidth(2); lgc_lo3->SetLineWidth(2); lgc_lo4->SetLineWidth(2); //Make upper bound lines (purity) TLine *lgb_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac); TLine *lgb_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac); TLine *lgb_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac); TLine *lgb_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac); TLine *lgb_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac); TLine *lgc_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac); TLine *lgc_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac); TLine *lgc_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac); TLine *lgc_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac); TLine *lgc_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac); lgb_hi0->SetLineColor(1); lgb_hi1->SetLineColor(1); lgb_hi2->SetLineColor(1); lgb_hi3->SetLineColor(1); lgb_hi4->SetLineColor(1); lgc_hi0->SetLineColor(2); lgc_hi1->SetLineColor(3); lgc_hi2->SetLineColor(4); lgc_hi3->SetLineColor(5); lgc_hi4->SetLineColor(6); lgb_hi0->SetLineWidth(4); lgb_hi1->SetLineWidth(4); lgb_hi2->SetLineWidth(4); lgb_hi3->SetLineWidth(4); lgb_hi4->SetLineWidth(4); lgc_hi0->SetLineWidth(2); lgc_hi1->SetLineWidth(2); lgc_hi2->SetLineWidth(2); lgc_hi3->SetLineWidth(2); lgc_hi4->SetLineWidth(2); lgc_hi0->SetLineStyle(2); lgc_hi1->SetLineStyle(2); lgc_hi2->SetLineStyle(2); lgc_hi3->SetLineStyle(2); lgc_hi4->SetLineStyle(2); //Make avg purity horizontal lines TLine *lgb_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0)); TLine *lgb_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1)); TLine *lgb_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2)); TLine *lgb_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3)); TLine *lgb_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4)); TLine *lgc_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0)); TLine *lgc_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1)); TLine *lgc_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2)); TLine *lgc_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3)); TLine *lgc_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4)); lgb_pur0->SetLineColor(1); lgb_pur1->SetLineColor(1); lgb_pur2->SetLineColor(1); lgb_pur3->SetLineColor(1); lgb_pur4->SetLineColor(1); //lgb_pur0->SetLineColor(2); //lgb_pur1->SetLineColor(3); //lgb_pur2->SetLineColor(4); //lgb_pur3->SetLineColor(5); //lgb_pur4->SetLineColor(6); lgc_pur0->SetLineColor(2); lgc_pur1->SetLineColor(3); lgc_pur2->SetLineColor(4); lgc_pur3->SetLineColor(5); lgc_pur4->SetLineColor(6); lgb_pur0->SetLineWidth(4); lgb_pur1->SetLineWidth(4); lgb_pur2->SetLineWidth(4); lgb_pur3->SetLineWidth(4); lgb_pur4->SetLineWidth(4); lgc_pur0->SetLineWidth(2); lgc_pur1->SetLineWidth(2); lgc_pur2->SetLineWidth(2); lgc_pur3->SetLineWidth(2); lgc_pur4->SetLineWidth(2); //lgc_pur0->SetLineStyle(2); //lgc_pur1->SetLineStyle(2); //lgc_pur2->SetLineStyle(2); //lgc_pur3->SetLineStyle(2); //lgc_pur4->SetLineStyle(2); //----------------------------------------------------- Double_t themax = 0 ; themax = std::max(themax, h_Nsig->GetMaximum()); themax = std::max(themax, h_Nbkg->GetMaximum()); themax = std::max(themax, h_Deno->GetMaximum()); //Make lower bound lines (hist) Double_t logmax; Double_t logmin; logmax = std::log(themax); logmin = std::log(1); Double_t spacing = (logmax-logmin)/nthreshs; //std::cout<<spacing<<std::endl; //Double_t fifmax = themax/5.; TLine *lhb_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing)); TLine *lhb_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing)); TLine *lhb_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing)); TLine *lhb_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing)); TLine *lhb_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing)); TLine *lhc_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing)); TLine *lhc_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing)); TLine *lhc_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing)); TLine *lhc_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing)); TLine *lhc_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing)); lhb_lo0->SetLineColor(1); lhb_lo1->SetLineColor(1); lhb_lo2->SetLineColor(1); lhb_lo3->SetLineColor(1); lhb_lo4->SetLineColor(1); lhc_lo0->SetLineColor(2); lhc_lo1->SetLineColor(3); lhc_lo2->SetLineColor(4); lhc_lo3->SetLineColor(5); lhc_lo4->SetLineColor(6); lhb_lo0->SetLineWidth(4); lhb_lo1->SetLineWidth(4); lhb_lo2->SetLineWidth(4); lhb_lo3->SetLineWidth(4); lhb_lo4->SetLineWidth(4); lhc_lo0->SetLineWidth(2); lhc_lo1->SetLineWidth(2); lhc_lo2->SetLineWidth(2); lhc_lo3->SetLineWidth(2); lhc_lo4->SetLineWidth(2); //Make upper bound lines (hist) TLine *lhb_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing)); TLine *lhb_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing)); TLine *lhb_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing)); TLine *lhb_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing)); TLine *lhb_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing)); TLine *lhc_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing)); TLine *lhc_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing)); TLine *lhc_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing)); TLine *lhc_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing)); TLine *lhc_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing)); lhb_hi0->SetLineColor(1); lhb_hi1->SetLineColor(1); lhb_hi2->SetLineColor(1); lhb_hi3->SetLineColor(1); lhb_hi4->SetLineColor(1); lhc_hi0->SetLineColor(2); lhc_hi1->SetLineColor(3); lhc_hi2->SetLineColor(4); lhc_hi3->SetLineColor(5); lhc_hi4->SetLineColor(6); lhb_hi0->SetLineWidth(4); lhb_hi1->SetLineWidth(4); lhb_hi2->SetLineWidth(4); lhb_hi3->SetLineWidth(4); lhb_hi4->SetLineWidth(4); lhc_hi0->SetLineWidth(2); lhc_hi1->SetLineWidth(2); lhc_hi2->SetLineWidth(2); lhc_hi3->SetLineWidth(2); lhc_hi4->SetLineWidth(2); lhc_hi0->SetLineStyle(2); lhc_hi1->SetLineStyle(2); lhc_hi2->SetLineStyle(2); lhc_hi3->SetLineStyle(2); lhc_hi4->SetLineStyle(2); //----------------------------------------------------- //----------------------------------------------------- //Draw Histograms TLegend *meg = new TLegend(0.4,0.6,0.88,0.88); //meg->SetTextSize(0.04) ; meg->SetFillColor(0); meg->SetShadowColor(0);meg->SetBorderSize(2); meg->SetTextFont(22.); meg->AddEntry(h_Nsig,"Signal","l"); meg->AddEntry(h_Nsig_GJ,"Signal (GJ MC)","l"); meg->AddEntry(h_Nsig_QCD,"Signal (QCD MC)","l"); meg->AddEntry(h_Nbkg,"Background","l"); meg->AddEntry(h_Nbkg_GJ,"Background (GJ MC)","l"); meg->AddEntry(h_Nbkg_QCD,"Background (QCD MC)","l"); meg->AddEntry(h_Deno,"Denominator","l"); meg->AddEntry(h_Deno_GJ,"Denominator (GJ MC)","l"); meg->AddEntry(h_Deno_QCD,"Denominator (QCD MC)","l"); TString leg_h0; leg_h0.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(0), xsatthresh.at(0), xsatqt.at(0)); TString leg_h1; leg_h1.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(1), xsatthresh.at(1), xsatqt.at(1)); TString leg_h2; leg_h2.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(2), xsatthresh.at(2), xsatqt.at(2)); TString leg_h3; leg_h3.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(3), xsatthresh.at(3), xsatqt.at(3)); TString leg_h4; leg_h4.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(4), xsatthresh.at(4), xsatqt.at(4)); TLegend *neg = new TLegend(0.15,0.5,0.4,0.75); //meg->SetTextSize(0.04) ; neg->SetFillColor(0); neg->SetShadowColor(0);neg->SetBorderSize(2); neg->SetTextFont(22.); neg->AddEntry(lhc_lo0,leg_h0,"l"); neg->AddEntry(lhc_lo1,leg_h1,"l"); neg->AddEntry(lhc_lo2,leg_h2,"l"); neg->AddEntry(lhc_lo3,leg_h3,"l"); neg->AddEntry(lhc_lo4,leg_h4,"l"); h_Nsig->SetTitle(cut); h_Nsig->SetXTitle(h_Nsig->GetTitle()); h_Nsig->SetYTitle("Events "); h_Nsig->SetMaximum(1000*themax); h_Nsig->SetMinimum(1); h_Nsig->Draw("hist"); h_Nsig_GJ->Draw("hist,same"); h_Nsig_QCD->Draw("hist,same"); h_Nbkg->Draw("hist,same"); h_Nbkg_GJ->Draw("hist,same"); h_Nbkg_QCD->Draw("hist,same"); h_Deno->Draw("hist,same"); h_Deno_GJ->Draw("hist,same"); h_Deno_QCD->Draw("hist,same"); meg->SetHeader("photon p_{T}: "+ptrange); meg->Draw(); if(dolines){ neg->Draw(); } title->DrawTextNDC(0.17,0.87,"CMS"); extra->DrawTextNDC(0.17,0.81,"Preliminary"); lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)"); if(dolines){ lhb_lo0->Draw(); lhb_lo1->Draw(); lhb_lo2->Draw(); lhb_lo3->Draw(); lhb_lo4->Draw(); lhb_hi0->Draw(); lhb_hi1->Draw(); lhb_hi2->Draw(); lhb_hi3->Draw(); lhb_hi4->Draw(); lhc_lo0->Draw(); lhc_lo1->Draw(); lhc_lo2->Draw(); lhc_lo3->Draw(); lhc_lo4->Draw(); lhc_hi0->Draw(); lhc_hi1->Draw(); lhc_hi2->Draw(); lhc_hi3->Draw(); lhc_hi4->Draw(); } gPad->SetLogy(); canvas->SaveAs(outpath+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf"); canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf"); canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png"); canvas->Clear(); gPad->SetLogy(kFALSE); //----------------------------------------------------- //----------------------------------------------------- //Draw Purity TLegend *leg = new TLegend(0.5,0.75,0.88,0.88); leg->SetTextSize(0.04) ; leg->SetFillColor(0); leg->SetShadowColor(0);leg->SetBorderSize(0); leg->SetTextFont(22.); leg->AddEntry(purity_signal,"Signal","lep"); leg->AddEntry(purity_background,"Background","lep"); float xmin ; //= 0.; float xmax ; //= 25.; xmin = h_Nsig->GetXaxis()->GetXmin(); xmax = h_Nsig->GetXaxis()->GetXmax(); TLine *lowline = new TLine(xmin,0,xmax,0); TLine *hiline = new TLine(xmin,1,xmax,1); lowline->SetLineWidth(1); lowline->SetLineColor(1); lowline->SetLineStyle(3); hiline->SetLineWidth(1); hiline->SetLineColor(1); hiline->SetLineStyle(3); TH1F *hframe = canvas->DrawFrame(xmin,-0.05,xmax,1.4,""); lowline->Draw(); hiline->Draw(); title->DrawTextNDC(0.17,0.87,"CMS"); extra->DrawTextNDC(0.17,0.81,"Preliminary"); lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)"); hframe->SetTitle(cut); hframe->SetXTitle(isovar); hframe->SetYTitle("Purity"); // draw points purity_signal->Draw("P"); purity_background->Draw("P"); leg->SetHeader("photon p_{T}: "+ptrange); leg->Draw(); //canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+"_"+rebin+xn+".pdf"); if(dolines){ lgb_lo0->Draw(); lgb_lo1->Draw(); lgb_lo2->Draw(); lgb_lo3->Draw(); lgb_lo4->Draw(); lgb_hi0->Draw(); lgb_hi1->Draw(); lgb_hi2->Draw(); lgb_hi3->Draw(); lgb_hi4->Draw(); lgc_lo0->Draw(); lgc_lo1->Draw(); lgc_lo2->Draw(); lgc_lo3->Draw(); lgc_lo4->Draw(); lgc_hi0->Draw(); lgc_hi1->Draw(); lgc_hi2->Draw(); lgc_hi3->Draw(); lgc_hi4->Draw(); lgb_pur0->Draw(); lgb_pur1->Draw(); lgb_pur2->Draw(); lgb_pur3->Draw(); lgb_pur4->Draw(); lgc_pur0->Draw(); lgc_pur1->Draw(); lgc_pur2->Draw(); lgc_pur3->Draw(); lgc_pur4->Draw(); } canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf"); canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf"); canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png"); canvas->Clear(); //----------------------------------------------------- // clean your room! h_Nsig->Delete(); h_Nsig_GJ->Delete(); h_Nsig_QCD->Delete(); h_Nbkg->Delete(); h_Nbkg_GJ->Delete(); h_Nbkg_QCD->Delete(); h_Deno->Delete(); h_Deno_GJ->Delete(); h_Deno_QCD->Delete(); } log<<"--------------------------------------\n"; log_latex<<"--------------------------------------\n"; } } } log.close(); log_latex.close(); }
void DetailedComparePlot(TH1 * href_, TH1 * hnew_, TString currentfile, TString referencefile, TString theDir, TString theHisto ) { gStyle->SetOptTitle(0); TString theName = theDir+"/"+theHisto; std::cout << "Histogram name = " << theName << std::endl; HistoCompare * myPV = new HistoCompare(); int rcolor = 2; int scolor = 4; int rmarker = 21; int smarker = 20; Double_t markerSize = 0.75; href_->SetLineColor(rcolor); href_->SetMarkerStyle(rmarker); href_->SetMarkerSize(markerSize); href_->SetMarkerColor(rcolor); hnew_->SetLineColor(scolor); hnew_->SetMarkerStyle(smarker); hnew_->SetMarkerSize(markerSize); hnew_->SetMarkerColor(scolor); TCanvas *myPlot = 0; if ( href_ && hnew_ ) { myPlot = new TCanvas("myPlot","Histogram comparison",200,10,700,900); TPad *pad0 = new TPad("pad0","The pad with the function ",0.0,0.9,0.0,1.0); TPad *pad1 = new TPad("pad1","The pad with the function ",0.0,0.6,0.5,0.9); TPad *pad2 = new TPad("pad2","The pad with the histogram",0.5,0.6,1.0,0.9); TPad *pad3 = new TPad("pad3","The pad with the histogram",0.0,0.3,0.5,0.6); TPad *pad4 = new TPad("pad4","The pad with the histogram",0.5,0.3,1.0,0.6); TPad *pad5 = new TPad("pad5","The pad with the histogram",0.0,0.0,0.5,0.3); TPad *pad6 = new TPad("pad6","The pad with the histogram",0.5,0.0,1.0,0.3); pad1->Draw(); pad2->Draw(); pad3->Draw(); pad4->Draw(); pad5->Draw(); pad6->Draw(); // Draw a global picture title TText titte; titte.SetTextSize(0.02); titte.DrawTextNDC(0.1,0.98,theName); titte.DrawTextNDC(0.1,0.96,"Reference File (A):"); titte.DrawTextNDC(0.1,0.94,referencefile); titte.DrawTextNDC(0.1,0.92,"Current File (B):"); titte.DrawTextNDC(0.1,0.90,currentfile); hnew_->SetXTitle(href_->GetTitle()); href_->SetXTitle(href_->GetTitle()); hnew_->SetTitleOffset(1.5,"Y"); href_->SetTitleOffset(1.5,"Y"); // Draw reference pad1->cd(); href_->SetYTitle("Events (A)"); href_->DrawCopy("e1"); // Draw new pad2->cd(); hnew_->SetYTitle("Events (B)"); hnew_->DrawCopy("e1"); gStyle->SetOptStat("nemruoi"); // Draw the two overlayed Normalized display region to 1 pad3->cd(); pad3->SetGridx(); pad3->SetGridy(); TH1 *hnew_c=(TH1*)hnew_->Clone(); TH1 *href_c=(TH1*)href_->Clone(); double integral=href_c->Integral(1,href_c->GetNbinsX()); if(integral!=0)href_c->Scale(1/integral); integral=hnew_c->Integral(1,href_c->GetNbinsX()); if(integral!=0)hnew_c->Scale(1/integral); href_c->SetYTitle("Comparison of A and B"); href_c->DrawCopy("e1"); hnew_c->DrawCopy("e1same"); TText* te = new TText(); te->SetTextSize(0.04); myPV->PVCompute( href_ , hnew_ , te ); TH1 *ratio_=(TH1*)hnew_c->Clone(); ratio_->Divide(href_c); ratio_->SetYTitle("Ratio: B/A"); pad4->cd(); pad4->SetGridx(); pad4->SetGridy(); ratio_->DrawCopy("e1"); TH1 *diff_=(TH1*)hnew_c->Clone(); diff_->Add(href_c,-1); diff_->SetYTitle("Difference: B-A"); pad5->cd(); pad5->SetGridx(); pad5->SetGridy(); diff_->DrawCopy("e1"); TH1 *sigma_=(TH1*)diff_->Clone(); for(unsigned int i=1; i<=sigma_->GetNbinsX(); i++ ){ double v=sigma_->GetBinContent(i); double e=sigma_->GetBinError(i); // cout << v << "+/-" << e << " " << v/fabs(e) << endl; if(e!=0)sigma_->SetBinContent(i,v/fabs(e)); else sigma_->SetBinContent(i,0); } sigma_->SetYTitle("Sigma on Difference: (B-A)/sigma(B-A)"); pad6->cd(); pad6->SetGridx(); pad6->SetGridy(); sigma_->DrawCopy("phisto"); pad0->cd(); gStyle->SetOptStat(0000000); } TString plotFile = theHisto+".eps"; if(myPlot)myPlot->Print(plotFile); delete myPV; delete myPlot; }
TCanvas* pHitSpecPosGen( ) { TCanvas* c = new TCanvas("cHitSpecPosGen","cHitSpecPosGen",1200,600); c->Divide(2,1); TVirtualPad* p; TH2D *h; TH2D *hAtPhi0; TText t; t.SetTextColor(4); p =c->cd(1); p->SetLogy(); p->SetGrid(0,1); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGen_Minus"); hAtPhi0 = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGenAtPhi0_Minus"); h->GetYaxis()->SetRange(4,33); h->GetXaxis()->SetNdivisions(505); h->GetXaxis()->SetLabelSize(0.04); h->DrawCopy("box"); hAtPhi0->SetLineColor(2); hAtPhi0->DrawCopy("box same"); t.DrawTextNDC(0.17,0.15, "BARREL MU MINUS"); std::cout <<h->GetTitle() << std::endl; for (int iy = 1; iy <=h->GetNbinsY(); iy++) { std::cout <<" pt: " << h->GetYaxis()->GetBinLowEdge(iy); double xmin=100.; double xAtMax = 0.; double valAtMax = 0.; double xmax=-100.; for (int ix = 1; ix <=h->GetNbinsX(); ix++) { double val = h->GetBinContent(ix,iy); double xbmin = h->GetXaxis()->GetBinLowEdge(ix); double xcent = h->GetXaxis()->GetBinCenter(ix); double xbmax = h->GetXaxis()->GetBinUpEdge(ix); if (val > valAtMax) { valAtMax = val; xAtMax = xcent; } if (val > 1 && (xbmin < xmin)) xmin = xbmin; if (val > 1 && (xbmax > xmax)) xmax = xbmax; } std::cout <<" set DPHI0 = "<<1.025-xAtMax <<"; set DPHI_MARGIN = " <<std::max( (xAtMax-xmin), (xmax-xAtMax)) <<";" << std::endl; } p =c->cd(2); p->SetLogy(); p->SetGrid(1,1); h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGen_Plus"); hAtPhi0 = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhiGenAtPhi0_Plus"); h->GetYaxis()->SetRange(4,32); h->GetXaxis()->SetNdivisions(505); h->GetXaxis()->SetLabelSize(0.04); h->DrawCopy("box"); hAtPhi0->SetLineColor(2); hAtPhi0->DrawCopy("box same"); t.DrawTextNDC(0.17,0.15, "BARREL MU PLUS"); std::cout <<h->GetTitle() << std::endl; for (int iy = 1; iy <=h->GetNbinsY(); iy++) { std::cout <<" pt: " << h->GetYaxis()->GetBinLowEdge(iy); double xmin=100.; double xAtMax = 0.; double valAtMax = 0.; double xmax=-100.; for (int ix = 1; ix <=h->GetNbinsX(); ix++) { double val = h->GetBinContent(ix,iy); double xbmin = h->GetXaxis()->GetBinLowEdge(ix); double xcent = h->GetXaxis()->GetBinCenter(ix); double xbmax = h->GetXaxis()->GetBinUpEdge(ix); if (val > valAtMax) { valAtMax = val; xAtMax = xcent; } if (val > 1 && (xbmin < xmin)) xmin = xbmin; if (val > 1 && (xbmax > xmax)) xmax = xbmax; } std::cout <<" set DPHI0 = "<<1.025-xAtMax <<"; set DPHI_MARGIN = " <<std::max( (xAtMax-xmin), (xmax-xAtMax)) <<";" << std::endl; } return c; }
void MEComparePlot(TH1 * href_, TH1 * hnew_, TString currentfile, TString referencefile, TString theDir, TString theHisto ) { TString theName = theDir+"/"+theHisto; std::cout << "Histogram name = " << theName << std::endl; HistoCompare * myPV = new HistoCompare(); int rcolor = 2; int scolor = 4; int rmarker = 21; int smarker = 20; Double_t markerSize = 0.75; href_->SetLineColor(rcolor); href_->SetMarkerStyle(rmarker); href_->SetMarkerSize(markerSize); href_->SetMarkerColor(rcolor); hnew_->SetLineColor(scolor); hnew_->SetMarkerStyle(smarker); hnew_->SetMarkerSize(markerSize); hnew_->SetMarkerColor(scolor); TCanvas *myPlot = 0; if ( href_ && hnew_ ) { myPlot = new TCanvas("myPlot","Histogram comparison",200,10,700,900); TPad *pad1 = new TPad("pad1", "The pad with the function",0.03,0.62,0.50,0.92); TPad *pad2 = new TPad("pad2", "The pad with the histogram",0.51,0.62,0.98,0.92); TPad *pad3 = new TPad("pad3", "The pad with the histogram",0.03,0.02,0.97,0.57); pad1->Draw(); pad2->Draw(); pad3->Draw(); // Draw a global picture title TPaveLabel *title = new TPaveLabel(0.1,0.94,0.9,0.98,theName); title->SetFillColor(16); title->SetTextFont(52); title->Draw(); TText * titte = new TText(); // Draw reference pad1->cd(); href_->DrawCopy("e1"); titte->DrawTextNDC(0.,0.02, referencefile); // Draw new pad2->cd(); hnew_->DrawCopy("e1"); titte->DrawTextNDC(0.,0.02, currentfile); gStyle->SetOptStat("nemruoi"); // Draw the two overlayed pad3->cd(); pad3->SetGridx(); pad3->SetGridy(); href_->DrawCopy("e1"); hnew_->DrawCopy("e1same"); TText* te = new TText(); te->SetTextSize(0.1); myPV->PVCompute( href_ , hnew_ , te ); gStyle->SetOptStat(0000000); } TString plotFile = theHisto+".jpg"; if(myPlot) myPlot->Print(plotFile); delete myPV; delete myPlot; }
void DrawMLPoutputMovie( TFile* file, const TString& methodType, const TString& methodTitle ) { gROOT->SetBatch( 1 ); // define Canvas layout here! const Int_t width = 600; // size of canvas // this defines how many canvases we need TCanvas* c = 0; Float_t nrms = 4; Float_t xmin = -1.2; Float_t xmax = 1.2; Float_t ymin = 0; Float_t ymax = 0; Float_t maxMult = 6.0; Int_t countCanvas = 0; Bool_t first = kTRUE; TString dirname = methodType + "/" + methodTitle + "/" + "EpochMonitoring"; TDirectory *epochDir = (TDirectory*)file->Get( dirname ); if (!epochDir) { cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl; exit(1); } // now read all evolution histograms TIter keyItTit(epochDir->GetListOfKeys()); TKey *titkeyTit; while ((titkeyTit = (TKey*)keyItTit())) { if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom("TH1F")) continue; TString name = titkeyTit->GetName(); if (!name.BeginsWith("convergencetest___")) continue; if (!name.Contains("_train_")) continue; // only for training so far if (name.EndsWith( "_B")) continue; // must be signal histogram if (!name.EndsWith( "_S")) { cout << "Big troubles with histogram: " << name << " -> should end with _S" << endl; exit(1); } // create canvas countCanvas++; TString ctitle = Form("TMVA response %s",methodTitle.Data()); c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 ); TH1F* sig = (TH1F*)titkeyTit->ReadObj(); sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) ); TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)"); // find background TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B'; TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn )); if (bgd == 0) { cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl; exit(1); } cout << "sig = " << sig->GetName() << endl; cout << "bgd = " << bgd->GetName() << endl; // set the histogram style TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd ); // normalise both signal and background TMVAGlob::NormalizeHists( sig, bgd ); // set only first time, then same for all plots if (first) { if (xmin == 0 && xmax == 0) { xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), bgd->GetMean() - nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmin() ); xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), bgd->GetMean() + nrms*bgd->GetRMS() ), sig->GetXaxis()->GetXmax() ); } ymin = 0; ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult; first = kFALSE; } // build a frame Int_t nb = 100; TString hFrameName(TString("frame") + methodTitle); TObject *o = gROOT->FindObject(hFrameName); if(o) delete o; TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), nb, xmin, xmax, nb, ymin, ymax ); frame->GetXaxis()->SetTitle( methodTitle + " response" ); frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx"); TMVAGlob::SetFrameStyle( frame ); // find epoch number (4th token) TObjArray* tokens = name.Tokenize("_"); TString es = ((TObjString*)tokens->At(4))->GetString(); if (!es.IsFloat()) { cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl; exit(1); } Int_t epoch = es.Atoi(); // eventually: draw the frame frame->Draw(); c->GetPad(0)->SetLeftMargin( 0.105 ); frame->GetYaxis()->SetTitleOffset( 1.2 ); // Draw legend TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() ); legend->SetFillStyle( 1 ); legend->AddEntry(sig,TString("Signal ") + dataType, "F"); legend->AddEntry(bgd,TString("Background ") + dataType, "F"); legend->SetBorderSize(1); legend->SetMargin( 0.15 ); legend->Draw("same"); TText* t = new TText(); t->SetTextSize( 0.04 ); t->SetTextColor( 1 ); t->SetTextAlign( 31 ); t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) ); // overlay signal and background histograms sig->Draw("samehist"); bgd->Draw("samehist"); // save to file TString dirname = "movieplots"; TString foutname = dirname + "/" + name; foutname.Resize( foutname.Length()-2 ); foutname.ReplaceAll("convergencetest___",""); foutname += ".gif"; cout << "storing file: " << foutname << endl; c->Update(); c->Print(foutname); } }