ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CaloTester Class Reference

Helpers for creating calorimeter objects for unit tests. More...

#include <CaloTester.h>

Collaboration diagram for CaloTester:

Public Member Functions

 CaloTester ()
 Constructor. More...
 
StatusCode record_mgr ()
 Record the CaloDetDescrManager in the detector store. More...
 
const CaloDetDescriptorfind_dd (int hashid)
 Return a region descriptor corresponding to a given cell. More...
 
const CaloDetDescriptorfind_dd (const Identifier &cell_id)
 Return a region descriptor corresponding to a given cell. More...
 
std::unique_ptr< CaloCellmake_cell (int hashid)
 Create a calorimeter cell. More...
 
std::vector< CaloCell * > get_cells ()
 Return a vector of all cells. More...
 
std::vector< const CaloCell * > get_const_cells ()
 Return a vector of all cells as const pointers. More...
 
std::unique_ptr< CaloCellContainermake_ccc ()
 Return a CaloCellContainer for all cells. More...
 
CaloDetDescrManagermgr ()
 Return the CaloDetDescrManager. More...
 
const CaloHelpersTesthelpers () const
 Return the ID helpers. More...
 
const LArEM_IDemID () const
 Return the LArEM ID helper. More...
 
const LArHEC_IDhecID () const
 Return the LArHEC ID helper. More...
 
const LArFCAL_IDfcalID () const
 Return the LArFCAL ID helper. More...
 
const LArMiniFCAL_IDminifcalID () const
 Return the LArMiniFCAL ID helper. More...
 
const TileIDtileID () const
 Return the Tile ID helper. More...
 
const CaloCell_IDcaloID () const
 Return the Calorimeter ID helper. More...
 

Private Member Functions

void make_cells ()
 Create all calo cells and save in internal list. More...
 

Private Attributes

CaloHelpersTest m_helpers
 The ID helpers. More...
 
std::vector< std::unique_ptr< CaloDetDescrElement > > m_tileddes
 All Tile detdescr elements. More...
 
std::vector< std::unique_ptr< CaloCell > > m_cells
 The cells made by make_cells(). More...
 
CaloDetDescrManagerm_mgr
 The manager object. More...
 
std::unique_ptr< CaloDetDescrManagerm_mgr_up
 Owning pointer to the manager object. More...
 

Detailed Description

Helpers for creating calorimeter objects for unit tests.

Helpers to create ID helpers, detector description, and cells for use in unit tests, etc. Builds an idealized geometry.

Warning: DD built here is known to be incorrect for tile/fcal. Some parts of DD are likely to be incomplete for all subcalorimeters. Use with care.

Definition at line 40 of file CaloTester.h.

Constructor & Destructor Documentation

◆ CaloTester()

CaloTester::CaloTester ( )

Constructor.

The constructor will create the ID helpers. A CaloDetDescrManager instance will also be created, but it will not be recorded in the detector store unless record_mgr is called.

Definition at line 28 of file CaloTester.cxx.

29  : m_mgr_up (std::make_unique<CaloDetDescrManager>())
30 {
31  // Make a manager instance.
32  m_mgr = m_mgr_up.get();
34  m_mgr->initialize();
35 }

Member Function Documentation

◆ caloID()

const CaloCell_ID& CaloTester::caloID ( ) const
inline

Return the Calorimeter ID helper.

Definition at line 136 of file CaloTester.h.

136 { return m_helpers.caloID(); }

◆ emID()

const LArEM_ID& CaloTester::emID ( ) const
inline

Return the LArEM ID helper.

Definition at line 116 of file CaloTester.h.

116 { return m_helpers.emID(); }

◆ fcalID()

const LArFCAL_ID& CaloTester::fcalID ( ) const
inline

Return the LArFCAL ID helper.

Definition at line 124 of file CaloTester.h.

124 { return m_helpers.fcalID(); }

◆ find_dd() [1/2]

const CaloDetDescriptor * CaloTester::find_dd ( const Identifier cell_id)

Return a region descriptor corresponding to a given cell.

Parameters
reg_idCell identifier.

The desciptor will be created if needed and registered with the manager.

Definition at line 120 of file CaloTester.cxx.

121 {
122  return find_dd (m_helpers.caloID().calo_cell_hash (cell_id));
123 }

◆ find_dd() [2/2]

const CaloDetDescriptor * CaloTester::find_dd ( int  hashid)

