本文整理汇总了C++中TH1::GetMean方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::GetMean方法的具体用法?C++ TH1::GetMean怎么用?C++ TH1::GetMean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::GetMean方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawStatBox
void DrawStatBox(TObject** Histos, std::vector<char*> legend, bool Mean, double X, double Y, double W, double H)
{
int N = legend.size();
char buffer[255];
if(Mean)H*=3;
for(int i=0;i<N;i++){
TPaveText* stat = new TPaveText(X,Y-(i*H), X+W, Y-(i+1)*H, "NDC");
TH1* Histo = (TH1*)Histos[i];
sprintf(buffer,"Entries : %i\n",(int)Histo->GetEntries());
stat->AddText(buffer);
if(Mean){
sprintf(buffer,"Mean : %6.2f\n",Histo->GetMean());
stat->AddText(buffer);
sprintf(buffer,"RMS : %6.2f\n",Histo->GetRMS());
stat->AddText(buffer);
}
stat->SetFillColor(0);
stat->SetLineColor(Color[i]);
stat->SetTextColor(Color[i]);
stat->SetBorderSize(0);
stat->SetMargin(0.05);
stat->SetTextAlign(12);
stat->Draw();
}
}
示例2: CreateFillMeanRms
//________________________________________________________
void GFOverlay::CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName,
std::vector<TH1*> &meanHists, std::vector<TH1*> &rmsHists) const
{
// fill mean/rms from hists into the corresponding meanHists/rmsHists
// if these are empty, create one hist for each slot of hists (even for empty ones!)
if (hists.IsEmpty()) return;
TH1 *h1 = 0;
for (Int_t iH = 0; !h1 && iH < hists.GetEntriesFast(); ++iH) {
h1 = static_cast<TH1*>(hists[iH]);
}
if (!h1 || h1->GetDimension() > 1) return; // only for 1D hists
if (meanHists.empty()) { // create mean/RMS hists if not yet done
const Float_t min = h1->GetXaxis()->GetXmin()/3.;
const Float_t max = h1->GetXaxis()->GetXmax()/3.;
const Int_t nBins = h1->GetNbinsX()/2;
for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
TH1 *hMean = new TH1F(Form("mean%d_%d", layer, iHist), Form("%s: mean", dirName),
nBins, min, max);
meanHists.push_back(hMean);
TH1 *hRms = new TH1F(Form("rms%d_%d", layer, iHist), Form("%s: RMS", dirName),
nBins, 0., max);
rmsHists.push_back(hRms);
}
}
// now fill mean and rms hists
for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
TH1 *h = static_cast<TH1*>(hists[iHist]);
if (!h) continue;
meanHists[iHist]->Fill(h->GetMean());
rmsHists[iHist]->Fill(h->GetRMS());
}
}
示例3: fadc_fit_heights
void fadc_fit_heights(std::string fadc_id,std::string hist_type)
{
/*****************************************************************/
// Prepare the canvas
gStyle->SetOptFit(1111);
TCanvas *AlCapCanvas = (TCanvas *) gROOT->GetListOfCanvases()->At(0);
AlCapCanvas->Clear();
AlCapCanvas->Divide(4,2);
// gROOT->ProcessLine(".L common/get_histogram.C"); // get_histogram() is called here
/*****************************************************************/
const int n_channels = 8;
std::string bank_names[n_channels] = {"Na", "Nb", "Nc", "Nd", "Ne", "Nf", "Ng", "Nh"};
std::string name;
double mean = 0;
double rms = 0;
for (int iChn = 0; iChn < n_channels; iChn++) {
name=bank_names[iChn]+fadc_id;
TH1* hist = get_histogram(name, hist_type);
mean = hist->GetMean();
rms = hist->GetRMS();
AlCapCanvas->cd(iChn+1);
if (hist->Integral()!=0) {
TF1* gaus = new TF1("gaus","gaus",mean-rms,mean+rms);
hist->Fit("gaus","Q");
hist->GetXaxis()->SetRange(mean-2*rms,mean+2*rms);
hist->Draw();
}
}
}
示例4: getPlotData
void getPlotData() {
TH1 * h = (TH1*) m_file->Get(m_direc.c_str());
for (int i=0; i<h->GetXaxis()->GetNbins(); i++) {
m_xs.push_back(h->GetXaxis()->GetBinCenter(i));
m_ys.push_back(h->GetBinContent(i));
}
m_plot->m_xAxisTitle = std::string(h->GetXaxis()->GetTitle());
m_plot->m_yAxisTitle = std::string(h->GetYaxis()->GetTitle());
m_plot->m_title = std::string(h->GetTitle());
std::stringstream ssN, ssMu, ssSig, ssUF, ssOF;
ssN << std::setprecision(4) << h->GetEntries();
ssMu << std::setprecision(4) << h->GetMean();
ssSig << std::setprecision(4) << h->GetRMS();
ssUF << std::setprecision(4) << h->GetBinContent(0);
ssOF << std::setprecision(4) << h->GetBinContent(h->GetNbinsX() + 1);
m_statsTitles.push_back("N:");
m_statsTitles.push_back("mu:");
m_statsTitles.push_back("sig:");
m_statsTitles.push_back("UF:");
m_statsTitles.push_back("OF:");
m_statsValues.push_back(ssN.str());
m_statsValues.push_back(ssMu.str());
m_statsValues.push_back(ssSig.str());
m_statsValues.push_back(ssUF.str());
m_statsValues.push_back(ssOF.str());
}
示例5: PlotAndCheck
int PlotAndCheck(TTree *tree, TCanvas *c1, int index, const char *selection)
{
c1->cd(index);
tree->Draw("fOffset*fX.fElements",selection);
TH1 *href = (TH1*)gPad->GetListOfPrimitives()->FindObject("htemp");
c1->cd(index+1);
tree->Draw("mult", selection);
TH1 *halias = (TH1*)gPad->GetListOfPrimitives()->FindObject("htemp");
if ( href->GetEntries() != halias->GetEntries()
|| fabs(href->GetMean()-halias->GetMean()) > 0.000001 ){
fprintf(stdout, "For %s\n",selection);
fprintf(stdout, "The direct histogram and the alias histogram are different!\n");
fprintf(stdout, "Entries: %f vs %f\n",href->GetEntries(),halias->GetEntries());
fprintf(stdout, "Mean : %f vs %f\n",href->GetMean(),halias->GetMean());
}
return index+2;
}
示例6: FindZLine
//________________________________________________________________
void KVZALineFinder::FindZLine(Int_t zz)
{
fLinearHisto->SetAxisRange(zz-0.5,zz+0.5,"Y");
KVIDLine* line = (KVIDLine*)fGrid->GetIdentifier(zz,2*zz+1); // A=2*zz+1 : dummy, A is ignored in this case
if(!line)
{
int i=1;
while(!(line = (KVIDLine*)fGrid->GetIdentifier(zz+i,2*zz+1))) i++;
}
if(!line) return;
Double_t lX, lY;
line->GetStartPoint(lX,lY);
Int_t xbmin = 1;
line->GetEndPoint(lX,lY);
Int_t xbmax = fLinearHisto->GetXaxis()->FindBin(lX);
Int_t width = (Int_t)((xbmax-xbmin)*1.0/100.);
Int_t widthmax = (Int_t)((xbmax-xbmin)*1.0/30.);
KVIDZALine* TheLine = 0;
TheLine = (KVIDZALine*)((KVIDZAGrid*)fGeneratedGrid)->NewLine("ID");
TheLine->SetZ(zz);
TheLine->SetA(fAList.at(zz-1));
TH1* projey = 0;
Int_t i=0;
Double_t lasty = zz;
for(int xx=xbmin; xx<xbmax; xx+=width)
{
projey = fLinearHisto->ProjectionY("ProjectionAfterLin",TMath::Max(xx-width/2,xbmin),xx+width/2);
Double_t xline = fLinearHisto->GetBinCenter(xx);
Double_t yline = projey->GetMean();
if((yline>zz-0.5)&&(yline<zz+0.5))
{
if(i==0) lasty = yline;
if(TMath::Abs(yline-lasty)<0.2)
{
TheLine->SetPoint(i, xline, yline);
lasty = yline;
i++;
if(width<widthmax) width*=1.2;
}
}
delete projey;
}
if(TheLine->GetN()>5) fGeneratedGrid->Add("ID",TheLine);
}
示例7: ProcessSPEFile
int ProcessSPEFile(const char* fname, Long_t roi = -1, int channel = -1)
{
TCanvas* c = new TCanvas;
c->SetLogy();
c->SetTitle(fname);
static bool loaded = false;
if(!loaded){
gROOT->ProcessLine(".L lib/libDict.so");
loaded = true;
}
TFile* fin = new TFile(fname);
if(!fin->IsOpen()){
std::cerr<<"Unable to open file "<<fname<<std::endl;
return 1;
}
TTree* Events = (TTree*)(fin->Get("Events"));
if(!Events){
std::cerr<<"Unable to load Events tree from file "<<fname<<std::endl;
return 2;
}
TString data_source;
if(roi == -1) data_source = "channels.pulses.integral";
else data_source = TString("-channels.regions[") + roi
+ TString("].integral");
Events->Draw(data_source+" >> htemp",data_source+" > 0");
TH1* htemp = (TH1*)(gROOT->FindObject("htemp"));
double emax = htemp->GetMean()*5;
TCut min_en = (data_source+" > 0").Data();
char chstring[100];
sprintf(chstring,data_source+" < %.0f",emax);
TCut max_en = chstring;
sprintf(chstring,"channels.channel_id == %d",channel);
TCut chan_cut = (channel == -1 ? "" : chstring);
TCut time_cut = (roi == -1 ? get_time_cut(Events, chan_cut) : "" );
TCut total_cut = min_en && max_en && time_cut && chan_cut;
Events->Draw(data_source+" >> hspec",total_cut,"e");
TH1* hspec = (TH1*)(gROOT->FindObject("hspec"));
int val = FitSPE(hspec, Events->GetEntries());
return val;
}
示例8:
TH1 *
YieldMean_ReturnExtremeHisto(TH1 *hin, Float_t sign)
{
Double_t ptlow, pthigh;
for (Int_t ibin = 0; ibin < hin->GetNbinsX(); ibin++) {
if (hin->GetBinError(ibin + 1) <= 0.) continue;
ptlow = hin->GetBinLowEdge(ibin + 1);
break;
}
for (Int_t ibin = hin->GetNbinsX(); ibin >= 0; ibin--) {
if (hin->GetBinError(ibin + 1) <= 0.) continue;
pthigh = hin->GetBinLowEdge(ibin + 2);
break;
}
Double_t mean = hin->GetMean();
Double_t maxdiff = 0.;
TH1 *hmax = NULL;
for (Int_t inode = 0; inode < hin->GetNbinsX(); inode++) {
Double_t ptnode = hin->GetBinCenter(inode + 1);
TH1 *hout = (TH1 *)hin->Clone(Form("%s_extremehard", hin->GetName()));
for (Int_t ibin = 0; ibin < hin->GetNbinsX(); ibin++) {
if (hin->GetBinError(ibin + 1) <= 0.) continue;
Double_t val = hin->GetBinContent(ibin + 1);
Double_t err = hin->GetBinError(ibin + 1);
Double_t cen = hin->GetBinCenter(ibin + 1);
if (cen < ptnode)
err *= -1. + (cen - ptlow) / (ptnode - ptlow);
else
err *= (cen - ptnode) / (pthigh - ptnode);
hout->SetBinContent(ibin + 1, val + sign * err);
}
Double_t diff = TMath::Abs(mean - hout->GetMean());
if (diff > maxdiff) {
// printf("found max at %f\n", ptnode);
if (hmax) delete hmax;
hmax = (TH1 *)hout->Clone("hmax");
maxdiff = diff;
}
delete hout;
}
return hmax;
}
示例9: logStatisticsPar
void logStatisticsPar(std::ostream& out, RooDataSet *dataSet, RooRealVar *realVar, int nBins, double chi2, const RooArgList &variables)
{
TH1 *histogram = dataSet->createHistogram(Form("h%s", dataSet->GetName()), *realVar, RooFit::Binning(nBins));
// Create the TeX file
out << "\\documentclass[10pt]{article}" << std::endl;
out << "\\usepackage[usenames]{color} %used for font color" << std::endl;
out << "\\usepackage{fontspec}" << std::endl;
out << "\\usepackage{xunicode}" << std::endl;
out << "\\usepackage{xltxtra}" << std::endl;
out << "\\defaultfontfeatures{Scale=MatchLowercase}" << std::endl;
out << "\\setromanfont[Mapping=tex-text]{Myriad Pro}" << std::endl;
out << "\\setsansfont[Mapping=tex-text]{Myriad Pro}" << std::endl;
out << "\\setmonofont{Monaco}" << std::endl;
out << "\\begin{document}" << std::endl;
out << "\\thispagestyle{empty}" << std::endl;
out << "\\setlength{\\tabcolsep}{1ex}" << std::endl;
out << "\\setlength{\\fboxsep}{0ex}" << std::endl;
out << "{\\fontsize{7pt}{0.9em}\\selectfont" << std::endl;
out << "\\framebox{\\begin{tabular*}{60pt}{[email protected]{\\extracolsep{\\fill}}r}" << std::endl;
// This is the particular info for the histogram
out << "Entries & " ;
formatNumber(histogram->GetEntries(), out) << " \\\\" << std::endl;
out << "Mean & " ;
formatNumber(histogram->GetMean(), out) << " \\\\" << std::endl;
out << "RMS & " ;
formatNumber(histogram->GetRMS(), out) << " \\\\" << std::endl;
if (chi2 > 0.0) {
out << "Fit $\\chi^{2}$ & " ;
formatNumber(chi2, out) << " \\\\" << std::endl;
}
RooRealVar *theVariable;
for (int index = 0; index < variables.getSize(); index++) {
theVariable = dynamic_cast<RooRealVar*>(variables.find(variables[index].GetName()));
out << theVariable->GetTitle() << " & $\\textrm{" ;
formatNumber(theVariable->getValV(), out) << "} \\pm \\textrm{" ;
formatNumber(theVariable->getError(), out) << "}$ \\\\" << std::endl;
}
out << "\\end{tabular*}}}" << std::endl;
out << "\\end{document}" << std::endl;
histogram->Delete();
}
示例10: Error
/**
* Draw the Poisson estimate of the occupancy in a given ring.
*
* @param p List
* @param d Detector
* @param r Ring
*
* @return The occupancy (in percent)
*
* @deprecated Use QATrender instead
* @ingroup pwglf_forward_scripts_qa
*/
Double_t
DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
{
if (!p) return 0;
TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
if (!ring) {
Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
return 0;
}
TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
if (!corr) {
Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
d, r);
return 0;
}
corr->Rebin(4);
TPad* pad = static_cast<TPad*>(gPad);
pad->SetGridy();
pad->SetGridx();
pad->SetLogy();
pad->SetFillColor(0);
pad->SetRightMargin(0.01);
#if 0
if (d == 3) {
pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99,
pad->GetYlowNDC()+pad->GetHNDC());
pad->SetRightMargin(0.15);
}
#endif
corr->Draw("hist");
TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
ltx->SetNDC();
ltx->SetTextAlign(33);
ltx->SetTextSize(.08);
ltx->Draw();
return corr->GetMean();
}
示例11: my_hook
void my_hook()
{
hadaq::TrbProcessor* trb3 = base::ProcMgr::instance()->FindProc("TRB0");
if (trb3==0) return;
printf("Do extra work NUM %u\n", trb3->NumSubProc());
for (unsigned ntdc=0xC000;ntdc<0xC005;ntdc++) {
hadaq::TdcProcessor* tdc = trb3->GetTDC(ntdc);
if (tdc==0) continue;
TH1* hist = (TH1*) tdc->GetChannelRefHist(1);
printf(" TDC%u mean:%5.2f rms:%5.2f\n", tdc->GetID(), hist->GetMean(), hist->GetRMS());
tdc->ClearChannelRefHist(1);
}
}
示例12: nextDir
cmsListDir( const TObjString * firstdirname, const TDirectory * firstDir )
{
TObjArray * dirs = new TObjArray ;
dirs->AddLast(new TPair(firstdirname,firstDir)) ;
TList * keys ;
TKey * key ;
TH1 * histo ;
TIter nextDir(dirs) ;
TPair * pair ;
const TObjString * dirname ;
const TDirectory * dir ;
while (pair = (TPair *)nextDir())
{
dirname = (TObjString *)pair->Key() ;
dir = (TDirectory *)pair->Value() ;
keys = dir->GetListOfKeys() ;
TIter nextKey(keys) ;
while (key = (TKey *)nextKey())
{
obj = key->ReadObj() ;
if (obj->IsA()->InheritsFrom("TDirectory"))
{
dirs->AddLast(new TPair(new TObjString(dirname->String()+"/"+obj->GetName()),obj)) ;
}
else if (obj->IsA()->InheritsFrom("TH1"))
{
histo = (TH1 *)obj ;
std::cout
<<"Histo "<<dirname->String()<<"/"<<histo->GetName()
<<" has "<<histo->GetEffectiveEntries()<<" entries"
<<" of mean value "<<histo->GetMean()
<<std::endl ;
}
else
{ std::cout<<"What is "<<obj->GetName()<<" ?"<<std::endl ; }
}
}
}
示例13: CalcPeriod
//.........这里部分代码省略.........
gProgress->Reset();
gProgress->SetMax(nevt);
gSystem->ProcessEvents();
while (ievt <= nevt && !flagEnd) {
fread((void *) &event_data, 1, sizeof(event_data), fdata);
if (feof(fdata))
flagEnd = 1;
p = (struct channel_struct *) &event_data.ch[0]; // read bunch of data
dep = (struct channel_struct *) &event_data.ch[1]; // read bunch of data
// goes to channel to analyze
p += anaChannel;
// read data, subtract pedestals values and save results in grAnaChDataTemp graph with
// fixed error for each point (x = 0.5 and y = 2.1). Also generate an array with Domino
// X and Y values
TGraphErrors *grAnaChDataTemp = new TGraphErrors(DOMINO_NCELL);
for (int ch = 0; ch < DOMINO_NCELL; ch++) {
// Read pedestal value for this cell
grPed->GetPoint(ch, itmp, PedVal);
chtmp = (Double_t)(p->data[ch]); // data value
chtmp = chtmp - PedVal;
grAnaChDataTemp->SetPoint(ch, (Double_t) ch, chtmp);
grAnaChDataTemp->SetPointError(ch, 0.5, 2.1);
}
// create fit functions
TF1 *fsin = new TF1("fsin", sigSin, 0., 1024., 4);
fsin->SetParameters(600., 255., 150., 150.);
fsin->SetParNames("amplitude", "Period", "Phase", "DC-Offset");
grAnaChDataTemp->Fit("fsin", "Q");
TF1 *fsinFit = grAnaChDataTemp->GetFunction("fsin");
fsinFit->SetParNames("amplitude", "Period", "Phase", "DC-Offset");
// debug
cfitTest->cd(ievt);
grAnaChDataTemp->SetMarkerStyle(20);
grAnaChDataTemp->SetMarkerSize(0.3);
grAnaChDataTemp->GetYaxis()->SetLabelSize(0.12);
grAnaChDataTemp->GetXaxis()->SetLabelSize(0.12);
grAnaChDataTemp->Draw("APE");
Double_t fitPeriod, fitAmplitude, chisquare;
fitPeriod = fsinFit->GetParameter("Period");
fitAmplitude = TMath::Abs(fsinFit->GetParameter("amplitude"));
chisquare = fsinFit->GetChisquare();
cout << "period: " << fitPeriod << " amplitude: " << fitAmplitude << " chisquare: " << chisquare << endl;
if(chisquare > 0.1e+06) {
gProgress->Increment(1);
gSystem->DispatchOneEvent(kTRUE);
ievt++;
continue;
}
gProgress->Increment(1);
gSystem->DispatchOneEvent(kTRUE);
hPeriod->Fill(fitPeriod);
fitusati++;
ievt++;
}
cout << "fit scartati :" << nevt - fitusati << endl;
//draw
TString Title = "Period distribution for nevt events";
TCanvas *cPeriod = new TCanvas("cPeriod", Title, 700, 700);
hPeriod->Draw();
hPeriod->Fit("gaus");
TF1 *fgausFit = hPeriod->GetFunction("gaus");
//mean = fgausFit->GetParameter(1);
// rms = fgausFit->GetParameter(2);
mean = hPeriod->GetMean();
rms = hPeriod->GetRMS();
TString OutFile = "Period";
OutFile += nevt;
OutFile += "events.dat";
FILE *f = fopen(OutFile.Data(), "w");
fwrite(&mean, sizeof(mean), 1, f);
fwrite(&rms, sizeof(rms), 1, f);
((TGMainFrame *) gProgress->GetParent())->CloseWindow();
fclose(f);
cout << "mean: " << mean << " rms: " << rms << endl;
fclose(fdata);
}
示例14: my_hook
void my_hook()
{
hadaq::HldProcessor* hld = base::ProcMgr::instance()->FindProc("HLD");
cout << Form("hook counter: %d", hook_counter) << endl;
// Calibraton Time //
if (width_counter==0)
{
// int chId = 5;
// gSystem->Exec(Form("echo -e 'asdf \tasdf sadf sadf as f' >> ~/git_cahitugur/trb3/measurements/ToT/pulseWidth_scan.txt"));
// gSystem->Exec(Form("echo -e '%5.3f \t%d' >> ~/git_cahitugur/trb3/measurements/ToT/pulseWidth_scan.txt", width_counter*1.667, chId));
if (hook_counter==15)
{
width_counter++;
hook_counter = 0;
continue;
}
hook_counter++;
continue;
}
////////////////////////////////////
// Pulser Settings //
if (hook_counter==0)
{
printf("Set pulser\n");
gSystem->Exec(Form("perl ~/git_cahitugur/scripts/telnet_command_send.pl -pt 0x%x -pr 0x1fff -st 0x11", width_counter));
}
else if(hook_counter == 10)
{
width_counter++;
hook_counter = 0;
continue;
}
hook_counter++;
//////////////////////////////////////
// Histogram generation //
int tdcmap[2] = { 0xC000, 0xC008 };
if(hook_counter == 2)
{
cout << Form("Clear histograms\n") << endl;
for (int cnt=0;cnt<2;cnt++) {
hadaq::TdcProcessor* tdc = hld ? hld->FindTDC(tdcmap[cnt]) : 0;
if (tdc==0) { printf("DID NOT FOUND TDC\n"); return; }
for (int chId=1;chId<chNumber;chId=chId+1){
// tdc_1->ClearChannelRefHist(chId);
tdc->ClearHist(chId, 5);
}
}
}
else if(hook_counter == 10)
{
gSystem->Exec(Form("echo -e '# pulseWidth(ns) \tTDC \tCHANNEL \tMEAN(ns) \tRMS(ps)' >> ~/git_cahitugur/trb3/measurements/ProgrammableOscillator/pulseWidth_scan.txt"));
for (int cnt=0;cnt<2;cnt++) {
hadaq::TdcProcessor* tdc = hld ? hld->FindTDC(tdcmap[cnt]) : 0;
if (tdc==0) { printf("DID NOT FOUND TDC\n"); return; }
for (int chId=1;chId<chNumber;chId=chId+1){
// TH1* hist = (TH1*) tdc_1->GetChannelRefHist(chId); // argument is the channel number
TH1* tot = (TH1*) tdc->GetHist(chId,5); // arguments are the channel number and the ToT histogram number
gSystem->Exec(Form("echo -e '%5.3f \t\t%x \t%d \t\t%5.3f \t\t%5.4f' >> ~/git_cahitugur/trb3/measurements/ProgrammableOscillator/pulseWidth_scan.txt", width_counter*1.667, tdc->GetID(), chId, tot->GetMean(), tot->GetRMS()*1000 ));
}
}
}
}
示例15: mvas
//.........这里部分代码省略.........
else if (htype == RarityType)
sig->SetTitle( Form("TMVA Rarity for classifier: %s", methodTitle.Data()) );
else if (htype == CompareType)
sig->SetTitle( Form("TMVA overtraining check for classifier: %s", methodTitle.Data()) );
// create new canvas
TString ctitle = ((htype == MVAType) ?
Form("TMVA response %s",methodTitle.Data()) :
(htype == ProbaType) ?
Form("TMVA probability %s",methodTitle.Data()) :
(htype == CompareType) ?
Form("TMVA comparison %s",methodTitle.Data()) :
Form("TMVA Rarity %s",methodTitle.Data()));
TString cname = ((htype == MVAType) ?
Form("output_%s",methodTitle.Data()) :
(htype == ProbaType) ?
Form("probability_%s",methodTitle.Data()) :
(htype == CompareType) ?
Form("comparison_%s",methodTitle.Data()) :
Form("rarity_%s",methodTitle.Data()));
c = new TCanvas( Form("canvas%d", countCanvas+1), ctitle,
countCanvas*50+200, countCanvas*20, width, (Int_t)width*0.78 );
// set the histogram style
TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
// 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,