ATLAS Offline Software
Loading...
Searching...
No Matches
LArCalibDelayMonAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include <set>
9#include <algorithm>
10
11
12/*---------------------------------------------------------*/
13LArCalibDelayMonAlg::LArCalibDelayMonAlg(const std::string& name,ISvcLocator* pSvcLocator )
14 : AthMonitorAlgorithm(name,pSvcLocator),
15 m_onlineHelper(nullptr)
16{}
17
18/*---------------------------------------------------------*/
20 ATH_MSG_INFO( "Initialize LArCalibDelayMonAlg" );
21
22/*For pedestal run ONLY, not delay and ramp*/
23 ATH_MSG_INFO( "m_accCalibDigitContainerKey.empty() " << m_accCalibDigitContainerKey.empty() );
25 if (m_accCalibDigitContainerKey.empty()) {
26 ATH_MSG_FATAL("LArAccumulatedCalibDigitContainerKey must be set");
27 return StatusCode::FAILURE;
28 }
29
30 StatusCode sc = detStore()->retrieve(m_onlineHelper, "LArOnlineID");
31 if (sc.isFailure()) {
32 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
33 return StatusCode::FAILURE;
34 }
35
36 m_histoGroups.reserve(m_SubDetNames.size());
37 for (unsigned i=0; i<m_SubDetNames.size(); ++i) {
38 std::vector<std::string> part;
39 part.push_back(m_partitions[2*i]);
40 part.push_back(m_partitions[2*i+1]);
42 }
43
45}
46
47
48/*---------------------------------------------------------*/
49StatusCode LArCalibDelayMonAlg::fillHistograms( const EventContext& ctx ) const {
50
51 ATH_MSG_DEBUG( "in fillHists()" );
52
53 //get digit container
55
56 std::unordered_set<unsigned int> chanids;
57
58 auto dac = Monitored::Scalar<int>("dac",0);
59 auto delay = Monitored::Scalar<int>("delay",0);
60 auto sample_max = Monitored::Scalar<double>("sample_max",0.);
61 auto sample_max30 = Monitored::Scalar<double>("sample_max30",0.);
62 auto sample_min = Monitored::Scalar<double>("sample_min",0.);
63 auto chid = Monitored::Scalar<unsigned int>("chid",-1);
64 auto slot = Monitored::Scalar<int>("slot",-1);
65 auto ft = Monitored::Scalar<int>("FT",-1);
66 auto slot30 = Monitored::Scalar<int>("slot30",-1);
67 auto ft30 = Monitored::Scalar<int>("FT30",-1);
68 auto febchid = Monitored::Scalar<int>("febchid",-1);
69
70 if(!m_accCalibDigitContainerKey.empty()) {
71
73 if(pLArAccCalibDigitContainer.isValid()){
74 ATH_MSG_DEBUG("Got LArAccumulatedCalibDigitContainer with key "<< m_accCalibDigitContainerKey.key());
75 } else {
76 ATH_MSG_WARNING("Do not have LArAcumulatedCalibDigitContainer with key "<< m_accCalibDigitContainerKey.key());
77 }
78 if(pLArAccCalibDigitContainer->empty()) return StatusCode::SUCCESS; // Nothing to fill
79
81 for (auto ijDig: * pLArAccCalibDigitContainer) {
82 HWIdentifier id = ijDig->hardwareID();
83 chid = (ijDig->hardwareID()).get_identifier32().get_compact();
84 chanids.emplace(chid); //inserts if the chid does not exist
85
86 febchid = m_onlineHelper->channel(id);
87
88 unsigned ntriggers = ijDig->nTriggers();
89 std::vector <double> sample;
90
91 // transform sampleSum vector from uint32_t to double
92 std::vector <double> samplesum;
93
94 for (auto samplesum_it: ijDig->sampleSum()) {
95 samplesum.push_back((double)(samplesum_it));
96 // Get the vector of sample values
97 sample.push_back((double)(samplesum_it)/ntriggers);
98 }
99
100 // Get highest and lowest energy samples
101 double samplemax = * std::max_element(sample.begin(), sample.end());
102 double samplemin = * std::min_element(sample.begin(), sample.end());
103 // Get dac and delay
104 dac = ijDig->DAC();
105 delay = ijDig->delay();
106
107 // Then fill histo about max/min sample
108 sample_max = samplemax;
109 sample_min = samplemin;
110 fill(m_MonGroupName, sample_max, sample_min, febchid, dac, delay, chid);
111
112 slot = m_onlineHelper->slot(id);
113 ft = m_onlineHelper->feedthrough(id);
114 int barrel_ec = m_onlineHelper->barrel_ec(id);
115 int pos_neg = m_onlineHelper->pos_neg(id);
116 unsigned int partitionNb = returnPartition(barrel_ec,pos_neg,ft,slot);
117 unsigned int subdet = partitionNb / 2;
118
119 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitionNb])],slot,ft,sample_max,sample_min);
120
121 if (samplemax <= 3000.) {
122 sample_max30 = samplemax;
123 slot30 = m_onlineHelper->slot(id);
124 ft30 = m_onlineHelper->feedthrough(id);
125 fill(m_tools[m_histoGroups.at(subdet).at(m_partitions[partitionNb])],slot30,ft30,sample_max30);
126 }
127
128 }//end loop over pLArAccCalibDigitContainer
129
130 ATH_MSG_DEBUG("Filling nbChan: "<<chanids.size());
131 auto nbchan = Monitored::Scalar<unsigned int>("nbChan",chanids.size());
132 fill(m_MonGroupName,nbchan);
133 }
134
135 return StatusCode::SUCCESS;
136}
137
138unsigned int LArCalibDelayMonAlg::returnPartition(int be,int pn,int ft,int sl) const {
139 // partitionNb = 0 : EMBC / 1 : EMBA / 2 : EMECC / 3 : EMECA / 4 : HECC / 5 : HECA / 6 : FCALC / 7 : FCALA
140 unsigned int part = be*2+pn;
141 if (be == 1){
142 // This is a HEC FEB - Dirty method as IsHECOnlineFEBId is buggy!
143 if ((ft == 3 || ft == 10 || ft == 16 || ft == 22) && (sl > 2)) part = be*2+pn + 2;
144 if (ft == 6) part = be*2 + pn + 4; // This is FCAL FEB
145 }
146 return part;
147}
#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_WARNING(x)
#define ATH_MSG_DEBUG(x)
double delay(std::size_t d)
static Double_t sc
Header file to be included by clients of the Monitored infrastructure.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
std::vector< std::map< std::string, int > > m_histoGroups
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
LArCalibDelayMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
unsigned int returnPartition(int be, int pn, int ft, int sl) const
Gaudi::Property< std::vector< std::string > > m_partitions
Gaudi::Property< std::string > m_MonGroupName
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_accCalibDigitContainerKey
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Gaudi::Property< std::vector< std::string > > m_SubDetNames
const LArOnlineID * m_onlineHelper
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::vector< V > buildToolMap(const ToolHandleArray< GenericMonitoringTool > &tools, const std::string &baseName, int nHist)
Builds an array of indices (base case)
void fill(H5::Group &out_file, size_t iterations)