9#include <pxd/modules/pxdPerformanceVariablesCollector/PXDPerformanceVariablesCollectorModule.h>
11#include <framework/database/DBObjPtr.h>
12#include <analysis/dataobjects/ParticleList.h>
13#include <mdst/dbobjects/BeamSpot.h>
14#include <mdst/dataobjects/Track.h>
15#include <tracking/dataobjects/RecoTrack.h>
21#include <boost/format.hpp>
38 , m_selected4Eff(false)
39 , m_deltaD0oSqrt2(0.0), m_deltaZ0oSqrt2(0.0)
40 , m_signal(0), m_estimated(0.0)
50 addParam(
"nBinsU",
m_nBinsU,
"Number of gain corrections per sensor along u side",
int(4));
51 addParam(
"nBinsV",
m_nBinsV,
"Number of gain corrections per sensor along v side",
int(6));
52 addParam(
"gainPayloadName",
m_gainName,
"Payload name for Gain to be read from DB",
string(
""));
54 "Flag to use cluster position rather than track point to group pixels for gain calibration.",
bool(
false));
56 "Flag to fill Ratio (cluster charge to the expected MPV) histograms",
bool(
true));
57 addParam(
"fillChargeTree",
m_fillChargeTree,
"Flag to fill cluster charge with the estimated MPV to TTree",
bool(
false));
58 addParam(
"maskedDistance",
m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
62 std::string(
"e+:gain"));
64 std::string(
"vpho:eff"));
65 addParam(
"PList4ResName",
m_PList4ResName,
"Name of the particle list for resolution study", std::string(
"vpho:res"));
73 B2WARNING(
"Number of bins along u side incremented from 0->1");
78 B2WARNING(
"Number of bins along v side incremented from 0->1");
89 auto hPXDClusterCounter =
new TH1I(
"hPXDClusterCounter",
"Number of clusters found in data sample",
92 hPXDClusterCounter->GetXaxis()->SetTitle(
"bin id");
93 hPXDClusterCounter->GetYaxis()->SetTitle(
"Number of clusters");
94 auto hPXDClusterChargeRatio =
new TH2F(
"hPXDClusterChargeRatio",
"Charge ratio of clusters found in data sample",
98 hPXDClusterChargeRatio->GetXaxis()->SetTitle(
"bin id");
99 hPXDClusterChargeRatio->GetYaxis()->SetTitle(
"Cluster charge ratio (relative to expected MPV)");
100 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
101 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
102 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
103 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
104 string sensorDescr = id;
106 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
109 str(format(
"%1%_%2%_%3%") % sensorDescr % uBin % vBin).c_str());
114 registerObject<TH1I>(
"PXDClusterCounter", hPXDClusterCounter);
116 registerObject<TH2F>(
"PXDClusterChargeRatio", hPXDClusterChargeRatio);
121 auto hPXDTrackClusterCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackClusterCounter");
122 hPXDTrackClusterCounter->SetTitle(
"Number of track clusters");
123 hPXDTrackClusterCounter->GetYaxis()->SetTitle(
"Number of track clusters");
124 registerObject<TH1I>(
"PXDTrackClusterCounter", hPXDTrackClusterCounter);
129 auto hPXDTrackPointCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackPointCounter");
130 hPXDTrackPointCounter->SetTitle(
"Number of track points");
131 hPXDTrackPointCounter->GetYaxis()->SetTitle(
"Number of track points");
132 registerObject<TH1I>(
"PXDTrackPointCounter", hPXDTrackPointCounter);
137 auto hPXDSelTrackClusterCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDSelTrackClusterCounter");
138 hPXDSelTrackClusterCounter->SetTitle(
"Number of selected track clusters (the same selectrion as for PXDSelTrackPointCounter)");
139 hPXDSelTrackClusterCounter->GetYaxis()->SetTitle(
"Number of track clusters");
140 registerObject<TH1I>(
"PXDSelTrackClusterCounter", hPXDSelTrackClusterCounter);
145 auto hPXDSelTrackPointCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDSelTrackPointCounter");
146 hPXDSelTrackPointCounter->SetTitle(
"Number of selected track points excluding hot/dead regions");
147 hPXDSelTrackPointCounter->GetYaxis()->SetTitle(
"Number of track points");
148 registerObject<TH1I>(
"PXDSelTrackPointCounter", hPXDSelTrackPointCounter);
155 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
156 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
157 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
158 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
160 auto ladderNumber =
id.getLadderNumber();
161 auto sensorNumber =
id.getSensorNumber();
162 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
163 auto tree =
new TTree(treename.c_str(), treename.c_str());
164 tree->Branch<
int>(
"signal", &
m_signal);
166 registerObject<TTree>(treename, tree);
171 auto hTotalHitsLayer1 =
new TH2F(
"hTotalHitsLayer1",
"Total number of hits from layer 1;#phi;z [cm]", 720, -M_PI, M_PI, 400,
173 auto hPassedHitsLayer1 =
new TH2F(
"hPassedHitsLayer1",
"Passed number of hits from layer 1;#phi;z [cm]", 720, -M_PI, M_PI, 400,
175 auto hTotalHitsLayer2 =
new TH2F(
"hTotalHitsLayer2",
"Total number of hits from layer 2;#phi;z [cm]", 720, -M_PI, M_PI, 400,
177 auto hPassedHitsLayer2 =
new TH2F(
"hPassedHitsLayer2",
"Passed number of hits from layer 2;#phi;z [cm]", 720, -M_PI, M_PI, 400,
179 registerObject<TH2F>(
"hTotalHitsLayer1", hTotalHitsLayer1);
180 registerObject<TH2F>(
"hPassedHitsLayer1", hPassedHitsLayer1);
181 registerObject<TH2F>(
"hTotalHitsLayer2", hTotalHitsLayer2);
182 registerObject<TH2F>(
"hPassedHitsLayer2", hPassedHitsLayer2);
185 auto treeD0Z0 =
new TTree(
"tree_d0z0",
"TTree of delta d0 (z0) over sqrt(2)");
188 registerObject<TTree>(
"tree_d0z0", treeD0Z0);
191 auto dbtree =
new TTree(
"dbtree",
"dbtree");
192 dbtree->Branch<
int>(
"run", &
m_run);
193 dbtree->Branch<
int>(
"exp", &
m_exp);
195 registerObject<TTree>(
"dbtree", dbtree);
209 getObjectPtr<TTree>(
"dbtree")->Fill();
217 if (particles4Eff.
isValid() && particles4Eff->getListSize() == 1)
219 const Particle* vpho4eff = particles4Eff->getParticle(0);
227 if (!particles.isValid() || particles->getListSize() < 1)
230 for (
auto const& particle : *particles) {
231 const Track* trackPtr = particle.getTrack();
232 auto mass = particle.getMass();
233 if (!trackPtr)
return;
235 if (!recoTrackPtr)
return;
237 for (
auto const& pxdIntercept : pxdIntercepts) {
240 if (!trackCluster.
setValues(pxdIntercept,
"",
"PXDClustersFromTracks", mass))
243 auto const& cluster = trackCluster.
cluster;
245 auto const& usedInTrack = trackCluster.
usedInTrack;
252 if (particle.isCopyOf(daughter))
259 if (!usedInTrack || !intersection.inside || intersection.chargeMPV <= 0)
274 if (!particles.isValid() || particles->getListSize() != 1)
277 const Particle* mother = particles->getParticle(0);
284 auto ip = ROOT::Math::XYZVector(beamSpotDB->getIPPosition());
305 getObjectPtr<TTree>(
"tree_d0z0")->Fill();
310 auto cluster = trackCluster.
cluster;
317 int uBin(-1), vBin(-1);
328 B2ERROR(
"On module " << sensorID
329 <<
": Failed to get bin ID for the track cluster at (u,v) = (" << cluster.posU <<
"," << cluster.posV
330 <<
") and (uBin, vBin) = (" << uBin <<
"," << vBin <<
").");
335 getObjectPtr<TH1I>(
"PXDClusterCounter")->Fill(binID);
339 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
340 getObjectPtr<TTree>(treename)->Fill();
346 auto axis = getObjectPtr<TH2F>(
"PXDClusterChargeRatio")->GetYaxis();
347 double maxY = axis->GetBinCenter(axis->GetNbins());
349 getObjectPtr<TH2F>(
"PXDClusterChargeRatio")->Fill(binID, TMath::Min(ratio, maxY));
355 auto const& cluster = trackCluster.
cluster;
357 auto const& usedInTrack = trackCluster.
usedInTrack;
359 auto phi = atan2(tPoint.y, tPoint.x);
364 auto localPoint = Info.
pointToLocal(ROOT::Math::XYZVector(tPoint.x, tPoint.y, tPoint.z),
true);
375 getObjectPtr<TH1I>(
"PXDTrackPointCounter")->Fill(binID);
377 getObjectPtr<TH1I>(
"PXDTrackClusterCounter")->Fill(binID);
380 getObjectPtr<TH1I>(
"PXDSelTrackPointCounter")->Fill(binID);
382 getObjectPtr<TH1I>(
"PXDSelTrackClusterCounter")->Fill(binID);
386 if (cluster.pxdID < 2000) {
388 getObjectPtr<TH2F>(
"hTotalHitsLayer1")->Fill(phi, z);
390 getObjectPtr<TH2F>(
"hPassedHitsLayer1")->Fill(phi, z);
393 getObjectPtr<TH2F>(
"hTotalHitsLayer2")->Fill(phi, z);
395 getObjectPtr<TH2F>(
"hPassedHitsLayer2")->Fill(phi, z);
Calibration collector module base class.
static const ChargedStable pion
charged pion particle
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...
The payload class for PXD gain corrections.
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
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...
Class to store reconstructed particles.
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
std::vector< Belle2::Particle * > getDaughters() const
Returns a vector of pointers to daughter particles.
const Particle * getDaughter(unsigned i) const
Returns a pointer to the i-th daughter particle.
This is the Reconstruction Event-Data Model Track.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
Values of the result of a track fit with a given particle hypothesis.
Class that bundles various TrackFitResults.
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for a fit hypothesis with the closest mass.
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 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.
float d0p
Corrected impact parameter in r-phi.
void setTrackVariables(const TrackFitResult *tfrPtr, const ROOT::Math::XYZVector &ip)
update track level variables from TrackFitResult
float z0p
Corrected impact parameter in z.
Struct to hold variables for track clusters.
bool usedInTrack
True if the cluster is used in tracking.
RecoTrack * setValues(const PXDIntercept &pxdIntercept, const std::string &recoTracksName="", const std::string &pxdTrackClustersName="PXDClustersFromTracks", const double &mass=Const::electronMass)
Update values from a PXDIntercept.
Cluster_t cluster
Cluster associated to the track.
TrackPoint_t intersection
The track-module intersection.