ATLAS Offline Software
MMT_struct.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
10 
11 MMT_Parameters::MMT_Parameters(const std::string& layerSetup, char wedgeSize, const MuonGM::MuonDetectorManager* detManager)
12  : AthMessaging(Athena::getMessageSvc(), "MMT_Parameters") {
13 
14  // Get the modules for each multiplet, the sector and side arguement (third and fifth argument, respectively) shouldn't matter
15  // since the algorithm computes locally
16  char side = 'A';
17  m_sector = wedgeSize;
18  MMDetectorHelper aHelper;
19  MMDetectorDescription* mm_top_mult1 = aHelper.Get_MMDetector(m_sector, 2, 5, 1, side); // Parameters: sector, eta, phi, layer/multiplet
20  MMDetectorDescription* mm_top_mult2 = aHelper.Get_MMDetector(m_sector, 2, 5, 2, side);
21  MMDetectorDescription* mm_bottom_mult1 = aHelper.Get_MMDetector(m_sector, 1, 5, 1, side);
22  MMDetectorDescription* mm_bottom_mult2 = aHelper.Get_MMDetector(m_sector, 1, 5, 2, side);
23 
24  MMReadoutParameters roParam_top_mult1 = mm_top_mult1->GetReadoutParameters();
25  MMReadoutParameters roParam_top_mult2 = mm_top_mult2->GetReadoutParameters();
26  MMReadoutParameters roParam_bottom_mult1 = mm_bottom_mult1->GetReadoutParameters();
27  MMReadoutParameters roParam_bottom_mult2 = mm_bottom_mult2->GetReadoutParameters();
28 
29  //Needed to get the max channels for the deadZone in the x planes... a little annoying...
30  //Only changes for small or large and per module. Phi, layer, etc don't matter (just set to 1)
31  std::string wedgeString = (wedgeSize=='L' ? "MML" : "MMS");
32 
33  m_pitch = roParam_bottom_mult1.stripPitch;
34  m_lWidth = mm_top_mult1->lWidth();
35  m_innerRadiusEta1 = roParam_bottom_mult1.distanceFromZAxis;
36  m_innerRadiusEta2 = roParam_top_mult1.distanceFromZAxis;
37  m_missedBottomEta = roParam_bottom_mult1.nMissedBottomEta;
38  m_missedBottomStereo = roParam_bottom_mult1.nMissedBottomStereo;
39  if (m_sector == 'L') {
40  ATH_MSG_DEBUG("LM1 \n" <<
41  "\t\t\t\t Total Strips: " << roParam_bottom_mult1.tStrips << " with pitch: " << roParam_bottom_mult1.stripPitch << "\n" <<
42  "\t\t\t\t KO strips TopEta: " << roParam_bottom_mult1.nMissedTopEta << " - BottomEta: " << roParam_bottom_mult1.nMissedBottomEta << "\n" <<
43  "\t\t\t\t KO strips TopStereo: " << roParam_bottom_mult1.nMissedTopStereo << " - BottomStereo: " << roParam_bottom_mult1.nMissedBottomStereo << "\n" <<
44  "\t\t\t\t (Top, Bottom, Length): (" << mm_bottom_mult1->lWidth() << ", " << mm_bottom_mult1->sWidth() << ", " << mm_bottom_mult1->Length() << ")\n" <<
45  "\t\t\t\t Zpos - Distance from ZAxis: " << roParam_bottom_mult1.zpos << " - " << roParam_bottom_mult1.distanceFromZAxis << "\n" <<
46  "\t\t\t\t dlStereoTop/Bottom: " << roParam_bottom_mult1.dlStereoTop << " " << roParam_bottom_mult1.dlStereoBottom << "\n" <<
47  "\t\t\t\t Active area --> (Bottom, Top, Height) : (" << roParam_bottom_mult1.activeBottomLength << ", " << roParam_bottom_mult1.activeTopLength << ", " << roParam_bottom_mult1.activeH << ")");
48  } else if (m_sector == 'S') {
49  ATH_MSG_DEBUG("SM1 \n" <<
50  "\t\t\t\t KO strips TopEta: " << roParam_bottom_mult1.nMissedTopEta << " - BottomEta: " << roParam_bottom_mult1.nMissedBottomEta << "\n" <<
51  "\t\t\t\t KO strips TopStereo: " << roParam_bottom_mult1.nMissedTopStereo << " - BottomStereo: " << roParam_bottom_mult1.nMissedBottomStereo << "\n" <<
52  "\t\t\t\t Total Strips: " << roParam_bottom_mult1.tStrips << " with pitch: " << roParam_bottom_mult1.stripPitch << "\n" <<
53  "\t\t\t\t (Top, Bottom, Length): (" << mm_bottom_mult1->lWidth() << ", " << mm_bottom_mult1->sWidth() << ", " << mm_bottom_mult1->Length() << ")\n" <<
54  "\t\t\t\t Zpos - Distance from ZAxis: " << roParam_bottom_mult1.zpos << " - " << roParam_bottom_mult1.distanceFromZAxis << "\n" <<
55  "\t\t\t\t dlStereoTop/Bottom: " << roParam_bottom_mult1.dlStereoTop << " " << roParam_bottom_mult1.dlStereoBottom << "\n" <<
56  "\t\t\t\t Active area --> (Bottom, Top, Height) : (" << roParam_bottom_mult1.activeBottomLength << ", " << roParam_bottom_mult1.activeTopLength << ", " << roParam_bottom_mult1.activeH << ")");
57  }
58 
59  if (m_sector == 'L') {
60  ATH_MSG_DEBUG("LM2 \n" <<
61  "\t\t\t\t Total Strips: " << roParam_top_mult1.tStrips << " with pitch: " << roParam_top_mult1.stripPitch << "\n" <<
62  "\t\t\t\t KO strips TopEta: " << roParam_top_mult1.nMissedTopEta << " - BottomEta: " << roParam_top_mult1.nMissedBottomEta << "\n" <<
63  "\t\t\t\t KO strips TopStereo: " << roParam_top_mult1.nMissedTopStereo << " - BottomStereo: " << roParam_top_mult1.nMissedBottomStereo << "\n" <<
64  "\t\t\t\t (Top, Bottom, Length): (" << mm_top_mult1->lWidth() << ", " << mm_top_mult1->sWidth() << ", " << mm_top_mult1->Length() << ")\n" <<
65  "\t\t\t\t Zpos - Distance from ZAxis: " << roParam_top_mult1.zpos << " - " << roParam_top_mult1.distanceFromZAxis << "\n" <<
66  "\t\t\t\t dlStereoTop/Bottom: " << roParam_top_mult1.dlStereoTop << " " << roParam_top_mult1.dlStereoBottom << "\n" <<
67  "\t\t\t\t Active area --> (Top, Bottom, Height) : (" << roParam_top_mult1.activeTopLength << ", " << roParam_top_mult1.activeBottomLength << ", " << roParam_top_mult1.activeH << ")");
68  } else if (m_sector == 'S') {
69  ATH_MSG_DEBUG("SM2 \n" <<
70  "\t\t\t\t KO strips TopEta: " << roParam_top_mult1.nMissedTopEta << " - BottomEta: " << roParam_top_mult1.nMissedBottomEta << "\n" <<
71  "\t\t\t\t KO strips TopStereo: " << roParam_top_mult1.nMissedTopStereo << " - BottomStereo: " << roParam_top_mult1.nMissedBottomStereo << "\n" <<
72  "\t\t\t\t (Top, Bottom, Length): (" << mm_top_mult1->lWidth() << ", " << mm_top_mult1->sWidth() << ", " << mm_top_mult1->Length() << ")\n" <<
73  "\t\t\t\t Zpos - Distance from ZAxis: " << roParam_top_mult1.zpos << " - " << roParam_top_mult1.distanceFromZAxis << "\n" <<
74  "\t\t\t\t dlStereoTop/Bottom: " << roParam_top_mult1.dlStereoTop << " " << roParam_top_mult1.dlStereoBottom << "\n" <<
75  "\t\t\t\t Active area --> (Top, Bottom, Height) : (" << roParam_top_mult1.activeTopLength << ", " << roParam_top_mult1.activeBottomLength << ", " << roParam_top_mult1.activeH << ")");
76  for (const auto &angle : roParam_top_mult1.stereoAngle) ATH_MSG_DEBUG("Stereo angle: " << angle);
77  }
78 
79  // retrieve the z-position of the planes
80  std::vector<double> z_nominal;
81  int eta = 1;
82  for (const auto& pos: MM_firststrip_positions(detManager, wedgeString, eta)) z_nominal.push_back(pos.Z());
83 
84  if(z_nominal.size() != layerSetup.size()){
85  ATH_MSG_WARNING("Number of planes in setup is "<< layerSetup.size() << ", but we have a nominal " << z_nominal.size() << " planes.");
86  throw std::runtime_error("MMT_Parameters: Invalid number of planes");
87  }
88 
89  float stereo_degree = Gaudi::Units::deg*roParam_top_mult1.stereoAngle[2];
90 
91  // MM_firststrip_positions returns the position for phi sector 1.
92  // => for the small sectors, rotate this by -1/16 of a rotation to make our lives easier.
93  // in this coordinate basis, x is up/down the wedge (radial), and y is left/right (phi).
94  float cos_rotation = std::cos(-2*M_PI / 16.0);
95  float sin_rotation = std::sin(-2*M_PI / 16.0);
96  float x_rotated = 0.0;
97  float y_rotated = 0.0;
98 
99  float st_angle = 0.0;
100 
101  float radial_pos = 0;
102  float radial_pos_xx_1 = 0, radial_pos_xx_2 = 0;
103  float radial_pos_uv_1 = 0, radial_pos_uv_2 = 0;
104 
105  for (unsigned int eta = 1; eta <= 2; eta++){
106  unsigned int layer = 1;
107  for (const auto& pos: MM_firststrip_positions(detManager, wedgeString, eta)){
108 
109  if (wedgeString=="MMS"){
110  x_rotated = pos.X()*cos_rotation - pos.Y()*sin_rotation;
111  y_rotated = pos.X()*sin_rotation + pos.Y()*cos_rotation;
112  }
113  else{
114  x_rotated = pos.X();
115  y_rotated = pos.Y();
116  }
117 
118  if (is_u(layer)) st_angle = -1*std::abs(stereo_degree);
119  else if (is_v(layer)) st_angle = std::abs(stereo_degree);
120  else st_angle = 0;
121 
122  // walk from the center of the strip to the position of the strip at the center of the wedge.
123  // NB: for X-planes, this is simply the center of the strip: tan(0) = 0.
124  radial_pos = std::abs(x_rotated - y_rotated*std::tan(st_angle * M_PI/180.0));
125 
126  if (is_x(layer) && eta==1) radial_pos_xx_1 = radial_pos;
127  else if (is_x(layer) && eta==2) radial_pos_xx_2 = radial_pos;
128  if (is_u(layer) && eta==1) radial_pos_uv_1 = radial_pos;
129  else if (is_u(layer) && eta==2) radial_pos_uv_2 = radial_pos;
130 
131  layer++;
132  }
133  }
134 
135  // store radial positions as fixed point
136  std::array<float, 2> radial_pos_xx = {radial_pos_xx_1, radial_pos_xx_2};
137  std::array<float, 2> radial_pos_uv = {radial_pos_uv_1, radial_pos_uv_2};
138  m_ybases[0] = radial_pos_xx;
139  m_ybases[1] = radial_pos_xx;
140  m_ybases[2] = radial_pos_uv;
141  m_ybases[3] = radial_pos_uv;
142  m_ybases[4] = radial_pos_uv;
143  m_ybases[5] = radial_pos_uv;
144  m_ybases[6] = radial_pos_xx;
145  m_ybases[7] = radial_pos_xx;
146 }
147 
148 std::vector<ROOT::Math::XYZVector> MMT_Parameters::MM_firststrip_positions(const MuonGM::MuonDetectorManager* detManager, const std::string& wedge, int eta) const {
149 
150  std::vector<ROOT::Math::XYZVector> positions;
151  positions.reserve(8);
152 
153  Identifier strip_id;
154  int phi = 1;
155  int strip = 200;
156  unsigned int n_multiplets = 2;
157  unsigned int n_layers = 4;
158 
159  for (unsigned int mult = 1; mult <= n_multiplets; mult++) {
160  for (unsigned int layer = 1; layer <= n_layers; layer++) {
161 
162  Amg::Vector3D pos(0.0, 0.0, 0.0);
163  strip_id = detManager->mmIdHelper()->channelID(wedge, eta, phi, mult, layer, strip);
164  const MuonGM::MMReadoutElement* readout = detManager->getMMReadoutElement(strip_id);
165  ROOT::Math::XYZVector coordinates(0.,0.,0.);
166  if (readout->stripGlobalPosition(strip_id, pos)) coordinates.SetXYZ(pos.x(), pos.y(), pos.z());
167  else ATH_MSG_WARNING("Wedge " << wedge << " phi " << phi << " multiplet " << mult << " layer " << layer << " | Unable to retrieve global positions");
168  positions.push_back(coordinates);
169 
170  ATH_MSG_DEBUG( "global z-pos. (using MMReadoutElement) for"
171  << " wedge size " << wedge
172  << " multiplet " << mult
173  << " layer " << layer
174  << " | z = " << coordinates.Z() );
175  }
176  }
177 
178  return positions;
179 }
180 
181 evInf_entry::evInf_entry(int event,int pdg,double e,double p,double ieta,double peta,double eeta,double iphi,double pphi,double ephi,double ithe,double pthe,double ethe,double dth,
182  int trn,int mun,const ROOT::Math::XYZVector& tex):
183  athena_event(event),pdg_id(pdg),E(e),pt(p),eta_ip(ieta),eta_pos(peta),eta_ent(eeta),phi_ip(iphi),phi_pos(pphi),phi_ent(ephi),theta_ip(ithe),theta_pos(pthe),theta_ent(ethe),
184  dtheta(dth),truth_n(trn),mu_n(mun),vertex(tex) {}
185 
186 
187 hitData_entry::hitData_entry(int ev, double gt, double q, int vmm, int mmfe, int pl, int st, int est, int phi, int mult, int gg, double locX, double tr_the, double tru_phi,
188  bool q_tbg, int bct, const ROOT::Math::XYZVector& tru, const ROOT::Math::XYZVector& rec):
189  event(ev),gtime(gt),charge(q),VMM_chip(vmm),MMFE_VMM(mmfe),plane(pl),strip(st),station_eta(est),station_phi(phi),multiplet(mult),gasgap(gg),localX(locX),tru_theta_ip(tr_the),tru_phi_ip(tru_phi),truth_nbg(q_tbg),BC_time(bct),truth(tru),recon(rec) {}
190 
192  const std::string &stationName,
193  double tmpGTime,
194  const ROOT::Math::XYZVector& truthLPos,
195  const ROOT::Math::XYZVector& stripLPos,
196  const ROOT::Math::XYZVector& stripGPos
197  ):
198  digit(digit),
199  stName(stationName),
200  gTime(tmpGTime),
201  truth_lpos(truthLPos),
202  strip_lpos(stripLPos),
203  strip_gpos(stripGPos){}
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
MMReadoutParameters::activeH
double activeH
Definition: MMDetectorDescription.h:30
MMReadoutParameters::nMissedTopEta
int nMissedTopEta
Definition: MMDetectorDescription.h:34
MMReadoutParameters::tStrips
int tStrips
Definition: MMDetectorDescription.h:42
SiliconTech::strip
@ strip
MMDetectorDescription.h
digitWrapper::digitWrapper
digitWrapper(const MmDigit *digit=0, const std::string &stationName=std::string(), double tmpGTime=0, const ROOT::Math::XYZVector &truthLPos=ROOT::Math::XYZVector(), const ROOT::Math::XYZVector &stripLPos=ROOT::Math::XYZVector(), const ROOT::Math::XYZVector &stripGPos=ROOT::Math::XYZVector())
Definition: MMT_struct.cxx:191
MMReadoutParameters::dlStereoBottom
double dlStereoBottom
Definition: MMDetectorDescription.h:41
MMReadoutParameters::activeBottomLength
double activeBottomLength
Definition: MMDetectorDescription.h:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
Trk::locX
@ locX
Definition: ParamDefs.h:37
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
MMT_Parameters::m_sector
char m_sector
Definition: MMT_struct.h:54
hitData_entry::hitData_entry
hitData_entry(int ev=0, double gt=0, double q=0, int vmm=0, int mmfe=0, int pl=0, int st=0, int est=0, int phi=0, int mult=0, int gg=0, double locX=0, double tr_the=0, double tru_phi=0, bool q_tbg=0, int bct=0, const ROOT::Math::XYZVector &tru=ROOT::Math::XYZVector(), const ROOT::Math::XYZVector &rec=ROOT::Math::XYZVector())
Definition: MMT_struct.cxx:187
MMReadoutParameters::activeTopLength
double activeTopLength
Definition: MMDetectorDescription.h:29
MMT_Parameters::m_missedBottomEta
double m_missedBottomEta
Definition: MMT_struct.h:56
test_pyathena.pt
pt
Definition: test_pyathena.py:11
MMT_Parameters::MMT_Parameters
MMT_Parameters(const std::string &layerSetup, char wedgeSize, const MuonGM::MuonDetectorManager *detManager)
Definition: MMT_struct.cxx:11
M_PI
#define M_PI
Definition: ActiveFraction.h:11
MmDigit
Definition: MmDigit.h:20
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonGM::MuonDetectorManager::mmIdHelper
const MmIdHelper * mmIdHelper() const
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:244
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
MMReadoutParameters::zpos
double zpos
Definition: MMDetectorDescription.h:25
MMDetectorDescription::lWidth
double lWidth() const
Definition: MMDetectorDescription.h:52
MMDetectorDescription::GetReadoutParameters
MMReadoutParameters & GetReadoutParameters()
Definition: MMDetectorDescription.h:69
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
MMT_Parameters::m_pitch
double m_pitch
Definition: MMT_struct.h:55
TRT::Hit::side
@ side
Definition: HitInfo.h:83
MMDetectorDescription::sWidth
double sWidth() const
Definition: MMDetectorDescription.h:51
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ev
int ev
Definition: globals.cxx:25
MMDetectorDescription
Definition: MMDetectorDescription.h:45
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MMT_Parameters::m_missedBottomStereo
double m_missedBottomStereo
Definition: MMT_struct.h:56
angle
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
Definition: TRTDetectorFactory_Full.cxx:73
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
MuonGM::MMReadoutElement::stripGlobalPosition
bool stripGlobalPosition(const Identifier &id, Amg::Vector3D &gpos) const
Definition: MMReadoutElement.h:280
MMReadoutParameters::stripPitch
double stripPitch
Definition: MMDetectorDescription.h:19
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
MMT_Parameters::is_v
bool is_v(int plane) const
Definition: MMT_struct.h:38
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
MMT_Parameters::m_lWidth
double m_lWidth
Definition: MMT_struct.h:55
MMDetectorHelper::Get_MMDetector
MMDetectorDescription * Get_MMDetector(char type, int ieta, int iphi, int layer=1, char side='A')
Definition: MMDetectorHelper.cxx:41
MMT_struct.h
MMT_Parameters::m_ybases
std::array< std::array< float, 2 >, 8 > m_ybases
Definition: MMT_struct.h:53
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
charge
double charge(const T &p)
Definition: AtlasPID.h:756
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
MMReadoutParameters::nMissedTopStereo
int nMissedTopStereo
Definition: MMDetectorDescription.h:36
MMReadoutParameters::stereoAngle
std::vector< double > stereoAngle
Definition: MMDetectorDescription.h:23
MMT_Parameters::MM_firststrip_positions
std::vector< ROOT::Math::XYZVector > MM_firststrip_positions(const MuonGM::MuonDetectorManager *detManager, const std::string &wedge, int eta) const
Definition: MMT_struct.cxx:148
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
CalibCoolCompareRT.station_eta
station_eta
Definition: CalibCoolCompareRT.py:88
MuonChannelDesign.h
MMT_Parameters::is_u
bool is_u(int plane) const
Definition: MMT_struct.h:34
MMReadoutParameters::nMissedBottomStereo
int nMissedBottomStereo
Definition: MMDetectorDescription.h:37
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
MMDetectorDescription::Length
double Length() const
Definition: MMDetectorDescription.h:53
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonGM::MuonDetectorManager::getMMReadoutElement
const MMReadoutElement * getMMReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonDetectorManager.cxx:255
MMReadoutParameters::nMissedBottomEta
int nMissedBottomEta
Definition: MMDetectorDescription.h:35
MMT_Parameters::m_innerRadiusEta2
double m_innerRadiusEta2
Definition: MMT_struct.h:55
MuonGM::MMReadoutElement
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
Definition: MMReadoutElement.h:25
MMT_Parameters::m_innerRadiusEta1
double m_innerRadiusEta1
Definition: MMT_struct.h:55
extractSporadic.q
list q
Definition: extractSporadic.py:98
MMReadoutParameters::dlStereoTop
double dlStereoTop
Definition: MMDetectorDescription.h:40
MMT_Parameters::is_x
bool is_x(int plane) const
Definition: MMT_struct.h:30
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
MMDetectorHelper
Definition: MMDetectorHelper.h:24
MMReadoutParameters::distanceFromZAxis
double distanceFromZAxis
Definition: MMDetectorDescription.h:26
MmIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:736
CalibCoolCompareRT.station_phi
station_phi
Definition: CalibCoolCompareRT.py:87
MMDetectorHelper.h
MMReadoutParameters
Definition: MMDetectorDescription.h:18
evInf_entry::evInf_entry
evInf_entry(int event=0, int pdg=0, double e=0, double p=0, double ieta=0, double peta=0, double eeta=0, double iphi=0, double pphi=0, double ephi=0, double ithe=0, double pthe=0, double ethe=0, double dth=0, int trn=0, int mun=0, const ROOT::Math::XYZVector &tex=ROOT::Math::XYZVector())
Definition: MMT_struct.cxx:181
Identifier
Definition: IdentifierFieldParser.cxx:14