ATLAS Offline Software
Loading...
Searching...
No Matches
LArCellBuilderFromLArRawChannelTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5
6// implementation of LArCellBuilderFromLArRawChannelTool
7// H.Ma Mar 2001
8
9// Updated Jun 10, 2001. H. Ma
10// made a tool June 2, 2004 D. Rousseau
11// Major overhaul, Feb 2008, W.Lampl
12// Migrate to athenaMT, March 2018, W.Lampl
13
14
16#include "LArRecEvent/LArCell.h"
23
26#include "GaudiKernel/SystemOfUnits.h"
27
28#include <bitset>
29
30
32
33 ATH_CHECK(m_rawChannelsKey.initialize());
34
35 ATH_CHECK( detStore()->retrieve (m_caloCID, "CaloCell_ID") );
36
37 ATH_CHECK( m_cablingKey.initialize() );
38 ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
39
40 if (!m_missingFebKey.key().empty()) {
41 ATH_CHECK( m_missingFebKey.initialize() );
42 }
43 else {
44 if (m_addDeadOTX) {
45 ATH_MSG_ERROR( "Configuration problem: 'addDeadOTX' set, but no missing FEB container given." );
46 return StatusCode::FAILURE;
47 }
48 }
49
50 ATH_CHECK(m_caloMgrKey.initialize());
51
52 //Compute total number of cells
54
55 IdentifierHash caloCellMin, caloCellMax ;
56 m_caloCID->calo_cell_hash_range(CaloCell_ID::LAREM,caloCellMin,caloCellMax);
57 m_nTotalCells+=caloCellMax-caloCellMin;
58 m_caloCID->calo_cell_hash_range(CaloCell_ID::LARHEC,caloCellMin,caloCellMax);
59 m_nTotalCells+=caloCellMax-caloCellMin;
60 m_caloCID->calo_cell_hash_range(CaloCell_ID::LARFCAL,caloCellMin,caloCellMax);
61 m_nTotalCells+=caloCellMax-caloCellMin;
62
64 ATH_MSG_DEBUG("Initial size of DataPool<LArCell>: " << m_initialDataPoolSize);
65
66 ATH_MSG_DEBUG("Initialisating finished");
67 return StatusCode::SUCCESS;
68}
69
70
71
72// ========================================================================================== //
73StatusCode
75 const EventContext& ctx) const
76{
77 if (theCellContainer->ownPolicy() == SG::OWN_ELEMENTS) {
78 ATH_MSG_ERROR( "Called with a CaloCellContainer with wrong ownership policy! Need a VIEW container!" );
79 return StatusCode::FAILURE;
80 }
81
83 if(!rawColl.isValid()) {
84 ATH_MSG_ERROR( " Can not retrieve LArRawChannelContainer: "
85 << m_rawChannelsKey.key() );
86 return StatusCode::FAILURE;
87 }
88
89 const size_t nRawChannels=rawColl->size();
90 if (nRawChannels==0) {
91 ATH_MSG_WARNING( "Got empty LArRawChannel container. Do nothing" );
92 return StatusCode::SUCCESS;
93 }
94 else
95 ATH_MSG_DEBUG("Got " << nRawChannels << " LArRawChannels");
96
97
98 unsigned nCellsAdded=0;
99 std::bitset<CaloCell_ID::NSUBCALO> includedSubcalos;
100 // resize calo cell container to correct size
101 if (!theCellContainer->empty()) {
102 ATH_MSG_WARNING( "Container should be empty! Clear now.");
103 theCellContainer->clear();
104 }
105
107
109 const LArOnOffIdMapping* cabling=*cablingHdl;
110
112 const CaloDetDescrManager* caloDDM = *caloMgrHandle;
113
114 theCellContainer->resize(m_nTotalCells);
115
116 for (const LArRawChannel& rawChan : *rawColl) {
117 const HWIdentifier hwid=rawChan.channelID();
118 const IdentifierHash onlHash=m_onlineID->channel_Hash(hwid);
119 if( cabling->isOnlineConnectedFromHash(onlHash)) {
120 const IdentifierHash oflHash= cabling->oflHashFromOnlHash(onlHash);
121 const Identifier id=m_caloCID->cell_id(oflHash);
122 const CaloDetDescrElement * theDDE=caloDDM->get_element(oflHash);
123
124 LArCell *pCell = pool.nextElementPtr();
125
126 *pCell = LArCell (theDDE,
127 id,
128 rawChan.energy(),
129 rawChan.time()*Gaudi::Units::picosecond/Gaudi::Units::nanosecond, // convert time from ps (LArRawChannel) to ns
130 rawChan.quality(),
131 rawChan.provenance(),
132 rawChan.gain());
133
134 if ((*theCellContainer)[oflHash]) {
135 ATH_MSG_WARNING("Channel added twice! Data corruption? hash="
136 << oflHash << " online ID=0x" << std::hex
137 << hwid.get_identifier32().get_compact() << std::dec
138 << " " << m_onlineID->channel_name(hwid));
139 } else {
140 (*theCellContainer)[oflHash] = pCell;
141 ++nCellsAdded;
142 includedSubcalos.set(m_caloCID->sub_calo(oflHash));
143 }
144 }//end if connected
145 }//end loop over LArRawChannelContainer
146
147 //Now add in dummy cells (if requested)
148 unsigned nMissingButPresent=0;
149
150 if (m_addDeadOTX) {
152 const LArBadFebCont::BadChanVec& allMissingFebs=(*missingFebHdl)->fullCont();
153
154 for (const LArBadFebCont::BadChanEntry& it : allMissingFebs) {
155 const LArBadFeb& febstatus=it.second;
156 if (febstatus.deadReadout() || febstatus.deadAll() || febstatus.deactivatedInOKS() ) {
157 const HWIdentifier febId(it.first);
158 //Loop over channels belonging to this FEB
159 const int chansPerFeb=m_onlineID->channelInSlotMax(febId);
160 for (int ch=0; ch<chansPerFeb; ++ch) {
161 const HWIdentifier hwid = m_onlineID->channel_Id(febId, ch);
162 if ( cabling->isOnlineConnected(hwid)) {
163 const Identifier id=cabling->cnvToIdentifier(hwid);
164 const IdentifierHash hashid= m_caloCID->calo_cell_hash(id);
165 const CaloDetDescrElement * theDDE=caloDDM->get_element(hashid);
166 LArCell *pCell = pool.nextElementPtr();
167 *pCell = LArCell (theDDE,
168 id,
169 0.0, //energy
170 0.0, //time
171 0.0, //quality;
172 0x0A00, // 0x0800 (dead) + 0x0200 (to indicate missing readout)
174
175
176 if ((*theCellContainer)[hashid]) {
177 ++nMissingButPresent;
178 ATH_MSG_DEBUG("The supposedly missing channel with online ID=0x" << std::hex
179 << hwid.get_identifier32().get_compact() << std::dec
180 << " " << m_onlineID->channel_name(hwid)
181 << " is actually present in the LArRawChannel container");
182 }
183 else {
184 (*theCellContainer)[hashid]=pCell;
185 ++nCellsAdded;
186 includedSubcalos.set(m_caloCID->sub_calo(hashid));
187 }
188 }//end if connected
189 }//end loop over channels of one missing FEB
190 }//end if is dead/missing FEB
191 }//end loop over bad/missing FEBs
192 }//end if m_addDeadOTX
193
194 //Set the 'hasCalo' variable of CaloCellContainer
195 for (int iCalo=0;iCalo<CaloCell_ID::NSUBCALO;++iCalo) {
196 if (includedSubcalos.test(iCalo))
197 theCellContainer->setHasCalo(static_cast<CaloCell_ID::SUBCALO>(iCalo));
198 }
199
200 if (nMissingButPresent)
201 ATH_MSG_WARNING( "A total of " << nMissingButPresent
202 << " supposedly missing channels where present in the LArRawChannelContainer" );
203
204 if (nCellsAdded!=m_nTotalCells) {
205 ATH_MSG_DEBUG("Filled only " << nCellsAdded << " out of " << m_nTotalCells << " cells. Removing holes");
206 auto end1=std::remove(theCellContainer->begin(),theCellContainer->end(),nullptr);
207 theCellContainer->erase(end1,theCellContainer->end());
208 ATH_MSG_DEBUG("Shrunk the cell container to " << theCellContainer->size() << " (" << m_nTotalCells-nCellsAdded << " cells missing)");
209 }//end if nCellsAdded!=m_nTotalCells
210 else
211 ATH_MSG_DEBUG("All " << nCellsAdded << " cells filled (no holes)");
212
213 return StatusCode::SUCCESS;
214}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Definition of CaloDetDescrManager.
Definition of CaloDetDescriptor.
Handle class for reading from StoreGate.
Container class for CaloCell.
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
void resize(size_type sz)
Resizes the collection to the specified number of elements.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
iterator erase(iterator position)
Remove element at a given position.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
SG::OwnershipPolicy ownPolicy() const
Return the ownership policy setting for this container.
size_type size() const noexcept
Returns the number of elements in the collection.
void clear()
Erase all the elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
bool deadAll() const
FEB is completely missing, e.g. powered off.
Definition LArBadFeb.h:30
bool deactivatedInOKS() const
Deactivated in OKS.
Definition LArBadFeb.h:39
bool deadReadout() const
FEB is not sending readout data, but the L1 trigger path is working.
Definition LArBadFeb.h:33
std::vector< BadChanEntry > BadChanVec
std::pair< ChanId_t, LArBadFeb > BadChanEntry
unsigned m_nTotalCells
Number of cells, set in Initialize()
Gaudi::Property< bool > m_addDeadOTX
activate addition of missing cells from dead OTX
SG::ReadCondHandleKey< LArBadFebCont > m_missingFebKey
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelsKey
rdo container name (jO)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Gaudi::Property< int > m_initialDataPoolSize
Initial size of DataPool<LArCell>
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode initialize() override
Initialize method.
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
process method as defined in ICaloCellMaker interface
Data object for LAr calorimeter readout cell.
Definition LArCell.h:53
Liquid Argon ROD output object base class.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
@ LARHIGHGAIN
Definition CaloGain.h:18
@ OWN_ELEMENTS
this data object owns its elements
pool namespace
Definition libname.h:15
DataModel_detail::iterator< DVL > remove(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, const T &value)
Specialization of remove for DataVector/List.