ATLAS Offline Software
JGTowerBuilder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "JGTowerBuilder.h"
7 #include "AthLinks/ElementLink.h"
9 
10 namespace
11 {
12  const static SG::AuxElement::Decorator<float> decArea("area");
13  const static SG::AuxElement::Decorator<std::size_t> decNextEtaIndex("nextEtaIndex");
14  const static SG::AuxElement::Decorator<std::size_t> decPreviousEtaIndex("previousEtaIndex");
15  const static SG::AuxElement::Decorator<std::size_t> decNextPhiIndex("nextPhiIndex");
16  const static SG::AuxElement::Decorator<std::size_t> decPreviousPhiIndex("previousPhiIndex");
17  const static SG::AuxElement::Decorator<std::size_t> decIndexInFront("indexInFront");
18  const static SG::AuxElement::Decorator<std::size_t> decIndexBehind("indexBehind");
19 } // namespace
20 
21 namespace LVL1
22 {
23  JGTowerBuilder::JGTowerBuilder(const std::string &name, ISvcLocator *pSvcLocator)
24  : AthReentrantAlgorithm(name, pSvcLocator)
25  {
26  declareProperty("InputCells", m_cellsKey = "AllCalo");
27  declareProperty("InputSuperCells", m_superCellsKey = "SCell");
28  declareProperty("InputTriggerTowers", m_triggerTowersKey = "xAODTriggerTowers");
29  declareProperty("UseAllCalo", m_useAllCalo = false);
30  declareProperty("UseAllRun2TT", m_useAllRun2TT = false);
31  declareProperty("OutputTowers", m_towersKey);
32  declareProperty("EmulateSuperCellTiming", m_emulateSCTiming = false);
33  declareProperty("UseSCQuality", m_useSCQuality = true);
34  declareProperty("SuperCellQuality", m_scQuality = 0x200);
35  declareProperty("MinSCETp", m_minSCETp = -1, "Minimum Et for positive energy scells");
36  declareProperty("MaxSCETm", m_maxSCETm = 1, "Maximum Et for negative energy scells");
37  declareProperty("MinTowerET", m_minTowerEt = -9e9);
38  }
39 
41 
43  {
47  ATH_CHECK(m_towersKey.initialize());
49 
51  return StatusCode::SUCCESS;
52  }
53 
54  StatusCode JGTowerBuilder::execute(const EventContext &ctx) const
55  {
56  ATH_MSG_DEBUG("Executing " << name());
57  auto superCells = SG::makeHandle(m_superCellsKey, ctx);
58  ATH_CHECK(superCells.isValid());
59  const CaloCellContainer *cells = nullptr;
60  const xAOD::TriggerTowerContainer *triggerTowers = nullptr;
61  if (m_useAllCalo)
62  {
63  auto cellsHandle = SG::makeHandle(m_cellsKey, ctx);
64  ATH_CHECK(cellsHandle.isValid());
65  cells = cellsHandle.ptr();
66  }
67  else
68  {
69  auto triggerTowersHandle = SG::makeHandle(m_triggerTowersKey, ctx);
70  ATH_CHECK(triggerTowersHandle.isValid());
71  triggerTowers = triggerTowersHandle.ptr();
72  }
73 
74  auto towerHandle = SG::makeHandle(m_towersKey, ctx);
75  auto towers = std::make_unique<xAOD::JGTowerContainer>();
76  auto towersAux = std::make_unique<xAOD::JGTowerAuxContainer>();
77  towers->setStore(towersAux.get());
78 
80  if (!mapping.isValid())
81  {
82  ATH_MSG_ERROR("Failed to retrieve mapping " << m_mappingKey);
83  return StatusCode::FAILURE;
84  }
85  for (const JGTowerHelper &towerHelper : **mapping)
86  {
87  float LArEt = 0;
88  float tileEt = 0;
89  if (m_useAllRun2TT)
90  {
91  for (const xAOD::TriggerTower *triggerTower : *triggerTowers)
92  {
93  if (triggerTower->sampling() != towerHelper.sampling() && std::abs(towerHelper.Eta()) < 3.1)
94  continue;
95  if (!towerHelper.inBox(triggerTower->eta(), triggerTower->phi()))
96  continue;
97  tileEt += 500 * triggerTower->cpET();
98  }
99  }
100  else
101  {
102  // Fill towers from SC
103  for (unsigned int scIdx : towerHelper.GetSCIndices())
104  {
105  Identifier scID = m_scid->cell_id(scIdx);
106  IdentifierHash scHash = m_scid->calo_cell_hash(scID);
107  const CaloCell *superCell = superCells->findCell(scHash);
108  if (!superCell)
109  // TODO: Should this at least be a warning?
110  continue;
111  float et = superCell->et();
112  float time = superCell->time();
113  if (std::isnan(superCell->et()))
114  // TODO: Should this only be a warning, or else a job failure?
115  ATH_MSG_ERROR("Supercell ET is nan. Likely due to BCID correction or something else upstream");
116  if (m_emulateSCTiming)
117  {
118  if (
119  (et < 10e3 && std::abs(time) > 8) ||
120  (et >= 10e3 && (time > 16 || time < -8)))
121  continue;
122  }
123  else
124  {
125  if (
126  (m_useSCQuality && !(superCell->provenance() & m_scQuality)) ||
127  (et > 0 && et < m_minSCETp) ||
129  continue;
130  }
131  LArEt += et;
132  }
133 
134  if (towerHelper.sampling() == 1)
135  {
136  if (m_useAllCalo)
137  for (unsigned int tileIdx : towerHelper.GetTileIndices())
138  {
139  const CaloCell *cell = cells->findCell(tileIdx);
140  if (!cell)
141  // TODO: Should this be at least a warning?
142  continue;
143  tileEt += cell->e() * cell->sinTh();
144  }
145  else
146  for (const xAOD::TriggerTower *triggerTower : *triggerTowers) {
147  if (std::abs(triggerTower->eta()) < 1.5) {
148  if (triggerTower->sampling() == 1 &&
149  towerHelper.inBox(triggerTower->eta(), triggerTower->phi()))
150  tileEt += 500 * triggerTower->cpET();
151  }
152  }
153  }
154  }
155  float towerEt = LArEt + tileEt;
156  if (towerEt < m_minTowerEt)
157  towerEt = 0;
158  xAOD::JGTower *tower = new xAOD::JGTower();
159  towers->push_back(tower);
160  tower->initialize(towers->size() - 1, towerHelper.Eta(), towerHelper.Phi());
161  tower->setdEta(towerHelper.dEta());
162  tower->setdPhi(towerHelper.dPhi());
163  tower->setEt(towerEt);
164  tower->setSCIndex(towerHelper.GetSCIndices());
165  tower->setTileIndex(towerHelper.GetTileIndices());
166  tower->setSampling(towerHelper.sampling());
167  decArea(*tower) = towerHelper.area();
168  // Decorate the relations
169  decNextEtaIndex(*tower) = towerHelper.nextEtaIndex();
170  decPreviousEtaIndex(*tower) = towerHelper.previousEtaIndex();
171  decNextPhiIndex(*tower) = towerHelper.nextPhiIndex();
172  decPreviousPhiIndex(*tower) = towerHelper.previousPhiIndex();
173  decIndexInFront(*tower) = towerHelper.indexInFront();
174  decIndexBehind(*tower) = towerHelper.indexBehind();
175  } //> end loop over tower helpers
176 
177  ATH_CHECK(towerHandle.record(std::move(towers), std::move(towersAux)));
178  return StatusCode::SUCCESS;
179  }
180 } // namespace LVL1
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
xAOD::JGTower_v1
Description of JGTower_v1.
Definition: JGTower_v1.h:46
LVL1::JGTowerBuilder::m_triggerTowersKey
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowersKey
Definition: JGTowerBuilder.h:32
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
et
Extra patterns decribing particle interation process.
LVL1::JGTowerBuilder::m_mappingKey
SG::ReadCondHandleKey< JGTowerMappingData > m_mappingKey
Definition: JGTowerBuilder.h:34
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
xAOD::JGTower_v1::setdPhi
void setdPhi(float)
Definition: JGTower_v1.cxx:103
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
xAOD::JGTower_v1::setTileIndex
void setTileIndex(const std::vector< int > &)
set TileIndex
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
LVL1::JGTowerBuilder::m_towersKey
SG::WriteHandleKey< xAOD::JGTowerContainer > m_towersKey
Definition: JGTowerBuilder.h:33
LVL1::JGTowerBuilder::m_useAllCalo
bool m_useAllCalo
Definition: JGTowerBuilder.h:36
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
JGTowerBuilder.h
LVL1::JGTowerHelper
Definition: JGTowerHelper.h:26
LVL1::JGTowerBuilder::~JGTowerBuilder
virtual ~JGTowerBuilder() override
Definition: JGTowerBuilder.cxx:40
CaloCell::provenance
uint16_t provenance() const
get provenance (data member)
Definition: CaloCell.h:338
CaloCell::time
float time() const
get time (data member)
Definition: CaloCell.h:352
LVL1
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
Definition: ICMMCPHitsCnvTool.h:18
find_tgc_unfilled_channelids.mapping
mapping
Definition: find_tgc_unfilled_channelids.py:17
LVL1::JGTowerBuilder::m_cellsKey
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Definition: JGTowerBuilder.h:30
ReadCondHandle.h
LVL1::JGTowerBuilder::m_scQuality
uint16_t m_scQuality
Definition: JGTowerBuilder.h:40
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
xAOD::JGTower_v1::setSampling
void setSampling(int)
Definition: JGTower_v1.cxx:127
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
LVL1::JGTowerBuilder::initialize
virtual StatusCode initialize() override
Definition: JGTowerBuilder.cxx:42
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LVL1::JGTowerBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: JGTowerBuilder.cxx:54
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:58
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
LVL1::JGTowerBuilder::m_emulateSCTiming
bool m_emulateSCTiming
Definition: JGTowerBuilder.h:38
xAOD::TriggerTower_v2
Description of TriggerTower_v2.
Definition: TriggerTower_v2.h:49
LVL1::JGTowerBuilder::m_scid
const CaloCell_SuperCell_ID * m_scid
Definition: JGTowerBuilder.h:46
CaloCell::et
virtual double et() const override final
get et
Definition: CaloCell.h:407
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
LVL1::JGTowerBuilder::m_minSCETp
float m_minSCETp
Definition: JGTowerBuilder.h:41
TrigConf::name
Definition: HLTChainList.h:35
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::JGTower_v1::setEt
void setEt(float)
Definition: JGTower_v1.cxx:140
xAOD::JGTower_v1::setdEta
void setdEta(float)
Definition: JGTower_v1.cxx:91
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::JGTower
JGTower_v1 JGTower
Define the latest version of the JGTower class.
Definition: JGTower.h:15
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
xAOD::JGTower_v1::setSCIndex
void setSCIndex(const std::vector< int > &)
set SCIndex
LVL1::JGTowerBuilder::m_maxSCETm
float m_maxSCETm
Definition: JGTowerBuilder.h:42
LVL1::JGTowerBuilder::m_minTowerEt
float m_minTowerEt
Definition: JGTowerBuilder.h:43
LVL1::JGTowerBuilder::m_superCellsKey
SG::ReadHandleKey< CaloCellContainer > m_superCellsKey
Definition: JGTowerBuilder.h:31
CaloCell
Data object for each calorimeter readout cell.
Definition: CaloCell.h:57
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
RunTileMonitoring.towers
towers
Definition: RunTileMonitoring.py:133
LVL1::JGTowerBuilder::m_useSCQuality
bool m_useSCQuality
Definition: JGTowerBuilder.h:39
LVL1::JGTowerBuilder::m_useAllRun2TT
bool m_useAllRun2TT
Definition: JGTowerBuilder.h:37
IdentifierHash
Definition: IdentifierHash.h:38
LVL1::JGTowerBuilder::JGTowerBuilder
JGTowerBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition: JGTowerBuilder.cxx:23
xAOD::JGTower_v1::initialize
virtual void initialize(const int Id, const float Eta, const float Phi, const float Et)
Definition: JGTower_v1.cxx:48
JGTowerAuxContainer.h