ATLAS Offline Software
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 
5 #include "LArCalibDelayMonAlg.h"
8 #include <set>
9 #include <algorithm>
10 
11 
12 /*---------------------------------------------------------*/
13 LArCalibDelayMonAlg::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() );
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]);
41  m_histoGroups.push_back(Monitored::buildToolMap<int>(m_tools,m_SubDetNames[i],part));
42  }
43 
45 }
46 
47 
48 /*---------------------------------------------------------*/
49 StatusCode LArCalibDelayMonAlg::fillHistograms( const EventContext& ctx ) const {
50 
51  ATH_MSG_DEBUG( "in fillHists()" );
52 
53  //get digit container
54  SG::ReadHandle<LArAccumulatedCalibDigitContainer> pLArAccCalibDigitContainer;
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 
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);
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 
138 unsigned 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 }
LArCalibDelayMonAlg::m_accCalibDigitContainerKey
SG::ReadHandleKey< LArAccumulatedCalibDigitContainer > m_accCalibDigitContainerKey
Definition: LArCalibDelayMonAlg.h:41
LArCalibDelayMonAlg::m_partitions
Gaudi::Property< std::vector< std::string > > m_partitions
Definition: LArCalibDelayMonAlg.h:47
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
PlotCalibFromCool.ft
ft
Definition: PlotCalibFromCool.py:329
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArCalibDelayMonAlg::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: LArCalibDelayMonAlg.cxx:49
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
LArCalibDelayMonAlg.part
string part
Definition: LArCalibDelayMonAlg.py:152
LArOnlineID_Base::slot
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
Definition: LArOnlineID_Base.cxx:1961
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
HWIdentifier
Definition: HWIdentifier.h:13
LArOnlineID_Base::barrel_ec
int barrel_ec(const HWIdentifier id) const
Return the position barrel or endcap of a hardware cell identifier: barrel_ec = [0,...
Definition: LArOnlineID_Base.cxx:1942
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArCalibDelayMonAlg::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArCalibDelayMonAlg.h:56
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
python.ZdcRecConfig.pn
pn
Definition: ZdcRecConfig.py:357
LArCalibDelayMonAlg::LArCalibDelayMonAlg
LArCalibDelayMonAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArCalibDelayMonAlg.cxx:13
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1967
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCalibDelayMonAlg::initialize
virtual StatusCode initialize() override
Overwrite dummy method from AlgTool.
Definition: LArCalibDelayMonAlg.cxx:19
FullCPAlgorithmsTest_eljob.sample
sample
Definition: FullCPAlgorithmsTest_eljob.py:100
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1954
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
delay
double delay(std::size_t d)
Definition: JetTrigTimerTest.cxx:14
AthMonitorAlgorithm::fill
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable >> &&variables) const
Fills a vector of variables to a group by reference.
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
integrator_ascii2db.dac
dac
Definition: integrator_ascii2db.py:126
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArCalibDelayMonAlg::m_histoGroups
std::vector< std::map< std::string, int > > m_histoGroups
Definition: LArCalibDelayMonAlg.h:51
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1948
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCalibDelayMonAlg.h
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
LArCalibDelayMonAlg::returnPartition
unsigned int returnPartition(int be, int pn, int ft, int sl) const
Definition: LArCalibDelayMonAlg.cxx:138
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
LArCalibDelayMonAlg::m_SubDetNames
Gaudi::Property< std::vector< std::string > > m_SubDetNames
Definition: LArCalibDelayMonAlg.h:48
PlotCalibFromCool.be
be
Definition: PlotCalibFromCool.py:398
LArCalibDelayMonAlg::m_MonGroupName
Gaudi::Property< std::string > m_MonGroupName
Definition: LArCalibDelayMonAlg.h:44
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
LArOnlineID.h