ATLAS Offline Software
MuonEventInfoMonTool.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 "MuonEventInfoMonTool.h"
6 #include "MuonDQAEvent.h"
7 
8 #include "GaudiKernel/MsgStream.h"
10 #include "StoreGate/ReadHandle.h"
12 
13 
15 
16 // trigger includes:
17 #include "TrigT1Result/CTP_RDO.h"
18 #include "TrigT1Result/CTP_RIO.h"
20 
21 
22 #include "TH1F.h"
23 
24 namespace MuonDQA {
25 
27  // *********************************************************************
28  // Public Methods
29  // *********************************************************************
30 
31  MuonEventInfoMonTool::MuonEventInfoMonTool( const std::string & type, const std::string & name, const IInterface* parent )
32  : ManagedMonitorToolBase( type, name, parent ), m_eventStore(nullptr),
33  m_hTriggerType(nullptr)
34  {
35  /*---------------------------------------------------------*/
36  declareProperty("LastEvent", m_lastEvent=0);
37  declareProperty("TriggerTagAdd", m_TriggerTagAdd = true);
38  }
39  /*---------------------------------------------------------*/
40 
41  /*---------------------------------------------------------*/
43  /*---------------------------------------------------------*/
44  {
46 
47  ATH_MSG_INFO( "initialize MuonEventInfoMonTool" );
48 
49  // The StoreGateSvc is where event-by-event information is stored.
50  ATH_CHECK(service( "StoreGateSvc", m_eventStore));
51 
53 
54  return StatusCode::SUCCESS;
55  }
56 
57  /*----------------------------------------------------------------------------------*/
59  /*----------------------------------------------------------------------------------*/
60  {
61 
62  ATH_MSG_DEBUG( "MuonEventInfoMonTool Histograms being filled" );
63  StatusCode sc = StatusCode::SUCCESS;
64 
65  std::string generic_path_muonmonitoring = "Muon/MuonEventInfo";
66 
67  //declare a group of histograms
68  MonGroup muonevt_shift( this, generic_path_muonmonitoring, run, ATTRIB_MANAGED );
69 
70  if(newEventsBlockFlag()){}
71  if(newLumiBlockFlag()){}
72  if(newRunFlag())
73  {
74  ATH_MSG_DEBUG( "MuonEventInfoMonTool : isNewRun" );
75 
76  // Trigger types
77 
78  m_hTriggerType = new TH1F("TriggerType","Number_of_Events_per_L1_TriggerType(8 bits)",256, -0.5, 255.5);
79  m_hTriggerType->SetFillColor(42);
80 
81 
82  m_hTriggerType->GetXaxis()->SetTitle("L1 trigger word");
83  m_hTriggerType->GetYaxis()->SetTitle("Number of Events");
84 
85 
86  sc=muonevt_shift.regHist(m_hTriggerType);
87  if(sc.isFailure()){
88  ATH_MSG_FATAL( "m_hTriggerType Failed to register histogram " );
89  return StatusCode::FAILURE;
90  }
91 
92  ATH_MSG_DEBUG( "exiting bookHistograms for trigger type " << m_hTriggerType << " end of run : " << run );
93 
94  }// isEndOfRun
95 
96  return sc;
97 
98 
99  }
100 
101  /*----------------------------------------------------------------------------------*/
103  /*----------------------------------------------------------------------------------*/
104  {
105 
106  StatusCode sc = StatusCode::SUCCESS;
107 
108  ATH_MSG_DEBUG( "MuonEventInfoMonTool::EventInfo Monitoring Histograms being filled" );
109 
110  //Retrieve all ingredients needed to build an MuonDQAMonitoringEvent
112  return sc;
113  }
114  /*---------------------------------------------------------*/
116  {
117 
118  StatusCode sc = StatusCode::SUCCESS;
119  ATH_MSG_VERBOSE( "MuonEventInfoMonTool::retrieveEventInfo() called" );
120 
121 
122  MuonDQAEventInfo MuonDQAeventInfo;
123 
125 
126  //Cast eventID into MuonDQAEventInfo class:
127 
128  MuonDQAeventInfo.setRunNumber( eventInfo->runNumber() ) ;
129  MuonDQAeventInfo.setEventNumber( eventInfo->eventNumber() );
130  MuonDQAeventInfo.setTimeStamp( eventInfo->timeStamp() );
131  // Number of days since 1/1/1970
132  MuonDQAeventInfo.setOffset( eventInfo->timeStamp()/(24*3600));
133 
134  MuonDQAeventInfo.setTrigType(eventInfo->level1TriggerType());
135 
136  // Get time of the day for the event and convert from seconds to hours
137  MuonDQAeventInfo.setRunTime( float( eventInfo->timeStamp() - ( ((eventInfo->timeStamp()/(24*3600))*24*3600)/3600. ) ) );
138  MuonDQAeventInfo.setLumiBlock(eventInfo->lumiBlock() );
139 
140  std::string eventTag=m_eventTag;
141  MuonDQAeventInfo.setTag( eventTag );
142 
143  ATH_MSG_DEBUG( "MuonDQAeventInfo" << MuonDQAeventInfo );
144 
145  uint l1Trig = (uint) ( eventInfo->level1TriggerType() );
146  m_hTriggerType->Fill(l1Trig);
147 
148  // Get number of events per Trigger type : 0001 Tile | 0010 RPC | 0100 TGC | 1000 CTP
149  //for(int idx = 0; idx < 0; idx++) if(l1Trig.test(idx)) m_hTriggerType->Fill(idx);
150 
151  // Fill CTP bin for exclusive CTP events only
152  //if( l1Trig == 8) m_hTriggerType->Fill(3);
153 
154  if ( m_TriggerTagAdd ) {
155 
156  if(!m_eventStore->contains<CTP_RDO>("CTP_RDO") || ! m_eventStore->contains<CTP_RIO>("CTP_RIO"))
157  {
158  return MuonDQAeventInfo;
159  }
160 
161  const CTP_RDO* ctpRDO = nullptr;
162  sc = m_eventStore->retrieve( ctpRDO, "CTP_RDO" );
163  if ( sc.isFailure() ) {
164  ATH_MSG_WARNING( "CTP_RDO trigger info missing, not added to EventTag" );
165  return MuonDQAeventInfo;
166  }
167 
168  const CTP_RIO* ctpRIO = nullptr;
169  sc = m_eventStore->retrieve( ctpRIO, "CTP_RIO" );
170  if ( sc.isFailure() ) {
171  ATH_MSG_WARNING( "CTP_RIO trigger info missing, not added to EventTag" );
172  return MuonDQAeventInfo;
173  }
174 
176  ctp.setRDO(ctpRDO);
177  const std::vector<CTP_BC>& BCs = ctp.getBunchCrossings();
178 
179  // now get the data
180  //uint16_t l1aPos = ctpRIO->getDetectorEventType() >> 16;
181  unsigned int storeBunch = ctpRDO->getL1AcceptBunchPosition();
182 
183  //const CTP_BC& bunch = ctp.getBunchCrossings().at(l1aPos);
184  const CTP_BC& bunch = BCs.at(storeBunch);
185 
186  MuonDQAeventInfo.setNumberOfTriggerBits(bunch.getTAV().size() + bunch.getTAP().size());
187  int nth_bit(0);
188  for(unsigned int i=0; i<bunch.getTAV().size(); i++)
189  {
190  MuonDQAeventInfo.setTriggerBit(nth_bit, bunch.getTAV().test(i));
191  nth_bit++;
192  }
193  for(unsigned int i=0; i<bunch.getTAP().size(); i++)
194  {
195  MuonDQAeventInfo.setTriggerBit(nth_bit, bunch.getTAP().test(i));
196  nth_bit++;
197  }
198 
199  }
200 
201  return MuonDQAeventInfo;
202 
203  }
204 
205  // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
206 
208  {
209  StatusCode sc = StatusCode::SUCCESS;
210 
211  ATH_MSG_DEBUG( "MuonEventInfoMonTool procHist()" );
212 
213  if(endOfEventsBlockFlag()){}
214  if(endOfLumiBlockFlag()){}
215  if(endOfRunFlag()){
216  } // isEndOfRun
217 
218  return sc;
219  }
221 
222  //Retrieve all ingredients needed to build an MuonDQAEvent
223  MuonDQAEventInfo eventInfo = retrieveEventInfo();
224  MuonDQAEvent* event = new MuonDQAEvent();
225  event->setMuonDQAEventInfo( eventInfo );
226  return event;
227  }
228 }//end namespace MuonDQA
CTP_RIO
Definition: CTP_RIO.h:22
MuonDQA::MuonEventInfoMonTool::m_hTriggerType
TH1F * m_hTriggerType
Definition: MuonEventInfoMonTool.h:67
MuonDQA::MuonEventInfoMonTool::initialize
virtual StatusCode initialize() override
Definition: MuonEventInfoMonTool.cxx:42
CTP_Decoder.h
StoreGateSvc::contains
bool contains(const TKEY &key) const
Look up a keyed object in TDS (compare also tryRetrieve) returns false if object not available in TDS...
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::EventInfo_v1::eventNumber
uint64_t eventNumber() const
The current event's event number.
ManagedMonitorToolBase::newEventsBlockFlag
bool newEventsBlockFlag() const
Definition: ManagedMonitorToolBase.h:855
MuonDQA
Definition: MuonDQAEvent.cxx:9
MuonDQA::MuonEventInfoMonTool::m_TriggerTagAdd
bool m_TriggerTagAdd
property toggling if the Trigger type should be added to the EventTag
Definition: MuonEventInfoMonTool.h:63
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
CTP_BC::getTAV
const std::bitset< 512 > & getTAV() const
get bitset of TAV words
Definition: CTP_Decoder.h:115
MuonEventInfoMonTool.h
MuonDQA::MuonEventInfoMonTool::m_eventTag
std::string m_eventTag
tag of the event, describing reconstruction mechanism
Definition: MuonEventInfoMonTool.h:65
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ManagedMonitorToolBase::endOfLumiBlockFlag
bool endOfLumiBlockFlag() const
Definition: ManagedMonitorToolBase.h:858
MuonDQA::MuonEventInfoMonTool::MuonEventInfoMonTool
MuonEventInfoMonTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MuonEventInfoMonTool.cxx:31
MuonDQA::MuonEventInfoMonTool::retrieveEvent
const MuonDQAEvent * retrieveEvent()
retrieve event information from storegate and convert to MuonRawDQAEventInfo
Definition: MuonEventInfoMonTool.cxx:220
MuonDQA::MuonEventInfoMonTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: MuonEventInfoMonTool.h:70
MuonDQA::MuonEventInfoMonTool::fillHistograms
virtual StatusCode fillHistograms() override
An inheriting class should either override this function or fillHists().
Definition: MuonEventInfoMonTool.cxx:102
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonDQAEvent.h
xAOD::EventInfo_v1::runNumber
uint32_t runNumber() const
The current event's run number.
MuonDQA::MuonEventInfoMonTool::m_eventStore
StoreGateSvc * m_eventStore
Definition: MuonEventInfoMonTool.h:58
CTP_Decoder
Definition: CTP_Decoder.h:142
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
MuonDQA::MuonDQAEventInfo::setTimeStamp
void setTimeStamp(const unsigned int time_stamp)
sets timestamp
Definition: MuonDQAEventInfo.h:82
StoreGateSvc::retrieve
StatusCode retrieve(const T *&ptr) const
Retrieve the default object into a const T*.
MuonDQA::MuonDQAEventInfo::setLumiBlock
void setLumiBlock(const unsigned int lumi_block)
sets LumiBlock
Definition: MuonDQAEventInfo.h:86
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
ManagedMonitorToolBase::MonGroup
A container of information describing a monitoring object.
Definition: ManagedMonitorToolBase.h:138
MuonDQA::MuonDQAEventInfo::setTag
void setTag(const std::string &tag)
sets reconstruction tag
Definition: MuonDQAEventInfo.h:88
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:669
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
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
LogFileMsgStream.h
CTP_BC
Definition: CTP_Decoder.h:17
MuonDQA::MuonDQAEventInfo::setTriggerBit
void setTriggerBit(unsigned int n, bool bit)
Definition: MuonDQAEventInfo.h:91
MuonDQA::MuonEventInfoMonTool::bookHistograms
virtual StatusCode bookHistograms() override
An inheriting class should either override this function or bookHists().
Definition: MuonEventInfoMonTool.cxx:58
MuonDQA::MuonDQAEventInfo::setRunTime
void setRunTime(const float running_time)
sets ns_Offset
Definition: MuonDQAEventInfo.h:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaMonManager.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonDQA::MuonEventInfoMonTool::m_lastEvent
int m_lastEvent
Definition: MuonEventInfoMonTool.h:62
run
Definition: run.py:1
ManagedMonitorToolBase::ATTRIB_MANAGED
@ ATTRIB_MANAGED
Definition: ManagedMonitorToolBase.h:131
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
ManagedMonitorToolBase::endOfEventsBlockFlag
bool endOfEventsBlockFlag() const
Definition: ManagedMonitorToolBase.h:856
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
ManagedMonitorToolBase::MonGroup::regHist
StatusCode regHist(TH1 *h)
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
Definition: ManagedMonitorToolBase.cxx:195
MuonDQA::MuonDQAEventInfo
Definition: MuonDQAEventInfo.h:39
MuonDQA::MuonDQAEvent
Definition: MuonDQAEvent.h:28
CTP_BC::getTAP
const std::bitset< 512 > & getTAP() const
get bitset of TAP words
Definition: CTP_Decoder.h:106
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonDQA::MuonDQAEventInfo::setNumberOfTriggerBits
void setNumberOfTriggerBits(unsigned int n)
Definition: MuonDQAEventInfo.h:90
CTP_RIO.h
MuonDQA::MuonDQAEventInfo::setOffset
void setOffset(const unsigned int ns_Offset)
sets ns_Offset
Definition: MuonDQAEventInfo.h:83
CTP_RDO::getL1AcceptBunchPosition
uint32_t getL1AcceptBunchPosition() const
Definition: CTP_RDO.cxx:94
TriggerTest.ctp
ctp
Retrieve trigger EDM objects.
Definition: TriggerTest.py:14
CTP_RDO.h
CTP_RDO
Definition: CTP_RDO.h:20
MuonDQA::MuonDQAEventInfo::setTrigType
void setTrigType(const std::bitset< 8 > &trig_Type)
sets Trigger Type
Definition: MuonDQAEventInfo.h:84
MuonDQA::MuonDQAEventInfo::setRunNumber
void setRunNumber(const unsigned int run_number)
sets runnumber
Definition: MuonDQAEventInfo.h:80
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
ManagedMonitorToolBase::endOfRunFlag
bool endOfRunFlag() const
Definition: ManagedMonitorToolBase.h:859
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MuonDQA::MuonEventInfoMonTool::retrieveEventInfo
MuonDQAEventInfo retrieveEventInfo()
retrieve event information from storegate and convert to MuonCalibEventInfo
Definition: MuonEventInfoMonTool.cxx:115
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
xAOD::EventInfo_v1::timeStamp
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
MuonDQA::MuonDQAEventInfo::setEventNumber
void setEventNumber(const unsigned int event_number)
sets eventnumber
Definition: MuonDQAEventInfo.h:81
ReadHandle.h
Handle class for reading from StoreGate.
ManagedMonitorToolBase::newLumiBlockFlag
bool newLumiBlockFlag() const
Definition: ManagedMonitorToolBase.h:853
StoreGateSvc.h
MuonDQA::MuonEventInfoMonTool::procHistograms
virtual StatusCode procHistograms() override
An inheriting class should either override this function or finalHists().
Definition: MuonEventInfoMonTool.cxx:207
ManagedMonitorToolBase::newRunFlag
bool newRunFlag() const
Definition: ManagedMonitorToolBase.h:854