Belle II Software development
ROIToUnitTranslator.templateDetails.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <tracking/roiFinding/ROIToUnitTranslator.h>
12#include <vxd/geometry/GeoCache.h>
13#include <vxd/geometry/SensorInfoBase.h>
14#include <tracking/dataobjects/ROIid.h>
15
16namespace Belle2 {
22 template<class aIntercept>
24 : m_sigmaSystU(theROIinfo->sigmaSystU)
25 , m_sigmaSystV(theROIinfo->sigmaSystV)
26 , m_numSigmaTotU(theROIinfo->numSigmaTotU)
27 , m_numSigmaTotV(theROIinfo->numSigmaTotV)
28 , m_maxWidthU(theROIinfo->maxWidthU)
29 , m_maxWidthV(theROIinfo->maxWidthV)
30 {};
31
32 template<class aIntercept>
33 ROIToUnitTranslator<aIntercept>::ROIToUnitTranslator(double sigmaSystU, double sigmaSystV,
34 double numSigmaTotU, double numSigmaTotV,
35 double maxWidthU, double maxWidthV)
36 : m_sigmaSystU(sigmaSystU)
37 , m_sigmaSystV(sigmaSystV)
38 , m_numSigmaTotU(numSigmaTotU)
39 , m_numSigmaTotV(numSigmaTotV)
40 , m_maxWidthU(maxWidthU)
41 , m_maxWidthV(maxWidthV)
42 {};
43
44 template<class aIntercept>
46 {
47
48 const VXD::GeoCache& aGeometry = VXD::GeoCache::getInstance();
49
50 for (int i = 0; i < listOfIntercepts->getEntries(); i++) {
51
52 B2DEBUG(21, " --->> a NEW INTERCEPT!");
53
54
55 const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo((*listOfIntercepts)[i]->getSensorID());
56
57 double widthTotU = std::min(m_maxWidthU,
58 sqrt((*listOfIntercepts)[i]->getSigmaU() * (*listOfIntercepts)[i]->getSigmaU() + m_sigmaSystU * m_sigmaSystU) * m_numSigmaTotU);
59 double widthTotV = std::min(m_maxWidthV,
60 sqrt((*listOfIntercepts)[i]->getSigmaV() * (*listOfIntercepts)[i]->getSigmaV() + m_sigmaSystV * m_sigmaSystV) * m_numSigmaTotV);
61
62 double minU = (*listOfIntercepts)[i]->getCoorU() - widthTotU / 2 ;
63 double maxU = (*listOfIntercepts)[i]->getCoorU() + widthTotU / 2 ;
64 const int nUnitsU = aSensorInfo.getUCells() - 1;
65
66 double minV = (*listOfIntercepts)[i]->getCoorV() - widthTotV / 2;
67 double maxV = (*listOfIntercepts)[i]->getCoorV() + widthTotV / 2;
68 const int nUnitsV = aSensorInfo.getVCells() - 1;
69
70 const int firstPixelID = 0;
71
72 double bottomLeft_uID = aSensorInfo.getUCellID(minU, minV, false);
73 double bottomLeft_vID = aSensorInfo.getVCellID(minV, false);
74 double topRight_uID = aSensorInfo.getUCellID(maxU, maxV, false);
75 double topRight_vID = aSensorInfo.getVCellID(maxV, false);
76
77 B2DEBUG(21, " LAYER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLayerNumber()
78 << " LADDER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLadderNumber()
79 << " SENSOR = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getSensorNumber()
80 );
81
82 B2DEBUG(21, " number of units (pixel or strip) (U,V) = (" << nUnitsU << "," << nUnitsV << ")");
83
84 B2DEBUG(21, " widthU = " << maxU - minU
85 << " minU = " << minU
86 << " maxU = " << maxU
87 << " lengthU = " << aSensorInfo.getUSize((*listOfIntercepts)[i]->getCoorV())
88 );
89
90 B2DEBUG(21, " widthV = " << maxV - minV
91 << " minV = " << minV
92 << " maxV = " << maxV
93 << " lengthV = " << aSensorInfo.getVSize());
94
95 B2DEBUG(21, " bottom left unit (pixel or strip) (U,V) = (" << bottomLeft_uID << "," << bottomLeft_vID << ")");
96 B2DEBUG(21, " top right unit (pixel or strip) (U,V) = (" << topRight_uID << "," << topRight_vID << ")");
97
98
99 //check that the pixel belong to the sensor
100 bool inside = true;
101 if (bottomLeft_uID > nUnitsU || topRight_uID < firstPixelID || bottomLeft_vID > nUnitsV || topRight_vID < firstPixelID) {
102 B2DEBUG(21, " OOOPS: this unit (pixel or strip) does NOT belong to the sensor");
103 inside = false;
104 }
105
106 ROIid tmpROIid;
107
108 if (inside) {
109 tmpROIid.setMinUid(aSensorInfo.getUCellID(minU, minV, true));
110 tmpROIid.setMinVid(aSensorInfo.getVCellID(minV, true));
111 tmpROIid.setMaxUid(aSensorInfo.getUCellID(maxU, maxV, true));
112 tmpROIid.setMaxVid(aSensorInfo.getVCellID(maxV, true));
113 tmpROIid.setSensorID((*listOfIntercepts)[i]->getSensorID()) ;
114
115 ROIidList->appendNew(tmpROIid);
116
117 // this is the pointer to the transient copy of tmpROIid
118 ROIid* transientROIid = (*ROIidList)[ROIidList->getEntries() - 1];
119
120 (*listOfIntercepts)[i]->addRelationTo(transientROIid);
121 }
122 }
123 }
124
126} // namespace Belle2
Translator for ROI-geometry-information into a list of pixels or strips.
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:25
void setMaxUid(double user_maxUid)
set the maximum U id of the ROI
Definition: ROIid.h:51
void setMinUid(double user_minUid)
set the minimum U id of the ROI
Definition: ROIid.h:50
void setMaxVid(double user_maxVid)
set the maximum V id of the ROI
Definition: ROIid.h:53
void setSensorID(VxdID::baseType user_sensorID)
set the sensor ID of the ROI
Definition: ROIid.h:54
void setMinVid(double user_minVid)
set the minimum V id of the ROI
Definition: ROIid.h:52
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:246
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:39
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
Base class to provide Sensor Information for PXD and SVD.
double getVSize() const
Return the length of the sensor.
int getVCells() const
Return number of pixel/strips in v direction.
int getUCells() const
Return number of pixel/strips in u direction.
double getUSize(double v=0) const
Return the width of the sensor.
int getVCellID(double v, bool clamp=false) const
Return the corresponding pixel/strip ID of a given v coordinate.
int getUCellID(double u, double v=0, bool clamp=false) const
Return the corresponding pixel/strip ID of a given u coordinate.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28
ROIToUnitTranslator(const ROIinfo *theROIinfo)
Constructor.
Abstract base class for different kinds of events.
ROIinfo contains the parameters that can be changed by the user in the python script.
Definition: ROIinfo.h:15