本文整理汇总了C++中TCanvas::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::GetName方法的具体用法?C++ TCanvas::GetName怎么用?C++ TCanvas::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveCanvas
// ______________________________________________________________________________________
void SaveCanvas(const Char_t* name, Bool_t isNice = kTRUE) {
// -- Write out canvas
gSystem->Exec(Form("mkdir -p results/nice/%s/png", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/pdf", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/eps", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/gif", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/root", name));
if (isNice) {
gSystem->Exec(Form("mkdir -p results/nice/pdf"));
gSystem->Exec(Form("mkdir -p results/nice/png"));
}
// -----------------------------------------------------
for (Int_t idx = 0; idx < canA.GetEntriesFast() ; ++idx) {
TCanvas* c = static_cast<TCanvas*>(canA.At(idx));
if (!c)
continue;
c->SaveAs(Form("results/nice/%s/png/%s.png", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/eps/%s.eps", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/gif/%s.gif", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/pdf/%s.pdf", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/root/%s.C", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/root/%s.root", name, c->GetName()));
if (isNice) {
c->SaveAs(Form("results/nice/pdf/%s.pdf", c->GetName()));
c->SaveAs(Form("results/nice/png/%s.png", c->GetName()));
}
}
}
示例2: printAllCanvases
//--- Print all created canvasses ---
void printAllCanvases(const char* folder="plots")
{
TSeqCollection * sc = dynamic_cast<TSeqCollection*>(gROOT->GetListOfCanvases());
for (int i =0; i<sc->GetSize(); ++i) {
TCanvas * c = dynamic_cast<TCanvas*>(sc->At(i));
TString cname(c->GetName());
printf("Canvas: %s/%s.gif\n",folder,cname.Data());
c->Print(Form("%s/%s.gif",folder,cname.Data()));
}
}
示例3: printCanvasesPS
// Print all canvases in a single PS file
void printCanvasesPS(TString name){
TPostScript * ps = new TPostScript(name,112);
TIter iter(gROOT->GetListOfCanvases());
TCanvas *c;
while( (c = (TCanvas *)iter()) )
{
cout << "Printing " << c->GetName() << endl;
ps->NewPage();
c->Draw();
}
cout << " File " << name << " was created" << endl;
ps->Close();
}
示例4: SaveAsPdf
void KVSpiderIdentificator::SaveAsPdf(Option_t* opt_, const Char_t* path_)
{
Draw(opt_);
TCanvas* cc = (TCanvas*) gROOT->FindObject(_htot->GetName());
_htot->RebinX(4);
_htot->RebinY(4);
CheckPath(path_);
cc->Print(Form("%s/%s.pdf", path_, cc->GetName()), "pdf");
cc->Close();
delete cc;
}
示例5: AliTRDCheckPedestal
//__________________________________________________________
void AliTRDCheckPedestal(const Int_t runNr){
// Establish grid connection
if(!TGrid::Connect("alien://")){printf("F-No grid connection\n");return;}
// Set the storage to the OCDB of this runNr. It will be like
// alien://folder=/alice/data/2016/OCDB
AliCDBManager *man = AliCDBManager::Instance();
man->SetDefaultStorageFromRun(runNr);
// We derive the reference storage from it
const AliCDBStorage *stor = man->GetDefaultStorage();
TString folder = stor->GetBaseFolder();
folder.ReplaceAll("OCDB","Reference");
man->SetDefaultStorage(Form("alien://folder=%s",folder.Data()));
// Set the run number
man->SetRun(runNr);
// We abuse the folder name to derive the year
TString yearString(folder);
yearString.ReplaceAll("/alice/data/","");
yearString.ReplaceAll("/Reference/","");
const Int_t year = yearString.Atoi();
printf("W-Experimental: Derived year %d from storage folder\n",year);
// The reference data is stored per Local Data Concentrator
std::vector<Int_t> LDCvec = GetLDCVector(year);
// Loop over LDCs
for(std::vector<Int_t>::iterator LDCit = LDCvec.begin();LDCit!=LDCvec.end();LDCit++){
const TString padstatus = Form("TRD/DAQData/PadStatus%d",*LDCit);
AliCDBEntry *entry = AliCDBManager::Instance()->Get(padstatus.Data());
AliTRDCalibPadStatus *calpadstatus = dynamic_cast<AliTRDCalibPadStatus *>(entry->GetObject());
if(!calpadstatus){printf("E-Can not find %s in %s \n",padstatus.Data(),folder.Data());continue;}
//Create the noise pad with the RMS values of each channel
AliTRDCalPad *noisePad = calpadstatus->CreateCalPad();
// LDC -> SM mapping
std::vector<Int_t> SMvec = GetSMVector(year,*LDCit);
for(std::vector<Int_t>::iterator SMit=SMvec.begin();SMit!=SMvec.end();SMit++){
const TString padstatussm = Form("PadNoise-LDC%d-SM%02d",*LDCit,*SMit);
TCanvas *cpadstatusm = new TCanvas(padstatussm.Data(),padstatussm.Data(),50,50,600,800);
cpadstatusm->Divide(3,2);
// Draw each layer (or here plane)
const Float_t zRange[2]={0.,0.2};
for(Int_t iLayer = 0;iLayer<6;iLayer++){
cpadstatusm->cd(iLayer+1);
noisePad->MakeHisto2DSmPl(*SMit,iLayer,0,0,zRange[0],zRange[1],-1)->Draw("colz");
}
cpadstatusm->SaveAs(Form("%s.pdf",cpadstatusm->GetName()));
} // Loop over SMs of this LDC
} // End of loop over LDCs
} // End of void AliTRDcheckPedestal
示例6: superimposeHistos
void superimposeHistos()
{
TFile* bFile = TFile::Open("Electron_In_Jets_900GeV_bJets.root");
TFile* cFile = TFile::Open("Electron_In_Jets_900GeV_cJets.root");
TFile* udsgFile = TFile::Open("Electron_In_Jets_900GeV_udsgJets.root");
TIter next(bFile->GetListOfKeys());
TFile* newFile = new TFile("testFile.root", "RECREATE");
while(TKey* key = (TKey*)next())
{
TH1F* bHist = (TH1F*)bFile->Get(key->GetName());
bHist->SetFillColor(2);
TH1F* cHist = (TH1F*)cFile->Get(key->GetName());
cHist->SetFillColor(3);
TH1F* udsgHist = (TH1F*)udsgFile->Get(key->GetName());
udsgHist->SetFillColor(4);
THStack* stack = new THStack(bHist->GetName(), bHist->GetTitle());
stack->Add(udsgHist, "hist ][");
stack->Add(cHist, "hist ][");
stack->Add(bHist, "hist ][");
TLegend* legend = new TLegend(0.5, 0.68, 0.88, 0.88);
legend->AddEntry(bHist, "b-Jets");
legend->AddEntry(cHist, "c-Jets");
legend->AddEntry(udsgHist, "udsg-Jets");
TCanvas* canvas = new TCanvas(bHist->GetName());
stack->Draw();
stack->GetXaxis()->SetTitle(bHist->GetXaxis()->GetTitle());
legend->Draw();
canvas->Write(canvas->GetName());
}
newFile->Close();
bFile->Close();
cFile->Close();
udsgFile->Close();
}
示例7: extractObjectFromFile
TList* extractObjectFromFile(const char* fileName, const char* name)
{
TList* objects = new TList();
TFile file(fileName);
gROOT->cd();
TList* keyList = file.GetListOfKeys();
for (int i = 0; i < keyList->GetSize(); ++i) {
TKey* key = static_cast<TKey*>(keyList->At(i));
std::cout<< key->GetName()<< std::endl;
if (!strcmp(key->GetName(), name)) {
objects->Add(key->ReadObj()->Clone());
} else if (!strcmp(key->GetClassName(), "TCanvas")) {
TCanvas* canvas = static_cast<TCanvas*>(key->ReadObj());
if (!strcmp(canvas->GetName(), name))
objects->Add(canvas->Clone());
TList* objectsFromPad = extractObjectFromPad(canvas, name);
for (int j = 0; j < objectsFromPad->GetSize(); ++j)
objects->Add(objectsFromPad->At(j));
}
}
file.Close();
return objects;
}
示例8: plot
void plot( TString var, TString data, TString pdf, double low=-1, double high=-1 ) {
TFile *tf = TFile::Open( "root/FitOut.root" );
RooWorkspace *w = (RooWorkspace*)tf->Get("w");
TCanvas *canv = new TCanvas("c","c",800,800);
TPad *upperPad = new TPad(Form("%s_upper",canv->GetName()),"",0.,0.33,1.,1.);
TPad *lowerPad = new TPad(Form("%s_lower",canv->GetName()),"",0.,0.,1.,0.33);
canv->cd();
upperPad->Draw();
lowerPad->Draw();
if ( low < 0 ) low = w->var(var)->getMin();
if ( high < 0 ) high = w->var(var)->getMax();
RooPlot *plot = w->var(var)->frame(Range(low,high));
w->data(data)->plotOn(plot);
w->pdf(pdf)->plotOn(plot);
RooHist *underHist = plot->pullHist();
underHist->GetXaxis()->SetRangeUser(plot->GetXaxis()->GetXmin(), plot->GetXaxis()->GetXmax());
underHist->GetXaxis()->SetTitle(plot->GetXaxis()->GetTitle());
underHist->GetYaxis()->SetTitle("Pull");
underHist->GetXaxis()->SetLabelSize(0.12);
underHist->GetYaxis()->SetLabelSize(0.12);
underHist->GetXaxis()->SetTitleSize(0.2);
underHist->GetXaxis()->SetTitleOffset(0.7);
underHist->GetYaxis()->SetTitleSize(0.18);
underHist->GetYaxis()->SetTitleOffset(0.38);
plot->GetXaxis()->SetTitle("");
upperPad->SetBottomMargin(0.1);
upperPad->cd();
plot->Draw();
canv->cd();
lowerPad->SetTopMargin(0.05);
lowerPad->SetBottomMargin(0.35);
lowerPad->cd();
underHist->Draw("AP");
double ymin = underHist->GetYaxis()->GetXmin();
double ymax = underHist->GetYaxis()->GetXmax();
double yrange = Max( Abs( ymin ), Abs( ymax ) );
underHist->GetYaxis()->SetRangeUser( -1.*yrange, 1.*yrange );
double xmin = plot->GetXaxis()->GetXmin();
double xmax = plot->GetXaxis()->GetXmax();
TColor *mycol3sig = gROOT->GetColor( kGray );
mycol3sig->SetAlpha(0.5);
TColor *mycol2sig = gROOT->GetColor( kGray+1 );
mycol2sig->SetAlpha(0.5);
TColor *mycol1sig = gROOT->GetColor( kGray+2 );
mycol1sig->SetAlpha(0.5);
TBox box3sig;
box3sig.SetFillColor( mycol3sig->GetNumber() );
//box3sig.SetFillColorAlpha( kGray, 0.5 );
box3sig.SetFillStyle(1001);
box3sig.DrawBox( xmin, -3., xmax, 3.);
TBox box2sig;
box2sig.SetFillColor( mycol2sig->GetNumber() );
//box2sig.SetFillColorAlpha( kGray+1, 0.5 );
box2sig.SetFillStyle(1001);
box2sig.DrawBox( xmin, -2., xmax, 2.);
TBox box1sig;
box1sig.SetFillColor( mycol1sig->GetNumber() );
//box1sig.SetFillColorAlpha( kGray+2, 0.5 );
box1sig.SetFillStyle(1001);
box1sig.DrawBox( xmin, -1., xmax, 1.);
TLine lineErr;
lineErr.SetLineWidth(1);
lineErr.SetLineColor(kBlue-9);
lineErr.SetLineStyle(2);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),1.,plot->GetXaxis()->GetXmax(),1.);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),-1.,plot->GetXaxis()->GetXmax(),-1.);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),2.,plot->GetXaxis()->GetXmax(),2.);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),-2.,plot->GetXaxis()->GetXmax(),-2.);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),3.,plot->GetXaxis()->GetXmax(),3.);
lineErr.DrawLine(plot->GetXaxis()->GetXmin(),-3.,plot->GetXaxis()->GetXmax(),-3.);
TLine line;
line.SetLineWidth(3);
line.SetLineColor(kBlue);
line.DrawLine(plot->GetXaxis()->GetXmin(),0.,plot->GetXaxis()->GetXmax(),0.);
underHist->Draw("Psame");
RooHist *redPull = new RooHist();
int newp=0;
for (int p=0; p<underHist->GetN(); p++) {
double x,y;
underHist->GetPoint(p,x,y);
if ( TMath::Abs(y)>3 ) {
redPull->SetPoint(newp,x,y);
redPull->SetPointError(newp,0.,0.,underHist->GetErrorYlow(p),underHist->GetErrorYhigh(p));
newp++;
}
}
redPull->SetLineWidth(underHist->GetLineWidth());
redPull->SetMarkerStyle(underHist->GetMarkerStyle());
//.........这里部分代码省略.........
示例9: CheckTime
//______________________________________________________________________________
void CheckTime(const Char_t* loc)
{
// Check time.
Char_t t[256];
// number of runs
Int_t nRuns = gFiles->GetSize();
// create arrays
const Int_t nCh = 352;
Double_t** pedPos = new Double_t*[nCh];
Double_t* runNumbersD = new Double_t[nRuns];
for (Int_t i = 0; i < nCh; i++) pedPos[i] = new Double_t[nRuns];
// open the output files
TFile* fROOTout = new TFile("/tmp/tagger_time.root", "RECREATE");
// create directories
for (Int_t i = 0; i < nCh; i++)
{
sprintf(t, "%03d", i);
fROOTout->mkdir(t);
}
TF1* func = new TF1("func", "gaus(0)+pol1(3)", -1000 , 1000);
// loop over runs
for (Int_t i = 0; i < nRuns; i++)
{
// get the file
TFile* f = (TFile*) gFiles->At(i);
// extract run number
Int_t runNumber;
sprintf(t, "%s/ARHistograms_CB_%%d.root", loc);
sscanf(f->GetName(), t, &runNumber);
runNumbersD[i] = (Double_t)runNumber;
printf("Processing run %d (%d/%d)\n", runNumber, i+1, nRuns);
fROOTout->cd();
TH2* h2 = (TH2*) f->Get("CaLib_Tagger_Time");
// loop over channels
for (Int_t j = 0; j < nCh; j++)
{
// load histogram
sprintf(t, "%03d", j);
fROOTout->cd(t);
sprintf(t, "%d_%d", i, j);
TH1* h = h2->ProjectionX(t, j+1, j+1);
h->Rebin(2);
sprintf(t, "Run_%d", runNumber);
TCanvas* c = new TCanvas(t, t);
TLine* tline = 0;
// check entries
if (h->GetEntries())
{
// fit gaussian to peak
Double_t maxPos = h->GetXaxis()->GetBinCenter(h->GetMaximumBin());
func->SetParameters(1, maxPos, 0.5, 1, 0.1);
func->SetRange(maxPos - 2, maxPos + 2);
func->SetParLimits(0, 0, 1000);
for (Int_t k = 0; k < 10; k++)
if (!h->Fit(func, "RBQ")) break;
// save position in file and memory
maxPos = func->GetParameter(1);
pedPos[j][i] = maxPos;
h->GetXaxis()->SetRangeUser(maxPos - 10, maxPos + 10);
h->Draw();
tline = new TLine(maxPos, 0, maxPos, 10000);
tline->SetLineColor(kRed);
tline->SetLineWidth(2);
tline->Draw();
}
else
{
h->Draw();
}
c->Write(c->GetName(), TObject::kOverwrite);
delete h;
delete c;
if (tline) delete tline;
}
delete h2;
}
// create pedestal evolution graphs
fROOTout->cd();
//.........这里部分代码省略.........
示例10: CreateTemplatesForW
void CreateTemplatesForW(TString CAT, TString CUT)
{
gROOT->ForceStyle();
RooMsgService::instance().setSilentMode(kTRUE);
RooMsgService::instance().setStreamStatus(0,kFALSE);
RooMsgService::instance().setStreamStatus(1,kFALSE);
TFile *infMC = TFile::Open("Histo_TT_TuneCUETP8M1_13TeV-powheg-pythia8.root");
TFile *infData = TFile::Open("Histo_JetHT.root");
TH1F *hMC,*hData;
RooDataHist *roohMC,*roohData;
RooAddPdf *signal,*qcd;
TString VAR,TAG;
float XMIN,XMAX;
VAR = "mW";
TAG = CUT+"_"+CAT;
XMIN = 20.;
XMAX = 160.;
RooWorkspace *w = new RooWorkspace("w","workspace");
//---- define observable ------------------------
RooRealVar *x = new RooRealVar("mW","mW",XMIN,XMAX);
w->import(*x);
//---- first do the data template ---------------
hData = (TH1F*)infData->Get("boosted/h_mW_"+CUT+"_0btag");
hData->Rebin(5);
roohData = new RooDataHist("roohistData","roohistData",RooArgList(*x),hData);
//---- QCD -----------------------------------
RooRealVar bBkg0("qcd_b0","qcd_b0",0.5,0,1);
RooRealVar bBkg1("qcd_b1","qcd_b1",0.5,0,1);
RooRealVar bBkg2("qcd_b2","qcd_b2",0.5,0,1);
RooRealVar bBkg3("qcd_b3","qcd_b3",0.5,0,1);
RooBernstein qcd1("qcd_brn","qcd_brn",*x,RooArgList(bBkg0,bBkg1,bBkg2,bBkg3));
RooRealVar mQCD("qcd_mean2" ,"qcd_mean2",40,0,100);
RooRealVar sQCD("qcd_sigma2","qcd_sigma2",20,0,50);
RooGaussian qcd2("qcd_gaus" ,"qcd_gaus",*x,mQCD,sQCD);
RooRealVar fqcd("qcd_f1","qcd_f1",0.5,0,1);
qcd = new RooAddPdf("qcd_pdf","qcd_pdf",qcd1,qcd2,fqcd);
//---- plots ---------------------------------------------------
TCanvas *canB = new TCanvas("Template_W_QCD_"+CUT+"_"+CAT,"Template_W_QCD_"+CUT+"_"+CAT,900,600);
RooFitResult *res = qcd->fitTo(*roohData,RooFit::Save());
res->Print();
RooPlot *frameB = x->frame();
roohData->plotOn(frameB);
qcd->plotOn(frameB);
qcd->plotOn(frameB,RooFit::Components("qcd_brn"),RooFit::LineColor(kRed),RooFit::LineWidth(2),RooFit::LineStyle(2));
qcd->plotOn(frameB,RooFit::Components("qcd_gaus"),RooFit::LineColor(kGreen+1),RooFit::LineWidth(2),RooFit::LineStyle(2));
frameB->GetXaxis()->SetTitle("m_{W} (GeV)");
frameB->Draw();
gPad->Update();
canB->Print("plots/"+TString(canB->GetName())+".pdf");
RooArgSet *parsQCD = (RooArgSet*)qcd->getParameters(roohData);
parsQCD->setAttribAll("Constant",true);
w->import(*qcd);
//---- then do the signal templates -------------
hMC = (TH1F*)infMC->Get("boosted/hWt_"+VAR+"_"+TAG);
roohMC = new RooDataHist("roohistTT","roohistTT",RooArgList(*x),hMC);
normMC = ((TH1F*)infMC->Get("eventCounter/GenEventWeight"))->GetSumOfWeights();
hMC->Rebin(2);
RooRealVar m("ttbar_mean","ttbar_mean",90,70,100);
RooRealVar s("ttbar_sigma","ttbar_sigma",20,0,50);
RooGaussian sig_core("ttbar_core","ttbar_core",*x,m,s);
RooRealVar bSig0("ttbar_b0","ttbar_b0",0.5,0,1);
RooRealVar bSig1("ttbar_b1","ttbar_b1",0.5,0,1);
RooRealVar bSig2("ttbar_b2","ttbar_b2",0.5,0,1);
RooRealVar bSig3("ttbar_b3","ttbar_b3",0.5,0,1);
RooRealVar bSig4("ttbar_b4","ttbar_b4",0.5,0,1);
RooRealVar bSig5("ttbar_b5","ttbar_b5",0.5,0,1);
RooRealVar bSig6("ttbar_b6","ttbar_b6",0.5,0,1);
RooRealVar bSig7("ttbar_b7","ttbar_b7",0.5,0,1);
RooRealVar bSig8("ttbar_b8","ttbar_b8",0.5,0,1);
RooBernstein sig_tail("ttbar_tail","ttbar_tail",*x,RooArgList(bSig0,bSig1,bSig2,bSig3,bSig4,bSig5,bSig6,bSig7,bSig8));
RooRealVar fcore("ttbar_fcore","ttbar_fcore",0.5,0,1);
signal = new RooAddPdf("ttbar_pdf","ttbar_pdf",RooArgList(sig_core,sig_tail),RooArgList(fcore));
TCanvas *canS = new TCanvas("Template_W_TT_"+CAT+"_"+CUT,"Template_W_TT_"+CAT+"_"+CUT,900,600);
res = signal->fitTo(*roohMC,RooFit::Save());
//.........这里部分代码省略.........
示例11: exec3event
void exec3event(Int_t event, Int_t x, Int_t y, TObject *selected)
{
TCanvas *c = (TCanvas *) gTQSender;
printf("Canvas %s: event=%d, x=%d, y=%d, selected=%s\n", c->GetName(),
event, x, y, selected->IsA()->GetName());
}
示例12: performFit
//.........这里部分代码省略.........
plotlabel5->AddText(temp);
TPaveText *plotlabel6 = new TPaveText(0.6,0.87,0.8,0.92,"NDC");
plotlabel6->SetTextColor(kBlack);
plotlabel6->SetFillColor(kWhite);
plotlabel6->SetBorderSize(0);
plotlabel6->SetTextAlign(12);
plotlabel6->SetTextSize(0.03);
plotlabel6->AddText("Passing probes");
TPaveText *plotlabel7 = new TPaveText(0.6,0.72,0.8,0.77,"NDC");
plotlabel7->SetTextColor(kBlack);
plotlabel7->SetFillColor(kWhite);
plotlabel7->SetBorderSize(0);
plotlabel7->SetTextAlign(12);
plotlabel7->SetTextSize(0.03);
sprintf(temp, "Eff = %.3f #pm %.3f", ParEfficiency->getVal(), ParEfficiency->getErrorHi());
plotlabel7->AddText(temp);
TPaveText *plotlabel8 = new TPaveText(0.6,0.72,0.8,0.66,"NDC");
plotlabel8->SetTextColor(kBlack);
plotlabel8->SetFillColor(kWhite);
plotlabel8->SetBorderSize(0);
plotlabel8->SetTextAlign(12);
plotlabel8->SetTextSize(0.03);
sprintf(temp, "#chi^{2}/DOF = %.3f", frame1->chiSquare());
plotlabel8->AddText(temp);
plotlabel4->Draw();
plotlabel5->Draw();
plotlabel6->Draw();
plotlabel7->Draw();
plotlabel8->Draw();
// c->SaveAs( cname + TString(".eps"));
c->SaveAs( cname + TString(".gif"));
canvasFile->WriteTObject(c, c->GetName(), "WriteDelete");
Mass.setBins(NBINSFAIL);
cname = TString((label+"_Fail").c_str());
TCanvas* c2 = new TCanvas(cname,cname,800,600);
RooPlot* frame2 = Mass.frame();
frame2->SetMinimum(0);
dataFail->plotOn(frame2,RooFit::DataError(errorType));
pdfFail.plotOn(frame2,RooFit::ProjWData(*dataFail),
RooFit::Components(*bkgFailPdf),RooFit::LineColor(kRed));
pdfFail.plotOn(frame2,RooFit::ProjWData(*dataFail));
frame2->Draw("e0");
plotlabel = new TPaveText(0.23,0.87,0.43,0.92,"NDC");
plotlabel->SetTextColor(kBlack);
plotlabel->SetFillColor(kWhite);
plotlabel->SetBorderSize(0);
plotlabel->SetTextAlign(12);
plotlabel->SetTextSize(0.03);
plotlabel->AddText("CMS Preliminary 2010");
plotlabel2 = new TPaveText(0.23,0.82,0.43,0.87,"NDC");
plotlabel2->SetTextColor(kBlack);
plotlabel2->SetFillColor(kWhite);
plotlabel2->SetBorderSize(0);
plotlabel2->SetTextAlign(12);
plotlabel2->SetTextSize(0.03);
plotlabel2->AddText("#sqrt{s} = 7 TeV");
plotlabel3 = new TPaveText(0.23,0.75,0.43,0.80,"NDC");
plotlabel3->SetTextColor(kBlack);
plotlabel3->SetFillColor(kWhite);
plotlabel3->SetBorderSize(0);
plotlabel3->SetTextAlign(12);
示例13: distribution
//.........这里部分代码省略.........
if (data0_noData1 == 0) {
subpad_1 = new TPad("pad_1","",0.0,0.28,1.0,1.0);
if (yAxisLog_flag) subpad_1->SetLogy();
//subpad_1->SetBottomMargin(0);
subpad_2 = new TPad("pad_2","",0.0,0.0,1.0,0.32);
subpad_2->SetGridy();
//subpad_2->SetTopMargin(0);
subpad_2->SetBottomMargin(0.3);
subpad_1->Draw();
subpad_2->Draw();
subpad_1->cd();
} else if (yAxisLog_flag) c->SetLogy();
hMCstack->Draw("HIST");
//if (yAxisMin > 0) hMCstack->SetMinimum(yAxisMin);
if (yAxisMin < yAxisMax) {
if (data0_noData1 == 0) subpad_1->Update(); // to be done after Draw() to access pad parameters such as default axis range
else c->Update();
hMCstack->GetYaxis()->SetRangeUser(yAxisMin,yAxisMax);
}
// if (data0_noData1 == 0) {
// if (yAxisMin > 0) hMCstack->GetYaxis()->SetRangeUser(yAxisMin, subpad_1->GetY2());
// else hMCstack->GetYaxis()->SetRangeUser(yAxisMin, c->GetY2());
// }
//hMCstack->SetMaximum(4000.0);
TH1D* stackCopy = (TH1D*)(((TH1D*)hMCstack->GetStack()->Last())->DrawCopy("E2 SAME"));
stackCopy->SetFillColor(kBlack);
stackCopy->SetFillStyle(3144);
if (data0_noData1 == 1) { // when using data ( == 0) the x axis will not have labels (they will only be below in the ratio plot
hMCstack->GetXaxis()->SetTitle(xAxisName.c_str());
hMCstack->GetXaxis()->SetTitleSize(0.06);
hMCstack->GetXaxis()->SetTitleOffset(0.6);
}
if (xAxisMin < xAxisMax) {
if (data0_noData1 == 0) subpad_1->Update(); // to be done after Draw() to access pad parameters such as default axis range
else c->Update();
hMCstack->GetXaxis()->SetRangeUser(xAxisMin,xAxisMax);
}
if (binDensity_flag == 0) hMCstack->GetYaxis()->SetTitle("events");
else hMCstack->GetYaxis()->SetTitle("events / GeV");
hMCstack->GetYaxis()->SetTitleSize(0.06);
hMCstack->GetYaxis()->SetTitleOffset(0.8);
hMCstack->GetYaxis()->CenterTitle();
for (Int_t j = (nFiles-1); j >= 0; j--) {
leg->AddEntry(hMC[j],Form("%s",MC_TexLabel[j].c_str()),"lf");
}
if (data0_noData1 == 0) {
hdata->SetMarkerStyle(8); // large dot
hdata->Draw("EX0 SAME"); //X0 doesn't draw x error
leg->AddEntry(hdata,Form("%s",data_TexLabel.c_str()),"p");
}
gStyle->SetStatStyle(0);
leg->Draw();
leg->SetMargin(0.3);
leg->SetBorderSize(0);
if (data0_noData1 == 0) { // if using data, draw the ratio plot
subpad_2->cd();
ratioplot = new TH1D(*hdata);
ratioplot->Divide(stackCopy);
ratioplot->SetStats(0);
ratioplot->SetTitle("");
ratioplot->GetXaxis()->SetLabelSize(0.10);
ratioplot->GetXaxis()->SetTitle(xAxisName.c_str());
ratioplot->GetXaxis()->SetTitleSize(0.14);
ratioplot->GetXaxis()->SetTitleOffset(0.8);
ratioplot->GetYaxis()->SetLabelSize(0.10);
ratioplot->GetYaxis()->SetTitle("data / MC");
ratioplot->GetYaxis()->SetTitleSize(0.15);
ratioplot->GetYaxis()->SetTitleOffset(0.3);
ratioplot->GetYaxis()->CenterTitle();
ratioplot->GetYaxis()->SetRangeUser(0.5,1.5);
ratioplot->GetYaxis()->SetNdivisions(011);
if (xAxisMin < xAxisMax) {
//subpad_2->Update(); // to be done after Draw() to access pad parameters such as default axis range
ratioplot->GetXaxis()->SetRangeUser(xAxisMin,xAxisMax);
}
ratioplot->SetMarkerStyle(8); //medium dot
ratioplot->DrawCopy("E");
}
c->SaveAs( (plotDirectoryPath + c->GetName() + plotFileExtension).c_str() );
}
示例14: CheckPulsers
//______________________________________________________________________________
void CheckPulsers(const Char_t* loc)
{
// Some old pedestal checking method.
Char_t t[256];
// number of runs
Int_t nRuns = gFiles->GetSize();
// number of channels
Int_t nCh = gReadAR->GetNelements();
// create arrays
Double_t** pedPos = new Double_t*[nCh];
Double_t* runNumbersD = new Double_t[nRuns];
for (Int_t i = 0; i < nCh; i++) pedPos[i] = new Double_t[nRuns];
// open the output files
TFile* fROOTout = new TFile("/tmp/pulser.root", "RECREATE");
// create directories
for (Int_t i = 0; i < nCh; i++)
{
sprintf(t, "%03d_%s", i, gReadAR->GetElement(i)->GetTDC());
fROOTout->mkdir(t);
}
TF1* func = new TF1("gausfunc", "gaus", 0 , 200);
// loop over runs
for (Int_t i = 0; i < nRuns; i++)
{
// get the file
TFile* f = (TFile*) gFiles->At(i);
// extract run number
Int_t runNumber;
sprintf(t, "%s/ARHistograms_CB_%%d.root", loc);
sscanf(f->GetName(), t, &runNumber);
runNumbersD[i] = (Double_t)runNumber;
printf("Processing run %d (%d/%d)\n", runNumber, i+1, nRuns);
fROOTout->cd();
// loop over TDCs
for (Int_t j = 0; j < nCh; j++)
{
// load histogram
sprintf(t, "%03d_%s", j, gReadAR->GetElement(j)->GetTDC());
fROOTout->cd(t);
sprintf(t, "ADC%s", gReadAR->GetElement(j)->GetTDC());
TH1D* h = (TH1D*) f->Get(t);
// fit gaussian to pulser
Double_t maxPos = h->GetXaxis()->GetBinCenter(h->GetMaximumBin());
func->SetParameters(1, maxPos, 0.1);
func->SetRange(maxPos - 2, maxPos + 2);
h->Fit(func, "RBQ");
maxPos = func->GetParameter(1);
// save position in file and memory
pedPos[j][i] = maxPos;
sprintf(t, "Run_%d", runNumber);
TCanvas* c = new TCanvas(t, t);
h->Draw();
TLine* tline = new TLine(maxPos, 0, maxPos, 10000);
tline->SetLineColor(kRed);
tline->SetLineWidth(2);
tline->Draw();
c->Write(c->GetName(), TObject::kOverwrite);
delete h;
delete c;
delete tline;
}
}
// create pedestal evolution graphs
fROOTout->cd();
// loop over channels
for (Int_t j = 0; j < nCh; j++)
{
printf("Creating pedestal graph for channel %d\n", j);
TGraph* g = new TGraph(nRuns, runNumbersD, pedPos[j]);
sprintf(t, "Overview_%03d_%s", j, gReadAR->GetElement(j)->GetTDC());
g->SetName(t);
g->SetTitle(t);
//g->GetYaxis()->SetRangeUser(1200, 1300);
g->Write(g->GetName(), TObject::kOverwrite);
delete g;
}
//.........这里部分代码省略.........
示例15: makePlots
void makePlots (string configFilePath){
if (( nHistList % inputRootFile.size() == 0 ))
{
for (int i=0; i<numHistos; i++)
{
TCanvas *c = new TCanvas(theHistNameStrings.at(i).c_str(), "", 81,58,500,602);
TH1* h_mc; // histograms for MC
TH1* h_mc_clone; // histograms for MC
TH1* h_data; // histogram to store data points
TH1* h_data_clone;
TLegend *legend = new TLegend(0.2, 0.85-.035*inputLegend.size(), 0.5, 0.90,NULL,"brNDC");
int whichHisto = 0;
for (int j=1;j<inputRootFile.size();j++)
{
whichHisto=j*numHistos;
int a = 0;
bool foundHisto = false;
if (theHistNameStrings.at(i) == theHistNameStrings.at(i+whichHisto))
{
foundHisto=true;
a=i;
}
else
{
for (a = 0; a < numHistos; a++)
{
if (theHistNameStrings.at(i) == theHistNameStrings.at(a+whichHisto))
{
foundHisto = true;
break;
}
}
}
//-----------------------------------------------------------
string hist2name = listHistos->At(a+whichHisto)->GetName();
if (foundHisto == true)
{
h_data = (TH1*)listHistos->At(i);
h_data->SetMarkerStyle(inputMarkerStyle.at(0));
h_data = SetStyleh(h_data);
h_data->Sumw2();
int thelineStyle = inputSetLineStyle.at(j);
int thelineWidth = inputSetLineWidth.at(j);
int setcolor = inputColor.at(j);
int marker = inputMarkerStyle.at(j);
h_data->SetMarkerColor(inputColor.at(0));
h_data->SetLineColor(inputColor.at(0));
if (j == 1)
{
if ( h_data->IsA()->InheritsFrom( "TH2" ) ) {
//n.b. that ProfileX will do nothing if the
//name you choose is alreayd taken! so each
//profileX needs a unique name
TString profileName = TString::Format("%s_data_pfx",h_data->GetName());
TProfile *dataProf = ((TH2*)h_data)->ProfileX(profileName.Data());
dataProf->SetMinimum(h_data->GetMinimum()); //min/max values were stored in the original hist
dataProf->SetMaximum(h_data->GetMaximum());
dataProf->Draw("");
//profileX cretaes a clone, so no need to
//clone again here. Need to set the hist
//name so root doesn't complain
TString cloneName = TString::Format("%s_data_pfx_clone",h_data->GetName());
TString cloneName2 = TString::Format("%s_data_pfx_clone_px",h_data->GetName());
h_data_clone = ((TH2*)h_data)->ProfileX(cloneName.Data())->ProjectionX(cloneName2.Data());
}
else { //1d case
Float_t ymaxc = gPad->GetUymax();
//h_data->SetMaximum(ymaxc+0.15*ymaxc);
h_data->Draw("ep1");
h_data_clone = (TH1*)h_data->Clone();
}
//h_data->SetLineColor(1);
h_data->SetLineStyle(thelineStyle);
h_data->SetLineWidth(thelineWidth);
float rms_data = h_data->GetRMS();
float mean_data = h_data->GetMean();
std::stringstream legend_data;
legend_data.str("");
legend_data << inputLegend.at(0).c_str() << ": mean=" << setprecision(3)
<<mean_data <<", rms=" << setprecision(3) <<rms_data<< endl;
legend->AddEntry(h_data,legend_data.str().c_str(), "lep");
}
h_mc = (TH1*)listHistos->At(a+whichHisto);
h_mc = SetStyleh(h_mc);
h_mc->SetName(hist2name.c_str());
//cout<<"NAME "<<h_mc->GetName()<<endl;
// Style
string processlegend = (inputLegend.at(j)).c_str();
//.........这里部分代码省略.........