ATLAS Offline Software
Loading...
Searching...
No Matches
PRDHandle_TGC Class Reference

#include <PRDHandle_TGC.h>

Inheritance diagram for PRDHandle_TGC:
Collaboration diagram for PRDHandle_TGC:

Public Member Functions

 PRDHandle_TGC (PRDCollHandle_TGC *, const Muon::TgcPrepData *)
virtual ~PRDHandle_TGC ()
SoTransform * createTransform () const
void buildShapes (SoNode *&shape_simple, SoNode *&shape_detailed)
int regionIndex ()
const Muon::TgcPrepDatatgc () const
const Trk::PrepRawDatagetPRD () const
bool inMuonChamber () const
GeoPVConstLink parentMuonChamberPV () const
void setVisible (bool)
bool visible () const
virtual bool highLight () const
virtual bool transformUsesSurfacePositionOnly () const
SoSeparator * sepSimple () const
SoSeparator * sepDetailed () const
PRDSysCommonDatacommon () const
virtual Amg::Vector3D center () const
Amg::Vector3D positionPRD () const
Amg::Vector3D positionSecondPRD () const
Amg::Transform3D getTransform_CLHEP () const
void update3DObjects ()
void updateMaterial ()
virtual QStringList clicked () const
PRDCollHandleBasecollHandle () const
virtual const Trk::PrepRawDatagetSecondPRD () const
virtual bool isSane () const
 Returns false if the PRD is not safe to draw.

Private Attributes

const Muon::TgcPrepDatam_tgc
Impm_d
PRDSysCommonDatam_common
bool m_visible

Detailed Description

Definition at line 12 of file PRDHandle_TGC.h.

Constructor & Destructor Documentation

◆ PRDHandle_TGC()

PRDHandle_TGC::PRDHandle_TGC ( PRDCollHandle_TGC * collhandle,
const Muon::TgcPrepData * tgc )

Definition at line 24 of file PRDHandle_TGC.cxx.

25 : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_tgc(tgc)
26{
28}
PRDHandleBase(PRDCollHandleBase *)
const Muon::TgcPrepData * m_tgc
const Muon::TgcPrepData * tgc() const
static void initClass()

◆ ~PRDHandle_TGC()

virtual PRDHandle_TGC::~PRDHandle_TGC ( )
inlinevirtual

Definition at line 16 of file PRDHandle_TGC.h.

16{};

Member Function Documentation

◆ buildShapes()

void PRDHandle_TGC::buildShapes ( SoNode *& shape_simple,
SoNode *& shape_detailed )
virtual

Implements PRDHandleBase.

Definition at line 97 of file PRDHandle_TGC.cxx.

