ATLAS Offline Software
LArCellMerger.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7 NAME: LArCellMerger
8 PACKAGE: offline/Calorimeter/LArCellRec
9 
10 AUTHORS: G.Unal
11 CREATION: 9 July 2009
12 
13 PURPOSE:
14 
15 ********************************************************************/
16 
17 #include "LArCellMerger.h"
18 
21 #include "Identifier/Identifier.h"
26 
27 
29 // INITIALIZE:
30 // The initialize method will create all the required algorithm objects
32 
34 
35  ATH_CHECK(detStore()->retrieve(m_calo_id,"CaloCell_ID"));
36  ATH_CHECK( detStore()->retrieve(m_onlineID, "LArOnlineID") );
38 
40 
41  return StatusCode::SUCCESS;
42 }
43 
45  return StatusCode::SUCCESS;
46 }
47 
49  const EventContext& ctx) const
50 {
51  ATH_MSG_DEBUG("in LArCellMerger::process");
52 
54  if (!rawColl.isValid()) {
55  ATH_MSG_ERROR("Failed to retrieve LArRawChannelContainer with key " <<
56  rawColl.name());
57  return StatusCode::FAILURE;
58  }
59 
61  const LArOnOffIdMapping* cabling=*larCablingHdl;
62 
63  unsigned nReplaced=0;
64 
65  // loop over raw channel container
66  // as this new container is supposed to contain only few cells, we do a simple loop and the basics onlineId to offlineId conversion
67  // this could be a little slow if by mistake this container contains all cells (not what this tool is supposed to be used for)
68  for ( const LArRawChannel& theRawChannel : *rawColl ) {
69  const HWIdentifier hwid=theRawChannel.channelID();
70  const IdentifierHash onlHash=m_onlineID->channel_Hash(hwid);
71  if( cabling->isOnlineConnectedFromHash(onlHash)) {
72  const IdentifierHash theCellHashID= cabling->oflHashFromOnlHash(onlHash);
73  const Identifier id=m_calo_id->cell_id(theCellHashID);
74  int index = theCont->findIndex(theCellHashID);
75  if (index<0) {
76  ATH_MSG_WARNING( " cell " << hwid.get_compact() << " " << id.get_compact() << " is not in the container " );
77  continue;
78  }
79  CaloCell* aCell = theCont->at(index);
80 
81  if (aCell) {
82  ATH_MSG_DEBUG(" replace energies in cell hwid= " << hwid.get_identifier32().get_compact()
83  << " offlineid = " << id.get_identifier32().get_compact()
84  << " old energy " << aCell->e() << " new energy " << theRawChannel.energy());
85  nReplaced++;
86  aCell->setEnergy((float)(theRawChannel.energy()));
87  aCell->setTime((float)(theRawChannel.time())*0.001); // convert from ps int in raw channel to ns float in calocell
88  aCell->setQuality(theRawChannel.quality());
89  aCell->setProvenance(theRawChannel.provenance());
90  }
91 
92  }// isConnected
93  }// loop over raw channel container
94 
95  if (nReplaced*5>theCont->size()) {
96  ATH_MSG_WARNING("Replaced more than 20% of channels reco'ed online by channels reco'ed offline");
97  }
98  return StatusCode::SUCCESS;
99 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1636
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
LArCellMerger::initialize
virtual StatusCode initialize() override
initialize the tool
Definition: LArCellMerger.cxx:33
CaloCell::setTime
virtual void setTime(float time)
set time
Definition: CaloCell.cxx:151
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
index
Definition: index.py:1
SG::VarHandleBase::name
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleBase.cxx:75
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
CaloCell::e
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition: CaloCell.h:317
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition: CaloCell.cxx:136
HWIdentifier
Definition: HWIdentifier.h:13
CaloCell_ID.h
LArCellMerger::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer
Definition: LArCellMerger.cxx:48
LArOnOffIdMapping.h
LArCellMerger::m_calo_id
const CaloCell_ID * m_calo_id
Definition: LArCellMerger.h:67
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCellMerger::finalize
virtual StatusCode finalize() override
finalize the tool
Definition: LArCellMerger.cxx:44
Identifier32::get_compact
value_type get_compact(void) const
Get the compact id.
Definition: Identifier32.h:171
CaloCell::setQuality
virtual void setQuality(uint16_t quality)
set quality
Definition: CaloCell.cxx:156
LArRawChannel
Liquid Argon ROD output object base class.
Definition: LArRawChannel.h:40
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
LArCellMerger::m_rawChannelContainerName
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelContainerName
key for raw channel container to merge to cells
Definition: LArCellMerger.h:64
LArCellMerger.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
CaloCell::setProvenance
void setProvenance(uint16_t prov)
set Provenance
Definition: CaloCell.cxx:167
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
LArCellMerger::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
handle to LAr cabling
Definition: LArCellMerger.h:59
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CaloCellContainer::findIndex
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Definition: CaloCellContainer.cxx:363
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
IdentifierHash
Definition: IdentifierHash.h:38
Identifier::get_identifier32
Identifier32 get_identifier32(void) const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
LArRawChannelContainer.h
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
LArCellMerger::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArCellMerger.h:68