ATLAS Offline Software
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
26 #include "CaloIdentifier/TileID.h"
27 #include "CaloDetDescr/CaloDetDescrElement.h"
28 
29 // Atlas includes
30 // access all Hits inside container
32 #include "StoreGate/ReadHandle.h"
33 #include "StoreGate/WriteHandle.h"
35 
36 //
37 // Constructor
38 //
39 TileHitToCell::TileHitToCell(const std::string& name, ISvcLocator* pSvcLocator)
40  : AthAlgorithm(name, pSvcLocator)
41 {
42 }
43 
45 }
46 
47 //
48 // Alg standard initialize function
49 //
51 
52  // retrieve Tile detector manager, TileID helper from det store
53 
55 
57 
59 
62 
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());
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileCell
Definition: TileCell.h:57
TileSamplingFraction::getSamplingFraction
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
Definition: TileSamplingFraction.h:53
TileHitToCell::m_tileMgr
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
Definition: TileHitToCell.h:82
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SelectAllObjectMT::end
const_iterator end()
Definition: SelectAllObjectMT.h:131
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
Tile_Base_ID::cell_context
IdContext cell_context(void) const
id for cells
Definition: Tile_Base_ID.cxx:1059
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
Tile_Base_ID::pmt
int pmt(const Identifier &id) const
Definition: Tile_Base_ID.cxx:180
ReadBchFromCool.pmt
pmt
Definition: ReadBchFromCool.py:62
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
TileHitToCell::m_hitContainerKey
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
Definition: TileHitToCell.h:67
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:206
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TileCalibUtils.h
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
TileHitToCell::initialize
virtual StatusCode initialize() override
initialize method
Definition: TileHitToCell.cxx:50
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
ReadCondHandle.h
TileHWID::channel
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
Definition: TileHWID.h:189
TileID.h
TileDetDescrManager.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
TileHitToCell::m_tileID
const TileID * m_tileID
Pointer to TileID helper.
Definition: TileHitToCell.h:80
TileHWID::ros
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
Definition: TileHWID.h:167
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition: CaloGain.h:18
TileDetDescrManager::tile_cell_size
calo_element_vec_size tile_cell_size() const
Definition: TileDetDescrManager.h:153
WriteHandle.h
Handle class for recording to StoreGate.
SelectAllObjectMT::begin
const_iterator begin()
Definition: SelectAllObjectMT.h:115
SelectAllObjectMT
Definition: SelectAllObjectMT.h:11
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
TileCell::MASK_AMPL
@ MASK_AMPL
Definition: TileCell.h:65
TileCell.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileHitToCell::execute
virtual StatusCode execute() override
execute method
Definition: TileHitToCell.cxx:73
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
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
SelectAllObjectMT::const_iterator
Definition: SelectAllObjectMT.h:22
TileHitToCell::m_cellContainerKey
SG::WriteHandleKey< CaloCellContainer > m_cellContainerKey
Definition: TileHitToCell.h:70
TileHitToCell::finalize
virtual StatusCode finalize() override
finalize method
Definition: TileHitToCell.cxx:178
AthAlgorithm
Definition: AthAlgorithm.h:47
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Tile_Base_ID::get_hash
virtual int get_hash(const Identifier &id, IdentifierHash &hash_id, const IdContext *context=0) const
create hash id from compact id (return == 0 for OK)
Definition: Tile_Base_ID.cxx:1151
TileDetDescrManager::get_cell_element
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
Definition: TileDetDescrManager.h:156
TileHitToCell::m_samplingFractionKey
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Definition: TileHitToCell.h:77
TileHitToCell::m_tileHWID
const TileHWID * m_tileHWID
Pointer to TileHWID helper.
Definition: TileHitToCell.h:81
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SG::WriteHandle< CaloCellContainer >
TileHWID::drawer
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
Definition: TileHWID.h:171
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Tile_Base_ID::to_string
std::string to_string(const Identifier &id, int level=0) const
Definition: Tile_Base_ID.cxx:52
CaloCellContainer::push_back
void push_back(CaloCell *)
reimplementation of const push_back
Definition: CaloCellContainer.cxx:74
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
SelectAllObject.h
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
Definition: IdentifierHash.h:38
TileHitToCell::~TileHitToCell
virtual ~TileHitToCell()
Destructor
Definition: TileHitToCell.cxx:44
Tile_Base_ID::cell_id
Identifier cell_id(const Identifier &any_id) const
Definition: Tile_Base_ID.cxx:581
IdContext
class IdContext
Definition: IdContext.h:34
TileHitToCell::TileHitToCell
TileHitToCell(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition: TileHitToCell.cxx:39
TileHitToCell.h