20 #include "dqm_core/exceptions.h"
21 #include "dqm_core/AlgorithmConfig.h"
22 #include "dqm_core/AlgorithmManager.h"
23 #include "dqm_core/Result.h"
38 : m_name(
"MDTTubeCheck")
60 const TH1 * refhist(0);
62 if(
object.
IsA()->InheritsFrom(
"TH1" ) ) {
65 throw dqm_core::BadConfig( ERS_HERE,
name,
"dimension >= 2 " );
68 throw dqm_core::BadConfig( ERS_HERE,
name,
"does not inherit from TH1" );
86 catch ( dqm_core::Exception & ex ) {
87 throw dqm_core::BadConfig( ERS_HERE,
name, ex.what(), ex );
93 refhist =
static_cast<const TH1*
>(
config.getReference() );
95 catch ( dqm_core::Exception & ex ) {
96 throw dqm_core::BadRefHist(ERS_HERE,
name,
" Could not retreive reference");
98 if (
histogram->GetDimension() != refhist->GetDimension() ) {
99 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different dimension!" );
101 if (
histogram->GetNbinsX() != refhist->GetNbinsX() ) {
102 throw dqm_core::BadRefHist( ERS_HERE,
name,
"Reference VS histo: Different number of bins!" );
107 if (
histogram->GetEntries() < minstat ) {
108 ERS_INFO(
"Histogram does not satisfy MinStat requirement " <<
histogram->GetName());
113 ERS_DEBUG(1,
"Statistics: "<<
histogram->GetEntries()<<
" entries ");
115 int NewDead_count = 0;
116 int StillDead_count = 0;
117 int Revived_count = 0;
118 int LowStat_count = 0;
119 std::vector<int>
range;
123 ERS_INFO(
"Histogram has not dimension 1 : " <<
histogram->GetName());
124 throw dqm_core::Exception( ERS_HERE,
histogram->GetName() );
127 std::vector<int> Tubes;
134 double RefCont = refhist->GetBinContent(
i);
135 if ((
content < bin_threshold) && ((RefCont >= bin_threshold) || (RefCont == LowStatLevel))) {
138 }
else if ((
content < bin_threshold) && ((RefCont < bin_threshold) || (RefCont == LowStatLevel))) {
140 }
else if ((
content >= bin_threshold) && (RefCont < bin_threshold)) {
144 if (((
content < bin_threshold) ) ) {
151 ERS_DEBUG(1,
"Number of bins " <<
name <<
" different from a treshold of " << bin_threshold <<
" is " << NewDead_count );
154 if (LowStat_count > 0)
result->tags_[
"NTubes_withLowStat"] = LowStat_count;
155 if (Revived_count > 0)
result->tags_[
"NTubes_Revived"] = Revived_count;
156 result->tags_[
"NewDead_Tubes"] = NewDead_count;
157 if (Tubes.size()>0) {
158 for (
int k=0;
k<(
int)Tubes.size();
k++) {
159 std::string ToDB=
"ChangedStatusTube_";
161 result->tags_[ToDB] = Tubes[
k];
162 ERS_DEBUG(1,
"MDT Tube which changed status: "<<ToDB<<
" = "<<Tubes[
k] );
165 if (NewDead_count >= redTh) {
168 }
else if ( (NewDead_count > greenTh) || (Revived_count > 0)) {
169 result->status_ = dqm_core::Result::Yellow;
170 ERS_DEBUG(1,
"Yellow");
171 }
else if (LowStat_count > 0) {
173 ERS_DEBUG(1,
"Undefined");
174 }
else if (StillDead_count ==
range[1]) {
179 ERS_DEBUG(1,
"Green");
191 message +=
"Description: Check if the number of entries in bins is less than BinThreshold and compare with Reference Histo \n";
192 message +=
"Mandatory Parameter: BinThreshold = Look for bins less than BinTreshold; Count number of bins satifying requirement \n";
193 message +=
"Mandatory Parameter: ReferenceCheck = 0 if no check on reference is requested \n";
194 message +=
"Mandatory Green/Red Threshold: NBins = number of bins satifying requirement\n";
195 message +=
"Optional Parameters: LowStatLevel = Level (in y) that means too few statistics for analysis\n";
196 message +=
"Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
197 message +=
" xmin: minimum x range\n";
198 message +=
" xmax: maximum x range\n";