9#include <pxd/modules/pxdClusterPositionCollector/PXDClusterPositionCollectorModule.h>
10#include <pxd/dataobjects/PXDDigit.h>
11#include <pxd/dataobjects/PXDTrueHit.h>
12#include <vxd/geometry/GeoCache.h>
13#include <pxd/reconstruction/PXDClusterPositionEstimator.h>
14#include <pxd/geometry/SensorInfo.h>
20#include <boost/format.hpp>
37 , m_clusterEta(0), m_positionOffsetU(0), m_positionOffsetV(0), m_sizeV(0), m_pitchV(0)
40 setDescription(
"Calibration collector module for PXD cluster position estimation");
54 string gridname = str(format(
"GridKind_%1%") %
m_clusterKind);
55 auto grid =
new TH2F(gridname.c_str(), gridname.c_str(),
m_binsU, -90.0, +90.0,
m_binsV, -90.0, +90.0);
56 registerObject<TH2F>(gridname, grid);
58 string pitchtreename =
"pitchtree";
59 auto ptree =
new TTree(pitchtreename.c_str(), pitchtreename.c_str());
61 ptree->Branch<
float>(
"PitchV", &
m_pitchV);
62 registerObject<TTree>(pitchtreename, ptree);
64 for (
auto uBin = 1; uBin <= grid->GetXaxis()->GetNbins(); uBin++) {
65 for (
auto vBin = 1; vBin <= grid->GetYaxis()->GetNbins(); vBin++) {
66 string treename = str(format(
"tree_%1%_%2%_%3%") %
m_clusterKind % uBin % vBin);
67 auto tree =
new TTree(treename.c_str(), treename.c_str());
73 tree->Branch<
int>(
"SizeV", &
m_sizeV);
74 registerObject<TTree>(treename, tree);
84 string gridname = str(format(
"GridKind_%1%") %
m_clusterKind);
85 auto grid = getObjectPtr<TH2F>(gridname);
90 if (cluster.getRelationsTo<
PXDTrueHit>().size() > 1) {
95 if (cluster.getSize() >= 1000) {
104 for (
auto& truehit : cluster.getRelationsTo<
PXDTrueHit>()) {
106 auto mom = truehit.getMomentum();
108 if (mom.Z() == 0 || mom.R() < 0.02)
continue;
110 double thetaU = TMath::ATan2(mom.X() / mom.Z(), 1.0) * TMath::RadToDeg();
111 double thetaV = TMath::ATan2(mom.Y() / mom.Z(), 1.0) * TMath::RadToDeg();
112 int uBin = grid->GetXaxis()->FindBin(thetaU);
113 int vBin = grid->GetYaxis()->FindBin(thetaV);
115 if (uBin < 1 || uBin >
m_binsU || vBin < 1 || vBin >
m_binsV)
continue;
118 grid->Fill(thetaU, thetaV);
120 VxdID sensorID = truehit.getSensorID();
124 set<PXD::Pixel> pixels;
125 for (
int i = 0; i < cluster.getSize(); i++) {
126 const PXDDigit*
const storeDigit = cluster.getRelationsTo<
PXDDigit>(
"PXDDigits")[i];
132 cluster.getVSize(), thetaU, thetaV);
134 cluster.getVStart(), cluster.getVSize(), thetaU, thetaV);
143 string treename = str(format(
"tree_%1%_%2%_%3%") %
m_clusterKind % uBin % vBin);
144 getObjectPtr<TTree>(treename)->Fill();
147 string pitchtreename =
"pitchtree";
148 if (getObjectPtr<TTree>(pitchtreename)->GetEntries() == 0) {
149 getObjectPtr<TTree>(pitchtreename)->Fill();
Calibration collector module base class.
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...
float m_clusterEta
Eta value of cluster.
void prepare() override final
Prepare.
float m_positionOffsetU
Position offset u of cluster.
int m_binsU
Number of bins for thetaU
std::string m_mirroredShapeName
Name of mirrored cluster shape.
int m_binsV
Number of bins for thetaV
std::string m_shapeName
Name of cluster shape.
StoreArray< PXDCluster > m_pxdCluster
< Required input for PXDCluster
float m_pitchV
Pitch in V.
void collect() override final
Collect.
float m_positionOffsetV
Position offset v of cluster.
int m_clusterKind
Collect data for Clusterkind
std::string m_storeClustersName
Name of the collection to use for PXDClusters.
PXDClusterPositionCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
static PXDClusterPositionEstimator & getInstance()
Main (and only) way to access the PXDClusterPositionEstimator.
const std::string getMirroredShortName(const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
Return the mirrored name for the pixel set.
float computeEta(const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
Return the normed charge ratio between head and tail pixels (size>=2) or the charge of the seed (size...
const std::string getShortName(const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
Return the name for the pixel set.
Class to represent one pixel, used in clustering for fast access.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
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.
double getVCellPosition(int vID) const
Return the position of a specific strip/pixel in v direction.
double getUCellPosition(int uID, int vID=-1) const
Return the position of a specific strip/pixel in u direction.
double getVPitch(double v=0) const
Return the pitch of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
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.