98{
99 const TgcIdHelper * idhelper = VP1DetInfo::tgcIDHelper();
100 if (!idhelper)
101 return;
102
103 Identifier id = m_tgc->identify();
104
105 int plane = idhelper->gasGap( id );
106 int strip = idhelper->channel( id );
107 int isStrip = idhelper->isStrip( id );
108
109 double striplength =0.0, stripWidth = 0.0;
110
111 if (isStrip){
112 striplength = m_tgc->detectorElement()->stripLength();
113 stripWidth = m_tgc->detectorElement()->stripWidth(plane, strip);
114 } else {
115 striplength = m_tgc->detectorElement()->gangShortWidth(plane, strip);
116 stripWidth = m_tgc->detectorElement()->gangRadialLength(plane, strip);
117 }
118
119 if (static_cast<PRDCollHandle_TGC*>(collHandle())->project())
120 striplength += 300.0;//Fixme: Rough extension for now
121
122 shape_simple = common()->nodeManager()->getShapeNode_Strip(striplength);
123
124 const bool settingsShowRDOs = true; //FIXME: get from controller
125 SoSeparator * errDetailed = new SoSeparator;
126 const std::vector<Identifier> rdolist = m_tgc->rdoList();
127 if (rdolist.size() == 1 || !settingsShowRDOs)
128 {
129 errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
130 std::max(10.0,stripWidth), //strip width -> fixme: std::max hack for now since stripWidth returns 0.0
131 3*0.8)); //strip thickness - hardcoded to be ~= the gas gap
132 } else
133 {
134 VP1Msg::message("Warning: TGC has additional elements in rdoList: THIS HAS NEVER BEEN TESTED");
135 SoSeparator * rdos = new SoSeparator;
136
137 const Amg::Vector3D& globalposHIT = m_tgc->detectorElement()->channelPos( id );
138 // get local position on wire plane, here we have to use a tolarance as the wire plane is located 2.5 CLHEP::mm
139 // from the strip plane
140 double tolerance = 3.;
141 std::optional<Amg::Vector2D>localposHIT = m_tgc->detectorElement()->surface( id ).Trk::Surface::globalToLocal(globalposHIT,tolerance);
142 if( !localposHIT )
143 {
144 localposHIT.emplace();
145 localposHIT->setZero();
146 VP1Msg::message("Warning: Local wire position is NULL");
147 }
148
149 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
150 std::max(10.0,stripWidth), //strip width -> fixme: std::max hack for now since stripWidth returns 0.0
151 3*0.8)); //strip thickness - hardcoded to be ~= the gas gap
152
153 SoTransparency * transparent = new SoTransparency;
154 transparent->transparency.setValue(0.5);
155 rdos->addChild( transparent );
156 Amg::Vector2D localposOLD = *localposHIT;
157 for (const Identifier& rdo_id : rdolist)
158 {
159 if (rdo_id == id )
160 continue;
161 const Amg::Vector3D& globalposRDO = m_tgc->detectorElement()->channelPos( rdo_id );
162 std::optional<Amg::Vector2D> localposRDO = m_tgc->detectorElement()->surface( rdo_id ).Trk::Surface::globalToLocal(globalposRDO,tolerance);
163 if (!localposRDO)
164 {
165 VP1Msg::message("Warning: Local wire position is NULL");
166 continue;
167 }
168
169 SoTranslation * localtrans = new SoTranslation;
170 localtrans->translation.setValue((*localposRDO)[Trk::locX]-localposOLD[Trk::locX],(*localposRDO)[Trk::locY]-localposOLD[Trk::locY],0);
171 rdos->addChild(localtrans);
172
173 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
174 std::max(10.0,stripWidth), //strip width -> fixme: std::max hack for now since stripWidth returns 0.0
175 3*0.8)); //strip thickness - hardcoded to be ~= the gas gap
176
177 localposOLD = *localposRDO;
178 }
179 errDetailed->addChild(rdos);
180 }
181 shape_detailed = errDetailed;
182 }
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
PRDSysCommonData * common() const
PRDCollHandleBase * collHandle() const
HitsSoNodeManager * nodeManager() const
SoSFFloat transparency
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int isStrip(const Identifier &id) const
isStrip corresponds to measuresPhi
static const TgcIdHelper * tgcIDHelper()
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
constexpr double tolerance

◆ center()

Amg::Vector3D PRDHandleBase::center ( ) const
virtualinherited

Reimplemented in PRDHandle_SpacePoint.

Definition at line 316 of file PRDHandleBase.cxx.

317{
318 return positionPRD();
319}
Amg::Vector3D positionPRD() const

◆ clicked()

QStringList PRDHandleBase::clicked ( ) const
virtualinherited

Reimplemented in PRDHandle_CSC, PRDHandle_CSC_Strip, PRDHandle_MDT, PRDHandle_MM, PRDHandle_RPC, and PRDHandle_TRT.

Definition at line 276 of file PRDHandleBase.cxx.

277{
278 const Trk::PrepRawData * prd = getPRD();
279 if (!prd)
280 return QStringList("Null PRD");
281 std::ostringstream os;
282 os << *(prd);
283 return QString(os.str().c_str()).split("\n");
284}
virtual const Trk::PrepRawData * getPRD() const =0

◆ collHandle()

PRDCollHandleBase * PRDHandleBase::collHandle ( ) const
inherited

Definition at line 228 of file PRDHandleBase.cxx.

229{
230 return m_d->colhandle;
231}

◆ common()

PRDSysCommonData * PRDHandleBase::common ( ) const
inlineinherited

Definition at line 53 of file PRDHandleBase.h.

53{ return m_common; }
PRDSysCommonData * m_common

◆ createTransform()

SoTransform * PRDHandle_TGC::createTransform ( ) const
virtual

Reimplemented from PRDHandleBase.

Definition at line 31 of file PRDHandle_TGC.cxx.

