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 ) {
261 <<
"Loading pixel resolution file = " << filename << std::endl
267 if ( !ignore_multi ) {
277 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 X",
282 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
289 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
290 if ( tmphist->GetEntries() < 5 ) {
291 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
292 <<
" entries. Trouble ahead." << std::endl;
299 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin %d npixel>1 Y",
304 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
311 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
312 if ( tmphist->GetEntries() < 5 ) {
313 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
314 <<
" entries. Trouble ahead." << std::endl;
335 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 X",
339 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
341 if ( !ignore_single ) {
349 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
350 LOGDEBUG <<
"Found histo with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
351 if ( tmphist->GetEntries() < 5 ) {
352 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
353 <<
" entries. Trouble ahead." << std::endl;
363 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f npixel=1 Y",
367 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
369 if ( !ignore_single ) {
377 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
378 if ( tmphist->GetEntries() < 5 ) {
379 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
380 <<
" entries. Trouble ahead." << std::endl;
389 sprintf( histo,
"hqbin%d%02d%d",
detType_,
ii+1,
jj+1 );
390 sprintf( title,
"cotbeta %.1f-%.1f cotalpha %.2f-%.2f qbin",
394 tmphist = (TH1F*)
file_->Get( Form(
"%s%s" , rootdir.c_str(),
histo ) );
396 if ( !ignore_qBin ) {
404 <<
" with title = " <<
std::string( tmphist->GetTitle() ) << std::endl;
405 if ( tmphist->GetEntries() < 5 ) {
406 LOGINFO <<
"Histogram " <<
std::string(histo) <<
" has only " << tmphist->GetEntries()
407 <<
" entries. Trouble ahead." << std::endl;
440 <<
"PixelResHistoStore: Writing the histograms to the output file. " 481 Fill(
double dx,
double dy,
double cotalpha,
double cotbeta,
482 int qbin,
int nxpix,
int nypix )
484 int icotalpha, icotbeta, iqbin ;
487 iqbin = qbin > 2 ? 3 : qbin;
488 if( icotalpha >= 0 && icotalpha < cotalphaBins_ && icotbeta >= 0 && icotbeta <
cotbetaBins_ ) {
489 qbinHist_[icotbeta][icotalpha]->Fill((
double)iqbin);
514 int icotalpha, icotbeta, iqbin ;
517 iqbin = qbin > 2 ? 3 : qbin;
553 int icotalpha, icotbeta, iqbin ;
556 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()