ATLAS Offline Software
EmptyCellBuilderTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 // USED IN ATLFAST3
5 #include "EmptyCellBuilderTool.h"
6 
8 
9 #include "CaloEvent/CaloCell.h"
11 #include "TileEvent/TileCell.h"
12 
14  const std::string& name,
15  const IInterface* parent)
16  : base_class(type, name, parent)
17 {
18 }
19 
21 {
22  ATH_MSG_INFO("Initialisating started");
24  ATH_MSG_INFO("Initialisating finished");
25  return StatusCode::SUCCESS;
26 }
27 
30  const EventContext& ctx) const
31 {
32  create_empty_calo(ctx, theCellContainer);
33  return StatusCode::SUCCESS;
34 }
35 
36 void EmptyCellBuilderTool::create_empty_calo(const EventContext& ctx,
37  CaloCellContainer * theCellContainer) const
38 {
40  if (!caloMgrHandle.isValid()) {
41  ATH_MSG_FATAL("Failed to retrieve CaloDetDescrManager!");
42  std::abort();
43  }
44  const CaloDetDescrManager* caloDDM = *caloMgrHandle;
45 
46  ATH_MSG_DEBUG("Executing start calo size=" <<theCellContainer->size()<<" Event="<<ctx.evt());
47  bool check_exist=false;
48  if(theCellContainer->size()>0) {
49  check_exist=true;
50  ATH_MSG_DEBUG(" CaloCells do already exist: check required when creating!");
51  }
52 
53  int ncreate=0;
54  int nfound=0;
55  double E_tot=0;
56  double Et_tot=0;
57 
58  DataPool<TileCell> CellsPTile(10000);
59  DataPool<CaloCell> CellsPCalo(190000);
60  ATH_MSG_DEBUG("before: CellsPTile.capacity()="<<CellsPTile.capacity()<<" CellsPTile.allocated()="<<CellsPTile.allocated());
61  ATH_MSG_DEBUG("before: CellsPCalo.capacity()="<<CellsPCalo.capacity()<<" CellsPCalo.allocated()="<<CellsPCalo.allocated());
62 
63  for (const CaloDetDescrElement* theDDE : caloDDM->element_range()) {
64  if (theDDE) {
65  CaloCell* theCaloCell=0;
66 
67  if (check_exist) { theCaloCell = (CaloCell*)(theCellContainer->findCell(theDDE->calo_hash())); }
68 
69  if (theCaloCell) {
70  theCaloCell->setGain(CaloGain::INVALIDGAIN);
71  E_tot += theCaloCell->energy();
72  Et_tot += theCaloCell->energy() / cosh(theCaloCell->eta());
73  ++nfound;
74  } else {
75  CaloCell_ID::SUBCALO calo=theDDE->getSubCalo();
76  if (calo == CaloCell_ID::TILE) {
77  theCaloCell = CellsPTile.nextElementPtr();
78  } else {
79  theCaloCell = CellsPCalo.nextElementPtr();
80  }
81 
82  theCaloCell->setEnergy(0);
83  theCaloCell->setTime(0);
84  theCaloCell->setQuality(1.0);
85  theCaloCell->setGain(CaloGain::INVALIDGAIN);
86  theCaloCell->setCaloDDE(theDDE);
87 
88  theCellContainer->push_back(theCaloCell);
89  ++ncreate;
90  }
91  }
92  }
93 
94  ATH_MSG_DEBUG(ncreate<<" cells created, "<<nfound<<" cells already found: size="<<theCellContainer->size()<<" e="<<E_tot<<" ; et="<<Et_tot<<". Now initialize and order calo...");
95 
96  // check whether has max hash id size
97  const CaloCell_ID * theCaloCCIDM = caloDDM->getCaloCell_ID() ;
98  unsigned int hashMax = theCaloCCIDM->calo_cell_hash_max();
99  if (theCellContainer->size() < hashMax) {
100  ATH_MSG_DEBUG("CaloCellContainer size " << theCellContainer->size() << " smaller than hashMax: " << hashMax);
101  }
102  else if (theCellContainer->size() == hashMax) {
103  ATH_MSG_DEBUG("CaloCellContainer size " << theCellContainer->size() << " correspond to hashMax : " << hashMax);
104  theCellContainer->setHasTotalSize(true);
105  }
106  else {
107  ATH_MSG_WARNING("CaloCellContainer size " << theCellContainer->size()
108  << " larger than hashMax ! Too many cells ! " << hashMax);
109 
110  }
111 
112  // check whether in order and complete
113  if (theCellContainer->checkOrderedAndComplete()){
114  ATH_MSG_DEBUG("CaloCellContainer ordered and complete");
115  theCellContainer->setIsOrderedAndComplete(true);
116  theCellContainer->setIsOrdered(true);
117  } else {
118  ATH_MSG_DEBUG("CaloCellContainer not ordered or incomplete");
119  theCellContainer->setIsOrderedAndComplete(false);
120  // check whether in order
121  if (theCellContainer->checkOrdered()){
122  ATH_MSG_DEBUG("CaloCellContainer ordered");
123  theCellContainer->setIsOrdered(true);
124  } else {
125  ATH_MSG_DEBUG("CaloCellContainer not ordered");
126  theCellContainer->setIsOrdered(false);
127  }
128  }
129 
130  if (!theCellContainer->isOrdered()) {theCellContainer->order();}
131 
132  ATH_MSG_DEBUG("before: CellsPTile.capacity()="<<CellsPTile.capacity()<<" CellsPTile.allocated()="<<CellsPTile.allocated());
133  ATH_MSG_DEBUG("before: CellsPCalo.capacity()="<<CellsPCalo.capacity()<<" CellsPCalo.allocated()="<<CellsPCalo.allocated());
134 }
135 
CaloDetDescrManager_Base::element_range
calo_element_range element_range() const
Range over element vector.
Definition: CaloDetDescrManager.cxx:123
CaloCell::setCaloDDE
virtual void setCaloDDE(const CaloDetDescrElement *caloDDE)
set pointer to CaloDetDescrElement
Definition: CaloCell.cxx:127
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CaloCellContainer::checkOrderedAndComplete
bool checkOrderedAndComplete() const
verify one by one the container is complete (i.e.
Definition: CaloCellContainer.cxx:150
CaloCellContainer::setHasTotalSize
void setHasTotalSize(const bool)
If @ flag is true, then the container size equals the maximum hash.
Definition: CaloCellContainer.cxx:169
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCell::setTime
virtual void setTime(float time)
set time
Definition: CaloCell.cxx:151
EmptyCellBuilderTool::create_empty_calo
void create_empty_calo(const EventContext &ctx, CaloCellContainer *theCellContainer) const
Definition: EmptyCellBuilderTool.cxx:36
CaloCellContainer::setIsOrdered
void setIsOrdered(const bool ordered)
indicates that the container is ordered
Definition: CaloCellContainer.cxx:204
EmptyCellBuilderTool.h
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCellContainer::isOrdered
bool isOrdered() const
tell wether container is ordered
Definition: CaloCellContainer.h:293
CaloCell.h
CaloCell::setEnergy
virtual void setEnergy(float energy)
set energy
Definition: CaloCell.cxx:136
DataPool::allocated
unsigned int allocated()
return size already allocated OK
CaloCell::energy
double energy() const
get energy (data member)
Definition: CaloCell.h:311
EmptyCellBuilderTool::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: EmptyCellBuilderTool.h:37
CaloGain::INVALIDGAIN
@ INVALIDGAIN
Definition: CaloGain.h:18
CaloCell::setQuality
virtual void setQuality(uint16_t quality)
set quality
Definition: CaloCell.cxx:156
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
CaloCell_Base_ID::SUBCALO
SUBCALO
enumeration of sub calorimeters
Definition: CaloCell_Base_ID.h:46
TileCell.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
CaloCell::setGain
void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN)
set gain
Definition: CaloCell.cxx:173
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
DataPool.h
CaloCellContainer::findCell
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
Definition: CaloCellContainer.cxx:345
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCellContainer::checkOrdered
bool checkOrdered() const
verify one by one the container is ordered
Definition: CaloCellContainer.cxx:173
CaloCellContainer::order
void order()
order container
Definition: CaloCellContainer.cxx:474
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
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::push_back
void push_back(CaloCell *)
reimplementation of const push_back
Definition: CaloCellContainer.cxx:74
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
EmptyCellBuilderTool::process
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
Definition: EmptyCellBuilderTool.cxx:29
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
CaloDetDescrManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
Definition: CaloDetDescrManager.cxx:1590
EmptyCellBuilderTool::EmptyCellBuilderTool
EmptyCellBuilderTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: EmptyCellBuilderTool.cxx:13
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
CaloCellContainer::setIsOrderedAndComplete
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
Definition: CaloCellContainer.cxx:165
EmptyCellBuilderTool::initialize
virtual StatusCode initialize() override
Definition: EmptyCellBuilderTool.cxx:20
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366
DataPool::capacity
unsigned int capacity()
return capacity of pool OK
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size