ATLAS Offline Software
Loading...
Searching...
No Matches
SCTCalib.cxx File Reference

Find noisy strips, HV trips and dead strips/chips Upload NoiseOccupancy and BSErrors from monitoring histograms. More...

#include "SCT_CalibAlgs/SCTCalib.h"
#include "SCT_CalibAlgs/SCT_LorentzAngleFunc.h"
#include "SCT_CalibUtilities.h"
#include "XmlHeader.h"
#include "XmlStreamer.h"
#include "InDetReadoutGeometry/SiDetectorElement.h"
#include "GaudiKernel/IEventProcessor.h"
#include "TFile.h"
#include "TH1I.h"
#include "TH2D.h"
#include "TF1.h"
#include "TProfile.h"
#include "TProfile2D.h"
#include "Math/ProbFuncMathCore.h"
#include <array>
#include <cmath>

Go to the source code of this file.

Functions

StatusCode SCTCalib::stop ATLAS_NOT_THREAD_SAFE ()
 stop - process results accumulated in execute()
StatusCode SCTCalib::writeModuleListToCool ATLAS_NOT_THREAD_SAFE (const std::map< Identifier, std::set< Identifier > > &moduleListAll, const std::map< Identifier, std::set< Identifier > > &moduleListNew, const std::map< Identifier, std::set< Identifier > > &moduleListRef)

Detailed Description

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

StatusCode SCTCalib::stop ATLAS_NOT_THREAD_SAFE ( void )
inline

stop - process results accumulated in execute()

Install fatal handler with default options.

getLorentzAngle() Read LorentzAngle from HIST and write out into local DB

getBSErrors() Read BSErrors from Monitoring HIST and write out into local DB

getEfficiency() Read Efficiency from Monitoring HIST and write out into local DB

getRawOccupancy() Read RawOccupancy from Monitoring HIST and write out into local DB

getNoiseOccupancy() Read NoiseOccupancy from HIST and write out into local DB

getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats

Definition at line 341 of file SCTCalib.cxx.

