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>
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());
121 auto hPXDTrackClusterCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackClusterCounter");
122 hPXDTrackClusterCounter->SetTitle(
"Number of track clusters");
123 hPXDTrackClusterCounter->GetYaxis()->SetTitle(
"Number of track clusters");
129 auto hPXDTrackPointCounter = (TH1I*)hPXDClusterCounter->Clone(
"hPXDTrackPointCounter");
130 hPXDTrackPointCounter->SetTitle(
"Number of track points");
131 hPXDTrackPointCounter->GetYaxis()->SetTitle(
"Number of track points");
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");
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");
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);
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,
185 auto treeD0Z0 =
new TTree(
"tree_d0z0",
"TTree of delta d0 (z0) over sqrt(2)");
191 auto dbtree =
new TTree(
"dbtree",
"dbtree");
192 dbtree->Branch<
int>(
"run", &
m_run);
193 dbtree->Branch<
int>(
"exp", &
m_exp);
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());
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 <<
").");
339 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
347 double maxY = axis->GetBinCenter(axis->GetNbins());
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);
365 auto uID = Info.getUCellID(localPoint.X());
366 auto vID = Info.getVCellID(localPoint.Y());
386 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()
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
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< 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 the fit hypothesis with the closest mass.
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.
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.
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.