32{
33 const TgcIdHelper * idhelper = VP1DetInfo::tgcIDHelper();
34 const Muon::TgcPrepData * prd = tgc();
35 if (!prd || !idhelper) {
36 return new SoTransform;
37 }
38
39 const Trk::Surface& theSurface = prd->detectorElement()->surface(prd->identify());
40 SoTransform * theHitTransform =0;
41 if (idhelper->isStrip( prd->identify() )){
42
43 int stripNo = idhelper->channel(prd->identify());
44 int gasGap = idhelper->gasGap(prd->identify());
45
46 const MuonGM::TgcReadoutElement* detEl = prd->detectorElement();
47
48 // calculate two points along the tgc phi strip in the local tgc reference frame
49 const Amg::Vector3D lposTGC = detEl->stripCenterLocX(gasGap, stripNo, 0.) * Amg::Vector3D::UnitX();
50 const double shift = detEl->getStationEta() > 0 ? 1.*Gaudi::Units::cm : - 1.*Gaudi::Units::cm;
51 const Amg::Vector3D lposTgcShifted = detEl->stripCenterLocX(gasGap, stripNo, shift) * Amg::Vector3D::UnitX()+
52 shift * Amg::Vector3D::UnitY();
53 const double angle = (lposTGC - lposTgcShifted).phi();
54 // for phi strips, use sinstereo to get correct orientation
55 Amg::RotationMatrix3D localRot{Amg::RotationMatrix3D::Identity()};
56
57
58 // std::ostream os;
59 // std::cout<<localRot.print(os)<<std::endl;
60 //double angle = M_PI/2.0 - asin(prd->detectorElement()->sinStereo(prd->identify())) ;
61 // double angle = asin(prd->detectorElement()->sinStereo(prd->identify())) ;
62 // trying by trial and error to set right component of matrix!
63 // setting theta=PI/4 rotated strips 45deg around z axis, but also a bit around x and y too! So clearly not working as expected.
64
65 // localRot.setPhi (M_PI/4);
66
67 if (0 < detEl->getStationEta()) {
68 Amg::setPhi (localRot, angle);
69 } else {
70 Amg::setPhi (localRot, -angle);
71 }
72 // std::cout<<localRot.print(os)<<std::endl;
73 // localRot.setPhi (angle);
74
75 // VP1Msg::message(QString::number(prd->identify().get_compact())+": angle="+QString::number(angle));
76 localRot*=theSurface.transform().rotation ();
77
78 Amg::Transform3D trans (localRot, theSurface.transform().translation());
79 // Trk::GlobalDirection difPosGlobal = gpos_shift-gpos;
80 // HepTransform3D toLocal = trans.inverse();
81 // Trk::GlobalDirection difPosLocal = toLocal*difPosGlobal;
82 // Trk::GlobalDirection difPosLocal2 = trans*difPosGlobal;
83
84 // std::cout << " global strip direction " << difPosGlobal << " local " << difPosLocal << " local2 " << difPosLocal2 << std::endl;
85 theHitTransform = VP1LinAlgUtils::toSoTransform(trans);
86 } else {
87 // eta strips just use surface orientiation
88 theHitTransform = VP1LinAlgUtils::toSoTransform(theSurface.transform());
89 }
90
91 Amg::Vector3D theHitGPos= theSurface.localToGlobal(prd->localPosition());
92 theHitTransform->translation.setValue((theHitGPos)[0], (theHitGPos)[1], (theHitGPos)[2]);
93 return theHitTransform;
94}
Scalar phi() const
phi method
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
double stripCenterLocX(int gasGap, int strip, double radialPos) const
Returns the local X of the strip center at a given local radial position.
virtual const MuonGM::TgcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD The pointer will be zero if the det el is not ...
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Amg::RotationMatrix3D setPhi(Amg::RotationMatrix3D mat, double angle, int convention=0)
Eigen::Affine3d Transform3D

◆ getPRD()

const Trk::PrepRawData * PRDHandle_TGC::getPRD ( ) const
inlinevirtual

Implements PRDHandleBase.

Definition at line 24 of file PRDHandle_TGC.h.

24{ return m_tgc; }

◆ getSecondPRD()

virtual const Trk::PrepRawData * PRDHandleBase::getSecondPRD ( ) const
inlinevirtualinherited

Reimplemented in PRDHandle_SpacePoint.

Definition at line 73 of file PRDHandleBase.h.

73{ return 0; }//For SCT spacepoints

◆ getTransform_CLHEP()

Amg::Transform3D PRDHandleBase::getTransform_CLHEP ( ) const
inherited

Definition at line 322 of file PRDHandleBase.cxx.