341 { // Thread unsafe getNoisyStrip, getDeadStrip, getNoiseOccupancy, getRawOccupancy, getEfficiency, getBSErrors, getLorentzAngle methods are used.
342 ATH_MSG_INFO("----- in stop() ----- ");
343 //--- Number of events processed
344 m_numberOfEvents = (m_readHIST or (!m_doHitMaps and m_readHitMaps)) ? m_numberOfEventsHist : m_calibEvtInfoTool->counter();
345 m_calibEvtInfoTool->getTimeStamps(m_utcBegin, m_utcEnd);
346
347 //--- IOV range defined by RunNumber and LB
348 unsigned int beginRun{static_cast<unsigned int>(m_runNumber.value())};
349 unsigned int endRun{static_cast<unsigned int>(m_runNumber.value())};
350 unsigned int beginLB{IOVTime::MINEVENT};
351 unsigned int endLB{IOVTime::MAXEVENT};
352 m_iovStart.setRunEvent(static_cast<unsigned long>(beginRun), static_cast<unsigned long>(beginLB));
353 m_iovStop.setRunEvent(static_cast<unsigned long>(endRun), static_cast<unsigned long>(endLB));
354
355 //--- Find noisy strips from hitmaps
356 const bool doNoisyStripAnalysis{((!m_doHitMaps and m_readHitMaps) or !m_readHitMaps) and m_doNoisyStrip};
357 if (doNoisyStripAnalysis) {
358 if (getNoisyStrip().isFailure()) {
359 ATH_MSG_ERROR("Failed to run getNoisyStrip()");
360 return StatusCode::FAILURE;
361 }
362 }
363
364 //--- Upload hv
365 if (m_doHV) {
366 m_gofile.open(m_badModulesFile.value().c_str(), std::ios::out);
367 if (not m_gofile) ATH_MSG_ERROR("Problem opening " << m_badModulesFile);
368 //
369 XmlHeader myXml{m_gofile};
370 XmlStreamer root{"modules", m_gofile};
371 SCT_ID::const_id_iterator waferItr{m_pSCTHelper->wafer_begin()};
372 SCT_ID::const_id_iterator waferItrE{m_pSCTHelper->wafer_end()};
373 const unsigned int onlyDummy{1};
374 std::pair<int, int> timeInterval{0, 0};
375 std::pair<int, int> lbRange{0, 0};
376 const int withinLimits{m_maxtbins};
377 //
378 for (; waferItr not_eq waferItrE; ++waferItr) {
379 const Identifier waferId{*waferItr};
380 IdentifierHash waferHash{m_pSCTHelper->wafer_hash(waferId)};
381 const std::vector<std::pair<int, int>>& tvec{m_summarytrips.at(waferHash.value())};
382 const std::vector<std::pair<int, int>>& tlbn{m_summarytripslb.at(waferHash.value())};
383 //tvec is a pair of times in general, although the very first one is a dummy
384 const unsigned int numberOfElements{static_cast<unsigned int>(tvec.size())};
385 if (numberOfElements > onlyDummy) {
386 //only care if something happened in this module
387 timeInterval=tvec.at(1);
388 lbRange=tlbn.at(1);
389 for (unsigned int itrip{2}; itrip != numberOfElements; ++itrip) { //skip 0 since that is just the dummy pair.
390 if (areConsecutiveIntervals(tvec[itrip], timeInterval, withinLimits)) {
391 timeInterval.second = tvec.at(itrip).second;
392 lbRange.second = tlbn.at(itrip).second;
393 } else {
394 //not consecutive, so first print out the old one
395 doHVPrintXML(timeInterval, lbRange, waferId);
396 timeInterval = tvec.at(itrip);
397 lbRange = tlbn.at(itrip);
398 }
399 } // end loop over times
400 doHVPrintXML(timeInterval, lbRange, waferId);
401 }
402 } // end loop over wafers
403 }
404
405 //--- Find dead strips/chips from hitmaps
406 if ((m_doDeadStrip or m_doDeadChip) and getDeadStrip().isFailure()) {
407 ATH_MSG_ERROR("Failed to run getDeadStrip()");
408 return StatusCode::FAILURE;
409 }
410
411 //--- Upload noise occupancy
412 if (m_doNoiseOccupancy and getNoiseOccupancy().isFailure()) {
413 ATH_MSG_ERROR("Failed to run getNoiseOccupancy()");
414 return StatusCode::FAILURE;
415 }
416
417 //--- Upload raw occupancy
418 if (m_doRawOccupancy and getRawOccupancy().isFailure()) {
419 ATH_MSG_ERROR("Failed to run getRawOccupancy()");
420 return StatusCode::FAILURE;
421 }
422
423 //--- Upload efficiency
424 if (m_doEfficiency and getEfficiency().isFailure()) {
425 ATH_MSG_ERROR("Failed to run getEfficiency()");
426 return StatusCode::FAILURE;
427 }
428
429 //--- Upload ByteStream Errors
430 if (m_doBSErrorDB and getBSErrors().isFailure()) {
431 ATH_MSG_ERROR("Failed to run getBSErrors()");
432 return StatusCode::FAILURE;
433 }
434
435 //--- Upload Lorentz Angle
436 if (m_doLorentzAngle and getLorentzAngle().isFailure()) {
437 ATH_MSG_ERROR("Failed to run getLorentzAngle()");
438 return StatusCode::FAILURE;
439 }
440
441 //--- Close HIST
442 if (m_readHIST) m_inputHist->Close();
443
444 return StatusCode::SUCCESS;
445}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static constexpr uint32_t MINEVENT
Definition IOVTime.h:50
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
This is a "hash" representation of an Identifier.
constexpr value_type value() const
std::vector< Identifier >::const_iterator const_id_iterator
Definition SCT_ID.h:73
std::pair< StatusCode, TEfficiency * > getEfficiency(ITHistSvc &svc, const std::string &name)

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

