ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTTMgrDetDescrCnv.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 Calo Trigger Tower Manager converter package
7 --------------------------------------------
8 ***************************************************************************/
9
10//<doc><file> $Id: CaloTTMgrDetDescrCnv.cxx,v 1.21 2008-12-14 01:56:04 ssnyder Exp $
11//<version> $Name: not supported by cvs2svn $
12
13
15
16// infrastructure includes
19
20// detdescr includes
25
29#include "CaloDetDescr/CaloDetDescrElement.h"
31
32// Instantiation of a static factory class used by clients to create
33// instances of this service
34
35long int
37{
38 return (storageType());
39}
40
41StatusCode
43{
44 ATH_MSG_DEBUG("in initialize");
45 // First call parent init
46 ATH_CHECK(DetDescrConverter::initialize());
47
48 // The following is an attempt to "bootstrap" the loading of a
49 // proxy for CaloTTDescrManager into the detector store. However,
50 // CaloTTMgrDetDescrCnv::initialize is NOT called by the conversion
51 // service. So for the moment, this cannot be use. Instead the
52 // DetDescrCnvSvc must do the bootstrap from a parameter list.
53
54
55// // Add CaloTTDescrManager proxy as entry point to the detector store
56// // - this is ONLY needed for the manager of each system
57// sc = addToDetStore(classID(), "CaloTTDescrManager");
58// if (sc.isFailure()) {
59// log << MSG::FATAL << "Unable to add proxy for CaloTTDescrManager to the Detector Store!" << endmsg;
60// return StatusCode::FAILURE;
61// } else {}
62
63 return StatusCode::SUCCESS;
64}
65
66//--------------------------------------------------------------------
67
68StatusCode
70{
71 ATH_MSG_DEBUG("in finalize");
72 return StatusCode::SUCCESS;
73}
74
75//--------------------------------------------------------------------
76
77StatusCode
78CaloTTMgrDetDescrCnv::createObj(IOpaqueAddress* /*pAddr*/, DataObject*& pObj)
79{
80 ATH_MSG_INFO("in createObj: creating a CaloTTDescrManager object in the detector store");
81
82 // Create a new CaloTTDescrManager
83 CaloTTDescrManager* caloTTMgr = new CaloTTDescrManager();
84
85 // Pass a pointer to the container to the Persistency service by reference.
86 pObj = SG::asStorable(caloTTMgr);
87
88 // Get idhelper from detector store and add to mgr
89 //const DataHandle<CaloLVL1_ID> lvl1_id;
90 const CaloLVL1_ID* lvl1_id = nullptr;
91 ATH_CHECK(detStore()->retrieve(lvl1_id, "CaloLVL1_ID"));
92 caloTTMgr->set_helper(lvl1_id);
93 ATH_MSG_INFO("Set CaloLVL1_ID helper in CaloTTMgr ");
94
95 // Get CaloDetDescrManager from condition store
96 // to build geometry of trigger towers
97 //
98 // NB! The information retrieved from the CaloDetDescrManager is NOT sensitive
99 // to Calo alignment changes. Hence, it is OK to write CaloTTDescrManager
100 // into DetStore
101 SG::ReadCondHandleKey<CaloDetDescrManager> caloMgrKey {"CaloDetDescrManager"};
102 ATH_CHECK(caloMgrKey.initialize());
103 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{caloMgrKey};
104 const CaloDetDescrManager* caloMgr = *caloMgrHandle;
105
106 SmartIF<IToolSvc> toolSvc{service("ToolSvc")};
107 ATH_CHECK(toolSvc.isValid());
108
109 CaloTriggerTowerService* ttSvc{nullptr};
110 ATH_CHECK(toolSvc->retrieveTool("CaloTriggerTowerService",ttSvc));
111
112 // Initialize the caloTT mgr
113 // We protect here in case this has been initialized elsewhere
114
115 if (!caloTTMgr->is_initialized()) {
116
117 ATH_MSG_DEBUG("Initializing CaloTTMgr from values in CaloTTMgrDetDescrCnv");
118
119 int numberOfIdRegions=0;
120 int numberOfDescrRegions=0;
121 int nEmb=0;
122 int nEmec=0;
123 int nHec=0;
124 int nFcal=0;
125
126 // Initialize the manager ...
127 const CaloLVL1_ID* lvl1_helper = lvl1_id;
128
129 std::vector<Identifier>::const_iterator itId = lvl1_id->region_begin();
130 std::vector<Identifier>::const_iterator itIdEnd = lvl1_id->region_end();
131
132 for(; itId!=itIdEnd;++itId){
133 Identifier regId = *itId;
134 ++numberOfIdRegions;
135 int posNeg = lvl1_helper->pos_neg_z(regId);
136 // int sampling = lvl1_helper->sampling(regId);
137 int region = lvl1_helper->region(regId);
138 int halfNphi = (lvl1_helper->phi_max(regId)+1)/2;
139 int nLay = lvl1_helper->layer_max(regId)+1;
140
141 // create Descriptors for both LAr and Tile
142 CaloTTDescriptor* calo_descriptor = new CaloTTDescriptor() ;
143 calo_descriptor->set(regId);
144
145 if( 0 == region ) {
146 // calo_descriptor->set(0. ,2.5,0.1,-M_PI,M_PI,M_PI/halfNphi,posNeg,nLay);
147 calo_descriptor->set(0. ,2.5,0.1,0.,2.*M_PI,M_PI/halfNphi,posNeg,nLay);
148 } else if( 1 == region ) {
149 // calo_descriptor->set(2.5,3.1,0.2,-M_PI,M_PI,M_PI/halfNphi,posNeg,nLay);
150 calo_descriptor->set(2.5,3.1,0.2,0.,2.*M_PI,M_PI/halfNphi,posNeg,nLay);
151 } else if( 2 == region ) {
152 // calo_descriptor->set(3.1,3.2,0.1,-M_PI,M_PI,M_PI/halfNphi,posNeg,nLay);
153 calo_descriptor->set(3.1,3.2,0.1,0.,2.*M_PI,M_PI/halfNphi,posNeg,nLay);
154 } else if( 3 == region ) {
155 // calo_descriptor->set(3.2,4.9,0.4,-M_PI,M_PI,M_PI/halfNphi,posNeg,nLay);
156 calo_descriptor->set(3.2,4.9,0.4,0.,2.*M_PI,M_PI/halfNphi,posNeg,nLay);
157 }
158
159 // Initialize
160 caloTTMgr->add(calo_descriptor);
161
162 // now, create CaloTTDescrRegions for LAr only
163 // Loop on TTs of this region and create CaloTTDescrRegion's (equiv. to cell's CaloDDE for TT)
164 int maxEta=calo_descriptor->nEta();
165 for(int iEta=0;iEta<maxEta;++iEta) {
166
167 int maxPhi=calo_descriptor->nPhi();
168 for(int iPhi=0;iPhi<maxPhi;++iPhi) {
169
170 Identifier TTid = lvl1_helper->tower_id(regId,iEta,iPhi);
171 if(!lvl1_helper->is_tile(TTid)) {
172
173 int maxLay=calo_descriptor->nLay();
174 for(int iLay=0;iLay<maxLay;++iLay) {
175
176 Identifier layId = lvl1_helper->layer_id(TTid,iLay);
177 bool isFCAL(0), isEC(0);
178 if(lvl1_helper->is_fcal(layId)) {
179 isFCAL=true;
180 }
181 else if(lvl1_helper->is_emec(layId) || lvl1_helper->is_hec(layId)) {
182 isEC=true;
183 }
184 if (this->msgLvl(MSG::DEBUG)) {
185 if(lvl1_helper->is_emb(layId) || lvl1_helper->is_barrel_end(layId) ) {
186 ++nEmb;
187 ATH_MSG_DEBUG(" Found EMB TT " << lvl1_helper->show_to_string(layId));
188 }
189 else if(lvl1_helper->is_emec(layId)) {
190 ++nEmec;
191 ATH_MSG_DEBUG(" Found EMEC TT " << lvl1_helper->show_to_string(layId));
192 }
193 else if(lvl1_helper->is_hec(layId)) {
194 ++nHec;
195 ATH_MSG_DEBUG(" Found HEC TT " << lvl1_helper->show_to_string(layId));
196 }
197 else { // FCAL
198 ++nFcal;
199 ATH_MSG_DEBUG(" Found FCAL TT " << lvl1_helper->show_to_string(layId));
200 }
201 }
202
203 double dEta=calo_descriptor->deta();
204 double eta=calo_descriptor->eta_min()+(iEta+0.5)*dEta;
205 eta*=calo_descriptor->sign_eta();
206
207 double dPhi=calo_descriptor->dphi();
208 // beware of the -pi,pi convention
209 // fixed thanks to Denis Damazio when integrating LArRegionSelector
210 // float orig=-M_PI;
211 float orig=0.;
212 double phi=calo_descriptor->phiMin() + (iPhi+0.5)*dPhi + orig;
213 if(phi>=M_PI) {phi-=2.*M_PI;}
214 if(phi<-M_PI) {phi+=2.*M_PI;}
215
216
217 float rhoMin=99999.;
218 float rhoMax=0.;
219 float zMin=99999.;
220 float zMax=-99999.;
221
222 //int atlas_tb=0;
223 std::vector<Identifier> vec = ttSvc->createCellIDvecLayer(layId);
224
225 if(vec.size() > 0) {
226 numberOfDescrRegions++;
227 std::vector<Identifier>::const_iterator it = vec.begin();
228 std::vector<Identifier>::const_iterator it_end = vec.end();
229 for(;it!=it_end;++it) {
230 Identifier offId = (*it);
231 const CaloDetDescrElement* caloDDE =
232 caloMgr->get_element(offId);
233 double rho =caloDDE->r_raw();
234 double cDrho=caloDDE->dr();
235 double z =caloDDE->z_raw();
236 double cDz =caloDDE->dz();
237
238 if( (rho-cDrho/2.)<rhoMin ) {rhoMin=std::max(rho-cDrho/2.,0.);}
239 if( (rho+cDrho/2.)>rhoMax ) {rhoMax=rho+cDrho/2.;}
240 if( (z-cDz/2.)<zMin ) {zMin=z-cDz/2.;}
241 if( (z+cDz/2.)>zMax ) {zMax=z+cDz/2.;}
242 } // end loop on vector elements
243
244
245 CaloTTDescrRegion* tt_region = new CaloTTDescrRegion(layId,calo_descriptor);
246 if(isFCAL) {
247 // FIX ME !?
248 tt_region->set_cylindric(eta,phi,(zMax+zMin)/2.);
249 tt_region->set_cylindric_size(dEta,dPhi,fabs(zMax-zMin));
250 } else if(isEC) {
251 tt_region->set_cylindric(eta,phi,(zMax+zMin)/2.);
252 tt_region->set_cylindric_size(dEta,dPhi,fabs(zMax-zMin));
253 } else {
254 tt_region->set_spherical(eta,phi,(rhoMax+rhoMin)/2.);
255 tt_region->set_spherical_size(dEta,dPhi,fabs(rhoMax-rhoMin));
256 }
257
258 caloTTMgr->add(tt_region);
259
260 } // end condition of vec size
261 else {
262 ATH_MSG_DEBUG(" Found no cell for TT " << lvl1_helper->show_to_string(layId));
263 }
264 } // end loop on layers
265 } // end condition against tile
266 } // end loop on phi
267 } // end loop on eta
268 } // end loop on descr_regions
269
270 // Set to initialized state only if descriptors have been found
271 if (caloTTMgr->calo_descriptors_size () > 0) caloTTMgr->initialize();
272
273 ATH_MSG_INFO(" Initialized CaloTTMgr, number of descr regions is " << numberOfDescrRegions);
274 ATH_MSG_DEBUG(" including "
275 << nEmb << " Em Barrel "
276 << nEmec << " Em EC "
277 << nHec << " HEC "
278 << nFcal << " FCAL ");
279 ATH_MSG_DEBUG(" number of helper regions= " << numberOfIdRegions);
280 } // end of condition !is_initialized()
281
282 return StatusCode::SUCCESS;
283}
284
285//--------------------------------------------------------------------
286
287long
292
293//--------------------------------------------------------------------
294const CLID&
298
299//--------------------------------------------------------------------
304
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
std::vector< Identifier > ID
Definition of CaloDetDescrManager.
std::vector< size_t > vec
const long DetDescr_StorageType
uint32_t CLID
The Class ID type.
#define z
bool msgLvl(const MSG::Level lvl) const
Test the output level.
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
Helper class for offline TT identifiers.
Definition CaloLVL1_ID.h:66
bool is_barrel_end(const Identifier id) const
Test wether given tower or layer is part of the EM barrel END.
int phi_max(const Identifier regId) const
min value of phi index (-999 == failure)
int region(const Identifier id) const
return region according to :
bool is_emb(const Identifier id) const
Test wether given tower or layer is part of the EM barrel.
bool is_tile(const Identifier id) const
Test wether given tower or layer is part of the Tile Calorimeter.
bool is_emec(const Identifier id) const
Test wether given tower or layer is part of the EM end-cap.
id_iterator region_begin() const
begin iterator over regions
int layer_max(const Identifier regId) const
max value of phi index (-999 == failure)
bool is_fcal(const Identifier id) const
Test wether given tower or layer is part of the FCAL.
id_iterator region_end() const
end iterator over regions
bool is_hec(const Identifier id) const
Test wether given tower or layer is part of the HEC.
int pos_neg_z(const Identifier id) const
return pos_neg_z according to :
Identifier tower_id(int pos_neg_z, int sampling, int region, int eta, int phi) const
build a tower identifier
Identifier layer_id(int pos_neg_z, int sampling, int region, int eta, int phi, int layer) const
build a layer identifier
This class is used to build the CaloTTDescriptors and CaloTTDetDescrRegions carrying the geometry inf...
void add(CaloTTDescrRegion *region)
Insertion in the vector of Det Descr regions (== Trigger Towers)
calo_descr_size calo_descriptors_size(void) const
Total number of descriptors.
void set_helper(const CaloLVL1_ID *id_helper)
set the helper used to decode the TT offline identifiers
void initialize(void)
dummy.
bool is_initialized(void) const
This class provides an interface to the geometrical description of the Calorimeter Trigger Towers.
void set_spherical_size(double deta, double dphi, double drho)
set size of the Det Descr region – pseudo spherical system; eta is signed, rho is unsigned
void set_cylindric_size(double deta, double dphi, double dz)
set size of the Det Descr region – pseudo cylindrical system; eta is signed, z as well (same sign)
void set_spherical(double eta, double phi, double rho)
set coordinates of the Det Descr region – pseudo spherical system; eta is signed, rho is unsigned
void set_cylindric(double eta, double phi, double z)
set coordinates of the Det Descr region – pseudo cylindrical system; eta is signed,...
This class holds the Calorimeter TriggerTower geometrical description.
void set(const Identifier &id)
set internal data member m_id (which is unused.
short nPhi() const
descriptor parameter: number of phi bins
float deta() const
descriptor parameter: eta granularity
short nLay() const
descriptor parameter: number of layers
int sign_eta() const
descriptor parameter: sign of eta (+-1)
float dphi() const
descriptor parameter: phi granularity
short nEta() const
descriptor parameter: number of eta bins
float phiMin() const
descriptor parameter: min value of phi
float eta_min() const
descriptor parameter: min value of abs(eta)
virtual StatusCode finalize() override
CaloTTMgrDetDescrCnv(ISvcLocator *svcloc)
virtual long int repSvcType() const override
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
virtual StatusCode initialize() override
static const CLID & classID()
Tool providing the mapping of the online and offline TriggerTower identifiers as well as the TT-cells...
std::vector< Identifier > createCellIDvecLayer(const Identifier &id) const
Return a vector of offline Identifiers (corresponding helpers = LArEM_ID, LArHEC_ID,...
DetDescrConverter(const CLID &myCLID, ISvcLocator *svcloc, const char *name=nullptr)
const ServiceHandle< StoreGateSvc > & detStore() const
Handle to DetectorStore.
StatusCode initialize(bool used=true)
DataObject * asStorable(SG::DataObjectSharedPtr< T > pObject)
Default, invalid implementation of ClassID_traits.