ATLAS Offline Software
Loading...
Searching...
No Matches
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
7NAME: LArCellMerger
8PACKAGE: offline/Calorimeter/LArCellRec
9
10AUTHORS: G.Unal
11CREATION: 9 July 2009
12
13PURPOSE:
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") );
37 ATH_CHECK( m_cablingKey.initialize() );
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}
#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)
Container class for CaloCell.
int findIndex(const IdentifierHash theHash) const
Return index of the cell with a given hash.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual double e() const override final
get energy (data member) (synonym to method energy()
Definition CaloCell.h:333
virtual void setTime(float time)
set time
Definition CaloCell.h:484
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
void setQuality(uint16_t quality)
set quality
Definition CaloCell.h:460
void setProvenance(uint16_t prov)
set Provenance
Definition CaloCell.h:490
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
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.
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
handle to LAr cabling
virtual StatusCode initialize() override
initialize the tool
SG::ReadHandleKey< LArRawChannelContainer > m_rawChannelContainerName
key for raw channel container to merge to cells
const LArOnlineID * m_onlineID
const CaloCell_ID * m_calo_id
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
update theCellContainer
virtual StatusCode finalize() override
finalize the tool
Liquid Argon ROD output object base class.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const std::string & name() const
Return the StoreGate ID for the referenced object.
Definition index.py:1