ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTester Class Reference

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

#include <CaloTester.h>

Collaboration diagram for CaloTester:

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

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();
33 m_mgr->set_helper (&m_helpers.caloID());
34 m_mgr->initialize();
35}
CaloHelpersTest m_helpers
The ID helpers.
Definition CaloTester.h:146
std::unique_ptr< CaloDetDescrManager > m_mgr_up
Owning pointer to the manager object.
Definition CaloTester.h:160
CaloDetDescrManager * m_mgr
The manager object.
Definition CaloTester.h:156

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 121 of file CaloTester.cxx.

122{
123 return find_dd (m_helpers.caloID().calo_cell_hash (cell_id));
124}
const CaloDetDescriptor * find_dd(int hashid)
Return a region descriptor corresponding to a given cell.

◆ 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 62 of file CaloTester.cxx.

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

◆ 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 187 of file CaloTester.cxx.

188{
189 if (m_cells.empty()) {
190 make_cells();
191 }
192 std::vector<CaloCell*> cells;
193 cells.reserve (m_cells.size());
194 for (const std::unique_ptr<CaloCell>& cell : m_cells) {
195 cells.push_back (cell.get());
196 }
197 return cells;
198}
void make_cells()
Create all calo cells and save in internal list.
std::vector< std::unique_ptr< CaloCell > > m_cells
The cells made by make_cells().
Definition CaloTester.h:153

◆ 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 205 of file CaloTester.cxx.

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

◆ 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 224 of file CaloTester.cxx.

225{
226 if (m_cells.empty()) {
227 make_cells();
228 }
229 auto ccc = std::make_unique<CaloCellContainer> (SG::VIEW_ELEMENTS);
230 for (std::unique_ptr<CaloCell>& cell : m_cells) {
231 ccc->push_back (cell.get());
232 }
233 ccc->initializeLookUpTable();
234 return ccc;
235}
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts

◆ make_cell()

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

Create a calorimeter cell.

Parameters
hashidCell hash id.

Definition at line 131 of file CaloTester.cxx.

132{
133 const CaloDetDescriptor* descr = find_dd (hashid);
134 auto ddep = std::make_unique<DummyDetDescrElement> (hashid -
135 descr->caloCellMin(),
136 0,
137 0,
138 descr);
139 CaloDetDescrElement* dde = ddep.get();
140
141 int ieta_min = m_helpers.caloID().eta_min (descr->identify());
142 int iphi_min = m_helpers.caloID().phi_min (descr->identify());
143 int ieta = m_helpers.caloID().eta (dde->identify());
144 int iphi = m_helpers.caloID().phi (dde->identify());
145 float r = 0; // FIXME; not filled in
146 float phi = descr->calo_phi_min() + (iphi - iphi_min) * descr->dphi();
147 float eta;
148 if (descr->calo_sign() > 0) {
149 eta = descr->calo_eta_min() + (ieta - ieta_min) * descr->deta();
150 }
151 else {
152 eta = descr->calo_eta_max() - (ieta - ieta_min) * descr->deta();
153 }
154
155 ddep->set_cylindric (eta, phi, r);
156 ddep->set_cylindric_size (descr->deta(), descr->dphi(), 0);
157
158 // mgr takes ownership of LAr ddes, but not tile...
159 m_mgr->add (dde);
160 if (m_helpers.caloID().is_tile (hashid)) {
161 m_tileddes.push_back (std::move (ddep));
162 }
163 else {
164 ddep.release();
165 }
166
167 return std::make_unique<CaloCell> (dde, 1, 1, 1, CaloGain::LARHIGHGAIN);
168}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
Identifier identify() const override final
cell identifier
std::vector< std::unique_ptr< CaloDetDescrElement > > m_tileddes
All Tile detdescr elements.
Definition CaloTester.h:150
int r
Definition globals.cxx:22
@ LARHIGHGAIN
Definition CaloGain.h:18
list descr
print "%s.properties()" % self.__name__

◆ make_cells()

void CaloTester::make_cells ( )
private

Create all calo cells and save in internal list.

Definition at line 174 of file CaloTester.cxx.

175{
176 size_t hashmax = m_helpers.caloID().calo_cell_hash_max();
177 m_cells.reserve (hashmax);
178 for (size_t i = 0; i < hashmax; i++)
179 m_cells.push_back (make_cell (i));
180}
std::unique_ptr< CaloCell > make_cell(int hashid)
Create a calorimeter cell.

◆ 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
44 Athena_test::DummyRCUSvc rcu;
45 EventContext ctx(0, 0);
46 DataObjID id1 ("testDetDescr");
47 ServiceHandle<StoreGateSvc> condStore ("ConditionStore", "test");
48 auto mgr_cc=std::make_unique<CondCont<CaloDetDescrManager> >(rcu, id1);
49 CHECK_WITH_CONTEXT(mgr_cc->insert(IOVInfiniteRange::infiniteTime(),std::move(m_mgr_up),ctx),"CaloTester");
50 CHECK_WITH_CONTEXT(condStore->record(std::move(mgr_cc),"CaloDetDescrManager"),"CaloTester");
51
52 return StatusCode::SUCCESS;
53}
#define CHECK_WITH_CONTEXT(...)
Evaluate an expression and check for errors, with an explicitly specified context name.
static EventIDRange infiniteTime()
Produces an EventIDRange that is inifinite in Time and invalid in RunLumi.

◆ 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: