Belle II Software  release-05-02-19
ROIPixelTranslator.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Giulia Casarosa, Eugenio Paoloni *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 
12 #include <tracking/pxdDataReductionClasses/ROIPixelTranslator.h>
13 #include <framework/logging/Logger.h>
14 #include <vxd/geometry/GeoCache.h>
15 #include <vxd/geometry/SensorInfoBase.h>
16 
17 using namespace std;
18 using namespace Belle2;
19 
20 ROIPixelTranslator::ROIPixelTranslator(double user_sigmaSystU, double user_sigmaSystV, double user_numSigmaTotU,
21  double user_numSigmaTotV, double user_maxWidthU, double user_maxWidthV)
22  : m_sigmaSystU(user_sigmaSystU)
23  , m_sigmaSystV(user_sigmaSystV)
24  , m_numSigmaTotU(user_numSigmaTotU)
25  , m_numSigmaTotV(user_numSigmaTotV)
26  , m_maxWidthU(user_maxWidthU)
27  , m_maxWidthV(user_maxWidthV)
28 {}
29 
30 
32  : m_sigmaSystU(theROIinfo->sigmaSystU)
33  , m_sigmaSystV(theROIinfo->sigmaSystV)
34  , m_numSigmaTotU(theROIinfo->numSigmaTotU)
35  , m_numSigmaTotV(theROIinfo->numSigmaTotV)
36  , m_maxWidthU(theROIinfo->maxWidthU)
37  , m_maxWidthV(theROIinfo->maxWidthV)
38 {}
39 
40 
42 {}
43 
44 
45 void
47  StoreArray<ROIid>* ROIidList)
48 {
49 
51 
52  for (int i = 0; i < listOfIntercepts->getEntries(); i++) {
53 
54  B2DEBUG(10, " --->> a NEW INTERCEPT!");
55 
56 
57  const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo((*listOfIntercepts)[i]->getSensorID());
58 
59  double widthTotU = std::min(m_maxWidthU ,
60  sqrt((*listOfIntercepts)[i]->getSigmaU() * (*listOfIntercepts)[i]->getSigmaU() + m_sigmaSystU * m_sigmaSystU) * m_numSigmaTotU);
61  double widthTotV = std::min(m_maxWidthV ,
62  sqrt((*listOfIntercepts)[i]->getSigmaV() * (*listOfIntercepts)[i]->getSigmaV() + m_sigmaSystV * m_sigmaSystV) * m_numSigmaTotV);
63 
64  double minU = (*listOfIntercepts)[i]->getCoorU() - widthTotU / 2 ;
65  double maxU = (*listOfIntercepts)[i]->getCoorU() + widthTotU / 2 ;
66  const int nPixelsU = aSensorInfo.getUCells() - 1;
67 
68  double minV = (*listOfIntercepts)[i]->getCoorV() - widthTotV / 2;
69  double maxV = (*listOfIntercepts)[i]->getCoorV() + widthTotV / 2;
70  const int nPixelsV = aSensorInfo.getVCells() - 1;
71 
72  const int firstPixelID = 0;
73 
74  double bottomLeft_uID = aSensorInfo.getUCellID(minU, minV, false);
75  double bottomLeft_vID = aSensorInfo.getVCellID(minV, false);
76  double topRight_uID = aSensorInfo.getUCellID(maxU, maxV, false);
77  double topRight_vID = aSensorInfo.getVCellID(maxV, false);
78 
79  B2DEBUG(10, " LAYER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLayerNumber()
80  << " LADDER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLadderNumber()
81  << " SENSOR = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getSensorNumber()
82  );
83 
84  B2DEBUG(10, " nPixels (U,V) = (" << nPixelsU << "," << nPixelsV << ")");
85 
86  B2DEBUG(10, " widthU = " << maxU - minU
87  << " minU = " << minU
88  << " maxU = " << maxU
89  << " lengthU = " << aSensorInfo.getUSize((*listOfIntercepts)[i]->getCoorV())
90  );
91 
92  B2DEBUG(10, " widthV = " << maxV - minV
93  << " minV = " << minV
94  << " maxV = " << maxV
95  << " lengthV = " << aSensorInfo.getVSize());
96 
97  B2DEBUG(10, " bottom left pixel (U,V) = (" << bottomLeft_uID << "," << bottomLeft_vID << ")");
98  B2DEBUG(10, " top right pixel (U,V) = (" << topRight_uID << "," << topRight_vID << ")");
99 
100 
101  //check that the pixel belong to the sensor
102  bool inside = true;
103  if (bottomLeft_uID > nPixelsU || topRight_uID < firstPixelID || bottomLeft_vID > nPixelsV || topRight_vID < firstPixelID) {
104  B2DEBUG(5, " OOOPS: this pixel does NOT belong to the sensor");
105  inside = false;
106  }
107 
108  ROIid tmpROIid;
109 
110  if (inside) {
111  tmpROIid.setMinUid(aSensorInfo.getUCellID(minU, minV, true));
112  tmpROIid.setMinVid(aSensorInfo.getVCellID(minV, true));
113  tmpROIid.setMaxUid(aSensorInfo.getUCellID(maxU, maxV, true));
114  tmpROIid.setMaxVid(aSensorInfo.getVCellID(maxV, true));
115  tmpROIid.setSensorID((*listOfIntercepts)[i]->getSensorID()) ;
116 
117  ROIidList->appendNew(tmpROIid);
118 
119  // this is the pointer to the transient copy of tmpROIid
120  ROIid* transientROIid = (*ROIidList)[ROIidList->getEntries() - 1];
121 
122  (*listOfIntercepts)[i]->addRelationTo(transientROIid);
123 
124  }
125 
126  }
127 
128 }
129 
Belle2::StoreArray::appendNew
T * appendNew()
Construct a new T object at the end of the array.
Definition: StoreArray.h:256
Belle2::VXD::SensorInfoBase::getUCells
int getUCells() const
Return number of pixel/strips in u direction.
Definition: SensorInfoBase.h:223
Belle2::ROIPixelTranslator::m_numSigmaTotV
double m_numSigmaTotV
number of standard deviations to be taken to define a ROI along V
Definition: ROIPixelTranslator.h:62
Belle2::ROIPixelTranslator::ROIPixelTranslator
ROIPixelTranslator(const ROIinfo *theROIinfo)
Constructor.
Definition: ROIPixelTranslator.cc:31
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::VXD::SensorInfoBase::getUCellID
int getUCellID(double u, double v=0, bool clamp=false) const
Return the corresponding pixel/strip ID of a given u coordinate.
Definition: SensorInfoBase.h:203
Belle2::ROIPixelTranslator::m_maxWidthU
double m_maxWidthU
ROI maximum width allowed in the U direction.
Definition: ROIPixelTranslator.h:63
Belle2::RelationsInterface::addRelationTo
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).
Definition: RelationsObject.h:144
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::ROIPixelTranslator::m_numSigmaTotU
double m_numSigmaTotU
number of standard deviations to be taken to define a ROI along U
Definition: ROIPixelTranslator.h:61
Belle2::VXD::SensorInfoBase::getVCellID
int getVCellID(double v, bool clamp=false) const
Return the corresponding pixel/strip ID of a given v coordinate.
Definition: SensorInfoBase.h:213
Belle2::ROIid
ROIid stores the U and V ids and the sensor id of the Region Of Interest.
Definition: ROIid.h:35
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::SensorInfoBase::getVCells
int getVCells() const
Return number of pixel/strips in v direction.
Definition: SensorInfoBase.h:225
Belle2::ROIPixelTranslator::m_sigmaSystU
double m_sigmaSystU
systematic error along the U coordinate
Definition: ROIPixelTranslator.h:59
Belle2::ROIPixelTranslator::m_sigmaSystV
double m_sigmaSystV
systematic error along the V coordinate
Definition: ROIPixelTranslator.h:60
Belle2::VXD::SensorInfoBase::getUSize
double getUSize(double v=0) const
Return the width of the sensor.
Definition: SensorInfoBase.h:127
Belle2::ROIPixelTranslator::fillRoiIDList
void fillRoiIDList(StoreArray< PXDIntercept > *listOfIntercepts, StoreArray< ROIid > *ROIidList)
Append the ROIid to the list listToBeFilled.
Definition: ROIPixelTranslator.cc:46
Belle2::ROIPixelTranslator::m_maxWidthV
double m_maxWidthV
ROI maximum width allowed in the V direction.
Definition: ROIPixelTranslator.h:64
Belle2::VXD::GeoCache
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
Definition: GeoCache.h:41
ROIinfo
ROIinfo contains the parameters that can be changed by the user in the python script.
Definition: ROIinfo.h:8
Belle2::VXD::GeoCache::getSensorInfo
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:68
Belle2::ROIPixelTranslator::~ROIPixelTranslator
~ROIPixelTranslator()
Destructor.
Definition: ROIPixelTranslator.cc:41
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::VXD::SensorInfoBase::getVSize
double getVSize() const
Return the length of the sensor.
Definition: SensorInfoBase.h:132
Belle2::StoreArray::getEntries
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:226