323{
324 if (m_d->sepDetailed&&m_d->sepDetailed->getNumChildren()>0) {
325 //For efficiency/consistency we simply copy the transform from the
326 //inventor transformation (only loose slight precision in the
327 //double->float->double conversions):
328 SoTransform * transform = static_cast<SoTransform*>(m_d->sepDetailed->getChild(0));
329 float tx, ty, tz;
330 transform->translation.getValue().getValue(tx,ty,tz);
331 SbVec3f so_rotaxis;
332 float so_rotangle;
333 transform->rotation.getValue().getValue(so_rotaxis, so_rotangle);
334 float rx, ry, rz;
335 so_rotaxis.getValue(rx,ry,rz);
336 Amg::Vector3D axis(rx,ry,rz);
337// Amg::AngleAxis3D angleAxis = Amg::getRotation3DfromAngleAxis( so_rotangle, axis );
338// Amg::Rotation3D rot;
339// rot = angleAxis;
340 Amg::Rotation3D rot = Amg::getRotation3DfromAngleAxis( so_rotangle, axis );
341 return Amg::Translation3D(tx,ty,tz) * rot;
342 }
343 std::cout<<"VP1 PRDHandleBase Warning: getTransform_CLHEP called at inopportune moment!!"<<std::endl;
344
345 //NB: Some code duplicated here and in the createTransform() method.
346
347 const Trk::PrepRawData * prd = getPRD();
348 if (!prd) {
349 return Amg::Transform3D::Identity();
350 }
351 const Trk::Surface& theSurface = prd->detectorElement()->surface(prd->identify());
352 Amg::Vector3D theHitGPos;
354 // for tubes, should use position of center of tube (if drawing full tube)
355 theHitGPos= Amg::Vector3D(theSurface.center());
356 } else {
357 // for clusters or short tubes, use position of hit.
358 theHitGPos = theSurface.localToGlobal(prd->localPosition()); //theSurface 'new s' a Vector3D and returns pointer
359 }
360
361// CLHEP::Hep3Vector t(theSurface.transform().getTranslation());
362// return HepGeom::Transform3D( HepGeom::Translate3D(theHitGPos->x()-t.x(),theHitGPos->y()-t.y(),theHitGPos->z()-t.z()) * (theSurface.transform()) );
365 Amg::Translation3D transl = Amg::Translation3D(theHitGPos.x()-t.x(), theHitGPos.y()-t.y(), theHitGPos.z()-t.z());
366 Amg::Transform3D transf = transl * (theSurface.transform());
367 return transf;
368}
static Double_t rz
virtual bool transformUsesSurfacePositionOnly() const
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
const Amg::Vector3D & center() const
Returns the center position of the Surface.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
Amg::Vector3D getTranslationVectorFromTransform(const Amg::Transform3D &tr)
Get the Translation vector out of a Transformation.
Eigen::Quaternion< double > Rotation3D
Amg::Rotation3D getRotation3DfromAngleAxis(double angle, Amg::Vector3D &axis)
get a AngleAxis from an angle and an axis.
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Eigen::Translation< double, 3 > Translation3D

◆ highLight()

virtual bool PRDHandleBase::highLight ( ) const
inlinevirtualinherited

Reimplemented in PRDHandle_MDT, and PRDHandle_TRT.

Definition at line 45 of file PRDHandleBase.h.

45{ return false; }//Return true to get hit highlighted (for e.g. a TRT hits with HT).

◆ inMuonChamber()

bool PRDHandle_TGC::inMuonChamber ( ) const
inlinevirtual

Reimplemented from PRDHandleBase.

Definition at line 26 of file PRDHandle_TGC.h.

26{ return true; }

◆ isSane()

virtual bool PRDHandleBase::isSane ( ) const
inlinevirtualinherited

Returns false if the PRD is not safe to draw.

Reimplemented in PRDHandle_Pixel.

Definition at line 75 of file PRDHandleBase.h.

◆ parentMuonChamberPV()

GeoPVConstLink PRDHandle_TGC::parentMuonChamberPV ( ) const
inlinevirtual

Reimplemented from PRDHandleBase.

Definition at line 27 of file PRDHandle_TGC.h.

27{ return m_tgc->detectorElement()->getMaterialGeom()->getParent(); }

◆ positionPRD()

Amg::Vector3D PRDHandleBase::positionPRD ( ) const
inherited

Definition at line 303 of file PRDHandleBase.cxx.

304{
305 return Imp::positionPRD(getPRD());
306}
static Amg::Vector3D positionPRD(const Trk::PrepRawData *prd)

◆ positionSecondPRD()

Amg::Vector3D PRDHandleBase::positionSecondPRD ( ) const
inherited

Definition at line 309 of file PRDHandleBase.cxx.

310{
312}
virtual const Trk::PrepRawData * getSecondPRD() const

◆ regionIndex()

int PRDHandle_TGC::regionIndex ( )
virtual

Reimplemented from PRDHandleBase.

Definition at line 185 of file PRDHandle_TGC.cxx.

186 {
187 //Unique for each station.
188 const MuonGM::MuonStation* station = m_tgc->detectorElement()->parentMuonStation();
189 return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
190 }
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB

◆ sepDetailed()

SoSeparator * PRDHandleBase::sepDetailed ( ) const
inherited

