ATLAS Offline Software
PRDHandle_TRT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
8 #include "VP1Utils/VP1DetInfo.h"
9 #include "VP1Base/VP1Msg.h"
12 
13 #include <Inventor/C/errors/debugerror.h>
14 #include <Inventor/nodes/SoSeparator.h>
15 #include <Inventor/nodes/SoTransform.h>
16 #include <Inventor/nodes/SoTranslation.h>
17 
18 #include "InDetIdentifier/TRT_ID.h"
20 #include "TrkSurfaces/Surface.h"
21 
23 //____________________________________________________________________
25  : PRDHandleBase(static_cast<PRDCollHandleBase*>(collhandle)), m_driftcircle(dc)
26 {
27 }
28 
29 //____________________________________________________________________
30 void PRDHandle_TRT::buildShapes(SoNode*&shape_simple, SoNode*&shape_detailed)
31 {
33  if (not ccbo) return;
34  const double radius = m_driftcircle->localPosition()[0];
35  const double halflength = ccbo->halflengthZ();
36  const double mintuberadius = 0.1;
37 
38  if ( m_driftcircle->rdoList().size() > 1)
39  VP1Msg::message("Warning: TRT has additional elements in rdoList: NOT IMPLEMENTED");
40 
41  const PRDCollHandle_TRT* trtcollhandle(static_cast<PRDCollHandle_TRT*>(collHandle()));
42 
43  if (trtcollhandle->project()) {
44 
46  // Projections: //
48 
49  const InDetProjFlags::InDetProjPartsFlags projparts(trtcollhandle->appropriateProjections());
50  bool inner,outer;
51  if (isBarrel()) {
52  inner = (projparts&InDetProjFlags::BarrelCentral);
54  } else {
55  const bool posz(isPositiveZ());
58  //Special TRT EndCap Z->R projections.
59 
60  //Find center of tube:
61  Amg::Transform3D prdtransform(getTransform_CLHEP());
62  Amg::Vector3D center(prdtransform*Amg::Vector3D(0,0,0));
63 
64  // --> Get points for special projections
66  std::vector<Amg::Vector3D > points;
67 
68  if (posz) {
69  if ( projparts & InDetProjFlags::TRT_EndCapZToRPositive ) {
76  points.push_back(p);
77  }
78  if ( projparts & InDetProjFlags::TRT_EndCapZToRCentral ) {
80  //Fixme: Use same parameters here as in InDetProjHelper!!
86  points.push_back(p);
87  }
88  } else {
89  if ( projparts & InDetProjFlags::TRT_EndCapZToRNegative ) {
96  points.push_back(p);
97  }
98  if ( projparts & InDetProjFlags::TRT_EndCapZToRCentral ) {
101  -0.5* InDetProjParams::surfacethickness() - eps,
105  points.push_back(p);
106  }
107  }
108  // --> Build scene objects for special projections
109 
110  const unsigned npoints = points.size();
111  if (npoints<1||npoints>2) {
112  collHandle()->message("PRDHandle_TRT::buildShapes ERROR: Unexpected number of points in special endcap projections!!");
113  } else {
114  SoSeparator * sepsimple = new SoSeparator;
115  SoTransform * transf1(VP1LinAlgUtils::toSoTransform((prdtransform.inverse())
116  * Amg::Translation3D(points.at(0).x(),points.at(0).y(),points.at(0).z())));
117  SoNode* point = common()->nodeManager()->getShapeNode_Point();
118  sepsimple->addChild(transf1);
119  sepsimple->addChild(point);
120  SoTranslation * transf2(0);
121  if (npoints==2) {
122  transf2 = new SoTranslation;
123  transf2->translation.setValue(points[1].x()-points[0].x(),points[1].y()-points[0].y(),points[1].z()-points[0].z());
124  sepsimple->addChild(transf2);
125  sepsimple->addChild(point);
126  }
127  shape_simple = sepsimple;
128 
129  if (radius<mintuberadius) {
130  shape_detailed = shape_simple;
131  return;
132  }
133  SoSeparator * sepdetailed = new SoSeparator;
134  SoNode* disc = common()->nodeManager()->getShapeNode_DriftDisc(radius);
135  sepdetailed->addChild(transf1);
136  sepdetailed->addChild(disc);
137  if (npoints==2) {
138  sepdetailed->addChild(transf2);
139  sepdetailed->addChild(disc);
140  }
141  shape_detailed = sepdetailed;
142  return;
143  }
144  inner = false;outer = false;
145  //end special projections
146  } else {
149  }
150  }//end endcap
151  if (!inner&&!outer) {
152  collHandle()->message("PRDHandle_TRT::buildShapes ERROR: Inconsistent projection settings! Won't project!");
153  } else {
154  //Perform projections
155  shape_simple = common()->nodeManager()->getShapeNode_ProjectedDriftTube( halflength, 0.0, inner, outer );
156  if (radius<mintuberadius)
157  shape_detailed = shape_simple;
158  else
159  shape_detailed = common()->nodeManager()->getShapeNode_ProjectedDriftTube( halflength, radius, inner, outer );
160  return;
161  }
162  }//endif projections
163 
165  // No projections: //
167 
168  shape_simple = common()->nodeManager()->getShapeNode_DriftTube( halflength, 0.0 );
169  if (radius<mintuberadius)
170  shape_detailed = shape_simple;
171  else
172  shape_detailed = common()->nodeManager()->getShapeNode_DriftTube( halflength, radius );
173 
174 }
175 
176 //____________________________________________________________________
178 {
179  const TRT_ID * id_helper = VP1DetInfo::trtIDHelper();
180  if (!id_helper)
181  return 0;
183  return id_helper->barrel_ec(id)*10000+id_helper->layer_or_wheel(id)*100+(id_helper->phi_module(id)%4);
184 }
185 // MuonGM::MuonDetectorManager::getMdtReadoutElement ()
186 
187 //____________________________________________________________________
188 QStringList PRDHandle_TRT::clicked() const
189 {
190  QStringList l;
192  const unsigned int data = m_driftcircle->getWord();
193 
194  QString s;
195  int i;
196  for (i = 26; i >=0; i--)
197  {
198  if (i!=26&&(i+1)%9==0)
199  s+=" ";
200  s += ( data & (0x1<<i) ? "1" : "0");
201  if ((i+1)%9==0)
202  s+=" ";
203  }
204  l << "Raw data bits: "+s;
205 
206 
207  std::ostringstream os;
208  os << std::hex<<data;
209  l << QString(os.str().c_str());
210 
211 
212 // l << "Drift radius: "+QString::number(m_driftcircle->localPosition()[0]/CLHEP::mm)+" CLHEP::mm";
213 // const Trk::CylinderBounds* ccbo = dynamic_cast<const Trk::CylinderBounds*>(&(m_driftcircle->detectorElement()->surface(m_driftcircle->identify()).bounds()));
214 // if (ccbo)
215 // l << "Straw length: "+QString::number(ccbo->halflengthZ()*2/CLHEP::cm)+" CLHEP::cm";
216 
217  return l;
218 }
HitsSoNodeManager::getShapeNode_DriftDisc
SoNode * getShapeNode_DriftDisc(double radius)
Definition: HitsSoNodeManager.cxx:177
HitsSoNodeManager.h
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
InDetProjFlags::EndCapOuterNegative
@ EndCapOuterNegative
Definition: InDetProjFlags.h:54
InDetProjParams::trt_endcap_zasr_endcapz_begin
static double trt_endcap_zasr_endcapz_begin()
Definition: InDetProjParams.h:81
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
PRDHandleBase::getTransform_CLHEP
Amg::Transform3D getTransform_CLHEP() const
Definition: PRDHandleBase.cxx:322
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
InDetProjHelper.h
Surface.h
InDetProjFlags::BarrelPositive
@ BarrelPositive
Definition: InDetProjFlags.h:50
VP1Msg.h
PRDHandleBase::collHandle
PRDCollHandleBase * collHandle() const
Definition: PRDHandleBase.cxx:228
InDet::TRT_DriftCircle::detectorElement
virtual const InDetDD::TRT_BaseElement * detectorElement() const override final
return the detector element corresponding to this PRD
TRT_ID.h
This is an Identifier helper class for the TRT subdetector. This class is a factory for creating comp...
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
yodamerge_tmp.npoints
npoints
Definition: yodamerge_tmp.py:250
PRDHandle_TRT::regionIndex
int regionIndex()
Definition: PRDHandle_TRT.cxx:177
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
PRDCollHandle_TRT::appropriateProjections
InDetProjFlags::InDetProjPartsFlags appropriateProjections() const
Definition: PRDCollHandle_TRT.h:25
PRDHandle_TRT::buildShapes
void buildShapes(SoNode *&shape_simple, SoNode *&shape_detailed)
Definition: PRDHandle_TRT.cxx:30
x
#define x
PRDHandleBase::common
PRDSysCommonData * common() const
Definition: PRDHandleBase.h:53
PRDHandleBase::clicked
virtual QStringList clicked() const
Definition: PRDHandleBase.cxx:276
InDet::TRT_DriftCircle
Definition: TRT_DriftCircle.h:32
InDetProjFlags::TRT_EndCapZToRCentral
@ TRT_EndCapZToRCentral
Definition: InDetProjFlags.h:60
InDetProjParams::trt_barrel_posneg_z
static double trt_barrel_posneg_z()
Definition: InDetProjParams.h:55
InDetProjParams::trt_endcap_zasr_squeezefact
static double trt_endcap_zasr_squeezefact()
Definition: InDetProjParams.h:61
PRDSysCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: PRDSysCommonData.h:79
VP1LinAlgUtils.h
VP1DetInfo.h
GeoPrimitives.h
InDetProjParams.h
PRDHandle_TRT::isBarrel
bool isBarrel() const
Definition: PRDHandle_TRT.h:27
PRDCollHandleBase
Definition: PRDCollHandleBase.h:25
InDetProjParams::surfacethickness
static double surfacethickness()
Definition: InDetProjParams.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:92
z
#define z
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
Trk::CylinderBounds
Definition: CylinderBounds.h:46
InDetProjHelper::transformECPointToZPlane_specialZtoR
static void transformECPointToZPlane_specialZtoR(Amg::Vector3D &p, const double &planeZ, const double &planeRBegin, const double &endcapZBegin, const double &squeezeFactor)
Definition: InDetProjHelper.cxx:780
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
InDetProjFlags::EndCapInnerPositive
@ EndCapInnerPositive
Definition: InDetProjFlags.h:55
TRT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: TRT_ID.h:866
PRDHandle_TRT::PRDHandle_TRT
PRDHandle_TRT(PRDCollHandle_TRT *, const InDet::TRT_DriftCircle *)
Definition: PRDHandle_TRT.cxx:24
TRT_ID::layer_or_wheel
int layer_or_wheel(const Identifier &id) const
Definition: TRT_ID.h:884
InDetProjFlags::EndCapInnerNegative
@ EndCapInnerNegative
Definition: InDetProjFlags.h:56
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
InDetProjFlags::BarrelCentral
@ BarrelCentral
Definition: InDetProjFlags.h:52
PRDHandle_TRT::isPositiveZ
bool isPositiveZ() const
Definition: PRDHandle_TRT.h:28
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
Trk::Surface::bounds
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
Trk::PrepRawData::localPosition
const Amg::Vector2D & localPosition() const
return the local position reference
PRDHandle_TRT::clicked
virtual QStringList clicked() const
Definition: PRDHandle_TRT.cxx:188
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
TRT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: TRT_ID.h:875
ParticleGun_SamplingFraction.radius
radius
Definition: ParticleGun_SamplingFraction.py:96
InDetProjParams::trt_data_disttosurface_epsilon
static double trt_data_disttosurface_epsilon()
Definition: InDetProjParams.h:62
CylinderBounds.h
TRT_ID
Definition: TRT_ID.h:84
PRDHandle_TRT::m_driftcircle
const InDet::TRT_DriftCircle * m_driftcircle
Definition: PRDHandle_TRT.h:35
VP1DetInfo::trtIDHelper
static const TRT_ID * trtIDHelper()
Definition: VP1DetInfo.cxx:166
y
#define y
HitsSoNodeManager::getShapeNode_ProjectedDriftTube
SoNode * getShapeNode_ProjectedDriftTube(double halfLength, double radius, bool inner, bool outer)
Definition: HitsSoNodeManager.cxx:203
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
PRDHandle_TRT.h
HitsSoNodeManager::getShapeNode_Point
SoNode * getShapeNode_Point()
Definition: HitsSoNodeManager.cxx:412
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition: GeoPrimitives.h:44
InDetProjParams::trt_endcap_zasr_innerradius
static double trt_endcap_zasr_innerradius()
Definition: InDetProjParams.h:74
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
PRDHandleBase
Definition: PRDHandleBase.h:35
HitsSoNodeManager::getShapeNode_DriftTube
SoNode * getShapeNode_DriftTube(double halfLength, double radius)
Definition: HitsSoNodeManager.cxx:138
InDet::TRT_DriftCircle::getWord
unsigned int getWord() const
returns the TRT dataword
InDetProjFlags::TRT_EndCapZToRPositive
@ TRT_EndCapZToRPositive
Definition: InDetProjFlags.h:58
InDetProjFlags::BarrelNegative
@ BarrelNegative
Definition: InDetProjFlags.h:51
InDetProjFlags::EndCapOuterPositive
@ EndCapOuterPositive
Definition: InDetProjFlags.h:53
VP1LinAlgUtils::toSoTransform
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Definition: VP1LinAlgUtils.cxx:40
InDetDD::TRT_BaseElement::surface
virtual const Trk::Surface & surface() const override final
Element Surface: access to the Surface (straw layer)
PRDCollHandle_TRT
Definition: PRDCollHandle_TRT.h:12
PRDHandleBase::center
virtual Amg::Vector3D center() const
Definition: PRDHandleBase.cxx:316
InDetProjFlags::TRT_EndCapZToRNegative
@ TRT_EndCapZToRNegative
Definition: InDetProjFlags.h:59
PRDCollHandle_TRT::project
bool project() const
Definition: PRDCollHandle_TRT.h:24