ATLAS Offline Software
Loading...
Searching...
No Matches
LArCellBuilderFromLArRawChannelTool Class Reference

Building LArCell objects from LArRawChannel. More...

#include <LArCellBuilderFromLArRawChannelTool.h>

Inheritance diagram for LArCellBuilderFromLArRawChannelTool:
Collaboration diagram for LArCellBuilderFromLArRawChannelTool:

Public Member Functions

virtual ~LArCellBuilderFromLArRawChannelTool ()=default
 Destructor, deletes the MsgService.
virtual StatusCode initialize () override
 Initialize method.
virtual StatusCode process (CaloCellContainer *theCellContainer, const EventContext &ctx) const override
 process method as defined in ICaloCellMaker interface

Private Attributes

SG::ReadHandleKey< LArRawChannelContainerm_rawChannelsKey {this,"RawChannelsName","LArRawChannels","Name of input container"}
 rdo container name (jO)
Gaudi::Property< bool > m_addDeadOTX {this,"addDeadOTX",true,"Add dummy cells for missing FEBs"}
 activate addition of missing cells from dead OTX
Gaudi::Property< int > m_initialDataPoolSize {this,"InitialCellPoolSize",-1,"Initial size of the DataPool<LArCells> (-1: Use nCells)"}
 Initial size of DataPool<LArCell>
unsigned m_nTotalCells =0
 Number of cells, set in Initialize()
SG::ReadCondHandleKey< LArOnOffIdMappingm_cablingKey {this,"LArCablingKey","LArOnOffIdMap","Key of conditions data object holding cabling"}
const LArOnlineIDm_onlineID =nullptr
const CaloCell_IDm_caloCID =nullptr
SG::ReadCondHandleKey< LArBadFebContm_missingFebKey {this,"MissingFebKey","LArBadFeb","Key of conditions data object holding bad-feb info"}
SG::ReadCondHandleKey< CaloDetDescrManagerm_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager"}

Detailed Description

Building LArCell objects from LArRawChannel.

An AlgTool class to create a CaloCellContainer out of a LArRawChannel container.

AlgTool properties (name defined in cxx file): RawChannelsName : input RawChannelContainer EThreshold: energy threshold

Modified: Dec 4, 2002 Hong Ma Use MakeLArCellFromRaw to make LArCell. Modified: June 2, 2004, David Rousseau : converted to AlgTool

Inherits from ICaloCellMakerTool and should be called by an instance of the CaloCellMaker algorithm.

Definition at line 52 of file LArCellBuilderFromLArRawChannelTool.h.

Constructor & Destructor Documentation

◆ ~LArCellBuilderFromLArRawChannelTool()

virtual LArCellBuilderFromLArRawChannelTool::~LArCellBuilderFromLArRawChannelTool ( )
virtualdefault

Destructor, deletes the MsgService.

Member Function Documentation

◆ initialize()

StatusCode LArCellBuilderFromLArRawChannelTool::initialize ( )
overridevirtual

Initialize method.

Returns
Gaudi status code.

Initialazes pointers to servies and private members variable. Sets the m_subCalo variable based on the m_lArRegion jobOption. Computes the total number of cells based on the subcalo hash-range.

Definition at line 31 of file LArCellBuilderFromLArRawChannelTool.cxx.

