ATLAS Offline Software
Loading...
Searching...
No Matches
dqm_algorithms::DivideReference Struct Reference

#include <DivideReference.h>

Inherits dqm_core::Algorithm.

Inherited by dqm_algorithms::DivideReference_All_Bins_Filled, dqm_algorithms::DivideReference_BinContentComp, dqm_algorithms::DivideReference_Bins_Diff_FromAvg, dqm_algorithms::DivideReference_Bins_Equal_Threshold, dqm_algorithms::DivideReference_Bins_GreaterThanEqual_Threshold, dqm_algorithms::DivideReference_Bins_GreaterThan_Threshold, dqm_algorithms::DivideReference_Bins_LessThanEqual_Threshold, dqm_algorithms::DivideReference_Bins_LessThan_Threshold, and dqm_algorithms::DivideReference_Bins_NotEqual_Threshold.

Collaboration diagram for dqm_algorithms::DivideReference:

Public Member Functions

 DivideReference (const std::string &name)
DivideReferenceclone ()
void printDescription (std::ostream &out)
dqm_core::Result * execute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)

Private Attributes

std::string m_name

Detailed Description

Definition at line 18 of file DivideReference.h.

Constructor & Destructor Documentation

◆ DivideReference()

dqm_algorithms::DivideReference::DivideReference ( const std::string & name)

Definition at line 31 of file DivideReference.cxx.

31 : m_name(name)
32{
33 dqm_core::AlgorithmManager::instance().registerAlgorithm("DivideReference_"+name,this);
34}

Member Function Documentation

◆ clone()

dqm_algorithms::DivideReference * dqm_algorithms::DivideReference::clone ( )

Definition at line 37 of file DivideReference.cxx.

38{
39 return new DivideReference(m_name);
40}
DivideReference(const std::string &name)

◆ execute()

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

Definition at line 43 of file DivideReference.cxx.

44{
45 TH1 * histogram;
46
47 if( object.IsA()->InheritsFrom( "TH1" ) ) {
48 histogram = (TH1*)(object.Clone());
49 } else {
50 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
51 }
52
53 const double minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
54
55 if (histogram->GetEffectiveEntries() < minstat ) {
56 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
57 result->tags_["InsufficientEffectiveEntries"] = histogram->GetEffectiveEntries();
58 delete histogram;
59 return result;
60 }
61
62
63 TObject* ro = config.getReference();
64 const TObject* firstReference=0;
65 TObject* secondReference=0;
66 try {
67 dqm_algorithms::tools::handleReference( *ro , firstReference , secondReference );
68 }
69 catch ( dqm_core::Exception & ex ) {
70 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
71 }
72 //Check the reference
73 const TH1* refhist = dynamic_cast<const TH1*>(firstReference);
74 if ( refhist==0 )
75 {
76 throw dqm_core::BadRefHist( ERS_HERE, "Dimension", name );
77 }
78 if ((histogram->GetDimension() != refhist->GetDimension()) ||
79 (histogram->GetNbinsX() != refhist->GetNbinsX()) ||
80 (histogram->GetNbinsY() != refhist->GetNbinsY()) ||
81 refhist->GetNbinsZ() != histogram->GetNbinsZ() )
82 {
83 throw dqm_core::BadRefHist( ERS_HERE, "number of bins", name );
84 }
85 //Configuration done, prepare input histogram
86 histogram->Divide(refhist);
87 //Now prepare to run the real algorithm...
88 ERS_DEBUG(2,"Running algorithm: "<<m_name);
89 dqm_core::Algorithm* subalgorithm;
90 try {
91 subalgorithm = dqm_core::AlgorithmManager::instance().getAlgorithm( m_name );
92 }
93 catch ( dqm_core::AlgorithmNotFound& ex )
94 {
95 ERS_DEBUG(2,"Cannot find algorithm:"+m_name);
96 throw dqm_core::BadConfig(ERS_HERE,name,"Cannot Find sub-algorithm:"+m_name);
97 }
98 //Copy configuration and update reference
99 dqm_algorithms::tools::SimpleAlgorithmConfig newConf( config );
100 newConf.setReference( secondReference );
101 dqm_core::Result* result = subalgorithm->execute( name , *histogram , newConf);
102 ERS_DEBUG(2,"Sub algorithm returns:"<<*result);
103 //Add modified histogram to result
104 TObject* robject = result->getObject();
105 if ( !robject ) //No object defined, add the modified histogram
106 {
107 ERS_DEBUG(2,"Adding modified histogram in result");
108 result->object_.reset(histogram);
109 }
110 else //Transform the object_ in TObjArray (if needed) and add this result
111 {
112 ERS_DEBUG(2,"Result already have an associated TObject, appending modified histogram");
113 if ( robject->IsA()->InheritsFrom("TCollection") ) //It is already an array add it...
114 {
115 static_cast<TCollection*>(robject)->Add( histogram );
116 }
117 else
118 {
119 TObjArray* array = new TObjArray( 2 );
120 array->AddAt( robject->Clone() , 0 );
121 array->AddAt( histogram , 1 );
122 //Check in again
123 result->object_.reset( array );
124 }
125 ERS_DEBUG(2,"Result now have a TObjArray of size:"<<static_cast<TObjArray*>(result->getObject())->GetEntries());
126 }
127 return result;
128}
std::string histogram
Definition chains.cxx:52
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
void handleReference(const TObject &inputReference, const TObject *&firstReference, TObject *&secondReference)
Helper function used to handle complex reference histograms This function gets as input a reference o...
#define IsA
Declare the TObject style functions.

◆ printDescription()

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

Definition at line 131 of file DivideReference.cxx.

131 {
132 out<<"DivideReference_"+m_name+" : Performs the "+m_name+" algorithm after dividing the input histogram by the reference. I.e. performing: histogram /= Reference (see TH1::Divide). Adds to the output TObject list the modified input histogram."<<std::endl;
133 out<<"Optional Parameter : MinStat : Minimum histogram statistics needed to perform Algorithm"<<std::endl;
134
135
136}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::DivideReference::m_name
private

Definition at line 26 of file DivideReference.h.


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