ATLAS Offline Software
Loading...
Searching...
No Matches
PRDHandle_sTGC.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "VP1Base/VP1Msg.h"
11
12#include <Inventor/nodes/SoSeparator.h>
13#include <Inventor/nodes/SoTranslation.h>
14#include <Inventor/nodes/SoTransform.h>
15
17
19
20//____________________________________________________________________
26
27// fixme: uncomment and update
30{
31 std::cout<<"creating sTGC transform:"<< std::endl;
32
33 const sTgcIdHelper * idhelper = VP1DetInfo::stgcIDHelper();
34 const Muon::sTgcPrepData * prd = stgc();
35 if (!prd || !idhelper) return new SoTransform;
36
37 Identifier id = prd->identify();
38
39 const MuonGM::sTgcReadoutElement* detEl = prd->detectorElement();
40 if (!detEl) return new SoTransform;
41
42 const Amg::Transform3D& transf = detEl->transform(id);
43
44 SoTransform * theHitTransform = VP1LinAlgUtils::toSoTransform(transf);
45
46 // return the channel position
47 Amg::Vector2D locPos;
48
49 if (!detEl->stripPosition(id,locPos) ) {
50 return theHitTransform;
51 }
52
53 theHitTransform = VP1LinAlgUtils::toSoTransform(transf*Amg::Translation3D(locPos.x(),locPos.y(),0.));
54
55 return theHitTransform;
56}
57
58
59//____________________________________________________________________
60void PRDHandle_sTGC::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed)
61{
62
63 VP1Msg::messageDebug("buildShapes()");
64
65 const sTgcIdHelper * idhelper = VP1DetInfo::stgcIDHelper();
66
67 if (!idhelper) {
68 VP1Msg::messageDebug("idhelper is null. Returning without building the shape...");
69 return;
70 }
71 const Muon::sTgcPrepData * prd = stgc();
72
73 if (!prd) {
74 VP1Msg::messageDebug("prd is null. Returning without building the shape...");
75 return;
76 }
77
78 Identifier id = prd->identify();
79
80 const MuonGM::sTgcReadoutElement* detEl = prd->detectorElement();
81
82 if (idhelper->channelType(id)==sTgcIdHelper::Pad) { // pads
83 VP1Msg::messageDebug("Building sTgc pad...");
84 const MuonGM::MuonPadDesign* pad_design = detEl->getPadDesign( id );
85
86 // use point shape for simple view
87// shape_simple = common()->nodeManager()->getShapeNode_Strip(0.); // FIXME: ORIGINAL FROM SHARKA. Works perfectly but the STGC elements are point-like until very very very close...
88
89 // local position of the pad
90 if (!pad_design) return;
91
92 using padCorners = MuonGM::MuonPadDesign::padCorners;
93 using CornerArray = MuonGM::MuonPadDesign::CornerArray;
94 CornerArray padEdges{};
95 pad_design->channelCorners(idhelper->channel(id), padEdges);
96 double etaWidth = padEdges[padCorners::topRight].x() - padEdges[padCorners::botRight].x();
97 double phiMinWidth = padEdges[padCorners::botLeft].y();
98 double phiMaxWidth = padEdges[padCorners::topLeft].y();
99
100 shape_simple = common()->nodeManager()->getShapeNode_Pad(etaWidth,phiMinWidth,phiMaxWidth,0.01); // fixme: now shape_simple == shape_detailed
101
102 // use trapezoid shape for detailed view
103 SoSeparator * errDetailed = new SoSeparator;
104 errDetailed->addChild(common()->nodeManager()->getShapeNode_Pad(etaWidth,phiMinWidth,phiMaxWidth,0.01));
105
106 shape_detailed = errDetailed;
107
108 return;
109 } else if (idhelper->channelType(id)==2) { // wire gangs
110 VP1Msg::messageDebug("Building sTgc wire gang...");
111 const MuonGM::MuonChannelDesign* design = detEl->getDesign( id );
112
113 // use point shape for simple view
114// shape_simple = common()->nodeManager()->getShapeNode_Strip(0.); // FIXME: ORIGINAL FROM SHARKA. Works perfectly but the STGC elements are point-like until very very very close...
115
116 // local position of the wire gang
117 Amg::Vector2D locWire;
118 if (!detEl->stripPosition(id,locWire) ) return;
119 if (!design) return;
120
121 double etaWidth=design->channelLength(idhelper->channel(id));
122 double phiMaxWidth=design->maxYSize()/design->nch;
123 double phiMinWidth=design->minYSize()/design->nch;
124
125
126 shape_simple = common()->nodeManager()->getShapeNode_Wire(etaWidth,phiMinWidth,phiMaxWidth,0.01); // fixme: now shape_simple == shape_detailed
127
128 // use trapezoid shape for detailed view
129 SoSeparator * errDetailed = new SoSeparator;
130 errDetailed->addChild(common()->nodeManager()->getShapeNode_Wire(etaWidth,phiMinWidth,phiMaxWidth,0.01));
131
132 shape_detailed = errDetailed;
133
134 return;
135 } else if (idhelper->channelType(id)==1) { // strips
136 VP1Msg::messageDebug("Building sTgc strip...");
137 const MuonGM::MuonChannelDesign* design = detEl->getDesign( id );
138
139 // use point shape for simple view
140// shape_simple = common()->nodeManager()->getShapeNode_Strip(0.); // FIXME: ORIGINAL FROM SHARKA. Works perfectly but the STGC elements are point-like until very very very close...
141
142 // local position of the wire gang
143 Amg::Vector2D locPos;
144 if (!detEl->stripPosition(id,locPos) ) return;
145 if (!design) return;
146
147 double striplength=design->channelLength(idhelper->channel(id));
148 double stripWidth=design->inputWidth;
149
150 shape_simple = common()->nodeManager()->getShapeNode_Strip(striplength,std::min(10.0,stripWidth),0.01); // fixme: now shape_simple == shape_detailed
151
152 // use rectangular shape for detailed view
153 SoSeparator * errDetailed = new SoSeparator;
154 errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,std::min(10.0,stripWidth),0.01));
155
156 shape_detailed = errDetailed;
157
158 return;
159 }
160
161 return;
162
163 }
164
165//____________________________________________________________________
167 {
168 //Unique for each station.
169 const MuonGM::MuonStation* station = m_stgc->detectorElement()->parentMuonStation();
170 if (!station) {VP1Msg::message("Warning - sTGC station gives null parent. Something is wrong with the geometry!"); return 0;}
171
172 return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
173 }
SoNode * getShapeNode_Wire(double length, double minWidth=0, double maxWidth=0, double depth=0)
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
SoNode * getShapeNode_Pad(double length, double minWidth=0, double maxWidth=0, double depth=0)
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
Class to represent sTgc measurements.
virtual const MuonGM::sTgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
PRDHandleBase(PRDCollHandleBase *)
PRDSysCommonData * common() const
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
SoTransform * createTransform() const
PRDHandle_sTGC(PRDCollHandle_sTGC *, const Muon::sTgcPrepData *)
const Muon::sTgcPrepData * stgc() const
const Muon::sTgcPrepData * m_stgc
HitsSoNodeManager * nodeManager() const
static void initClass()
Identifier identify() const
return the identifier
static const sTgcIdHelper * stgcIDHelper()
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Translation< double, 3 > Translation3D
double channelLength(int channel) const
STRIPS ONLY: calculate channel length for a given strip number.
Parameters defining the design of the readout sTGC pads.
bool channelCorners(const std::pair< int, int > &pad, CornerArray &corners) const
std::array< Amg::Vector2D, 4 > CornerArray
calculate local channel corners for a given channel number