ATLAS Offline Software
Loading...
Searching...
No Matches
CscCalibMonToolPed.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cassert>
8#include <sstream>
9#include <iomanip>
10#include <fstream>
11
14
15
16CscCalibMonToolPed::CscCalibMonToolPed(const std::string & type, const std::string & name,
17 const IInterface* parent) :
18 CscCalibMonToolBase(type, name, parent),
20 m_pedBadBin(1),
22 m_rmsBadBin(3),
23 m_f001BadBin(4),
25 m_chi2BadBin(6),
28 m_h_numBad(nullptr),
29 m_pedNewColl(nullptr),
30 m_pedOldColl(nullptr),
31 m_pedDiffColl(nullptr),
32 m_noiseNewColl(nullptr),
33 m_noiseOldColl(nullptr),
34 m_noiseDiffColl(nullptr),
35 m_chi2Coll(nullptr),
36 m_rmsNewColl(nullptr),
37 m_rmsOldColl(nullptr),
38 m_rmsDiffColl(nullptr),
39 m_f001NewColl(nullptr),
40 m_f001OldColl(nullptr),
41 m_f001DiffColl(nullptr),
42 m_onlTHoldBreachColl(nullptr),
43 m_nEntriesColl(nullptr),
44 m_tholdDiffColl(nullptr),
45 m_maxBitCorrColl(nullptr),
46 m_h2_rmsVnoiseEta(nullptr),
47 m_h2_rmsVnoisePhi(nullptr)
48{
49 declareProperty("MaxPedDiff",m_pedMaxDiff=2.0);
50 declareProperty("MaxNoiseDiff",m_noiseMaxDiff = 5.0);
51 declareProperty("MaxChi2_NDF",m_chi2Max = 800);
52 declareProperty("MaxRMSDiff",m_rmsMaxDiff = 5);
53 declareProperty("MaxF001Diff", m_f001MaxDiff = 5);
54 declareProperty("MaxOnlTHoldBreachesPerChannel", m_onlTHoldBreachMax = 400);
55 declareProperty("PedAmpHistKey", m_histKey = "cscPedCalibReport");
56 declareProperty("DoRmsVNoise", m_doRmsVNoise = false);
57 declareProperty("MinAmpHistEntries", m_minAmpHistEntries = 4000);
58 declareProperty("AlwaysPrintErrorReport",m_allGoodFileName = "AllCalibMonGood");
59 declareProperty("StatusReportFileName", m_statusReportName = "PedReport.txt");
60 declareProperty("StatusReportPrefix", m_statusReportPrefix = "");
61
62 declareProperty("DoBitCorrelations", m_doBitCorrelations = false);
63
64
65 //Although this can be declared in the base class, we give a default here
66 if(m_calibResultKey == "")
67 m_calibResultKey = "CscCalibResultPed"; //Determines what CscCalibMonToolBase will pull out of TDS
68
69
70
71 /*##From CscCalibMonToolBase.cxx, for reference.
72 declareProperty("MakeHashValueHist",m_makeHashHist=true);
73 declareProperty("MakeLayerValueHists",m_makeLayerHists=false);
74 declareProperty("DetailedResultHashIds",m_detailedHashIds);
75 */
76
77}
78
80{
82
83 m_generic_path_csccalibmonitoring = "MUON_CSC_PED";
84
85 return sc;
86}
87
88
90{
91 delete m_pedNewColl;
92 delete m_pedOldColl;
93 delete m_pedDiffColl;
94 delete m_noiseNewColl;
95 delete m_noiseOldColl;
96 delete m_noiseDiffColl;
97 delete m_rmsNewColl;
98 delete m_rmsOldColl;
99 delete m_rmsDiffColl;
100 delete m_f001NewColl;
101 delete m_f001OldColl;
102 delete m_f001DiffColl;
103 delete m_chi2Coll;
104
106}
107
109{
110 if (!CscCalibMonToolBase::bookHistograms().isSuccess())
111 {
112 ATH_MSG_WARNING( "CscCalibMonToolPed : in bookHistograms()" );
113 }
114 ATH_MSG_DEBUG( "CscCalibMonToolPed : in bookHistograms()" );
115
116 //declare a group of histograms
117
118 if (newRunFlag())
119 {
121
122 std::string geoPath = getGeoPath();
123 std::string path = getFullPath(geoPath, "Misc", "");
124 MonGroup monGroup( this, path, run, ATTRIB_MANAGED );
125
126 std::string name,title,xaxis,yaxis;
127 int highbound,lowbound,nbins;
128
129 //num bad histograms
130 name = "h_csc_calib_numSignificant";
131 title = "Number of significant results.";
132 xaxis = "Catagory";
133 yaxis = "Num channels with bad value.";
134 lowbound = 1;
135 highbound = 8;
136 m_h_numBad = new TH1I(name.c_str(),title.c_str(),highbound-lowbound+1,lowbound,highbound+1);
137 m_h_numBad->GetYaxis()->SetTitle(yaxis.c_str());
138 m_h_numBad->GetXaxis()->SetTitle(xaxis.c_str());
139 std::stringstream pedBinTitle; pedBinTitle << "#Delta ped > " << m_pedMaxDiff;
140 m_h_numBad->GetXaxis()->SetBinLabel(m_pedBadBin, pedBinTitle.str().c_str());
141 std::stringstream noiseBinTitle; noiseBinTitle << "#Delta noise > "<< m_noiseMaxDiff;
142 m_h_numBad->GetXaxis()->SetBinLabel(m_noiseBadBin, noiseBinTitle.str().c_str());
143 std::stringstream rmsBinTitle; rmsBinTitle << "#Delta RMS > " << m_rmsMaxDiff;
144 m_h_numBad->GetXaxis()->SetBinLabel(m_rmsBadBin, rmsBinTitle.str().c_str());
145 std::stringstream f001BinTitle; f001BinTitle << "#Delta F001 > " << m_f001MaxDiff;
146 m_h_numBad->GetXaxis()->SetBinLabel(m_f001BadBin, f001BinTitle.str().c_str());
147 std::stringstream statisticsBinTitle; statisticsBinTitle << "N Entries < " << m_minAmpHistEntries;
148 m_h_numBad->GetXaxis()->SetBinLabel(m_nEntriesBadBin, statisticsBinTitle.str().c_str());
149 std::stringstream chiBinTitle; chiBinTitle << "#frac{#chi^{2}}{ndf} > " << m_chi2Max;
150 m_h_numBad->GetXaxis()->SetBinLabel(m_chi2BadBin,chiBinTitle.str().c_str());
151 m_h_numBad->GetXaxis()->SetBinLabel(m_missingBadBin,"Missing channels ");
152 m_h_numBad->GetXaxis()->SetBinLabel(m_onlTHoldBreachBadBin, "Onl THold Breaches");
153 m_h_numBad->SetFillColor(m_histColAlert);
154 monGroup.regHist(m_h_numBad).ignore();
155
156
157 name = "h_csc_calib_pedMissingChannels";
158 title = "Channels Missing Data From Pedestal Run.";
159 xaxis = "Channel (Hash ID)";
160 yaxis = "Number of Parameter Types Missing";
161 lowbound = 0;
162 highbound = m_maxHashId +1;
163 nbins = m_maxHashId +1;
164 m_h_pedMissingChannels = new TH1F(name.c_str(), title.c_str(), nbins,lowbound,highbound);
165 m_h_pedMissingChannels->GetXaxis()->SetTitle(xaxis.c_str());
166 m_h_pedMissingChannels->GetYaxis()->SetTitle(yaxis.c_str());
168 monGroup.regHist(m_h_pedMissingChannels).ignore();
169
170 //Set naming parameters for datatypes
171 std::string pedDataName = "ped";
172 std::string pedDataTitle = "Pedestals";
173 std::string pedSubDir = "Ped";
174
175 std::string noiseDataName = "noise";
176 std::string noiseDataTitle = "Noise (ped sigma)";
177 std::string noiseSubDir = "Noise";
178
179 std::string chi2DataName = "chi2";
180 std::string chi2DataTitle = "Chi^2/ndf for Pedestal Gaussian Fit";
181 std::string chi2SubDir = "Chi2";
182
183 std::string rmsDataName = "rms";
184 std::string rmsDataTitle = "RMS from gaussian distribution";
185 std::string rmsSubDir = "RMS";
186
187 std::string f001DataName = "f001";
188 std::string f001DataTitle = "F001";
189 std::string f001SubDir = "F001";
190
191 std::string onlTHoldBreachDataName = "onlTHoldBreach";
192 std::string onlTHoldBreachDataTitle = "Online Threshold Breaches";
193 std::string onlTHoldBreachSubDir = "OnlTHoldBreaches";
194
195 std::string nEntriesDataName = "nEntries";
196 std::string nEntriesDataTitle = "Number of Entries from Pedestal Amplitude Hist";
197 std::string nEntriesSubDir = "NumEntries";
198
199 std::string maxBitCorrDataName = "maxBitCorr";
200 std::string maxBitCorrDataTitle = "Maximimum Bit Correlation";
201 std::string maxBitCorrSubDir = "MaxBitCorr";
202
203
204 //Set naming parameters for histogram category names
205 std::string newCatName = "new";
206 std::string newCatTitle = "New";
207
208 std::string oldCatName = "old";
209 std::string oldCatTitle = "COOL";
210
211 std::string diffCatName = "diff";
212 std::string diffCatTitle = "Change of ";
213
214 //axis info
215 std::string pedAxisLabel = "Pedestal Mean (ADC counts)";
216 std::string pedDiffAxisLabel = "Pedestal Difference (ADC counts)";
217 int pedNumBins =300;
218 float pedLowBound = 1900;
219 float pedHighBound = 2200;
220
221 std::string noiseAxisLabel = "Pedestal Noise (ADC counts)";
222 std::string noiseDiffAxisLabel = "Noise Difference (ADC counts)";
223 int noiseNumBins = 300;
224 float noiseLowBound = 0;
225 float noiseHighBound = 30;
226
227 std::string chi2AxisLabel = "Chi^2/ndf";
228 int chi2NumBins = 500;
229 float chi2LowBound = 0;
230 float chi2HighBound = 500;
231
232 std::string rmsAxisLabel = "RMS (ADC Counts)";
233 std::string rmsDiffAxisLabel = "RMS Difference (ADC Counts)";
234 int rmsNumBins = 300;
235 float rmsLowBound =0;
236 float rmsHighBound = 30;
237
238 std::string f001AxisLabel = "F001 (ADC)";
239 std::string f001DiffAxisLabel = "F001 Difference (ADC)";
240 int f001NumBins = 350;
241 float f001LowBound =1950;
242 float f001HighBound = 2300;
243
244 std::string nEntriesAxisLabel = "Number of Entries";
245 int nEntriesNumBins = 20;
246 float nEntriesLowBound = 0;
247 float nEntriesHighBound = 10000;
248 uint16_t nEntriesHistMask = 0x3F; //only do overall spectra and 2d view
249
250 std::string maxBitCorrAxisLabel = "Correlation";
251 int maxBitCorrNumBins = 300;
252 float maxBitCorrLowBound = -3;
253 float maxBitCorrHighBound = 3;
254 //Subdirectory this will be stored in:
255
256 //Initialize histogram collections
257 //Each colleciton contains all of the "views" for one particular set of data
258 m_pedNewColl = new HistCollection(m_maxHashId +1, m_maxHashId +1); //New Pedestals
259 m_pedOldColl = new HistCollection(m_maxHashId +1); //Last pedestals
260 m_pedDiffColl = new HistCollection(m_maxHashId +1); //Difference
261
265
267
271
275
277
279
280
282
285
286
287 //initialize, name, and book histograms in histogram collections:
288
289 ATH_MSG_DEBUG( "Registering pedNewColl" );
290 ATH_CHECK( bookHistCollection(m_pedNewColl, pedDataName, pedDataTitle, newCatName, newCatTitle,
291 pedAxisLabel, pedNumBins, pedLowBound, pedHighBound, pedSubDir) );
292
293 ATH_MSG_DEBUG( "Registering pedOldColl" );
294 ATH_CHECK( bookHistCollection(m_pedOldColl, pedDataName, pedDataTitle, oldCatName, oldCatTitle,
295 pedAxisLabel, pedNumBins, pedLowBound, pedHighBound, pedSubDir) );
296
297 ATH_MSG_DEBUG( "Registering pedDiffColl" );
298 ATH_CHECK( bookHistCollection(m_pedDiffColl, pedDataName, pedDataTitle, diffCatName, diffCatTitle,
299 pedDiffAxisLabel, 100, -2, 2, pedSubDir) );
300
301 ATH_MSG_DEBUG( "Registering noiseNewColl" );
302 ATH_CHECK( bookHistCollection(m_noiseNewColl, noiseDataName, noiseDataTitle, newCatName,
303 newCatTitle, noiseAxisLabel, noiseNumBins, noiseLowBound, noiseHighBound, noiseSubDir) );
304
305 ATH_MSG_DEBUG( "Registering noiseOldColl" );
306 ATH_CHECK( bookHistCollection(m_noiseOldColl, noiseDataName, noiseDataTitle, oldCatName,
307 oldCatTitle, noiseAxisLabel, 100, -2, 2, noiseSubDir) );
308
309 ATH_MSG_DEBUG( "Registering noiseDiffColl" );
310 ATH_CHECK( bookHistCollection(m_noiseDiffColl, noiseDataName, noiseDataTitle, diffCatName,
311 diffCatTitle, noiseDiffAxisLabel, noiseNumBins, -1*noiseHighBound, noiseHighBound,noiseSubDir) );
312
313 ATH_MSG_DEBUG( "Registering rmsNewColl" );
314 ATH_CHECK( bookHistCollection(m_rmsNewColl, rmsDataName, rmsDataTitle, newCatName,
315 newCatTitle, rmsAxisLabel, rmsNumBins, rmsLowBound, rmsHighBound, rmsSubDir) );
316
317 ATH_MSG_DEBUG( "Registering rmsOldColl" );
318 ATH_CHECK( bookHistCollection(m_rmsOldColl, rmsDataName, rmsDataTitle, oldCatName,
319 oldCatTitle, rmsAxisLabel, rmsNumBins, rmsLowBound, rmsHighBound, rmsSubDir) );
320
321 ATH_MSG_DEBUG( "Registering rmsDiffColl" );
322 ATH_CHECK( bookHistCollection(m_rmsDiffColl, rmsDataName, rmsDataTitle, diffCatName,
323 diffCatTitle, rmsDiffAxisLabel, rmsNumBins, -1*rmsHighBound, rmsHighBound,rmsSubDir) );
324
325 ATH_MSG_DEBUG( "Registering f001NewColl" );
326 ATH_CHECK( bookHistCollection(m_f001NewColl, f001DataName, f001DataTitle, newCatName,
327 newCatTitle, f001AxisLabel, f001NumBins, f001LowBound, f001HighBound, f001SubDir) );
328
329 ATH_MSG_DEBUG( "Registering f001OldColl" );
330 ATH_CHECK( bookHistCollection(m_f001OldColl, f001DataName, f001DataTitle, oldCatName,
331 oldCatTitle, f001AxisLabel, 100, -2, 2, f001SubDir) );
332
333 ATH_MSG_DEBUG( "Registering f001DiffColl" );
334 ATH_CHECK( bookHistCollection(m_f001DiffColl, f001DataName, f001DataTitle, diffCatName,
335 diffCatTitle, f001DiffAxisLabel, 60, -30, 30, f001SubDir) );
336
337 ATH_MSG_DEBUG( "Registering onlTHoldBreachColl" );
338 ATH_CHECK( bookHistCollection(m_onlTHoldBreachColl, onlTHoldBreachDataName, onlTHoldBreachDataTitle, "",
339 "" , "Number of Online THold Breachs", 100, 0, 1000, onlTHoldBreachSubDir) );
340
341 ATH_MSG_DEBUG( "Registering Num Entries" );
342 ATH_CHECK( bookHistCollection(m_nEntriesColl, nEntriesDataName, nEntriesDataTitle, "",
343 "", nEntriesAxisLabel, nEntriesNumBins, nEntriesLowBound, nEntriesHighBound, nEntriesSubDir, nEntriesHistMask) );
344
345 ATH_CHECK( bookHistCollection(m_chi2Coll, chi2DataName, chi2DataTitle, "", "",
346 chi2AxisLabel, chi2NumBins, chi2LowBound, chi2HighBound, chi2SubDir) );
347
348 ATH_CHECK( bookHistCollection(m_tholdDiffColl, "thold", "Threshold", diffCatName, diffCatTitle, "#Delta{}Threshold", 500, -10, 10, "THold") );
349
351 ATH_CHECK( bookHistCollection(m_maxBitCorrColl, maxBitCorrDataName, maxBitCorrDataTitle,
352 "", "", maxBitCorrAxisLabel, maxBitCorrNumBins, maxBitCorrLowBound,
353 maxBitCorrHighBound, maxBitCorrSubDir) );
354 }
355 }//end if newRun
356
357 return StatusCode::SUCCESS;
358}//end bookHistograms
359
360
361//--handleParameter: Processes a vector of parameter values by filling the appropriate histograms
363{
364 ATH_MSG_DEBUG( "CscCalibMonToolPed : in procParameter()" );
365
366 //The whole point of this funciton is to pass the correct histograms and setup info
367 //to CsccalibMonToolBase::procParameter. To organize this, we store the setup info into
368 //these structs:
369 ProcSetupInfo ProcParameterInput;
370
371
372 //--setup for this parameter
373 //We will specify :
374 //name of database parameter if we want to compare with datbase value
375 //otherwise we provide expeted value to compare with
376 //we also provide handles to all the arrays and values procParameter uses, such as the list
377 //of expected hash ids.
378 if(!parVals)
379 {
380 ATH_MSG_FATAL("Blank parval passed to handle parameter");
381 return StatusCode::FAILURE;
382 }
383 std::string parName = parVals->parName();
384 if(parName == "ped")
385 {
386 ProcParameterInput.dbName = parVals->parName();
387 ProcParameterInput.badHist = m_h_numBad;
388 ProcParameterInput.badBin = m_pedBadBin;
389 ProcParameterInput.maxDiff = m_pedMaxDiff;
390 ProcParameterInput.chi2BadBin = m_chi2BadBin;
391 ProcParameterInput.chi2Max = m_chi2Max;
392 ProcParameterInput.doChi2 = true;
393 ProcParameterInput.vals = &(m_pedNewColl->data);
394 ProcParameterInput.errors = &(m_pedNewColl->errors);
395 ProcParameterInput.oldVals =& (m_pedOldColl->data);
396 ProcParameterInput.diffs = &(m_pedDiffColl->data);
397 ProcParameterInput.chi2s = &(m_chi2Coll->data);
398 ProcParameterInput.expectedChannels = m_expectedHashIdsAll;
399 }
400 else if (parName == "noise")
401 {
402 ProcParameterInput.dbName = parVals->parName();
403 ProcParameterInput.badHist = m_h_numBad;
404 ProcParameterInput.badBin = m_noiseBadBin;
405 ProcParameterInput.maxDiff = m_noiseMaxDiff;
406 ProcParameterInput.missingBadBin = m_missingBadBin;
407 ProcParameterInput.missingChans = m_h_pedMissingChannels;
408 ProcParameterInput.doChi2 = false;
409 ProcParameterInput.vals = &(m_noiseNewColl->data);
410 ProcParameterInput.errors = &(m_noiseNewColl->errors);
411 ProcParameterInput.oldVals = &(m_noiseOldColl->data);
412 ProcParameterInput.diffs = &(m_noiseDiffColl->data);
413 ProcParameterInput.expectedChannels = m_expectedHashIdsAll;
414 }
415 else if (parName == "rms")
416 {
417 ProcParameterInput.dbName = parVals->parName();
418 ProcParameterInput.badHist = m_h_numBad;
419 ProcParameterInput.badBin = m_rmsBadBin;
420 ProcParameterInput.maxDiff = m_rmsMaxDiff;
421 ProcParameterInput.missingBadBin = m_missingBadBin;
422 ProcParameterInput.missingChans = m_h_pedMissingChannels;
423 ProcParameterInput.doChi2 = false;
424 ProcParameterInput.vals = &(m_rmsNewColl->data);
425 ProcParameterInput.errors = &(m_rmsNewColl->errors);
426 ProcParameterInput.oldVals = &(m_rmsOldColl->data);
427 ProcParameterInput.diffs = &(m_rmsDiffColl->data);
428 ProcParameterInput.expectedChannels = m_expectedHashIdsAll;
429 }
430 else if (parName == "f001")
431 {
432 ProcParameterInput.dbName = parVals->parName();
433 ProcParameterInput.badHist = m_h_numBad;
434 ProcParameterInput.badBin = m_f001BadBin;
435 ProcParameterInput.maxDiff = m_f001MaxDiff;
436 ProcParameterInput.missingBadBin = m_missingBadBin;
437 ProcParameterInput.missingChans = m_h_pedMissingChannels;
438 ProcParameterInput.doChi2 = false;
439 ProcParameterInput.vals = &(m_f001NewColl->data);
440 ProcParameterInput.errors = &(m_f001NewColl->errors);
441 ProcParameterInput.oldVals = &(m_f001OldColl->data);
442 ProcParameterInput.diffs = &(m_f001DiffColl->data);
443 ProcParameterInput.expectedChannels = m_expectedHashIdsAll;
444 }
445 else if (parName == "OnlTHoldBreaches"){
446 //How many samples failed the online threshold test of f001 +2*RMS
447 //(f001 and RMS read from a file from online configuration db)
448 //ProcParameterInput.dbName = parVals->parName();
449 ProcParameterInput.badHist = m_h_numBad;
450 ProcParameterInput.badBin = m_onlTHoldBreachBadBin;
451 ProcParameterInput.expectedVal = 0; //expect 0 f001
452 ProcParameterInput.maxDiff = m_onlTHoldBreachMax;
453 ProcParameterInput.missingBadBin = m_missingBadBin;
454 ProcParameterInput.missingChans = m_h_pedMissingChannels;
455 ProcParameterInput.doChi2 = false;
456 ProcParameterInput.vals = &(m_onlTHoldBreachColl->data);
457 ProcParameterInput.errors = &(m_onlTHoldBreachColl->errors);
458 //ProcParameterInput.oldVals = &(m_onlTHoldBreachColl->data);
459 //ProcParameterInput.diffs = &(m_onlTHoldBreachColl->data);
460 ProcParameterInput.expectedChannels = m_expectedHashIdsAll;
461 }
462 else
463 {
464 ATH_MSG_INFO( "CscCalibMonToolPed : Did not recognize parameter name "
465 << parName << ". This is usually ok." );
466 return StatusCode::SUCCESS;
467 }
468
469 //Process data in parVals according to setting in ProcParameterInput. This includes:
470 // -Copying data from parVals to ProcParameterInput.vals (i.e. the HistCollection)
471 // -Checking for missing channels
472 // -Look for deviations from expected values for each channel
473 if(!procParameter(parVals,&ProcParameterInput).isSuccess())
474 {
475 ATH_MSG_FATAL( "CscCalibMonToolPed : Failed to process parameter "
476 << parName );
477 return StatusCode::FAILURE;
478 }
479
480 if(parName == "ped")
481 {
486 }
487 if(parName == "noise")
488 {
492 }
493 if(parName == "rms")
494 {
498 }
499 if(parName == "f001")
500 {
504 }
505 if(parName == "OnlTHoldBreaches"){
507 }
508 return StatusCode::SUCCESS;
509}
510
511void CscCalibMonToolPed::genThreshold(HistCollection * pedColl, HistCollection * noiseColl, HistCollection * tholdColl, float multiplier) {
512 for(unsigned int chanItr = 0 ; chanItr <= m_maxHashId; chanItr++) {
513 tholdColl->data[chanItr] = pedColl->data[chanItr] + multiplier*noiseColl->data[chanItr];
514 }
515}
516//--postProc() will retrieve the details for the channels
517//requested by the user in m_detailedHashIds.
519{
520 ATH_MSG_DEBUG( "CscCalibMonToolPed : in postProc()" );
521
522 IdContext chanContext = m_idHelperSvc->cscIdHelper().channel_context();
523
525
527
528 if(m_doRmsVNoise) {
529 std::string geoPath = getGeoPath();
530 std::string path = getFullPath(geoPath, "Misc", "");
531
532 m_h2_rmsVnoiseEta = new TH2I("rmsVsigma_eta", "RMS versus sigma for #eta strips", 100, 0, 30, 100, 0,30) ;
533 m_h2_rmsVnoiseEta->GetXaxis()->SetTitle("Sigma");
534 m_h2_rmsVnoiseEta->GetYaxis()->SetTitle("RMS");
536
537 m_h2_rmsVnoisePhi = new TH2I("rmsVsigma_phi", "RMS versus sigma for #phi strips", 100, 0, 30, 100, 0,30) ;
538 m_h2_rmsVnoisePhi->GetXaxis()->SetTitle("Sigma");
539 m_h2_rmsVnoisePhi->GetYaxis()->SetTitle("RMS");
541
542 std::vector<float> & rmsVec = m_rmsNewColl->data;
543 std::vector<float> & noiseVec = m_noiseNewColl->data;
544 size_t nEntries = rmsVec.size();
545 if(nEntries != noiseVec.size()){
546 ATH_MSG_ERROR( "Number of noises != number of rmses" );
547 return StatusCode::FAILURE;
548 }
549 ATH_MSG_DEBUG( "Filling rmsVnoise " );
550
551 for(unsigned int hashId = 0; hashId < nEntries; hashId++){
552 ATH_MSG_DEBUG( "Filling rmsVnoise for hash id " << hashId );
553 Identifier chanId;
554 m_idHelperSvc->cscIdHelper().get_id(IdentifierHash(hashId), chanId, &chanContext);
555 int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(chanId);
556
557 if(m_expectedHashIdsAll.count(hashId)) {
558 if(measuresPhi)
559 m_h2_rmsVnoisePhi->Fill(noiseVec[hashId], rmsVec[hashId]);
560 else
561 m_h2_rmsVnoiseEta->Fill(noiseVec[hashId], rmsVec[hashId]);
562 }
563 }
564 ATH_MSG_DEBUG( "filled rmsVnoise " );
565
566 }
567
569 {
570 //Retrieve calibration report container from transient data store
571 const CscCalibReportContainer* repCont = nullptr;
572 if (!evtStore()->retrieve(repCont, m_histKey).isSuccess())
573 {
574 ATH_MSG_WARNING( " Cannot retrieve object from storegate with key "
575 << m_histKey << " aborting retrieving hists " );
576 return StatusCode::RECOVERABLE;
577 }
578
579 if(repCont->size() != 1)
580 {
581 ATH_MSG_WARNING( "Container with key " << m_histKey
582 << " does not have a size of one. Do not know how to proceed, so aborting"
583 << " retrieving calibration histograms." );
584 return StatusCode::RECOVERABLE;
585 }
586
587 //Retrieve DataVector of amplitude histograms
588 const CscCalibReportPed * pedReport = dynamic_cast<const CscCalibReportPed *>(repCont->front());
589 if((not pedReport) or (pedReport->getLabel() != "pedAmps"))
590 {
591 ATH_MSG_WARNING( "Incorrect object retrieved from container."
592 << " Aborting hist retrieval." );
593 return StatusCode::RECOVERABLE;
594 }
595
596 const DataVector<TH1I> * pedAmpHists = pedReport->getPedAmpHists();
597 if(!pedAmpHists)
598 ATH_MSG_WARNING( "No pedAmpHists vector found from calibration. "
599 << " Won't be in monitoring output file" );
600
601 const DataVector<TH1I> * bitHists = pedReport->getBitHists();
602 if(!bitHists)
603 ATH_MSG_INFO( "No bit histogram vector found from calibration. "
604 << " Won't be in monitoring output file. " );
605
606 const DataVector<TH2F> * bitCorrelations = nullptr;
607
609 bitCorrelations = pedReport->getBitCorrelation();
610
611 const DataVector< DataVector<TH1I> >* sampHists = pedReport->getSampHists();
612
613 //These are the channels we will get detailed amplitude histograms for.
614 for(unsigned int idItr = 0; idItr <= m_maxHashId; idItr++)
615 {
616 if(m_expectedHashIdsAll.count(idItr))
617 {
618 ATH_MSG_VERBOSE( "Debug info for hash " << idItr
619 << " is being retrieved." );
620 TH1I * sourceHist;
621
622 Identifier chanId;
623 m_idHelperSvc->cscIdHelper().get_id(IdentifierHash(idItr), chanId, &chanContext);
624 int stationSize = m_idHelperSvc->cscIdHelper().stationName(chanId);
625 int stationEta = m_idHelperSvc->cscIdHelper().stationEta(chanId);
626 int stationPhi = m_idHelperSvc->cscIdHelper().stationPhi(chanId);
627 int wireLayer = m_idHelperSvc->cscIdHelper().wireLayer(chanId);
628 int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(chanId);
629 int strip = m_idHelperSvc->cscIdHelper().strip(chanId);
630 int sector = getSector(stationPhi, stationSize);
631
632 std::string geoPath = getGeoPath(stationEta, sector, wireLayer, measuresPhi);
633
634 std::string pedAmpPath = getFullPath(geoPath, "PedAmpHists", "");
635 std::string sampPath = getFullPath(geoPath, "SampHists","");
636 std::string bitHistPath = getFullPath(geoPath, "BitHists", "");
637 std::string bitCorrelationPath("");
638 if(bitCorrelations)
639 bitCorrelationPath = getFullPath(geoPath, "BitCorrelations", "");
640
641 ATH_MSG_DEBUG( "Hash Id: " << idItr << ". Booking channel histograms in paths : " << pedAmpPath << " and " << bitHistPath );
642 //MonGroup chanMonGroup( this, path , run, ATTRIB_MANAGED);
643
644 //Pedestal amplitude histograms
645 //copy source histogram into new histogram, and store
646 if(pedAmpHists)
647 {
648 sourceHist = const_cast<TH1I*>((*pedAmpHists)[idItr]);
649 if(!sourceHist)
650 {
651 ATH_MSG_ERROR( "There is no pedestal amplitude histogram with hashId "
652 << idItr );
653 return StatusCode::RECOVERABLE;
654 }
655
656 double nEntries = sourceHist->GetEntries();
657
658 if(idItr >= m_nEntriesColl->data.size() ){
659
660 ATH_MSG_ERROR( "idItr == " << idItr
661 << " but maximum m_nEntriesColl.data.size() == "
662 << m_nEntriesColl->data.size() );
663 return StatusCode::RECOVERABLE;
664 }
665 m_nEntriesColl->data[idItr] = nEntries;
666
667 if(nEntries < m_minAmpHistEntries){
668 m_detailedHashIds[idItr] = true;
670 }
671
673
674
675 std::stringstream name;
676 name << "h_pedAmp"
677 << "_EC" << getEndCap(stationEta)
678 << "_sector_" << sector
679 << "_layer_" << wireLayer
680 << "_" << (measuresPhi ? "trans" : "prec")
681 << "_strip_"
682 << std::setfill ('0') << std::setw (measuresPhi ? 2 : 3)
683 << strip;
684
685 //Calibration is finished with histogram, so we can modify it a bit:
686
687 sourceHist->SetName(name.str().c_str());
688 sourceHist->SetFillColor((m_detailedHashIds[idItr] ? m_histColAlert : m_histCol));
689 ATH_CHECK( regHist(sourceHist, pedAmpPath, run, ATTRIB_MANAGED) );
690 }
691 }
692
693 if(sampHists) {
694 const DataVector<TH1I> * histVect = (*sampHists)[idItr];
695
696 size_t hNum = histVect->size();
697 for(size_t hCnt = 0; hCnt < hNum; hCnt++) {
698 sourceHist = const_cast<TH1I*>((*histVect)[hCnt]);
699 std::stringstream name;
700 name << "h_samp"
701 << "_EC" << getEndCap(stationEta)
702 << "_sector_" << sector
703 << "_layer_" << wireLayer
704 << "_" << (measuresPhi ? "trans" : "prec")
705 << "_strip_"
706 << std::setfill ('0') << std::setw (measuresPhi ? 2 : 3)
707 << strip
708 <<"_samp_"
709 << hCnt;
710 sourceHist->SetName(name.str().c_str());
711 sourceHist->SetFillColor(m_histCol);
712 ATH_CHECK( regHist(sourceHist,sampPath,run, ATTRIB_MANAGED) );
713 }
714 }
715
716 //Bit map histograms
717 //copy source histogram into new histogram, and store
718 if(bitHists)
719 {
720 sourceHist = const_cast<TH1I*>((*bitHists)[idItr]);
721 if(!sourceHist)
722 {
723 ATH_MSG_ERROR( "There is no bit histogram with hashId "
724 << idItr << " Quiting out of detailed histogram loop." );
725 return StatusCode::RECOVERABLE;
726 }
727
728 std::stringstream name2;
729 name2 << "h_bitMap"
730 << "_EC" << getEndCap(stationEta)
731 << "_sector_" << sector
732 << "_layer_" << wireLayer
733 << "_" << (measuresPhi ? "trans" : "prec")
734 << "_strip_"
735 << std::setfill ('0') << std::setw (measuresPhi ? 2 : 3)
736 << strip;
737 sourceHist->SetName(name2.str().c_str());
738 sourceHist->SetFillColor((m_detailedHashIds[idItr] ? m_histColAlert : m_histCol));
739
740 ATH_CHECK( regHist(sourceHist, bitHistPath, run, ATTRIB_MANAGED) );
741 }//end if bithists*/
742
743 if(bitCorrelations)
744 {
745 TH2F* hist = const_cast<TH2F*>((*bitCorrelations)[idItr]);
746 ATH_CHECK( regHist(hist,bitCorrelationPath,run, ATTRIB_MANAGED) );
747
748 float maxVal = -2;
749 //Now find the maximum correlation
750 size_t nx = hist->GetXaxis()->GetNbins();
751 size_t ny = hist->GetYaxis()->GetNbins();
752 size_t x_cut = nx -1; //skip last two bits, which can introduce fake
753 size_t y_cut = ny -1; //correlation
754 for(size_t xi = 1; xi < x_cut; xi++){
755 for(size_t yi = 1; yi < y_cut; yi++){
756 if(yi == xi) //Don't do diagonal
757 continue;
758 float val = hist->GetBinContent(xi,yi);
759 if(val > maxVal)
760 maxVal = val;
761 }
762 }//end x/y loops
763 m_maxBitCorrColl->data[idItr] = maxVal;
764
765 }
766 }//if detailedHashInfo[stripHash] || do all hists.
767 }//end hash loop
768 }
769 else
770 ATH_MSG_DEBUG( "No channels flagged for debug info retrieval" );
771
772 //Copy data from the num entries vector to all relevant histograms
774 //Copy data from the bit correlation vector to all relevant histograms
777 }
779
780 return StatusCode::SUCCESS;
781}
782
783
785 std::stringstream report;
786
787 double numBadPed = m_h_numBad->GetBinContent(m_pedBadBin);
788 report << "Num channels with Delta Ped > " << m_pedMaxDiff << " : " << numBadPed << std::endl ;
789
790 double numBadRms = m_h_numBad->GetBinContent(m_rmsBadBin);
791 report << "Num channels with Delta RMS > " << m_rmsMaxDiff << " : " << numBadRms << std::endl ;
792
793 double numBadF001 = m_h_numBad->GetBinContent(m_f001BadBin);
794 report << "Num channels with Delta f001 > " << m_f001MaxDiff << " : " << numBadF001 << std::endl ;
795
796 double numBadNoise = m_h_numBad->GetBinContent(m_noiseBadBin);
797 report << "Num channels with Delta sigma > " << m_noiseMaxDiff << " : " << numBadNoise << std::endl ;
798
799 double numBadNEntries = m_h_numBad->GetBinContent(m_nEntriesBadBin);
800 report << "Num channels with num pedestal amplitude entries < " << m_minAmpHistEntries
801 << ": " << numBadNEntries <<std::endl ;
802
803 double numBreachEntries = m_h_numBad->GetBinContent(m_onlTHoldBreachBadBin);
804 report << "Num channels with too high an occupancy (> " << m_onlTHoldBreachMax << ")."
805 << ": " << numBreachEntries <<std::endl ;
806
807 if(!(numBadPed >100 || numBadRms > 100 || numBadNEntries>0|| numBreachEntries > 0)){
808 std::ofstream allGoodFile(m_allGoodFileName.c_str());
809 allGoodFile << "All tests past.";
810 allGoodFile.close();
811 }
812
813 std::ofstream reportFile(m_statusReportName.c_str());
814 reportFile << m_statusReportPrefix;
815 reportFile << "\n\n";
816 reportFile << report.str();
817 return;
818
819}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual int getSector(int stationPhi, int stationSize)
Produces a sector number from the phi and size of a station.
std::string getEndCap(int eta)
Gets the letter endcap (A or C) for a given eta index (1,-1)
std::string getGeoPath(int eta=-9999, int sector=-9999, int wireLayer=-9999, int measuresPhi=-9999, int channel=-9999)
getGeoPath creates a directory structure for a histogram based upon where it is in the CSC geometry.
std::string m_calibResultKey
Calibration result storegate key.
std::set< int > m_expectedHashIdsAll
virtual StatusCode initialize()
initializes services, tools, etc.
CscCalibMonToolBase(const std::string &type, const std::string &name, const IInterface *parent)
constructor
DataVector< MonGroup > * m_monGroupVec
Keeps track of MonGroups.
std::string getFullPath(const std::string &geoPath, const std::string &histTypeDir, const std::string &parTypeDir)
Geo path creates a directory structure for a histogram based upon its geoPath, the hist type dir (spe...
virtual StatusCode finalize()
deletes private members
virtual StatusCode bookHistCollection(HistCollection *histCollection, const std::string &dataTypeName, const std::string &dataTypeTitle, const std::string &categoryName, const std::string &categoryTitle, const std::string &axisLabel, int numBins, float lowBound, float highBound, const std::string &parDir="", uint16_t toSkip=0)
Initializes the histograms in a histCollection and books them.
virtual StatusCode copyDataToHists(HistCollection *histCollection)
Fills the histograms in the histCollection based on the data in the std::vector in the HistCollection...
std::string m_generic_path_csccalibmonitoring
Path of histograms.
virtual StatusCode bookHistograms()
Standard function for a ManagedMonitorToolBase.
virtual StatusCode procParameter(const CscCalibResultCollection *parVals, ProcSetupInfo *simpleSet)
Processors a parameter type.
TH1F * m_h_pedMissingChannels
Histograms that simply histogram all entries for a value.
StatusCode initialize()
initialize function.
int m_pedBadBin
Bin in m_h_numBen corresponding to each type of data.
HistCollection * m_pedOldColl
int m_minAmpHistEntries
Allowed number of entries.
void genThreshold(HistCollection *pedColl, HistCollection *noiseColl, HistCollection *tholdColl, float multiplier)
HistCollection * m_chi2Coll
std::string m_statusReportPrefix
Status report prefix.
std::string m_histKey
Samples.
HistCollection * m_rmsDiffColl
HistCollection * m_rmsOldColl
float m_chi2Max
Allowed maximum values.
HistCollection * m_maxBitCorrColl
HistCollection * m_f001OldColl
virtual StatusCode handleParameter(const CscCalibResultCollection *parVals)
handleParameter sets things up for the base class procParameter.
HistCollection * m_noiseDiffColl
StatusCode bookHistograms()
Books all histograms not retrieved driectly from CscCalcPed.
HistCollection * m_pedDiffColl
HistCollection * m_rmsNewColl
HistCollection * m_f001DiffColl
bool m_doBitCorrelations
DO bit correlation plots?
TH1I * m_h_numBad
Stores number of channels that are bad in several categories.
HistCollection * m_noiseNewColl
StatusCode finalize()
finalize function.
HistCollection * m_pedNewColl
HistCollections.
HistCollection * m_f001NewColl
std::string m_allGoodFileName
name of file indicating all is well
virtual StatusCode postProc()
postProc does some post processing work after the main parameter histograms are filled
CscCalibMonToolPed(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
HistCollection * m_onlTHoldBreachColl
HistCollection * m_nEntriesColl
HistCollection * m_tholdDiffColl
float m_pedMaxDiff
Allowed deviations from COOL data.
HistCollection * m_noiseOldColl
std::string m_statusReportName
Status report name.
const std::string & getLabel() const
const DataVector< TH2F > * getBitCorrelation() const
const DataVector< TH1I > * getBitHists() const
Retrieve bit histogram vector.
const DataVector< DataVector< TH1I > > * getSampHists() const
Retrieve pedestal sample amplitude histogram vector.
const DataVector< TH1I > * getPedAmpHists() const
Retrieve pedestal amplitude histogram vector.
const std::string & parName() const
the identify of this collection
Derived DataVector<T>.
Definition DataVector.h:795
const T * front() const
Access the first element in the collection as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
A container of information describing a monitoring object.
virtual StatusCode regHist(TH1 *h, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
Definition run.py:1
Contains an array with data on a per-channel basis, as well as various histograms that give different...
Contains info to be passed to procParameter.