ATLAS Offline Software
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 
18 #include "StoreGate/StoreGateSvc.h"
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 
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
104  MbtsDetectorElement* mbtsDDE = new MbtsDetectorElement();
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 }
IRDBRecord::getInt
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
TileTBID::channel_id
Identifier channel_id(int type, int module, int channel) const
identifer for one channel of a Tile testbeam detector
Definition: TileTBID.cxx:196
MbtsDetectorElement::set_dz
void set_dz(double dz)
Definition: CaloDetectorElements.h:397
LArGeo::buildMbtsReadout
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)
Definition: MbtsReadoutBuilder.cxx:22
MbtsDetectorElement::set_id
void set_id(const Identifier &id)
Definition: CaloDetectorElements.h:395
MbtsDetectorElement::compute_derived
void compute_derived()
Definition: CaloDetectorElements.cxx:598
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
GeoDBUtils::getTransformRecord
static const IRDBRecord * getTransformRecord(IRDBRecordset_ptr positionRecSet, const std::string &key)
Definition: GeoDBUtils.h:23
IRDBAccessSvc::getRecordsetPtr
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.
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
xAOD::deltaPhi
setSAddress setEtaMS setDirPhiMS setDirZMS setBarrelRadius setEndcapAlpha setEndcapRadius setInterceptInner setEtaMap setEtaBin setIsTgcFailure setDeltaPt deltaPhi
Definition: L2StandAloneMuon_v1.cxx:160
MbtsDetectorElement::set_phi
void set_phi(double phi)
Definition: CaloDetectorElements.h:402
deg
#define deg
Definition: SbPolyhedron.cxx:17
MbtsDetectorElement::set_deta
void set_deta(double deta)
Definition: CaloDetectorElements.h:401
MbtsDetectorElement::set_dphi
void set_dphi(double dphi)
Definition: CaloDetectorElements.h:403
GeoDBUtils::getTransform
static GeoTrf::Transform3D getTransform(const IRDBRecord *currentRec)
Definition: GeoDBUtils.h:33
MbtsDetDescrManager
Definition: MbtsDetDescrManager.h:16
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
MbtsDetDescrManager.h
MbtsDetDescrManager::add
void add(CaloDetDescrElement *element)
Definition: MbtsDetDescrManager.cxx:38
TRT::Hit::side
@ side
Definition: HitInfo.h:83
TileTBID.h
MbtsDetectorElement::set_z
void set_z(double z)
Definition: CaloDetectorElements.h:396
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
IRDBAccessSvc.h
Definition of the abstract IRDBAccessSvc interface.
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
GeoDBUtils.h
IRDBAccessSvc
IRDBAccessSvc is an abstract interface to the athena service that provides the following functionalit...
Definition: IRDBAccessSvc.h:45
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MbtsDetectorElement::set_dr
void set_dr(double dr)
Definition: CaloDetectorElements.h:399
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MbtsDetectorElement::set_eta
void set_eta(double eta)
Definition: CaloDetectorElements.h:400
IRDBRecordset_ptr
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition: IRDBAccessSvc.h:25
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
IRDBRecord.h
Definition of the abstract IRDBRecord interface.
IRDBRecord::isFieldNull
virtual bool isFieldNull(const std::string &fieldName) const =0
Check if the field value is NULL.
MbtsDetectorElement
Mbts Detector Element.
Definition: CaloDetectorElements.h:387
IRDBRecord
IRDBRecord is one record in the IRDBRecordset object.
Definition: IRDBRecord.h:27
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
TileTBID
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
Definition: Calorimeter/CaloIdentifier/CaloIdentifier/TileTBID.h:65
IRDBRecord::getDouble
virtual double getDouble(const std::string &fieldName) const =0
Get double field value.
IRDBRecordset.h
Definition of the abstract IRDBRecordset interface.
StoreGateSvc.h
MbtsReadoutBuilder.h
Helper function for building readout geometry of the MBTS.
MbtsDetectorElement::set_r
void set_r(double r)
Definition: CaloDetectorElements.h:398
CaloDetectorElements.h
Calo Subsystem specific Detector Elements + Dummy element for testing.