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 
31 
34 
35 #include "sTGC_RegSelCondAlg.h"
36 
37 
38 sTGC_RegSelCondAlg::sTGC_RegSelCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
39  MuonRegSelCondAlg( name, pSvcLocator )
40 {
41  ATH_MSG_DEBUG( "sTGC_RegSelCondAlg::sTGC_RegSelCondAlg() " << name );
42 }
43 
44 
45 
46 
47 std::unique_ptr<RegSelSiLUT> sTGC_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
48 
50 
51  if( !manager.range( id_range ) ) {
52  ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
53  return {nullptr};
54  }
55 
56  const sTgcIdHelper* helper = manager->stgcIdHelper();
57 
58  std::vector<Identifier>::const_iterator idfirst = helper->module_begin();
59  std::vector<Identifier>::const_iterator idlast = helper->module_end();
60 
62  const IdContext ModuleContext = helper->module_context();
63 
64  ATH_MSG_DEBUG("createTable()");
65 
66  std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>(RegSelSiLUT::sTGC);
67 
68 
69  for ( std::vector<Identifier>::const_iterator i=idfirst ; i!=idlast ; ++i ) {
70 
71  Identifier Id = *i;
72  IdentifierHash hashId;
73 
74  helper->get_hash( Id, hashId, &ModuleContext );
75 
76  const MuonGM::sTgcReadoutElement* stgc = manager->getsTgcReadoutElement(Id);
77  if (!stgc) continue;
78 
79  // std::cout << "stgc station name: " << mm->getStationName() << "\teta: " << mm->getStationEta() << "\tphi: " << mm->getStationPhi() << std::endl;
80 
81  std::string stationName=stgc->getStationName();
82  int stationEta=stgc->getStationEta();
83  int stationPhi=stgc->getStationPhi();
84  int multilayer = helper->multilayer(Id);
85 
86  char side = stationEta < 0 ? 'C' : 'A';
87 
88  char sector_l = stationName.substr(2,1)=="L" ? 'L' : 'S';
89 
90  sTGCDetectorHelper aHelper;
91  sTGCDetectorDescription* md = aHelper.Get_sTGCDetector( sector_l, std::abs(stationEta), stationPhi, multilayer, side );
92 
93  Amg::Vector3D mmPos = stgc->center();
94 
95  double swidth = md->sWidth();
96  double lwidth = md->lWidth();
97 
98  double ycutout = md->yCutout();
99 
100  double length = md->Length();
101  double depth = md->Tck();
102 
103  double moduleR = std::sqrt( mmPos.mag()*mmPos.mag() - mmPos.z()*mmPos.z());
104 
105  double zmin = mmPos.z()-0.5*depth;
106  double zmax = mmPos.z()+0.5*depth;
107 
108  double rmin = moduleR-0.5*length;
109  double rmax = std::sqrt( (moduleR+0.5*length)*(moduleR+0.5*length) + lwidth*lwidth/4 );
110 
111  double dphi1 = std::atan( (0.5*lwidth)/(moduleR+0.5*length) );
112  double dphi2 = std::atan( (0.5*swidth)/(moduleR-0.5*length) );
113 
114  double dphi = ( dphi1 > dphi2 ? dphi1 : dphi2 );
115 
116  if ( ycutout > 0 ) {
117  double rcutout = moduleR+0.5*length - ycutout;
118  double dphicutout = std::atan( (0.5*lwidth)/rcutout );
119  if ( dphi < dphicutout ) dphi = dphicutout;
120  }
121 
122  double phimin = mmPos.phi()-dphi;
123  double phimax = mmPos.phi()+dphi;
124 
125  if ( phimin > M_PI ) phimin -= 2*M_PI;
126  if ( phimin < -M_PI ) phimin += 2*M_PI;
127 
128  int layerid = multilayer;
129  int detid = ( side == 'C' ? -1 : 1 );
130 
132  Muon::nsw::helper::NSWOfflineRobId robIdHelper(stationName,static_cast<int8_t>(stationEta),static_cast<uint8_t>(stationPhi));
133  for(uint32_t robId : robIdHelper.get_ids()){
134  RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
135  lut->addModule( m );
136  }
137 
138  }
139 
140  lut->initialise();
141 
142  return lut;
143 }
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:129
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
sTGCDetectorDescription::sWidth
double sWidth() const
Definition: sTGCDetectorDescription.h:70
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
sTGC_RegSelCondAlg.h
emacs: this is -*- c++ -*-
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
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:176
M_PI
#define M_PI
Definition: ActiveFraction.h:11
sTGCDetectorDescription::Length
double Length() const
Definition: sTGCDetectorDescription.h:72
RegSelSiLUT.h
emacs: this is -*- c++ -*-
sTGCDetectorDescription::Tck
double Tck() const
Definition: sTGCDetectorDescription.h:73
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:38
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
sTGCDetectorDescription
Definition: sTGCDetectorDescription.h:51
TRT::Hit::side
@ side
Definition: HitInfo.h:83
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
sTGCDetectorDescription.h
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:47
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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:28
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
sTGCDetectorHelper.h
MuonReadoutElement.h
Muon::nsw::helper::NSWOfflineRobId
Definition: NSWOfflineHelper.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IdentifierHash.h
sTgcIdHelper
Definition: sTgcIdHelper.h:55
sTGCDetectorDescription::yCutout
void yCutout(double y)
Definition: sTGCDetectorDescription.h:75
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
sTGCDetectorDescription::lWidth
double lWidth() const
Definition: sTGCDetectorDescription.h:71
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
IdentifierHash
Definition: IdentifierHash.h:38
RegSelSiLUT::sTGC
@ sTGC
Definition: RegSelSiLUT.h:45
MuonStation.h
IdContext
class IdContext
Definition: IdContext.h:34
sTGCDetectorHelper
Definition: sTGCDetectorHelper.h:24
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
sTGCDetectorHelper::Get_sTGCDetector
sTGCDetectorDescription * Get_sTGCDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition: sTGCDetectorHelper.cxx:35