ATLAS Offline Software
Loading...
Searching...
No Matches
MM_RegSelCondAlg.cxx
Go to the documentation of this file.
1
13
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
35
36
37#include "MM_RegSelCondAlg.h"
38
39
40MM_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
47std::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
#define M_PI
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
double length(const pvec &v)
emacs: this is -*- c++ -*-
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::unique_ptr< RegSelSiLUT > createTable(const EventContext &ctx, EventIDRange &id_range) const override
MM_RegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
MuonDetectorManager from the conditions store.
MuonRegSelCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
const std::vector< uint32_t > & get_ids() const
std::string depth
tag string for intendation
Definition fastadd.cxx:46
Eigen::Matrix< double, 3, 1 > Vector3D