ATLAS Offline Software
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"
8 #include "VP1Utils/VP1DetInfo.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 //____________________________________________________________________
25  : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_csc(csc)
26 {
28 }
29 
30 //____________________________________________________________________
31 void 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,
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,
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.
143  return station->getPhiIndex()-99999*station->getEtaIndex();//hopefully unique.
144 }
145 
146 //____________________________________________________________________
147 QStringList 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 
CscIdHelper.h
HitsSoNodeManager.h
Trk::locX
@ locX
Definition: ParamDefs.h:43
PRDHandle_CSC.h
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:44
Muon::CscPrepData::charge
int charge() const
Returns the charge.
Definition: CscPrepData.h:153
SoTransparency
Definition: SoTransparency.h:20
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
VP1Msg.h
mat
GeoMaterial * mat
Definition: LArDetectorConstructionTBEC.cxx:53
PRDHandleBase::collHandle
PRDCollHandleBase * collHandle() const
Definition: PRDHandleBase.cxx:228
PRDCollHandleBase::drawRDOs
bool drawRDOs() const
Definition: PRDCollHandleBase.cxx:631
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
PRDHandle_CSC::PRDHandle_CSC
PRDHandle_CSC(PRDCollHandle_CSC *, const Muon::CscPrepData *)
Definition: PRDHandle_CSC.cxx:24
SoTransparency.h
PRDHandle_CSC::regionIndex
int regionIndex()
Definition: PRDHandle_CSC.cxx:139
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
MuonGM::CscReadoutElement::stripLength
double stripLength(int chamberLayer, int measuresPhi, int stripNumber, double &epsilon) const
Definition: CscReadoutElement.cxx:292
SoTransparency::transparency
SoSFFloat transparency
Definition: SoTransparency.h:27
PRDSysCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: PRDSysCommonData.h:79
VP1DetInfo.h
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
GeoPrimitives.h
PRDCollHandleBase
Definition: PRDCollHandleBase.h:25
MuonGM::MuonStation::getPhiIndex
int getPhiIndex() const
a la AMDB
Definition: MuonStation.h:162
Muon::toString
std::string toString(CscStripStatus cstat)
Return a string description of a CSC cluster status flag.
Definition: CscStripStatus.h:48
SoTransparency::initClass
static void initClass()
Definition: SoTransparency.cxx:29
lumiFormat.i
int i
Definition: lumiFormat.py:92
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
Muon::CscPrepData
Class representing clusters from the CSC.
Definition: CscPrepData.h:39
MuonGM::MuonReadoutElement::parentMuonStation
const MuonStation * parentMuonStation() const
Definition: MuonDetDescr/MuonReadoutGeometry/src/MuonReadoutElement.cxx:135
Muon::CscPrepData::globalPosition
virtual const Amg::Vector3D & globalPosition() const override final
Returns the global position.
Definition: CscPrepData.h:174
Muon::CscPrepData::status
CscClusterStatus status() const
Returns the Csc status (position measurement) flag.
Definition: CscPrepData.h:163
MuonGM::MuonStation
Definition: MuonStation.h:51
HitsSoNodeManager::getShapeNode_Strip
SoNode * getShapeNode_Strip(double length, double width=0, double depth=0)
Definition: HitsSoNodeManager.cxx:269
Muon::CscPrepData::time
double time() const
Returns the time.
Definition: CscPrepData.h:158
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
Muon::CscPrepData::detectorElement
virtual const MuonGM::CscReadoutElement * detectorElement() const override final
Return the detector element corresponding to this PRD.
Definition: CscPrepData.h:148
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
PRDHandle_CSC::m_csc
const Muon::CscPrepData * m_csc
Definition: PRDHandle_CSC.h:33
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
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
project
T_ResultType project(ParameterMapping::type< N > parameter_map, const T_Matrix &matrix)
Definition: MeasurementSelector.h:142
PRDHandle_CSC::clicked
virtual QStringList clicked() const
Definition: PRDHandle_CSC.cxx:147
CscIdHelper
Definition: CscIdHelper.h:52
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
VP1DetInfo::cscIDHelper
static const CscIdHelper * cscIDHelper()
Definition: VP1DetInfo.cxx:158
CscIdHelper::measuresPhi
bool measuresPhi(const Identifier &id) const override
Definition: CscIdHelper.cxx:774
MuonGM::CscReadoutElement::stripPos
Amg::Vector3D stripPos(const Identifier &id) const
takes into account internal alignment parameters, hence gives accurate answer
Definition: CscReadoutElement.cxx:227
PRDHandle_CSC::buildShapes
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
Definition: PRDHandle_CSC.cxx:31
MuonStation.h
PRDCollHandle_CSC
Definition: PRDCollHandle_CSC.h:10
CscIdHelper::chamberLayer
int chamberLayer(const Identifier &id) const
Definition: CscIdHelper.cxx:770
MuonGM::CscReadoutElement::cathodeReadoutPitch
double cathodeReadoutPitch(int chLayer, int measuresPhi) const
Definition: CscReadoutElement.cxx:147