Belle II Software  release-06-01-15
ROIStripTranslator.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 #include <tracking/svdROIFinder/ROIStripTranslator.h>
10 #include <framework/logging/Logger.h>
11 #include <vxd/geometry/GeoCache.h>
12 #include <vxd/geometry/SensorInfoBase.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 
17 ROIStripTranslator::ROIStripTranslator(double user_sigmaSystU, double user_sigmaSystV, double user_numSigmaTotU,
18  double user_numSigmaTotV, double user_maxWidthU, double user_maxWidthV)
19  : m_sigmaSystU(user_sigmaSystU)
20  , m_sigmaSystV(user_sigmaSystV)
21  , m_numSigmaTotU(user_numSigmaTotU)
22  , m_numSigmaTotV(user_numSigmaTotV)
23  , m_maxWidthU(user_maxWidthU)
24  , m_maxWidthV(user_maxWidthV)
25 {}
26 
27 
29  : m_sigmaSystU(theROIinfo->sigmaSystU)
30  , m_sigmaSystV(theROIinfo->sigmaSystV)
31  , m_numSigmaTotU(theROIinfo->numSigmaTotU)
32  , m_numSigmaTotV(theROIinfo->numSigmaTotV)
33  , m_maxWidthU(theROIinfo->maxWidthU)
34  , m_maxWidthV(theROIinfo->maxWidthV)
35 {}
36 
37 
39 {}
40 
41 
42 void
44  StoreArray<ROIid>* ROIidList)
45 {
46 
48 
49  for (int i = 0; i < listOfIntercepts->getEntries(); i++) {
50 
51  B2DEBUG(10, " --->> a NEW INTERCEPT!");
52 
53 
54  const VXD::SensorInfoBase& aSensorInfo = aGeometry.getSensorInfo((*listOfIntercepts)[i]->getSensorID());
55 
56  double widthTotU = std::min(m_maxWidthU ,
57  sqrt((*listOfIntercepts)[i]->getSigmaU() * (*listOfIntercepts)[i]->getSigmaU() + m_sigmaSystU * m_sigmaSystU) * m_numSigmaTotU);
58  double widthTotV = std::min(m_maxWidthV ,
59  sqrt((*listOfIntercepts)[i]->getSigmaV() * (*listOfIntercepts)[i]->getSigmaV() + m_sigmaSystV * m_sigmaSystV) * m_numSigmaTotV);
60 
61  double minU = (*listOfIntercepts)[i]->getCoorU() - widthTotU / 2 ;
62  double maxU = (*listOfIntercepts)[i]->getCoorU() + widthTotU / 2 ;
63  const int nStripsU = aSensorInfo.getUCells() - 1;
64 
65  double minV = (*listOfIntercepts)[i]->getCoorV() - widthTotV / 2;
66  double maxV = (*listOfIntercepts)[i]->getCoorV() + widthTotV / 2;
67  const int nStripsV = aSensorInfo.getVCells() - 1;
68 
69  const int firstStripID = 0;
70 
71  double min_uID = aSensorInfo.getUCellID(minU, minV, false);
72  double min_vID = aSensorInfo.getVCellID(minV, false);
73  double max_uID = aSensorInfo.getUCellID(maxU, maxV, false);
74  double max_vID = aSensorInfo.getVCellID(maxV, false);
75 
76  B2DEBUG(10, " LAYER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLayerNumber()
77  << " LADDER = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getLadderNumber()
78  << " SENSOR = " << VxdID((*listOfIntercepts)[i]->getSensorID()).getSensorNumber()
79  );
80 
81  B2DEBUG(10, " nStrips (U,V) = (" << nStripsU << "," << nStripsV << ")");
82 
83  B2DEBUG(10, " widthU = " << maxU - minU
84  << " minU = " << minU
85  << " maxU = " << maxU
86  << " lengthU = " << aSensorInfo.getUSize((*listOfIntercepts)[i]->getCoorV())
87  );
88 
89  B2DEBUG(10, " widthV = " << maxV - minV
90  << " minV = " << minV
91  << " maxV = " << maxV
92  << " lengthV = " << aSensorInfo.getVSize());
93 
94  B2DEBUG(10, " U strips in (" << min_uID << "," << max_uID << ")");
95  B2DEBUG(10, " V strips in (" << min_vID << "," << max_vID << ")");
96 
97 
98  //check that the pixel belong to the sensor
99  bool inside = true;
100  if (min_uID > nStripsU || max_uID < firstStripID || min_vID > nStripsV || max_vID < firstStripID) {
101  B2DEBUG(5, " OOOPS: this pixel does NOT belong to the sensor");
102  inside = false;
103  }
104 
105  ROIid tmpROIid;
106 
107  if (inside) {
108  tmpROIid.setMinUid(aSensorInfo.getUCellID(minU, minV, true));
109  tmpROIid.setMinVid(aSensorInfo.getVCellID(minV, true));
110  tmpROIid.setMaxUid(aSensorInfo.getUCellID(maxU, maxV, true));
111  tmpROIid.setMaxVid(aSensorInfo.getVCellID(maxV, true));
112  tmpROIid.setSensorID((*listOfIntercepts)[i]->getSensorID()) ;
113 
114  ROIidList->appendNew(tmpROIid);
115 
116  // this is the pointer to the transient copy of tmpROIid
117  ROIid* transientROIid = (*ROIidList)[ROIidList->getEntries() - 1];
118 
119  (*listOfIntercepts)[i]->addRelationTo(transientROIid);
120 
121  }
122 
123  }
124 
125 }
126 
double m_maxWidthV
ROI maximum width allowed in the V direction.
double m_maxWidthU
ROI maximum width allowed in the U direction.
ROIStripTranslator(const ROIinfo *theROIinfo)
Constructor.
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
void fillRoiIDList(StoreArray< SVDIntercept > *listOfIntercepts, StoreArray< ROIid > *ROIidList)
Append the ROIid to the list listToBeFilled.
double m_numSigmaTotU
number of standard deviations to be taken to define a ROI along U
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