Belle II Software prerelease-10-00-00a
PXDPerformanceVariablesCollectorModule.h
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#pragma once
10
11#include <calibration/CalibrationCollectorModule.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <vxd/geometry/GeoCache.h>
14#include <pxd/geometry/SensorInfo.h>
15#include <pxd/utilities/PXDPerformanceStructs.h>
16#include <pxd/utilities/PXDUtilities.h>
17#include <pxd/reconstruction/PXDGainCalibrator.h>
18#include <pxd/dbobjects/PXDGainMapPar.h>
19#include <pxd/reconstruction/PXDPixelMasker.h>
20
21#include <string>
22
23namespace Belle2 {
47
48 public:
49
55 void prepare() override final;
57 void collect() override final;
59 void startRun() override final;
60
64 void collectDeltaIP();
69 void collectGainVariables(const PXD::TrackCluster_t& trackCluster);
74 void collectEfficiencyVariables(const PXD::TrackCluster_t& trackCluster);
75
85 int getBinID(const PXD::TrackCluster_t& trackCluster, int& uBin, int& vBin, bool useCluster = false)
86 {
87
88 // Get PXD::TrackPoint_t
89 auto const& tPoint = trackCluster.intersection;
90 // Get uBin and vBin from a global point.
91 VxdID sensorID = PXD::getVxdIDFromPXDModuleID(trackCluster.cluster.pxdID);
92 const PXD::SensorInfo& Info = dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::getInstance().getSensorInfo(sensorID));
93 float posU(0.), posV(0.);
94 if (useCluster) {
95 posU = trackCluster.cluster.posU;
96 posV = trackCluster.cluster.posV;
97 } else {
98 auto localPoint = Info.pointToLocal(ROOT::Math::XYZVector(tPoint.x, tPoint.y, tPoint.z), true);
99 posU = localPoint.X();
100 posV = localPoint.Y();
101 }
102 auto uID = Info.getUCellID(posU);
103 auto vID = Info.getVCellID(posV);
104 auto iSensor = VXD::GeoCache::getInstance().getGeoTools()->getPXDSensorIndex(sensorID);
105 uBin = PXD::PXDGainCalibrator::getInstance().getBinU(sensorID, uID, vID, m_nBinsU);
107 //assert(uBin < m_nBinsU && vBin < m_nBinsV);
108 if (uBin >= m_nBinsU || vBin >= m_nBinsV)
109 throw std::out_of_range("uBin or vBin is outside of valid range.");
110
111 return iSensor * m_nBinsU * m_nBinsV + uBin * m_nBinsV + vBin;
112 }
113
121 bool isSelected(const VxdID& sensorID, const int& uID, const int& vID)
122 {
123 // Check a pixel matrix around the track point. Skip counting If any pixel is dead/hot.
124 // TODO: Using a dedicated cluster flag (under development).
125 if (PXD::isCloseToBorder(uID, vID, m_maskedDistance) ||
126 PXD::isDefectivePixelClose(uID, vID, m_maskedDistance, sensorID))
127 return false;
128 return true;
129 }
130
131 private:
134
143
149 std::string m_gainName;
156
159
169 int m_run;
171 int m_exp;
174
178 std::string m_PList4GainName = "";
180 std::string m_PList4EffName = "";
182 std::string m_PList4ResName = "";
183
184 };
185
186}
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
The payload class for PXD gain corrections.
bool isSelected(const VxdID &sensorID, const int &uID, const int &vID)
Helper function to select a track point according to the status of the related pixels.
std::string m_PList4ResName
Name of the particle list for resolution study.
int m_nBinsV
Number of corrections per sensor along v side.
bool m_fillChargeRatioHistogram
Flag to fill cluster charge ratio (relative to expected MPV) histograms.
std::string m_PList4GainName
Name of the particle list for gain calibration.
PXD::Track_t m_track_struct
Track struct for holding required variables.
std::string m_gainName
Payload name for Gain to be read from DB.
void collectGainVariables(const PXD::TrackCluster_t &trackCluster)
Collect variables for gain calibration.
bool m_useClusterPosition
Flag to use cluster position rather than track point to group pixels into bins for gain calibration.
std::string m_PList4EffName
Name of the particle list for efficiency study.
int m_nBinsU
Number of corrections per sensor along u side.
StoreObjPtr< EventMetaData > m_evtMetaData
Required input EventMetaData.
void collectEfficiencyVariables(const PXD::TrackCluster_t &trackCluster)
Collect variables for efficiency monitoring.
PXDPerformanceVariablesCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
bool m_selected4Eff
Event selection for efficiency validation.
int m_maskedDistance
Distance inside which no dead pixel or module border is allowed.
int getBinID(const PXD::TrackCluster_t &trackCluster, int &uBin, int &vBin, bool useCluster=false)
Helper function to get binID, uBin and vBin from Cluster_t struct The binning is derived from PXD::PX...
bool m_fillChargeTree
Flag to fill cluster charge and its estimated MPV in TTree.
void collectDeltaIP()
Collect info for impact parameter study on event level.
unsigned short getBinV(VxdID id, unsigned int vid) const
Get gain correction bin along sensor v side.
unsigned short getBinU(VxdID id, unsigned int uid, unsigned int vid) const
Get gain correction bin along sensor u side.
static PXDGainCalibrator & getInstance()
Main (and only) way to access the PXDGainCalibrator.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition SensorInfo.h:23
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference 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
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
Definition GeoCache.h:142
int getPXDSensorIndex(VxdID sensorID) const
Return index of sensor in plots.
Definition GeoTools.h:224
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:33
VxdID getVxdIDFromPXDModuleID(const unsigned short &id)
Helper function to get VxdID from DHE id like module iid.
bool isCloseToBorder(int u, int v, int checkDistance)
Helper function to check if a pixel is close to the border.
TrackBase_t< TrackCluster_t > Track_t
Typedef TrackBase_t<TrackCluster_t> Track_t.
bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
Helper function to check if a defective (hot/dead) pixel is close.
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.
Struct to hold variables for track clusters.
Cluster_t cluster
Cluster associated to the track.
TrackPoint_t intersection
The track-module intersection.