ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TileCalorimeter
TileSimAlgs
src
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
20
#include "
TileSimAlgs/TileHitToCell.h
"
21
#include "
TileDetDescr/TileDetDescrManager.h
"
22
#include "
TileEvent/TileCell.h
"
23
#include "
TileCalibBlobObjs/TileCalibUtils.h
"
24
25
// Calo includes
26
#include "
CaloIdentifier/TileID.h
"
27
#include "CaloDetDescr/CaloDetDescrElement.h"
28
29
// Atlas includes
30
// access all Hits inside container
31
#include "
EventContainers/SelectAllObject.h
"
32
#include "
StoreGate/ReadHandle.h
"
33
#include "
StoreGate/WriteHandle.h
"
34
#include "
StoreGate/ReadCondHandle.h
"
35
36
//
37
// Constructor
38
//
39
TileHitToCell::TileHitToCell
(
const
std::string& name, ISvcLocator* pSvcLocator)
40
:
AthAlgorithm
(name, pSvcLocator)
41
{
42
}
43
44
TileHitToCell::~TileHitToCell
() {
45
}
46
47
//
48
// Alg standard initialize function
49
//
50
StatusCode
TileHitToCell::initialize
() {
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
//
73
StatusCode
TileHitToCell::execute
(
const
EventContext& ctx) {
74
75
ATH_MSG_DEBUG
(
"Executing TileHitToCell"
);
76
77
SG::ReadCondHandle<TileSamplingFraction>
samplingFraction(
m_samplingFractionKey
, ctx);
78
ATH_CHECK
( samplingFraction.
isValid
() );
79
80
// step1: read hits from TES
81
SG::ReadHandle<TileHitContainer>
hitContainer(
m_hitContainerKey
, ctx);
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
151
SG::WriteHandle<CaloCellContainer>
cellContainer(
m_cellContainerKey
, ctx);
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
158
,
TileCell::MASK_AMPL
,
TileCell::MASK_AMPL
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
178
StatusCode
TileHitToCell::finalize
() {
179
180
ATH_MSG_INFO
(
"TileHitToCell::finalize() end"
);
181
182
return
StatusCode::SUCCESS;
183
}
184
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadCondHandle.h
SelectAllObject.h
SelectAllObject
SelectAllObjectMT< DCC, OBJECT > SelectAllObject
Definition
SelectAllObject.h:11
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TileCalibUtils.h
TileCell.h
TileDetDescrManager.h
TileHitToCell.h
TileID.h
AthAlgorithm::AthAlgorithm
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
AthAlgorithm.cxx:10
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell.
Definition
Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
HWIdentifier
Definition
HWIdentifier.h:13
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition
IdContext.h:26
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SelectAllObjectMT::end
const_iterator end()
Definition
SelectAllObjectMT.h:131
SelectAllObjectMT::begin
const_iterator begin()
Definition
SelectAllObjectMT.h:115
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition
TileCalibUtils.cxx:60
TileCell
Definition
TileCell.h:57
TileCell::MASK_AMPL
@ MASK_AMPL
Definition
TileCell.h:65
TileHitToCell::m_tileHWID
const TileHWID * m_tileHWID
Pointer to TileHWID helper.
Definition
TileHitToCell.h:81
TileHitToCell::m_cellContainerKey
SG::WriteHandleKey< CaloCellContainer > m_cellContainerKey
Definition
TileHitToCell.h:70
TileHitToCell::~TileHitToCell
virtual ~TileHitToCell()
Destructor.
Definition
TileHitToCell.cxx:44
TileHitToCell::execute
virtual StatusCode execute(const EventContext &ctx) override
execute method
Definition
TileHitToCell.cxx:73
TileHitToCell::finalize
virtual StatusCode finalize() override
finalize method
Definition
TileHitToCell.cxx:178
TileHitToCell::initialize
virtual StatusCode initialize() override
initialize method
Definition
TileHitToCell.cxx:50
TileHitToCell::m_hitContainerKey
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
Definition
TileHitToCell.h:67
TileHitToCell::m_tileID
const TileID * m_tileID
Pointer to TileID helper.
Definition
TileHitToCell.h:80
TileHitToCell::TileHitToCell
TileHitToCell(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
TileHitToCell.cxx:39
TileHitToCell::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition
TileHitToCell.h:77
TileHitToCell::m_tileMgr
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
Definition
TileHitToCell.h:82
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition
CaloGain.h:18
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0