ATLAS Offline Software
Loading...
Searching...
No Matches
VP1RawDataHandle_BCM_RDO.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class VP1RawDataHandle_BCM_RDO //
8// //
9// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
10// Initial version: April 2008 (rewritten January 2009) //
11// //
13
19#include "VP1Utils/VP1DetInfo.h"
23
24#include "GeoModelKernel/GeoVolumeCursor.h"
25#include "GeoModelKernel/GeoBox.h"
27
30
31#include <Inventor/nodes/SoShape.h>
32#include <Inventor/nodes/SoGroup.h>
33#include <Inventor/nodes/SoTransform.h>
34#include <Inventor/nodes/SoMaterial.h>
35
36#include <QPair>
37
38#include <map>
39
40
41//____________________________________________________________________
43public:
44 static QStringList describeHit(const BCM_RawData * data, const QString& prefix = "")
45 {
46 QStringList l;
47 l << "Word1: " + VP1RawDataHandleBase::unsignedToHex(data->getWord1());
48 l << "Word2: " + VP1RawDataHandleBase::unsignedToHex(data->getWord2());
49 l << "Channel ID [0-15]: " + QString::number(data->getChannel())+" ("+QString(isHighAttenuationChannel(data->getChannel())?"High":"Low")+" attenuation channel)";
50 l << "Position of first pulse [0-63]: " + QString::number(data->getPulse1Position());
51 l << "Width of first pulse [0-31]: " + QString::number(data->getPulse1Width());
52 l << "Position of second pulse [0-63]: " + QString::number(data->getPulse2Position());
53 l << "Width of second pulse [0-31]: " + QString::number(data->getPulse2Width());
54 l << "Level one accept [0-63]: " + QString::number(data->getLVL1A());
55 l << "Bunch crossing ID [0-4096]: " + QString::number(data->getBCID());
56 l << "Level 1 ID [0+]: " + QString::number(data->getLVL1ID());
57 if (prefix.isEmpty())
58 return l;
59 QStringList l2;
60 for (const QString& s : l)
61 l2 << (prefix + s);
62 return l2;
63 }
64
65
66 class ModuleInfo {
67 public:
69 ~ModuleInfo() { if (m_group) m_group->unref();if (m_transform) m_transform->unref(); }
70 void addBox(const Amg::Transform3D& t,const GeoBox* b)//Call at least once to init (all before the first call to get3DObjects).
71 //Call either with whole module, or diamond boxes, or whatever...
72 {
74 }
75 int moduleID() const { return m_moduleID; }
76 SoTransform * getTransform() {
77 if (!m_transform)
78 init();
79 return m_transform;
80 }
81 SoGroup * get3DObjects() {
82 if (!m_group)
83 init();
84 return m_group;
85 }
86 private:
87 void init() {
89 m_group = new SoGroup;
90 m_group->ref();
91 Amg::Transform3D accumTransf;
92 for(QPair< Amg::Transform3D,const GeoBox *> p : m_transformsAndBoxes) {
93 if (!m_transform) {
95 m_transform->ref();
96 accumTransf = p.first;
97 } else {
98 m_group->addChild(VP1LinAlgUtils::toSoTransform(accumTransf.inverse()*p.first));
99 accumTransf = (accumTransf*p.first);
100 }
101 a.handleBox(p.second);
102 if (a.getShape())
103 m_group->addChild(a.getShape());
104 }
105 m_transformsAndBoxes.clear();
106 if (!m_transform) {
107 m_transform = new SoTransform;
108 m_transform->ref();
109 }
110 }
112 SoGroup * m_group;
113 SoTransform * m_transform;
114 QList<QPair< Amg::Transform3D,const GeoBox *> > m_transformsAndBoxes;
115 };
116 static std::map<int,ModuleInfo*> * moduleID2ModuleInfo;
117 static void ensureInitModuleInfo();
118};
119
120std::map<int,VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo*> * VP1RawDataHandle_BCM_RDO::Imp::moduleID2ModuleInfo = 0;
121
122//____________________________________________________________________
124{
126 return;
127
128 Imp::moduleID2ModuleInfo = new std::map<int,ModuleInfo*>;//Fixme: Gives valgrind problems!
129 const GeoPVConstLink * world = VP1JobConfigInfo::geoModelWorld();
130 if (world) {
131 GeoVolumeCursor av(*world);
132 while (!av.atEnd()) {
133 if (av.getName()=="Pixel") {
134 Amg::Transform3D tr_pix = av.getTransform();
135 GeoVolumeCursor pv(av.getVolume());
136 while (!pv.atEnd()) {
137 int bcmModLogCopyNumber(-1);
138 if (pv.getVolume()->getLogVol()->getName()=="bcmModLog") {
139 Amg::Transform3D tr_bcmmod = pv.getTransform();
140 std::optional<int> Qint = pv.getId();
141 if (Qint) {
142 bcmModLogCopyNumber = *Qint;
143 ModuleInfo * modInfo = new ModuleInfo(bcmModLogCopyNumber - 951);
144 GeoVolumeCursor bv(pv.getVolume());
145 while (!bv.atEnd()) {
146 if (bv.getVolume()->getLogVol()->getName()=="bcmDiamondLog") {
147 Amg::Transform3D tr_diamond(bv.getTransform());
148 const GeoBox * box = bv.getVolume()->getLogVol()->getShape()->typeID()==GeoBox::getClassTypeID() ?
149 static_cast<const GeoBox*>(bv.getVolume()->getLogVol()->getShape()) : 0;
150 modInfo->addBox(tr_pix*tr_bcmmod*tr_diamond,box);
151 }
152 bv.next();
153 }//end bcm mod loop
154 (*moduleID2ModuleInfo)[modInfo->moduleID()] = modInfo;
155 }
156 }
157 pv.next();
158 }//end pixel loop
159 }
160 av.next();
161 }//end world loop
162 }
163}
164
165
166//____________________________________________________________________
176
177//____________________________________________________________________
181
182//____________________________________________________________________
184{
185 switch(moduleID()) {
186 case 0: return "F410";
187 case 1: return "F405";
188 case 2: return "F413";
189 case 3: return "F404";
190 case 4: return "F424";
191 case 5: return "F420";
192 case 6: return "F422";
193 case 7: return "F408";
194 default: return "Unknown";
195 }
196}
197
198//____________________________________________________________________
200{
201 switch(moduleID()) {
202 case 0: return "Marko";
203 case 1: return "Helmut/Peter";
204 case 2: return "William";
205 case 3: return "Harris";
206 case 4: return "Ewa";
207 case 5: return "Heinz";
208 case 6: return "Irena";
209 case 7: return "Andrej";
210 default: return "Unknown";
211 }
212}
213
214//____________________________________________________________________
216{
217 switch(moduleID()) {
218 case 0: return "A, +x";
219 case 1: return "A, +y";
220 case 2: return "A, -x";
221 case 3: return "A, -y";
222 case 4: return "C, +x";
223 case 5: return "C, +y";
224 case 6: return "C, -x";
225 case 7: return "C, -y";
226 default: return "Unknown";
227 }
228}
229
230//____________________________________________________________________
232{
233 QStringList l;
234 l << " ===> BCM Hit(s)";
235 l << " -- Module ID: "+QString::number(moduleID());
236 l << " -- Module Name: "+moduleName()+" (\""+moduleNick()+"\")";
237 l << " -- Module Position: "+modulePosDescription();
238 l << " -- Number of hits: "+QString::number(nHits());
239 l << " -- Number of hits with High Attenuation: "+QString::number(numberOfHighAttenuationHits());
240 if (verbose) {
241 for (int i=0;i<m_data.count();++i) {
242 l << " ------> BCM_RawData [hit "+QString::number(i+1)+"/"+QString::number(m_data.count())+"]";
243 l += Imp::describeHit(m_data.at(i), " -- ");
244 }
245 } else {
246 l << " -- (turn on verbose output for more information)";
247 }
248
249
250 return l;
251}
252
253//____________________________________________________________________
255{
256 std::map<int,Imp::ModuleInfo*>::iterator it = Imp::moduleID2ModuleInfo->find(m_moduleID);
257 SoNode * n = (it==Imp::moduleID2ModuleInfo->end() ? 0 : it->second->get3DObjects());
258 if (!n)
259 return common()->nodeManager()->getShapeNode_Point();//fixme: warn
260
261 if (numberOfHighAttenuationHits()>0 && static_cast<VP1RawDataColl_BCM_RDO*>(coll())->useSpecialBCMHighAttMaterial()) {
262 SoGroup * gr = new SoGroup;
263 gr->addChild(coll()->common()->controller()->bcmHighAttMaterial());
264 gr->addChild(n);
265 return gr;
266 } else {
267 return n;
268 }
269}
270
271//____________________________________________________________________
273{
274 std::map<int,Imp::ModuleInfo*>::iterator it = Imp::moduleID2ModuleInfo->find(m_moduleID);
275 SoTransform * t = (it==Imp::moduleID2ModuleInfo->end() ? 0 : it->second->getTransform());
276 if (!t)
277 return common()->nodeManager()->getUnitTransform();//fixme: warn
278 return t;
279}
#define gr
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t a
SoTransform * getUnitTransform()
static const GeoPVConstLink * geoModelWorld()
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
HitsSoNodeManager * nodeManager() const
VP1RawDataCommonData * common() const
VP1RawDataHandleBase(VP1RawDataCollBase *)
static QString unsignedToHex(unsigned)
VP1RawDataCollBase * coll() const
QList< QPair< Amg::Transform3D, const GeoBox * > > m_transformsAndBoxes
void addBox(const Amg::Transform3D &t, const GeoBox *b)
static std::map< int, ModuleInfo * > * moduleID2ModuleInfo
static QStringList describeHit(const BCM_RawData *data, const QString &prefix="")
VP1RawDataHandle_BCM_RDO(VP1RawDataCollBase *, int moduleID, const QList< const BCM_RawData * > &)
QList< const BCM_RawData * > m_data
static bool isHighAttenuationChannel(int channelID)
QStringList clicked(bool verbose) const
bool verbose
Definition hcg.cxx:73
Eigen::Affine3d Transform3D