9 #ifdef SI_PIXEL_TEMPLATE_STANDALONE
25 #define LOGDEBUG std::cout
26 #define LOGERROR std::cout
27 #define LOGINFO std::cout
37 #define LOGDEBUG LogDebug("")
38 #define LOGERROR edm::LogError("Error")
39 #define LOGINFO edm::LogInfo("Info")
66 double cotbetaBinWidth,
67 double cotbetaLowEdge,
69 double cotalphaBinWidth,
70 double cotalphaLowEdge,
74 : weOwnHistograms_(
true),
76 cotbetaBinWidth_(cotbetaBinWidth),
77 cotbetaLowEdge_(cotbetaLowEdge),
78 cotbetaBins_(cotbetaBins),
79 cotalphaBinWidth_(cotalphaBinWidth),
80 cotalphaLowEdge_(cotalphaLowEdge),
81 cotalphaBins_(cotalphaBins),
84 binningHisto_(nullptr),
85 resMultiPixelXHist_(),
86 resSinglePixelXHist_(),
87 resMultiPixelYHist_(),
88 resSinglePixelYHist_(),
93 resSinglePixelXGen_(),
95 resSinglePixelYGen_(),
97 file_ = std::make_unique<TFile>(filename.c_str(),
"RECREATE");
113 cotbetaLowEdge + cotbetaBins * cotbetaBinWidth,
116 cotalphaLowEdge + cotalphaBins * cotalphaBinWidth);
119 binningHisto_->SetBinContent(0, 0,
detType_);
131 sprintf(histo,
"hx%d1%02d%d%d",
detType_,
ii + 1,
jj + 1,
kk + 1);
134 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 X",
143 sprintf(histo,
"hy%d1%02d%d%d",
detType_,
ii + 1,
jj + 1,
kk + 1);
145 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 Y",
162 sprintf(histo,
"hx%d0%02d%d",
detType_,
ii + 1,
jj + 1);
165 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 X",
173 sprintf(histo,
"hy%d0%02d%d",
detType_,
ii + 1,
jj + 1);
175 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 Y",
183 sprintf(histo,
"hqbin%d%02d%d",
detType_,
ii + 1,
jj + 1);
185 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin",
210 : weOwnHistograms_(
false),
215 cotalphaBinWidth_(0),
220 binningHisto_(nullptr),
221 resMultiPixelXHist_(),
222 resSinglePixelXHist_(),
223 resMultiPixelYHist_(),
224 resSinglePixelYHist_(),
228 resMultiPixelXGen_(),
229 resSinglePixelXGen_(),
230 resMultiPixelYGen_(),
231 resSinglePixelYGen_(),
235 TH1F* tmphist =
nullptr;
238 file_ = std::make_unique<TFile>(filename.c_str(),
"READ");
241 LOGERROR <<
"PixelResolutionHistograms:: Error, file " << filename <<
" not found.";
249 LOGERROR <<
"PixelResolutionHistograms:: Error, binning histogrram ResHistoBinning not found.";
278 sprintf(histo,
"hx%d1%02d%d%d",
detType_,
ii + 1,
jj + 1,
kk + 1);
281 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 X",
288 tmphist = (TH1F*)
file_->Get(Form(
"%s%s", rootdir.c_str(),
histo));
296 if (tmphist->GetEntries() < 5) {
297 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
298 <<
" entries. Trouble ahead." << std::endl;
303 sprintf(histo,
"hy%d1%02d%d%d",
detType_,
ii + 1,
jj + 1,
kk + 1);
305 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 Y",
312 tmphist = (TH1F*)
file_->Get(Form(
"%s%s", rootdir.c_str(),
histo));
320 if (tmphist->GetEntries() < 5) {
321 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
322 <<
" entries. Trouble ahead." << std::endl;
339 sprintf(histo,
"hx%d0%02d%d",
detType_,
ii + 1,
jj + 1);
342 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 X",
348 tmphist = (TH1F*)
file_->Get(Form(
"%s%s", rootdir.c_str(),
histo));
350 if (!ignore_single) {
359 if (tmphist->GetEntries() < 5) {
360 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
361 <<
" entries. Trouble ahead." << std::endl;
369 sprintf(histo,
"hy%d0%02d%d",
detType_,
ii + 1,
jj + 1);
371 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 Y",
377 tmphist = (TH1F*)
file_->Get(Form(
"%s%s", rootdir.c_str(),
histo));
379 if (!ignore_single) {
387 if (tmphist->GetEntries() < 5) {
388 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
389 <<
" entries. Trouble ahead." << std::endl;
397 sprintf(histo,
"hqbin%d%02d%d",
detType_,
ii + 1,
jj + 1);
399 "cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin",
405 tmphist = (TH1F*)
file_->Get(Form(
"%s%s", rootdir.c_str(),
histo));
415 if (tmphist->GetEntries() < 5) {
416 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
417 <<
" entries. Trouble ahead." << std::endl;
442 LOGINFO <<
"PixelResHistoStore: Writing the histograms to the output file. "
474 double dx,
double dy,
double cotalpha,
double cotbeta,
int qbin,
int nxpix,
int nypix) {
475 int icotalpha, icotbeta, iqbin;
478 iqbin = qbin > 2 ? 3 : qbin;
479 if (icotalpha >= 0 && icotalpha < cotalphaBins_ && icotbeta >= 0 && icotbeta <
cotbetaBins_) {
480 qbinHist_[icotbeta][icotalpha]->Fill((
double)iqbin);
504 int icotalpha, icotbeta, iqbin;
507 iqbin = qbin > 2 ? 3 : qbin;
543 int icotalpha, icotbeta, iqbin;
546 iqbin = qbin > 2 ? 3 : qbin;
TH1F * resSinglePixelYHist_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
TH1F * resMultiPixelYHist_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX][QBIN_HIST_MAX]
TH1F * resSinglePixelXHist_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
SimpleHistogramGenerator * qbinGen_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
const SimpleHistogramGenerator * getGeneratorX(double cotalpha, double cotbeta, int qbin, bool singlex)
const SimpleHistogramGenerator * getGeneratorY(double cotalpha, double cotbeta, int qbin, bool singley)
TH1F * qbinHist_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
std::unique_ptr< TFile > file_
SimpleHistogramGenerator * resMultiPixelYGen_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX][QBIN_HIST_MAX]
SimpleHistogramGenerator * resMultiPixelXGen_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX][QBIN_HIST_MAX]
int Fill(double dx, double dy, double cotalpha, double cotbeta, int qbin, int nxpix, int nypix)
TH1F * resMultiPixelXHist_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX][QBIN_HIST_MAX]
SimpleHistogramGenerator * resSinglePixelYGen_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
SimpleHistogramGenerator(TH1 *histo)
PixelResolutionHistograms(std::string filename, std::string rootdir, std::string descTitle, unsigned int detType, double cotbetaBinWidth, double cotbetaLowEdge, int cotbetaBins, double cotalphaBinWidth, double cotalphaLowEdge, int cotalphaBins)
SimpleHistogramGenerator * resSinglePixelXGen_[COTBETA_HIST_MAX][COTALPHA_HIST_MAX]
virtual ~PixelResolutionHistograms()