ATLAS Offline Software
MM_RegSelCondAlg.cxx
Go to the documentation of this file.
1 
14 #include "GaudiKernel/EventIDRange.h"
16 
17 #include "CLHEP/Units/SystemOfUnits.h"
19 
20 #include <iostream>
21 #include <fstream>
22 #include <string>
23 #include <cmath>
24 
25 
28 
31 
33 
34 #include "RegSelLUT/RegSelSiLUT.h"
35 
36 
37 #include "MM_RegSelCondAlg.h"
38 
39 
40 MM_RegSelCondAlg::MM_RegSelCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
41  MuonRegSelCondAlg( name, pSvcLocator )
42 {
43  ATH_MSG_DEBUG( "MM_RegSelCondAlg::MM_RegSelCondAlg() " << name );
44 }
45 
46 
47 std::unique_ptr<RegSelSiLUT> MM_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
48 
51 
52  if( !manager.range( id_range ) ) {
53  ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
54  return {nullptr};
55  }
56 
57 
58 
59  const MmIdHelper* helper = manager->mmIdHelper();
60 
61 
62  std::vector<Identifier>::const_iterator idfirst = helper->module_begin();
63  std::vector<Identifier>::const_iterator idlast = helper->module_end();
64 
66  const IdContext ModuleContext = helper->module_context();
67 
68  ATH_MSG_DEBUG("createTable()");
69 
70  std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>(RegSelSiLUT::MM);
71 
72  for ( std::vector<Identifier>::const_iterator i=idfirst ; i!=idlast ; ++i ) {
73 
74  Identifier Id = *i;
75  IdentifierHash hashId;
76 
77  helper->get_hash( Id, hashId, &ModuleContext );
78 
79  const MuonGM::MMReadoutElement* mm = manager->getMMReadoutElement(Id);
80  if (!mm) continue;
81 
82  std::string stationName=mm->getStationName();
83  int stationEta=mm->getStationEta();
84  int stationPhi=mm->getStationPhi();
85  int multilayer = helper->multilayer(Id);
86 
87  char side = mm->getStationEta() < 0 ? 'C' : 'A';
88 
90  Amg::Vector3D mmPos = mm->center();
91 
92  double swidth = mm->getSsize();
93  double lwidth = mm->getLongSsize();
94 
95  double length = mm->getRsize();
96  double depth = mm->getZsize();
97 
98  double moduleR = std::sqrt( mmPos.mag()*mmPos.mag() - mmPos.z()*mmPos.z());
99 
100  double zmin = mmPos.z()-0.5*depth;
101  double zmax = mmPos.z()+0.5*depth;
102 
103  // std::cout << "MM:module: rcen: " << moduleR << "\tlength: " << length << "\tswidth: " << swidth << "\tlwidth: " << lwidth << std::endl;
104 
105  double rmin = moduleR-0.5*length;
106  double rmax = std::sqrt( (moduleR+0.5*length)*(moduleR+0.5*length) + 0.25*lwidth*lwidth );
107 
108  double dphi1 = std::atan( (0.5*lwidth)/(moduleR+0.5*length) );
109  double dphi2 = std::atan( (0.5*swidth)/(moduleR-0.5*length) );
110 
111  double dphi = ( dphi1 > dphi2 ? dphi1 : dphi2 );
112 
113  double phimin = mmPos.phi()-dphi;
114  double phimax = mmPos.phi()+dphi;
115 
116  if ( phimin > M_PI ) phimin -= 2*M_PI;
117  if ( phimin < -M_PI ) phimin += 2*M_PI;
118 
119  if ( phimax > M_PI ) phimax -= 2*M_PI;
120  if ( phimax < -M_PI ) phimax += 2*M_PI;
121 
122  int layerid = multilayer;
123  int detid = ( side == 'C' ? -1 : 1 );
124 
126  Muon::nsw::helper::NSWOfflineRobId robIdHelper(stationName,static_cast<int8_t>(stationEta),static_cast<uint8_t>(stationPhi));
127  for(uint32_t robId : robIdHelper.get_ids()){ // if the NSW is read out in a split ROB configuration there are multiple ROB ids associated to one region of interest
128  RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
129  lut->addModule( m );
130  }
131 
132  }
133 
134  lut->initialise();
135 
136  return lut;
137 
138 }
139 
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:158
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
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PixelAthClusterMonAlgCfg.zmin
zmin
Definition: PixelAthClusterMonAlgCfg.py:169
M_PI
#define M_PI
Definition: ActiveFraction.h:11
RegSelSiLUT.h
emacs: this is -*- c++ -*-
MuonRegSelCondAlg::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
Definition: MuonRegSelCondAlg.h:46
ITkPixEncoding::lut
constexpr auto lut(Generator &&f)
Definition: ITkPixQCoreEncodingLUT.h:19
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
RegSelSiLUT::MM
@ MM
Definition: RegSelSiLUT.h:45
TRT::Hit::side
@ side
Definition: HitInfo.h:83
runBeamSpotCalibration.helper
helper
Definition: runBeamSpotCalibration.py:112
MMReadoutElement.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
MM_RegSelCondAlg.h
emacs: this is -*- c++ -*-
lumiFormat.i
int i
Definition: lumiFormat.py:85
MM_RegSelCondAlg::createTable
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
Definition: MM_RegSelCondAlg.cxx:47
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteCondHandle.h
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:169
MuonReadoutElement.h
Muon::nsw::helper::NSWOfflineRobId
Definition: NSWOfflineHelper.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
IdentifierHash.h
MM_RegSelCondAlg::MM_RegSelCondAlg
MM_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MM_RegSelCondAlg.cxx:40
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
NSWOfflineHelper.h
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
Muon::nsw::helper::NSWOfflineRobId::get_ids
const std::vector< uint32_t > & get_ids() const
Definition: NSWOfflineHelper.h:54
MmIdHelper
Definition: MmIdHelper.h:54
MuonGM::MMReadoutElement
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
Definition: MMReadoutElement.h:25
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:156
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
MuonStation.h
IdContext
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
Definition: IdContext.h:26
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
Identifier
Definition: IdentifierFieldParser.cxx:14