Belle II Software development
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#include <pxd/utilities/PXDUtilities.h>
13
14namespace Belle2 {
19 namespace PXD {
20
21
22 void Cluster_t::setValues(const PXDCluster& pxdCluster)
23 {
24 pxdID = getPXDModuleID(pxdCluster.getSensorID());
25 charge = pxdCluster.getCharge();
26 size = pxdCluster.getSize();
27 uSize = pxdCluster.getUSize();
28 vSize = pxdCluster.getVSize();
29 posU = pxdCluster.getU();
30 posV = pxdCluster.getV();
31 }
32
33 RecoTrack* TrackPoint_t::setValues(const PXDIntercept& pxdIntercept, const std::string& recoTracksName, const double& mass)
34 {
35 // Construct VxdID from its baseType (unsigned short)
36 VxdID sensorID(pxdIntercept.getSensorID());
37
38 //RelationVector<RecoTrack>
39 // DataStore::getRelationsWithObj<RecoTrack>(pxdIntercept);
40 auto recoTracks = pxdIntercept.getRelationsFrom<RecoTrack>(recoTracksName);
41
42 // The recoTracks collection shouldn't be empty
43 if (!recoTracks.size()) return nullptr;
44
45 // Propogate a track state back to the module of interest
46 // as PXDIntercept doesn't contain global track point,
47 // cos(incident angle), and the expected charge from the hit.
48 const VXD::SensorInfoBase& sensorInfo = VXD::GeoCache::getInstance().getSensorInfo(sensorID);
49 auto statePtr = getTrackStateOnModule(sensorInfo, *recoTracks[0]);
50 if (statePtr == nullptr) return nullptr; // shouldn't happen.
51 auto intersec = statePtr -> getPos();
52 auto localPoint = sensorInfo.pointToLocal(ROOT::Math::XYZVector(intersec), true);
53 auto intersec_p = statePtr -> getMom();
54 auto local_p = sensorInfo.vectorToLocal(ROOT::Math::XYZVector(intersec_p), true);
55
56 //inside = sensorInfo.inside(localPoint.X(), localPoint.Y(), 0., 0.);
57 inside = sensorInfo.inside(localPoint.X(), localPoint.Y());
58 x = intersec.X();
59 y = intersec.Y();
60 z = intersec.Z();
61 tol = cos(local_p.Theta());
62
63 // Estimate the charge MPV (in ADU) of the hit.
64 double length = sensorInfo.getThickness() / tol; // track path length
65 auto ADUToEnergy = PXD::PXDGainCalibrator::getInstance().getADUToEnergy(sensorID,
66 sensorInfo.getUCellID(pxdIntercept.getCoorU()),
67 sensorInfo.getVCellID(pxdIntercept.getCoorV()));
68 chargeMPV = getDeltaP(intersec_p.Mag(), length, mass) / ADUToEnergy;
69
70 // Return pointer of the relatd RecoTrack for accessing additional info.
71 return recoTracks[0];
72 }
73
75 const std::string& recoTracksName,
76 const std::string& pxdTrackClustersName,
77 const double& mass)
78 {
79 auto recoTrackPtr = intersection.setValues(pxdIntercept, recoTracksName, mass);
80 // sensor ID from intersectioon
81 //VxdID sensorID(pxdIntercept.getSensorID());
82 if (!recoTrackPtr) return nullptr; // return nullptr
83 // Always set cluster pxdID for saving module id of the intersection.
84 cluster.pxdID = getPXDModuleID(VxdID(pxdIntercept.getSensorID()));
85 RelationVector<PXDCluster> pxdClusters = DataStore::getRelationsWithObj<PXDCluster>(recoTrackPtr, pxdTrackClustersName);
86 // Avoid returning nullptr (false) when no clusters associated,
87 // otherwise efficiency is overestimated!
88 // if (!pxdClusters.size()) return nullptr;
89 usedInTrack = false;
90 for (auto& aCluster : pxdClusters) {
91 if (aCluster.getSensorID().getID() == pxdIntercept.getSensorID()) {
92 cluster.setValues(aCluster);
93 dU = aCluster.getU() - pxdIntercept.getCoorU();
94 dV = aCluster.getV() - pxdIntercept.getCoorV();
95 usedInTrack = true;
96 break;
97 }
98 }
99 // If usedInTrack is still false, we can loop PXDClusters datastore to find one closest to the track point. (To be implemented)
100 return recoTrackPtr;
101 }
102
103 // Explicit instantiation of templates
104 //template struct TrackBase_t<TrackCluster_t>;
105
106 } // end namespace PXD
108} // 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:79
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:68
double getCoorU() const
return the U coordinate of the intercept
Definition: VXDIntercept.h:59
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.
ROOT::Math::XYZVector pointToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a point from global to local coordinates.
ROOT::Math::XYZVector vectorToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a vector from global to local coordinates.
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.
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.
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:21
unsigned short getPXDModuleID(const VxdID &sensorID)
Helper function to get DHE id like module id from VxdID.
Definition: PXDUtilities.h:78
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:68
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.