ATLAS Offline Software
Loading...
Searching...
No Matches
TGC_RegSelCondAlg.cxx
Go to the documentation of this file.
1
13
14
15#include "GaudiKernel/EventIDRange.h"
17
18#include "CLHEP/Units/SystemOfUnits.h"
20
21#include <iostream>
22#include <fstream>
23#include <string>
24#include <cmath>
25
26
30
32
33#include "TGC_RegSelCondAlg.h"
34
35
36
37TGC_RegSelCondAlg::TGC_RegSelCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
38 MuonRegSelCondAlg( name, pSvcLocator )
39{
40 ATH_MSG_DEBUG( "TGC_RegSelCondAlg::TGC_RegSelCondAlg() " << name );
41}
42
43
48
49
50std::unique_ptr<RegSelSiLUT> TGC_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
51
52 SG::ReadCondHandle manager( m_detMgrKey, ctx );
53
54 if( !manager.range( id_range ) ) {
55 ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
56 return nullptr;
57 }
58
59
61
63 if( !cabling.range( id_range ) ) {
64 ATH_MSG_ERROR("Failed to retrieve validity range for " << m_cablingKey.key());
65 return nullptr;
66 }
67
68 const TgcIdHelper* helper = manager->tgcIdHelper();
69
70 const IdContext ModuleContext = helper->module_context();
71
72 ATH_MSG_DEBUG("createTable()");
73
74 std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>();
75
76
77 for ( auto i = helper->module_begin(); i != helper->module_end(); ++i) {
78
79 Identifier Id = *i;
80 IdentifierHash hashId{0};
81
82 helper->get_module_hash(Id, hashId);
83
84 ExpandedIdentifier exp_id;
85 if (helper->get_expanded_id( Id, exp_id, &ModuleContext)) {
86 ATH_MSG_DEBUG("Failed retrieving ExpandedIdentifier for PRD Identifier = " << Id.getString() << ". Skipping to the next PRD.");
87 continue;
88 }
89
90 int detid = ( exp_id[2]<0 ? -1 : 1 );
91 int layerid = exp_id[1]+1;
92
93 const MuonGM::TgcReadoutElement* tgc = manager->getTgcReadoutElement(Id);
94 if (tgc == nullptr) {
95 continue;
96 }
97
98 constexpr int gapMin = 1;
99 const int gapMax = tgc->nGasGaps();
100
101 Identifier chId = helper -> channelID(Id,gapMin,0,1);
102 const int chmax = tgc->nWireGangs(gapMin);
103 Amg::Vector3D posmax = tgc->channelPos(gapMin,0,chmax); // gapMax gives posmax!
104 chId = helper -> channelID(Id,gapMax,0,1);
105 constexpr int chmin = 1;
106 Amg::Vector3D posmin = tgc->channelPos(gapMax, 0, chmin); // gapMin gives posmin!
107
108 // caliculation based on active sensitive area
109
110 Amg::Vector3D posctr = tgc->globalPosition();
111 double activeheight = tgc->length();
112
113 const double zmin = posmin.z();
114 const double zmax = posmax.z();
115
116 const double rmin = posctr.perp()-0.5*activeheight;
117 const double rmax = posctr.perp()+0.5*activeheight;
118
119 const double minTheta = std::atan2(std::abs(zmin), rmin);
120 const double maxTheta = std::atan2(std::abs(zmax), rmax);
121 double etamin = -std::log(0.5*std::tan(minTheta));
122 double etamax = -std::log(0.5*std::tan(maxTheta));
123
124 if (helper->stationEta(Id) < 0) {
125 etamin = -etamin;
126 etamax = -etamax;
127 }
128
129
130 // caliculation based on active sensitive area
131 double activelongside = tgc->getLongSsize()-tgc->frameXwidth()*2.;
134 double phimin = std::atan2(posctr.y(),posctr.x()) - std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
135 double phimax = std::atan2(posctr.y(),posctr.x()) + std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
136
137 if (phimin < 0) phimin += 2.*M_PI;
138 if (phimax < 0) phimax += 2.*M_PI;
139
140 // get ROB id
141 int subDetectorId = 0; // 0x67 (A side) or 0x68 (C side)
142 int rodId = 0; // 1-12
143 cabling->getReadoutIDfromElementID(Id, subDetectorId, rodId);
144 uint32_t robId = ( ((0x0ff) & subDetectorId)<<16 ) | (rodId);
145 // end part to get ROB id
146
147 RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
148 lut->addModule( m );
149
150 }
151
152 lut->initialise();
153
154 return lut;
155
156}
157
158
159
160
161
162
163
#define M_PI
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
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.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
int nWireGangs(int gasGap) const
Returns the number of wire gangs (Random grouping of wires) in a given gas gap.
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
int nGasGaps() const
Returns the number of gas gaps associated with the readout element (2 or 3)
virtual StatusCode initialize() override
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
MuonRegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
TGC_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingKey
StatusCode initialize() override
Eigen::Matrix< double, 3, 1 > Vector3D