210 {
211
212 auto superCells = std::make_unique<CaloCellContainer>();
213
215 if (!
cells.isValid())
216 {
218 return StatusCode::FAILURE;
219 }
220
221 const CaloBCIDAverage *caloBCIDAvg = nullptr;
224 {
226 if (!handle.isValid())
227 {
229 return StatusCode::FAILURE;
230 }
231 caloBCIDAvg = handle.cptr();
232 }
234 {
236 if (!handle.isValid())
237 {
239 return StatusCode::FAILURE;
240 }
241 caloNoiseSigmaDiff = handle.cptr();
242 }
243
245 const CaloSuperCellDetDescrManager* scellMgr = *caloSuperCellMgrHandle;
246
248 if (!evtInfo.isValid())
249 {
251 return StatusCode::FAILURE;
252 }
254
255 generator.seed(evtInfo->eventNumber() * evtInfo->runNumber());
256
257 const CaloCell_SuperCell_ID *superCellIDHelper =
m_caloIdMgr->getCaloCell_SuperCell_ID();
258 const TileID *tileCellID =
m_caloIdMgr->getTileID();
259 const Tile_SuperCell_ID *tileSuperCellID =
m_caloIdMgr->getTile_SuperCell_ID();
260 const CaloCell_ID *caloCellID =
m_caloIdMgr->getCaloCell_ID();
261
262
264 std::vector<float> energies(nSuperCells, 0.0);
265 std::vector<float> enTime(nSuperCells, 0.0);
266 std::vector<float> enForTime(nSuperCells, 0.0);
267 std::vector<char> timeDef(nSuperCells, false);
268 std::vector<uint16_t>
qualities(nSuperCells, 0);
269 std::vector<float> sigmaNoisePerSuperCell(nSuperCells, 0.0);
270
271 for (const CaloCell *cell : *cells)
272 {
273 Identifier cellID =
cell->ID();
275
276 Identifier superCellID =
m_scidTool->offlineToSuperCellID(cellID);
277 const CaloDetDescrElement *cdde =
cell->caloDDE();
279 {
280 continue;
281 }
282 IdentifierHash scIDHash = superCellIDHelper->
calo_cell_hash(superCellID);
286 energies[scIDHash] +=
energy;
288 sigmaNoisePerSuperCell[scIDHash] += (*caloNoiseSigmaDiff)[cellIDHash];
289
290
292 bool isTile_BAD =
s >= 9 &&
s < 21;
293 if (
cell->provenance() & 0x2000)
294 {
295 if (
cell->energy() > 256)
296 {
297
298 timeDef[scIDHash] |= true;
299 enForTime[scIDHash] +=
cell->energy();
300 enTime[scIDHash] +=
cell->energy() *
cell->time();
301 }
302 else if (!isTile_BAD)
303 {
304
305
307
309 if (iEta == SIZE_MAX)
310 {
311 ATH_MSG_ERROR(
"Eta value " <<
cell->eta() <<
" for sampling " << sample <<
" does not fall in a bin");
312 return StatusCode::FAILURE;
313 }
315 if (iEt == SIZE_MAX)
316 {
317 ATH_MSG_ERROR(
"Et value " <<
cell->et() <<
" for sampling " << sample <<
" does not fall in a bin");
318 return StatusCode::FAILURE;
319 }
321 timeDef.at(scIDHash) |= true;
322 enForTime.at(scIDHash) +=
cell->energy();
323 enTime.at(scIDHash) +=
cell->energy() * cellTime;
324 }
325 }
327
328 if ((std::numeric_limits<uint16_t>::max() + 1 - quality) <
cell->quality())
329 quality = std::numeric_limits<uint16_t>::max();
330 else
331 quality +=
cell->quality();
332
333
335 {
337 int side = tileCellID->
side(cellID);
338 int module = tileCellID->module(cellID);
339 int tower = tileCellID->
tower(cellID);
340
341
346 int tower1 = tower;
347 int tower2 = tower - 1;
348 if (tower == 0)
349 {
350 side1 = -1;
351 side2 = 1;
352 tower1 = 0;
353 tower2 = 0;
354 }
355 else if (tower == 10)
356 {
359 }
360
361 Identifier scID1 = tileSuperCellID->
cell_id(section1, side1, module, tower1, 0);
362 Identifier scID2 = tileSuperCellID->
cell_id(section2, side2, module, tower2, 0);
363
364
367 }
368 }
369
370 for (std::size_t idx = 0;
idx < energies.size(); ++
idx)
371 {
372 const CaloDetDescrElement *dde = scellMgr->
get_element(idx);
373 if (!dde)
374 {
376 continue;
377 }
378
380 bool isTile_BAD =
s >= 9 &&
s < 21;
381 if (isTile_BAD)
382 continue;
383 float energy = energies.at(idx);
384 float sigmaNoise = sigmaNoisePerSuperCell.at(dde->
calo_hash());
385 if (!dde->
is_tile() && sigmaNoise > 0.0)
386 {
387 std::normal_distribution<double> distribution(0.0, sigmaNoise);
388 energy += distribution(generator);
389 }
390 auto superCell = std::make_unique<CaloCell>();
391 superCell->setCaloDDE(dde);
392 superCell->setEnergy(energy);
394 if (timeDef.at(idx) && enForTime.at(idx) != 0)
395 {
396 float time = enTime.at(idx) / enForTime.at(idx);
397 superCell->setTime(time);
398 float et = superCell->et();
399 prov = 0x2000;
400 if ((
et > 10e3 && time > -8 && time < 18) || (
et <= 10e3 && std::abs(time) < 8))
401 prov |= 0x200;
402 }
403 else
404 superCell->setTime(999.0);
405 superCell->setProvenance(prov);
407 superCells->push_back(superCell.release());
408 }
410 ATH_CHECK(superCellHandle.record(std::move(superCells)));
411 return StatusCode::SUCCESS;
412 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
std::vector< float > CaloNoiseSigmaDiff
NAME : CaloNoiseSigmaDiff.h PACKAGE : Calorimeter/CaloConditions.
float et(const xAOD::jFexSRJetRoI *j)
static const std::vector< std::string > qualities
float average(const Identifier &id) const
size_type calo_cell_hash_max() const
cell 'global' hash table max size
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
IdentifierHash calo_hash() const
cell calo hash
bool is_tile() const
cell belongs to Tile
CaloCell_ID::CaloSample getSampling() const
cell sampling
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
bool is_valid() const
Check if id is in a valid state.
SG::ReadCondHandleKey< CaloNoiseSigmaDiff > m_caloNoiseSigmaDiffKey
std::size_t getEtaIndex(CaloSampling::CaloSample sample, float eta) const
SG::ReadHandleKey< CaloBCIDAverage > m_caloBCIDAverageKey
SG::ReadCondHandleKey< CaloSuperCellDetDescrManager > m_caloSuperCellMgrKey
Super cell manager key.
std::map< std::tuple< CaloSampling::CaloSample, std::size_t, std::size_t >, std::map< float, float > > m_timingSamples
Timing distributions.
const CaloIdManager * m_caloIdMgr
Calo ID helpers.
std::size_t getEtIndex(CaloSampling::CaloSample sample, float et) const
int tower(const Identifier &id) const
Identifier cell_id(const Identifier &any_id) const
int side(const Identifier &id) const
int section(const Identifier &id) const
int sampling(const Identifier &id) const
time(flags, cells_name, *args, **kw)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
generator
Configure Herwig7 These are the commands corresponding to what would go into the regular Herwig infil...
setScale setgFexType iEta