Return a region descriptor corresponding to a given cell.

Parameters
hashidCell hash id.

The desciptor will be created if needed and registered with the manager.

Definition at line 61 of file CaloTester.cxx.

62 {
64 
65  Identifier id = helper.cell_id (hashid);
66  Identifier reg_id;
67  int subcalo = helper.sub_calo (id);
68  if (subcalo == CaloCell_ID::TILE) {
69  int section = helper.section (id);
70  int side = helper.side (id);
71  reg_id = helper.region_id (subcalo, section, side, 0);
72  }
73  else {
74  int sampling = helper.sampling (id);
75  int posneg = helper.pos_neg (id);
76  int region = helper.region (id);
77  reg_id = helper.region_id (subcalo, posneg, sampling, region);
78  }
79 
80  const CaloDetDescriptor* dd = m_mgr->get_descriptor (reg_id);
81  if (!dd) {
82  auto ddp = std::make_unique<CaloDetDescriptor> (reg_id,
83  &m_helpers.tileID(),
84  &helper);
85 
86  if (subcalo != CaloCell_ID::TILE) {
87  float eta0 = helper.eta0 (reg_id);
88  float eta1 = eta0 + (helper.eta_max (reg_id) - helper.eta_min (reg_id)) * helper.etaGranularity (reg_id);
89 
90  if (ddp->calo_sign() >= 0) {
91  ddp->setLArRegMin (eta0);
92  ddp->setLArRegMax (eta1);
93  ddp->setCaloEtaMin (eta0);
94  ddp->setCaloEtaMax (eta1);
95  }
96  else {
97  ddp->setLArRegMin (-eta1);
98  ddp->setLArRegMax (-eta0);
99  ddp->setCaloEtaMin (-eta1);
100  ddp->setCaloEtaMax (-eta0);
101  }
102 
103  ddp->setLArEtaMin (eta0);
104  ddp->setLArPhiMin (0);
105  }
106 
107  dd = ddp.get();
108  m_mgr->add (std::move (ddp));
109  }
110  return dd;
111 }

◆ get_cells()

std::vector< CaloCell * > CaloTester::get_cells ( )

Return a vector of all cells.

The cells remain owned by the Tester object.

Definition at line 186 of file CaloTester.cxx.

187 {
188  if (m_cells.empty()) {
189  make_cells();
190  }
191  std::vector<CaloCell*> cells;
192  cells.reserve (m_cells.size());
193  for (const std::unique_ptr<CaloCell>& cell : m_cells) {
194  cells.push_back (cell.get());
195  }
196  return cells;
197 }

◆ get_const_cells()

std::vector< const CaloCell * > CaloTester::get_const_cells ( )

Return a vector of all cells as const pointers.

The cells remain owned by the Tester object.

Definition at line 204 of file CaloTester.cxx.

205 {
206  if (m_cells.empty()) {
207  make_cells();
208  }
209  std::vector<const CaloCell*> cells;
210  cells.reserve (m_cells.size());
211  for (const std::unique_ptr<CaloCell>& cell : m_cells) {
212  cells.push_back (cell.get());
213  }
214  return cells;
215 }

◆ hecID()

const LArHEC_ID& CaloTester::hecID ( ) const
inline

Return the LArHEC ID helper.

Definition at line 120 of file CaloTester.h.

120 { return m_helpers.hecID(); }

◆ helpers()

const CaloHelpersTest& CaloTester::helpers ( ) const
inline

Return the ID helpers.

Definition at line 112 of file CaloTester.h.

112 { return m_helpers; }

◆ make_ccc()

std::unique_ptr< CaloCellContainer > CaloTester::make_ccc ( )

Return a CaloCellContainer for all cells.

This will be a view container; the cells remain owned by the Tester object.

Definition at line 223 of file CaloTester.cxx.

224 {
225  if (m_cells.empty()) {
226  make_cells();
227  }
228  auto ccc = std::make_unique<CaloCellContainer> (SG::VIEW_ELEMENTS);
229  for (std::unique_ptr<CaloCell>& cell : m_cells) {
230  ccc->push_back (cell.get());
231  }
232  ccc->initializeLookUpTable();
233  return ccc;
234 }

◆ make_cell()

std::unique_ptr< CaloCell > CaloTester::make_cell ( int  hashid)

Create a calorimeter cell.

Parameters
hashidCell hash id.

Definition at line 130 of file CaloTester.cxx.

