ATLAS Offline Software
Loading...
Searching...
No Matches
HanAlgorithmConfig.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// **********************************************************************
6// $Id: HanAlgorithmConfig.cxx,v 1.3 2009-05-07 14:45:54 ponyisi Exp $
7// **********************************************************************
8
9#include <TDirectory.h>
10#include <TFile.h>
11#include <TKey.h>
12#include <TH1.h>
13#include <TMap.h>
14
22
23
24namespace dqi {
25
26// *********************************************************************
27// Public Methods
28// *********************************************************************
29
38
41 const std::map< std::string, double >& parameters,
42 const std::map< std::string, std::string>& stringParameters,
43 const std::map< std::string, double >& greenThresholds,
44 const std::map< std::string, double >& redThresholds,
45 const HanConfigAssessor* hca)
46 : m_file(0)
48 , m_hca(hca)
49{
50 m_parameters = parameters;
51 m_generic_parameters = stringParameters;
52 m_green_thresholds = greenThresholds;
53 m_red_thresholds = redThresholds;
55}
56
62
63
64TObject*
66getReference() const
67{
68 if (m_ref) {
69 TObject* rv = m_ref->Clone();
70 if (rv) {
71 return rv;
72 } else {
73 const char* parname = m_hca ? m_hca->GetName() : "???";
74 throw dqm_core::BadConfig( ERS_HERE, parname,
75 "Unable to clone reference" );
76 }
77 }
78 const char* parname = m_hca ? m_hca->GetName() : "???";
79 throw dqm_core::BadConfig( ERS_HERE, parname,
80 "No reference histogram provided" );
81}
82
83
84// *********************************************************************
85// Protected Methods
86// *********************************************************************
87
88void
91{
92 typedef std::map< std::string, double >::value_type ParsVal_t;
93 typedef std::map< std::string, double >::value_type ThrVal_t;
94
95 m_hca = &hca;
96
97 std::string parName;
98 TIter nextPar( hca.GetAllAlgPars() );
99 HanConfigAlgPar* par;
100 while( (par = dynamic_cast<HanConfigAlgPar*>( nextPar() )) != 0 ) {
101 parName = std::string( par->GetName() );
102 ParsVal_t parMapVal( parName, par->GetValue() );
103 m_parameters.insert( std::move(parMapVal) );
104 }
105 TIter nextStrPar( hca.GetAllAlgStrPars() );
106 HanConfigParMap* strPar;
107 while( (strPar = dynamic_cast<HanConfigParMap*>( nextStrPar() )) != 0 ) {
108 m_generic_parameters.emplace( strPar->GetName(), strPar->GetValue() );
109 }
110
111 std::string limName;
112 TIter nextLim( hca.GetAllAlgLimits() );
114 while( (lim = dynamic_cast<HanConfigAlgLimit*>( nextLim() )) != 0 ) {
115 limName = std::string( lim->GetName() );
116 ThrVal_t greenMapVal( limName, lim->GetGreen() );
117 m_green_thresholds.insert( std::move(greenMapVal) );
118 ThrVal_t redMapVal( limName, lim->GetRed() );
119 m_red_thresholds.insert( std::move(redMapVal) );
120 }
121
122 std::string refName( hca.GetAlgRefName() );
123 if( refName != "" ) {
124 TKey* key = dqi::getObjKey( m_file, refName );
125 if (key == NULL) {
126 std::cout << "ERROR: can't find reference " << refName << std::endl;
127 } else {
128 if (hca.GetIsRegex()) {
129 TMap* map = dynamic_cast<TMap*>(key->ReadObj());
130 if (! map) {
131 std::cerr << "Problem reading TMap input for regex" << std::endl;
132 m_ref = nullptr;
133 } else {
134 std::cout << "Get reference for " << hca.GetHistPath() << std::endl;
135 m_ref = map->GetValue(hca.GetHistPath());
136 }
137 } else {
138 // not a regex
139 m_ref = key->ReadObj();
140 }
141 }
142 }
143}
144
145void
148{
150
151 m_generic_parameters.emplace( "runtime_path", runtime.getPath() );
152 if ( runtime.pathIsRunDirectory() )
153 m_parameters.emplace( "run_number", runtime.getPathRunNumber() );
154}
155
156
157// *********************************************************************
158// Private Methods
159// *********************************************************************
160
161} // namespace dqi
const HanConfigAssessor * m_hca
void CopyAlgConfig(const HanConfigAssessor &hca)
HanAlgorithmConfig(const HanConfigAssessor &hca, TFile *config)
virtual TObject * getReference() const override
virtual const char * GetName() const
virtual float GetRed() const
virtual float GetGreen() const
virtual TIter GetAllAlgStrPars() const
virtual const char * GetHistPath() const
virtual TIter GetAllAlgLimits() const
virtual bool GetIsRegex() const
virtual std::string GetAlgRefName() const
virtual TIter GetAllAlgPars() const
virtual const char * GetValue() const
virtual const char * GetName() const
static HanRuntimeConfigSingleton & getInstance()
STL class.
TKey * getObjKey(TDirectory *dir, const std::string &path)
Definition HanUtils.cxx:36