ATLAS Offline Software
sTGC_RegSelCondAlg.cxx
Go to the documentation of this file.
1 
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18 
19 #include "CLHEP/Units/SystemOfUnits.h"
21 
22 #include "RegSelLUT/RegSelModule.h"
23 #include "RegSelLUT/RegSelSiLUT.h"
24 
26 
29 
32 
33 #include "sTGC_RegSelCondAlg.h"
34 
35 
36 sTGC_RegSelCondAlg::sTGC_RegSelCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
37  MuonRegSelCondAlg( name, pSvcLocator )
38 {
39  ATH_MSG_DEBUG( "sTGC_RegSelCondAlg::sTGC_RegSelCondAlg() " << name );
40 }
41 
42 
43 
44 
45 std::unique_ptr<RegSelSiLUT> sTGC_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
46 
48 
49  if( !manager.range( id_range ) ) {
50  ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
51  return {nullptr};
52  }
53 
54  const sTgcIdHelper* helper = manager->stgcIdHelper();
55 
56  std::vector<Identifier>::const_iterator idfirst = helper->module_begin();
57  std::vector<Identifier>::const_iterator idlast = helper->module_end();
58 
60  const IdContext ModuleContext = helper->module_context();
61 
62  ATH_MSG_DEBUG("createTable()");
63 
64  std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>(RegSelSiLUT::sTGC);
65 
66 
67  for ( std::vector<Identifier>::const_iterator i=idfirst ; i!=idlast ; ++i ) {
68 
69  Identifier Id = *i;
70  IdentifierHash hashId;
71 
72  helper->get_hash( Id, hashId, &ModuleContext );
73 
74  const MuonGM::sTgcReadoutElement* stgc = manager->getsTgcReadoutElement(Id);
75  if (!stgc) continue;
76 
77  // std::cout << "stgc station name: " << mm->getStationName() << "\teta: " << mm->getStationEta() << "\tphi: " << mm->getStationPhi() << std::endl;
78 
79  std::string stationName=stgc->getStationName();
80  int stationEta=stgc->getStationEta();
81  int stationPhi=stgc->getStationPhi();
82  int multilayer = helper->multilayer(Id);
83 
84  char side = stationEta < 0 ? 'C' : 'A';
85 
86 
87 
88  Amg::Vector3D sTgcPos = stgc->center();
89 
90  double swidth = stgc->getSsize();
91  double lwidth = stgc->getLongSsize();
92 
93  double ycutout = stgc->getPadDesign(1)->yCutout;
94 
95  double length = stgc->getRsize();
96  double depth = stgc->getZsize();
97 
98  double moduleR = std::sqrt( sTgcPos.mag()*sTgcPos.mag() - sTgcPos.z()*sTgcPos.z());
99 
100  double zmin = sTgcPos.z()-0.5*depth;
101  double zmax = sTgcPos.z()+0.5*depth;
102 
103  double rmin = moduleR-0.5*length;
104  double rmax = std::sqrt( (moduleR+0.5*length)*(moduleR+0.5*length) + lwidth*lwidth/4 );
105 
106  double dphi1 = std::atan( (0.5*lwidth)/(moduleR+0.5*length) );
107  double dphi2 = std::atan( (0.5*swidth)/(moduleR-0.5*length) );
108 
109  double dphi = ( dphi1 > dphi2 ? dphi1 : dphi2 );
110 
111  if ( ycutout > 0 ) {
112  double rcutout = moduleR+0.5*length - ycutout;
113  double dphicutout = std::atan( (0.5*lwidth)/rcutout );
114  if ( dphi < dphicutout ) dphi = dphicutout;
115  }
116 
117  double phimin = sTgcPos.phi()-dphi;
118  double phimax = sTgcPos.phi()+dphi;
119 
120  if ( phimin > M_PI ) phimin -= 2*M_PI;
121  if ( phimin < -M_PI ) phimin += 2*M_PI;
122 
123  int layerid = multilayer;
124  int detid = ( side == 'C' ? -1 : 1 );
125 
127  Muon::nsw::helper::NSWOfflineRobId robIdHelper(stationName,static_cast<int8_t>(stationEta),static_cast<uint8_t>(stationPhi));
128  for(uint32_t robId : robIdHelper.get_ids()){
129  RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
130  lut->addModule( m );
131  }
132 
133  }
134 
135  lut->initialise();
136 
137  return lut;
138 }
MuonRegSelCondAlg
Definition: MuonRegSelCondAlg.h:32
RegSelModule
Definition: RegSelModule.h:38
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:158
egammaParameters::depth
@ depth
pointing depth of the shower as calculated in egammaqgcld
Definition: egammaParamDefs.h:276
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
sTGC_RegSelCondAlg.h
emacs: this is -*- c++ -*-
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
MuonGM::MuonClusterReadoutElement::center
virtual const Amg::Vector3D & center() const override
Return the center of the element.
Definition: MuonClusterReadoutElement.h:125
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
sTgcReadoutElement.h
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:169
MuonGM::MuonReadoutElement::getZsize
double getZsize() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:198
M_PI
#define M_PI
Definition: ActiveFraction.h:11
RegSelSiLUT.h
emacs: this is -*- c++ -*-
MuonGM::MuonReadoutElement::getLongSsize
double getLongSsize() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:199
MuonRegSelCondAlg::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
Definition: MuonRegSelCondAlg.h:46
RegSelModule.h
sTGC_RegSelCondAlg::sTGC_RegSelCondAlg
sTGC_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
sTGC naming convention headers
Definition: sTGC_RegSelCondAlg.cxx:36
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
TRT::Hit::side
@ side
Definition: HitInfo.h:83
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
MuonGM::MuonReadoutElement::getSsize
double getSsize() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:196
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MuonGM::MuonReadoutElement::getStationName
const std::string & getStationName() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:190
sTGC_RegSelCondAlg::createTable
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
Definition: sTGC_RegSelCondAlg.cxx:45
lumiFormat.i
int i
Definition: lumiFormat.py:85
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::sTgcReadoutElement
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:30
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
MuonReadoutElement.h
Muon::nsw::helper::NSWOfflineRobId
Definition: NSWOfflineHelper.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IdentifierHash.h
sTgcIdHelper
Definition: sTgcIdHelper.h:55
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
NSWOfflineHelper.h
Muon::nsw::helper::NSWOfflineRobId::get_ids
const std::vector< uint32_t > & get_ids() const
Definition: NSWOfflineHelper.h:54
MuonGM::MuonReadoutElement::getRsize
double getRsize() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:197
MuonGM::MuonPadDesign::yCutout
double yCutout
Definition: MuonPadDesign.h:67
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
MuonGM::sTgcReadoutElement::getPadDesign
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:285
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:156
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
RegSelSiLUT::sTGC
@ sTGC
Definition: RegSelSiLUT.h:45
MuonStation.h
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
MuonGM::MuonReadoutElement::getStationPhi
int getStationPhi() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:194
MuonGM::MuonReadoutElement::getStationEta
int getStationEta() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonReadoutElement.h:193
Identifier
Definition: IdentifierFieldParser.cxx:14