Belle II Software development
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 {
44
45 public:
46
52 void prepare() override final;
54 void collect() override final;
56 void startRun() override final;
57
61 void collectDeltaIP();
66 void collectGainVariables(const PXD::TrackCluster_t& trackCluster);
71 void collectEfficiencyVariables(const PXD::TrackCluster_t& trackCluster);
72
82 int getBinID(const PXD::TrackCluster_t& trackCluster, int& uBin, int& vBin, bool useCluster = false)
83 {
84
85 // Get PXD::TrackPoint_t
86 auto const& tPoint = trackCluster.intersection;
87 // Get uBin and vBin from a global point.
88 VxdID sensorID = PXD::getVxdIDFromPXDModuleID(trackCluster.cluster.pxdID);
89 const PXD::SensorInfo& Info = dynamic_cast<const PXD::SensorInfo&>(VXD::GeoCache::getInstance().getSensorInfo(sensorID));
90 float posU(0.), posV(0.);
91 if (useCluster) {
92 posU = trackCluster.cluster.posU;
93 posV = trackCluster.cluster.posV;
94 } else {
95 auto localPoint = Info.pointToLocal(ROOT::Math::XYZVector(tPoint.x, tPoint.y, tPoint.z), true);
96 posU = localPoint.X();
97 posV = localPoint.Y();
98 }
99 auto uID = Info.getUCellID(posU);
100 auto vID = Info.getVCellID(posV);
101 auto iSensor = VXD::GeoCache::getInstance().getGeoTools()->getPXDSensorIndex(sensorID);
102 uBin = PXD::PXDGainCalibrator::getInstance().getBinU(sensorID, uID, vID, m_nBinsU);
104 //assert(uBin < m_nBinsU && vBin < m_nBinsV);
105 if (uBin >= m_nBinsU || vBin >= m_nBinsV)
106 throw std::out_of_range("uBin or vBin is outside of valid range.");
107
108 return iSensor * m_nBinsU * m_nBinsV + uBin * m_nBinsV + vBin;
109 }
110
118 bool isSelected(const VxdID& sensorID, const int& uID, const int& vID)
119 {
120 // Check a pixel matrix around the track point. Skip counting If any pixel is dead/hot.
121 // TODO: Using a dedicated cluster flag (under development).
122 if (PXD::isCloseToBorder(uID, vID, m_maskedDistance) ||
123 PXD::isDefectivePixelClose(uID, vID, m_maskedDistance, sensorID))
124 return false;
125 return true;
126 }
127
128 private:
131
140
146 std::string m_gainName;
153
156
166 int m_run;
168 int m_exp;
171
175 std::string m_PList4GainName = "";
177 std::string m_PList4EffName = "";
179 std::string m_PList4ResName = "";
180
181 };
183}
Calibration collector module base class.
The payload class for PXD gain corrections.
Definition: PXDGainMapPar.h:43
Collector module for PXD gain calibration and PXD calibration validation.
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 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
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
ROOT::Math::XYZVector pointToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a point from global to local coordinates.
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
VxdID getVxdIDFromPXDModuleID(const unsigned short &id)
Helper function to get VxdID from DHE id like module iid.
Definition: PXDUtilities.h:86
bool isCloseToBorder(int u, int v, int checkDistance)
Helper function to check if a pixel is close to the border.
Definition: PXDUtilities.cc:51
bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
Helper function to check if a defective (hot/dead) pixel is close.
Definition: PXDUtilities.cc:61
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 from a track which contains a vector of data type like TrackCluster.
Struct to hold variables for track clusters.
Cluster_t cluster
Cluster associated to the track.
TrackPoint_t intersection
The track-module intersection.