ATLAS Offline Software
Loading...
Searching...
No Matches
MbtsReadoutBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6
10
14
15#include "GeoModelKernel/GeoDefinitions.h"
17
19
20#define SYSTEM_OF_UNITS Gaudi::Units
21
23 , IRDBAccessSvc* paramSvc
24 , IMessageSvc* msgSvc
25 , double zposMM
26 , const std::map<std::string,unsigned>& trdMap
27 , const std::string& detKey
28 , const std::string& detNode)
29{
30 MsgStream log(msgSvc, "buildMbtsReadout");
31
32 IRDBRecordset_ptr larPositionRec = paramSvc->getRecordsetPtr("LArPosition",detKey,detNode);
33 IRDBRecordset_ptr mbtsGen = paramSvc->getRecordsetPtr("MBTSGen",detKey,detNode);
34 IRDBRecordset_ptr mbtsScin = paramSvc->getRecordsetPtr("MBTSScin",detKey,detNode);
35 IRDBRecordset_ptr mbtsTrds = paramSvc->getRecordsetPtr("MBTSTrds",detKey,detNode);
36
37 // Get ID helper
38 const TileTBID* tileTBID = nullptr;
39 StatusCode sc = detStore->retrieve(tileTBID);
40 if(sc.isFailure() || !tileTBID) {
41 log << MSG::ERROR << "Failed to initialize TileTBID" << endmsg;
42 return sc;
43 }
44
45 const IRDBRecord *posRec = GeoDBUtils::getTransformRecord(larPositionRec, "LARCRYO_EC_POS");
46 if(!posRec) {
47 log << MSG::ERROR << "No lar position record in the database" << endmsg;
48 return StatusCode::FAILURE;
49 }
50
51 GeoTrf::Transform3D xfPos = GeoDBUtils::getTransform(posRec);
52 double globalZMM = xfPos.translation().z() + zposMM;
53
54 // Create MBTS manager
55 MbtsDetDescrManager* mbtsManager = new MbtsDetDescrManager();
56
57 // Create Calo DDEs for both sides
58 for(int side=0; side<2; side++) {
59 int sidesign = (side ? -1 : 1);
60
61 for(unsigned int scinId=0; scinId<2; scinId++) {
62 int nScin(0), eta(0);
63 double dx1Scin(0.), dzScin(0.), zposScin(0.), rposScin(0.), scineta(0.), scindeta(0.), deltaPhi(0.), startPhi(0.);
64
65 if(mbtsGen->size()==0) {
66 // The "old" description:
67 const IRDBRecord* curScin = (*mbtsScin)[scinId];
68
69 nScin = curScin->getInt("SCINNUM");
70 eta = curScin->getInt("SCIN_ID")-1;
71 dx1Scin = curScin->getDouble("DX1")*SYSTEM_OF_UNITS::mm;
72 dzScin = curScin->getDouble("DZ")*SYSTEM_OF_UNITS::mm;
73 zposScin = curScin->getDouble("ZPOS")*SYSTEM_OF_UNITS::mm;
74 rposScin = curScin->getDouble("RPOS")*SYSTEM_OF_UNITS::mm;
75 if(!curScin->isFieldNull("ETA")) {
76 scineta = curScin->getDouble("ETA");
77 }
78 if(!curScin->isFieldNull("DETA")) {
79 scindeta = curScin->getDouble("DETA");
80 }
81 deltaPhi = 360.*SYSTEM_OF_UNITS::deg/nScin;
82 if(!curScin->isFieldNull("STARTPHI")) {
83 startPhi = curScin->getDouble("STARTPHI");
84 }
85 }
86 else {
87 // The "new" description
88 std::string scinName = (scinId==0?"MBTS1":"MBTS2");
89 const IRDBRecord* curScin = (*mbtsTrds)[trdMap.at(scinName)];
90 nScin = (*mbtsGen)[0]->getInt("NSCIN");
91 eta = curScin->getInt("SCIN_ID")-1;
92 dx1Scin = curScin->getDouble("DX1")*SYSTEM_OF_UNITS::mm;
93 dzScin = curScin->getDouble("DZ")*SYSTEM_OF_UNITS::mm;
94 zposScin = (*mbtsGen)[0]->getDouble("ZPOSENV")*SYSTEM_OF_UNITS::mm;
95 rposScin = ((*mbtsGen)[0]->getDouble("RPOSENV")+curScin->getDouble("ZPOS"))*SYSTEM_OF_UNITS::mm;
96 scineta = curScin->getDouble("ETA");
97 scindeta = curScin->getDouble("DETA");
98 startPhi = (*mbtsGen)[0]->getDouble("STARTPHI");
99 deltaPhi = 360.*SYSTEM_OF_UNITS::deg/nScin;
100 }
101
102 for(int phi=0; phi<nScin; phi++) {
103 // Construct CaloDDE
105 // Construct Identifier
106 mbtsDDE->set_id(tileTBID->channel_id(sidesign,phi,eta));
107 mbtsDDE->set_z((globalZMM + zposScin)*sidesign);
108 mbtsDDE->set_dz(dx1Scin);
109 mbtsDDE->set_r(rposScin);
110 mbtsDDE->set_dr(dzScin);
111 mbtsDDE->set_phi((phi+startPhi)*deltaPhi);
112 mbtsDDE->set_dphi(deltaPhi*0.5);
113 mbtsDDE->set_eta(scineta);
114 mbtsDDE->set_deta(scindeta);
115 mbtsDDE->compute_derived();
116 // Store CaloDDE into the manager
117 mbtsManager->add(mbtsDDE);
118 } // Loop over indivudual scintillators
119 } // Loop over mbtsScin contents
120 } // Loop over sides
121
122 // Record the manager into the DS
123 sc = detStore->record(mbtsManager,"MBTS");
124 if(sc.isFailure()) {
125 log << MSG::FATAL << "Failed to record MBTS Detector Manager into the DS" << endmsg;
126 }
127 return sc;
128}
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
#define endmsg
Calo Subsystem specific Detector Elements + Dummy element for testing.
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
static Double_t sc
Helper function for building readout geometry of the MBTS.
static const IRDBRecord * getTransformRecord(IRDBRecordset_ptr positionRecSet, const std::string &key)
Definition GeoDBUtils.h:23
static GeoTrf::Transform3D getTransform(const IRDBRecord *currentRec)
Definition GeoDBUtils.h:33
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
virtual IRDBRecordset_ptr getRecordsetPtr(const std::string &node, const std::string &tag, const std::string &tag2node="", const std::string &connName="ATLASDD")=0
Provides access to the Recordset object containing HVS-tagged data.
IRDBRecord is one record in the IRDBRecordset object.
Definition IRDBRecord.h:27
virtual bool isFieldNull(const std::string &fieldName) const =0
Check if the field value is NULL.
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
virtual unsigned int size() const =0
void add(CaloDetDescrElement *element)
Mbts Detector Element.
void set_id(const Identifier &id)
void set_deta(double deta)
void set_dphi(double dphi)
The Athena Transient Store API.
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
Identifier channel_id(int type, int module, int channel) const
identifer for one channel of a Tile testbeam detector
Definition TileTBID.cxx:197
StatusCode buildMbtsReadout(StoreGateSvc *detStore, IRDBAccessSvc *paramSvc, IMessageSvc *msgSvc, double zposMM, const std::map< std::string, unsigned > &trdMap, const std::string &detKey, const std::string &detNode)