A class describing a physics channel. More...
#include <BCMTFChannel.h>
A class describing a physics channel.
Definition at line 32 of file BCMTFChannel.h.
BCMTFChannel::BCMTFChannel | ( | const char * | name | ) |
The default constructor.
name | The name of the channel. |
Definition at line 23 of file BCMTFChannel.cxx.
: fData(0) , fFlagChannelActive(true) , fHistUncertaintyBandExpectation(0) , fHistUncertaintyBandPoisson(0) { fName = name; }
BCMTFChannel::~BCMTFChannel | ( | ) |
The default destructor.
Definition at line 33 of file BCMTFChannel.cxx.
{ if (fData) delete fData; for (unsigned int i = 0; i < fTemplateContainer.size(); ++i) delete (fTemplateContainer.at(i)); for (unsigned int i = 0; i < fSystematicVariationContainer.size(); ++i) delete (fSystematicVariationContainer.at(i)); /* if (fHistUncertaintyBandExpectation) delete fHistUncertaintyBandExpectation; if (fHistUncertaintyBandPoisson) delete fHistUncertaintyBandPoisson; */ }
void BCMTFChannel::AddSystematicVariation | ( | BCMTFSystematicVariation * | variation | ) | [inline] |
Add a systematic variation.
variation | The variation. |
Definition at line 161 of file BCMTFChannel.h.
{ fSystematicVariationContainer.push_back(variation); };
void BCMTFChannel::AddTemplate | ( | BCMTFTemplate * | bctemplate | ) | [inline] |
Add a template.
bctemplate | The template. |
Definition at line 155 of file BCMTFChannel.h.
{ fTemplateContainer.push_back(bctemplate); };
void BCMTFChannel::CalculateHistUncertaintyBandPoisson | ( | ) |
Calculate histogram for uncertainty band calculation.
Definition at line 205 of file BCMTFChannel.cxx.
{ // calculate histogram int nbinsy_exp = fHistUncertaintyBandExpectation->GetNbinsY(); int nbinsx_poisson = fHistUncertaintyBandPoisson->GetNbinsX(); int nbinsy_poisson = fHistUncertaintyBandPoisson->GetNbinsY(); // loop over x-axis of observation for (int ix = 1; ix <= nbinsx_poisson; ++ix) { double sum_w = 0; // loop over y-axis of expectation and calculate sum of weights for (int iy = 1; iy <= nbinsy_exp; ++iy) { double w = fHistUncertaintyBandExpectation->GetBinContent(ix, iy); sum_w += w; } // loop over y-axis of expectation for (int iy = 1; iy <= nbinsy_exp; ++iy) { double w = fHistUncertaintyBandExpectation->GetBinContent(ix, iy)/sum_w; double expectation = fHistUncertaintyBandExpectation->GetYaxis()->GetBinCenter(iy); // loop over y-axis of observation for (int jbin = 1; jbin <= nbinsy_poisson; ++jbin) { double p = TMath::Poisson(double(jbin-1), expectation); double bincontent = 0; if (iy>1) bincontent=fHistUncertaintyBandPoisson->GetBinContent(ix, jbin); fHistUncertaintyBandPoisson->SetBinContent(ix, jbin, bincontent+p*w); } } } }
TH1D * BCMTFChannel::CalculateUncertaintyBandPoisson | ( | double | minimum, | |
double | maximumm, | |||
int | color | |||
) |
Calculate histogram for uncertainty band calculation and return a TH1D.
minimum | The minimum value on the expectation. | |
maximum | The maximum value on the expectation. | |
color | The color scheme. |
Definition at line 238 of file BCMTFChannel.cxx.
{ TH1D* hist = new TH1D(*(fData->GetHistogram())); hist->SetMarkerSize(0); hist->SetFillColor(color); hist->SetFillStyle(1001); int nbinsx_poisson = fHistUncertaintyBandPoisson->GetNbinsX(); int nbinsy_poisson = fHistUncertaintyBandPoisson->GetNbinsY(); // loop over x-axis of observation for (int ix = 1; ix <= nbinsx_poisson; ++ix) { double sum_p = 0; // sum of all probabilities inside the interval int limit_min = 0; int limit_max = nbinsx_poisson-1; // loop over y-axis of observation for (int jbin = 1; jbin <= nbinsy_poisson; ++jbin) { double p = fHistUncertaintyBandPoisson->GetBinContent(ix, jbin); sum_p+=p; if (sum_p < minimum) limit_min=jbin; if (sum_p > maximum && (sum_p - p) < maximum ) limit_max=jbin-1; } hist->SetBinContent(ix, 0.5*double(limit_min+limit_max)); hist->SetBinError(ix, 0.5*double(limit_max-limit_min)); } return hist; }
BCMTFTemplate* BCMTFChannel::GetData | ( | ) | [inline] |
bool BCMTFChannel::GetFlagChannelActive | ( | ) | [inline] |
Definition at line 79 of file BCMTFChannel.h.
{ return fFlagChannelActive; };
TH2D* BCMTFChannel::GetHistUncertaintyBandExpectation | ( | ) | [inline] |
Return a histogram ued for the calculation of the error band of the expectation.
Definition at line 86 of file BCMTFChannel.h.
{ return fHistUncertaintyBandExpectation; };
TH2D* BCMTFChannel::GetHistUncertaintyBandPoisson | ( | ) | [inline] |
Return a histogram used for the calculation of the Poisson fluctuations.
Definition at line 92 of file BCMTFChannel.h.
{ return fHistUncertaintyBandPoisson; };
std::string BCMTFChannel::GetName | ( | ) | [inline] |
double BCMTFChannel::GetRangeYMax | ( | ) | [inline] |
Definition at line 102 of file BCMTFChannel.h.
{ return fRangeYMax; };
double BCMTFChannel::GetRangeYMin | ( | ) | [inline] |
Definition at line 97 of file BCMTFChannel.h.
{ return fRangeYMin; };
BCMTFSystematicVariation* BCMTFChannel::GetSystematicVariation | ( | int | index | ) | [inline] |
Return a systematic variation
index | The systematic index. |
Definition at line 74 of file BCMTFChannel.h.
{ return fSystematicVariationContainer.at(index); };
BCMTFTemplate* BCMTFChannel::GetTemplate | ( | int | index | ) | [inline] |
Return a template
index | The template index. |
Definition at line 67 of file BCMTFChannel.h.
{ return fTemplateContainer.at(index); };
void BCMTFChannel::PrintHistCumulativeUncertaintyBandPoisson | ( | const char * | filename | ) |
Print cumulative histogram for uncertainty band calculation.
filename | The name of the file. |
Definition at line 271 of file BCMTFChannel.cxx.
{ // create new canvas TCanvas * c1 = new TCanvas(); c1->cd(); // calculate error band this->CalculateHistUncertaintyBandPoisson(); TH2D hist(*fHistUncertaintyBandPoisson); int nbinsx_poisson = hist.GetNbinsX(); int nbinsy_poisson = hist.GetNbinsY(); // loop over x-axis of observation for (int ix = 1; ix <= nbinsx_poisson; ++ix) { double sum_p = 0; // sum of all probabilities inside the interval // loop over y-axis of observation for (int jbin = 1; jbin <= nbinsy_poisson; ++jbin) { double p = hist.GetBinContent(ix, jbin); sum_p+=p; hist.SetBinContent(ix, jbin, sum_p); } } // draw histogram hist.Draw("COLZ"); c1->Draw(); // print c1->Print(filename); // free memory delete c1; }
void BCMTFChannel::PrintHistUncertaintyBandExpectation | ( | const char * | filename | ) |
Print histogram for uncertainty band calculation.
filename | The name of the file. |
Definition at line 187 of file BCMTFChannel.cxx.
{ // create new canvas TCanvas * c1 = new TCanvas(); c1->cd(); // draw histogram fHistUncertaintyBandExpectation->Draw("COLZ"); c1->Draw(); // print c1->Print(filename); // free memory delete c1; }
void BCMTFChannel::PrintHistUncertaintyBandPoisson | ( | const char * | filename | ) |
Print histogram for uncertainty band calculation.
filename | The name of the file. |
Definition at line 309 of file BCMTFChannel.cxx.
{ // create new canvas TCanvas * c1 = new TCanvas(); c1->cd(); // calculate error band this->CalculateHistUncertaintyBandPoisson(); // draw histogram fHistUncertaintyBandPoisson->Draw("COLZ"); c1->Draw(); // print c1->Print(filename); // free memory delete c1; }
void BCMTFChannel::PrintTemplate | ( | int | index, | |
const char * | filename | |||
) |
Print a particular template with systematics.
index | The template index. | |
filename | The name of the file. |
Definition at line 119 of file BCMTFChannel.cxx.
{ // create new canvas TCanvas * c1 = new TCanvas(); c1->cd(); // get number of systematics unsigned int nsystematics = fSystematicVariationContainer.size(); // draw template GetTemplate(index)->GetHistogram()->Draw(); // print to file if (nsystematics == 0) c1->Print(filename); else c1->Print( (std::string(filename)+std::string("(")).c_str() ); // loop over systematics for (unsigned int isystematic = 0; isystematic < nsystematics; ++isystematic) { c1->cd(); // check that histogram exists if (!GetSystematicVariation(isystematic)->GetHistogramUp(index) || !GetSystematicVariation(isystematic)->GetHistogramDown(index)) continue; // get histogram TH1D hist = TH1D(*GetTemplate(index)->GetHistogram()); TH1D hist_up(hist); TH1D hist_down(hist); // set style hist.SetFillStyle(0); hist_up.SetFillStyle(0); hist_up.SetLineStyle(2); hist_down.SetFillStyle(0); hist_down.SetLineStyle(3); // get efficiency double efficiency = GetTemplate(index)->GetEfficiency(); // scale histogram hist.Scale(efficiency/ hist.Integral()); // loop over all bins for (int i = 1; i <= hist.GetNbinsX(); ++i) { hist.SetBinContent(i, GetTemplate(index)->GetHistogram()->GetBinContent(i)); hist_up.SetBinContent(i, hist.GetBinContent(i) * (1.0 + GetSystematicVariation(isystematic)->GetHistogramUp(index)->GetBinContent(i))); hist_down.SetBinContent(i, hist.GetBinContent(i) * (1.0 - GetSystematicVariation(isystematic)->GetHistogramDown(index)->GetBinContent(i))); } // draw histogram hist_up.Draw("HIST"); hist.Draw("HISTSAME"); hist_down.Draw("HISTSAME"); if (isystematic < nsystematics-1) c1->Print(filename); else c1->Print( (std::string(filename)+std::string(")")).c_str() ); } // free memory delete c1; }
void BCMTFChannel::PrintTemplates | ( | const char * | filename | ) |
Print the templates in this channel.
filename | The name of the file. |
Definition at line 54 of file BCMTFChannel.cxx.
{ // create new canvas TCanvas * c1 = new TCanvas(); c1->Divide(2, 2); std::string f(filename); // get number of templates unsigned int ntemplates = fTemplateContainer.size(); // calculate number of pages unsigned int npages = ntemplates / 4; if (ntemplates % 4 > 0) npages++; // loop over pages for (unsigned int i = 0; i < npages; ++i) { // loop over pads for (unsigned int j = 0; j < 4; ++j) { // calculate template index unsigned int templateindex = 4 * i + j; if (templateindex < ntemplates && GetTemplate(templateindex)->GetHistogram()) { // cd into pad c1->cd(j+1); // get histogram TH1D * hist = new TH1D( *( (TH1D *) GetTemplate(templateindex)->GetHistogram()->Clone() ) ); // get efficiency double efficiency = GetTemplate(templateindex)->GetEfficiency(); // scale histogram hist->Scale(efficiency/hist->Integral()); // draw histogram hist->Draw("HIST"); } else { // clear pad c1->cd(j+1)->Clear(); } } if (npages == 1) c1->Print(f.c_str()); else if (i == 0) { c1->Print( (f+std::string("[")).c_str() ); c1->Print(f.c_str()); } else if (i < npages-1) { c1->Print(f.c_str()); } else { c1->Print(f.c_str()); c1->Print( (f+std::string("]")).c_str() ); } } // free memory delete c1; }
void BCMTFChannel::SetData | ( | BCMTFTemplate * | bctemplate | ) | [inline] |
Set the data set.
bctemplate | The data set. |
Definition at line 118 of file BCMTFChannel.h.
{ fData = bctemplate; };
void BCMTFChannel::SetFlagChannelActive | ( | bool | flag | ) | [inline] |
Set flag to define if the channel is active or not.
flag | The flag. |
Definition at line 137 of file BCMTFChannel.h.
{ fFlagChannelActive = flag; };
void BCMTFChannel::SetHistUncertaintyBandExpectation | ( | TH2D * | hist | ) | [inline] |
Set a histogram ued for the calculation of the error band of the expectation.
hist | The histogram. |
Definition at line 125 of file BCMTFChannel.h.
{ fHistUncertaintyBandExpectation = hist; }
void BCMTFChannel::SetHistUncertaintyBandPoisson | ( | TH2D * | hist | ) | [inline] |
Set a histogram used for the calculation of the Poisson fluctuations.
The | histogram. |
Definition at line 131 of file BCMTFChannel.h.
{ fHistUncertaintyBandPoisson = hist; }
void BCMTFChannel::SetName | ( | const char * | name | ) | [inline] |
Set the name of the channel.
name | The name of the channel. |
Definition at line 112 of file BCMTFChannel.h.
{ fName = name; };
void BCMTFChannel::SetRangeY | ( | double | min, | |
double | max | |||
) | [inline] |
Set the y-ranges for printing.
min | The minimum range. | |
max | The maximum range. |
Definition at line 144 of file BCMTFChannel.h.
{ fRangeYMin = min; fRangeYMax = max; };
BCMTFTemplate* BCMTFChannel::fData [private] |
The data set.
Definition at line 218 of file BCMTFChannel.h.
bool BCMTFChannel::fFlagChannelActive [private] |
Flag defining if the channel is active or not.
Definition at line 238 of file BCMTFChannel.h.
TH2D* BCMTFChannel::fHistUncertaintyBandExpectation [private] |
A histogram for the calculation of uncertainty bands.
Definition at line 242 of file BCMTFChannel.h.
TH2D* BCMTFChannel::fHistUncertaintyBandPoisson [private] |
A histogram for the calculation of uncertainty bands.
Definition at line 246 of file BCMTFChannel.h.
std::string BCMTFChannel::fName [private] |
The name of the channel.
Definition at line 214 of file BCMTFChannel.h.
double BCMTFChannel::fRangeYMax [private] |
The maximal y-range for printing.
Definition at line 226 of file BCMTFChannel.h.
double BCMTFChannel::fRangeYMin [private] |
The minimal y-range for printing.
Definition at line 222 of file BCMTFChannel.h.
std::vector<BCMTFSystematicVariation *> BCMTFChannel::fSystematicVariationContainer [private] |
A container of systematics.
Definition at line 234 of file BCMTFChannel.h.
std::vector<BCMTFTemplate *> BCMTFChannel::fTemplateContainer [private] |
A container of templates.
Definition at line 230 of file BCMTFChannel.h.