ATLAS Offline Software
Loading...
Searching...
No Matches
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
19FindDuplicatedLArDigits::FindDuplicatedLArDigits(const std::string& name, ISvcLocator* pSvcLocator)
20 : AthAlgorithm(name, pSvcLocator),
23 m_emId(0),
24 m_hecId(0),
25 m_fcalId(0)
26{
27 declareProperty("ContainerKey",m_contKey);
28 m_nDigits=-1;
29}
30
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();
97 const IdentifierHash h=m_onlineHelper->channel_Hash(hwid);
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) {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
Header file for AthHistogramAlgorithm.
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
const LArFCAL_ID * fcal_idHelper() const
access to FCAL idHelper
Definition CaloCell_ID.h:75
const LArEM_ID * em_idHelper() const
access to EM idHelper
Definition CaloCell_ID.h:63
const LArHEC_ID * hec_idHelper() const
access to HEC idHelper
Definition CaloCell_ID.h:69
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
const LArOnlineID * m_onlineHelper
FindDuplicatedLArDigits(const std::string &name, ISvcLocator *pSvcLocator)
std::bitset< 200000 > m_bitpattern
This is a "hash" representation of an Identifier.
Container class for LArDigit.
uint64_t eventNumber() const
The current event's event number.
EventInfo_v1 EventInfo
Definition of the latest event info version.