ATLAS Offline Software
TRT_Hits_Monitoring_Tool.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 #ifdef ONLINE // This tool is only meant for special online monitoring at Point 1
6 
9 
10 #include "StoreGate/ReadHandle.h"
11 
12 #include "boost/date_time/posix_time/posix_time_types.hpp"
13 
14 TRT_Hits_Monitoring_Tool::TRT_Hits_Monitoring_Tool(const std::string &type, const std::string &name, const IInterface *parent):
16  m_pTRTHelper(0),
17  m_lastPublishTime(boost::posix_time::min_date_time) // never
18 {
19  declareProperty("Partition", m_partition = "initial");
20  declareProperty("Server", m_server = "beamconditions");
21  declareProperty("Name", m_name = "hitfractionTRT");
22  declareProperty("LongToTCut", m_longToTCut = 9.375);
23  declareProperty("SleepTime", m_sleepTime = 500); // milliseconds
24 }
25 
26 TRT_Hits_Monitoring_Tool::~TRT_Hits_Monitoring_Tool() {
27 }
28 
30  StatusCode sc;
31 
33 
35 
36  ATH_CHECK(detStore()->retrieve(m_pTRTHelper, "TRT_ID"));
37 
38  IPCPartition partition(m_partition);
39  m_dict = ISInfoDictionary(partition);
40 
41  m_name_longToT = m_server + "." + m_name + "_longToT";
42  m_nameBR_longToT = m_server + "." + m_name + "Barrel_longToT";
43  m_nameEA_longToT = m_server + "." + m_name + "EndCapA_longToT";
44  m_nameEC_longToT = m_server + "." + m_name + "EndCapC_longToT";
45 
46  m_dict.checkin(m_name_longToT, m_occ_longToT);
47  m_dict.checkin(m_nameBR_longToT, m_occBR_longToT);
48  m_dict.checkin(m_nameEA_longToT, m_occEA_longToT);
49  m_dict.checkin(m_nameEC_longToT, m_occEC_longToT);
50 
51  ATH_CHECK(m_rdoContainerKey.initialize());
52 
53  return StatusCode::SUCCESS;
54 }
55 
56 StatusCode TRT_Hits_Monitoring_Tool::bookHistogramsRecurrent() {
57  return StatusCode::SUCCESS;
58 }
59 
60 StatusCode TRT_Hits_Monitoring_Tool::fillHistograms() {
61  const static boost::posix_time::time_duration sleepTime = boost::posix_time::milliseconds(m_sleepTime);
62  const boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time();
63  if (now - m_lastPublishTime < sleepTime) return StatusCode::SUCCESS; // do not publish results too often
64 
65  SG::ReadHandle<TRT_RDO_Container> rdoContainer(m_rdoContainerKey);
66  if (!rdoContainer.isValid()) {
67  ATH_MSG_ERROR("Could not find TRT RDO container " << m_rdoContainerKey.key());
68  return StatusCode::FAILURE;
69  }
70 
71  unsigned int nHits_longToT = 0;
72  unsigned int nHitsBR_longToT = 0;
73  unsigned int nHitsEA_longToT = 0;
74  unsigned int nHitsEC_longToT = 0;
75 
76  const TRT_RDO_Container::const_iterator containerBeg = rdoContainer->begin();
77  const TRT_RDO_Container::const_iterator containerEnd = rdoContainer->end();
78  for (TRT_RDO_Container::const_iterator collection = containerBeg; collection != containerEnd; ++collection) {
79  const InDetRawDataCollection<TRT_RDORawData> *TRT_Collection(*collection);
80  if (!TRT_Collection) continue; // select only TRT RDOs
81 
82  const DataVector<TRT_RDORawData>::const_iterator collectionBeg = TRT_Collection->begin();
83  const DataVector<TRT_RDORawData>::const_iterator collectionEnd = TRT_Collection->end();
84  for (DataVector<TRT_RDORawData>::const_iterator rdo = collectionBeg; rdo != collectionEnd; ++rdo) {
85  const TRT_LoLumRawData *rawData = dynamic_cast<const TRT_LoLumRawData *>(*rdo);
86  if (!rawData) continue; // not the right data type
87  if (rawData->timeOverThreshold() <= m_longToTCut) continue; // omit hits with short ToT
88 
89  ++nHits_longToT;
90  switch (m_pTRTHelper->barrel_ec((*rdo)->identify())) { // which detector region?
91  case -1: // ... or ...
92  case +1: ++nHitsBR_longToT; break;
93  case +2: ++nHitsEA_longToT; break;
94  case -2: ++nHitsEC_longToT; break;
95  }
96  }
97  }
98 
99  const unsigned int nChannelsBarrel = 105088; // 52544 straws with two channels
100  const unsigned int nChannelsEndcap = 122880; // 122880 straws with one channel
101  const unsigned int nChannelsTotal = nChannelsBarrel + 2 * nChannelsEndcap;
102 
103  m_occ_longToT = (float)nHits_longToT / nChannelsTotal;
104  m_occBR_longToT = (float)nHitsBR_longToT / nChannelsBarrel;
105  m_occEA_longToT = (float)nHitsEA_longToT / nChannelsEndcap;
106  m_occEC_longToT = (float)nHitsEC_longToT / nChannelsEndcap;
107 
108  m_dict.update(m_name_longToT, m_occ_longToT);
109  m_dict.update(m_nameBR_longToT, m_occBR_longToT);
110  m_dict.update(m_nameEA_longToT, m_occEA_longToT);
111  m_dict.update(m_nameEC_longToT, m_occEC_longToT);
112 
113  m_lastPublishTime = now;
114  return StatusCode::SUCCESS;
115 }
116 
117 StatusCode TRT_Hits_Monitoring_Tool::procHistograms() {
118  return StatusCode::SUCCESS;
119 }
120 
121 #endif // ONLINE
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TRT_DetectorManager.h
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TRT_LoLumRawData
Definition: TRT_LoLumRawData.h:25
initialize
void initialize()
Definition: run_EoverP.cxx:894
boost
Definition: DVLIterator.h:29
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
python.handimod.now
now
Definition: handimod.py:675
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TRT_LoLumRawData::timeOverThreshold
virtual double timeOverThreshold() const override final
Definition: TRT_LoLumRawData.h:47
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
StateLessPT_NewConfig.partition
partition
Definition: StateLessPT_NewConfig.py:49
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
TRT_Hits_Monitoring_Tool.h
ReadHandle.h
Handle class for reading from StoreGate.
readCCLHist.float
float
Definition: readCCLHist.py:83