ATLAS Offline Software
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 
7 #include "VP1Utils/VP1DetInfo.h"
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 //____________________________________________________________________
23  : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_rpc(rpc)
24 {
26 }
27 
28 //____________________________________________________________________
29 void 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.
118  return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
119 }
120 
121 //____________________________________________________________________
122 QStringList 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 }
HitsSoNodeManager.h
MuonGM::RpcReadoutElement::StripLength
double StripLength(bool measphi) const
returns the strip length for the phi or eta plane
Trk::locX
@ locX
Definition: ParamDefs.h:43
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
SoTransparency
Definition: SoTransparency.h:20
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Muon::RpcPrepData::globalPosition
virtual const Amg::Vector3D & globalPosition() const override
Returns the global position.
Definition: RpcPrepData.h:218
VP1Msg.h
PRDHandleBase::collHandle
PRDCollHandleBase * collHandle() const
Definition: PRDHandleBase.cxx:228
RpcIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: RpcIdHelper.cxx:1068
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
PRDHandle_RPC::regionIndex
int regionIndex()
Definition: PRDHandle_RPC.cxx:114
SoTransparency.h
PRDHandleBase::common
PRDSysCommonData * common() const
Definition: PRDHandleBase.h:53
MuonGM::MuonClusterReadoutElement::surface
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
Definition: MuonClusterReadoutElement.h:123
RpcIdHelper
Definition: RpcIdHelper.h:51
SoTransparency::transparency
SoSFFloat transparency
Definition: SoTransparency.h:27
RpcIdHelper.h
PRDHandle_RPC::m_rpc
const Muon::RpcPrepData * m_rpc
Definition: PRDHandle_RPC.h:29
PRDSysCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: PRDSysCommonData.h:79
VP1DetInfo.h
Muon::RpcPrepData::time
float time() const
Returns the time.
Definition: RpcPrepData.h:197
PRDCollHandle_RPC
Definition: PRDCollHandle_RPC.h:10
GeoPrimitives.h
PRDCollHandleBase
Definition: PRDCollHandleBase.h:25
PRDHandle_RPC.h
MuonGM::MuonStation::getPhiIndex
int getPhiIndex() const
a la AMDB
Definition: MuonStation.h:162
SoTransparency::initClass
static void initClass()
Definition: SoTransparency.cxx:29
lumiFormat.i
int i
Definition: lumiFormat.py:92
Muon::RpcPrepData
Class to represent RPC measurements.
Definition: RpcPrepData.h:35
Muon::RpcPrepData::detectorElement
virtual const MuonGM::RpcReadoutElement * detectorElement() const override final
Returns the detector element corresponding to this PRD.
Definition: RpcPrepData.h:202
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
PRDHandle_RPC::clicked
QStringList clicked() const
Definition: PRDHandle_RPC.cxx:122
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:135
MuonGM::MuonStation
Definition: MuonStation.h:51
HitsSoNodeManager::getShapeNode_Strip
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
Definition: HitsSoNodeManager.cxx:269
VP1DetInfo::rpcIDHelper
static const RpcIdHelper * rpcIDHelper()
Definition: VP1DetInfo.cxx:159
Muon::RpcPrepData::triggerInfo
int triggerInfo() const
Returns the trigger coincidence - usually false, unless ijk>5 or highpt&&ijk==0.
Definition: RpcPrepData.h:207
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
tolerance
Definition: suep_shower.h:17
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
AtlasDetectorID::print_to_string
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:655
MuonGM::RpcReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
Definition: MuonDetDescr/MuonReadoutGeometry/src/RpcReadoutElement.cxx:177
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
PRDHandle_RPC::buildShapes
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
Definition: PRDHandle_RPC.cxx:29
project
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
Definition: MeasurementSelector.h:142
MuonGM::RpcReadoutElement::StripWidth
double StripWidth(bool measphi) const
returns the strip width for the phi or eta plane
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
MuonGM::MuonStation::getEtaIndex
int getEtaIndex() const
a la AMDB
Definition: MuonStation.h:163
PRDHandleBase
Definition: PRDHandleBase.h:35
MuonStation.h
PRDHandle_RPC::PRDHandle_RPC
PRDHandle_RPC(PRDCollHandle_RPC *, const Muon::RpcPrepData *)
Definition: PRDHandle_RPC.cxx:22
Muon::RpcPrepData::ambiguityFlag
int ambiguityFlag() const
Returns the number of ambiguities associated with this RpcPrepData.
Definition: RpcPrepData.h:212