ATLAS Offline Software
VP1RawDataHandle_LUCID.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // //
7 // Implementation of class VP1RawDataHandle_LUCID //
8 // //
9 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
10 // Initial version: February 2009 //
11 // //
13 
19 #include "VP1Utils/VP1DetInfo.h"
23 #include "VP1Base/VP1Msg.h"
24 
25 #include "VP1HEPVis/nodes/SoTubs.h"
26 
27 #include "GeoModelKernel/GeoVolumeCursor.h"
28 #include "GeoModelKernel/GeoTube.h"
30 
32 
33 #include <Inventor/nodes/SoShape.h>
34 #include <Inventor/nodes/SoTransform.h>
35 #include <Inventor/nodes/SoMaterial.h>
36 #include <Inventor/nodes/SoCylinder.h>
37 #include <Inventor/nodes/SoGroup.h>
38 #include <Inventor/nodes/SoLineSet.h>
39 #include <Inventor/nodes/SoVertexProperty.h>
40 
41 #include <QPair>
42 #include <map>
43 
44 
45 //____________________________________________________________________
47 public:
48  class TubeInfo {
49  public:
50  TubeInfo(int tubeID,const Amg::Transform3D& heptransform,const GeoTube* geotube)
51  : m_tubeID(tubeID), m_group(0),m_transform(0), m_heptransform(heptransform), m_geotube(geotube) {}
52  ~TubeInfo() { if (m_group) m_group->unref();if (m_transform) m_transform->unref(); }
53  int tubeID() const { return m_tubeID; }
54  SoTransform * getTransform() {
55  if (!m_transform)
56  init();
57  return m_transform;
58  }
59  SoGroup * get3DObjects() {
60  if (!m_group)
61  init();
62  return m_group;
63  }
64  private:
65  void init() {
66  m_group = new SoGroup;
67  m_group->ref();
68 
70  a.handleTube(m_geotube);
71 
72  SoShape * shape(a.getShape() ? a.getShape() : new SoCylinder);
73  m_group->addChild(shape);
74 
76  if (shape->getTypeId().isDerivedFrom(SoTubs::getClassTypeId())) {
77  SoTubs * tubs = static_cast<SoTubs*>(shape);
78  const double halfz(tubs->pDz.getValue());
79  tubs->pDz.setValue(halfz + 0.2*CLHEP::mm);
80  //Fixme:: Add line (0.1mm shorter than the geotube) under m_group
81  SoLineSet * line = new SoLineSet;
82  SoVertexProperty * vertices = new SoVertexProperty;
83  line->vertexProperty = vertices;
84  vertices->vertex.set1Value(0,0,0,+(halfz-0.1*CLHEP::mm));
85  vertices->vertex.set1Value(1,0,0,-(halfz-0.1*CLHEP::mm));
86  line->numVertices.set1Value(0,2);
87  m_group->addChild(line);
88  }
90  m_transform->ref();
91  }
92  int m_tubeID;
93  SoGroup * m_group;
94  SoTransform * m_transform;
96  const GeoTube* m_geotube;
97  };
98  static std::map<int,TubeInfo*> * tubeID2TubeInfo;
99  static void ensureInitTubeInfo();
100 };
101 
102 std::map<int,VP1RawDataHandle_LUCID::Imp::TubeInfo*> * VP1RawDataHandle_LUCID::Imp::tubeID2TubeInfo = 0;
103 
104 //____________________________________________________________________
106 {
107  if (tubeID2TubeInfo)
108  return;
109 
110  Imp::tubeID2TubeInfo = new std::map<int,TubeInfo*>;//Fixme: Gives valgrind problems!
111  const GeoPVConstLink * world = VP1JobConfigInfo::geoModelWorld();
112  if (world) {
113  GeoVolumeCursor av(*world);
114  while (!av.atEnd()) {
115  QString topvolname(av.getName().c_str());
116  if (topvolname.startsWith("LucidSide")) {
117  const bool sideA(topvolname.contains("SideA"));
118  GeoVolumeCursor av2(av.getVolume());
119  while (!av2.atEnd()) {
120  if (av2.getVolume()->getLogVol()->getName()=="lvVessel") {
121  GeoVolumeCursor av3(av2.getVolume());
122  while (!av3.atEnd()) {
123  if (av3.getVolume()->getLogVol()->getName()=="lvVesselGas") {
124  GeoVolumeCursor av4(av3.getVolume());
125  while (!av4.atEnd()) {
126  if (av4.getVolume()->getLogVol()->getName()=="lvTubeGas") {
127  //Decode tube-id:
128  int tubeID = -1;
129  QString tubegasname(av4.getName().c_str());
130  if (tubegasname.startsWith("LucidTubeGas")) {
131  tubegasname.remove(0,12);
132  bool ok;
133  int t(tubegasname.toInt(&ok));
134  if (ok) {
135  tubeID = t + (sideA?0:20);
136  }
137  }
138  if (tubeID>=0) {
139  const GeoTube * geotube = av4.getVolume()->getLogVol()->getShape()->typeID()==GeoTube::getClassTypeID() ?
140  static_cast<const GeoTube*>(av4.getVolume()->getLogVol()->getShape()) : 0;
141  Amg::Transform3D tr( av.getTransform()*av2.getTransform()*av3.getTransform()*av4.getTransform() );
142  (*tubeID2TubeInfo)[tubeID] = new TubeInfo(tubeID,tr,geotube);
143  if (VP1Msg::verbose())
144  VP1Msg::messageVerbose("VP1RawDataHandle_LUCID Added TubeInfo for tubeID = "+QString::number(tubeID));
145  } else {
146  VP1Msg::message("VP1RawDataHandle_LUCID ERROR: Can't decode tube id from PMT volume name");
147  }
148  }
149  av4.next();
150  }//end lvVesselGas loop
151  }
152  av3.next();
153  }//end lvVessel loop
154  }
155  av2.next();
156  }//end lucid-topvol loop
157  }
158  av.next();
159  }//end world loop
160  }
161 }
162 
163 
164 //____________________________________________________________________
167 {
169 }
170 
171 //____________________________________________________________________
173 {
174 }
175 
176 //____________________________________________________________________
178 {
180  SoNode * n = (it==Imp::tubeID2TubeInfo->end() ? 0 : it->second->get3DObjects());
181  if (!n)
182  return common()->nodeManager()->getShapeNode_Point();//fixme: warn
183  return n;
184 }
185 
186 //____________________________________________________________________
188 {
190  SoTransform * t = (it==Imp::tubeID2TubeInfo->end() ? 0 : it->second->getTransform());
191  if (!t)
192  return common()->nodeManager()->getUnitTransform();//fixme: warn
193  return t;
194 }
195 
196 //____________________________________________________________________
197 QStringList VP1RawDataHandle_LUCID::commonClicked(const QString& prefix) const
198 {
199  QStringList l;
200  l << prefix+"TubeID: "+QString::number(getTubeID());
201  l << prefix+"QDC: "+QString::number(getQDC());
202  l << prefix+"TDC: "+QString::number(getTDC());
203  l << prefix+"SideA: "+(isSideA()?"Yes":"No");
204  l << prefix+"SideC: "+(isSideC()?"Yes":"No");
205  return l;
206 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
HitsSoNodeManager.h
VP1RawDataHandle_LUCID::buildShape
SoNode * buildShape()
Definition: VP1RawDataHandle_LUCID.cxx:177
VP1RawDataHandle_LUCID::Imp::TubeInfo::tubeID
int tubeID() const
Definition: VP1RawDataHandle_LUCID.cxx:53
checkFileSG.line
line
Definition: checkFileSG.py:75
VP1RawDataHandleBase
Definition: VP1RawDataHandleBase.h:34
VP1RawDataHandle_LUCID::commonClicked
QStringList commonClicked(const QString &prefix="") const
Definition: VP1RawDataHandle_LUCID.cxx:197
VP1RawDataHandle_LUCID::Imp::TubeInfo::m_tubeID
int m_tubeID
Definition: VP1RawDataHandle_LUCID.cxx:92
VP1RawDataHandle_LUCID::Imp::TubeInfo::m_transform
SoTransform * m_transform
Definition: VP1RawDataHandle_LUCID.cxx:94
VP1RawDataColl_LUCID.h
SoTubs
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition: SoTubs.h:50
VP1Msg.h
SoVisualizeAction.h
VP1RawDataCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: VP1RawDataCommonData.h:42
skel.it
it
Definition: skel.GENtoEVGEN.py:423
VP1RawDataCollBase
Definition: VP1RawDataCollBase.h:29
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1RawDataHandle_LUCID::Imp
Definition: VP1RawDataHandle_LUCID.cxx:46
VP1RawDataHandle_LUCID::Imp::TubeInfo::getTransform
SoTransform * getTransform()
Definition: VP1RawDataHandle_LUCID.cxx:54
VP1LinAlgUtils.h
VP1DetInfo.h
VP1RawDataHandle_LUCID::Imp::TubeInfo::get3DObjects
SoGroup * get3DObjects()
Definition: VP1RawDataHandle_LUCID.cxx:59
VP1RawDataHandle_LUCID::Imp::ensureInitTubeInfo
static void ensureInitTubeInfo()
Definition: VP1RawDataHandle_LUCID.cxx:105
VP1RawDataHandle_LUCID::getTubeID
virtual unsigned short getTubeID() const =0
SoVisualizeAction
Definition: SoVisualizeAction.h:19
beamspotman.n
n
Definition: beamspotman.py:731
VP1JobConfigInfo::geoModelWorld
static const GeoPVConstLink * geoModelWorld()
Definition: VP1JobConfigInfo.cxx:240
VP1RawDataSysController.h
VP1RawDataHandle_LUCID::buildTransform
SoTransform * buildTransform()
Definition: VP1RawDataHandle_LUCID.cxx:187
VP1RawDataHandle_LUCID::getTDC
virtual unsigned short getTDC() const =0
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
VP1RawDataHandle_LUCID::Imp::TubeInfo::init
void init()
Definition: VP1RawDataHandle_LUCID.cxx:65
BCM_RawData.h
VP1RawDataHandle_LUCID::Imp::TubeInfo::m_geotube
const GeoTube * m_geotube
Definition: VP1RawDataHandle_LUCID.cxx:96
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
VP1RawDataHandle_LUCID::Imp::TubeInfo
Definition: VP1RawDataHandle_LUCID.cxx:48
SoTubs::initClass
static void initClass()
Class Initializer, required.
Definition: SoTubs.cxx:68
VP1RawDataHandle_LUCID::isSideA
virtual bool isSideA() const =0
CLHEPtoEigenConverter.h
VP1RawDataCommonData.h
VP1RawDataHandle_LUCID::VP1RawDataHandle_LUCID
VP1RawDataHandle_LUCID(VP1RawDataCollBase *)
Definition: VP1RawDataHandle_LUCID.cxx:165
python.selection.number
number
Definition: selection.py:20
VP1RawDataHandle_LUCID::Imp::TubeInfo::TubeInfo
TubeInfo(int tubeID, const Amg::Transform3D &heptransform, const GeoTube *geotube)
Definition: VP1RawDataHandle_LUCID.cxx:50
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
VP1RawDataHandle_LUCID::isSideC
virtual bool isSideC() const =0
VP1RawDataHandle_LUCID::Imp::TubeInfo::~TubeInfo
~TubeInfo()
Definition: VP1RawDataHandle_LUCID.cxx:52
python.SystemOfUnits.mm
int mm
Definition: SystemOfUnits.py:83
ZDC::sideA
BySideTypeMod sideA(1)
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
HitsSoNodeManager::getShapeNode_Point
SoNode * getShapeNode_Point()
Definition: HitsSoNodeManager.cxx:412
VP1RawDataHandleBase::coll
VP1RawDataCollBase * coll() const
Definition: VP1RawDataHandleBase.h:40
SoTubs.h
VP1RawDataHandle_LUCID::Imp::TubeInfo::m_group
SoGroup * m_group
Definition: VP1RawDataHandle_LUCID.cxx:93
VP1RawDataHandle_LUCID::Imp::tubeID2TubeInfo
static std::map< int, TubeInfo * > * tubeID2TubeInfo
Definition: VP1RawDataHandle_LUCID.cxx:98
VP1JobConfigInfo.h
VP1RawDataHandle_LUCID::getQDC
virtual unsigned short getQDC() const =0
VP1Msg::verbose
static bool verbose()
Definition: VP1Msg.h:31
VP1RawDataHandle_LUCID.h
VP1RawDataHandle_LUCID::Imp::TubeInfo::m_heptransform
const Amg::Transform3D m_heptransform
Definition: VP1RawDataHandle_LUCID.cxx:95
VP1RawDataHandle_LUCID::~VP1RawDataHandle_LUCID
virtual ~VP1RawDataHandle_LUCID()
Definition: VP1RawDataHandle_LUCID.cxx:172
SoTubs::pDz
SoSFFloat pDz
Half-length in Z.
Definition: SoTubs.h:68
VP1LinAlgUtils::toSoTransform
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Definition: VP1LinAlgUtils.cxx:40
VP1RawDataHandleBase::common
VP1RawDataCommonData * common() const
Definition: VP1RawDataHandleBase.h:41
HitsSoNodeManager::getUnitTransform
SoTransform * getUnitTransform()
Definition: HitsSoNodeManager.cxx:456