9#include <pxd/modules/pxdClusterChargeCollector/PXDClusterChargeCollectorModule.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>
20#include <boost/format.hpp>
36 , m_signal(0), m_run(0), m_exp(0)
39 setDescription(
"Calibration collector module for cluster charge related calibrations.");
47 addParam(
"nBinsU",
m_nBinsU,
"Number of gain corrections per sensor along u side",
int(4));
48 addParam(
"nBinsV",
m_nBinsV,
"Number of gain corrections per sensor along v side",
int(6));
49 addParam(
"chargePayloadName",
m_chargeName,
"Payload name for Cluster Charge to be read from DB",
string(
""));
50 addParam(
"gainPayloadName",
m_gainName,
"Payload name for Gain to be read from DB",
string(
""));
53 "Flag to use track matched clusters (=1) and apply theta angle projection to cluster charge (=2)",
int(0));
55 addParam(
"relationCheck",
m_relationCheck,
"Flag to check relations between PXDClusters and PXDClustersFromTracks",
bool(
false));
63 std::string storeClustersName2;
65 "PXDClustersFromTracks" :
"PXDClusters";
79 B2WARNING(
"Number of bins along u side incremented from 0->1");
84 B2WARNING(
"Number of bins along v side incremented from 0->1");
95 auto hPXDClusterCounter =
new TH1I(
"hPXDClusterCounter",
"Number of clusters found in data sample",
98 hPXDClusterCounter->GetXaxis()->SetTitle(
"bin id");
99 hPXDClusterCounter->GetYaxis()->SetTitle(
"Number of clusters");
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());
110 registerObject<TH1I>(
"PXDClusterCounter", hPXDClusterCounter);
112 auto hPXDClusterCharge =
new TH2I(
"hPXDClusterCharge",
"Charge of clusters found in data sample",
116 hPXDClusterCharge->GetXaxis()->SetTitle(
"bin id");
117 hPXDClusterCharge->GetYaxis()->SetTitle(
"Cluster charge [ADU]");
118 registerObject<TH2I>(
"PXDClusterCharge", hPXDClusterCharge);
125 for (
int iSensor = 0; iSensor < nPXDSensors; iSensor++) {
126 for (
int uBin = 0; uBin <
m_nBinsU; uBin++) {
127 for (
int vBin = 0; vBin <
m_nBinsV; vBin++) {
128 VxdID id = gTools->getSensorIDFromPXDIndex(iSensor);
130 auto ladderNumber =
id.getLadderNumber();
131 auto sensorNumber =
id.getSensorNumber();
132 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
133 auto tree =
new TTree(treename.c_str(), treename.c_str());
134 tree->Branch<
int>(
"signal", &
m_signal);
135 registerObject<TTree>(treename, tree);
140 auto dbtree =
new TTree(
"dbtree",
"dbtree");
141 dbtree->Branch<
int>(
"run", &
m_run);
142 dbtree->Branch<
int>(
"exp", &
m_exp);
145 registerObject<TTree>(
"dbtree", dbtree);
164 getObjectPtr<TTree>(
"dbtree")->Fill();
180 if (!relPXDClusters.
size())
continue;
183 if (!relPXDClusters.
size())
continue;
186 double correction = 1.0;
189 if (!mcParticlesPXD.
size())
continue;
191 correction = sin(mcParticlesPXD[0]->getMomentum().Theta());
197 VxdID sensorID = cluster.getSensorID();
201 auto iSensor = gTools->getPXDSensorIndex(sensorID);
207 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
212 getObjectPtr<TTree>(treename)->Fill();
217 cluster.getCharge()*correction);
230 if (!recoTrack.
size())
continue;
234 double correction = 1.0;
237 for (
auto& cluster : pxdClustersTrack) {
241 if (!relPXDClusters.
size())
continue;
243 B2WARNING(
"Relation check for data only works when clustersName is set to PXDClustersFromTracks");
250 VxdID sensorID = cluster.getSensorID();
254 auto iSensor = gTools->getPXDSensorIndex(sensorID);
260 string treename = str(format(
"tree_%1%_%2%_%3%_%4%_%5%") % layerNumber % ladderNumber % sensorNumber % uBin % vBin);
265 getObjectPtr<TTree>(treename)->Fill();
270 cluster.getCharge()*correction);
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...
int m_matchTrack
Flag to use track matched clusters (=1) and apply theta angle projection to cluster charge (=2)
void prepare() override final
Prepare.
std::string m_storeRecoTracksName
Name of the collection to use for RecoTracks.
int m_nBinsV
Number of corrections per sensor along v side.
PXDClusterChargeMapPar m_chargeMap
ChargeMap to be stored in dbtree.
int m_signal
Cluster charge in ADU.
int m_minClusterSize
Minimum cluster size cut.
std::string m_gainName
Payload name for Gain to be read from DB.
std::string m_storeMCParticlesName
Name of the collection to use for MCParticles.
PXDGainMapPar m_gainMap
GainMap to be stored in dbtree.
int m_nBinsU
Number of corrections per sensor along u side.
bool m_mcSamples
Flag to deal with MC samples.
void collect() override final
Collect.
std::string m_chargeName
Payload name for Cluster Charge to be read from DB.
StoreObjPtr< EventMetaData > m_evtMetaData
Required input EventMetaData.
StoreArray< Track > m_tracks
Required input Tracks.
int m_exp
Experiment number to be stored in dbtree.
bool m_relationCheck
Flag to check relations between PXDClusters and PXDClustersFromTracks.
std::string m_storeClustersName
Name of the collection to use for PXDClusters.
int m_maxClusterSize
Maximum cluster size cut.
StoreArray< PXDCluster > m_pxdClusters
Required input PXDClusters
StoreArray< RecoTrack > m_recoTracks
Required input RecoTracks.
int m_minClusterCharge
Minimum cluster charge cut
StoreArray< MCParticle > m_mcParticles
Optional input MCParticles
void startRun() override final
Start run.
int m_run
Run number to be stored in dbtree.
PXDClusterChargeCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
bool m_fillChargeHistogram
Flag to fill cluster charge histograms.
The payload class for PXD cluster charge calibrations.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
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...
This is the Reconstruction Event-Data Model Track.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
Accessor to arrays stored in the data store.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
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.
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.
Abstract base class for different kinds of events.