ATLAS Offline Software
Loading...
Searching...
No Matches
TileHitToCell.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5//*****************************************************************************
6// Filename : TileHitToCell.cxx
7// Author : Zhifang
8// Created : April, 2002
9//
10// DESCRIPTION:
11// Implement the TileHitToCell class
12//
13// HISTORY:
14//
15// BUGS:
16//
17//*****************************************************************************
18
19// Tile includes
22#include "TileEvent/TileCell.h"
24
25// Calo includes
27#include "CaloDetDescr/CaloDetDescrElement.h"
28
29// Atlas includes
30// access all Hits inside container
35
36//
37// Constructor
38//
39TileHitToCell::TileHitToCell(const std::string& name, ISvcLocator* pSvcLocator)
40 : AthAlgorithm(name, pSvcLocator)
41{
42}
43
46
47//
48// Alg standard initialize function
49//
51
52 // retrieve Tile detector manager, TileID helper from det store
53
54 ATH_CHECK( detStore()->retrieve(m_tileMgr) );
55
56 ATH_CHECK( detStore()->retrieve(m_tileID) );
57
58 ATH_CHECK( detStore()->retrieve(m_tileHWID) );
59
60 ATH_CHECK( m_hitContainerKey.initialize() );
61 ATH_CHECK( m_cellContainerKey.initialize() );
62
63 ATH_CHECK( m_samplingFractionKey.initialize() );
64
65 ATH_MSG_INFO( "TileHitToCell initialisation completed" );
66
67 return StatusCode::SUCCESS;
68}
69
70//
71// Alg standard execute function
72//
74
75 ATH_MSG_DEBUG( "Executing TileHitToCell" );
76
78 ATH_CHECK( samplingFraction.isValid() );
79
80 // step1: read hits from TES
82 ATH_CHECK( hitContainer.isValid() );
83
84 //Zero sums for monitoring.
85 int nTwo = 0;
86 int nChan = 0;
87 int nCell = 0;
88 double eHitTot = 0.0;
89 double eCellTot = 0.0;
90
91 // step2: to figure out the cell energy from the hits obtained above
92 unsigned int nCellMax = m_tileMgr->tile_cell_size();
93 std::vector<double> enePmt1;
94 std::vector<double> enePmt2;
95 enePmt1.resize(nCellMax);
96 enePmt2.resize(nCellMax);
97
98 SelectAllObject<TileHitContainer> selAll(hitContainer.cptr());
99 SelectAllObject<TileHitContainer>::const_iterator hitItr = selAll.begin();
100 SelectAllObject<TileHitContainer>::const_iterator lastHit = selAll.end();
101
102 IdentifierHash cellHash_id;
103 IdContext cellContext = m_tileID->cell_context();
104
105 for (; hitItr != lastHit; ++hitItr) {
106
107 // Get hit id (logical pmt id)
108 Identifier pmt_id = (*hitItr)->identify();
109 int pmt = m_tileID->pmt(pmt_id); // 0 or 1 - first or second PMT of the cell
110
111 HWIdentifier pmt_hwid = (*hitItr)->pmt_HWID();
112 int ros = m_tileHWID->ros(pmt_hwid);
113 int drawer = m_tileHWID->drawer(pmt_hwid);
114 int channel = m_tileHWID->channel(pmt_hwid);
115 int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
116
117 // Get logical ID of cell
118 Identifier cell_id = m_tileID->cell_id(pmt_id);
119 m_tileID->get_hash(cell_id, cellHash_id, &cellContext);
120
121 // Convert hit energy deposit to cell energy
122 double eHit = (*hitItr)->energy();
123 double fact = samplingFraction->getSamplingFraction(drawerIdx, channel);
124 double eCell = eHit * fact;
125
126 ++nChan;
127 eHitTot += eHit;
128 eCellTot += eCell;
129
130 // Add energy to existing entry for this cell, or
131 // make new cell entry if there is no previous entry for this cell
132 if (0 == pmt) {
133 ++nCell;
134 enePmt1[cellHash_id] = eCell;
135 } else {
136 ++nTwo;
137 enePmt2[cellHash_id] = eCell;
138 }
139
140 ATH_MSG_VERBOSE( "TileHitToCell: "
141 << " nChan=" << nChan
142 << " pmt_id=" << m_tileID->to_string(pmt_id, -1)
143 << " eHit=" << eHit
144 << " nCell=" << nCell
145 << " cell_id=" << m_tileID->to_string(cell_id, -2)
146 << " eCell=" << eCell );
147 }
148
149 // step3: form cells, and put them in container
150
152 ATH_CHECK( cellContainer.record(std::make_unique<CaloCellContainer>()) );
153 ATH_MSG_VERBOSE( "TileCell container registered to the TES with name" << m_cellContainerKey.key() );
154
155 for (unsigned int i = 0; i < nCellMax; ++i) {
156 const CaloDetDescrElement* caloDDE = m_tileMgr->get_cell_element(i);
157 TileCell* pCell = new TileCell(caloDDE, enePmt1[i], enePmt2[i], 0.0, 0.0, 0, 0
159 , CaloGain::INVALIDGAIN, CaloGain::INVALIDGAIN); // gain is not known
160 cellContainer->push_back(pCell);
161 }
162
163 // Execution completed.
164 if (msgLvl(MSG::DEBUG)) {
165 msg(MSG::DEBUG) << "TileHitToCell execution completed." << endmsg;
166 msg(MSG::DEBUG) << " nChan=" << nChan
167 << " eHitTot=" << eHitTot
168 << " nCell=" << nCell
169 << " n2=" << nTwo
170 << " eneTot=" << eCellTot << endmsg;
171 }
172
173
174
175 return StatusCode::SUCCESS;
176}
177
179
180 ATH_MSG_INFO( "TileHitToCell::finalize() end" );
181
182 return StatusCode::SUCCESS;
183}
184
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
This class groups all DetDescr information related to a CaloCell.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
const_iterator end()
const_iterator begin()
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
@ MASK_AMPL
Definition TileCell.h:65
const TileHWID * m_tileHWID
Pointer to TileHWID helper.
SG::WriteHandleKey< CaloCellContainer > m_cellContainerKey
virtual ~TileHitToCell()
Destructor.
virtual StatusCode finalize() override
finalize method
virtual StatusCode execute() override
execute method
virtual StatusCode initialize() override
initialize method
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
const TileID * m_tileID
Pointer to TileID helper.
TileHitToCell(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
@ INVALIDGAIN
Definition CaloGain.h:18