ATLAS Offline Software
Loading...
Searching...
No Matches
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
10namespace
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
21namespace 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 {
44 ATH_CHECK(m_superCellsKey.initialize());
47 ATH_CHECK(m_towersKey.initialize());
48 ATH_CHECK(m_mappingKey.initialize());
49
50 ATH_CHECK(detStore()->retrieve(m_scid));
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;
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");
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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
float et(const xAOD::jFexSRJetRoI *j)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
Container class for CaloCell.
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
float time() const
get time (data member)
Definition CaloCell.h:368
uint16_t provenance() const
get provenance (data member)
Definition CaloCell.h:354
virtual double et() const override final
get et
Definition CaloCell.h:423
This is a "hash" representation of an Identifier.
const CaloCell_SuperCell_ID * m_scid
virtual ~JGTowerBuilder() override
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
SG::ReadHandleKey< CaloCellContainer > m_superCellsKey
SG::ReadHandleKey< xAOD::TriggerTowerContainer > m_triggerTowersKey
virtual StatusCode initialize() override
JGTowerBuilder(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< xAOD::JGTowerContainer > m_towersKey
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< JGTowerMappingData > m_mappingKey
SG::Decorator< T, ALLOC > Decorator
Definition AuxElement.h:575
void setdEta(float)
void setSCIndex(const std::vector< int > &)
set SCIndex
void setEt(float)
void setTileIndex(const std::vector< int > &)
set TileIndex
void setdPhi(float)
void setSampling(int)
virtual void initialize(const int Id, const float Eta, const float Phi, const float Et)
eFexTowerBuilder creates xAOD::eFexTowerContainer from supercells (LATOME) and triggerTowers (TREX) i...
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
JGTower_v1 JGTower
Define the latest version of the JGTower class.
Definition JGTower.h:15
TriggerTowerContainer_v2 TriggerTowerContainer
Define the latest version of the TriggerTower container.
TriggerTower_v2 TriggerTower
Define the latest version of the TriggerTower class.
Extra patterns decribing particle interation process.