..........................................................
87{
89
90 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey};
92 const CaloDetDescrManager* caloDDMgr = *caloMgrHandle;
93
94
95
96
97 std::vector<SG::WriteHandle<CaloCellContainer> > truthCells;
98 std::vector<SG::WriteHandle<xAOD::CaloClusterContainer> > truthClusters;
99 std::vector<SG::WriteHandle<CaloClusterCellLinkContainer> > truthLinks;
100
101
102
104
106 ATH_CHECK(truthCells.back().record(std::make_unique<CaloCellContainer>()));
107
110
112 ATH_CHECK(truthLinks.back().record(std::make_unique<CaloClusterCellLinkContainer>()));
113 }
114
115
117 std::vector<const CaloCalibrationHitContainer*> calibHitContainers(nCont,nullptr);
118 for (
unsigned int i=0;
i<nCont;
i++) {
121 ATH_MSG_DEBUG(
" Retrieved container " << calibHitContainers[i]->
Name() <<
" with size " << calibHitContainers[i]->
Size() );
122 if( calibHitContainers[i]->
Size() == 0 ) {
124 }
125 }
126 ATH_MSG_DEBUG(
"CaloCalibrationHitContainers retrieved successfuly" );
127
128
130 int em_nchan=0;
131 int hec_nchan=0;
132 int fcal_nchan=0;
133 int tile_nchan=0;
134
135 std::vector<Identifier>
ID;
136
137
138 std::vector<CaloCell*> CellsEtot;
139 std::vector<CaloCell*> CellsEvis;
140 std::vector<CaloCell*> CellsEem;
141
142 int nhitsInactive = 0;
143
144 for (
unsigned int i=0;
i<calibHitContainers.size();
i++) {
145 for( const auto *const calibhit: *(calibHitContainers[i])) {
146
148
149 double Etot = calibhit->energyTotal();
150 double Eem = calibhit->energy(0);
151 double Enonem = calibhit->energy(1);
152 double Evis = Eem + Enonem;
153
154 Identifier id=calibhit->cellID();
155
156
157 if (i>0) {
158
159 bool isNewId = true;
160 for (
int n=0;
n<nhitsInactive;
n++) {
162 CellsEtot[
n]->addEnergy(Etot);
163 CellsEvis[
n]->addEnergy(Evis);
164 CellsEem[
n]->addEnergy(Eem);
165 isNewId = false;
166 break;
167 }
168 }
169 if(!isNewId) continue;
170 }
171
172
175 const CaloDetDescrElement* caloDDE = caloDDMgr->
get_element(
id);
181 }
184 const CaloDetDescrElement* caloDDE = caloDDMgr->
get_element(
id);
190 }
191 else {
194 continue;
195 }
196 }
197 if (i==0) nhitsInactive = (
int)
ID.size();
198 }
199
200
201
202
203
204
205
207
208 for(
int itr=0; itr!=
nchan; itr++) {
213 ++em_nchan;
214 }
215 }
216 if(em_nchan) {
218 }
219
220 for(
int itr=0; itr!=
nchan; itr++) {
225 ++hec_nchan;
226 }
227 }
228 if(hec_nchan){
230 }
231
232 for(
int itr=0; itr!=
nchan; itr++) {
237 ++fcal_nchan;
238 }
239 }
240 if(fcal_nchan) {
242 }
243
244 for(
int itr=0; itr!=
nchan; itr++) {
249 ++tile_nchan;
250 }
251 }
252 if(tile_nchan) {
254 }
261
263
265
270 if (!truthCluster[i]) {
272 return StatusCode::FAILURE;
273 }
274 for (const auto cell: *truthCells[i]) {
276 truthCluster[
i]->
addCell( truthCells[i]->findIndex(
cell->caloDDE()->calo_hash()) , 1.);
277 }
278
282 truthClusters[i].
ptr()));
283
285 }
286
288 return StatusCode::SUCCESS;
289}
#define ATH_MSG_VERBOSE(x)
std::vector< Identifier > ID
ServiceHandle< StoreGateSvc > & evtStore()
static void calculateKine(xAOD::CaloCluster *clu, const bool useweight=true, const bool updateLayers=true, const bool useGPUCriteria=false)
Helper class to calculate cluster kinematics based on cells.
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
void setClusterSize(const ClusterSize)
Get cluster size.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
bool isGenStable(const T &p)
Determine if the particle is stable at the generator (not det-sim) level,.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.