ATLAS Offline Software
Loading...
Searching...
No Matches
PRDHandle_RPC.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
8#include "VP1Base/VP1Msg.h"
10
11#include <Inventor/nodes/SoSeparator.h>
12#include <Inventor/nodes/SoTranslation.h>
13
16
18
19#include <sstream>
20
21//____________________________________________________________________
27
28//____________________________________________________________________
29void PRDHandle_RPC::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed)
30{
31 const RpcIdHelper * idhelper = VP1DetInfo::rpcIDHelper();
32 if (!idhelper)
33 return;
34
35 Identifier id = m_rpc->identify();
36 SoSeparator * errDetailed = new SoSeparator;
37
38 int measPhi = idhelper->measuresPhi( id );
39 double striplength = m_rpc->detectorElement()->StripLength(measPhi);
40 shape_simple = common()->nodeManager()->getShapeNode_Strip(striplength);
41
42
43 // Translation from objects local position to the strip position
44 const Amg::Vector2D& localpos = m_rpc->localPosition();
45 const Amg::Vector3D& globalposHIT = m_rpc->detectorElement()->stripPos( id );
46 // get local position on wire plane, here we have to use a tolarance as the wire plane is located 2.5 CLHEP::mm
47 // from the strip plane
48 double tolerance = 3.;
49// const Amg::Vector2D * localposHIT = m_rpc->detectorElement()->surface( id ).globalToLocal(globalposHIT,tolerance);
50 std::optional<Amg::Vector2D> localposHIT = m_rpc->detectorElement()->surface( id ).Trk::Surface::globalToLocal(globalposHIT,tolerance);
51 if( !localposHIT )
52 {
53 localposHIT.emplace();
54 localposHIT->setZero();
55 VP1Msg::message("Warning: Local wire position is NULL");
56 }
57 SoTranslation * localtrans0 = new SoTranslation;
58 localtrans0->translation.setValue((*localposHIT)[Trk::locX]-localpos[Trk::locX],(*localposHIT)[Trk::locY]-localpos[Trk::locY],0);
59
60 bool project(static_cast<PRDCollHandle_RPC*>(collHandle())->project());
61
62 const std::vector<Identifier> rdolist = m_rpc->rdoList();
63 if (rdolist.size() == 1 || !collHandle()->drawRDOs())
64 {
65 errDetailed->addChild(localtrans0);
66 errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(project ? striplength+0.2 : striplength,
67 m_rpc->detectorElement()->StripWidth(measPhi),//strip width
68 project ? 2*(6.85+0.1) : 0.8));//strip thickness - hardcoded to something (hopefully) reasonable.
69 //Translate back so errDetailed is left sane (eg. when drawing errors later)
70 SoTranslation * localtransBack = new SoTranslation;
71 localtransBack->translation.setValue(-(localtrans0->translation.getValue()));
72 errDetailed->addChild(localtransBack);
73 } else {
74 VP1Msg::message("Warning: RPC has additional elements in rdoList: THIS HAS NEVER BEEN TESTED");
75 SoSeparator * rdos = new SoSeparator;
76 rdos->addChild(localtrans0);
77
78 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(project ? striplength+0.2 : striplength,
79 m_rpc->detectorElement()->StripWidth(measPhi),//strip width
80 project ? 2*(6.85+0.1) : 0.8));//strip thickness - hardcoded to something (hopefully) reasonable.
81
82 SoTransparency * transparent = new SoTransparency;
83 transparent->transparency.setValue(0.5);
84 rdos->addChild( transparent );
85 Amg::Vector2D localposOLD = *localposHIT;
86 for (const Identifier& rdo_id : rdolist)
87 {
88 if (rdo_id == id )
89 continue;
90 const Amg::Vector3D& globalposRDO = m_rpc->detectorElement()->stripPos( rdo_id );
91 std::optional<Amg::Vector2D> localposRDO = m_rpc->detectorElement()->surface( rdo_id ).Trk::Surface::globalToLocal(globalposRDO,tolerance);
92 if (!localposRDO)
93 {
94 VP1Msg::message("Warning: Local wire position is NULL");
95 continue;
96 }
97
98 SoTranslation * localtrans = new SoTranslation;
99 localtrans->translation.setValue((*localposRDO)[Trk::locX]-localposOLD[Trk::locX],(*localposRDO)[Trk::locY]-localposOLD[Trk::locY],0);
100 rdos->addChild(localtrans);
101
102 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(project ? striplength+0.2 : striplength,
103 m_rpc->detectorElement()->StripWidth(measPhi),//strip width
104 project ? 2*(6.85+0.1) : 0.8));
105
106 localposOLD = *localposRDO;
107 }
108 errDetailed->addChild(rdos);
109 }
110 shape_detailed = errDetailed;
111}
112
113//____________________________________________________________________
115{
116 //Unique for each station.
117 const MuonGM::MuonStation* station = m_rpc->detectorElement()->parentMuonStation();
118 return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
119}
120
121//____________________________________________________________________
122QStringList PRDHandle_RPC::clicked() const
123{
124 if (!m_rpc)
125 return QStringList("Null PRD");
126 const RpcIdHelper * idhelper = VP1DetInfo::rpcIDHelper();
127 if (!idhelper)
128 return QStringList("Null PRD");
129 std::ostringstream os;
130 Identifier id = m_rpc->identify();
131
132 os << "RpcPrepData with Identifier ["<<id.get_compact() ;
133 os << "] = [" << (idhelper->print_to_string(id)) ;
134 os << "]\n at global position = [" << m_rpc->globalPosition()<<"], local position = ["<<m_rpc->localPosition()<<"].";
135 os <<"\nTime: "<<m_rpc->time();
136 os <<", Trigger info: "<<m_rpc->triggerInfo();
137 os <<", Ambiguity Flag: 0x"<<std::hex<<m_rpc->ambiguityFlag()<<std::dec;
138 os << ". Rdo list= [";
139 for( unsigned int i=0;i<m_rpc->rdoList().size();++i) os << m_rpc->rdoList()[i] << " , ";
140 os << "].";
141 QStringList l(QString(os.str().c_str()));
142 // if (detailed) l << PRDHandleBase::clicked() ;
143
144 return l;
145}
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB
Class to represent RPC measurements.
Definition RpcPrepData.h:35
PRDHandleBase(PRDCollHandleBase *)
PRDSysCommonData * common() const
PRDCollHandleBase * collHandle() const
const Muon::RpcPrepData * rpc() const
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
QStringList clicked() const
const Muon::RpcPrepData * m_rpc
PRDHandle_RPC(PRDCollHandle_RPC *, const Muon::RpcPrepData *)
HitsSoNodeManager * nodeManager() const
bool measuresPhi(const Identifier &id) const override
static void initClass()
SoSFFloat transparency
static const RpcIdHelper * rpcIDHelper()
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