ATLAS Offline Software
Loading...
Searching...
No Matches
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
6
8
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");
23 ATH_CHECK(m_caloMgrKey.initialize());
24 ATH_MSG_INFO("Initialisating finished");
25 return StatusCode::SUCCESS;
26}
27
28StatusCode
30 const EventContext& ctx) const
31{
32 create_empty_calo(ctx, theCellContainer);
33 return StatusCode::SUCCESS;
34}
35
36void 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Container class for CaloCell.
bool checkOrdered() const
verify one by one the container is ordered
const CaloCell * findCell(const IdentifierHash theHash) const
fast find method given identifier hash.
void push_back(CaloCell *)
reimplementation of const push_back
void order()
order container
void setHasTotalSize(const bool)
If @ flag is true, then the container size equals the maximum hash.
bool isOrdered() const
tell wether container is ordered
bool checkOrderedAndComplete() const
verify one by one the container is complete (i.e.
void setIsOrderedAndComplete(const bool ordered)
indicate that the container is complete and in order
void setIsOrdered(const bool ordered)
indicates that the container is ordered
size_type calo_cell_hash_max() const
cell 'global' hash table max size
Helper class for offline cell identifiers.
Definition CaloCell_ID.h:34
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
virtual void setTime(float time)
set time
Definition CaloCell.h:484
double energy() const
get energy (data member)
Definition CaloCell.h:327
void setCaloDDE(const CaloDetDescrElement *caloDDE)
set pointer to CaloDetDescrElement
Definition CaloCell.h:503
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
void setGain(CaloGain::CaloGain gain=CaloGain::INVALIDGAIN)
set gain
Definition CaloCell.h:497
virtual void setEnergy(float energy)
set energy
Definition CaloCell.h:472
void setQuality(uint16_t quality)
set quality
Definition CaloCell.h:460
This class groups all DetDescr information related to a CaloCell.
calo_element_range element_range() const
Range over element vector.
This class provides the client interface for accessing the detector description information common to...
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
unsigned int capacity()
return capacity of pool OK
unsigned int allocated()
return size already allocated OK
size_type size() const noexcept
Returns the number of elements in the collection.
virtual StatusCode initialize() override
void create_empty_calo(const EventContext &ctx, CaloCellContainer *theCellContainer) const
EmptyCellBuilderTool(const std::string &type, const std::string &name, const IInterface *parent)
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
@ INVALIDGAIN
Definition CaloGain.h:18