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

#include <MDTMLOverview.h>

Inheritance diagram for dqm_algorithms::MDTMLOverview:
Collaboration diagram for dqm_algorithms::MDTMLOverview:

Public Member Functions

 MDTMLOverview ()
virtual ~MDTMLOverview ()
virtual dqm_core::Algorithm * clone ()
virtual dqm_core::Result * execute (const std::string &name, const TObject &object, const dqm_core::AlgorithmConfig &config)
virtual void printDescription (std::ostream &out)

Private Attributes

std::string m_name

Detailed Description

Definition at line 16 of file MDTMLOverview.h.

Constructor & Destructor Documentation

◆ MDTMLOverview()

dqm_algorithms::MDTMLOverview::MDTMLOverview ( )

Definition at line 42 of file MDTMLOverview.cxx.

43 : m_name("MDTMLoverview")
44{
45 dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
46}

◆ ~MDTMLOverview()

dqm_algorithms::MDTMLOverview::~MDTMLOverview ( )
virtual

Definition at line 49 of file MDTMLOverview.cxx.

50{
51}

Member Function Documentation

◆ clone()

dqm_core::Algorithm * dqm_algorithms::MDTMLOverview::clone ( )
virtual

Definition at line 55 of file MDTMLOverview.cxx.

56{
57 return new MDTMLOverview(*this);
58}

◆ execute()

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

Definition at line 62 of file MDTMLOverview.cxx.

63{
64 const TH1 * hist;
65 const TH1 * ref;
66
67 if( object.IsA()->InheritsFrom( "TH1" ) ) {
68 hist = static_cast<const TH1*>(&object);
69 if (hist->GetDimension() >= 2 ){
70 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
71 }
72 } else {
73 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
74 }
75
76 //Get Parameters and Thresholds
77 bool ref_y_n=0;
78 double thresh;
79 double minstat;
80 double greenTh;
81 double redTh;
82 try {
83 ref_y_n = dqm_algorithms::tools::GetFirstFromMap("ref", config.getParameters(), 0);
84 thresh = dqm_algorithms::tools::GetFirstFromMap("thresh", config.getParameters());
85 minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), 50);
86 redTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getRedThresholds());
87 greenTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getGreenThresholds() );
88 }
89 catch ( dqm_core::Exception & ex ) {
90 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
91 }
92
93 //Get Reference Histo
94
95 try {
96 ref = static_cast<const TH1*>( config.getReference() );
97 }
98 catch ( dqm_core::Exception & ex ) {
99 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retrieve reference");
100 }
101
102 if (hist->GetDimension() != ref->GetDimension() ) {
103 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
104 }
105 if (hist->GetNbinsX() != ref->GetNbinsX() ) {
106 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different bin number in X axis!" );
107 }
108
109 //Check of statistics
110 if (hist->GetEntries() < minstat ) {
111 ERS_INFO("Histogram does not satisfy MinStat requirement " <<hist->GetName());
112 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
113 result->tags_["InsufficientEntries"] = hist->GetEntries();
114 return result;
115 }
116 ERS_DEBUG(1,"Statistics: "<< hist->GetEntries()<< " entries ");
117
118
119 //Algo
120
121 int binX = hist->GetNbinsX();
122 //double x_center=0;
123
124 std::vector<int> hist_buffer;
125 std::vector<int> ref_buffer;
126
127 std::vector< double > new_empty_bins;
128 int count=0;
129
130 for(int x_index=1; x_index<=binX; x_index++){
131 if( hist->GetBinContent(x_index) != 0 ) hist_buffer.push_back((int)hist->GetBinContent(x_index));
132 if(ref_y_n==1) {
133 if( ref->GetBinContent(x_index) != 0 ) ref_buffer.push_back((int)ref->GetBinContent(x_index));
134 }
135 };
136
137
138
139 auto median=[](std::vector<int> & v)->int {
140 const auto midPoint = v.begin()+v.size()/2;
141 std::nth_element(v.begin(), midPoint, v.end());
142 return v[v.size()/2];
143 };
144
145
146 double percentThreshold = thresh*0.01;
147 const int mediana_hist = median(hist_buffer);
148
149 if(ref_y_n==1) {
150 const int mediana_ref = median(ref_buffer);
151 for(int xi=1; xi<=binX; xi++){
152 if( hist->GetBinContent(xi) < mediana_hist*percentThreshold && ref->GetBinContent(xi) >= mediana_ref*percentThreshold){
153 count++;
154 new_empty_bins.push_back(hist->GetBinCenter(xi));
155 };
156 };
157 } else if(ref_y_n==0){
158 for(int xi=1; xi<=binX; xi++){
159 if( hist->GetBinContent(xi) < mediana_hist*percentThreshold){
160 count++;
161 new_empty_bins.push_back(hist->GetBinCenter(xi));
162 };
163 };
164 };
165
166
167 //double tot=binX;
168 //if(ref_y_n==0) tot=binX;
169
170 //Tag generator
171
172 dqm_core::Result* result = new dqm_core::Result();
173
174 std::string message;
175 std::string eta="ETA_";
176 std::string ml="__ML";
177 char eta_num[3];
178 std::string ml_num;
179 double num_ml_off=1;
180 int counter=0;
181
182 int empty_bin_number=new_empty_bins.size();
183
184 for(int i=0; i<empty_bin_number; i++){
185 counter=-1;
186 do{
187 counter++;
188 if(counter>=20) break;
189 }while(std::abs(counter-new_empty_bins[i])>0.3);
190
191 snprintf(eta_num,sizeof(eta_num),"%d",counter);
192 if( (counter-new_empty_bins[i])>=0)ml_num="1";
193 if( (counter-new_empty_bins[i])<0) ml_num="2";
194 message=eta+(std::string)eta_num+ml+ml_num;
195 result->tags_[message]=num_ml_off;
196 };
197
198 //Result
199
200 result->tags_["00-number_of_off_ML"] = count;
201
202 if (count<greenTh) {
203 result->status_ = dqm_core::Result::Green;
204 ERS_DEBUG(1,"Green");
205 } else if ( count>=greenTh && count<redTh ) {
206 result->status_ = dqm_core::Result::Yellow;
207 ERS_DEBUG(1,"Yellow");
208 } else if (count>=redTh) {
209 result->status_ = dqm_core::Result::Red;
210 ERS_DEBUG(1,"Red");
211 }
212 return result;
213}
const boost::regex ref(r_ef)
Scalar eta() const
pseudorapidity method
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
float median(std::vector< float > &Vec)
@ binX
Definition BinningType.h:47
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
#define IsA
Declare the TObject style functions.

◆ printDescription()

void dqm_algorithms::MDTMLOverview::printDescription ( std::ostream & out)
virtual

Definition at line 217 of file MDTMLOverview.cxx.

218{
219 std::string message;
220 message += "\n";
221 message += "Algorithm: \"" + m_name + "\"\n";
222 message += "Description: compare the histo with reference and check if there are any ML switched off\n";
223 message += "Mandatory Green/Red Threshold: Limits: number of new ML switched off while are on in reference\n";
224 message += " thresh = % of the mean entries per ML under which the algo will set ML off\n";
225 message += "Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
226 message += " ref = Bool value: 1 if you want perform the check comparing with ref\n";
227 message += " 0 if you want perform the check without the comparison with ref\n";
228 message += "\n";
229
230 out << message;
231}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::MDTMLOverview::m_name
private

Definition at line 29 of file MDTMLOverview.h.


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