ATLAS Offline Software
VP1RawDataHandle_BCM_RDO.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 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 //____________________________________________________________________
43 public:
44  static QStringList describeHit(const BCM_RawData * data, 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 (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  {
73  m_transformsAndBoxes << QPair< Amg::Transform3D,const GeoBox *>(t,b);
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 
120 std::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  Query<int> Qint = pv.getId();
141  if (Qint.isValid()) {
142  bcmModLogCopyNumber = int(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 //____________________________________________________________________
169 {
171  for(const BCM_RawData* hit : data) {
172  if (isHighAttenuationChannel(hit->getChannel()))
174  }
175 }
176 
177 //____________________________________________________________________
179 {
180 }
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 {
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 {
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
HitsSoNodeManager.h
VP1RawDataHandle_BCM_RDO::moduleName
QString moduleName() const
Definition: VP1RawDataHandle_BCM_RDO.cxx:183
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::moduleID
int moduleID() const
Definition: VP1RawDataHandle_BCM_RDO.cxx:75
VP1RawDataHandleBase::unsignedToHex
static QString unsignedToHex(unsigned)
Definition: VP1RawDataHandleBase.cxx:158
VP1RawDataColl_BCM_RDO.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::m_group
SoGroup * m_group
Definition: VP1RawDataHandle_BCM_RDO.cxx:112
VP1RawDataHandleBase
Definition: VP1RawDataHandleBase.h:34
VP1RawDataHandle_BCM_RDO::~VP1RawDataHandle_BCM_RDO
virtual ~VP1RawDataHandle_BCM_RDO()
Definition: VP1RawDataHandle_BCM_RDO.cxx:178
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
VP1RawDataHandle_BCM_RDO::Imp::moduleID2ModuleInfo
static std::map< int, ModuleInfo * > * moduleID2ModuleInfo
Definition: VP1RawDataHandle_BCM_RDO.cxx:116
SoVisualizeAction.h
VP1RawDataCommonData::nodeManager
HitsSoNodeManager * nodeManager() const
Definition: VP1RawDataCommonData.h:42
VP1RawDataHandle_BCM_RDO::buildShape
SoNode * buildShape()
Definition: VP1RawDataHandle_BCM_RDO.cxx:254
skel.it
it
Definition: skel.GENtoEVGEN.py:396
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::m_transformsAndBoxes
QList< QPair< Amg::Transform3D, const GeoBox * > > m_transformsAndBoxes
Definition: VP1RawDataHandle_BCM_RDO.cxx:114
VP1RawDataCollBase
Definition: VP1RawDataCollBase.h:29
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
gr
#define gr
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::getTransform
SoTransform * getTransform()
Definition: VP1RawDataHandle_BCM_RDO.cxx:76
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
VP1RawDataHandle_BCM_RDO::isHighAttenuationChannel
static bool isHighAttenuationChannel(int channelID)
Definition: VP1RawDataHandle_BCM_RDO.h:39
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::m_transform
SoTransform * m_transform
Definition: VP1RawDataHandle_BCM_RDO.cxx:113
VP1RawDataHandle_BCM_RDO::VP1RawDataHandle_BCM_RDO
VP1RawDataHandle_BCM_RDO(VP1RawDataCollBase *, int moduleID, QList< const BCM_RawData * >)
Definition: VP1RawDataHandle_BCM_RDO.cxx:167
VP1LinAlgUtils.h
VP1DetInfo.h
VP1RawDataHandle_BCM_RDO.h
GeoPrimitives.h
skel.l2
l2
Definition: skel.GENtoEVGEN.py:399
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
lumiFormat.i
int i
Definition: lumiFormat.py:85
VP1RawDataHandle_BCM_RDO::m_nHighAttenuationHits
int m_nHighAttenuationHits
Definition: VP1RawDataHandle_BCM_RDO.h:46
SoVisualizeAction
Definition: SoVisualizeAction.h:19
beamspotman.n
n
Definition: beamspotman.py:731
VP1JobConfigInfo::geoModelWorld
static const GeoPVConstLink * geoModelWorld()
Definition: VP1JobConfigInfo.cxx:240
VP1RawDataSysController.h
BCM_RawData
Definition: BCM_RawData.h:36
VP1RawDataHandle_BCM_RDO::numberOfHighAttenuationHits
int numberOfHighAttenuationHits() const
Definition: VP1RawDataHandle_BCM_RDO.h:36
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
BCM_RawData.h
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo
Definition: VP1RawDataHandle_BCM_RDO.cxx:66
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::~ModuleInfo
~ModuleInfo()
Definition: VP1RawDataHandle_BCM_RDO.cxx:69
VP1RawDataHandle_BCM_RDO::m_moduleID
int m_moduleID
Definition: VP1RawDataHandle_BCM_RDO.h:45
CLHEPtoEigenConverter.h
VP1RawDataCommonData.h
python.selection.number
number
Definition: selection.py:20
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1RawDataHandle_BCM_RDO::nHits
int nHits() const
Definition: VP1RawDataHandle_BCM_RDO.h:37
VP1RawDataHandle_BCM_RDO::moduleID
int moduleID() const
Definition: VP1RawDataHandle_BCM_RDO.h:31
VP1RawDataHandle_BCM_RDO::Imp
Definition: VP1RawDataHandle_BCM_RDO.cxx:42
VP1RawDataColl_BCM_RDO
Definition: VP1RawDataColl_BCM_RDO.h:23
a
TList * a
Definition: liststreamerinfos.cxx:10
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::addBox
void addBox(const Amg::Transform3D &t, const GeoBox *b)
Definition: VP1RawDataHandle_BCM_RDO.cxx:70
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::get3DObjects
SoGroup * get3DObjects()
Definition: VP1RawDataHandle_BCM_RDO.cxx:81
HitsSoNodeManager::getShapeNode_Point
SoNode * getShapeNode_Point()
Definition: HitsSoNodeManager.cxx:412
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
python.changerun.pv
pv
Definition: changerun.py:81
VP1RawDataHandleBase::coll
VP1RawDataCollBase * coll() const
Definition: VP1RawDataHandleBase.h:40
VP1RawDataHandle_BCM_RDO::clicked
QStringList clicked(bool verbose) const
Definition: VP1RawDataHandle_BCM_RDO.cxx:231
VP1JobConfigInfo.h
VP1RawDataHandle_BCM_RDO::moduleNick
QString moduleNick() const
Definition: VP1RawDataHandle_BCM_RDO.cxx:199
VP1RawDataHandle_BCM_RDO::Imp::describeHit
static QStringList describeHit(const BCM_RawData *data, QString prefix="")
Definition: VP1RawDataHandle_BCM_RDO.cxx:44
VP1RawDataHandle_BCM_RDO::buildTransform
SoTransform * buildTransform()
Definition: VP1RawDataHandle_BCM_RDO.cxx:272
VP1RawDataHandle_BCM_RDO::Imp::ensureInitModuleInfo
static void ensureInitModuleInfo()
Definition: VP1RawDataHandle_BCM_RDO.cxx:123
VP1RawDataHandle_BCM_RDO::modulePosDescription
QString modulePosDescription() const
Definition: VP1RawDataHandle_BCM_RDO.cxx:215
VP1LinAlgUtils::toSoTransform
static SoTransform * toSoTransform(const HepGeom::Transform3D &, SoTransform *t=0)
Definition: VP1LinAlgUtils.cxx:40
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::ModuleInfo
ModuleInfo(int moduleID)
Definition: VP1RawDataHandle_BCM_RDO.cxx:68
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::init
void init()
Definition: VP1RawDataHandle_BCM_RDO.cxx:87
VP1RawDataHandleBase::common
VP1RawDataCommonData * common() const
Definition: VP1RawDataHandleBase.h:41
VP1RawDataHandle_BCM_RDO::Imp::ModuleInfo::m_moduleID
int m_moduleID
Definition: VP1RawDataHandle_BCM_RDO.cxx:111
HitsSoNodeManager::getUnitTransform
SoTransform * getUnitTransform()
Definition: HitsSoNodeManager.cxx:456
VP1RawDataHandle_BCM_RDO::m_data
QList< const BCM_RawData * > m_data
Definition: VP1RawDataHandle_BCM_RDO.h:47