StatusCode SCTCalib::writeModuleListToCool ATLAS_NOT_THREAD_SAFE ( const std::map< Identifier, std::set< Identifier > > & moduleListAll,
const std::map< Identifier, std::set< Identifier > > & moduleListNew,
const std::map< Identifier, std::set< Identifier > > & moduleListRef )

Definition at line 2775 of file SCTCalib.cxx.

2778 {
2779 //--- Write out strips
2780 float noisyStripThr{m_noisyStripThrDef?(m_noisyStripThrOffline):(m_noisyStripThrOnline)};
2781 int nDefects{0};
2782 SCT_ID::const_id_iterator idItr{m_pSCTHelper->wafer_begin()};
2783 SCT_ID::const_id_iterator idItrE{m_pSCTHelper->wafer_end()};
2784 for (; idItr != idItrE; ++idItr) {
2785 if (m_pSCTHelper->side(*idItr) == 0) {
2786 Identifier moduleId{m_pSCTHelper->module_id(*idItr)};
2787 std::map<Identifier, std::set<Identifier>>::const_iterator moduleAllItr{moduleListAll.find(moduleId)};
2788 std::map<Identifier, std::set<Identifier>>::const_iterator moduleNewItr{moduleListNew.find(moduleId)};
2789 std::map<Identifier, std::set<Identifier>>::const_iterator moduleRefItr{moduleListRef.find(moduleId)};
2790 std::string defectStripsAll{moduleAllItr != moduleListAll.end() ? getStripList((*moduleAllItr).second) : ""};
2791 std::string defectStripsNew{moduleNewItr != moduleListNew.end() ? getStripList((*moduleNewItr).second) : ""};
2792 std::string defectStripsRef{moduleRefItr != moduleListRef.end() ? getStripList((*moduleRefItr).second) : ""};
2793 if (m_noisyUpdate) { //--- UPD1/UPD4
2794 if (defectStripsAll != defectStripsRef) {
2795 if (m_pCalibWriteTool->createCondObjects(moduleId, m_pSCTHelper, 10000, "NOISY", noisyStripThr, defectStripsAll).isFailure()) {
2796 ATH_MSG_ERROR("Could not create defect strip entry in the CalibWriteTool.");
2797 }
2798 nDefects++;
2799 };
2800 } else {
2801 if (m_noisyStripAll) { //--- ALL noisy strips
2802 if (!defectStripsAll.empty() || m_noisyWriteAllModules) {
2803 if (m_pCalibWriteTool->createCondObjects(moduleId, m_pSCTHelper, 10000, "NOISY", noisyStripThr, defectStripsAll).isFailure()) {
2804 ATH_MSG_ERROR("Could not create defect strip entry in the CalibWriteTool.");
2805 }
2806 }
2807 } else { //--- Only NEW noisy strips
2808 if (!defectStripsNew.empty()) {
2809 if (m_pCalibWriteTool->createCondObjects(moduleId, m_pSCTHelper, 10000, "NOISY", noisyStripThr, defectStripsNew).isFailure()) {
2810 ATH_MSG_ERROR("Could not create defect strip entry in the CalibWriteTool.");
2811 }
2812 }
2813 }
2814 }
2815 }
2816 }
2817 ATH_MSG_DEBUG("Number of modules for which conditions were created: " << nDefects << " !!!!");
2818 if (moduleListAll.empty() or ( nDefects==0 && m_noisyUpdate )) {
2819 ATH_MSG_INFO("Number of noisy strips was zero or the same list of noisy strips. No local DB was created.");
2820 } else {
2821 ATH_MSG_DEBUG("directly before call of wrapUpNoisyChannel");
2822 if (m_pCalibWriteTool->wrapUpNoisyChannel().isFailure()) {
2823 ATH_MSG_ERROR("Could not get NoisyStrips info");
2824 return StatusCode::FAILURE;
2825 }
2826 }
2827 ATH_MSG_DEBUG("before return");
2828 return StatusCode::SUCCESS;
2829}
#define ATH_MSG_DEBUG(x)