131 {
132  const CaloDetDescriptor* descr = find_dd (hashid);
133  auto ddep = std::make_unique<DummyDetDescrElement> (hashid -
134  descr->caloCellMin(),
135  0,
136  0,
137  descr);
138  CaloDetDescrElement* dde = ddep.get();
139 
140  int ieta_min = m_helpers.caloID().eta_min (descr->identify());
141  int iphi_min = m_helpers.caloID().phi_min (descr->identify());
142  int ieta = m_helpers.caloID().eta (dde->identify());
143  int iphi = m_helpers.caloID().phi (dde->identify());
144  float r = 0; // FIXME; not filled in
145  float phi = descr->calo_phi_min() + (iphi - iphi_min) * descr->dphi();
146  float eta;
147  if (descr->calo_sign() > 0) {
148  eta = descr->calo_eta_min() + (ieta - ieta_min) * descr->deta();
149  }
150  else {
151  eta = descr->calo_eta_max() - (ieta - ieta_min) * descr->deta();
152  }
153 
154  ddep->set_cylindric (eta, phi, r);
155  ddep->set_cylindric_size (descr->deta(), descr->dphi(), 0);
156 
157  // mgr takes ownership of LAr ddes, but not tile...
158  m_mgr->add (dde);
159  if (m_helpers.caloID().is_tile (hashid)) {
160  m_tileddes.push_back (std::move (ddep));
161  }
162  else {
163  ddep.release();
164  }
165 
166  return std::make_unique<CaloCell> (dde, 1, 1, 1, CaloGain::LARHIGHGAIN);
167 }

◆ make_cells()

void CaloTester::make_cells ( )
private

Create all calo cells and save in internal list.

Definition at line 173 of file CaloTester.cxx.

174 {
175  size_t hashmax = m_helpers.caloID().calo_cell_hash_max();
176  m_cells.reserve (hashmax);
177  for (size_t i = 0; i < hashmax; i++)
178  m_cells.push_back (make_cell (i));
179 }

◆ mgr()

CaloDetDescrManager& CaloTester::mgr ( )
inline

Return the CaloDetDescrManager.

Definition at line 108 of file CaloTester.h.

108 { return *m_mgr; }

◆ minifcalID()

const LArMiniFCAL_ID& CaloTester::minifcalID ( ) const
inline

Return the LArMiniFCAL ID helper.

Definition at line 128 of file CaloTester.h.

128 { return m_helpers.minifcalID(); }

◆ record_mgr()

StatusCode CaloTester::record_mgr ( )

Record the CaloDetDescrManager in the detector store.

Record the CaloDetDescrManager in the ConditionStore.

This may create the detector store as a side effect.

Definition at line 41 of file CaloTester.cxx.

42 {
43  //Mock ConditonStore-infrastructure
45  DataObjID id1 ("testDetDescr");
46  ServiceHandle<StoreGateSvc> condStore ("ConditionStore", "test");
47  auto mgr_cc=std::make_unique<CondCont<CaloDetDescrManager> >(rcu, id1);
48  CHECK_WITH_CONTEXT(mgr_cc->insert(IOVInfiniteRange::infiniteTime(),std::move(m_mgr_up)),"CaloTester");
49  CHECK_WITH_CONTEXT(condStore->record(std::move(mgr_cc),"CaloDetDescrManager"),"CaloTester");
50 
51  return StatusCode::SUCCESS;
52 }

◆ tileID()

const TileID& CaloTester::tileID ( ) const
inline

Return the Tile ID helper.

Definition at line 132 of file CaloTester.h.

132 { return m_helpers.tileID(); }

Member Data Documentation

◆ m_cells

std::vector<std::unique_ptr<CaloCell> > CaloTester::m_cells
private

The cells made by make_cells().

Definition at line 153 of file CaloTester.h.

◆ m_helpers

CaloHelpersTest CaloTester::m_helpers
private

The ID helpers.

Definition at line 146 of file CaloTester.h.

◆ m_mgr

CaloDetDescrManager* CaloTester::m_mgr
private

The manager object.

Definition at line 156 of file CaloTester.h.

◆ m_mgr_up

std::unique_ptr<CaloDetDescrManager> CaloTester::m_mgr_up
private

Owning pointer to the manager object.

This is set at the start, and cleared if the object is recorded in SG.

Definition at line 160 of file CaloTester.h.

◆ m_tileddes

