9#include <pxd/modules/pxdPerformanceCollector/PXDPerformanceCollectorModule.h>
11#include <framework/datastore/RelationArray.h>
13#include <vxd/geometry/GeoCache.h>
14#include <pxd/geometry/SensorInfo.h>
15#include <pxd/reconstruction/PXDGainCalibrator.h>
16#include <pxd/utilities/PXDUtilities.h>
22#include <boost/format.hpp>
53 addParam(
"nBinsU",
m_nBinsU,
"Number of gain corrections per sensor along u side",
int(4));
54 addParam(
"nBinsV",
m_nBinsV,
"Number of gain corrections per sensor along v side",
int(6));
55 addParam(
"gainPayloadName",
m_gainName,
"Payload name for Gain to be read from DB",
string(
""));
57 "Flag to fill Ratio (cluster charge to the expected MPV) histograms",
bool(
true));
58 addParam(
"fillChargeTree",
m_fillChargeTree,
"Flag to fill cluster charge with the estimated MPV to TTree",
bool(
false));
63 addParam(
"maxAbsVx",
m_maxAbsVx,
"Minimum abs(Vx) cut in cm for efficiency validation",
float(0.03));
64 addParam(
"maxAbsVy",
m_maxAbsVy,
"Minimum abs(Vy) cut in cm for efficiency validation",
float(0.03));
65 addParam(
"maxAbsVz",
m_maxAbsVz,
"Minimum abs(Vz) cut in cm for efficiency validation",
float(0.155));
68 addParam(
"minSVDHits",
m_minSVDHits,
"Minimum number of SVD hits for resolution validation",
int(8));
69 addParam(
"minCDCHits",
m_minCDCHits,
"Minimum number of CDC hits for resolution validation",
int(21));
83 B2WARNING(
"Number of bins along u side incremented from 0->1");
88 B2WARNING(
"Number of bins along v side incremented from 0->1");
99 auto hPXDClusterCounter =
new TH1I(
"hPXDClusterCounter",
"Number of clusters found in data sample",
102 hPXDClusterCounter->GetXaxis()->SetTitle(
"bin id");
103 hPXDClusterCounter->GetYaxis()->SetTitle(
"Number of clusters");
104 auto hPXDClusterChargeRatio =
new TH2F(
"hPXDClusterChargeRatio",
"Charge ratio of clusters found in data sample",
108 hPXDClusterChargeRatio->GetXaxis()->SetTitle(
"bin id");
109 hPXDClusterChargeRatio->GetYaxis()->SetTitle(
"Cluster charge ratio (relative to expected MPV)");
120 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
121 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
122 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
123 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
124 string sensorDescr = id;
126 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
129 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
145 auto hPXDTrackClusterCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackClusterCounter");
146 hPXDTrackClusterCounter->SetTitle(
"Number of track clusters");
147 hPXDTrackClusterCounter->GetYaxis()->SetTitle(
"Number of track clusters");
153 auto hPXDTrackPointCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackPointCounter");
154 hPXDTrackPointCounter->SetTitle(
"Number of track points");
155 hPXDTrackPointCounter->GetYaxis()->SetTitle(
"Number of track points");
163 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
164 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
165 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
166 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
168 auto ladderNumber =
id.getLadderNumber();
169 auto sensorNumber =
id.getSensorNumber();
170 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
171 auto tree =
new TTree(treename.c_str(), treename.c_str());
172 tree->Branch<
int>(
"signal", &
m_signal);
184 auto hTotalHitsLayer1 =
new TH2F(
"hTotalHitsLayer1",
"Total number of hits from layer 1;#phi;z [cm]", 730, -M_PI, M_PI, 400,
186 auto hPassedHitsLayer1 =
new TH2F(
"hPassedHitsLayer1",
"Passed number of hits from layer 1;#phi;z [cm]", 730, -M_PI, M_PI, 400,
188 auto hTotalHitsLayer2 =
new TH2F(
"hTotalHitsLayer2",
"Total number of hits from layer 2;#phi;z [cm]", 128, 1.4, 2.5, 400,
190 auto hPassedHitsLayer2 =
new TH2F(
"hPassedHitsLayer2",
"Passed number of hits from layer 2;#phi;z [cm]", 128, 1.4, 2.5, 400,
198 auto treeD0Z0 =
new TTree(
"tree_d0z0",
"TTree of corrected d0 and z0");
204 auto dbtree =
new TTree(
"dbtree",
"dbtree");
205 dbtree->Branch<
int>(
"run", &
m_run);
206 dbtree->Branch<
int>(
"exp", &
m_exp);
211 auto tree =
new TTree(
"pxd",
"PXD 2-track events");
237 auto ip = ROOT::Math::XYZVector(beamSpotDB->getIPPosition());
244 auto vertex = pxd2TrackEvent.getVertex();
269 auto d0p_1 =
event.getTrackP().d0p;
270 auto d0p_2 =
event.getTrackM().d0p;
271 auto z0p_1 =
event.getTrackP().z0p;
272 auto z0p_2 =
event.getTrackM().z0p;
283 bool selected4Gain =
true;
284 bool selected4Eff =
true;
286 if (track.pt <
m_minPt) selected4Gain =
false;
295 auto lambda0 =
atan(track.tanLambda);
298 auto sinTheta0 = 1. /
sqrt(1. + pow(track.tanLambda, 2));
299 auto pBetaSinTheta3o2 = track.pt * 1.0 *
sqrt(sinTheta0);
303 for (
auto& trackCluster : track.trackClusters) {
304 bool selectedCluster =
true;
305 auto cluster = trackCluster.cluster;
306 auto intersection = trackCluster.intersection;
307 auto usedInTrack = trackCluster.usedInTrack;
310 if (!usedInTrack || intersection.chargeMPV <= 0)
311 selectedCluster =
false;
315 selectedCluster =
false;
317 if (cluster.pxdID <= 0) {
318 B2FATAL(
"Unexpected cluster module id : " << cluster.pxdID);
323 if (selected4Gain && selectedCluster) {
332 auto vID = Info.getVCellID(cluster.posV);
333 auto iSensor = gTools->getPXDSensorIndex(sensorID);
347 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
355 double maxY = axis->GetBinCenter(axis->GetNbins());
363 auto x = intersection.x;
364 auto y = intersection.y;
365 auto phi = atan2(y, x);
366 auto z = intersection.z;
371 auto localPoint = Info.
pointToLocal(ROOT::Math::XYZVector(x, y, z));
372 auto uID = Info.getUCellID(localPoint.X());
373 auto vID = Info.getVCellID(localPoint.Y());
374 auto iSensor = gTools->getPXDSensorIndex(sensorID);
384 if (cluster.pxdID < 2000) {
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
void event() final
Check current experiment and run and update if needed, fill into RunRange and collect()
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
Class for accessing objects in the database.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Belle2::PXD::Track_t baseType
Class PXD2TrackEvent: Event data container for performance and calibration studies.
The payload class for PXD gain corrections.
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...
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
const GeoTools * getGeoTools()
Return a raw pointer to a GeoTools object.
ROOT::Math::XYZVector pointToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a point from global to local coordinates.
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.
baseType getSensorNumber() const
Get the sensor id.
baseType getLadderNumber() const
Get the ladder id.
baseType getLayerNumber() const
Get the layer id.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double atan(double a)
atan for double
double sqrt(double a)
sqrt for double
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
VxdID getVxdIDFromPXDModuleID(const unsigned short &id)
Helper function to get VxdID from DHE id like module iid.
Abstract base class for different kinds of events.