ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::MaximumBin Class Reference

#include <MaximumBin.h>

Inheritance diagram for dqm_algorithms::MaximumBin:
Collaboration diagram for dqm_algorithms::MaximumBin:

Public Member Functions

 MaximumBin ()
MaximumBinclone ()
dqm_core::Result * execute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
void printDescription (std::ostream &out)

Detailed Description

Definition at line 14 of file MaximumBin.h.

Constructor & Destructor Documentation

◆ MaximumBin()

dqm_algorithms::MaximumBin::MaximumBin ( )

Definition at line 13 of file MaximumBin.cxx.

14{
15 dqm_core::AlgorithmManager::instance().registerAlgorithm("MaximumBin", this);
16}

Member Function Documentation

◆ clone()

dqm_algorithms::MaximumBin * dqm_algorithms::MaximumBin::clone ( )

Definition at line 19 of file MaximumBin.cxx.

20{
21 return new MaximumBin();
22}

◆ execute()

dqm_core::Result * dqm_algorithms::MaximumBin::execute ( const std::string & name,
const TObject & object,
const dqm_core::AlgorithmConfig & config )

Definition at line 26 of file MaximumBin.cxx.

29{
30 // get the histogram
31 const TH1 * histogram;
32
33 if( object.IsA()->InheritsFrom( "TH1" ) ) {
34 histogram = static_cast<const TH1*>(&object);
35 } else {
36 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
37 }
38
39 int dim = histogram->GetDimension();
40
41 // get the reference maximum bin indices
42 int refBinX=-1, refBinY=-1, refBinZ=-1; // bin x,y,z-index to be compared to the maximum bin
43 try {
44 refBinX = (int)dqm_algorithms::tools::GetFirstFromMap("RefBinX", config.getParameters());
45 if (dim>1) refBinY = (int)dqm_algorithms::tools::GetFirstFromMap("RefBinY", config.getParameters());
46 if (dim>2) refBinZ = (int)dqm_algorithms::tools::GetFirstFromMap("RefBinZ", config.getParameters());
47 }
48 catch ( dqm_core::Exception & ex ) {
49 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
50 }
51
52 // check MinStat
53 const double minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), -1);
54 if (histogram->GetEntries() < minstat ) {
55 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
56 result->tags_["InsufficientEntries"] = histogram->GetEntries();
57 return result;
58 }
59
60 // find the maximum bin indices
61 int maxBinX=-1, maxBinY=-1, maxBinZ=-1;
62 histogram->GetMaximumBin(maxBinX,maxBinY,maxBinZ);
63
64 // publish the maximum bin indices
65 dqm_core::Result* result = new dqm_core::Result();
66 result->tags_["MaxBin_xIndex"] = maxBinX;
67 if (dim>1) result->tags_["MaxBin_yIndex"] = maxBinY;
68 if (dim>2) result->tags_["MaxBin_zIndex"] = maxBinZ;
69
70 // check if the conditions are met
71 bool match = (maxBinX == refBinX);
72 if (dim>1) match &= (maxBinY == refBinY);
73 if (dim>2) match &= (maxBinZ == refBinZ);
74
75 // set the flag and return the result
76 if (match) result->status_ = dqm_core::Result::Green;
77 else result->status_ = dqm_core::Result::Red;
78
79 return result;
80}
std::string histogram
Definition chains.cxx:52
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
#define IsA
Declare the TObject style functions.

◆ printDescription()

void dqm_algorithms::MaximumBin::printDescription ( std::ostream & out)

Definition at line 83 of file MaximumBin.cxx.

83 {
84 out<<"MaximumBin : Finds a bin with the maximum content and checks if the bin index matches the expectation"<< std::endl;
85 out<<"Mandatory parameter : RefBinX : Bin x-index where the maximum is expected"<< std::endl;
86 out<<"Optional parameter : RefBinY : Bin y-index where the maximum is expected"<< std::endl;
87 out<<"Optional parameter : RefBinZ : Bin z-index where the maximum is expected"<< std::endl;
88 out<<"Optional Parameter : MinStat : Minimum histogram statistics needed to perform Algorithm\n"<< std::endl;
89}

The documentation for this class was generated from the following files: