ATLAS Offline Software
Loading...
Searching...
No Matches
PRDHandle_CSC.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 "VP1Base/VP1Msg.h"
9
11
14
16
17#include <Inventor/nodes/SoSeparator.h>
18#include <Inventor/nodes/SoTranslation.h>
19#include <Inventor/nodes/SoMaterial.h>
20
21#include <sstream>
22
23//____________________________________________________________________
29
30//____________________________________________________________________
31void PRDHandle_CSC::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed)
32{
33 const CscIdHelper * idhelper = VP1DetInfo::cscIDHelper();
34 if (!idhelper)
35 return;
36
37 Identifier id = m_csc->identify();
38
39 SoSeparator * errDetailed = new SoSeparator;
40
41 double striplength = m_csc->detectorElement()->stripLength( id );
42 if (static_cast<PRDCollHandle_CSC*>(collHandle())->project())
43 striplength += 300.0;//Fixme: Rough extension for now
44 shape_simple = common()->nodeManager()->getShapeNode_Strip(striplength);
45
46 // Translation from objects local position to the strip position
47 const Amg::Vector2D& localpos = m_csc->localPosition();
48 const Amg::Vector3D& globalposHIT = m_csc->detectorElement()->stripPos( id );
49 // get local position on wire plane, here we have to use a tolarance as the wire plane is located 2.5 CLHEP::mm
50 // from the strip plane
51 double tolerance = 3.;
52 std::optional<Amg::Vector2D> localposHIT = m_csc->detectorElement()->surface( id ).Trk::Surface::globalToLocal(globalposHIT,tolerance);
53
54 if( !localposHIT )
55 {
56 localposHIT.emplace();
57 localposHIT->setZero();
58 VP1Msg::message("Warning: Local wire position is NULL");
59 }
60 SoTranslation * localtrans0 = new SoTranslation;
61 localtrans0->translation.setValue((*localposHIT)[Trk::locX]-localpos[Trk::locX],(*localposHIT)[Trk::locY]-localpos[Trk::locY],0);
62
63 const double maxCharge = 1e7;
64 //Thickness of highlighed strip
65 //FIXME: the maxCharge/3 is just a quick fix to get a nice presentation
66 // maybe this should go like sqrt(charge/maxCharge) so that it
67 // is clear for small charges.
68 //const double stripHeight = (1 + 4*sqrt(m_csc->charge()/maxCharge))*CLHEP::mm; // [1,5]
69 //
70 // The minimum is chosen equal to the neighbouring strips, such
71 // that a zero charge will give the same stirp height
72 const double stripHeight = (1 + 4*m_csc->charge()/(maxCharge/3))*CLHEP::mm; // [1,5]
73 //Thickness of additional strips (from rdoList())
74 const double stripHeightRDOs = 1*CLHEP::mm;
75
76 const std::vector<Identifier> rdolist = m_csc->rdoList();
77 if (rdolist.size() == 1 || !collHandle()->drawRDOs())
78 {
79 errDetailed->addChild(localtrans0);
80 errDetailed->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
81 m_csc->detectorElement()->cathodeReadoutPitch(idhelper->chamberLayer( id ),
82 idhelper->measuresPhi( id )), stripHeight));
83
84 //Translate back so errDetailed is left sane (eg. when drawing errors later)
85 SoTranslation * localtransBack = new SoTranslation;
86 localtransBack->translation.setValue(-(localtrans0->translation.getValue()));
87 errDetailed->addChild(localtransBack);
88 } else
89 {
90 SoSeparator * rdos = new SoSeparator;
91 rdos->addChild(localtrans0);
92
93 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplength,
94 m_csc->detectorElement()->cathodeReadoutPitch(idhelper->chamberLayer( id ),
95 idhelper->measuresPhi( id )), stripHeight));
96
97 SoTransparency * transparent = new SoTransparency;
98 transparent->transparency.setValue(0.5);
99 rdos->addChild( transparent );
100 Amg::Vector2D localposOLD = *localposHIT;
101 for (const Identifier& rdo_id : rdolist)
102 {
103 if (rdo_id == id )
104 continue;
105 const Amg::Vector3D& globalposRDO = m_csc->detectorElement()->stripPos( rdo_id );
106
107 // const Amg::Vector2D * localposRDO = m_csc->detectorElement()->surface( rdo_id ).globalToLocal(globalposRDO,tolerance);
108 std::optional<Amg::Vector2D> localposRDO = m_csc->detectorElement()->surface( rdo_id ).Trk::Surface::globalToLocal(globalposRDO,tolerance);
109
110 if (!localposRDO)
111 {
112 VP1Msg::message("Warning: Local wire position is NULL");
113 continue;
114 }
115
116 SoTranslation * localtrans = new SoTranslation;
117 localtrans->translation.setValue((*localposRDO)[Trk::locX]-localposOLD[Trk::locX],(*localposRDO)[Trk::locY]-localposOLD[Trk::locY],0);
118 rdos->addChild(localtrans);
119 double striplengthRDO = m_csc->detectorElement()->stripLength( rdo_id );
120
121 rdos->addChild(common()->nodeManager()->getShapeNode_Strip(striplengthRDO,
122 m_csc->detectorElement()->cathodeReadoutPitch(idhelper->chamberLayer( rdo_id ),
123 idhelper->measuresPhi( rdo_id )), stripHeightRDOs));
124
125 localposOLD = *localposRDO;
126 }
127 errDetailed->addChild(rdos);
128 }
129
130 SoMaterial * mat = new SoMaterial;
131 mat->diffuseColor.setValue(1.0,0,0);
132 errDetailed->addChild(mat);
133 errDetailed->addChild(common()->nodeManager()->getShapeNode_Cross(10));
134
135 shape_detailed = errDetailed;
136}
137
138//____________________________________________________________________
140{
141 //Unique for each station.
142 const MuonGM::MuonStation* station = m_csc->detectorElement()->parentMuonStation();
143 return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
144}
145
146//____________________________________________________________________
147QStringList PRDHandle_CSC::clicked() const
148{
149
150 if (!m_csc)
151 return QStringList("Null PRD");
152 const CscIdHelper * idhelper = VP1DetInfo::cscIDHelper();
153 if (!idhelper)
154 return QStringList("Null PRD");
155
156 Identifier id = m_csc->identify();
157 std::ostringstream os;
158 os << "CscPrepData with Identifier ["<<id.get_compact() ;
159 os << "] = [" << (idhelper->print_to_string(id)) ;
160 os << "]\n at global position = [" << m_csc->globalPosition()<<"], local position = ["<<m_csc->localPosition()<<"].";
161 os << ". Charge="<<m_csc->charge()<<", time="<< m_csc->time()<<", status="<<Muon::toString(m_csc->status());
162 os << ". RDO list= [";
163 for( unsigned int i=0;i<m_csc->rdoList().size();++i) os << m_csc->rdoList()[i] << " , ";
164 os << "].";
165 // os << *(m_csc);
166 return QString(os.str().c_str()).split("\n");
167}
168
169
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
int chamberLayer(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB
Class representing clusters from the CSC.
Definition CscPrepData.h:39
PRDHandleBase(PRDCollHandleBase *)
PRDSysCommonData * common() const
PRDCollHandleBase * collHandle() const
PRDHandle_CSC(PRDCollHandle_CSC *, const Muon::CscPrepData *)
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
const Muon::CscPrepData * m_csc
const Muon::CscPrepData * csc() const
virtual QStringList clicked() const
HitsSoNodeManager * nodeManager() const
static void initClass()
SoSFFloat transparency
static const CscIdHelper * cscIDHelper()
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
std::string toString(CscStripStatus cstat)
Return a string description of a CSC cluster status flag.
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37