31 {
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
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
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ process()

StatusCode LArCellBuilderFromLArRawChannelTool::process ( CaloCellContainer * theCellContainer,
const EventContext & ctx ) const
overridevirtual

process method as defined in ICaloCellMaker interface

Parameters
theCellContainerPointer to the CaloCellContainer we are working on
ctxThe event context.
Returns
Gaudi status code.

Definition at line 74 of file LArCellBuilderFromLArRawChannelTool.cxx.

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
82 SG::ReadHandle<LArRawChannelContainer> rawColl(m_rawChannelsKey, ctx);
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
106 DataPool<LArCell> pool (ctx,m_initialDataPoolSize);
107
108 SG::ReadCondHandle<LArOnOffIdMapping> cablingHdl(m_cablingKey, ctx);
109 const LArOnOffIdMapping* cabling=*cablingHdl;
110
111 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey,ctx};
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) {
151 SG::ReadCondHandle<LArBadFebCont> missingFebHdl(m_missingFebKey, ctx);
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_MSG_WARNING(x)
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
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.
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
@ LARHIGHGAIN
Definition CaloGain.h:18
@ OWN_ELEMENTS
this data object owns its elements
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.

Member Data Documentation

◆ m_addDeadOTX

Gaudi::Property<bool> LArCellBuilderFromLArRawChannelTool::m_addDeadOTX {this,"addDeadOTX",true,"Add dummy cells for missing FEBs"}
private

activate addition of missing cells from dead OTX

Definition at line 89 of file LArCellBuilderFromLArRawChannelTool.h.

89{this,"addDeadOTX",true,"Add dummy cells for missing FEBs"};

◆ m_cablingKey

SG::ReadCondHandleKey<LArOnOffIdMapping> LArCellBuilderFromLArRawChannelTool::m_cablingKey {this,"LArCablingKey","LArOnOffIdMap","Key of conditions data object holding cabling"}
private

Definition at line 96 of file LArCellBuilderFromLArRawChannelTool.h.

96{this,"LArCablingKey","LArOnOffIdMap","Key of conditions data object holding cabling"};

◆ m_caloCID

const CaloCell_ID* LArCellBuilderFromLArRawChannelTool::m_caloCID =nullptr
private

Definition at line 98 of file LArCellBuilderFromLArRawChannelTool.h.

◆ m_caloMgrKey

SG::ReadCondHandleKey<CaloDetDescrManager> LArCellBuilderFromLArRawChannelTool::m_caloMgrKey {this,"CaloDetDescrManager", "CaloDetDescrManager"}
private

Definition at line 101 of file LArCellBuilderFromLArRawChannelTool.h.

101{this,"CaloDetDescrManager", "CaloDetDescrManager"};

◆ m_initialDataPoolSize

Gaudi::Property<int> LArCellBuilderFromLArRawChannelTool::m_initialDataPoolSize {this,"InitialCellPoolSize",-1,"Initial size of the DataPool<LArCells> (-1: Use nCells)"}
private

Initial size of DataPool<LArCell>

Definition at line 90 of file LArCellBuilderFromLArRawChannelTool.h.

90{this,"InitialCellPoolSize",-1,"Initial size of the DataPool<LArCells> (-1: Use nCells)"};

◆ m_missingFebKey

SG::ReadCondHandleKey<LArBadFebCont> LArCellBuilderFromLArRawChannelTool::m_missingFebKey {this,"MissingFebKey","LArBadFeb","Key of conditions data object holding bad-feb info"}
private

Definition at line 99 of file LArCellBuilderFromLArRawChannelTool.h.

99{this,"MissingFebKey","LArBadFeb","Key of conditions data object holding bad-feb info"};

◆ m_nTotalCells

unsigned LArCellBuilderFromLArRawChannelTool::m_nTotalCells =0
private

Number of cells, set in Initialize()

Definition at line 93 of file LArCellBuilderFromLArRawChannelTool.h.

◆ m_onlineID

const LArOnlineID* LArCellBuilderFromLArRawChannelTool::m_onlineID =nullptr
private

Definition at line 97 of file LArCellBuilderFromLArRawChannelTool.h.

◆ m_rawChannelsKey

SG::ReadHandleKey<LArRawChannelContainer> LArCellBuilderFromLArRawChannelTool::m_rawChannelsKey {this,"RawChannelsName","LArRawChannels","Name of input container"}
private

rdo container name (jO)

Definition at line 88 of file LArCellBuilderFromLArRawChannelTool.h.

88{this,"RawChannelsName","LArRawChannels","Name of input container"};

The documentation for this class was generated from the following files: