ATLAS Offline Software
Loading...
Searching...
No Matches
sTGC_RegSelCondAlg.cxx
Go to the documentation of this file.
1
13
14
15#include <iostream>
16#include <fstream>
17#include <string>
18
19#include "CLHEP/Units/SystemOfUnits.h"
21
24
26
29
32
33#include "sTGC_RegSelCondAlg.h"
34
35
36sTGC_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
45std::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}
#define M_PI
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double length(const pvec &v)
emacs: this is -*- c++ -*-
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition IdContext.h:26
This is a "hash" representation of an Identifier.
virtual const Amg::Vector3D & center() const override
Return the center of the element.
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
MuonRegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
const std::vector< uint32_t > & get_ids() const
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
sTGC_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
sTGC naming convention headers
std::string depth
tag string for intendation
Definition fastadd.cxx:46
Eigen::Matrix< double, 3, 1 > Vector3D
emacs: this is -*- c++ -*-