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

#include <MDTADCSpectrum.h>

Inheritance diagram for dqm_algorithms::MDTADCSpectrum:
Collaboration diagram for dqm_algorithms::MDTADCSpectrum:

Public Member Functions

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

Private Attributes

std::string m_name

Detailed Description

Definition at line 17 of file MDTADCSpectrum.h.

Constructor & Destructor Documentation

◆ MDTADCSpectrum()

dqm_algorithms::MDTADCSpectrum::MDTADCSpectrum ( )

Definition at line 37 of file MDTADCSpectrum.cxx.

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

◆ ~MDTADCSpectrum()

dqm_algorithms::MDTADCSpectrum::~MDTADCSpectrum ( )
virtual

Definition at line 44 of file MDTADCSpectrum.cxx.

45{
46}

Member Function Documentation

◆ clone()

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

Definition at line 50 of file MDTADCSpectrum.cxx.

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

◆ execute()

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

Definition at line 57 of file MDTADCSpectrum.cxx.

58{
59 const TH1 * hist;
60 const TH1 * ref;
61
62 if( object.IsA()->InheritsFrom( "TH1" ) ) {
63 hist = static_cast<const TH1*>(&object);
64 if (hist->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 thresh;
74 double greenTh;
75 double redTh;
76 try {
77 thresh = dqm_algorithms::tools::GetFirstFromMap( "thresh", config.getParameters(), 50);
78 minstat = dqm_algorithms::tools::GetFirstFromMap("MinStat", config.getParameters(), 0);
79 redTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getRedThresholds());
80 greenTh = dqm_algorithms::tools::GetFromMap( "Limits", config.getGreenThresholds() );
81 }
82 catch ( dqm_core::Exception & ex ) {
83 throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
84 }
85
86 //Get Reference Histo
87
88 try {
89 ref = static_cast<const TH1*>( config.getReference() );
90 }
91 catch ( dqm_core::Exception & ex ) {
92 throw dqm_core::BadRefHist(ERS_HERE,name," Could not retreive reference");
93 }
94 if (hist->GetDimension() != ref->GetDimension() ) {
95 throw dqm_core::BadRefHist( ERS_HERE, name, "Reference VS histo: Different dimension!" );
96 }
97
98 //Check of statistics
99 if (hist->GetEntries() < minstat ) {
100 ERS_INFO("Histogram does not satisfy MinStat requirement " <<hist->GetName());
101 dqm_core::Result *result = new dqm_core::Result(dqm_core::Result::Undefined);
102 result->tags_["InsufficientEntries"] = hist->GetEntries();
103 return result;
104 }
105 ERS_DEBUG(1,"Statistics: "<< hist->GetEntries()<< " entries ");
106
107 //Algo
108
109 Double_t n_min_50=0;
110 Double_t n_min_50_ref=0;
111
112 Double_t N = hist->GetEntries();
113 Double_t N_ref = ref ->GetEntries();
114
115 int i=0;
116
117 do{
118 i++;
119 n_min_50 += hist->GetBinContent(i);
120 if(i>hist->GetNbinsX()){
121 ERS_INFO("bin limit!"<<i);
122 dqm_core::Result* result = new dqm_core::Result();
123 result->status_ = dqm_core::Result::Undefined;
124 return result;
125 };
126 }while(hist->GetBinCenter(i)<thresh);
127
128 i=0;
129
130 do{
131 i++;
132 n_min_50_ref += ref->GetBinContent(i);
133 if(i>ref->GetNbinsX()){
134 ERS_INFO("bin limit!"<<i);
135 dqm_core::Result* result = new dqm_core::Result();
136 result->status_ = dqm_core::Result::Undefined;
137 return result;
138 };
139 }while(ref->GetBinCenter(i)<thresh);
140
141 Double_t f = -1;
142 Double_t f_r= 1;
143 Double_t sigma_hist = -1;
144 Double_t sigma_ref = -1;
145 Double_t sigma = -1;
146 Double_t F = -1;
147
148
149 if(N == 0 && N_ref == 0) {
150 ERS_INFO("null N entries found");
151 dqm_core::Result* result = new dqm_core::Result();
152 result->tags_["ERROR_null_entries_found"] = -999.;
153 result->status_ = dqm_core::Result::Undefined;
154 return result;
155 };
156
157 if(N !=0 && N_ref !=0){
158 f = n_min_50/N;
159 f_r = n_min_50_ref/N_ref;
160
161 if(f*f_r == 0 || (1-f)<0 || (1-f_r)<0 ){
162 ERS_DEBUG(1,"*) f = "<<f<<" f_r = "<<f_r);
163 dqm_core::Result* result = new dqm_core::Result();
164 result->tags_["ERROR_problem_in_fraction_computation"] = -999.;
165 result->tags_["n_min_50/N"] = f;
166 result->tags_["n_min_50_ref/N_ref"] = f_r;
167 result->status_ = dqm_core::Result::Undefined;
168 return result;
169 };
170
171 //Bernulli distribution
172
173 sigma_hist= std::sqrt(f*(1-f)/N);
174 sigma_ref= std::sqrt(f_r*(1-f_r)/N_ref);
175
176 F=f/f_r;
177
178 sigma = F*std::sqrt((sigma_hist/f)*(sigma_hist/f)+(sigma_ref/f_r)*(sigma_ref/f_r));
179
180
181 };
182
183
184 //Result
185
186 dqm_core::Result* result = new dqm_core::Result();
187 result->tags_["00-Pedestal_fraction"] = f;
188 result->tags_["1-Pedestal_over_Ped_ref"] = (1-F);
189 result->tags_["sigma_1-Ped_over_Ped_ref"] = sigma;
190
191 if(f<= greenTh || (f>greenTh && f_r>greenTh)) {
192 result->status_ = dqm_core::Result::Green;
193 }
194 else if( f>redTh && f_r<greenTh ) {
195 result->tags_["Difference_against_Ref-Pedestal_fraction_Ref"] = f_r;
196 result->status_ = dqm_core::Result::Red;
197 }
198 else {
199 result->status_ = dqm_core::Result::Yellow;
200 }
201
202 // Return the result
203 return result;
204}
const boost::regex ref(r_ef)
#define F(x, y, z)
Definition MD5.cxx:112
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::MDTADCSpectrum::printDescription ( std::ostream & out)
virtual

Definition at line 208 of file MDTADCSpectrum.cxx.

208 {
209 std::string message;
210 message += "\n";
211 message += "Algorithm: \"" + m_name + "\"\n";
212 message += "Description: Checks if the ratio of hits under treshold is below the limits\n";
213 message += " Comparison with reference is performed \n";
214 message += "Mandatory Parameters: Green/Red Threshold: Limits: warning: ratio limits \n";
215 message += " error\n";
216 message += "Optional Parameters: MinStat = Minimum histogram statistics needed to perform Algorithm\n";
217 message += " thresh = ADC cut on pedestal N counts (def 50)\n";
218 message += "\n";
219
220 out << message;
221}

Member Data Documentation

◆ m_name

std::string dqm_algorithms::MDTADCSpectrum::m_name
private

Definition at line 29 of file MDTADCSpectrum.h.


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