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 
32 
34 
36 
37 #include "RegSelLUT/RegSelSiLUT.h"
38 
39 
40 #include "MM_RegSelCondAlg.h"
41 
42 
43 MM_RegSelCondAlg::MM_RegSelCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
44  MuonRegSelCondAlg( name, pSvcLocator )
45 {
46  ATH_MSG_DEBUG( "MM_RegSelCondAlg::MM_RegSelCondAlg() " << name );
47 }
48 
49 
50 std::unique_ptr<RegSelSiLUT> MM_RegSelCondAlg::createTable( const EventContext& ctx, EventIDRange& id_range ) const {
51 
54 
55  if( !manager.range( id_range ) ) {
56  ATH_MSG_ERROR("Failed to retrieve validity range for " << manager.key());
57  return {nullptr};
58  }
59 
60 
61 
62  const MmIdHelper* helper = manager->mmIdHelper();
63 
64 
65  std::vector<Identifier>::const_iterator idfirst = helper->module_begin();
66  std::vector<Identifier>::const_iterator idlast = helper->module_end();
67 
69  const IdContext ModuleContext = helper->module_context();
70 
71  ATH_MSG_DEBUG("createTable()");
72 
73  std::unique_ptr<RegSelSiLUT> lut = std::make_unique<RegSelSiLUT>(RegSelSiLUT::MM);
74 
75 
76  for ( std::vector<Identifier>::const_iterator i=idfirst ; i!=idlast ; ++i ) {
77 
78  Identifier Id = *i;
79  IdentifierHash hashId;
80 
81  helper->get_hash( Id, hashId, &ModuleContext );
82 
83  const MuonGM::MMReadoutElement* mm = manager->getMMReadoutElement(Id);
84  if (!mm) continue;
85 
86  std::string stationName=mm->getStationName();
87  int stationEta=mm->getStationEta();
88  int stationPhi=mm->getStationPhi();
89  int multilayer = helper->multilayer(Id);
90 
91  char side = mm->getStationEta() < 0 ? 'C' : 'A';
92 
93  char sector_l = stationName.substr(2,1)=="L" ? 'L' : 'S';
94 
95  MMDetectorHelper aHelper;
96  MMDetectorDescription* md = aHelper.Get_MMDetector( sector_l, std::abs(stationEta), stationPhi, multilayer, side );
97 
99 
100  Amg::Vector3D mmPos = mm->center();
101 
102 
103  double swidth = md->sWidth();
104  double lwidth = md->lWidth();
105 
106  double length = md->Length();
107  double depth = md->Tck();
108 
109  double moduleR = std::sqrt( mmPos.mag()*mmPos.mag() - mmPos.z()*mmPos.z());
110 
111  double zmin = mmPos.z()-0.5*depth;
112  double zmax = mmPos.z()+0.5*depth;
113 
114  // std::cout << "MM:module: rcen: " << moduleR << "\tlength: " << length << "\tswidth: " << swidth << "\tlwidth: " << lwidth << std::endl;
115 
116  double rmin = moduleR-0.5*length;
117  double rmax = std::sqrt( (moduleR+0.5*length)*(moduleR+0.5*length) + 0.25*lwidth*lwidth );
118 
119  double dphi1 = std::atan( (0.5*lwidth)/(moduleR+0.5*length) );
120  double dphi2 = std::atan( (0.5*swidth)/(moduleR-0.5*length) );
121 
122  double dphi = ( dphi1 > dphi2 ? dphi1 : dphi2 );
123 
124  double phimin = mmPos.phi()-dphi;
125  double phimax = mmPos.phi()+dphi;
126 
127  if ( phimin > M_PI ) phimin -= 2*M_PI;
128  if ( phimin < -M_PI ) phimin += 2*M_PI;
129 
130  if ( phimax > M_PI ) phimax -= 2*M_PI;
131  if ( phimax < -M_PI ) phimax += 2*M_PI;
132 
133  int layerid = multilayer;
134  int detid = ( side == 'C' ? -1 : 1 );
135 
137  Muon::nsw::helper::NSWOfflineRobId robIdHelper(stationName,static_cast<int8_t>(stationEta),static_cast<uint8_t>(stationPhi));
138  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
139  RegSelModule m( zmin, zmax, rmin, rmax, phimin, phimax, layerid, detid, robId, hashId );
140  lut->addModule( m );
141  }
142 
143  }
144 
145  lut->initialise();
146 
147  return lut;
148 
149 }
150 
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:129
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
MMDetectorDescription.h
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:575
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:176
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
MMDetectorDescription::lWidth
double lWidth() const
Definition: MMDetectorDescription.h:52
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
MMDetectorDescription::sWidth
double sWidth() const
Definition: MMDetectorDescription.h:51
MMDetectorDescription
Definition: MMDetectorDescription.h:45
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:92
MM_RegSelCondAlg::createTable
std::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
Definition: MM_RegSelCondAlg.cxx:50
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WriteCondHandle.h
PixelAthClusterMonAlgCfg.zmax
zmax
Definition: PixelAthClusterMonAlgCfg.py:176
MuonReadoutElement.h
MMDetectorHelper::Get_MMDetector
MMDetectorDescription * Get_MMDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition: MMDetectorHelper.cxx:41
Muon::nsw::helper::NSWOfflineRobId
Definition: NSWOfflineHelper.h:49
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
IdentifierHash.h
MM_RegSelCondAlg::MM_RegSelCondAlg
MM_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: MM_RegSelCondAlg.cxx:43
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
MMDetectorDescription::Length
double Length() const
Definition: MMDetectorDescription.h:53
MuonGM::MMReadoutElement
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
Definition: MMReadoutElement.h:23
MMDetectorDescription::Tck
double Tck() const
Definition: MMDetectorDescription.h:54
python.Logging.manager
manager
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/Logging.py:92
MMDetectorHelper
Definition: MMDetectorHelper.h:24
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
IdentifierHash
Definition: IdentifierHash.h:38
MuonStation.h
MMDetectorHelper.h
IdContext
class IdContext
Definition: IdContext.h:34
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26