ATLAS Offline Software
FindDuplicatedLArDigits.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 
9 #include "GaudiKernel/SmartDataPtr.h"
13 
15 #include <fstream>
16 
17 
18 
19 FindDuplicatedLArDigits::FindDuplicatedLArDigits(const std::string& name, ISvcLocator* pSvcLocator)
20  : AthAlgorithm(name, pSvcLocator),
21  m_nProblemEvent(0),
22  m_onlineHelper(0),
23  m_emId(0),
24  m_hecId(0),
25  m_fcalId(0)
26 {
27  declareProperty("ContainerKey",m_contKey);
28  m_nDigits=-1;
29 }
30 
32 {}
33 
35 {
36  const CaloCell_ID* idHelper = nullptr;
37  ATH_CHECK( detStore()->retrieve (idHelper, "CaloCell_ID") );
38  m_emId=idHelper->em_idHelper();
39  m_fcalId=idHelper->fcal_idHelper();
40  m_hecId=idHelper->hec_idHelper();
41 
42  if (!m_emId) {
43  ATH_MSG_ERROR ( "Could not access lar EM ID helper" );
44  return StatusCode::FAILURE;
45  }
46  if (!m_fcalId) {
47  ATH_MSG_ERROR ( "Could not access lar FCAL ID helper" );
48  return StatusCode::FAILURE;
49  }
50  if (!m_hecId) {
51  ATH_MSG_ERROR ( "Could not access lar HEC ID helper" );
52  return StatusCode::FAILURE;
53  }
54 
55 
56  ATH_CHECK( detStore()->retrieve(m_onlineHelper, "LArOnlineID") );
57  ATH_MSG_DEBUG ( " Found the LArOnlineID helper. " );
58 
60  return StatusCode::SUCCESS;
61 }
62 
64 {
65  // Retrieve EventInfo
66  const xAOD::EventInfo* thisEventInfo;
67  StatusCode sc=evtStore()->retrieve(thisEventInfo);
68  unsigned eventnumber=0;
69  if (sc!=StatusCode::SUCCESS)
70  ATH_MSG_WARNING ( "No EventInfo object found!" );
71  else {
72  eventnumber=thisEventInfo->eventNumber();
73  }
74 
75  // Retrieve LArDigitContainer
76  const LArDigitContainer* digit_cont;
77  if (m_contKey.size())
78  ATH_CHECK( evtStore()->retrieve(digit_cont,m_contKey) );
79  else
80  ATH_CHECK( evtStore()->retrieve(digit_cont) );
81  ATH_MSG_DEBUG ( "Retrieved LArDigitContainer from StoreGate! key=" << m_contKey );
82 
83  int nDigits=digit_cont->size();
84  if (m_nDigits==-1 || m_nDigits==nDigits) { //first event or no change
85  ATH_MSG_DEBUG ( "Event " << eventnumber << ": Found " << nDigits << " Digits in container" );
86  }
87  else {
88  ATH_MSG_ERROR ( "Event " << eventnumber << ": Size of digit container changed! Now: " << nDigits << " Previous Event: " << m_nDigits );
89  }
90  m_nDigits=nDigits;
91  m_bitpattern.reset();
93  LArDigitContainer::const_iterator it_e = digit_cont->end();
94  unsigned nDoubleDigits=0;
95  for(; it!=it_e; ++it){
96  const HWIdentifier hwid=(*it)->channelID();//hardwareID();
98  if (m_bitpattern.test(h)) {
99  int barrel_ec = m_onlineHelper->barrel_ec(hwid);
100  std::string bc;
101  if (barrel_ec==0)
102  bc="Barrel";
103  else if (barrel_ec==1)
104  bc="Endcap";
105  else
106  bc="unknown";
107 
108  int pos_neg = m_onlineHelper->pos_neg(hwid);
109  std::string pn;
110  if (pos_neg==0)
111  pn="C-Side";
112  else if (pos_neg==1)
113  pn="A-Side";
114  else
115  pn="unknown";
116 
117  int FT = m_onlineHelper->feedthrough(hwid);
118  int slot = m_onlineHelper->slot(hwid);
119  int channel = m_onlineHelper->channel(hwid);
120  ATH_MSG_ERROR ( "Event " << eventnumber << " Found duplicated cell! Location: (" << bc << "/" << pn << "/FT="
121  << FT << "/Slot=" << slot << "/Channel=" << channel << ")" );
122  nDoubleDigits++;
123  }
124  m_bitpattern.set(h);
125  }
126  if (nDoubleDigits) {
127  m_nProblemEvent++;
128  ATH_MSG_ERROR ( "Found " << nDoubleDigits << " duplicated digits in event " << eventnumber );
129  //return StatusCode::RECOVERABLE;
130  }
131  return StatusCode::SUCCESS;
132 }// end finalize-method.
133 
134 
136  if (m_nProblemEvent)
137  ATH_MSG_ERROR ( "Found " << m_nProblemEvent << " Events with duplicated LArDigits" );
138  else
139  ATH_MSG_INFO ( "No duplicated LArDigits found." );
140  return StatusCode::SUCCESS;
141 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
FindDuplicatedLArDigits::m_contKey
std::string m_contKey
Definition: FindDuplicatedLArDigits.h:47
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
FindDuplicatedLArDigits::m_nProblemEvent
unsigned m_nProblemEvent
Definition: FindDuplicatedLArDigits.h:49
FindDuplicatedLArDigits::execute
StatusCode execute()
Definition: FindDuplicatedLArDigits.cxx:63
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
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.
CaloCell_ID::em_idHelper
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition: CaloCell_ID.h:63
FindDuplicatedLArDigits::initialize
StatusCode initialize()
Definition: FindDuplicatedLArDigits.cxx:34
FindDuplicatedLArDigits.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
FindDuplicatedLArDigits::finalize
StatusCode finalize()
Definition: FindDuplicatedLArDigits.cxx:135
skel.it
it
Definition: skel.GENtoEVGEN.py:396
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:1957
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:1938
FindDuplicatedLArDigits::m_nDigits
int m_nDigits
Definition: FindDuplicatedLArDigits.h:50
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
CaloCell_ID::hec_idHelper
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition: CaloCell_ID.h:69
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
python.ZdcRecConfig.pn
pn
Definition: ZdcRecConfig.py:524
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
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:1963
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
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
FindDuplicatedLArDigits::m_bitpattern
std::bitset< 200000 > m_bitpattern
Definition: FindDuplicatedLArDigits.h:48
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:1950
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
AthAlgorithm
Definition: AthAlgorithm.h:47
FindDuplicatedLArDigits::m_emId
const LArEM_ID * m_emId
Definition: FindDuplicatedLArDigits.h:53
FindDuplicatedLArDigits::m_hecId
const LArHEC_ID * m_hecId
Definition: FindDuplicatedLArDigits.h:54
LArFebHeaderContainer.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
FindDuplicatedLArDigits::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: FindDuplicatedLArDigits.h:51
LArDigitContainer.h
FindDuplicatedLArDigits::m_fcalId
const LArFCAL_ID * m_fcalId
Definition: FindDuplicatedLArDigits.h:55
EventInfo.h
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:124
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:1944
h
ILArPedestal.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
FindDuplicatedLArDigits::FindDuplicatedLArDigits
FindDuplicatedLArDigits(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FindDuplicatedLArDigits.cxx:19
LArDigitContainer
Container class for LArDigit.
Definition: LArDigitContainer.h:24
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloGain.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
CaloCell_ID::fcal_idHelper
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition: CaloCell_ID.h:75
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
FindDuplicatedLArDigits::~FindDuplicatedLArDigits
~FindDuplicatedLArDigits()
Definition: FindDuplicatedLArDigits.cxx:31