15#include "GaudiKernel/ISvcLocator.h"
16#include "GaudiKernel/Service.h"
26 const std::string& dirName,
27 const std::string& anaTag,
41 return StatusCode::SUCCESS;
49 const std::string& identifier,
50 const std::string& folderOverride,
51 const std::string& nameOverride )
const
54 ISvcLocator* svcLoc = Gaudi::svcLocator();
55 SmartIF<IPlotsDefinitionSvc> plotsDefSvc(svcLoc->service(
"PlotsDefSvc"+
m_anaTag ));
65 if( not folderOverride.empty() ) sDef.
folder( folderOverride );
68 if( not nameOverride.empty() ) sDef.
name( nameOverride );
83 return StatusCode::FAILURE;
102 return StatusCode::SUCCESS;
112 return StatusCode::FAILURE;
144 return StatusCode::SUCCESS;
154 return StatusCode::FAILURE;
199 return StatusCode::SUCCESS;
209 return StatusCode::FAILURE;
229 return StatusCode::SUCCESS;
239 return StatusCode::FAILURE;
271 return StatusCode::SUCCESS;
281 return StatusCode::FAILURE;
284 pHisto = ( def.
nBinsY() == 0 ) ?
309 return StatusCode::SUCCESS;
318 TH1* pTh1,
float value,
float weight )
const
322 return StatusCode::FAILURE;
325 if( std::isnan( value ) or std::isnan( weight ) ) {
326 ATH_MSG_ERROR(
"Non-valid fill arguments for TH1:" << pTh1->GetName() );
327 return StatusCode::FAILURE;
331 pTh1->Fill( value, weight );
332 return StatusCode::SUCCESS;
338 TH2* pTh2,
float xval,
float yval,
float weight )
const
342 return StatusCode::FAILURE;
345 if( std::isnan( xval ) or std::isnan( yval ) or std::isnan( weight ) ) {
346 ATH_MSG_ERROR(
"Non-valid fill arguments for TH2:" << pTh2->GetName() );
347 return StatusCode::FAILURE;
351 pTh2->Fill( xval, yval, weight );
352 return StatusCode::SUCCESS;
358 TH3* pTh3,
float xval,
float yval,
float zval,
float weight )
const
362 return StatusCode::FAILURE;
365 if( std::isnan( xval ) or std::isnan( yval ) or
366 std::isnan( zval ) or std::isnan( weight ) ) {
367 ATH_MSG_ERROR(
"Non-valid fill arguments for TH3:" << pTh3->GetName() );
368 return StatusCode::FAILURE;
373 pTh3->Fill( xval, yval, zval, weight );
374 return StatusCode::SUCCESS;
380 TProfile* pTprofile,
float xval,
float yval,
float weight )
const
382 if( not pTprofile ) {
384 return StatusCode::FAILURE;
387 if( std::isnan( xval ) or std::isnan( yval ) or std::isnan( weight ) ) {
388 ATH_MSG_ERROR(
"Non-valid fill arguments for TProfile:" << pTprofile->GetName() );
389 return StatusCode::FAILURE;
393 pTprofile->Fill( xval, yval, weight );
394 return StatusCode::SUCCESS;
400 TProfile2D* pTprofile,
float xval,
float yval,
float zval,
float weight )
const
402 if( not pTprofile ) {
404 return StatusCode::FAILURE;
407 if( std::isnan( xval ) or std::isnan( yval ) or
408 std::isnan( zval ) or std::isnan( weight ) ) {
409 ATH_MSG_ERROR(
"Non-valid fill arguments for TProfile2D:" << pTprofile->GetName() );
410 return StatusCode::FAILURE;
414 pTprofile->Fill( xval, yval, zval, weight );
415 return StatusCode::SUCCESS;
421 TEfficiency* pTeff,
float value,
bool accepted,
float weight )
const
424 ATH_MSG_ERROR(
"Trying to fill non-definded 1D TEfficiency" );
425 return StatusCode::FAILURE;
428 if( std::isnan( value ) or std::isnan( weight ) ) {
429 ATH_MSG_ERROR(
"Non-valid fill arguments for 1D TEfficiency:" << pTeff->GetName() );
430 return StatusCode::FAILURE;
435 if( weight==1.) pTeff->Fill( accepted, value );
436 else pTeff->FillWeighted( accepted, weight, value );
437 return StatusCode::SUCCESS;
443 TEfficiency* pTeff2d,
float xvalue,
float yvalue,
bool accepted,
float weight )
const
446 ATH_MSG_ERROR(
"Trying to fill non-definded 2D TEfficiency" );
447 return StatusCode::FAILURE;
450 if( std::isnan( xvalue ) or std::isnan( yvalue ) or std::isnan( weight ) ) {
451 ATH_MSG_ERROR(
"Non-valid fill arguments for 2D TEfficiency:" << pTeff2d->GetName() );
452 return StatusCode::FAILURE;
457 if( weight==1.) pTeff2d->Fill( accepted, xvalue, yvalue );
458 else pTeff2d->FillWeighted( accepted, weight, xvalue, yvalue );
459 return StatusCode::SUCCESS;
465 unsigned int nBins,
float absMin,
float absMax,
bool symmetriseAroundZero )
467 std::vector<float> emptyVec;
469 if( absMin<=0 or absMax<=0 ) {
470 ATH_MSG_WARNING(
"absMin or absMax argument to getLogLinearBins is out of range" );
472 }
else if( nBins==0 ) {
477 unsigned int asymVecSize = nBins + 1;
478 std::vector<float> theBinning( asymVecSize, 0.);
480 float logStart = std::log( absMin );
481 float logDist = std::log( absMax ) - logStart;
482 float logStep = logDist / (float) nBins;
484 float thisLog{ logStart };
485 for(
float& thisBin : theBinning ) {
486 thisBin = std::exp( thisLog );
489 if( symmetriseAroundZero ) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
Derived class to give extra capabilities to TrkValHistUtils/PlotBase.h such as ATH_MSG and an easier ...
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
StatusCode setLogLinearBins(P *&pHisto, unsigned int nBins, float absMin, float absMax, char axis)
Set Log-Linear axis.
StatusCode setVariableBins(P *&pHisto, const std::vector< float > &binning, char axis)
SetVariableBins.
StatusCode setBinLabels(P *&pHisto, const std::vector< std::string > &binLabels, char axis)
SetBinLabels (for TH* and TProfile* only)
StatusCode setLogLinearBinsEff(P *&pHisto, unsigned int nBins, float absMin, float absMax, char axis)
Set Log-Linear axis (for Efficiencies)
StatusCode book(TH1 *&pHisto, const SinglePlotDefinition &def)
Book a TH1 histogram.
StatusCode setVariableBinsEff(P *&pHisto, const std::vector< float > &binning, char axis)
SetVariableBins (for Efficiencies)
std::vector< float > getLogLinearBins(unsigned int nBins, float absMin, float absMax, bool symmetriseAroundZero=false)
Get Log-Linear binning vector inherited from InDetPhysValMonitoring/src/logLinearBinning....
StatusCode initialize()
initialize
StatusCode fill(TH1 *pTh1, float value, float weight=1.) const
PlotMgr(const std::string &dirName, const std::string &anaTag, PlotMgr *pParent=nullptr)
Constructor taking parent node and directory name for plots pParent = nullptr by default to book plot...
SinglePlotDefinition retrieveDefinition(const std::string &identifier, const std::string &folderOverride="", const std::string &nameOverride="") const
Retrieve a single histogram definition, given the unique string identifier.
const std::vector< float > & xBinsVec() const
unsigned int nBinsY() const
const std::vector< std::string > & yBinLabelsVec() const
unsigned int nBinsX() const
bool doLogLinBinsZ() const
unsigned int nBinsZ() const
const std::string & folder() const
const std::string & titleDigest() const
const std::vector< float > & yBinsVec() const
const std::vector< float > & zBinsVec() const
bool doLogLinBinsX() const
const std::string & identifier() const
const std::string & name() const
const std::vector< std::string > & zBinLabelsVec() const
const std::vector< std::string > & xBinLabelsVec() const
bool doLogLinBinsY() const
TH1D * Book1D(const std::string &name, const std::string &labels, int nBins, float start, float end, bool prependDir=true)
Book a TH1D histogram.
PlotBase(PlotBase *parent, const std::string &sDir)
TH3F * Book3D(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, int nBinsZ, float startZ, float endZ, bool prependDir=true)
Book a TH3F histogram.
TProfile * BookTProfile(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, float startY=-1, float endY=-1, bool prependDir=true, bool useRMS=false)
Book a TProfile histogram.
TH2F * Book2D(const std::string &name, const std::string &labels, int nBinsX, float startX, float endX, int nBinsY, float startY, float endY, bool prependDir=true)
Book a TH2F histogram.
TEfficiency * BookTEfficiency(const std::string &name, const std::string &labels, const int nBinsX, const float xlo, const float xhi, const bool prependDir=true)
Book a (1-D) TEfficiency histogram.
TProfile2D * BookTProfile2D(const std::string &name, const std::string &labels, const int nBinsX, const double xlo, const double xhi, const int nBinsY, const double ylo, const double yhi, bool prependDir=true, bool useRMS=false)
Book a TProfile 2D histogram with variable binning in x-axis and limits in y-values.