Belle II Software  release-06-01-15
PXDPerformanceStructs.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 <pxd/utilities/PXDPerformanceStructs.h>
10 #include <framework/logging/Logger.h>
11 #include <pxd/reconstruction/PXDGainCalibrator.h>
12 
13 namespace Belle2 {
18  namespace PXD {
19 
20 
21  void Cluster_t::setValues(const PXDCluster& pxdCluster)
22  {
23  pxdID = getPXDModuleID(pxdCluster.getSensorID());
24  charge = pxdCluster.getCharge();
25  size = pxdCluster.getSize();
26  uSize = pxdCluster.getUSize();
27  vSize = pxdCluster.getVSize();
28  posU = pxdCluster.getU();
29  posV = pxdCluster.getV();
30  }
31 
32  RecoTrack* TrackPoint_t::setValues(const PXDIntercept& pxdIntercept, const std::string& recoTracksName, const double& mass)
33  {
34  // Construct VxdID from its baseType (unsigned short)
35  VxdID sensorID(pxdIntercept.getSensorID());
36 
37  //RelationVector<RecoTrack>
38  // DataStore::getRelationsWithObj<RecoTrack>(pxdIntercept);
39  auto recoTracks = pxdIntercept.getRelationsFrom<RecoTrack>(recoTracksName);
40 
41  // The recoTracks collection shouldn't be empty
42  if (!recoTracks.size()) return nullptr;
43 
44  // Propogate a track state back to the module of interest
45  // as PXDIntercept doesn't contain global track point,
46  // cos(incident angle), and the expected charge from the hit.
47  const VXD::SensorInfoBase& sensorInfo = VXD::GeoCache::getInstance().get(sensorID);
48  auto statePtr = getTrackStateOnModule(sensorInfo, *recoTracks[0]);
49  if (statePtr == nullptr) return nullptr; // shouldn't happen.
50  auto intersec = statePtr -> getPos();
51  auto localPoint = sensorInfo.pointToLocal(intersec, true);
52  auto intersec_p = statePtr -> getMom();
53  auto local_p = sensorInfo.vectorToLocal(intersec_p, true);
54 
55  //inside = sensorInfo.inside(localPoint.X(), localPoint.Y(), 0., 0.);
56  inside = sensorInfo.inside(localPoint.X(), localPoint.Y());
57  x = intersec.X();
58  y = intersec.Y();
59  z = intersec.Z();
60  tol = local_p.CosTheta();
61 
62  // Estimate the charge MPV (in ADU) of the hit.
63  double length = sensorInfo.getThickness() / tol; // track path length
64  auto ADUToEnergy = PXD::PXDGainCalibrator::getInstance().getADUToEnergy(sensorID,
65  sensorInfo.getUCellID(pxdIntercept.getCoorU()),
66  sensorInfo.getVCellID(pxdIntercept.getCoorV()));
67  chargeMPV = getDeltaP(intersec_p.Mag(), length, mass) / ADUToEnergy;
68 
69  // Return pointer of the relatd RecoTrack for accessing additional info.
70  return recoTracks[0];
71  }
72 
74  const std::string& recoTracksName,
75  const std::string& pxdTrackClustersName,
76  const double& mass)
77  {
78  auto recoTrackPtr = intersection.setValues(pxdIntercept, recoTracksName, mass);
79  // sensor ID from intersectioon
80  //VxdID sensorID(pxdIntercept.getSensorID());
81  if (!recoTrackPtr) return nullptr; // return nullptr
82  // Always set cluster pxdID for saving module id of the intersection.
83  cluster.pxdID = getPXDModuleID(VxdID(pxdIntercept.getSensorID()));
84  RelationVector<PXDCluster> pxdClusters = DataStore::getRelationsWithObj<PXDCluster>(recoTrackPtr, pxdTrackClustersName);
85  // Avoid returning nullptr (false) when no clusters associated,
86  // otherwise efficiency is overestimated!
87  // if (!pxdClusters.size()) return nullptr;
88  usedInTrack = false;
89  for (auto& aCluster : pxdClusters) {
90  if (aCluster.getSensorID().getID() == pxdIntercept.getSensorID()) {
91  cluster.setValues(aCluster);
92  dU = aCluster.getU() - pxdIntercept.getCoorU();
93  dV = aCluster.getV() - pxdIntercept.getCoorV();
94  usedInTrack = true;
95  break;
96  }
97  }
98  // If usedInTrack is still false, we can loop PXDClusters datastore to find one closest to the track point. (To be implemented)
99  return recoTrackPtr;
100  }
101 
102  // Explicit instantiation of templates
103  //template struct TrackBase_t<TrackCluster_t>;
104 
105  } // end namespace PXD
107 } // end namespace Belle2
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:30
float getV() const
Get v coordinate of hit position.
Definition: PXDCluster.h:136
unsigned short getVSize() const
Get cluster size in v direction.
Definition: PXDCluster.h:176
unsigned short getSize() const
Get cluster size.
Definition: PXDCluster.h:166
unsigned short getCharge() const
Get collected charge.
Definition: PXDCluster.h:156
unsigned short getUSize() const
Get cluster size in u direction.
Definition: PXDCluster.h:171
VxdID getSensorID() const
Get the sensor ID.
Definition: PXDCluster.h:126
float getU() const
Get u coordinate of hit position.
Definition: PXDCluster.h:131
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:22
float getADUToEnergy(VxdID id, unsigned int uid, unsigned int vid) const
Get conversion factor from ADU to energy.
static PXDGainCalibrator & getInstance()
Main (and only) way to access the PXDGainCalibrator.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
Class for type safe access to objects that are referred to in relations.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
double getCoorV() const
return the V coordinate of the intercept
Definition: VXDIntercept.h:60
VxdID::baseType getSensorID() const
return the sensor ID
Definition: VXDIntercept.h:66
double getCoorU() const
return the U coordinate of the intercept
Definition: VXDIntercept.h:59
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
Base class to provide Sensor Information for PXD and SVD.
bool inside(double u, double v, double uTolerance=DBL_EPSILON, double vTolerance=DBL_EPSILON) const
Check wether a given point is inside the active area.
TVector3 pointToLocal(const TVector3 &global, bool reco=false) const
Convert a point from global to local coordinates.
double getThickness() const
Return the thickness 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.
TVector3 vectorToLocal(const TVector3 &global, bool reco=false) const
Convert a vector from global to local coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
std::shared_ptr< TrackState > getTrackStateOnModule(const VXD::SensorInfoBase &pxdSensorInfo, RecoTrack &recoTrack, double lambda=0.0)
Helper function to get a track state on a module.
Definition: PXDUtilities.cc:20
unsigned short getPXDModuleID(const VxdID &sensorID)
Helper function to get DHE id like module id from VxdID.
Definition: PXDUtilities.h:79
double getDeltaP(const double mom, const double length, const double mass=Const::electronMass)
helper function to estimate the most probable energy loss for a given track length.
Definition: PXDUtilities.h:69
Abstract base class for different kinds of events.
float posV
Local position along z.
float posU
Local position in r-phi.
unsigned short pxdID
Human readable id: layer * 1000 + ladder * 10 + sensor.
void setValues(const PXDCluster &pxdCluster)
Update values from a PXDCluster.
unsigned short charge
Cluster charge in ADU.
unsigned short uSize
Cluster size in U.
unsigned short vSize
Cluster size in V.
unsigned short size
Cluster size.
float dU
Residual (meas - prediction) in U.
bool usedInTrack
True if the cluster is used in tracking.
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string &recoTracksName="", const std::string &pxdTrackClustersName="PXDClustersFromTracks", const double &mass=Const::electronMass)
Update values from a PXDIntercept.
Cluster_t cluster
Cluster associated to the track.
TrackPoint_t intersection
The track-module intersection.
float dV
Residual (meas - prediciton) in V.
bool inside
True if it's inside the active region.
float chargeMPV
Expected charge in ADU.
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string &recoTracksName="", const double &mass=Const::electronMass)
Update values from a PXDCluster.
float tol
The variables below are included here as they can be calculated w.o.
float y
Global position in y.
float x
Global position in x.
float z
Global position in z.