Belle II Software  release-06-00-14
ROIPixelTranslator.cc
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 
10 #include <tracking/pxdDataReductionClasses/ROIPixelTranslator.h>
11 #include <framework/logging/Logger.h>
12 #include <vxd/geometry/GeoCache.h>
13 #include <vxd/geometry/SensorInfoBase.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 
18 ROIPixelTranslator::ROIPixelTranslator(double user_sigmaSystU, double user_sigmaSystV, double user_numSigmaTotU,
19  double user_numSigmaTotV, double user_maxWidthU, double user_maxWidthV)
20  : m_sigmaSystU(user_sigmaSystU)
21  , m_sigmaSystV(user_sigmaSystV)
22  , m_numSigmaTotU(user_numSigmaTotU)
23  , m_numSigmaTotV(user_numSigmaTotV)
24  , m_maxWidthU(user_maxWidthU)
25  , m_maxWidthV(user_maxWidthV)
26 {}
27 
28 
30  : m_sigmaSystU(theROIinfo->sigmaSystU)
31  , m_sigmaSystV(theROIinfo->sigmaSystV)
32  , m_numSigmaTotU(theROIinfo->numSigmaTotU)
33  , m_numSigmaTotV(theROIinfo->numSigmaTotV)
34  , m_maxWidthU(theROIinfo->maxWidthU)
35  , m_maxWidthV(theROIinfo->maxWidthV)
36 {}
37 
38 
40 {}
41 
42 
43 void
45  StoreArray<ROIid>* ROIidList)
46 {
47 
49 
50  for (int i = 0; i < listOfIntercepts->getEntries(); i++) {
51 
52  B2DEBUG(10, " --->> 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 nPixelsU = aSensorInfo.getUCells() - 1;
65 
66  double minV = (*listOfIntercepts)[i]->getCoorV() - widthTotV / 2;
67  double maxV = (*listOfIntercepts)[i]->getCoorV() + widthTotV / 2;
68  const int nPixelsV = 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(10, " LAYER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLayerNumber()
78  << " LADDER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLadderNumber()
79  << " SENSOR = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getSensorNumber()
80  );
81 
82  B2DEBUG(10, " nPixels (U,V) = (" << nPixelsU << "," << nPixelsV << ")");
83 
84  B2DEBUG(10, " widthU = " << maxU - minU
85  << " minU = " << minU
86  << " maxU = " << maxU
87  << " lengthU = " << aSensorInfo.getUSize((*listOfIntercepts)[i]->getCoorV())
88  );
89 
90  B2DEBUG(10, " widthV = " << maxV - minV
91  << " minV = " << minV
92  << " maxV = " << maxV
93  << " lengthV = " << aSensorInfo.getVSize());
94 
95  B2DEBUG(10, " bottom left pixel (U,V) = (" << bottomLeft_uID << "," << bottomLeft_vID << ")");
96  B2DEBUG(10, " top right pixel (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 > nPixelsU || topRight_uID < firstPixelID || bottomLeft_vID > nPixelsV || topRight_vID < firstPixelID) {
102  B2DEBUG(5, " OOOPS: this pixel 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  }
125 
126 }
127 
double m_maxWidthV
ROI maximum width allowed in the V direction.
void fillRoiIDList(StoreArray< PXDIntercept > *listOfIntercepts, StoreArray< ROIid > *ROIidList)
Append the ROIid to the list listToBeFilled.
double m_maxWidthU
ROI maximum width allowed in the U direction.
double m_sigmaSystV
systematic error along the V coordinate
double m_numSigmaTotV
number of standard deviations to be taken to define a ROI along V
double m_sigmaSystU
systematic error along the U coordinate
double m_numSigmaTotU
number of standard deviations to be taken to define a ROI along U
ROIPixelTranslator(const ROIinfo *theROIinfo)
Constructor.
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:50
void setSensorID(VxdID user_sensorID)
set the sensor ID of the ROI
Definition: ROIid.h:53
void setMinUid(double user_minUid)
set the minimum U id of the ROI
Definition: ROIid.h:49
void setMaxVid(double user_maxVid)
set the maximum V id of the ROI
Definition: ROIid.h:52
void setMinVid(double user_minVid)
set the minimum V id of the ROI
Definition: ROIid.h:51
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:66
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
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
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