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