ATLAS Offline Software
Loading...
Searching...
No Matches
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
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//____________________________________________________________________
47public:
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 }
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
102std::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//____________________________________________________________________
170
171//____________________________________________________________________
175
176//____________________________________________________________________
178{
179 std::map<int,Imp::TubeInfo*>::iterator it = Imp::tubeID2TubeInfo->find(getTubeID());
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{
189 std::map<int,Imp::TubeInfo*>::iterator it = Imp::tubeID2TubeInfo->find(getTubeID());
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//____________________________________________________________________
197QStringList 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}
static Double_t a
SoTransform * getUnitTransform()
SoTubs - Inventor version of the G4Tubs Geant Geometry entity.
Definition SoTubs.h:52
SoSFFloat pDz
Half-length in Z.
Definition SoTubs.h:70
static void initClass()
Class Initializer, required.
Definition SoTubs.cxx:63
static const GeoPVConstLink * geoModelWorld()
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static bool verbose()
Definition VP1Msg.h:31
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
HitsSoNodeManager * nodeManager() const
VP1RawDataCommonData * common() const
VP1RawDataHandleBase(VP1RawDataCollBase *)
VP1RawDataCollBase * coll() const
TubeInfo(int tubeID, const Amg::Transform3D &heptransform, const GeoTube *geotube)
static std::map< int, TubeInfo * > * tubeID2TubeInfo
virtual unsigned short getTDC() const =0
QStringList commonClicked(const QString &prefix="") const
virtual bool isSideA() const =0
virtual unsigned short getQDC() const =0
virtual bool isSideC() const =0
VP1RawDataHandle_LUCID(VP1RawDataCollBase *)
virtual unsigned short getTubeID() const =0
Eigen::Affine3d Transform3D