ATLAS Offline Software
PassInput.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 #ifndef DQM_ALGORITHMS_PASSINPUT_CXX
11 #define DQM_ALGORITHMS_PASSINPUT_CXX
12 
13 #include <dqm_core/AlgorithmConfig.h>
15 
16 #include <TClass.h>
17 #include <map>
18 
19 #include <dqm_core/AlgorithmManager.h>
20 
21 #ifndef DQM_ALGORITHMS_MULTIALGORITHMTEST
22 static dqm_algorithms::PassInput myInstance;
23 #endif //
24 
26 {
27  dqm_core::AlgorithmManager::instance().registerAlgorithm("PassInput", this);
28 }
29 
31 {
32 }
33 
36 {
37 
38  return new PassInput();
39 }
40 
41 
44  const TObject& object,
45  const dqm_core::AlgorithmConfig& config )
46 {
48  std::string tagName;
49 
50  if( (!object.IsA()->InheritsFrom( "TH1" )) && (!object.IsA()->InheritsFrom( "TObjArray" )) ) {
51  throw dqm_core::BadConfig( ERS_HERE, name, "input object does not inherit from either TH1 or TObjArray");
52  }
53 
54  //Pass this input object pointer
55  TObject* resultObject = object.Clone();
56  result->object_ = (boost::shared_ptr<TObject>)resultObject;
57 
58  //Pass the config as a series of tags (with labels embedded in the strings):
59  //First the options:
60  std::map<std::string,double> configParametersMap = config.getParameters(); //Copy needed to avoid runtime errors. AlgConfig needs to return map by reference, which it does not do.
61  if (!configParametersMap.empty()){
62  for ( std::map<std::string,double>::const_iterator paramIter = configParametersMap.begin();
63  paramIter != configParametersMap.end(); ++paramIter ) {
64  // if( paramIter->second.empty() ) {
65  // //Could just drop this, or throw an error, but will keep and label as empty for now
66  // tagName="EmptyParameter--" + paramIter->first;
67  // result->tags_[tagName] = -1.;
68  // continue;
69  // }
70  // if ( paramIter->second.size() == 1 ) {
71  tagName="ConfParameter--" + paramIter->first;
72  result->tags_[tagName] = paramIter->second;
73  // }
74  // else {
75  // int i=0;
76  // for( std::vector<double>::const_iterator valueIter = paramIter->second.begin();
77  // valueIter != paramIter->second.end(); valueIter++ ) {
78  // char numStr[32];
79  // sprintf(numStr,"%d",i);
80  // tagName="ConfParameter["+(numStr+("]--"+ paramIter->first));
81  // result->tags_[tagName] = *valueIter;
82  // }
83  // }
84  }
85  }
86  //Now the Green Thresholds:
87  std::map<std::string,double> greenThreshMap = config.getGreenThresholds(); //Copy needed to avoid runtime errors.
88  if (!greenThreshMap.empty()) {
89  for ( std::map<std::string,double>::const_iterator itr = greenThreshMap.begin();
90  itr != greenThreshMap.end(); ++itr ){
91  tagName = "GThreshold--"+itr->first;
92  result->tags_[tagName] = itr->second;
93  }
94  }
95  //Finally, the Red Thresholds:
96  std::map<std::string,double> redThreshMap = config.getRedThresholds(); //Copy needed to avoid runtime errors.
97  if (!redThreshMap.empty()) {
98  for ( std::map<std::string,double>::const_iterator itr = redThreshMap.begin();
99  itr != redThreshMap.end(); ++itr ){
100  tagName = "RThreshold--"+itr->first;
101  result->tags_[tagName] = itr->second;
102  }
103  }
104 
105  //No checks are done, so the result should be undefined:
107 
108  return result;
109 }
110 
111 void
113 {
114  out<<"PassInput: Minimal algorithm to pass its input histogram through to its result." << std::endl;
115 
116 }
117 
118 #endif // #ifndef DQM_ALGORITHMS_PASSINPUT_CXX
PassInput.h
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
dqm_algorithms::PassInput
Definition: PassInput.h:18
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::PassInput::printDescription
void printDescription(std::ostream &out)
Definition: PassInput.cxx:112
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
dqm_algorithms::PassInput::PassInput
PassInput()
Definition: PassInput.cxx:25
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
dqm_algorithms::PassInput::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: PassInput.cxx:43
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
dqm_algorithms::PassInput::~PassInput
~PassInput()
Definition: PassInput.cxx:30
dqm_algorithms::PassInput::clone
PassInput * clone()
Definition: PassInput.cxx:35