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");
41 setPropertyFlags(c_ParallelProcessingCertified);
43 addParam(
"clustersName", m_storeClustersName,
"Name of the collection to use for PXDClusters",
string(
""));
44 addParam(
"clusterKind", m_clusterKind,
"Collect data for Clusterkind",
int(0));
45 addParam(
"binsU", m_binsU,
"Number of bins for thetaU ",
int(18));
46 addParam(
"binsV", m_binsV,
"Number of bins for thetaV ",
int(18));
49 void PXDClusterPositionCollectorModule::prepare()
51 m_pxdCluster.isRequired();
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());
60 ptree->Branch<
int>(
"ClusterKind", &m_clusterKind);
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());
68 tree->Branch<
string>(
"ShapeName", &m_shapeName);
69 tree->Branch<
string>(
"MirroredShapeName", &m_mirroredShapeName);
70 tree->Branch<
float>(
"ClusterEta", &m_clusterEta);
71 tree->Branch<
float>(
"OffsetU", &m_positionOffsetU);
72 tree->Branch<
float>(
"OffsetV", &m_positionOffsetV);
73 tree->Branch<
int>(
"SizeV", &m_sizeV);
74 registerObject<TTree>(treename, tree);
79 void PXDClusterPositionCollectorModule::collect()
82 if (!m_pxdCluster)
return;
84 string gridname = str(format(
"GridKind_%1%") % m_clusterKind);
85 auto grid = getObjectPtr<TH2F>(gridname);
87 for (
auto& cluster : m_pxdCluster) {
90 if (cluster.getRelationsTo<
PXDTrueHit>().size() > 1) {
95 if (cluster.getSize() >= 1000) {
100 if (m_clusterKind != PXD::PXDClusterPositionEstimator::getInstance().getClusterkind(cluster)) {
104 for (
auto& truehit : cluster.getRelationsTo<
PXDTrueHit>()) {
106 auto mom = truehit.getMomentum();
108 if (mom[2] == 0 || mom.Mag() < 0.02)
continue;
110 double thetaU = TMath::ATan2(mom[0] / mom[2], 1.0) * 180.0 / M_PI;
111 double thetaV = TMath::ATan2(mom[1] / mom[2], 1.0) * 180.0 / M_PI;
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];
131 m_shapeName = PXD::PXDClusterPositionEstimator::getInstance().getShortName(pixels, cluster.getUStart(), cluster.getVStart(),
132 cluster.getVSize(), thetaU, thetaV);
133 m_mirroredShapeName = PXD::PXDClusterPositionEstimator::getInstance().getMirroredShortName(pixels, cluster.getUStart(),
134 cluster.getVStart(), cluster.getVSize(), thetaU, thetaV);
135 m_clusterEta = PXD::PXDClusterPositionEstimator::getInstance().computeEta(pixels, cluster.getVStart(), cluster.getVSize(), thetaU,
137 m_positionOffsetU = truehit.getU() - Info.
getUCellPosition(cluster.getUStart());
138 m_positionOffsetV = truehit.getV() - Info.
getVCellPosition(cluster.getVStart());
139 m_pitchV = Info.
getVPitch(truehit.getV());
140 m_sizeV = cluster.getVSize();
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.
Calibration collector module for PXD cluster position estimation.
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Class to represent one pixel, used in clustering for fast access.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
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.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.