ATLAS Offline Software
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 
7 #include "VP1Utils/VP1DetInfo.h"
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 //____________________________________________________________________
22  : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_stgc(stgc)
23 {
25 }
26 
27 // fixme: uncomment and update
29 SoTransform * PRDHandle_sTGC::createTransform() const
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 //____________________________________________________________________
60 void 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 
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.
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  }
HitsSoNodeManager.h
MuonGM::MuonPadDesign
Parameters defining the design of the readout sTGC pads.
Definition: MuonPadDesign.h:40
MuonGM::MuonClusterReadoutElement::transform
virtual const Amg::Transform3D & transform() const override
Return local to global transform.
Definition: MuonClusterReadoutElement.h:124
MuonGM::MuonPadDesign::CornerArray
std::array< Amg::Vector2D, 4 > CornerArray
calculate local channel corners for a given channel number
Definition: MuonPadDesign.h:104
PRDHandle_sTGC::regionIndex
int regionIndex()
Definition: PRDHandle_sTGC.cxx:166
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
VP1Msg.h
MuonGM::MuonChannelDesign::inputWidth
double inputWidth
Definition: MuonChannelDesign.h:36
CornerArray
MuonGM::MuonPadDesign::CornerArray CornerArray
Definition: sTgcPadPlottingAlg.cxx:19
MuonGM::sTgcReadoutElement::getDesign
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:281
VP1DetInfo::stgcIDHelper
static const sTgcIdHelper * stgcIDHelper()
Definition: VP1DetInfo.cxx:161
PRDHandle_sTGC::createTransform
SoTransform * createTransform() const
Definition: PRDHandle_sTGC.cxx:29
SoTransparency.h
PRDHandle_sTGC.h
PRDHandleBase::common
PRDSysCommonData * common() const
Definition: PRDHandleBase.h:53
MuonGM::sTgcReadoutElement::stripPosition
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...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:323
PRDSysCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: PRDSysCommonData.h:79
VP1LinAlgUtils.h
VP1DetInfo.h
GeoPrimitives.h
MuonGM::MuonChannelDesign::minYSize
double minYSize() const
Definition: MuonChannelDesign.h:480
PRDCollHandleBase
Definition: PRDCollHandleBase.h:25
MuonGM::MuonStation::getPhiIndex
int getPhiIndex() const
a la AMDB
Definition: MuonStation.h:162
sTgcIdHelper::channel
int channel(const Identifier &id) const override
Definition: sTgcIdHelper.cxx:1027
SoTransparency::initClass
static void initClass()
Definition: SoTransparency.cxx:29
PRDHandle_sTGC::PRDHandle_sTGC
PRDHandle_sTGC(PRDCollHandle_sTGC *, const Muon::sTgcPrepData *)
Definition: PRDHandle_sTGC.cxx:21
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:135
MuonGM::sTgcReadoutElement
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:28
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
MuonGM::MuonStation
Definition: MuonStation.h:51
HitsSoNodeManager::getShapeNode_Strip
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
Definition: HitsSoNodeManager.cxx:269
min
#define min(a, b)
Definition: cfImp.cxx:40
PRDHandle_sTGC::stgc
const Muon::sTgcPrepData * stgc() const
Definition: PRDHandle_sTGC.h:23
PRDHandle_sTGC::m_stgc
const Muon::sTgcPrepData * m_stgc
Definition: PRDHandle_sTGC.h:30
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
MuonGM::MuonPadDesign::padCorners
padCorners
Definition: MuonPadDesign.h:105
sTgcIdHelper
Definition: sTgcIdHelper.h:55
HitsSoNodeManager::getShapeNode_Pad
SoNode * getShapeNode_Pad(double length, double minWidth=0, double maxWidth=0, double depth=0)
Definition: HitsSoNodeManager.cxx:363
MuonGM::MuonChannelDesign::channelLength
double channelLength(int channel) const
STRIPS ONLY: calculate channel length for a given strip number.
Definition: MuonChannelDesign.h:391
MuonGM::MuonChannelDesign
Definition: MuonChannelDesign.h:24
Muon::sTgcPrepData::detectorElement
virtual const MuonGM::sTgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Definition: sTgcPrepData.h:139
VP1Msg::messageDebug
static void messageDebug(const QString &)
Definition: VP1Msg.cxx:39
MuonGM::MuonPadDesign::channelCorners
bool channelCorners(const std::pair< int, int > &pad, CornerArray &corners) const
Definition: MuonPadDesign.cxx:157
MuonGM::MuonChannelDesign::maxYSize
double maxYSize() const
Definition: MuonChannelDesign.h:479
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
sTgcIdHelper::Pad
@ Pad
Definition: sTgcIdHelper.h:190
MuonGM::MuonStation::getEtaIndex
int getEtaIndex() const
a la AMDB
Definition: MuonStation.h:163
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
MuonGM::MuonChannelDesign::nch
int nch
Definition: MuonChannelDesign.h:34
PRDHandleBase
Definition: PRDHandleBase.h:35
PRDCollHandle_sTGC
Definition: PRDCollHandle_sTGC.h:10
MuonGM::sTgcReadoutElement::getPadDesign
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/sTgcReadoutElement.h:287
MuonStation.h
Muon::sTgcPrepData
Class to represent sTgc measurements.
Definition: sTgcPrepData.h:20
sTgcIdHelper::channelType
int channelType(const Identifier &id) const
Definition: sTgcIdHelper.cxx:1022
VP1LinAlgUtils::toSoTransform
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Definition: VP1LinAlgUtils.cxx:40
PRDHandle_sTGC::buildShapes
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
Definition: PRDHandle_sTGC.cxx:60
HitsSoNodeManager::getShapeNode_Wire
SoNode * getShapeNode_Wire(double length, double minWidth=0, double maxWidth=0, double depth=0)
Definition: HitsSoNodeManager.cxx:317