本文整理汇总了C++中TCanvas::GetPad方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::GetPad方法的具体用法?C++ TCanvas::GetPad怎么用?C++ TCanvas::GetPad使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::GetPad方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Terminate
//_____________________________________________________________________________
void ProofEventProc::Terminate()
{
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
// Check ranges
CheckRanges();
if (gROOT->IsBatch()) return;
TCanvas* canvas = new TCanvas("event","event",800,10,700,780);
canvas->Divide(2,2);
TPad *pad1 = (TPad *) canvas->GetPad(1);
TPad *pad2 = (TPad *) canvas->GetPad(2);
TPad *pad3 = (TPad *) canvas->GetPad(3);
TPad *pad4 = (TPad *) canvas->GetPad(4);
// The number of tracks
pad1->cd();
pad1->SetLogy();
TH1F *hi = dynamic_cast<TH1F*>(fOutput->FindObject("pz_dist"));
if (hi) {
hi->SetFillColor(30);
hi->SetLineColor(9);
hi->SetLineWidth(2);
hi->DrawCopy();
} else { Warning("Terminate", "no pz dist found"); }
// The Pt distribution
pad2->cd();
pad2->SetLogy();
TH1F *hf = dynamic_cast<TH1F*>(fOutput->FindObject("pt_dist"));
if (hf) {
hf->SetFillColor(30);
hf->SetLineColor(9);
hf->SetLineWidth(2);
hf->DrawCopy();
} else { Warning("Terminate", "no pt dist found"); }
// The Px,Py distribution, color surface
TH2F *h2f = dynamic_cast<TH2F*>(fOutput->FindObject("px_py"));
if (h2f) {
// Color surface
pad3->cd();
h2f->DrawCopy("SURF1 ");
// Lego
pad4->cd();
h2f->DrawCopy("CONT2COL");
} else {
Warning("Terminate", "no px py found");
}
// Final update
canvas->cd();
canvas->Update();
}
示例2: Time
CheckTagger() {
Char_t* hname[] = {
"FPD_Nhits", "FPD_NhitsPrompt", "FPD_NhitsRand",
"FPD_Hits", "FPD_ScalerCurr", "FPD_ScalerAcc",
"FPD_EnergyOR","FPD_TimeOR","TAGG_PhotonEnergy",
"FPD_Hits_v_EnergyOR",
"FPD_Hits_v_TimeOR",
"TAGG_Micro_Hits_v_FPD_Hits",
};
Int_t log[] = { 0,0,0,0,1,1,0,0,0 };
Int_t col[] = { 2,2,2,4,5,5,3,3,3 };
Char_t* xname[] = {
"Number of Tagger Hits per Event",
"Number of Prompt Tagger Hits per Event",
"Number of Random Tagger Hits per Event",
"Tagger Hits distribution",
"Tagger Current Scaler Read",
"Tagger Accumulated Scalers",
"Tagger Pulse-Height (MeV)",
"Tagger Time (ns)",
"Tagger Photon Energy",
"Tagger Pulse-Height vs Hits",
"Tagger Time vs Hits",
"Microscope Hits vs Tagger Hits",
};
TH1F* h1;
TCanvas* canv;
//
canv = new TCanvas("Tagger-Spectra","Tagger-Online",240,180,1240,890);
canv->SetFillStyle(4000);
canv->Divide(3,4,0.01,0.01);
for( Int_t i=0; i<9; i++ ) {
h1 = (TH1F*)(gROOT->FindObject(hname[i]));
if( !h1 ) {
printf("No root histogram %s\n",hname[i]);
continue;
}
h1->SetLineColor( 1 );
h1->SetFillColor( col[i] );
canv->cd(i+1);
if( log[i] ) canv->GetPad(i+1)->SetLogy();
h1->GetXaxis()->SetTitle(xname[i]);
h1->Draw();
}
// return;
TH2F* h2;
for( Int_t i=9; i<12; i++ ) {
h2 = (TH2F*)(gROOT->FindObject(hname[i]));
if( !h2 ) {
printf("No root histogram %s\n",hname[i]);
continue;
}
canv->cd(i+1);
h2->GetXaxis()->SetTitle(xname[i]);
h2->Draw("COLZ");
}
return;
}
示例3: PlotParValVsLabelWithErr
void PlotParValVsLabelWithErr(TFile* f, TTree* tr, TString strMillepedeRes, TString strOutdir)
{
f->cd();
TString canvName="c_";
canvName+=strMillepedeRes;
canvName+="_";
canvName+=StrPlotType(PARSwithERRvsLABEL);
canvName.ReplaceAll(".res","");
TCanvas* canv = new TCanvas(canvName,canvName,900,600);
canv->Divide(3,2);
for (int ind=1; ind<=6; ind++){
canv->cd(ind);
TPad* pad = (TPad*)canv->GetPad(ind);
TString strCut="((label%20-1)%9+1)==";
strCut+=ind;
int n = tr->Draw("label%700000:10000*parVal:10000*parErr:0.01*(label%700000)",strCut,"goff");
TGraphErrors *gr = new TGraphErrors(n,tr->GetV1(),tr->GetV2(),tr->GetV4(),tr->GetV3());
gr->SetMarkerStyle(20);
gr->SetLineWidth(2);
for (int i=0; i<n; i++){
std::cout<<tr->GetV1()[i]<<" "<<tr->GetV2()[i]<<"+-"<<tr->GetV3()[i]<<std::endl;
}
gr->SetTitle(StrPar(ind)+TString(", 10000*(par+-err)"));
gr->GetXaxis()->SetTitle("label%700000");
gr->Draw("AP");
}// end of loop over ind
canvName+=".png";
TString saveName=strOutdir+canvName;
canv->SaveAs(saveName);
saveName.ReplaceAll(".png",".pdf");
canv->SaveAs(saveName);
}// end of PlotParValVsLabelWithErr
示例4: DrawKinvarPlot
void DrawKinvarPlot(TString filename="kinvarset/FMSOR_Pt_vs_run.root",
TString classname="pi0") {
TFile * infile = new TFile(filename.Data(),"READ");
char trig[32];
char typ[32];
char tmp[128];
TString tmpstr = filename;
tmpstr.ReplaceAll("_"," ");
TRegexp re("^.*\/");
tmpstr(re) = "";
cout << tmpstr << endl;
sscanf(tmpstr.Data(),"%s %s",trig,typ);
printf("%s %s\n",trig,typ);
TString hname = "h2_"+classname;
TH2D * h = (TH2D*)infile->Get(hname.Data());
TString gname = "g_"+classname;
TGraphErrors * g = (TGraphErrors*)infile->Get(gname.Data());
TString gtname = "gt_"+classname;
TGraphErrors * gt;
if(!strcmp(typ,"Pt")) gt = (TGraphErrors*)infile->Get(gtname.Data());
char htitle[256];
char hnewtitle[512];
strcpy(htitle,h->GetTitle());
sprintf(hnewtitle,"%s -- %s triggers",htitle,trig);
h->SetTitle(hnewtitle);
h->SetMinimum(0.001);
if(!strcmp(typ,"Pt")) {
gt->SetLineWidth(2);
gt->SetLineColor(kBlack);
};
// temporary hack to cut out fluctuations of pt_thresh vs. run to 0
Double_t xx,yy;
Int_t gtn = gt->GetN();
for(int ii=0; ii<gtn; ii++) {
gt->GetPoint(ii,xx,yy);
printf("xx=%f yy=%f\n",xx,yy);
if(yy<0.001) gt->RemovePoint(ii);
};
// drawing range
Float_t xmin = h->GetXaxis()->GetXmin();
Float_t xmax = h->GetXaxis()->GetXmax();
xmax = 515;
if(xmax<gtn) {
fprintf(stderr,"\nWARNING: xmax < gt->GetN(); graphs will be cut off!\n\n");
};
TCanvas * c = new TCanvas("c","c",1500,700);
c->Divide(1,2);
gStyle->SetOptStat(0);
for(int x=1; x<=2; x++) c->GetPad(x)->SetGrid(1,1);
c->cd(1);
c->GetPad(1)->SetLogz();
h->GetXaxis()->SetRangeUser(xmin,xmax);
h->Draw("colz");
if(!strcmp(typ,"Pt")) gt->Draw("LX");
c->cd(2);
g->SetFillColor(kGray);
printf("%f %f\n",xmin,xmax);
g->GetXaxis()->SetLimits(xmin,xmax);
g->GetXaxis()->SetRangeUser(xmin,xmax);
/*
g->Draw("A3");
g->Draw("PLX");
*/
g->Draw("APLX");
TString outname = filename.ReplaceAll(".root"," "+classname);
outname = outname+".png";
c->Print(outname.Data(),"png");
};
示例5: L1q1trigger
void L1q1trigger(){
const TString l1_input = "~/scratch1/DiHadronCorrelations/L1UpgradeAnalyzer.root";
TFile *lFile = TFile::Open(l1_input);
Int_t l1Up_evt, l1Up_run, l1Up_et, l1Up_q2;
TTree *l1UpTree = (TTree*)lFile->Get("L1UpgradeAnalyzer/L1UpgradeTree");
l1UpTree->SetBranchStatus("*",0);
l1UpTree->SetBranchStatus("event",1);
l1UpTree->SetBranchStatus("run",1);
l1UpTree->SetBranchStatus("centrality_hwPt",1);
l1UpTree->SetBranchStatus("v2_hwPt",1);
l1UpTree->SetBranchAddress("event",&l1Up_evt);
l1UpTree->SetBranchAddress("run",&l1Up_run);
l1UpTree->SetBranchAddress("centrality_hwPt",&l1Up_et);
l1UpTree->SetBranchAddress("v2_hwPt",&l1Up_q2);
const TString forest_input = "~/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/ebyeflow_promptreco_pt009.root";
TFile *fFile = TFile::Open(forest_input);
TTree *fTree = (TTree*)fFile->Get("ebyeflow_ana_HI/q2ntuple");
Float_t f_evt, f_run, f_lumi, hiBin;
float hiHF,q2hf;
fTree->SetBranchStatus("*",0);
fTree->SetBranchStatus("evtnum",1);
fTree->SetBranchStatus("run",1);
fTree->SetBranchStatus("lumi",1);
fTree->SetBranchStatus("cent",1);
fTree->SetBranchStatus("q2hf",1);
fTree->SetBranchStatus("hf",1);
fTree->SetBranchAddress("evtnum",&f_evt);
fTree->SetBranchAddress("run",&f_run);
fTree->SetBranchAddress("lumi",&f_lumi);
fTree->SetBranchAddress("cent",&hiBin);
fTree->SetBranchAddress("hf",&hiHF);
fTree->SetBranchAddress("q2hf",&q2hf);
map<long, int> kmap;
map<long, int> kmapcal;
cout << "Filling the map..." << endl;
int l1up_entries = l1UpTree->GetEntries();
//int l_entries = lEvtTree->GetEntries();
for(long j = 0; j < l1up_entries; ++j){
if(j % 10000 == 0) printf("%ld / %d\n",j,l1up_entries);
l1UpTree->GetEntry(j);
long key = makeKey(l1Up_run, l1Up_evt);
pair<long,int> p(key,j);
kmap.insert(p);
kmapcal.insert(p);
}
cout << "map filled!!!" << endl;
//q2 histos
TH2D* q2CorrHist = new TH2D("q2CorrHist",";offline q_{2};online q_{2}",1000,0.,1.0,1000,0.0,1.0);
TH2D* HFCorrHist = new TH2D("HFCorrHist",";offline HF E_{T} sum (GeV); online HF E_{T} sum (GeV)",100,0.,8000.0,100,0.0,8000.0);
TH2D* q2HFCorrHist = new TH2D("q2HFCorrHist",";online HF*q^{2}_{2} (GeV); online HF E_{T} sum (GeV)",300,0.,30000.0,100,0.0,8000.0);
Float_t q2On = 0.0;
int entries = fTree->GetEntries();
for(long int j = 1; j < entries; ++j){
if(j % 10000 == 0) printf("%ld / %d \n",j,entries);
fTree->GetEntry(j);
long keycal = makeKey(f_run, f_evt);
map<long,int>::const_iterator gotcal = kmapcal.find(keycal);
if(gotcal == kmapcal.end()){
continue;
}
else {
l1UpTree->GetEntry(gotcal->second);
kmapcal.erase(keycal);
if(l1Up_et == 0) continue;
//q2 part
q2On = sqrt(l1Up_q2)/l1Up_et;
// if(l1Up_run<182060 && l1Up_run>182050 & l1Up_et<2839 && l1Up_et>1198)
// if(l1Up_et<2839 && l1Up_et>1198)
{
q2CorrHist->Fill(q2hf,q2On);
HFCorrHist->Fill(hiHF,l1Up_et);
q2HFCorrHist->Fill(l1Up_q2,l1Up_et);
}
q2On = 0.0;
}
}
TCanvas* c = new TCanvas("c","c",800,400);
c->Divide(2,1);
c->cd(1);
c->GetPad(1)->SetLogz();
q2CorrHist->Rebin2D(2,2);
//.........这里部分代码省略.........
示例6: makePlot
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& sample, int massPoint, const std::string& channel, double k,
const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
TFile* inputFile = new TFile(inputFileName_full.data());
if ( !inputFile ) {
std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
assert(0);
}
inputFile->ls();
TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
if ( !canvas ) {
std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
assert(0);
}
int idxPad = -1;
if ( massPoint == 90 ) idxPad = 1;
if ( massPoint == 125 ) idxPad = 2;
if ( massPoint == 200 ) idxPad = 3;
if ( massPoint == 300 ) idxPad = 4;
if ( massPoint == 500 ) idxPad = 5;
if ( massPoint == 800 ) idxPad = 6;
if ( !(idxPad >= 1 && idxPad <= 6) ) {
std::cerr << "Invalid sample = " << sample << " !!" << std::endl;
assert(0);
}
TVirtualPad* pad = canvas->GetPad(idxPad);
std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;
TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 800);
canvas_new->SetFillColor(10);
canvas_new->SetBorderSize(2);
canvas_new->SetTopMargin(0.065);
canvas_new->SetLeftMargin(0.17);
canvas_new->SetBottomMargin(0.165);
canvas_new->SetRightMargin(0.015);
canvas_new->SetLogx(true);
canvas_new->SetLogy(true);
canvas_new->Draw();
canvas_new->cd();
//TList* pad_primitives = canvas->GetListOfPrimitives();
TList* pad_primitives = pad->GetListOfPrimitives();
TH1* histogramCA = 0;
TH1* histogramSVfit = 0;
TH1* histogramSVfitMEMkEq0 = 0;
TH1* histogramSVfitMEMkNeq0 = 0;
TIter pad_nextObj(pad_primitives);
while ( TObject* obj = pad_nextObj() ) {
std::string objName = "";
if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();
std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;
TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
if ( tmpHistogram ) {
std::cout << "tmpHistogram:"
<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
<< " integral = " << tmpHistogram->Integral() << std::endl;
std::cout << "(mean = " << tmpHistogram->GetMean() << ", rms = " << tmpHistogram->GetRMS() << ": rms/mean = " << (tmpHistogram->GetRMS()/tmpHistogram->GetMean()) << ")" << std::endl;
if ( tmpHistogram->GetLineColor() == 416 ) histogramCA = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 600 ) histogramSVfit = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 616 ) histogramSVfitMEMkEq0 = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 632 ) histogramSVfitMEMkNeq0 = tmpHistogram;
}
}
if ( !(histogramCA && histogramSVfit && histogramSVfitMEMkEq0 && histogramSVfitMEMkNeq0) ) {
std::cerr << "Failed to load histograms !!" << std::endl;
assert(0);
}
//gStyle->SetLineStyleString(2,"40 10 10 10 10 10 10 10");
//gStyle->SetLineStyleString(3,"25 15");
//gStyle->SetLineStyleString(4,"60 25");
//int colors[4] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7 };
int colors[4] = { 28, kGreen - 6, kBlue - 7, kBlack };
//int lineStyles[4] = { 2, 3, 4, 1 };
int lineStyles[4] = { 7, 1, 1, 1 };
//int lineWidths[4] = { 3, 3, 4, 3 };
int lineWidths[4] = { 3, 3, 1, 1 };
int markerStyles[4] = { 20, 25, 21, 24 };
int markerSizes[4] = { 2, 2, 2, 2 };
histogramCA->SetFillColor(0);
histogramCA->SetFillStyle(0);
histogramCA->SetLineColor(colors[0]);
histogramCA->SetLineStyle(lineStyles[0]);
histogramCA->SetLineWidth(lineWidths[0]);
histogramCA->SetMarkerColor(colors[0]);
histogramCA->SetMarkerStyle(markerStyles[0]);
histogramCA->SetMarkerSize(markerSizes[0]);
//.........这里部分代码省略.........
示例7: mvas
//.........这里部分代码省略.........
// normalise both signal and background
TMVAGlob::NormalizeHists( sig, bgd );
// frame limits (choose judicuous x range)
Float_t nrms = 4;
cout << "--- Mean and RMS (S): " << sig->GetMean() << ", " << sig->GetRMS() << endl;
cout << "--- Mean and RMS (B): " << bgd->GetMean() << ", " << bgd->GetRMS() << endl;
Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(),
bgd->GetMean() - nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmin() );
Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(),
bgd->GetMean() + nrms*bgd->GetRMS() ),
sig->GetXaxis()->GetXmax() );
Float_t ymin = 0;
Float_t maxMult = (htype == CompareType) ? 1.3 : 1.2;
Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
// build a frame
Int_t nb = 500;
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 + ((htype == MVAType || htype == CompareType) ? " response" : "") );
if (htype == ProbaType ) frame->GetXaxis()->SetTitle( "Signal probability" );
else if (htype == RarityType ) frame->GetXaxis()->SetTitle( "Signal rarity" );
frame->GetYaxis()->SetTitle("Normalized");
TMVAGlob::SetFrameStyle( frame );
// 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() + (htype == CompareType ? 0.40 : 0.3), 1 - c->GetTopMargin() );
legend->SetFillStyle( 1 );
legend->AddEntry(sig,TString("Signal") + ((htype == CompareType) ? " (test sample)" : ""), "F");
legend->AddEntry(bgd,TString("Background") + ((htype == CompareType) ? " (test sample)" : ""), "F");
legend->SetBorderSize(1);
legend->SetMargin( (htype == CompareType ? 0.2 : 0.3) );
legend->Draw("same");
// overlay signal and background histograms
sig->Draw("samehist");
bgd->Draw("samehist");
if (htype == CompareType) {
// if overtraining check, load additional histograms
TH1* sigOv = 0;
TH1* bgdOv = 0;
TString ovname = hname += "_Train";
sigOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_S" ));
bgdOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_B" ));
if (sigOv == 0 || bgdOv == 0) {
cout << "+++ Problem in \"mvas.C\": overtraining check histograms do not exist" << endl;
}
else {
cout << "--- Found comparison histograms for overtraining check" << endl;
TLegend *legend2= new TLegend( 1 - c->GetRightMargin() - 0.42, 1 - c->GetTopMargin() - 0.12,
示例8: vn_spectra_trackHF
//.........这里部分代码省略.........
double vn=Vn/vn0[n];
if(i<=2) vn=Vn/vn01[n];
double vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn0err[n]*vn0err[n]);
if(i<=2) vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn01err[n]*vn01err[n]);
gr[n-1]->SetPoint(i,hpt[i]->GetMean(),vn);
gr[n-1]->SetPointError(i,0,vnerr);
/*
double integral = hpt[i]->Integral();
if(i==0) integral = hpt[1]->Integral();
if(hpt[i]->GetMean()>3.0) continue;
merit[n-1] = merit[n-1] + integral/1000.*vn;
merit_err[n-1] = merit_err[n-1] + integral/1000.*vnerr;
total[n-1] = total[n-1] + integral/1000.;
gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1]));
if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl;
*/
double integral = hptcorr->GetBinContent(hptcorr->FindBin(hpt[i]->GetMean()))*hptcorr->GetBinWidth(hptcorr->FindBin(hpt[i]->GetMean()));
if(hpt[i]->GetMean()>3.0) continue;
merit[n-1] = merit[n-1] + integral/1000.*vn;
merit_err[n-1] = merit_err[n-1] + integral/1000.*vnerr;
total[n-1] = total[n-1] + integral/1000.;
gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1]));
if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl;
}
}
TH1D* h1corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),0,0,1.9,4.0);
TH1D* h2corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),11,0,1.9,4.0);
TCanvas* ccorr = new TCanvas("ccorr","ccorr",900,400);
ccorr->Divide(2,1);
ccorr->cd(1);
ccorr->GetPad(1)->SetLeftMargin(0.23);
h1corr->SetAxisRange(50.9,52.,"Y");
h1corr->GetYaxis()->SetTitleOffset(1.2);
h1corr->GetXaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98);
h1corr->GetYaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98);
h1corr->GetXaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98);
h1corr->GetYaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98);
h1corr->GetYaxis()->SetTitleOffset(h1corr->GetYaxis()->GetTitleOffset()*1.4);
h1corr->GetXaxis()->CenterTitle();
h1corr->GetYaxis()->CenterTitle();
h1corr->Draw("PE");
ccorr->cd(2);
ccorr->GetPad(2)->SetLeftMargin(0.23);
h2corr->SetAxisRange(50.8,52.4,"Y");
h2corr->GetYaxis()->SetTitleOffset(1.2);
h2corr->GetXaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98);
h2corr->GetYaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98);
h2corr->GetXaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98);
h2corr->GetYaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98);
h2corr->GetYaxis()->SetTitleOffset(h2corr->GetYaxis()->GetTitleOffset()*1.4);
h2corr->GetXaxis()->CenterTitle();
h2corr->GetYaxis()->CenterTitle();
h2corr->Draw("PE");
TF1* fitfunc1 = FitVnFunc(h1corr);
TF1* fitfunc2 = FitVnFunc(h2corr);
fitfunc1->SetLineStyle(4);
fitfunc2->SetLineStyle(4);
fitfunc1->SetParameters(fitfunc1->GetParameter(0),Vn0[1],Vn0[2],Vn0[3],Vn0[4],Vn0[5],Vn0[6],Vn0[7],Vn0[8],Vn0[9],Vn0[10]);
fitfunc2->SetParameters(fitfunc2->GetParameter(0),VnArray[1][10],VnArray[2][10],VnArray[3][10],VnArray[4][10],VnArray[5][10],VnArray[6][10],VnArray[7][10],VnArray[8][10],VnArray[9][10],VnArray[10][10]);
ccorr->cd(1);
fitfunc1->Draw("Lsame");
ccorr->cd(2);
示例9: if
void RDK2AnalysisPlotter::makeEPPlot(CoDet detType)
{
gROOT->cd();
TCanvas* theCanvas;
TPad* mainPad;
TPad* titlePad;
TPad* pTPad;
TPad* eEPad;
TPad* pEPad;
TPad* pTPadSubs[3];
TPad* eEPadSubs[3];
TPad* pEPadSubs[3];
int numTitleLines=getTitleBoxLines( detType);
int canvasNumPixelsYPlot=600;
int canvasNumPixelsYPlots=3*canvasNumPixelsYPlot;
int canvasNumPixelsYTitle=40*numTitleLines;
int canvasNumPixelsY=canvasNumPixelsYPlots+canvasNumPixelsYTitle;
theCanvas = new TCanvas("EPExpMCAnalysisComparisonPlot","EPExpMCAnalysisComparisonPlot",10,10,1200,canvasNumPixelsY);
mainPad=(TPad*) theCanvas->GetPad(0);
double ylow,yhigh;
yhigh=1;
ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY;
titlePad=new TPad("titlePad", "titlePad", 0., ylow, 1., yhigh, -1, 1, 1);
yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY;
ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY;
pTPad=new TPad("pTPad", "pTPad", 0., ylow, 1., yhigh, -1, 1, 1);
yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY;
ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY- 2*canvasNumPixelsYPlot/(double)canvasNumPixelsY;
eEPad=new TPad("eEPad", "eEPad", 0., ylow, 1., yhigh, -1, 1, 1);
yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-2*canvasNumPixelsYPlot/(double)canvasNumPixelsY;
ylow=0;
pEPad=new TPad("pEPad", "pEPad", 0., ylow, 1., yhigh, -1, 1, 1);
titlePad->Draw();
pTPad->Draw();
eEPad->Draw();
pEPad->Draw();
// titlePad=(TPad*) theCanvas->GetPad(1);
// pTPad=(TPad*) theCanvas->GetPad(2);
// eEPad=(TPad*) theCanvas->GetPad(3);
// pEPad=(TPad*) theCanvas->GetPad(4);
titlePad->SetMargin(0.05,0.0,0.0,0.0);
pTPad->SetMargin(0.05,0.0,0.0,0.05);
pEPad->SetMargin(0.05,0.0,0.0,0.05);
eEPad->SetMargin(0.05,0.0,0.0,0.05);
if(numExp+numMC >1)
{
pTPad->Divide(2);
eEPad->Divide(2);
pEPad->Divide(2);
pTPadSubs[0]=(TPad*) pTPad->GetPad(1);
eEPadSubs[0]=(TPad*) eEPad->GetPad(1);
pEPadSubs[0]=(TPad*) pEPad->GetPad(1);
TPad* tempPad;
tempPad=(TPad*) pTPad->GetPad(2);
tempPad->Divide(1,2);
pTPadSubs[1]=(TPad*) tempPad->GetPad(1);
pTPadSubs[2]=(TPad*) tempPad->GetPad(2);
tempPad=(TPad*) pEPad->GetPad(2);
tempPad->Divide(1,2);
pEPadSubs[1]=(TPad*) tempPad->GetPad(1);
pEPadSubs[2]=(TPad*) tempPad->GetPad(2);
tempPad=(TPad*) eEPad->GetPad(2);
tempPad->Divide(1,2);
eEPadSubs[1]=(TPad*) tempPad->GetPad(1);
eEPadSubs[2]=(TPad*) tempPad->GetPad(2);
TPad* allBasePads[10]={titlePad,pTPadSubs[0],pTPadSubs[1],pTPadSubs[2],eEPadSubs[0],eEPadSubs[1],eEPadSubs[2],pEPadSubs[0],pEPadSubs[1],pEPadSubs[2]};
for (int i = 1;i< 10;i++)
{
allBasePads[i]->SetGrid(1,1);
allBasePads[i]->SetTickx(1);
allBasePads[i]->SetTicky(1);
}
pTPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
pEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
eEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
pTPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
pEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
eEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
//.........这里部分代码省略.........
示例10: anaJesFF
//.........这里部分代码省略.........
Double_t fragVarMin = 0,
Double_t fragVarMax = 0.6,
//TString fragVar = "nlrjet",
//TString fragVarTag = "RefJEt",
//TString fragVarTitle = "E_{T}^{RefJet}",
//Double_t fragVarMin = 0,
//Double_t fragVarMax = 250,
TString jextraCut = "",//"(ljcpt[0]-ljcptbg[0])/nlrjet>0.5",
const char * inFile0Name="dj_HCPR-MB-151020to151076_trigana1116.root",
TString header = "HICore-MB",
TString AnaType = "dj")
{
// Define Inputs
TString outdir="out/"+SrcName+"/compare/"+AnaVersion+CmpVersion;
cout << "======= Inputs: ========" << endl;
cout << inFile0Name << endl;
cout << "Analyze: " << modName << endl;
TChain * djTree = new TChain(modName+"/djTree","dijet Tree");
djTree->Add(inFile0Name);
aliases_dijet(djTree,doMC);
// === Declare selection ===
selectionCut anaSel(SrcName,doMC,"S1",NrJEtMin,NrJEtMax,NrJEtMin,2.5);
anaSel.DJCutType = DJCutType;
anaSel.TrkCutType = "Ana";
anaSel.LJExtraCut = jextraCut;
anaSel.AJExtraCut = anaSel.Nr2Aw(jextraCut);
anaSel.Tag2+=TString("_"+modName);
anaSel.SetCut();
anaSel.Print(1);
anaSel.PreviewCuts(djTree,2);
// === Define Output ===
CPlot::sOutDir = outdir;
gSystem->mkdir(outdir.Data(),kTRUE);
// === ana ===
// frag var
Int_t numFragVarBins=40;
AnaFrag anaFragVarNr(fragVarTag,"Nr",djTree,anaSel.FinLJCut(),"",fragVar,"","",numFragVarBins,fragVarMin,fragVarMax);
AnaFrag anaFragVarAw(fragVarTag,"Aw",djTree,anaSel.FinAJCut(),"",anaSel.Nr2Aw(fragVar),"","",numFragVarBins,fragVarMin,fragVarMax);
cout << "=== Correlation Analysis ===" << endl;
// correlations
AnaFrag anaFragVar_AnaJEt(fragVarTag,"JEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_AnaJEt.xtitle = "E_{t}^{Jet}";
anaFragVar_AnaJEt.ytitle = fragVarTitle;
anaFragVar_AnaJEt.PlotCorrelations(anaSel,fragVar,"nljet",anaSel.numJEtBins,anaSel.hisJEtMin,anaSel.hisJEtMax);
AnaFrag anaFragVar_LzJEt(fragVarTag,"LzJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_LzJEt.xtitle = "z^{lead} = p_{T}^{trk}/E_{T}^{Jet}";
anaFragVar_LzJEt.ytitle = fragVarTitle;
anaFragVar_LzJEt.PlotCorrelations(anaSel,fragVar,"lppt[0]/nljet",numFragVarBins,0,1.5);
AnaFrag anaFragVar_JCPtDivJEt(fragVarTag,"JCPtDivJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_JCPtDivJEt.xtitle = "#Sigma_{jet cone} p_{T}^{Trk}/E_{t}^{Jet}";
anaFragVar_JCPtDivJEt.ytitle = fragVarTitle;
anaFragVar_JCPtDivJEt.PlotCorrelations(anaSel,fragVar,"(ljcpt[0]-ljcptbg[0])/nljet",numFragVarBins,0,2);
AnaFrag anaFragVar_JCRAvePtW(fragVarTag,"JCRAvePtW",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_JCRAvePtW.xtitle = "#LT dr(trk,jet) #GT_{p_{T}}";
anaFragVar_JCRAvePtW.ytitle = fragVarTitle;
anaFragVar_JCRAvePtW.PlotCorrelations(anaSel,fragVar,"ljcptr[0]/ljcpt[0]",numFragVarBins,0,0.8);
if (doMC==0) return;
AnaFrag anaFragVar_RefJEt(fragVarTag,"RefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_RefJEt.xtitle = "E_{t}^{RefJet}";
anaFragVar_RefJEt.ytitle = fragVarTitle;
anaFragVar_RefJEt.PlotCorrelations(anaSel,fragVar,"nlrjet",anaSel.numJEtBins,anaSel.hisJEtMin,anaSel.hisJEtMax);
AnaFrag anaFragVar_LzRefJEt(fragVarTag,"LzRefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_LzRefJEt.xtitle = "z^{lead} = p_{T}^{trk}/E_{T}^{RefJet}";
anaFragVar_LzRefJEt.ytitle = fragVarTitle;
anaFragVar_LzRefJEt.PlotCorrelations(anaSel,fragVar,"lppt[0]/nlrjet",numFragVarBins,0,1.5);
AnaFrag anaFragVar_JCPtDivRefJEt(fragVarTag,"JCPtDivRefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
anaFragVar_JCPtDivRefJEt.xtitle = "#Sigma_{jet cone} p_{T}^{Trk}/E_{t}^{RefJet}";
anaFragVar_JCPtDivRefJEt.ytitle = fragVarTitle;
anaFragVar_JCPtDivRefJEt.PlotCorrelations(anaSel,fragVar,"(ljcpt[0]-ljcptbg[0])/nlrjet",numFragVarBins,0,2);
AnaFrag anaFragVar_JResp("JResp",fragVarTag,djTree,numFragVarBins,0,2);
anaFragVar_JResp.xtitle = fragVarTitle;
anaFragVar_JResp.ytitle = "E_{T}^{RecoJet}/E_{t}^{RefJet}";
anaFragVar_JResp.PlotCorrelations(anaSel,"nljet/nlrjet",fragVar,numFragVarBins,fragVarMin,fragVarMax);
// -- plot frag var--
TCanvas * cFragVar = new TCanvas("c"+fragVarTag,"c"+fragVarTag,1000,500);
cFragVar->Divide(2,1);
CPlot cpFragVar(fragVarTag+anaSel.Tag2,fragVarTag,fragVarTitle,"unit normalization");
cpFragVar.SetLogy();
cpFragVar.AddHist1D(anaFragVarNr.hRaw,"Leading Jet","E",kRed,kOpenCircle);
cpFragVar.AddHist1D(anaFragVarAw.hRaw,"Away Jet","E",kBlue,kOpenSquare);
cFragVar->cd(1); cpFragVar.Draw((TPad*)cFragVar->GetPad(1),false);
CPlot cpJRespFragVar(fragVarTag+"_JResp"+anaSel.Tag2,fragVarTag,fragVarTitle,"unit normalization");
cpJRespFragVar.AddHist1D(anaFragVar_JResp.hCorrelProfNr,"Leading Jet","E",kRed,kOpenCircle);
cpJRespFragVar.AddHist1D(anaFragVar_JResp.hCorrelProfAw,"Away Jet","E",kBlue,kOpenSquare);
cFragVar->cd(2); cpJRespFragVar.Draw((TPad*)cFragVar->GetPad(2),false);
cFragVar->Print(CPlot::sOutDir+"/"+fragVarTag+anaSel.Tag2+".gif");
}
示例11: CheckPhysics
void CheckPhysics(){
Char_t* hname[] = {
"1", "EtaM_Nphoton", "log", "",
"2", "EtaM_Nproton", "log", "",
// "3", "EtaM_Nneutron", "log", "",
"3", "EtaM_Npi0", "log", "",
// "5", "EtaM_Npiplus", "log", "",
"4", "EtaM_Neta", "log", "",
"5", "EtaM_M2g", "log", "",
"6", "EtaM_M6g", "lin", "",
"7", "EtaM_EmEtaP", "lin", "",
"7", "EtaM_EmEtaR", "lin", "Same",
"8", "EtaM_EmEtapP", "lin", "",
"8", "EtaM_EmEtapR", "lin", "Same",
// "8", "EtaM_EmComptonpP", "lin", "",
// "8", "EtaM_EmComptonpR", "lin", "Same",
"9", "EtaM_M2gCBTAPS","lin", "",
"10", "EtaM_M2g_v_CB_NaI_ClNhitsOR", "log", "CONTZ",
"11", "EtaM_M2g_v_TAGG_FPD_HitsPrompt", "log", "COLZ",
"12", "EtaM_M6g_v_TAGG_FPD_HitsPrompt", "log", "COLZ",
};
Int_t col[] = { 2,2,2,2, 3,3,3,5,3,5,3,2,2,2,1,1 };
Int_t xxx;
Char_t* xname[] = {
"Number Reconstructed #gamma per event",
"Number Reconstructed p per event",
// "Number Reconstructed n per event",
"Number Reconstructed #pi^{0} per event",
// "Number Reconstructed #pi^{+} per event",
"Number Reconstructed #eta per event",
"2-#gamma Invariant Mass",
"6-#gamma Invariant Mass",
"Missing Mass if QF #eta (Gr-prompt, Yell-rand) ",
"",
"Missing Energy if QF #eta-p (Gr-prompt, Yell-rand)",
"",
"2-#gamma Invariant Mass (1-#gamma CB, 1-#gamma TAPS)",
"2-#gamma Invariant Mass vs CB Cluster Size",
"2-#gamma Invariant Mass vs Prompt Tagger Hits",
"6-#gamma Invariant Mass vs Prompt Tagger Hits",
};
Char_t* cloneName[] = {"rand1", "rand2", "rand3", "rand4"};
TH1F* h1r;
TH1F** ph1r[4];
for( Int_t i=0; i<2; i++ ){
h1r = (TH1F*)gROOT->FindObject(cloneName[i]);
if( !h1r ) h1r = new TH1F("cloneName[i]","Photo-Hist",1000,0,1000);
ph1r[i] = h1r;
}
//
TH1F* h1;
TH2F* h2;
// TH1F* h3 = new TH1F("h3x","Photo-Hist",10000,-5000,5000);
// TH1F* h4 = new TH1F("h4x","Photo-Hist",10000,-5000,5000);
// TH1F* h5 = new TH1F("h5x","Photo-Hist",10000,-5000,5000);
TCanvas* canv = new TCanvas("Physics-Spectra","Physics-Online",240,180,1240,890);
canv->Divide(4,3);
Int_t i = 0;
Int_t k = 0;
Int_t j;
Int_t pad_no;
for( j=0; j<44; j+=4){
sscanf(hname[j], "%d", &pad_no); // pad_no is 1st arg.
canv->cd(pad_no);
// printf("%d %d %d %s %s %s %s\n",pad_no,j,i,hname[j],hname[j+1],hname[j+2],hname[j+3]);
h1 = (TH1F*)gROOT->FindObjectAny(hname[j+1]); // name is 2nd argument
if( !h1 ){
printf("No object named '%s' was found.\n Check your macro!\n", hname[j+1]);
}
else{
if(strcmp(hname[j+3], "Same") == 0){
h1r = ph1r[k];
h1->Copy(*h1r);
*h1r = *h1r * 0.5;
h1 = h1r;
k++;
}
if(strcmp(hname[j+2], "log") == 0) // lin/log 3rd argument
canv->GetPad(pad_no)->SetLogy();
h1->GetXaxis()->SetTitle(xname[i]);
h1->SetLineColor( 1 );
h1->SetFillColor( col[i] );
h1->Draw(hname[j+3]); // parameter 4th arg.
gPad->RedrawAxis();
}
i++;
}
for( j=44; j<56; j+=4){
sscanf(hname[j], "%d", &pad_no); // pad_no is 1st arg.
canv->cd(pad_no);
// printf("%d %d %d\n",pad_no,j,i);
h2 = (TH2F*)gROOT->FindObjectAny(hname[j+1]); // name is 2nd argument
if( !h2 ){
printf("No object named '%s' was found.\n Check your macro!\n", hname[j+1]);
}
else{
if(strcmp(hname[j+2], "log") == 0) // lin/log 3rd argument
canv->GetPad(pad_no)->SetLogz();
h2->GetXaxis()->SetTitle(xname[i]);
h2->Draw(hname[j+3]); // parameter 4th arg.
//.........这里部分代码省略.........
示例12: CommandMSUGRA
void CommandMSUGRA(TString plotName,Int_t tanBeta_, Bool_t plotLO_, Bool_t tb40_plotExpected) {
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
gStyle->SetPalette(1);
gStyle->SetTextFont(42);
gStyle->SetFrameBorderMode(0);
//convert tanb value to string
std::stringstream tmp;
tmp << tanBeta_;
TString tanb( tmp.str() );
// Output file
std::cout << " create " << plotName << std::endl;
TFile* output = new TFile( plotName, "RECREATE" );
if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
//set old exclusion Limits
TGraph* LEP_ch = set_lep_ch(tanBeta_);
TGraph* LEP_sl = set_lep_sl(tanBeta_);//slepton curve
TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);//squark gluino cdf
TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);//squark gluino d0
// TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_);//trilepton cdf
// TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);//trilepton d0
TGraph* stau = set_tev_stau(tanBeta_);//stau
TGraph* NoEWSB = set_NoEWSB(tanBeta_);
TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);
//some tan beta 40 stuff (load the squark and gluino mass lines)
TGraph2D* squarkMasses=0;
TGraph2D* gluinoMasses=0;
if (tanBeta_==40) {
const int nPoints = nSusyGridPoints();
double m0[nPoints],m12[nPoints],squarkMass[nPoints],gluinoMass[nPoints];
susyGrid(m0,m12,squarkMass,gluinoMass);
squarkMasses = new TGraph2D("squarkMasses","",nPoints,m0,m12,squarkMass);
gluinoMasses = new TGraph2D("gluinoMasses","",nPoints,m0,m12,gluinoMass);
gluinoMasses->GetHistogram();
squarkMasses->GetHistogram();
}
// end of tan beta 40 stuff
//constant squark and gluino lines
TF1* lnsq[10];
TF1* lngl[10];
TLatex* sq_text[10];
TLatex* gl_text[10];
//versions for tan beta 40
TGraph* lnsq_40[15];
TGraph* lngl_40[15];
TLatex* sq_40_text[15];
TLatex* gl_40_text[15];
int loopmax = 6;
if (tanBeta_==40) loopmax=15;
for(int i = 0; i < loopmax; i++){
if (tanBeta_==10) {
lnsq[i] = constant_squark(tanBeta_,i);
sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
lngl[i] = constant_gluino(tanBeta_,i);
gl_text[i] = constant_gluino_text(i,*lngl[i]);
}
else if (tanBeta_==40) {
lnsq_40[i] = constant_mass(i*250,squarkMasses);
lngl_40[i] = constant_mass(i*250,gluinoMasses);
sq_40_text[i] = constant_squark_text_tanBeta40(i*250,lnsq_40[i]);
gl_40_text[i] = constant_gluino_text_tanBeta40(i*250,lngl_40[i]);;
}
}
//Legends
TLegend* legst = makeStauLegend(0.05,tanBeta_);
// TLegend* legNoEWSB = makeNoEWSBLegend(0.05,tanBeta_);
TLegend* legexp = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
//make Canvas
TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
gStyle->SetOptTitle(0);
cvsSys->SetFillColor(0);
cvsSys->GetPad(0)->SetRightMargin(0.07);
cvsSys->Range(-120.5298,26.16437,736.0927,750);
// cvsSys->Range(-50.5298,26.16437,736.0927,500);
cvsSys->SetFillColor(0);
cvsSys->SetBorderMode(0);
cvsSys->GetPad(0)->SetBorderMode(0);
cvsSys->GetPad(0)->SetBorderSize(2);
cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
cvsSys->GetPad(0)->SetTopMargin(0.08);
cvsSys->GetPad(0)->SetBottomMargin(0.13);
//.........这里部分代码省略.........
示例13: hv_scan
//.........这里部分代码省略.........
// -- lower limit is in place to remove low gain junk
// -- mean error must be less than mean
if(adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) > 10 &&
adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) <= 3800 &&
adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) >
adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParError(1))
{
if(nstb==1||nstb==2) hv=largehv[r];
else hv=smallhv[r];
// NSTB==4 LOST COMMUNICATION RUNS 020012-16; THIS FILTERS IT OUT (FILTER DISABLED)
// to enable filter, place the following if statement:
// if(!(r>=8 && nstb==4)) { around SetPoint & SetPointError & gaingr_i++ lines }
gaingr[nstb-1][row][col]->SetPoint(gaingr_i[nstb-1][row][col],hv,
adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1));
gaingr[nstb-1][row][col]->SetPointError(gaingr_i[nstb-1][row][col],0,
adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParError(1));
(gaingr_i[nstb-1][row][col])++;
hv_midcalc_low = (hv < hv_midcalc_low) ? hv:hv_midcalc_low;
hv_midcalc_high = (hv > hv_midcalc_high) ? hv:hv_midcalc_high;
};
};
// draw ADC dists to canvas
cdno=(canv_row-1)*NUM+r+canv_row;
if(cdno==1)
{
adccanv->Clear();
adccanv->Divide(NUM,1);
};
//printf("--- %d %d %d %d %d %p\n",cdno,nstb-1,row,col,r,(void*)(adccanv->GetPad(cdno)));
adccanv->GetPad(cdno)->SetLogx();
adccanv->GetPad(cdno)->SetLogy();
adccanv->GetPad(cdno)->cd();
adcdist[nstb-1][row][col][r]->Draw();
//adcdist[nstb-1][row][col][r]->Write();
};
hv_mid = (hv_midcalc_low+hv_midcalc_high)/2.0;
// fit ADC vs. HV gain curves and fill hvtr tree
gaincanv->cd();
gaincanv->SetLogy();
gaincanv->SetGrid(1,1);
// fit left half & right half of HV range separately, and choose the one with the
// better chisq to be the gain curve; this technique helps to avoid the cases where
// an outlier point draws the fit away from the trending data points
if(gaingr_i[nstb-1][row][col])
{
// fit left half (L), right half (R) and all points (A)
gaingr[nstb-1][row][col]->Fit(gaingr_fitL[nstb-1][row][col],"MQN","",hv_low,hv_mid);
gaingr[nstb-1][row][col]->Fit(gaingr_fitA[nstb-1][row][col],"MQN","",hv_low,hv_high);
gaingr[nstb-1][row][col]->Fit(gaingr_fitR[nstb-1][row][col],"MQN","",hv_mid,hv_high);
// parameter, chisq, and ndf "array", where array index is
// 0 for L (left half fit)
// 1 for A (all points fit)
// 2 for R (right half fit)
scale_arr[0] = gaingr_fitL[nstb-1][row][col]->GetParameter(0);
alpha_arr[0] = gaingr_fitL[nstb-1][row][col]->GetParameter(1);
chisq_arr[0] = gaingr_fitL[nstb-1][row][col]->GetChisquare();
ndf_arr[0] = gaingr_fitL[nstb-1][row][col]->GetNDF();
scale_arr[1] = gaingr_fitA[nstb-1][row][col]->GetParameter(0);
alpha_arr[1] = gaingr_fitA[nstb-1][row][col]->GetParameter(1);
示例14: checkTrkInputs
void checkTrkInputs(
TString infrec="nt_djhp_HyUQ110v0_djcalo.root",
TString infgen="nt_djhp_HyUQ110v0_djcalo_genp.root",
TCut evtCut="cent<30")
{
//TH1::SetDefaultSumw2();
TChain * trec = new TChain("tjttrk");
trec->Add(infrec);
setupAlias(trec);
TChain * tgen = new TChain("tjttrk");
tgen->Add(infgen);
cout << infrec << " cut " << TString(evtCut) << ": " << trec->GetEntries() << endl;
cout << infgen << " cut " << TString(evtCut) << ": " << tgen->GetEntries() << endl;
// Correction Histograms
TFile * fTrkCorr = new TFile("djtrkhist_hydjetBassv2_djuq110.root");
TString corrModule = "hitrkEffAnalyzer";
TH2F * hrec = (TH2F*)fTrkCorr->Get(Form("%s/hrec",corrModule.Data()));
TH1D * hrec_pt = (TH1D*)hrec->ProjectionY();
TH2F * hsim = (TH2F*)fTrkCorr->Get(Form("%s/hsim",corrModule.Data()));
TH1D * hsim_pt = (TH1D*)hsim->ProjectionY();
// Frag Histograms
//TH1D * hPPtRecRaw = new TH1D("hPPtRecRaw",";p_{T} (GeV/c); count;");
TH1D * hPPtRecRaw = (TH1D*)hrec_pt->Clone("hPPtRecRaw");
hPPtRecRaw->Reset();
TH1D * hPPtGen = (TH1D*)hrec_pt->Clone("hPPtGen");
hPPtGen->Reset();
trec->Project("hPPtRecRaw","ppt","");
tgen->Project("hPPtGen","ppt","");
TH1D * hRecSimRat_pt = (TH1D*)hrec_pt->Clone("hRecSimRat_pt");
hRecSimRat_pt->Sumw2();
hRecSimRat_pt->Divide(hrec_pt,hsim_pt);
TH1D * hPPtRat = (TH1D*)hrec_pt->Clone("hPPtRat");
hPPtRat->Sumw2();
hPPtRat->Divide(hPPtRecRaw,hPPtGen);
// Normalize
normHist(hsim_pt,0,true,1);
normHist(hrec_pt,0,true,1);
normHist(hPPtGen,0,true,1);
normHist(hPPtRecRaw,0,true,1);
// Plot
hsim_pt->SetAxisRange(0,100,"X");
hsim_pt->SetTitle(";p_{T} (GeV/c); count");
hRecSimRat_pt->SetTitle(";p_{T} (GeV/c); reco/gen ratio");
hsim_pt->SetLineColor(kRed);
hPPtGen->SetMarkerColor(kRed);
hPPtGen->SetLineColor(kRed);
hRecSimRat_pt->SetAxisRange(0,100,"X");
hRecSimRat_pt->SetAxisRange(-0.2,1.2,"Y");
hRecSimRat_pt->SetLineColor(kRed);
TCanvas *cRec = new TCanvas("cRec","Rec",500,900);
cRec->Divide(1,2);
cRec->cd(1);
cRec->GetPad(1)->SetLogy();
hsim_pt->Draw("hist");
hPPtGen->Draw("sameE");
hrec_pt->Draw("hist same");
hPPtRecRaw->Draw("sameE");
cRec->cd(2);
hRecSimRat_pt->Draw("hist");
hPPtRat->Draw("sameE");
// ====================
TLegend *leg = new TLegend(0.61,0.78,0.91,0.91);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.035);
}
示例15: DrawMLPoutputMovie
//.........这里部分代码省略.........
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);
}
}