ATLAS Offline Software
TGC_RegSelCondAlg.cxx
Go to the documentation of this file.
1 
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 
37 TGC_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 
46 std::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  const MuonTGC_CablingSvc* cabling = nullptr;
59 
60  if ( service( "MuonTGC_CablingSvc", cabling ).isFailure() ) {
61  ATH_MSG_ERROR( "Could not retrieve TGC cabling for " << name() );
62  return nullptr;
63  }
64 
65 
66 
67  const TgcIdHelper* helper = manager->tgcIdHelper();
68 
69  const IdContext ModuleContext = helper->module_context();
70 
71  ATH_MSG_DEBUG("createTable()");
72 
73  std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>();
74 
75 
76  for ( auto i = helper->module_begin(); i != helper->module_end(); ++i) {
77 
78  Identifier Id = *i;
79  IdentifierHash hashId{0};
80 
81  helper->get_module_hash(Id, hashId);
82 
83  ExpandedIdentifier exp_id;
84  if (helper->get_expanded_id( Id, exp_id, &ModuleContext)) {
85  ATH_MSG_DEBUG("Failed retrieving ExpandedIdentifier for PRD Identifier = " << Id.getString() << ". Skipping to the next PRD.");
86  continue;
87  }
88 
89  int detid = ( exp_id[2]<0 ? -1 : 1 );
90  int layerid = exp_id[1]+1;
91 
92  const MuonGM::TgcReadoutElement* tgc = manager->getTgcReadoutElement(Id);
93  if (tgc == nullptr) {
94  continue;
95  }
96 
97  constexpr int gapMin = 1;
98  const int gapMax = tgc->nGasGaps();
99 
100  Identifier chId = helper -> channelID(Id,gapMin,0,1);
101  const int chmax = tgc->nWireGangs(gapMin);
102  Amg::Vector3D posmax = tgc->channelPos(gapMin,0,chmax); // gapMax gives posmax!
103  chId = helper -> channelID(Id,gapMax,0,1);
104  constexpr int chmin = 1;
105  Amg::Vector3D posmin = tgc->channelPos(gapMax, 0, chmin); // gapMin gives posmin!
106 
107  // caliculation based on active sensitive area
108 
109  Amg::Vector3D posctr = tgc->globalPosition();
110  double activeheight = tgc->length();
111 
112  const double zmin = posmin.z();
113  const double zmax = posmax.z();
114 
115  const double rmin = posctr.perp()-0.5*activeheight;
116  const double rmax = posctr.perp()+0.5*activeheight;
117 
118  const double minTheta = std::atan2(std::abs(zmin), rmin);
119  const double maxTheta = std::atan2(std::abs(zmax), rmax);
120  double etamin = -std::log(0.5*std::tan(minTheta));
121  double etamax = -std::log(0.5*std::tan(maxTheta));
122 
123  if (helper->stationEta(Id) < 0) {
124  etamin = -etamin;
125  etamax = -etamax;
126  }
127 
128 
129  // caliculation based on active sensitive area
130  double activelongside = tgc->getLongSsize()-tgc->frameXwidth()*2.;
133  double phimin = std::atan2(posctr.y(),posctr.x()) - std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
134  double phimax = std::atan2(posctr.y(),posctr.x()) + std::atan2(activelongside/2.,posctr.perp()+activeheight/2.);
135 
136  if (phimin < 0) phimin += 2.*M_PI;
137  if (phimax < 0) phimax += 2.*M_PI;
138 
139  // get ROB id
140  int subDetectorId = 0; // 0x67 (A side) or 0x68 (C side)
141  int rodId = 0; // 1-12
142  cabling->getReadoutIDfromElementID(Id, subDetectorId, rodId);
143  uint32_t robId = ( ((0x0ff) & subDetectorId)<<16 ) | (rodId);
144  // end part to get ROB id
145 
146  RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
147  lut->addModule( m );
148 
149  }
150 
151  lut->initialise();
152 
153  return lut;
154 
155 }
156 
157 
158 
159 
160 
161 
162 
MuonRegSelCondAlg
Definition: MuonRegSelCondAlg.h:32
RegSelModule
Definition: RegSelModule.h:38
MuonTGC_CablingSvc.h
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
TgcIdHelper
Definition: TgcIdHelper.h:50
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:176
TGC_RegSelCondAlg::TGC_RegSelCondAlg
TGC_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TGC_RegSelCondAlg.cxx:37
ReadCalibFromCool.chmax
chmax
Definition: ReadCalibFromCool.py:488
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
M_PI
#define M_PI
Definition: ActiveFraction.h:11
ExpandedIdentifier
Definition: DetectorDescription/Identifier/Identifier/ExpandedIdentifier.h:108
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
MuonGM::TgcReadoutElement::nGasGaps
int nGasGaps() const
Returns the number of gas gaps associated with the readout element (2 or 3)
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
MuonGM::TgcReadoutElement::channelPos
Amg::Vector3D channelPos(const Identifier &id) const
Returns the position of the active channel (wireGang or strip)
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ReadCalibFromCool.chmin
chmin
Definition: ReadCalibFromCool.py:487
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::TgcReadoutElement::frameXwidth
double frameXwidth() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:55
WriteCondHandle.h
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
TGC_RegSelCondAlg::createTable
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
Definition: TGC_RegSelCondAlg.cxx:46
MuonGM::MuonReadoutElement::globalPosition
const Amg::Vector3D globalPosition() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:47
MuonGM::TgcReadoutElement::nWireGangs
int nWireGangs(int gasGap) const
Returns the number of wire gangs (Random grouping of wires) in a given gas gap.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IdentifierHash.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
Identifier::getString
std::string getString() const
Provide a string form of the identifier - hexadecimal.
Definition: Identifier.cxx:25
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MuonGM::TgcReadoutElement::length
double length() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/TgcReadoutElement.cxx:53
TgcReadoutElement.h
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
IdentifierHash
Definition: IdentifierHash.h:38
MuonTGC_CablingSvc
Definition: MuonTGC_CablingSvc.h:31
MuonStation.h
LArCellBinning.etamin
etamin
Definition: LArCellBinning.py:137
IdContext
class IdContext
Definition: IdContext.h:34
TGC_RegSelCondAlg.h
emacs: this is -*- c++ -*-