ATLAS Offline Software
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 
20 HLTCaloCellMaker::HLTCaloCellMaker(const std::string & name, ISvcLocator* pSvcLocator)
21  : AthReentrantAlgorithm(name, pSvcLocator)
22 {
23 }
24 
26 
32  CHECK( m_dataAccessSvc.retrieve() );
33  if (! m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
34  return StatusCode::SUCCESS;
35 }
36 
37 StatusCode 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
54  TrigRoiDescriptor* FS = new TrigRoiDescriptor(true);
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 }
TTHEC
@ TTHEC
Definition: RegSelEnums.h:29
CaloCell_Base_ID::LARFCAL
@ LARFCAL
Definition: CaloCell_Base_ID.h:46
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
CaloCell::phi
virtual double phi() const override final
get phi (through CaloDetDescrElement)
Definition: CaloCell.h:359
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
HLTCaloCellMaker::HLTCaloCellMaker
HLTCaloCellMaker(const std::string &name, ISvcLocator *pSvcLocator)
Definition: HLTCaloCellMaker.cxx:20
HLTCaloCellMaker::tileCellEtaInRoi
static bool tileCellEtaInRoi(const CaloCell *cell, const TrigRoiDescriptor *roi)
Definition: HLTCaloCellMaker.h:74
FCALEM
@ FCALEM
Definition: RegSelEnums.h:35
CaloCell_Base_ID::LARHEC
@ LARHEC
Definition: CaloCell_Base_ID.h:46
TrigRoiDescriptor
nope - should be used for standalone also, perhaps need to protect the class def bits #ifndef XAOD_AN...
Definition: TrigRoiDescriptor.h:56
FCALHAD
@ FCALHAD
Definition: RegSelEnums.h:36
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
HLTCaloCellMaker::m_tileEMScaleKey
SG::ReadCondHandleKey< TileEMScale > m_tileEMScaleKey
FIXME: Temporary (i hope) to get dependency needed by BS converter.
Definition: HLTCaloCellMaker.h:55
HLTCaloCellMaker::m_tileCellsInROI
Gaudi::Property< bool > m_tileCellsInROI
Definition: HLTCaloCellMaker.h:64
python.utils.AtlRunQueryTimer.timer
def timer(name, disabled=False)
Definition: AtlRunQueryTimer.py:86
HLTCaloCellMaker::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: HLTCaloCellMaker.cxx:37
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
HLTCaloCellMaker::m_cellContainerKey
SG::WriteHandleKey< CaloConstCellContainer > m_cellContainerKey
Definition: HLTCaloCellMaker.h:52
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
HLTCaloCellMaker::getCellPt
static double getCellPt(const CaloCell *aCell)
Definition: HLTCaloCellMaker.h:68
HLTCaloCellMaker::m_monCells
Gaudi::Property< bool > m_monCells
Definition: HLTCaloCellMaker.h:63
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TTEM
@ TTEM
Definition: RegSelEnums.h:28
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
sel
sel
Definition: SUSYToolsTester.cxx:92
TrigRoiDescriptorCollection
Athena::TPCnvVers::Current Athena::TPCnvVers::Old TrigRoiDescriptorCollection
Definition: TrigSteeringEventTPCnv.cxx:78
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
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
HLTCaloCellMaker::m_dataAccessSvc
ServiceHandle< ITrigCaloDataAccessSvc > m_dataAccessSvc
Definition: HLTCaloCellMaker.h:58
HLTCaloCellMaker::initialize
virtual StatusCode initialize() override
Definition: HLTCaloCellMaker.cxx:25
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
HLTCaloCellMaker::m_roiCollectionKey
SG::ReadHandleKey< TrigRoiDescriptorCollection > m_roiCollectionKey
Definition: HLTCaloCellMaker.h:48
HLTCaloCellMaker::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: HLTCaloCellMaker.h:60
HLTCaloCellMaker.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArTT_Selector< LArCellCont >
HLTCaloCellMaker::m_roiMode
Gaudi::Property< bool > m_roiMode
Definition: HLTCaloCellMaker.h:62
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
HLTCaloCellMaker::m_bcidAvgKey
SG::ReadHandleKey< CaloBCIDAverage > m_bcidAvgKey
Definition: HLTCaloCellMaker.h:49
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
HLTCaloCellMaker::m_cellContainerVKey
SG::WriteHandleKey< ConstDataVector< CaloCellContainerVector > > m_cellContainerVKey
Definition: HLTCaloCellMaker.h:51
TrigRoiDescriptor
Athena::TPCnvVers::Current TrigRoiDescriptor
Definition: TrigSteeringEventTPCnv.cxx:68
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
python.compressB64.c
def c
Definition: compressB64.py:93
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Monitored::Timer
A monitored timer.
Definition: MonitoredTimer.h:32
CaloCell::eta
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Definition: CaloCell.h:366