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>
23#include <boost/format.hpp>
40 , m_selectedEff(true), m_selectedRes(true)
42 , m_deltaD0oSqrt2(0.0), m_deltaZ0oSqrt2(0.0)
43 , m_signal(0), m_estimated(0.0)
54 addParam(
"nBinsU",
m_nBinsU,
"Number of gain corrections per sensor along u side",
int(4));
55 addParam(
"nBinsV",
m_nBinsV,
"Number of gain corrections per sensor along v side",
int(6));
56 addParam(
"gainPayloadName",
m_gainName,
"Payload name for Gain to be read from DB",
string(
""));
58 "Flag to fill Ratio (cluster charge to the expected MPV) histograms",
bool(
true));
59 addParam(
"fillChargeTree",
m_fillChargeTree,
"Flag to fill cluster charge with the estimated MPV to TTree",
bool(
false));
64 addParam(
"maxAbsVx",
m_maxAbsVx,
"Minimum abs(Vx) cut in cm for efficiency validation",
float(0.03));
65 addParam(
"maxAbsVy",
m_maxAbsVy,
"Minimum abs(Vy) cut in cm for efficiency validation",
float(0.03));
66 addParam(
"maxAbsVz",
m_maxAbsVz,
"Minimum abs(Vz) cut in cm for efficiency validation",
float(0.155));
69 addParam(
"minSVDHits",
m_minSVDHits,
"Minimum number of SVD hits foor resolution validation",
int(8));
70 addParam(
"minCDCHits",
m_minCDCHits,
"Minimum number of CDC hits foor resolution validation",
int(21));
84 B2WARNING(
"Number of bins along u side incremented from 0->1");
89 B2WARNING(
"Number of bins along v side incremented from 0->1");
100 auto hPXDClusterCounter =
new TH1I(
"hPXDClusterCounter",
"Number of clusters found in data sample",
103 hPXDClusterCounter->GetXaxis()->SetTitle(
"bin id");
104 hPXDClusterCounter->GetYaxis()->SetTitle(
"Number of clusters");
105 auto hPXDClusterChargeRatio =
new TH2F(
"hPXDClusterChargeRatio",
"Charge ratio of clusters found in data sample",
109 hPXDClusterChargeRatio->GetXaxis()->SetTitle(
"bin id");
110 hPXDClusterChargeRatio->GetYaxis()->SetTitle(
"Cluster charge ratio (relative to expected MPV)");
121 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
122 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
123 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
124 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
125 string sensorDescr = id;
127 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
130 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
139 registerObject<TH1I>(
"PXDClusterCounter", hPXDClusterCounter);
141 registerObject<TH2F>(
"PXDClusterChargeRatio", hPXDClusterChargeRatio);
146 auto hPXDTrackClusterCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackClusterCounter");
147 hPXDTrackClusterCounter->SetTitle(
"Number of track clusters");
148 hPXDTrackClusterCounter->GetYaxis()->SetTitle(
"Number of track clusters");
149 registerObject<TH1I>(
"PXDTrackClusterCounter", hPXDTrackClusterCounter);
154 auto hPXDTrackPointCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackPointCounter");
155 hPXDTrackPointCounter->SetTitle(
"Number of track points");
156 hPXDTrackPointCounter->GetYaxis()->SetTitle(
"Number of track points");
157 registerObject<TH1I>(
"PXDTrackPointCounter", hPXDTrackPointCounter);
164 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
165 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
166 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
167 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
169 auto ladderNumber =
id.getLadderNumber();
170 auto sensorNumber =
id.getSensorNumber();
171 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
172 auto tree =
new TTree(treename.c_str(), treename.c_str());
173 tree->Branch<
int>(
"signal", &
m_signal);
175 registerObject<TTree>(treename, tree);
185 auto hTotalHitsLayer1 =
new TH2F(
"hTotalHitsLayer1",
"Total number of hits from layer 1;#phi;z [cm]", 730, -M_PI, M_PI, 400,
187 auto hPassedHitsLayer1 =
new TH2F(
"hPassedHitsLayer1",
"Passed number of hits from layer 1;#phi;z [cm]", 730, -M_PI, M_PI, 400,
189 auto hTotalHitsLayer2 =
new TH2F(
"hTotalHitsLayer2",
"Total number of hits from layer 2;#phi;z [cm]", 128, 1.4, 2.5, 400,
191 auto hPassedHitsLayer2 =
new TH2F(
"hPassedHitsLayer2",
"Passed number of hits from layer 2;#phi;z [cm]", 128, 1.4, 2.5, 400,
193 registerObject<TH2F>(
"hTotalHitsLayer1", hTotalHitsLayer1);
194 registerObject<TH2F>(
"hPassedHitsLayer1", hPassedHitsLayer1);
195 registerObject<TH2F>(
"hTotalHitsLayer2", hTotalHitsLayer2);
196 registerObject<TH2F>(
"hPassedHitsLayer2", hPassedHitsLayer2);
199 auto treeD0Z0 =
new TTree(
"tree_d0z0",
"TTree of corrected d0 and z0");
202 registerObject<TTree>(
"tree_d0z0", treeD0Z0);
205 auto dbtree =
new TTree(
"dbtree",
"dbtree");
206 dbtree->Branch<
int>(
"run", &
m_run);
207 dbtree->Branch<
int>(
"exp", &
m_exp);
209 registerObject<TTree>(
"dbtree", dbtree);
212 auto tree =
new TTree(
"pxd",
"PXD 2-track events");
214 registerObject<TTree>(
"pxd", tree);
228 getObjectPtr<TTree>(
"dbtree")->Fill();
238 auto ip = ROOT::Math::XYZVector(beamSpotDB->getIPPosition());
245 auto vertex = pxd2TrackEvent.getVertex();
261 getObjectPtr<TTree>(
"pxd")->Fill();
270 auto d0p_1 =
event.getTrackP().d0p;
271 auto d0p_2 =
event.getTrackM().d0p;
272 auto z0p_1 =
event.getTrackP().z0p;
273 auto z0p_2 =
event.getTrackM().z0p;
278 getObjectPtr<TTree>(
"tree_d0z0")->Fill();
284 bool selected4Gain =
true;
285 bool selected4Eff =
true;
287 if (track.pt <
m_minPt) selected4Gain =
false;
296 auto lambda0 =
atan(track.tanLambda);
299 auto sinTheta0 = 1. /
sqrt(1. + pow(track.tanLambda, 2));
300 auto pBetaSinTheta3o2 = track.pt * 1.0 *
sqrt(sinTheta0);
304 for (
auto& trackCluster : track.trackClusters) {
305 bool selectedCluster =
true;
306 auto cluster = trackCluster.cluster;
307 auto intersection = trackCluster.intersection;
308 auto usedInTrack = trackCluster.usedInTrack;
311 if (!usedInTrack || intersection.chargeMPV <= 0)
312 selectedCluster =
false;
316 selectedCluster =
false;
318 if (cluster.pxdID <= 0) {
319 B2FATAL(
"Unexpected cluster module id : " << cluster.pxdID);
324 if (selected4Gain && selectedCluster) {
334 auto iSensor = gTools->getPXDSensorIndex(sensorID);
344 getObjectPtr<TH1I>(
"PXDClusterCounter")->Fill(binID);
348 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
349 getObjectPtr<TTree>(treename)->Fill();
355 auto axis = getObjectPtr<TH2F>(
"PXDClusterChargeRatio")->GetYaxis();
356 double maxY = axis->GetBinCenter(axis->GetNbins());
358 getObjectPtr<TH2F>(
"PXDClusterChargeRatio")->Fill(binID, TMath::Min(ratio, maxY));
364 auto x = intersection.x;
365 auto y = intersection.y;
366 auto phi = atan2(y, x);
367 auto z = intersection.z;
372 auto localPoint = Info.
pointToLocal(ROOT::Math::XYZVector(x, y, z));
375 auto iSensor = gTools->getPXDSensorIndex(sensorID);
385 if (cluster.pxdID < 2000) {
387 getObjectPtr<TH2F>(
"hTotalHitsLayer1")->Fill(phi, z);
389 getObjectPtr<TH2F>(
"hPassedHitsLayer1")->Fill(phi, z);
392 getObjectPtr<TH2F>(
"hTotalHitsLayer2")->Fill(phi, z);
394 getObjectPtr<TH2F>(
"hPassedHitsLayer2")->Fill(phi, z);
Calibration collector module base class.
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...
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 referecne 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 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.
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.
Struct to hold variables from a track which contains a vector of data type like TrackCluster.