ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
dqm_algorithms::AddReference Struct Reference

#include <AddReference.h>

Inherits Algorithm.

Inherited by dqm_algorithms::AddReference_All_Bins_Filled, dqm_algorithms::AddReference_BinContentComp, dqm_algorithms::AddReference_Bins_Diff_FromAvg, dqm_algorithms::AddReference_Bins_Equal_Threshold, dqm_algorithms::AddReference_Bins_GreaterThan_Threshold, dqm_algorithms::AddReference_Bins_GreaterThanEqual_Threshold, dqm_algorithms::AddReference_Bins_LessThan_Threshold, dqm_algorithms::AddReference_Bins_LessThanEqual_Threshold, and dqm_algorithms::AddReference_Bins_NotEqual_Threshold.

Collaboration diagram for dqm_algorithms::AddReference:

Public Member Functions

 AddReference (const std::string &name)
 
AddReferenceclone ()
 
void printDescription (std::ostream &out)
 
dqm_core::Resultexecute (const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
 

Private Attributes

std::string m_name
 

Detailed Description

Definition at line 18 of file AddReference.h.

Constructor & Destructor Documentation

◆ AddReference()

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

Definition at line 28 of file AddReference.cxx.

28  : m_name(name)
29 {
30  dqm_core::AlgorithmManager::instance().registerAlgorithm("AddReference_"+name,this);
31 }

Member Function Documentation

◆ clone()

dqm_algorithms::AddReference * dqm_algorithms::AddReference::clone ( )

Definition at line 34 of file AddReference.cxx.

35 {
36  return new AddReference(m_name);
37 }

◆ execute()

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

Definition at line 40 of file AddReference.cxx.

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

◆ printDescription()

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

Definition at line 129 of file AddReference.cxx.

129  {
130  out<<"AddReference_"+m_name+" : Performst the "+m_name+" algorithm after adding to the input histogram the reference. I.e. performing: histogram += c*Reference. Adds to the output TObject list the modified input histogram."<<std::endl;
131  out<<"Optional Parameter : MinStat : Minimum histogram statistics needed to perform Algorithm"<<std::endl;
132  out<<"Optional Parameter : Coeff : The multiplication coefficient c, for reference. Default c=+1"<<std::endl;
133 
134 }

Member Data Documentation

◆ m_name

std::string dqm_algorithms::AddReference::m_name
private

Definition at line 26 of file AddReference.h.


The documentation for this struct was generated from the following files:
dqm_algorithms::AddReference::m_name
std::string m_name
Definition: AddReference.h:26
Undefined
@ Undefined
Definition: MaterialTypes.h:8
get_generator_info.result
result
Definition: get_generator_info.py:21
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
lumiFormat.array
array
Definition: lumiFormat.py:91
dqm_algorithms::AddReference::AddReference
AddReference(const std::string &name)
Definition: AddReference.cxx:28
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
MuonCalib::Legendre::coeff
constexpr double coeff(unsigned int l, unsigned int k)
Calculates the n-th coefficient of the legendre polynomial series.
Definition: LegendrePoly.h:73
dqm_algorithms::tools::handleReference
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...
Definition: AlgorithmHelper.cxx:828
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
histogram
std::string histogram
Definition: chains.cxx:52