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

#include <MDTTubeCheck.h>

Inheritance diagram for dqm_algorithms::MDTTubeCheck:
Collaboration diagram for dqm_algorithms::MDTTubeCheck:

Public Member Functions

 MDTTubeCheck ()
virtual ~MDTTubeCheck ()
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 20 of file MDTTubeCheck.h.

Constructor & Destructor Documentation

◆ MDTTubeCheck()

dqm_algorithms::MDTTubeCheck::MDTTubeCheck ( )

Definition at line 37 of file MDTTubeCheck.cxx.

38 : m_name("MDTTubeCheck")
39{
40 dqm_core::AlgorithmManager::instance().registerAlgorithm( m_name, this );
41}

◆ ~MDTTubeCheck()

dqm_algorithms::MDTTubeCheck::~MDTTubeCheck ( )
virtual

Definition at line 44 of file MDTTubeCheck.cxx.

45{
46}

Member Function Documentation

◆ clone()

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

Definition at line 50 of file MDTTubeCheck.cxx.

51{
52 return new MDTTubeCheck(*this);
53}

◆ execute()

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

Definition at line 57 of file MDTTubeCheck.cxx.

58{
59 const TH1 * histogram(0);
60 const TH1 * refhist(0);
61
62 if( object.IsA()->InheritsFrom( "TH1" ) ) {
63 histogram = static_cast<const TH1*>(&object);
64 if (histogram->GetDimension() >= 2 ){
65 throw dqm_core::BadConfig( ERS_HERE, name, "dimension >= 2 " );
66 }
67 } else {
68 throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH1" );
69 }
70
71 //Get Parameters and Thresholds
72 double minstat;
73 double bin_threshold;
74 double refcheck;
75 double greenTh;
76 double redTh;
77 double LowStatLevel;
78 try {
79 bin_threshold = dqm_algorithms::tools::GetFirstFromMap( "BinThreshold", config.getParameters());
80 refcheck = dqm_algorithms::tools::GetFirstFromMap( "ReferenceCheck", config.getParameters());
81 LowStatLevel = dqm_algorithms::tools::GetFirstFromMap( "LowStatLevel", config.getParameters(), 10);
82 minstat = dqm_algorithms::tools::GetFirstFromMap( "MinStat", config.getParameters(), -1);
83 redTh = dqm_algorithms::tools::GetFromMap( "NBins", config.getRedThresholds());
84 greenTh = dqm_algorithms::tools::GetFromMap( "NBins", config.getGreenThresholds() );
85 }
86 catch ( dqm_core::Exception & ex ) {
87 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
88 }
89
90 //Get Reference Histo
91 if (refcheck>0) {
92 try {
93 refhist = static_cast<const TH1*>( config.getReference() );
94 }
95 catch ( dqm_core::Exception & ex ) {
96 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
97 }
98 if (histogram->GetDimension() != refhist->GetDimension() ) {
99 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
100 }
101 if (histogram->GetNbinsX() != refhist->GetNbinsX() ) {
102 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different number of bins!" );
103 }
104 }
105
106 //Check of statistics
107 if (histogram->GetEntries() < minstat ) {
108 ERS_INFO("Histogram does not satisfy MinStat requirement " <<histogram->GetName());
109 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
110 result->tags_["InsufficientEntries"] = histogram->GetEntries();
111 return result;
112 }
113 ERS_DEBUG(1,"Statistics: "<< histogram->GetEntries()<< " entries ");
114
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;
120 if (histogram->GetDimension() == 1){
122 } else {
123 ERS_INFO("Histogram has not dimension 1 : " <<histogram->GetName());
124 throw dqm_core::Exception( ERS_HERE, histogram->GetName() );
125 }
126
127 std::vector<int> Tubes;
128 for ( int i = range[0]; i <= range[1]; ++i ) {
129 double content = histogram->GetBinContent(i);
130 if (content == LowStatLevel) {
131 ++LowStat_count;
132 } else if (content != 0.) {
133 if (refcheck>0) {
134 double RefCont = refhist->GetBinContent(i);
135 if ((content < bin_threshold) && ((RefCont >= bin_threshold) || (RefCont == LowStatLevel))) {
136 ++NewDead_count;
137 Tubes.push_back(i);
138 } else if ((content < bin_threshold) && ((RefCont < bin_threshold) || (RefCont == LowStatLevel))) {
139 ++StillDead_count;
140 } else if ((content >= bin_threshold) && (RefCont < bin_threshold)) {
141 ++Revived_count;
142 }
143 } else {
144 if (((content < bin_threshold) ) ) {
145 ++NewDead_count;
146 Tubes.push_back(i);
147 }
148 }
149 }
150 }
151 ERS_DEBUG(1,"Number of bins " << name << " different from a treshold of " << bin_threshold << " is " << NewDead_count );
152
153 dqm_core::Result* result = new dqm_core::Result();
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_";
160 ToDB += std::to_string(k+1);
161 result->tags_[ToDB] = Tubes[k];
162 ERS_DEBUG(1,"MDT Tube which changed status: "<<ToDB<<" = "<<Tubes[k] );
163 }
164 }
165 if (NewDead_count >= redTh) {
166 result->status_ = dqm_core::Result::Red;
167 ERS_DEBUG(1,"Red");
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) {
172 result->status_ = dqm_core::Result::Undefined;
173 ERS_DEBUG(1,"Undefined");
174 } else if (StillDead_count == range[1]) {
175 //All tubes are still dead
176 result->status_ = dqm_core::Result::Undefined;
177 } else {
178 result->status_ = dqm_core::Result::Green;
179 ERS_DEBUG(1,"Green");
180 }
181 return result;
182}
std::string histogram
Definition chains.cxx:52
std::vector< int > GetBinRange(const TH1 *histogram, const std::map< std::string, double > &params)
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)
str content
Definition grepfile.py:56
#define IsA
Declare the TObject style functions.

◆ printDescription()

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

Definition at line 186 of file MDTTubeCheck.cxx.

187{
188 std::string message;
189 message += "\n";
190 message += "Algorithm: \"" + m_name + "\"\n";
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";
199 message += "\n";
200
201 out << message;
202}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::MDTTubeCheck::m_name
private

Definition at line 33 of file MDTTubeCheck.h.


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