Belle II Software  release-05-02-19
PXDPerformanceStructs.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2021 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Qingyuan Liu *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <pxd/utilities/PXDPerformanceStructs.h>
12 #include <framework/logging/Logger.h>
13 #include <pxd/reconstruction/PXDGainCalibrator.h>
14 
15 namespace Belle2 {
20  namespace PXD {
21 
22 
23  void Cluster_t::setValues(const PXDCluster& pxdCluster)
24  {
25  pxdID = getPXDModuleID(pxdCluster.getSensorID());
26  charge = pxdCluster.getCharge();
27  size = pxdCluster.getSize();
28  uSize = pxdCluster.getUSize();
29  vSize = pxdCluster.getVSize();
30  posU = pxdCluster.getU();
31  posV = pxdCluster.getV();
32  }
33 
34  RecoTrack* TrackPoint_t::setValues(const PXDIntercept& pxdIntercept, const std::string recoTracksName)
35  {
36  // Construct VxdID from its baseType (unsigned short)
37  VxdID sensorID(pxdIntercept.getSensorID());
38 
39  //RelationVector<RecoTrack>
40  // DataStore::getRelationsWithObj<RecoTrack>(pxdIntercept);
41  auto recoTracks = pxdIntercept.getRelationsFrom<RecoTrack>(recoTracksName);
42 
43  // The recoTracks collection shouldn't be empty
44  if (!recoTracks.size()) return nullptr;
45 
46  // Propogate a track state back to the module of interest
47  // as PXDIntercept doesn't contain global track point,
48  // cos(incident angle), and the expected charge from the hit.
49  const VXD::SensorInfoBase& sensorInfo = VXD::GeoCache::getInstance().get(sensorID);
50  auto statePtr = getTrackStateOnModule(sensorInfo, *recoTracks[0]);
51  if (statePtr == nullptr) return nullptr; // shouldn't happen.
52  auto intersec = statePtr -> getPos();
53  auto intersec_p = statePtr -> getMom();
54  auto local_p = sensorInfo.vectorToLocal(intersec_p, true);
55 
56  x = intersec.X();
57  y = intersec.Y();
58  z = intersec.Z();
59  tol = local_p.CosTheta();
60 
61  // Estimate the charge MPV (in ADU) of the hit.
62  double length = sensorInfo.getThickness() / tol; // track path length
63  auto ADUToEnergy = PXD::PXDGainCalibrator::getInstance().getADUToEnergy(sensorID,
64  sensorInfo.getUCellID(pxdIntercept.getCoorU()),
65  sensorInfo.getVCellID(pxdIntercept.getCoorV()));
66  chargeMPV = getDeltaP(intersec_p.Mag(), length) / ADUToEnergy;
67 
68  // Return pointer of the relatd RecoTrack for accessing additional info.
69  return recoTracks[0];
70  }
71 
73  const std::string recoTracksName,
74  const std::string pxdTrackClustersName)
75  {
76  auto recoTrackPtr = intersection.setValues(pxdIntercept, recoTracksName);
77  // sensor ID from intersectioon
78  //VxdID sensorID(pxdIntercept.getSensorID());
79  if (!recoTrackPtr) return nullptr; // return nullptr
80  // Always set cluster pxdID for saving module id of the intersection.
81  cluster.pxdID = getPXDModuleID(VxdID(pxdIntercept.getSensorID()));
82  RelationVector<PXDCluster> pxdClusters = DataStore::getRelationsWithObj<PXDCluster>(recoTrackPtr, pxdTrackClustersName);
83  // Return nullptr (false) as no clusters associated;
84  if (!pxdClusters.size()) return nullptr;
85  for (auto& aCluster : pxdClusters) {
86  if (aCluster.getSensorID().getID() == pxdIntercept.getSensorID()) {
87  cluster.setValues(aCluster);
88  dU = aCluster.getU() - pxdIntercept.getCoorU();
89  dV = aCluster.getV() - pxdIntercept.getCoorV();
90  usedInTrack = true;
91  break;
92  }
93  }
94  // If usedInTrack is still false, we can loop PXDClusters datastore to find one closest to the track point. (To be implemented)
95  return recoTrackPtr;
96  }
97 
98  // Explicit instantiation of templates
99  //template struct TrackBase_t<TrackCluster_t>;
100 
101  } // end namespace PXD
103 } // end namespace Belle2
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::PXD::Cluster_t::charge
unsigned short charge
Cluster charge in ADU.
Definition: PXDPerformanceStructs.h:60
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::PXD::TrackPoint_t::setValues
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string recoTracksName="")
Update values from a PXDCluster.
Definition: PXDPerformanceStructs.cc:42
Belle2::PXD::getPXDModuleID
unsigned short getPXDModuleID(const VxdID &sensorID)
Helper function to get DHE id like module id from VxdID.
Definition: PXDUtilities.h:89
Belle2::VXD::GeoCache::get
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:141
Belle2::PXD::TrackCluster_t::intersection
TrackPoint_t intersection
The track-module intersection.
Definition: PXDPerformanceStructs.h:111
Belle2::PXD::Cluster_t::uSize
unsigned short uSize
Cluster size in U.
Definition: PXDPerformanceStructs.h:62
Belle2::PXD::TrackPoint_t::chargeMPV
float chargeMPV
Expected charge in ADU.
Definition: PXDPerformanceStructs.h:90
Belle2::PXD::Cluster_t::posU
float posU
Local position in r-phi.
Definition: PXDPerformanceStructs.h:64
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::PXD::Cluster_t::size
unsigned short size
Cluster size.
Definition: PXDPerformanceStructs.h:61
Belle2::PXD::Cluster_t::posV
float posV
Local position along z.
Definition: PXDPerformanceStructs.h:65
Belle2::PXD::TrackCluster_t::dU
float dU
Residual (meas - prediction) in U.
Definition: PXDPerformanceStructs.h:108
Belle2::PXD::TrackCluster_t::cluster
Cluster_t cluster
Cluster associated to the track.
Definition: PXDPerformanceStructs.h:110
Belle2::PXD::Cluster_t::vSize
unsigned short vSize
Cluster size in V.
Definition: PXDPerformanceStructs.h:63
Belle2::PXD::TrackCluster_t::dV
float dV
Residual (meas - prediciton) in V.
Definition: PXDPerformanceStructs.h:109
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::PXD::TrackPoint_t::tol
float tol
The variables below are included here as they can be calculated w.o.
Definition: PXDPerformanceStructs.h:89
Belle2::PXD::PXDGainCalibrator::getADUToEnergy
float getADUToEnergy(VxdID id, unsigned int uid, unsigned int vid) const
Get conversion factor from ADU to energy.
Definition: PXDGainCalibrator.cc:45
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
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::PXD::TrackPoint_t::y
float y
Global position in y.
Definition: PXDPerformanceStructs.h:83
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::getThickness
double getThickness() const
Return the thickness of the sensor.
Definition: SensorInfoBase.h:121
Belle2::RelationsInterface::getRelationsFrom
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
Definition: RelationsObject.h:214
Belle2::PXD::TrackCluster_t::setValues
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string recoTracksName="", const std::string pxdTrackClustersName="PXDClustersFromTracks")
Update values from a PXDIntercept.
Definition: PXDPerformanceStructs.cc:80
Belle2::PXD::getDeltaP
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:79
Belle2::PXD::TrackCluster_t::usedInTrack
bool usedInTrack
True if the cluster is used in tracking.
Definition: PXDPerformanceStructs.h:107
Belle2::PXD::Cluster_t::pxdID
unsigned short pxdID
Human readable id: layer * 1000 + ladder * 10 + sensor.
Definition: PXDPerformanceStructs.h:59
Belle2::PXD::Cluster_t::setValues
void setValues(const PXDCluster &pxdCluster)
Update values from a PXDCluster.
Definition: PXDPerformanceStructs.cc:31
Belle2::PXD::PXDGainCalibrator::getInstance
static PXDGainCalibrator & getInstance()
Main (and only) way to access the PXDGainCalibrator.
Definition: PXDGainCalibrator.cc:29
Belle2::VXD::SensorInfoBase::vectorToLocal
TVector3 vectorToLocal(const TVector3 &global, bool reco=false) const
Convert a vector from global to local coordinates.
Definition: SensorInfoBase.h:403
Belle2::PXDIntercept
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
Definition: PXDIntercept.h:32
Belle2::PXD::TrackPoint_t::x
float x
Global position in x.
Definition: PXDPerformanceStructs.h:82
Belle2::PXD::TrackPoint_t::z
float z
Global position in z.
Definition: PXDPerformanceStructs.h:84