std::vector<std::unique_ptr<CaloDetDescrElement> > CaloTester::m_tileddes
private

All Tile detdescr elements.

The manager does not take ownership of these.

Definition at line 150 of file CaloTester.h.


The documentation for this class was generated from the following files:
beamspotman.r
def r
Definition: beamspotman.py:676
RunTileCalibRec.cells
cells
Definition: RunTileCalibRec.py:271
CaloHelpersTest::hecID
const LArHEC_ID & hecID() const
Definition: CaloHelpersTest.cxx:74
CaloTester::m_mgr_up
std::unique_ptr< CaloDetDescrManager > m_mgr_up
Owning pointer to the manager object.
Definition: CaloTester.h:160
CaloTester::m_cells
std::vector< std::unique_ptr< CaloCell > > m_cells
The cells made by make_cells().
Definition: CaloTester.h:153
CHECK_WITH_CONTEXT
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:396
CaloTester::find_dd
const CaloDetDescriptor * find_dd(int hashid)
Return a region descriptor corresponding to a given cell.
Definition: CaloTester.cxx:61
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
CaloTester::make_cells
void make_cells()
Create all calo cells and save in internal list.
Definition: CaloTester.cxx:173
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCell_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
CaloTester::make_cell
std::unique_ptr< CaloCell > make_cell(int hashid)
Create a calorimeter cell.
Definition: CaloTester.cxx:130
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloHelpersTest::tileID
const TileID & tileID() const
Definition: CaloHelpersTest.cxx:92
xAOD::eta1
setEt setPhi setE277 setWeta2 eta1
Definition: TrigEMCluster_v1.cxx:41
CaloHelpersTest::minifcalID
const LArMiniFCAL_ID & minifcalID() const
Definition: CaloHelpersTest.cxx:86
CaloDetDescrManager_Base::add
void add(CaloDetDescrElement *element)
add Calo DD element to the elements vector
Definition: CaloDetDescrManager.cxx:755
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
TRT::Hit::side
@ side
Definition: HitInfo.h:83
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
CaloTester::m_tileddes
std::vector< std::unique_ptr< CaloDetDescrElement > > m_tileddes
All Tile detdescr elements.
Definition: CaloTester.h:150
CaloDetDescrElement::identify
Identifier identify() const override final
cell identifier
Definition: CaloDetDescrElement.cxx:64
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloDetDescrManager::set_helper
void set_helper(const CaloCell_ID *idHelper)
set calo Cell ID helper
Definition: CaloDetDescrManager.cxx:1596
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
CaloTester::m_helpers
CaloHelpersTest m_helpers
The ID helpers.
Definition: CaloTester.h:146
CaloCell_Base_ID::eta
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
Athena_test::DummyRCUSvc
Definition: DummyRCUSvc.h:26
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
CaloCell_Base_ID::TILE
@ TILE
Definition: CaloCell_Base_ID.h:46
CaloCell_Base_ID::eta_min
int eta_min(const Identifier regId) const
min value of eta index (-999 == failure)
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloCell_Base_ID::phi
int phi(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
library_scraper.dd
list dd
Definition: library_scraper.py:46
CaloHelpersTest::fcalID
const LArFCAL_ID & fcalID() const
Definition: CaloHelpersTest.cxx:80
CaloTester::m_mgr
CaloDetDescrManager * m_mgr
The manager object.
Definition: CaloTester.h:156
CaloHelpersTest::caloID
const CaloCell_ID & caloID() const
Definition: CaloHelpersTest.cxx:98
CaloDetDescriptor
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
Definition: CaloDetDescriptor.h:58
CaloDetDescrManager_Base::initialize
void initialize()
initialization of the manager, used by the Converter when it creates the Manager
Definition: CaloDetDescrManager.cxx:49
IOVInfiniteRange::infiniteTime
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.
Definition: IOVInfiniteRange.h:47
section
void section(const std::string &sec)
Definition: TestTriggerMenuAccess.cxx:22
CaloCell_Base_ID
Helper base class for offline cell identifiers.
Definition: CaloCell_Base_ID.h:41
CaloHelpersTest::emID
const LArEM_ID & emID() const
Definition: CaloHelpersTest.cxx:68
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
ServiceHandle< StoreGateSvc >
CaloDetDescrManager_Base::get_descriptor
const CaloDetDescriptor * get_descriptor(const Identifier &regionId) const
get descriptor by region identifier
Definition: CaloDetDescrManager.cxx:579