ATLAS Offline Software
RpcLv1RawDataEfficiency.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // Package : RpcLv1RawDataEfficiency
7 // Author: Ulrike Schnoor (ulrike.schnoor@cern.ch) - P. Anger (panger@cern.ch)
8 //
9 // DESCRIPTION:
10 // Subject: RPCLV1--> Efficiency Offline Muon Data Quality
11 // RPCLv1 Sector Hits vs LB
13 
15 
16 #include <inttypes.h>
17 
18 #include <sstream>
19 
26 #include "StoreGate/DataHandle.h"
27 
28 //================================================================================================================================
30  const std::string& name,
31  const IInterface* parent)
33  declareProperty("isMC", m_isMC = false);
34 }
35 
36 //================================================================================================================================
39  ATH_MSG_INFO("In initializing 'RpcLv1RawDataEfficiency'");
40 
41  m_trigtype = 0;
42  m_event = 0;
43  m_lumiblock = 0;
44  m_BCID = 0;
45  m_rpclv1_sectorhits_A[0] = nullptr;
46  m_rpclv1_sectorhits_C[0] = nullptr;
47  m_rpclv1_sectorhits_all[0] = nullptr;
48  m_rpclv1_sectorhits_A[1] = nullptr;
49  m_rpclv1_sectorhits_C[1] = nullptr;
50  m_rpclv1_sectorhits_all[1] = nullptr;
51  m_rpclv1_sectorhits_A[2] = nullptr;
52  m_rpclv1_sectorhits_C[2] = nullptr;
53  m_rpclv1_sectorhits_all[2] = nullptr;
54  m_rpclv1_sectorhits_A[3] = nullptr;
55  m_rpclv1_sectorhits_C[3] = nullptr;
56  m_rpclv1_sectorhits_all[3] = nullptr;
57  m_rpclv1_sectorhits_A[4] = nullptr;
58  m_rpclv1_sectorhits_C[4] = nullptr;
59  m_rpclv1_sectorhits_all[4] = nullptr;
60  m_rpclv1_sectorhits_A[5] = nullptr;
61  m_rpclv1_sectorhits_C[5] = nullptr;
62  m_rpclv1_sectorhits_all[5] = nullptr;
63 
64  ATH_CHECK(m_idHelperSvc.retrieve());
65  // MuonDetectorManager from the conditions store
67  ATH_MSG_DEBUG("Found the MuonDetectorManager from detector store.");
68 
69  ATH_CHECK(m_rpcCoinKey.initialize());
72  return StatusCode::SUCCESS;
73 }
74 
75 //================================================================================================================================
76 // Reads RPC coincidence data from container into vectors for use in filling
77 // histograms
78 //================================================================================================================================
80  ATH_MSG_DEBUG("Reading RpcCoincidenceContainer... ");
81 
84  // Muon::RpcCoinDataCollection::const_iterator it_collection;
85  Identifier prdcoll_id;
86  const MuonGM::RpcReadoutElement* descriptor_Atl;
87  double x_atlas, y_atlas, z_atlas, phi_atlas, eta_atlas;
88  int irpcstationEta; // for the switch of the eta in the coin matrix
89 
90  // MuonDetectorManager from the conditions store
93  const MuonGM::MuonDetectorManager* MuonDetMgr =
94  DetectorManagerHandle.cptr();
95  if (MuonDetMgr == nullptr) {
97  "Null pointer to the read MuonDetectorManager conditions object");
98  return StatusCode::FAILURE;
99  }
100 
101  for (it_container = rpc_coin_container->begin();
102  it_container != rpc_coin_container->end(); ++it_container) {
104  (*it_container)->begin();
105  it_collection != (*it_container)->end();
106  ++it_collection) { // each collection is a trigger signal
107  ATH_MSG_DEBUG("Original RPC container: "
108  << (*it_collection)->threshold()
109  << int((*it_collection)->isLowPtCoin())
110  << int((*it_collection)->isHighPtCoin()));
111  if (int((*it_collection)->threshold()) < 1 ||
112  (*it_collection)->threshold() > 3 ||
113  (int((*it_collection)->isLowPtCoin()) +
114  int((*it_collection)->isHighPtCoin()) !=
115  1))
116  continue; // some thresholds are 99 (lowpt=highpt=0)->skip
117  CoincidenceData* coindata = new CoincidenceData;
118  coindata->SetThresholdLowHigh(
119  int((*it_collection)->threshold()),
120  int((*it_collection)->isLowPtCoin()),
121  int((*it_collection)->isHighPtCoin()));
122  prdcoll_id = (*it_collection)->identify();
123  descriptor_Atl = MuonDetMgr->getRpcReadoutElement(prdcoll_id);
124  irpcstationEta =
125  int(m_idHelperSvc->rpcIdHelper().stationEta(prdcoll_id));
126  x_atlas = descriptor_Atl->stripPos(prdcoll_id).x();
127  y_atlas = descriptor_Atl->stripPos(prdcoll_id).y();
128  z_atlas = descriptor_Atl->stripPos(prdcoll_id).z();
129  // obtaining phi coordinate:
130  if (x_atlas > 0) {
131  phi_atlas = std::atan(y_atlas / x_atlas);
132  } else if (x_atlas == 0) {
133  if (y_atlas > 0)
134  phi_atlas = CLHEP::pi / 2;
135  else
136  phi_atlas = -CLHEP::pi / 2;
137  } else {
138  if (y_atlas > 0)
139  phi_atlas = std::atan(y_atlas / x_atlas) + CLHEP::pi;
140  else
141  phi_atlas = -CLHEP::pi + std::atan(y_atlas / x_atlas);
142  }
143  // obtaining pseudorapidity coordinate
144  if (z_atlas != 0)
145  eta_atlas = -std::log(std::abs(std::tan(
146  0.5 * std::atan(std::hypot(x_atlas, y_atlas) / z_atlas))));
147  else
148  eta_atlas = 0;
149  if (irpcstationEta < 0)
150  eta_atlas = -eta_atlas;
151  coindata->SetEtaPhi(eta_atlas, phi_atlas);
152 
153  m_CoincidenceData.push_back(coindata);
154  }
155  }
156  ATH_MSG_DEBUG("Finished with reading the RpcCoinDataContainer... ");
157  return StatusCode::SUCCESS;
158 }
159 
160 //================================================================================================================================
161 // Reads the trigger type in memory
162 //================================================================================================================================
164  ATH_MSG_DEBUG("Storing Trigger Type... ");
166  ATH_MSG_DEBUG("RpcLv1RawDataEfficiency::retrieved eventInfo");
167 
168  // Protection against simulated cosmics when the trigger_info() of the
169  // event_info is not filled and returns a null pointer.
170  m_trigtype = eventInfo->level1TriggerType();
171 
172  // Get event index variables
173  m_lumiblock = eventInfo->lumiBlock();
174  m_event = eventInfo->eventNumber();
175  m_BCID = eventInfo->bcid();
176 
177  return StatusCode::SUCCESS;
178 }
179 
180 //================================================================================================================================
181 // Book the histogramms for nominator and denominator
182 //================================================================================================================================
184  ATH_MSG_INFO(
185  "Booking Sector Hits histograms for RPCLV1RawDataEfficiency... ");
186 
187  // not used yet, but commenting them out leads to "unused variables"
188  // warnings since they are passed as arguments to the function
189 
190  if (newRunFlag()) { // book all histograms per new run
191  std::string generic_path_rpclv1monitoring =
192  "Muon/MuonRawDataMonitoring/RPCLV1Efficiency";
193  MonGroup MG_SectorHits(this,
194  generic_path_rpclv1monitoring + "/SectorHits",
196 
197  // Sector hits
198  for (unsigned int iMuThreshold = 0; iMuThreshold < 6;
199  iMuThreshold++) { // threshold
200 
201  m_ss.str("");
202  m_ss << "SectorHits"
203  << "PT" << iMuThreshold + 1 << "_C";
204  m_rpclv1_sectorhits_C[iMuThreshold] = new TH2I(
205  m_ss.str().c_str(), (m_ss.str() + ";LB;Sector").c_str(), 500,
206  0., 1500., 32, 0., 32.);
207  ATH_CHECK(
208  MG_SectorHits.regHist(m_rpclv1_sectorhits_C[iMuThreshold]));
209 
210  m_ss.str("");
211  m_ss << "SectorHits"
212  << "PT" << iMuThreshold + 1 << "_A";
213  m_rpclv1_sectorhits_A[iMuThreshold] = new TH2I(
214  m_ss.str().c_str(), (m_ss.str() + ";LB;Sector").c_str(), 500,
215  0., 1500., 32, 32., 64.);
216  ATH_CHECK(
217  MG_SectorHits.regHist(m_rpclv1_sectorhits_A[iMuThreshold]));
218 
219  m_ss.str("");
220  m_ss << "SectorHits"
221  << "PT" << iMuThreshold + 1 << "_all";
222  m_rpclv1_sectorhits_all[iMuThreshold] = new TH2I(
223  m_ss.str().c_str(), (m_ss.str() + ";LB;Sector").c_str(), 500,
224  0., 1500., 64, 0., 64.);
225  ATH_CHECK(
226  MG_SectorHits.regHist(m_rpclv1_sectorhits_all[iMuThreshold]));
227  }
228  }
229 
230  return StatusCode::SUCCESS;
231 }
232 
233 //================================================================================================================================
234 // Fills the histograms for nominator and denominator
235 //================================================================================================================================
237  ATH_MSG_DEBUG("Filling histograms for RPCLv1RawDataEfficiency... ");
238 
239  // Retreive and store trigger type for this event
240  if (StoreTriggerType() != StatusCode::SUCCESS)
241  ATH_MSG_ERROR("Cannot find StoreTriggerType! ");
242 
243  // == Filling the Histograms
244  //--------------------Sector Hits---------------------------------
245  if (!m_isMC) {
246  // Retrieve the Sector Logic container
247  SG::ReadHandle<RpcSectorLogicContainer> sectorLogicContainer(
249 
251  sectorLogicContainer->begin();
252 
253  for (; it != sectorLogicContainer->end(); ++it) {
254  int i_sectorid = (*it)->sectorId();
255  // Loop over the trigger hits of each sector
256  RpcSectorLogic::const_iterator ithit = (*it)->begin();
257  for (; ithit != (*it)->end(); ++ithit) {
258  bool b_isInput = (*ithit)->isInput();
259  int i_ptid = (*ithit)->ptId();
260  if (b_isInput ==
261  true) // fill histograms only if there was a trigger hit
262  {
263  for (int iThresholdIndex = 0; iThresholdIndex < 6;
264  iThresholdIndex++) {
265  if (i_ptid == (iThresholdIndex + 1)) {
266  m_rpclv1_sectorhits_all[iThresholdIndex]->Fill(
267  m_lumiblock, i_sectorid);
268  m_rpclv1_sectorhits_A[iThresholdIndex]->Fill(
269  m_lumiblock, i_sectorid);
270  m_rpclv1_sectorhits_C[iThresholdIndex]->Fill(
271  m_lumiblock, i_sectorid);
272  }
273  }
274  }
275  }
276  }
277  }
278  return StatusCode::SUCCESS;
279 }
MuonGM::MuonDetectorManager::getRpcReadoutElement
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:168
RpcLv1RawDataEfficiency::StoreTriggerType
StatusCode StoreTriggerType()
Definition: RpcLv1RawDataEfficiency.cxx:163
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
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.
CoincidenceData::SetEtaPhi
void SetEtaPhi(float eta, float phi)
Definition: RpcLv1RawDataEfficiency.h:117
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
RpcLv1RawDataEfficiency::RpcLv1RawDataEfficiency
RpcLv1RawDataEfficiency(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RpcLv1RawDataEfficiency.cxx:29
ManagedMonitorToolBase
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
Definition: ManagedMonitorToolBase.h:74
RpcLv1RawDataEfficiency.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
RpcLv1RawDataEfficiency::m_rpclv1_sectorhits_A
std::array< TH2I *, 6 > m_rpclv1_sectorhits_A
Definition: RpcLv1RawDataEfficiency.h:190
RpcLv1RawDataEfficiency::m_ss
std::stringstream m_ss
Definition: RpcLv1RawDataEfficiency.h:167
skel.it
it
Definition: skel.GENtoEVGEN.py:423
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:54
RpcLv1RawDataEfficiency::fillHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Definition: RpcLv1RawDataEfficiency.cxx:236
MuonPrepDataContainer.h
RpcLv1RawDataEfficiency::m_event
int m_event
Definition: RpcLv1RawDataEfficiency.h:172
DataHandle.h
RpcLv1RawDataEfficiency::m_CoincidenceData
std::vector< CoincidenceData * > m_CoincidenceData
Definition: RpcLv1RawDataEfficiency.h:187
pi
#define pi
Definition: TileMuonFitter.cxx:65
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
MuonChamberNameConverter.h
RpcLv1RawDataEfficiency::readRpcCoinDataContainer
StatusCode readRpcCoinDataContainer()
Definition: RpcLv1RawDataEfficiency.cxx:79
ManagedMonitorToolBase::MonGroup
A container of information describing a monitoring object.
Definition: ManagedMonitorToolBase.h:138
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ManagedMonitorToolBase::initialize
virtual StatusCode initialize()
Definition: ManagedMonitorToolBase.cxx:669
MuonChambersRange.h
RpcLv1RawDataEfficiency::m_rpclv1_sectorhits_all
std::array< TH2I *, 6 > m_rpclv1_sectorhits_all
Definition: RpcLv1RawDataEfficiency.h:192
RpcLv1RawDataEfficiency::m_lumiblock
int m_lumiblock
Definition: RpcLv1RawDataEfficiency.h:173
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
RpcLv1RawDataEfficiency::m_trigtype
int m_trigtype
Definition: RpcLv1RawDataEfficiency.h:171
TH2I
Definition: rootspy.cxx:410
ManagedMonitorToolBase::ATTRIB_UNMANAGED
@ ATTRIB_UNMANAGED
Definition: ManagedMonitorToolBase.h:131
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MuonCosmicSetup.h
AthenaMonManager.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
IdentifiableContainerMT::end
const_iterator end() const
return const_iterator for end of container
Definition: IdentifiableContainerMT.h:242
run
Definition: run.py:1
IdentifiableContainerMT::const_iterator
Definition: IdentifiableContainerMT.h:82
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
IdentifiableContainerMT::begin
const_iterator begin() const
return const_iterator for first entry
Definition: IdentifiableContainerMT.h:236
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
MuonDQAHistMap.h
xAOD::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
RpcLv1RawDataEfficiency::m_rpcCoinKey
SG::ReadHandleKey< Muon::RpcCoinDataContainer > m_rpcCoinKey
Definition: RpcLv1RawDataEfficiency.h:178
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
RpcLv1RawDataEfficiency::bookHistogramsRecurrent
virtual StatusCode bookHistogramsRecurrent()
An inheriting class should either override this function, bookHists() or bookHistograms().
Definition: RpcLv1RawDataEfficiency.cxx:183
CoincidenceData::SetThresholdLowHigh
void SetThresholdLowHigh(int threshold, int low_pt, int high_pt)
Definition: RpcLv1RawDataEfficiency.h:112
RpcLv1RawDataEfficiency::m_rpclv1_sectorhits_C
std::array< TH2I *, 6 > m_rpclv1_sectorhits_C
Definition: RpcLv1RawDataEfficiency.h:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MuonGM::RpcReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/RpcReadoutElement.cxx:177
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:49
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
RpcLv1RawDataEfficiency::m_BCID
int m_BCID
Definition: RpcLv1RawDataEfficiency.h:174
CoincidenceData
Definition: RpcLv1RawDataEfficiency.h:90
RpcLv1RawDataEfficiency::m_eventInfo
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo
Definition: RpcLv1RawDataEfficiency.h:180
RpcLv1RawDataEfficiency::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: RpcLv1RawDataEfficiency.h:159
xAOD::EventInfo_v1::bcid
uint32_t bcid() const
The bunch crossing ID of the event.
RpcLv1RawDataEfficiency::m_isMC
bool m_isMC
Definition: RpcLv1RawDataEfficiency.h:176
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
RpcLv1RawDataEfficiency::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: RpcLv1RawDataEfficiency.h:155
RpcLv1RawDataEfficiency::m_sectorLogicContainerKey
SG::ReadHandleKey< RpcSectorLogicContainer > m_sectorLogicContainerKey
Definition: RpcLv1RawDataEfficiency.h:182
ManagedMonitorToolBase::newRunFlag
bool newRunFlag() const
Definition: ManagedMonitorToolBase.h:854
RpcLv1RawDataEfficiency::initialize
StatusCode initialize()
Definition: RpcLv1RawDataEfficiency.cxx:37