Definition at line 60 of file PRDHandleBase.cxx.

61{
62 return m_d->sepDetailed;
63}

◆ sepSimple()

SoSeparator * PRDHandleBase::sepSimple ( ) const
inherited

Definition at line 54 of file PRDHandleBase.cxx.

55{
56 return m_d->sepSimple;
57}

◆ setVisible()

void PRDHandleBase::setVisible ( bool vis)
inherited

Definition at line 234 of file PRDHandleBase.cxx.

235{
236 if (vis==m_visible)
237 return;
238 //std::cout<<"Changing visible status from "<<m_visible<<" to "<<vis<<" for: "<<*getPRD()<<std::endl;
239 m_visible=vis;
240 if (vis) {
241 m_d->colhandle->incrementNShownHandles();
242 if (inMuonChamber())
244 if (!m_d->sepSimple||!m_d->sepDetailed)
245 m_d->rebuild3DObjects(this);//The call to rebuild also fixes attached state.
246 else
247 m_d->attach3DObjects(this);
248 } else {
249 m_d->colhandle->decrementNShownHandles();
250 if (inMuonChamber())
252 m_d->detach3DObjects();
253 }
254}
virtual bool inMuonChamber() const
virtual GeoPVConstLink parentMuonChamberPV() const
TouchedMuonChamberHelper * touchedMuonChamberHelper() const
void decrementNumberOfObjectsForPV(const GeoPVConstLink &chamberPV)
void incrementNumberOfObjectsForPV(const GeoPVConstLink &chamberPV)

◆ tgc()

const Muon::TgcPrepData * PRDHandle_TGC::tgc ( ) const
inline

Definition at line 23 of file PRDHandle_TGC.h.

23{ return m_tgc; }

◆ transformUsesSurfacePositionOnly()

virtual bool PRDHandleBase::transformUsesSurfacePositionOnly ( ) const
inlinevirtualinherited

Reimplemented in PRDHandle_MDT, and PRDHandle_TRT.

Definition at line 47 of file PRDHandleBase.h.

47{ return false; }//Override and return true if should use just the surface position.

◆ update3DObjects()

void PRDHandleBase::update3DObjects ( )
inherited

Definition at line 257 of file PRDHandleBase.cxx.

257 {
258 //Fixme: If selected we really need to redo selection updates!!!
259 if (m_visible) {
260 m_d->rebuild3DObjects(this);
261 } else {
262 //Simply clear the present 3D objects. They will only be recreated if/when the prd becomes visible again.
263 if (m_d->sepDetailed) {
264 m_d->sepDetailed->unref();
265 m_d->sepDetailed = 0;
266 }
267 if (m_d->sepSimple) {
268 m_d->sepSimple->unref();
269 m_d->sepSimple = 0;
270 }
271 }
272
273}

◆ updateMaterial()

void PRDHandleBase::updateMaterial ( )
inherited

Definition at line 160 of file PRDHandleBase.cxx.

161{
162 //We need to change the current material. This means we need to
163 //clear the cache. Only if we are visible do we need to do a
164 //detach->clear material->attach cycle to trigger attachment under new material.
165
166 if (!m_d->currentmaterial)
167 return;//We have no material cached and is thus not attached either.
168 if (m_visible) {
169 //See if the material changed. If it did, detach, update the material, attach again.
170 SoMaterial * newmat = m_d->determineMaterial(this);
171 newmat->ref();
172 if (newmat!=m_d->currentmaterial) {
173 m_d->detach3DObjects();
174 m_d->currentmaterial->unref();
175 m_d->currentmaterial = newmat;
176 m_d->attach3DObjects(this);
177 } else {
178 newmat->unref();
179 }
180 } else {
181 //Just clear material.
182 m_d->currentmaterial->unref();
183 m_d->currentmaterial = 0;
184 }
185}

◆ visible()

bool PRDHandleBase::visible ( ) const
inlineinherited

Definition at line 42 of file PRDHandleBase.h.

42{ return m_visible; }

Member Data Documentation

◆ m_common

PRDSysCommonData* PRDHandleBase::m_common
privateinherited

Definition at line 84 of file PRDHandleBase.h.

◆ m_d

Imp* PRDHandleBase::m_d
privateinherited

Definition at line 83 of file PRDHandleBase.h.

◆ m_tgc

const Muon::TgcPrepData* PRDHandle_TGC::m_tgc
private

Definition at line 30 of file PRDHandle_TGC.h.

◆ m_visible

bool PRDHandleBase::m_visible
privateinherited

Definition at line 86 of file PRDHandleBase.h.


The documentation for this class was generated from the following files: