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
44
45
46std::unique_ptr<RegSelSiLUT> TGC_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
47
49
50 if( !manager.range( id_range ) ) {
51 ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
52 return nullptr;
53 }
54
55
57
58 ServiceHandle<MuonTGC_CablingSvc> cabling("MuonTGC_CablingSvc", name());
59 ATH_CHECK( cabling.retrieve(), {} );
60
61 const TgcIdHelper* helper = manager->tgcIdHelper();
62
63 const IdContext ModuleContext = helper->module_context();
64
65 ATH_MSG_DEBUG("createTable()");
66
67 std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>();
68
69
70 for ( auto i = helper->module_begin(); i != helper->module_end(); ++i) {
71
72 Identifier Id = *i;
73 IdentifierHash hashId{0};
74
75 helper->get_module_hash(Id, hashId);
76
77 ExpandedIdentifier exp_id;
78 if (helper->get_expanded_id( Id, exp_id, &ModuleContext)) {
79 ATH_MSG_DEBUG("Failed retrieving ExpandedIdentifier for PRD Identifier = " << Id.getString() << ". Skipping to the next PRD.");
80 continue;
81 }
82
83 int detid = ( exp_id[2]<0 ? -1 : 1 );
84 int layerid = exp_id[1]+1;
85
86 const MuonGM::TgcReadoutElement* tgc = manager->getTgcReadoutElement(Id);
87 if (tgc == nullptr) {
88 continue;
89 }
90
91 constexpr int gapMin = 1;
92 const int gapMax = tgc->nGasGaps();
93
94 Identifier chId = helper -> channelID(Id,gapMin,0,1);
95 const int chmax = tgc->nWireGangs(gapMin);
96 Amg::Vector3D posmax = tgc->channelPos(gapMin,0,chmax); // gapMax gives posmax!
97 chId = helper -> channelID(Id,gapMax,0,1);
98 constexpr int chmin = 1;
99 Amg::Vector3D posmin = tgc->channelPos(gapMax, 0, chmin); // gapMin gives posmin!
100
101 // caliculation based on active sensitive area
102
103 Amg::Vector3D posctr = tgc->globalPosition();
104 double activeheight = tgc->length();
105
106 const double zmin = posmin.z();
107 const double zmax = posmax.z();
108
109 const double rmin = posctr.perp()-0.5*activeheight;
110 const double rmax = posctr.perp()+0.5*activeheight;
111
112 const double minTheta = std::atan2(std::abs(zmin), rmin);
113 const double maxTheta = std::atan2(std::abs(zmax), rmax);
114 double etamin = -std::log(0.5*std::tan(minTheta));
115 double etamax = -std::log(0.5*std::tan(maxTheta));
116
117 if (helper->stationEta(Id) < 0) {
118 etamin = -etamin;
119 etamax = -etamax;
120 }
121
122
123 // caliculation based on active sensitive area
124 double activelongside = tgc->getLongSsize()-tgc->frameXwidth()*2.;
127 double phimin = std::atan2(posctr.y(),posctr.x()) - std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
128 double phimax = std::atan2(posctr.y(),posctr.x()) + std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
129
130 if (phimin < 0) phimin += 2.*M_PI;
131 if (phimax < 0) phimax += 2.*M_PI;
132
133 // get ROB id
134 int subDetectorId = 0; // 0x67 (A side) or 0x68 (C side)
135 int rodId = 0; // 1-12
136 cabling->getReadoutIDfromElementID(Id, subDetectorId, rodId);
137 uint32_t robId = ( ((0x0ff) & subDetectorId)<<16 ) | (rodId);
138 // end part to get ROB id
139
140 RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
141 lut->addModule( m );
142
143 }
144
145 lut->initialise();
146
147 return lut;
148
149}
150
151
152
153
154
155
156
#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)
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)
Eigen::Matrix< double, 3, 1 > Vector3D