ATLAS Offline Software
Loading...
Searching...
No Matches
HLTCaloCellMaker.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 * */
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 for( const TrigRoiDescriptor* roiDescriptor : *roiCollection) {
71 ATH_MSG_DEBUG ( "Running on RoI " << *roiDescriptor<< " FS="<<roiDescriptor->isFullscan());
72 if ( roiDescriptor->isFullscan() ) {
73 ATH_CHECK(m_dataAccessSvc->loadFullCollections( context, *cdv ));
74 cdv->setHasCalo(CaloCell_ID::LAREM);
75 cdv->setHasCalo(CaloCell_ID::LARHEC);
76 cdv->setHasCalo(CaloCell_ID::LARFCAL);
77 cdv->setHasCalo(CaloCell_ID::TILE);
78 cdv->updateCaloIterators();
79 clN=cdv->size();
80 if ( m_monCells ){
81 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
82 } else {
83 auto monitoring = Monitored::Group( m_monTool, timer, clN );
84 }
85
86 } else {
87 // TT EM PART
88 for(int sampling=0;sampling<4;sampling++){
90 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTEM, sampling, sel ));
91 for( const auto cell : sel ) {cdv->push_back( cell ); }
92 }
93 cdv->setHasCalo(CaloCell_ID::LAREM);
94 // TT HEC PART
95 for(int sampling=0;sampling<4;sampling++){
97 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTHEC, sampling, sel ));
98 for( const auto cell : sel ) {cdv->push_back( cell ); }
99 }
100 cdv->setHasCalo(CaloCell_ID::LARHEC);
101 // TILE PART
102 {
103 std::vector<const TileCell*> sel;
104 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, sel ));
105 for( const auto cell : sel ) {
106 if(m_tileCellsInROI && !tileCellEtaInRoi(cell, roiDescriptor)) continue;
107 cdv->push_back( cell );
108 }
109 }
110 cdv->setHasCalo(CaloCell_ID::TILE);
111 // TT FCAL EM PART
112 {
114 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALEM, 0, sel ));
115 for( const auto cell : sel ) {cdv->push_back( cell ); }
116 }
117 cdv->setHasCalo(CaloCell_ID::LARFCAL);
118 // TT FCAL HAD PART
119 for(int sampling=0;sampling<2;sampling++){
121 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALHAD, sampling, sel ));
122 for( const auto cell : sel ) {cdv->push_back( cell ); }
123 }
124 cdv->setHasCalo(CaloCell_ID::LARFCAL);
125 cdv->updateCaloIterators();
126 }
127 ATH_MSG_DEBUG ("REGTEST: Producing "<<cdv->size()<<" cells");
128 clN=cdv->size();
129 if ( m_monCells ){
130 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
131 } else {
132 auto monitoring = Monitored::Group( m_monTool, timer, clN );
133 }
134 auto ss = cellContainer.record( std::move(cdv) );
135 ATH_CHECK( ss );
136
137 // we have to take care of this
138 if ( seedLess ) { delete roiCollection; }
139 return StatusCode::SUCCESS;
140 }
141
142 } else {
144 auto cdv = std::make_unique<ConstDataVector<CaloCellContainerVector> >();
145 ATH_CHECK( cellContainerV.record( std::move(cdv) ) );
146 for( const TrigRoiDescriptor* roiDescriptor : *roiCollection) {
147 if ( roiDescriptor->isFullscan() ) {
148 auto c = std::make_unique<CaloConstCellContainer >(SG::VIEW_ELEMENTS);
149 auto clET = Monitored::Collection ("Cells_eT",*c,getCellPt);
150 auto clEta = Monitored::Collection ("Cells_eta",*c,&CaloCell::eta);
151 auto clPhi = Monitored::Collection ("Cells_phi",*c,&CaloCell::phi);
152 ATH_CHECK(m_dataAccessSvc->loadFullCollections( context, *c ));
153 clN=c->size();
154 if ( m_monCells ){
155 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
156 } else {
157 auto monitoring = Monitored::Group( m_monTool, timer, clN );
158 }
159 cellContainerV->push_back( c.release()->asDataVector() );
160 } else {
161 auto c = std::make_unique<CaloConstCellContainer >(SG::VIEW_ELEMENTS);
162 auto clET = Monitored::Collection ("Cells_eT",*c,getCellPt);
163 auto clEta = Monitored::Collection ("Cells_eta",*c,&CaloCell::eta);
164 auto clPhi = Monitored::Collection ("Cells_phi",*c,&CaloCell::phi);
165
166 // TT EM PART
167 for(int sampling=0;sampling<4;sampling++){
169 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTEM, sampling, sel ));
170 for( const auto cell : sel ) {c->push_back( cell ); }
171 }
172 c->setHasCalo(CaloCell_ID::LAREM);
173 // TT HEC PART
174 for(int sampling=0;sampling<4;sampling++){
176 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, TTHEC, sampling, sel ));
177 for( const auto cell : sel ) {c->push_back( cell ); }
178 }
179 c->setHasCalo(CaloCell_ID::LARHEC);
180 // TILE PART
181 {
182 std::vector<const TileCell*> sel;
183 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, sel ));
184 for( const auto cell : sel ) {
185 if(m_tileCellsInROI && !tileCellEtaInRoi(cell, roiDescriptor)) continue;
186 c->push_back( cell );
187 }
188 }
189 c->setHasCalo(CaloCell_ID::TILE);
190 // TT FCAL EM PART
191 {
193 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALEM, 0, sel ));
194 for( const auto cell : sel ) {c->push_back( cell ); }
195 }
196 c->setHasCalo(CaloCell_ID::LARFCAL);
197 // TT FCAL HAD PART
198 for(int sampling=0;sampling<2;sampling++){
200 ATH_CHECK(m_dataAccessSvc->loadCollections( context, *roiDescriptor, FCALHAD, sampling, sel ));
201 for( const auto cell : sel ) {c->push_back( cell ); }
202 }
203 c->setHasCalo(CaloCell_ID::LARFCAL);
204 c->updateCaloIterators();
205 clN=c->size();
206 if ( m_monCells ){
207 auto monitoring = Monitored::Group( m_monTool, timer, clN, clET, clEta, clPhi);
208 } else {
209 auto monitoring = Monitored::Group( m_monTool, timer, clN);
210 }
211 cellContainerV->push_back( c.release()->asDataVector() );
212 }
213 }
214 }
215
216 if ( seedLess ) { delete roiCollection; }
217 return StatusCode::SUCCESS;
218}
#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())