Belle II Software development
PXDDQMBowingModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <pxd/modules/pxdDQM/PXDDQMBowingModule.h>
10
11#include <alignment/dbobjects/VXDAlignment.h>
12#include <analysis/dataobjects/ParticleList.h>
13#include <framework/database/DBObjPtr.h>
14#include <genfit/Track.h>
15#include <mdst/dataobjects/Track.h>
16#include <pxd/reconstruction/PXDRecoHit.h>
17#include <tracking/dataobjects/RecoTrack.h>
18#include <tracking/trackFitting/fitter/base/TrackFitter.h>
19#include <vxd/geometry/GeoCache.h>
20#include "TDirectory.h"
21
22
23using namespace Belle2;
24
25REG_MODULE(PXDDQMBowing);
26
28{
29 // Set module properties
30 setDescription(R"DOC(Create basic histograms for PXD bowing monitoring)DOC");
31
34
35 // Parameter definitions
36 addParam("particleList", m_particleListName, "Name of the particle list to which the module is applied", m_particleListName);
37 addParam("histogramDirectoryName", m_histogramDirectoryName, "Name of the directory where the histogram will be placed",
38 std::string("PXDBow"));
39
40 addParam("cutResU", m_cutResU, "Cut value on |res u| (upper limit)", 0.04);
41 addParam("cutP", m_cutP, "Cut on the track momentum (lower limit)", 1.0);
42 addParam("cutD0", m_cutD0, "Cut on |d0| (upper limit)", 0.1);
43 addParam("cutZ0", m_cutZ0, "Cut on |z0| (upper limit)", 0.1);
44
45 addParam("rangeV", m_rangeV, "Upper edge of the res v histogram symmetrical range", 0.1);
46 addParam("rangeS", m_rangeS, "Upper edge of the sagitta histogram symmetrical range", 0.1);
47 addParam("binsV", m_binsV, "Number of bins of the res v histogram", 100);
48 addParam("binsS", m_binsS, "Number of bins of the sagitta histogram", 100);
49}
50
52{
54 REG_HISTOGRAM;
55
57 m_recoTracks.isOptional();
59
61 DBObjPtr<VXDAlignment> alignment;
63 const std::vector<VxdID>& sensors = geometry.getListOfSensors();
64 for (const VxdID& aVxdID : sensors) {
65 VXD::SensorInfoBase info = geometry.getSensorInfo(aVxdID);
66 if (info.getType() != VXD::SensorInfoBase::PXD || aVxdID.getSensorNumber() != 1) continue;
67 const double sensor_length = info.getLength();
68 const double sensor_alpha = alignment->get(aVxdID, VXDAlignment::dAlpha);
69 m_dwAlignment[aVxdID] = sensor_alpha * sensor_length;
70 }
71}
72
74{
76 for (auto& h : m_hResV) if (h.second) h.second->Reset();
77 for (auto& h : m_hSagitta) if (h.second) h.second->Reset();
78
79}
80
82{
83 if (!m_recoTracks.isValid()) {
84 B2INFO("RecoTrack array is missing, no residuals");
85 return;
86 }
87 if (!m_ParticleList.isValid()) {
88 B2INFO("Particle array is missing, no residuals");
89 return;
90 }
91
93 auto nParticles = m_ParticleList->getListSize();
94 for (unsigned int iParticle = 0; iParticle < nParticles; ++iParticle) {
95 auto particle = m_ParticleList->getParticle(iParticle);
96 auto b2track = particle->getTrack();
97 if (!b2track) {
98 B2WARNING("No Track for particle.");
99 continue;
100 }
101
103 const TrackFitResult* fitResult = b2track->getTrackFitResultWithClosestMass(Const::pion);
104 const ROOT::Math::XYZVector& mom = fitResult->getMomentum();
105 const auto p = mom.R();
106 if (p < m_cutP) continue;
107 const Helix& helix = fitResult->getHelix();
108 const auto d0 = helix.getD0();
109 const auto z0 = helix.getZ0();
110 if (std::abs(d0) > m_cutD0 || std::abs(z0) > m_cutZ0) continue;
111
112 auto recoTrack = b2track->getRelatedTo<RecoTrack>();
113 if (!recoTrack) {
114 B2WARNING("No RecoTrack for Track");
115 continue;
116 }
117
119 auto hits = recoTrack->getSortedPXDHitList();
120 if (!std::any_of(hits.begin(), hits.end(),
121 [](const auto & hit) {
122 return hit->getSensorID().getSensorNumber() == 1;
123 })) continue;
124
126 auto noPXDTrack = recoTrack->getRelatedTo<RecoTrack>("SVDCDCRecoTracks");
127
129 const genfit::Track& track = RecoTrackGenfitAccess::getGenfitTrack(*recoTrack);
130 for (unsigned int i = 0; i < track.getNumPoints() - 1; ++i) {
131 if (!track.getPoint(i)->hasRawMeasurements()) continue;
132
133 const PXDRecoHit* hit = dynamic_cast<PXDRecoHit*>(track.getPoint(i)->getRawMeasurement(0));
134 if (!hit) continue;
135
136 const auto fitterInfo = track.getPoint(i)->getFitterInfo();
137 if (fitterInfo) {
138 const auto& vxdid = VxdID(hit->getPlaneId());
139 if (vxdid.getSensorNumber() != 1) continue;
140 const auto& plane = fitterInfo->getPlane();
141 bool biased = true;
142 const auto& state = fitterInfo->getFittedState(biased).getState();
143 const auto residual = fitterInfo->getResidual(0, biased).getState();
144
145 const double hitposU = state[3] + residual[0];
146 const double hitposV = state[4] + residual[1];
147
148 auto noPXDState = genfit::StateOnPlane(noPXDTrack->getMeasuredStateOnPlaneFromFirstHit());
149 noPXDState.extrapolateToPlane(plane);
150
151 const double noPXDhitPredU = noPXDState.getState()[3];
152 const double noPXDhitPredV = noPXDState.getState()[4];
153
154 const double noPXDhitPredVp = noPXDState.getState()[2];
155
156 const double residualU = hitposU - noPXDhitPredU;
157
158 if (std::abs(residualU) > m_cutResU) continue;
159 const double residualV = hitposV - noPXDhitPredV;
160 const double residualW = residualV / noPXDhitPredVp;
161 const double sagitta = residualW + m_dwAlignment[vxdid];
162
163 if (m_hResV[vxdid]) m_hResV[vxdid]->Fill(residualV);
164 if (m_hSagitta[vxdid] && hitposV < -2) m_hSagitta[vxdid]->Fill(sagitta);
165 }
166 }
167 }
168}
169
171{
172 TDirectory* oldDir = gDirectory;
173 if (m_histogramDirectoryName != "") {
174 oldDir->mkdir(m_histogramDirectoryName.c_str());
175 oldDir->cd(m_histogramDirectoryName.c_str());
176 }
177 const VXD::GeoCache& vxdGeometry(VXD::GeoCache::getInstance());
178 std::vector<VxdID> sensors = vxdGeometry.getListOfSensors();
179 for (VxdID& avxdid : sensors) {
180 const VXD::SensorInfoBase& info = vxdGeometry.getSensorInfo(avxdid);
181 if (info.getType() != VXD::SensorInfoBase::PXD
182 || avxdid.getSensorNumber() != 1) continue;
183
184 TString buff = (std::string)avxdid;
185 buff.ReplaceAll(".", "_");
186
187 m_hResV[avxdid] = new TH1F("resV_" + buff, "resV " + buff, m_binsV, -m_rangeV, m_rangeV);
188 m_hSagitta[avxdid] = new TH1F("sagitta_" + buff, "sagitta " + buff, m_binsS, -m_rangeS, m_rangeS);
189 }
190 oldDir->cd();
191}
192
Helix parameter class.
Definition Helix.h:48
static const ChargedStable pion
charged pion particle
Definition Const.h:661
Class for accessing objects in the database.
Definition DBObjPtr.h:21
HistoModule()
Constructor.
Definition HistoModule.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
void initialize() override final
initializes the needed store arrays and histograms
int m_binsS
number of bins for the histograms of the sagitta
int m_binsV
number of bins for the histograms of the v residuals
std::string m_particleListName
Name of the particle list to which the module is applied.
std::map< VxdID, TH1F * > m_hResV
histos for the residual of the PXD hits' v component for each PXD module
void defineHisto() override final
actually defines the histograms
std::map< VxdID, Double_t > m_dwAlignment
Bowing amplitude of the PXD modules inside the alignment.
void event() override final
Refits tracks without PXD hits and calculate the residuals for the PXD layers.
Double_t m_cutZ0
value fot the cut on absolute value of the track parameter z0
std::map< VxdID, TH1F * > m_hSagitta
histos of the sagitta for each PXD module
Double_t m_rangeS
range for the histos of the sagitta
std::string m_histogramDirectoryName
Name of the directory where the histogram will be placed.
PXDDQMBowingModule()
Constructor: Sets the description, the properties and the parameters of the module.
Double_t m_cutResU
value fot the cut on absolute value of the u residuals
Double_t m_rangeV
range for the histos of the v residuls
StoreArray< RecoTrack > m_recoTracks
store array of the recoTracks related to the particles selected with m_ParticleList
void beginRun() override final
Resets the histograms for each run and print ROI size in v.
StoreObjPtr< ParticleList > m_ParticleList
particle list on which run the module (need to be charged particles to have some results)
Double_t m_cutP
value fot the cut on the momentum of the particle
Double_t m_cutD0
value fot the cut on absolute value of the track parameter d0
PXDRecoHit - an extended form of PXDCluster containing geometry information.
Definition PXDRecoHit.h:53
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition RecoTrack.cc:404
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
std::vector< Belle2::RecoTrack::UsedPXDHit * > getSortedPXDHitList() const
Return a sorted list of pxd hits. Sorted by the sortingParameter.
Definition RecoTrack.h:464
Values of the result of a track fit with a given particle hypothesis.
Helix getHelix() const
Conversion to framework Helix (without covariance).
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
static const baseType dAlpha
Sensor/layer/ladder alignment in local alpha.
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
Definition GeoCache.h:38
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
Definition GeoCache.cc:59
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
Definition GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition GeoCache.cc:214
Base class to provide Sensor Information for PXD and SVD.
Class to uniquely identify a any structure of the PXD and SVD.
Definition VxdID.h:32
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Common code concerning the geometry representation of the detector.
Definition CreatorBase.h:25
Abstract base class for different kinds of events.