ATLAS Offline Software
TileTMDBDigitsMonitorAlgorithm.cxx
Go to the documentation of this file.
1 /*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Tile includes
9 
10 #include <math.h>
11 // Athena includes
12 #include "StoreGate/ReadHandle.h"
13 
14 
15 TileTMDBDigitsMonitorAlgorithm::TileTMDBDigitsMonitorAlgorithm( const std::string& name, ISvcLocator* pSvcLocator )
16  :AthMonitorAlgorithm(name, pSvcLocator)
17  , m_tileHWID(nullptr)
18 {
19 
20 }
21 
23 }
24 
25 
27 
29 
30  ATH_MSG_DEBUG("in initialize()");
31 
33 
35 
36  using Tile = TileCalibUtils;
37  using namespace Monitored;
38 
39  m_hfnGroups = buildToolMap<int>(m_tools, "TMDB_DigitsHFN", Tile::MAX_ROS - 1);
40  m_pedGroups = buildToolMap<int>(m_tools, "TMDB_DigitsPedestal", Tile::MAX_ROS - 1);
41  m_ampGroups = buildToolMap<int>(m_tools, "TMDB_DigitsAmplitude", Tile::MAX_ROS - 1);
42 
43 
44  if (m_nChannels.size() != (Tile::MAX_ROS - 1)) {
45  ATH_MSG_FATAL( "Size of NumberOfChannels should be 4 (LBA, LBC, EBA, EBC), but is " << m_nChannels.size() );
46  return StatusCode::FAILURE;
47  }
48 
49  std::vector<std::string> partitionName = {"LBA", "LBC", "EBA", "EBC"}; // ROS - 1 to partition name map
50  for (unsigned int partition = 0; partition < Tile::MAX_ROS-1; ++partition) {
51  m_cellPedGroups.push_back(buildToolMap<int>(m_tools,
52  "TMDB_DigitsCellPedestal_" + partitionName[partition],
54  m_cellHFNGroups.push_back(buildToolMap<int>(m_tools,
55  "TMDB_DigitsCellHFN_" + partitionName[partition],
57  m_cellAmpGroups.push_back(buildToolMap<int>(m_tools,
58  "TMDB_DigitsCellAmplitude_" + partitionName[partition],
60  }
61 
62  return StatusCode::SUCCESS;
63 }
64 
65 
67 
68  ATH_MSG_DEBUG( "in fillHistograms()" );
69  using Tile = TileCalibUtils;
70  std::vector<int> drawers[Tile::MAX_ROS - 1];
71  std::vector<int> channels[Tile::MAX_ROS - 1];
72  std::vector<float> pedestals[Tile::MAX_ROS - 1];
73  std::vector<float> amplitudes[Tile::MAX_ROS - 1];
74  std::vector<float> hfns[Tile::MAX_ROS - 1];
75  static constexpr int TMDB_MAX_CHANNEL = 8;
76  std::vector<float> cellPedestals[Tile::MAX_ROS - 1][TMDB_MAX_CHANNEL];
77  std::vector<float> cellHFNs[Tile::MAX_ROS - 1][TMDB_MAX_CHANNEL];
78  std::vector<float> cellAmplitudes[Tile::MAX_ROS - 1][TMDB_MAX_CHANNEL];
79 
81  ATH_CHECK( digitsContainer.isValid() );
82 
83  for (IdentifierHash hash : digitsContainer->GetAllCurrentHashes()) {
84  const TileDigitsCollection* digitsCollection = digitsContainer->indexFindPtr (hash);
85 
86  int fragId = digitsCollection->identify();
87  unsigned int drawer = (fragId & 0x3F);
88  unsigned int ros = fragId >> 8;
89  unsigned int partition = ros - 1;
90 
91  for (const TileDigits* tile_digits : *digitsCollection) {
92 
93  HWIdentifier adc_id = tile_digits->adc_HWID();
94  int channel = m_tileHWID->channel(adc_id);
95  std::vector<float> digits = tile_digits->samples();
96 
97  double mean_samp = 0.0;
98  double rms_samp = 0.0;
99  unsigned int n_digits = digits.size();
100 
101  for (double digit : digits) {
102  mean_samp += digit;
103  rms_samp += digit * digit;
104  }
105 
106  if (n_digits > 1) {
107  drawers[partition].push_back(drawer);
108  channels[partition].push_back(channel);
109 
110  double ped = digits[0];
111  pedestals[partition].push_back(ped);
112 
113  mean_samp /= n_digits;
114  rms_samp = rms_samp / n_digits - mean_samp * mean_samp;
115  rms_samp = (rms_samp > 0.0) ? sqrt(rms_samp * n_digits / (n_digits - 1)) : 0.0;
116  hfns[partition].push_back(rms_samp);
117 
118  //-- temporary until TMDB raw channel monitoring tool be ready --//
119 
120  auto min_max = std::minmax_element(digits.begin(), digits.end());
121  float min_digit = *min_max.first;
122  float max_digit = *min_max.second;
123  float amplitude = max_digit - min_digit;
124  amplitudes[partition].push_back(amplitude);
125 
126 
127  //---------------------------------------------------------------//
128  if (channel < m_nChannels[partition]) {
129  cellPedestals[partition][channel].push_back(ped);
130  cellHFNs[partition][channel].push_back(rms_samp);
131  cellAmplitudes[partition][channel].push_back(amplitude);
132  }
133 
134  }
135  }
136  }
137 
138 
139  for (unsigned int partition = 0; partition < Tile::MAX_ROS - 1; ++partition) {
140  if (!pedestals[partition].empty()) {
141  auto monModule = Monitored::Collection("module", drawers[partition]);
142  auto monChannel = Monitored::Collection("channel", channels[partition]);
143  auto monPedestal = Monitored::Collection("pedestal", pedestals[partition]);
144  fill(m_tools[m_pedGroups[partition]], monModule, monChannel, monPedestal);
145 
146  auto monHFN = Monitored::Collection("HFN", hfns[partition]);
147  fill(m_tools[m_hfnGroups[partition]], monModule, monChannel, monHFN);
148 
149  auto monAmplitude = Monitored::Collection("amplitude", amplitudes[partition]);
150  fill(m_tools[m_ampGroups[partition]], monModule, monChannel, monAmplitude);
151 
152  for (int channel = 0; channel < int(m_nChannels[partition]); ++channel) {
153  if (!cellPedestals[partition][channel].empty()) {
154  auto monPedestal = Monitored::Collection("pedestal", cellPedestals[partition][channel]);
155  fill(m_tools[m_cellPedGroups[partition][channel]], monPedestal);
156  }
157  if (!cellHFNs[partition][channel].empty()) {
158  auto monHFN = Monitored::Collection("HFN", cellHFNs[partition][channel]);
160  }
161  if (!cellAmplitudes[partition][channel].empty()) {
162  auto monAmplitude = Monitored::Collection("amplitude", cellAmplitudes[partition][channel]);
163  fill(m_tools[m_cellAmpGroups[partition][channel]], monAmplitude);
164  }
165  }
166  }
167  }
168 
169 
170  return StatusCode::SUCCESS;
171 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileTMDBDigitsMonitorAlgorithm::m_cellHFNGroups
std::vector< std::vector< int > > m_cellHFNGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:42
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TileTMDBDigitsMonitorAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TileTMDBDigitsMonitorAlgorithm.cxx:66
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
TileTMDBDigitsMonitorAlgorithm::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileTMDBDigitsMonitorAlgorithm.h:28
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TileTMDBDigitsMonitorAlgorithm::m_digitsContainerKey
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
Definition: TileTMDBDigitsMonitorAlgorithm.h:35
TileTMDBDigitsMonitorAlgorithm::TileTMDBDigitsMonitorAlgorithm
TileTMDBDigitsMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileTMDBDigitsMonitorAlgorithm.cxx:15
TileTMDBDigitsMonitorAlgorithm::m_cellPedGroups
std::vector< std::vector< int > > m_cellPedGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:41
TileCalibUtils.h
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
dq_defect_copy_defect_database.channels
def channels
Definition: dq_defect_copy_defect_database.py:56
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
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
Tile
Definition: TileVolumeBuilder.h:43
TileTMDBDigitsMonitorAlgorithm::~TileTMDBDigitsMonitorAlgorithm
virtual ~TileTMDBDigitsMonitorAlgorithm()
Definition: TileTMDBDigitsMonitorAlgorithm.cxx:22
TileHWID.h
IdentifiableContainerMT::GetAllCurrentHashes
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
Definition: IdentifiableContainerMT.h:231
TileTMDBDigitsMonitorAlgorithm.h
Monitored
Generic monitoring tool for athena components.
Definition: GenericMonitoringTool.h:30
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TileRawDataCollection::identify
ID identify() const
Definition: TileRawDataCollection.h:71
TileTMDBDigitsMonitorAlgorithm::m_hfnGroups
std::vector< int > m_hfnGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:32
AthMonitorAlgorithm::m_tools
ToolHandleArray< GenericMonitoringTool > m_tools
Array of Generic Monitoring Tools.
Definition: AthMonitorAlgorithm.h:338
TileDigitsCollection
Definition: TileDigitsCollection.h:18
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TileDigits
Definition: TileDigits.h:30
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
IdentifiableContainerMT::indexFindPtr
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
Definition: IdentifiableContainerMT.h:292
TileTMDBDigitsMonitorAlgorithm::m_cellAmpGroups
std::vector< std::vector< int > > m_cellAmpGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:43
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
TileTMDBDigitsMonitorAlgorithm::m_nChannels
Gaudi::Property< std::vector< int > > m_nChannels
Definition: TileTMDBDigitsMonitorAlgorithm.h:38
python.Classes.TileCalibUtils
TileCalibUtils
Definition: TileCalib/TileCalibBlobObjs/python/Classes.py:5
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
TileTMDBDigitsMonitorAlgorithm::m_ampGroups
std::vector< int > m_ampGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:33
ReadHandle.h
Handle class for reading from StoreGate.
GlobalMonitoring_CA.partitionName
partitionName
Definition: GlobalMonitoring_CA.py:22
TileTMDBDigitsMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TileTMDBDigitsMonitorAlgorithm.cxx:26
TileTMDBDigitsMonitorAlgorithm::m_pedGroups
std::vector< int > m_pedGroups
Definition: TileTMDBDigitsMonitorAlgorithm.h:31