ATLAS Offline Software
CSCNoisyDead.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
9 #include <dqm_core/AlgorithmConfig.h>
12 #include <TH2.h>
13 #include <TF1.h>
14 #include <TClass.h>
15 #include <ers/ers.h>
16 
17 #include <dqm_core/AlgorithmManager.h>
18 static dqm_algorithms::CSCNoisyDead myInstance;
19 
20 
22 {
23  dqm_core::AlgorithmManager::instance().registerAlgorithm( "CSCNoisyDead", this );
24 }
25 
27 {
28 }
29 
32 {
33  return new CSCNoisyDead();
34 }
35 
36 
39  const TObject & object,
40  const dqm_core::AlgorithmConfig & config )
41 {
42  const TH2 * histogram;
43 
44  if(object.IsA()->InheritsFrom( "TH2" )) {
45  histogram = static_cast<const TH2*>(&object);
46  if (histogram->GetDimension() != 2 ){
47  throw dqm_core::BadConfig( ERS_HERE, name, "dimension != 2 " );
48  }
49  } else {
50  throw dqm_core::BadConfig( ERS_HERE, name, "does not inherit from TH2");
51  }
52 
53  double high = dqm_algorithms::tools::GetFirstFromMap( "HighRange", config.getParameters(), 0.2);
54  double low = dqm_algorithms::tools::GetFirstFromMap( "LowRange", config.getParameters(), 0.2);
55 
56  int gthreshold;
57  int rthreshold;
58  try {
59  rthreshold = dqm_algorithms::tools::GetFromMap( "NStrips", config.getRedThresholds() );
60  gthreshold = dqm_algorithms::tools::GetFromMap( "NStrips", config.getGreenThresholds() );
61  }
62  catch( dqm_core::Exception & ex ) {
63  throw dqm_core::BadConfig( ERS_HERE, name, ex.what(), ex );
64  }
65 
66  double phi_s_sum, phi_l_sum, eta_s_sum, eta_l_sum;
67 
68  double phi_s_avg[48], phi_l_avg[48], eta_s_avg[192], eta_l_avg[192];
69 
70  int NphiDead = 0;
71  int NphiNoisy = 0;
72  int NetaDead = 0;
73  int NetaNoisy = 0;
74  int NBad=0;
75 
76  for (int i = 0; i < 48; i++) {
77  phi_s_avg[i] = 0;
78  phi_l_avg[i] = 0;
79  }
80 
81  for (int i = 0; i < 192; i++) {
82  eta_s_avg[i] = 0;
83  eta_l_avg[i] = 0;
84  }
85 
86  // Average over Phi strips
87  for(size_t x = 0; x < 48; x++) {
88  int xbin = histogram->GetXaxis()->FindBin(x-48);
89  phi_s_sum = 0;
90  phi_l_sum = 0;
91  if (histogram->GetNbinsY() >= 85){
92  for(size_t y = 6; y < 86; y++) {
93  if( y%5 != 0 ) {
94 
95  // int lay = y%5;
96 
97  double content = histogram->GetBinContent(xbin,y);
98 
99  if(y%10 > 5) {
100  phi_l_sum += content;
101  }else {
102  phi_s_sum += content;
103  }
104  }
105  }
106  }
107  phi_s_avg[x] = (phi_s_sum/32.0);
108  phi_l_avg[x] = (phi_l_sum/32.0);
109  } // End phi strips average
110 
111  // Average over Eta strips
112  for(size_t x = 0; x < 192; x++) {
113  int xbin = histogram->GetXaxis()->FindBin(x+1);
114  eta_s_sum = 0;
115  eta_l_sum = 0;
116  for(size_t y = 6; y < 86; y++) {
117  if( y%5 != 0 ) {
118 
119  // int lay = y%5;
120 
121  double content = histogram->GetBinContent(xbin,y);
122 
123  if(y%10 > 5) {
124  eta_l_sum += content;
125  }else {
126  eta_s_sum += content;
127  }
128  }
129  }
130  eta_s_avg[x] = (eta_s_sum/32.0);
131  eta_l_avg[x] = (eta_l_sum/32.0);
132  } // End eta strips average
133 
134  // Compare Phi strips to average
135  for(size_t x = 0; x < 48; x++) {
136  int xbin = histogram->GetXaxis()->FindBin(int(x)-48);
137  phi_s_sum = 0;
138  phi_l_sum = 0;
139  for(size_t y = 6; y < 86; y++) {
140  if( y%5 != 0 ) {
141 
142  // int lay = y%5;
143 
144  double content = histogram->GetBinContent(xbin,y);
145 
146  if(y%10 > 5) {
147  if(content > (1+high)*phi_l_avg[x]){
148  NphiNoisy++;
149  }else if(content < (1-low)*phi_l_avg[x]){
150  NphiDead++;
151  }
152  }else {
153  if(content > (1+high)*phi_s_avg[x]){
154  NphiNoisy++;
155  }else if(content < (1-low)*phi_s_avg[x]){
156  NphiDead++;
157  }
158  }
159  }
160  }
161  } // End phi strips comparison
162 
163  // Compare Eta strips to average
164  for(size_t x = 0; x < 192; x++) {
165  int xbin = histogram->GetXaxis()->FindBin(x+1);
166  eta_s_sum = 0;
167  eta_l_sum = 0;
168  for(size_t y = 6; y < 86; y++) {
169  if( y%5 != 0 ) {
170 
171  // int lay = y%5;
172 
173  double content = histogram->GetBinContent(xbin,y);
174 
175  if(y%10 > 5) {
176  if(content > (1+high)*eta_l_avg[x]){
177  NetaNoisy++;
178  }else if(content < (1-low)*eta_l_avg[x]){
179  NetaDead++;
180  }
181  }else {
182  if(content > (1+high)*eta_s_avg[x]){
183  NetaNoisy++;
184  }else if(content < (1-low)*eta_s_avg[x]){
185  NetaDead++;
186  }
187  }
188  }
189  }
190  } // End phi strips comparison
191 
193  NBad = NphiNoisy + NphiDead + NetaNoisy + NetaDead;
194  result->tags_.insert(std::make_pair("NBad",NBad));
195  result->tags_.insert(std::make_pair("NphiNoisy",NphiNoisy));
196  result->tags_.insert(std::make_pair("NphiDead",NphiDead));
197  result->tags_.insert(std::make_pair("NetaNoisy",NetaNoisy));
198  result->tags_.insert(std::make_pair("NetaDead",NetaDead));
199 
200  if (NBad >= rthreshold){
201  result->status_ = dqm_core::Result::Red;
202  }else if (NBad < gthreshold){
203  result->status_ = dqm_core::Result::Green;
204  }else{
205  result->status_ = dqm_core::Result::Yellow;
206  }
207 
208  return result;
209 
210 /*
211 
212  dqm_core::Result* result = new dqm_core::Result();
213  int max = 1;
214  if(testrows){ max += histogram->GetNbinsY(); } else { max += histogram->GetNbinsX(); }
215  std::vector<float> rowtotal;
216  rowtotal.clear();
217  for(int i =0; i<max; ++i){ rowtotal.push_back(0.0); }
218 
219  if(checkstrip==0 && redcount >= yellowcount && redcount !=0 ){
220  result->tags_["RedBins"] = redcount;
221  result->status_ = dqm_core::Result::Red;
222  return result;
223  }
224  if(checkstrip==0 && yellowcount !=0 ){
225  result->tags_["YellowBins"] = yellowcount;
226  result->status_ = dqm_core::Result::Yellow;
227  return result;
228  }
229 
230  if(checkstrip && dorate && redrows >= yellowrows && redrows !=0 ){
231  result->tags_["RedRows"] = redrows;
232  result->status_ = dqm_core::Result::Red;
233  return result;
234  }
235  if(checkstrip && dorate && yellowrows !=0 ){
236  result->tags_["YellowRows"] = yellowrows;
237  result->status_ = dqm_core::Result::Yellow;
238  return result;
239  }
240 
241 
242  result->status_ = dqm_core::Result::Green;
243  return result;
244 */
245 }
246 
247 void
249 {
250 
251  out<<"CSCNoisyDead: Checks to see how many CSC layers are dead or noisy"<<std::endl;
252 
253  out<<"Mandatory Parameter: HighRange : Fraction above average considered noisy"<<std::endl;
254  out<<"Mandatory Parameter: LowRange : Fraction below average considered dead"<<std::endl;
255 
256  out<<"Mandatory Green/Red Threshold : NStrips : "<<std::endl;
257 
258 }
259 
get_generator_info.result
result
Definition: get_generator_info.py:21
IsA
#define IsA
Declare the TObject style functions.
Definition: xAODTEventBranch.h:59
dqm_algorithms::CSCNoisyDead::execute
dqm_core::Result * execute(const std::string &, const TObject &, const dqm_core::AlgorithmConfig &)
Definition: CSCNoisyDead.cxx:38
dqm_algorithms::CSCNoisyDead::~CSCNoisyDead
~CSCNoisyDead()
Definition: CSCNoisyDead.cxx:26
dqm_algorithms::CSCNoisyDead::clone
CSCNoisyDead * clone()
Definition: CSCNoisyDead.cxx:31
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
dqm_algorithms::CSCNoisyDead
Definition: CSCNoisyDead.h:19
x
#define x
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
grepfile.content
string content
Definition: grepfile.py:56
lumiFormat.i
int i
Definition: lumiFormat.py:92
Result
ICscStripFitter::Result Result
Definition: CalibCscStripFitter.cxx:13
python.handimod.Green
int Green
Definition: handimod.py:524
TH2
Definition: rootspy.cxx:373
python.handimod.Red
Red
Definition: handimod.py:551
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
dqm_algorithms::CSCNoisyDead::printDescription
void printDescription(std::ostream &out)
Definition: CSCNoisyDead.cxx:248
dqm_algorithms::CSCNoisyDead::CSCNoisyDead
CSCNoisyDead()
Definition: CSCNoisyDead.cxx:21
y
#define y
AlgorithmHelper.h
dqm_algorithms::tools::GetFromMap
const T & GetFromMap(const std::string &pname, const std::map< std::string, T > &params)
Definition: AlgorithmHelper.h:114
pickleTool.object
object
Definition: pickleTool.py:30
CSCNoisyDead.h
dqm_algorithms::tools::GetFirstFromMap
double GetFirstFromMap(const std::string &paramName, const std::map< std::string, double > &params)
Definition: AlgorithmHelper.cxx:339
histogram
std::string histogram
Definition: chains.cxx:52