10 #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") 71 double cotbetaBinWidth,
72 double cotbetaLowEdge,
74 double cotalphaBinWidth,
75 double cotalphaLowEdge,
79 : weOwnHistograms_(
true),
81 cotbetaBinWidth_ ( cotbetaBinWidth ),
82 cotbetaLowEdge_ ( cotbetaLowEdge ),
83 cotbetaBins_ ( cotbetaBins ),
84 cotalphaBinWidth_ ( cotalphaBinWidth ),
85 cotalphaLowEdge_ ( cotalphaLowEdge ),
86 cotalphaBins_ ( cotalphaBins ),
90 resMultiPixelXHist_(), resSinglePixelXHist_(),
91 resMultiPixelYHist_(), resSinglePixelYHist_(),
95 resMultiPixelXGen_(), resSinglePixelXGen_(),
96 resMultiPixelYGen_(), resSinglePixelYGen_(),
100 file_ = std::make_unique<TFile>( filename.c_str(),
"RECREATE" );
112 binningHisto_ =
new TH2F(
"ResHistoBinning", descTitle.c_str(),
113 cotbetaBins, cotbetaLowEdge, cotbetaLowEdge + cotbetaBins*cotbetaBinWidth,
114 cotalphaBins, cotalphaLowEdge, cotalphaLowEdge + cotalphaBins*cotalphaBinWidth );
117 binningHisto_->SetBinContent(0, 0,
detType_);
131 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 X",
139 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 Y",
158 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 X",
165 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 Y",
171 sprintf( histo,
"hqbin%d%02d%d",
detType_,
ii+1,
jj+1 );
172 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin",
176 qbinHist_ [
ii ][
jj ] =
new TH1F(histo, title, 4, -0.49, 3.51);
222 TH1F * tmphist =
nullptr;
225 file_ = std::make_unique<TFile>( filename.c_str() ,
"READ");
228 LOGERROR <<
"PixelResolutionHistograms:: Error, file " << filename <<
" not found.";
233 binningHisto_ = (TH2F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
"ResHistoBinning" ) );
236 LOGERROR <<
"PixelResolutionHistograms:: Error, binning histogrram ResHistoBinning not found.";
240 if ( detType == -1 ) {
259 if ( !ignore_multi ) {
269 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 X",
274 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
281 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
282 if ( tmphist->GetEntries() < 5 ) {
283 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
284 <<
" entries. Trouble ahead." << std::endl;
291 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 Y",
296 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
303 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
304 if ( tmphist->GetEntries() < 5 ) {
305 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
306 <<
" entries. Trouble ahead." << std::endl;
327 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 X",
331 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
333 if ( !ignore_single ) {
341 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
342 LOGDEBUG <<
"Found histo with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
343 if ( tmphist->GetEntries() < 5 ) {
344 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
345 <<
" entries. Trouble ahead." << std::endl;
355 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 Y",
359 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
361 if ( !ignore_single ) {
369 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
370 if ( tmphist->GetEntries() < 5 ) {
371 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
372 <<
" entries. Trouble ahead." << std::endl;
381 sprintf( histo,
"hqbin%d%02d%d",
detType_,
ii+1,
jj+1 );
382 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin",
386 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
388 if ( !ignore_qBin ) {
396 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
397 if ( tmphist->GetEntries() < 5 ) {
398 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
399 <<
" entries. Trouble ahead." << std::endl;
432 <<
"PixelResHistoStore: Writing the histograms to the output file. " 473 Fill(
double dx,
double dy,
double cotalpha,
double cotbeta,
474 int qbin,
int nxpix,
int nypix )
476 int icotalpha, icotbeta, iqbin ;
479 iqbin = qbin > 2 ? 3 : qbin;
480 if( icotalpha >= 0 && icotalpha < cotalphaBins_ && icotbeta >= 0 && icotbeta <
cotbetaBins_ ) {
481 qbinHist_[icotbeta][icotalpha]->Fill((
double)iqbin);
506 int icotalpha, icotbeta, iqbin ;
509 iqbin = qbin > 2 ? 3 : qbin;
545 int icotalpha, icotbeta, iqbin ;
548 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()