ATLAS Offline Software
Loading...
Searching...
No Matches
HLTCaloCellMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4/*
5 * */
6
7/*
8 * NAME: HLTCaloCellMaker.cxx
9 * PACKAGE: Trigger/TrigDataAccess/TrigCaloDataAccessSvc
10 *
11 * AUTHOR: Denis Oliveira Damazio
12 *
13 * PURPOSE: New Algorithm to produce CaloCellContainer Vector
14 *
15 **/
16
17#include "HLTCaloCellMaker.h"
19
20HLTCaloCellMaker::HLTCaloCellMaker(const std::string & name, ISvcLocator* pSvcLocator)
21 : AthReentrantAlgorithm(name, pSvcLocator)
22{
23}
24
26
30 ATH_CHECK( m_tileEMScaleKey.initialize() );
31 ATH_CHECK( m_bcidAvgKey.initialize() );
32 CHECK( m_dataAccessSvc.retrieve() );
33 if (! m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
34 return StatusCode::SUCCESS;
35}
36
37StatusCode HLTCaloCellMaker::execute( const EventContext& context ) const {
38
39 auto timer = Monitored::Timer("TIME_exec");
40 auto clN = Monitored::Scalar ("Cells_N",-999.0);
41
42 const bool seedLess = m_roiCollectionKey.empty();
43 const TrigRoiDescriptorCollection* roiCollection;
44 if (!seedLess){
45 auto roisHandle = SG::makeHandle( m_roiCollectionKey, context );
46 if ( not roisHandle.isValid() ) {
47 ATH_MSG_ERROR("Cell maker did not get a valid RoIs collection");
48 return StatusCode::FAILURE;
49 }
50 roiCollection = roisHandle.cptr();
51 }
52 else { // it is seedLess
55 roiCol->push_back( FS );
56 roiCollection = const_cast<TrigRoiDescriptorCollection*>(roiCol);
57 }
58 ATH_MSG_DEBUG("Operating on " << roiCollection->size() <<"RoI(s)");
59
60 // datahandle
61 if ( m_roiMode ) {
62 if ( roiCollection->size() > 1 )
63 ATH_MSG_DEBUG ( "roiMode but multiple rois found, will only use the first one");
64
66 auto cdv = std::make_unique<CaloConstCellContainer>(SG::VIEW_ELEMENTS);
67 auto clET = Monitored::Collection ("Cells_eT",*cdv,getCellPt);
68 auto clEta = Monitored::Collection ("Cells_eta",*cdv,&CaloCell::eta);
69 auto clPhi = Monitored::Collection ("Cells_phi",*cdv,&CaloCell::phi);
70 //loop only executes once, so coverity complains; suppress this as 'intentional'
71 //coverity[UNREACHABLE]
72 for( const TrigRoiDescriptor* roiDescriptor : *roiCollection) {
73 ATH_MSG_DEBUG ( "Running on RoI " << *roiDescriptor<< " FS="<<roiDescriptor->isFullscan());
74 if ( roiDescriptor->isFullscan() ) {
75 ATH_CHECK(m_dataAccessSvc->loadFullCollections( context, *cdv ));
76 cdv->setHasCalo(CaloCell_ID::LAREM);
77 cdv->setHasCalo(CaloCell_ID::LARHEC);
78 cdv->setHasCalo(CaloCell_ID::LARFCAL);
79 cdv->setHasCalo(CaloCell_ID::TILE);
80 cdv->updateCaloIterators();
81 clN=cdv->size();
82 if ( m_monCells ){
83 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
84 } else {
85 auto monitoring = Monitored::Group( m_monTool, timer, clN );
86 }
87
88 } else {
89 // TT EM PART
90 for(int sampling=0;sampling<4;sampling++){
92 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTEM, sampling, sel ));
93 for( const auto cell : sel ) {cdv->push_back( cell ); }
94 }
95 cdv->setHasCalo(CaloCell_ID::LAREM);
96 // TT HEC PART
97 for(int sampling=0;sampling<4;sampling++){
99 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTHEC, sampling, sel ));
100 for( const auto cell : sel ) {cdv->push_back( cell ); }
101 }
102 cdv->setHasCalo(CaloCell_ID::LARHEC);
103 // TILE PART
104 {
105 std::vector<const TileCell*> sel;
106 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, sel ));
107 for( const auto cell : sel ) {
108 if(m_tileCellsInROI && !tileCellEtaInRoi(cell, roiDescriptor)) continue;
109 cdv->push_back( cell );
110 }
111 }
112 cdv->setHasCalo(CaloCell_ID::TILE);
113 // TT FCAL EM PART
114 {
116 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALEM, 0, sel ));
117 for( const auto cell : sel ) {cdv->push_back( cell ); }
118 }
119 cdv->setHasCalo(CaloCell_ID::LARFCAL);
120 // TT FCAL HAD PART
121 for(int sampling=0;sampling<2;sampling++){
123 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALHAD, sampling, sel ));
124 for( const auto cell : sel ) {cdv->push_back( cell ); }
125 }
126 cdv->setHasCalo(CaloCell_ID::LARFCAL);
127 cdv->updateCaloIterators();
128 }
129 ATH_MSG_DEBUG ("REGTEST: Producing "<<cdv->size()<<" cells");
130 clN=cdv->size();
131 if ( m_monCells ){
132 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
133 } else {
134 auto monitoring = Monitored::Group( m_monTool, timer, clN );
135 }
136 auto ss = cellContainer.record( std::move(cdv) );
137 ATH_CHECK( ss );
138
139 // we have to take care of this
140 if ( seedLess ) { delete roiCollection; }
141 return StatusCode::SUCCESS;
142 }
143
144 } else {
146 auto cdv = std::make_unique<ConstDataVector<CaloCellContainerVector> >();
147 ATH_CHECK( cellContainerV.record( std::move(cdv) ) );
148 for( const TrigRoiDescriptor* roiDescriptor : *roiCollection) {
149 if ( roiDescriptor->isFullscan() ) {
150 auto c = std::make_unique<CaloConstCellContainer >(SG::VIEW_ELEMENTS);
151 auto clET = Monitored::Collection ("Cells_eT",*c,getCellPt);
152 auto clEta = Monitored::Collection ("Cells_eta",*c,&CaloCell::eta);
153 auto clPhi = Monitored::Collection ("Cells_phi",*c,&CaloCell::phi);
154 ATH_CHECK(m_dataAccessSvc->loadFullCollections( context, *c ));
155 clN=c->size();
156 if ( m_monCells ){
157 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
158 } else {
159 auto monitoring = Monitored::Group( m_monTool, timer, clN );
160 }
161 cellContainerV->push_back( c.release()->asDataVector() );
162 } else {
163 auto c = std::make_unique<CaloConstCellContainer >(SG::VIEW_ELEMENTS);
164 auto clET = Monitored::Collection ("Cells_eT",*c,getCellPt);
165 auto clEta = Monitored::Collection ("Cells_eta",*c,&CaloCell::eta);
166 auto clPhi = Monitored::Collection ("Cells_phi",*c,&CaloCell::phi);
167
168 // TT EM PART
169 for(int sampling=0;sampling<4;sampling++){
171 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTEM, sampling, sel ));
172 for( const auto cell : sel ) {c->push_back( cell ); }
173 }
174 c->setHasCalo(CaloCell_ID::LAREM);
175 // TT HEC PART
176 for(int sampling=0;sampling<4;sampling++){
178 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTHEC, sampling, sel ));
179 for( const auto cell : sel ) {c->push_back( cell ); }
180 }
181 c->setHasCalo(CaloCell_ID::LARHEC);
182 // TILE PART
183 {
184 std::vector<const TileCell*> sel;
185 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, sel ));
186 for( const auto cell : sel ) {
187 if(m_tileCellsInROI && !tileCellEtaInRoi(cell, roiDescriptor)) continue;
188 c->push_back( cell );
189 }
190 }
191 c->setHasCalo(CaloCell_ID::TILE);
192 // TT FCAL EM PART
193 {
195 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALEM, 0, sel ));
196 for( const auto cell : sel ) {c->push_back( cell ); }
197 }
198 c->setHasCalo(CaloCell_ID::LARFCAL);
199 // TT FCAL HAD PART
200 for(int sampling=0;sampling<2;sampling++){
202 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALHAD, sampling, sel ));
203 for( const auto cell : sel ) {c->push_back( cell ); }
204 }
205 c->setHasCalo(CaloCell_ID::LARFCAL);
206 c->updateCaloIterators();
207 clN=c->size();
208 if ( m_monCells ){
209 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
210 } else {
211 auto monitoring = Monitored::Group( m_monTool, timer, clN);
212 }
213 cellContainerV->push_back( c.release()->asDataVector() );
214 }
215 }
216 }
217
218 if ( seedLess ) { delete roiCollection; }
219 return StatusCode::SUCCESS;
220}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t ss
Header file to be included by clients of the Monitored infrastructure.
@ FCALEM
Definition RegSelEnums.h:35
@ TTHEC
Definition RegSelEnums.h:29
@ FCALHAD
Definition RegSelEnums.h:36
@ TTEM
Definition RegSelEnums.h:28
Athena::TPCnvVers::Current Athena::TPCnvVers::Old TrigRoiDescriptorCollection
Athena::TPCnvVers::Current TrigRoiDescriptor
An algorithm that can be simultaneously executed in multiple threads.
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition CaloCell.h:375
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition CaloCell.h:382
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< bool > m_monCells
SG::WriteHandleKey< ConstDataVector< CaloCellContainerVector > > m_cellContainerVKey
SG::ReadCondHandleKey< TileEMScale > m_tileEMScaleKey
FIXME: Temporary (i hope) to get dependency needed by BS converter.
virtual StatusCode initialize() override
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
ToolHandle< GenericMonitoringTool > m_monTool
static bool tileCellEtaInRoi(const CaloCell *cell, const TrigRoiDescriptor *roi)
HLTCaloCellMaker(const std::string &name, ISvcLocator *pSvcLocator)
SG::WriteHandleKey< CaloConstCellContainer > m_cellContainerKey
Gaudi::Property< bool > m_roiMode
static double getCellPt(const CaloCell *aCell)
virtual StatusCode execute(const EventContext &context) const override
ServiceHandle< ITrigCaloDataAccessSvc > m_dataAccessSvc
Gaudi::Property< bool > m_tileCellsInROI
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Group of local monitoring quantities and retain correlation when filling histograms
Declare a monitored scalar variable.
A monitored timer.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())