 |
Belle II Software
release-05-01-25
|
11 #include <pxd/modules/pxdDQM/PXDDQMEfficiencySelftrackModule.h>
12 #include <tracking/dataobjects/ROIid.h>
14 #include <pxd/reconstruction/PXDPixelMasker.h>
15 #include <mdst/dataobjects/Track.h>
16 #include <framework/gearbox/Const.h>
18 #include "TDirectory.h"
19 #include "TMatrixDSym.h"
34 setDescription(
"Create basic histograms for PXD efficiency");
37 setPropertyFlags(c_ParallelProcessingCertified);
40 addParam(
"pxdClustersName", m_pxdClustersName,
"name of StoreArray with PXD cluster", std::string(
""));
41 addParam(
"tracksName", m_tracksName,
"name of StoreArray with RecoTracks", std::string(
""));
42 addParam(
"ROIsName", m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
43 addParam(
"histogramDirectoryName", m_histogramDirectoryName,
"Name of the directory where histograms will be placed",
44 std::string(
"PXDEFF"));
45 addParam(
"binsU", m_u_bins,
"histogram bins in u direction",
int(4));
46 addParam(
"binsV", m_v_bins,
"histogram bins in v direction",
int(6));
47 addParam(
"distCut", m_distcut,
"max distance in [cm] for cluster to be counted to a track",
double(0.0500));
48 addParam(
"pCut", m_pcut,
"Set a cut on the track p-value",
double(1e-20));
49 addParam(
"requireROIs", m_requireROIs,
"require tracks to lie inside a ROI",
bool(
false));
50 addParam(
"useAlignment", m_useAlignment,
"if true the alignment will be used",
bool(
true));
51 addParam(
"maskDeadPixels", m_maskDeadPixels,
"Do not consider tracks going through known dead or hot pixels for the efficiency",
53 addParam(
"minSVDHits", m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
54 addParam(
"momCut", m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
55 addParam(
"pTCut", m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(1));
56 addParam(
"cutBorders", m_cutBorders,
"Do not use tracks near the borders of the sensor",
bool(
true));
57 addParam(
"maskedDistance", m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
58 addParam(
"trackUFactorDistCut", m_uFactor,
"Set a cut on u error of track (factor*err<dist), 0 disables",
double(2.0));
59 addParam(
"trackVFactorDistCut", m_vFactor,
"Set a cut on v error of track (factor*err<dist), 0 disables",
double(2.0));
60 addParam(
"z0minCut", m_z0minCut,
"Set a cut z0 minimum in cm (large negativ value eg -9999 disables)",
double(-1));
61 addParam(
"z0maxCut", m_z0maxCut,
"Set a cut z0 maximum in cm (large positiv value eg 9999 disables)",
double(1));
62 addParam(
"d0Cut", m_d0Cut,
"Set a cut abs(d0) in cm (and negativ value eg -9999 disables)",
double(0.5));
63 addParam(
"verboseHistos", m_verboseHistos,
"Add more verbose histograms for cuts (not for ereoc)",
bool(
false));
83 for (
auto& h :
m_h_p)
if (h.second) h.second->Reset();
84 for (
auto& h :
m_h_pt)
if (h.second) h.second->Reset();
85 for (
auto& h :
m_h_su)
if (h.second) h.second->Reset();
86 for (
auto& h :
m_h_sv)
if (h.second) h.second->Reset();
87 for (
auto& h :
m_h_p2)
if (h.second) h.second->Reset();
88 for (
auto& h :
m_h_pt2)
if (h.second) h.second->Reset();
89 for (
auto& h :
m_h_su2)
if (h.second) h.second->Reset();
90 for (
auto& h :
m_h_sv2)
if (h.second) h.second->Reset();
96 B2INFO(
"PXDClusters array is missing, no efficiencies");
100 B2INFO(
"RecoTrack array is missing, no efficiencies");
104 B2INFO(
"ROI array is missing but required hits in ROIs, aborting");
112 if (!a_track.wasFitSuccessful())
continue;
114 if (a_track.getNumberOfSVDHits() <
m_minSVDHits)
continue;
120 trackstate = a_track.getMeasuredStateOnPlaneFromFirstHit();
121 if (trackstate.getMom().Mag() <
m_momCut)
continue;
122 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
124 auto ptr = a_track.getRelated<
Track>(
"Tracks");
127 B2ERROR(
"expect a track for fitted recotracks");
130 auto ptr2 = ptr->getTrackFitResultWithClosestMass(
Const::pion);
132 B2ERROR(
"expect a track fit result for mass");
141 for (
VxdID& aVxdID : sensors) {
152 TVector3 intersec_buff =
getTrackInterSec(info, a_track, isgood, sigu, sigv);
158 if (
m_h_p[aVxdID])
m_h_p[aVxdID]->Fill(trackstate.getMom().Mag());
159 if (
m_h_pt[aVxdID])
m_h_pt[aVxdID]->Fill(trackstate.getMom().Pt());
166 double u_fit = intersec_buff.X();
167 double v_fit = intersec_buff.Y();
169 int ucell_fit = info.getUCellID(intersec_buff.X());
170 int vcell_fit = info.getVCellID(intersec_buff.Y());
183 bool fitInsideROI =
false;
184 for (
auto& roit :
m_ROIs) {
185 if (aVxdID != roit.getSensorID()) {
189 if (ucell_fit < roit.getMaxUid()
190 && ucell_fit > roit.getMinUid()
191 && vcell_fit < roit.getMaxVid()
192 && vcell_fit > roit.getMinVid()) {
207 if (bestcluster >= 0) {
212 TVector3 dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
216 if (
m_h_p2[aVxdID])
m_h_p2[aVxdID]->Fill(trackstate.getMom().Mag());
217 if (
m_h_pt2[aVxdID])
m_h_pt2[aVxdID]->Fill(trackstate.getMom().Pt());
232 double& du,
double& dv)
237 TVector3 intersec(99999999, 9999999, 0);
244 TVector3 zeroVec(0, 0, 0);
245 TVector3 uVec(1, 0, 0);
246 TVector3 vVec(0, 1, 0);
256 gfTrackState.extrapolateToPlane(sensorPlaneSptr);
258 B2WARNING(
"Fitting failed: " << gfException.getExcString());
262 B2WARNING(
"Fitting failed: for some reason");
271 B2DEBUG(1,
"Fitted momentum on the plane p = " << gfTrackState.getMom().Mag());
274 double tolerance = 0.0;
275 bool inside = pxdSensorInfo.
inside(intersec.X(), intersec.Y(), tolerance, tolerance);
278 TMatrixDSym covMatrix = gfTrackState.getCov();
281 du = std::sqrt(covMatrix(3, 3));
282 dv = std::sqrt(covMatrix(4, 4));
284 if (inside) isgood =
true;
293 TDirectory* oldDir = gDirectory;
300 for (
VxdID& avxdid : sensors) {
305 TString buff = (std::string)avxdid;
306 buff.ReplaceAll(
".",
"_");
308 int nu = info.getUCells();
309 int nv = info.getVCells();
312 m_h_track_hits[avxdid] =
new TH2F(
"track_hits_" + buff,
"tracks through sensor " + buff,
314 m_h_matched_cluster[avxdid] =
new TH2F(
"matched_cluster_" + buff,
"clusters matched to track intersections " + buff,
318 m_h_p[avxdid] =
new TH1F(
"p_" + buff,
"p " + buff, 100, 0, 10);
319 m_h_pt[avxdid] =
new TH1F(
"pt_" + buff,
"pt " + buff, 100, 0, 10);
320 m_h_su[avxdid] =
new TH1F(
"su_" + buff,
"su " + buff, 1000, 0, 1);
321 m_h_sv[avxdid] =
new TH1F(
"sv_" + buff,
"sv " + buff, 1000, 0, 1);
322 m_h_p2[avxdid] =
new TH1F(
"p2_" + buff,
"p2 " + buff, 100, 0, 10);
323 m_h_pt2[avxdid] =
new TH1F(
"pt2_" + buff,
"pt2 " + buff, 100, 0, 10);
324 m_h_su2[avxdid] =
new TH1F(
"su2_" + buff,
"su2 " + buff, 1000, 0, 1);
325 m_h_sv2[avxdid] =
new TH1F(
"sv2_" + buff,
"sv2 " + buff, 1000, 0, 1);
337 double mindist = 999999999999;
355 TVector3 current(u, v, 0);
358 double dist = (intersection - current).Mag();
359 if (dist < mindist) {
372 if (u - checkDistance < 0 || u + checkDistance >= 250 ||
373 v - checkDistance < 0 || v + checkDistance >= 768) {
383 for (
int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
384 for (
int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
Exception class for error handling in GENFIT (provides storage for diagnostic information)
double m_pTCut
Cut on fitted track pT.
bool isCloseToBorder(int u, int v, int checkDistance)
is it close to the border
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
std::string m_ROIsName
name of the store array of ROIs
Class to uniquely identify a any structure of the PXD and SVD.
std::map< VxdID, TH2F * > m_h_track_hits
histograms of track hits
TVector3 getTrackInterSec(const VXD::SensorInfoBase &pxdSensorInfo, const RecoTrack &aTrack, bool &isgood, double &du, double &dv)
helper functions to do some of the calculations
#StateOnPlane with additional covariance matrix.
std::map< VxdID, TH1F * > m_h_p2
histograms of p2
int findClosestCluster(const VxdID &vxdid, TVector3 intersection)
find the closest cluster
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
std::map< VxdID, TH1F * > m_h_sv2
histrograms of sv2
bool m_maskDeadPixels
mask dead pixels
bool m_requireROIs
Require tracks going through ROIs.
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane for the first hit in a fit useful for extrapolation of measureme...
bool m_verboseHistos
add some verbose histograms for cuts
double m_d0Cut
cut abs(d0) in cm (and negativ value eg -9999 disables)
std::string m_tracksName
name of the store array of tracks
baseType getLadderNumber() const
Get the ladder id.
VXD::GeoCache & m_vxdGeometry
the geometry
TVector3 vectorToGlobal(const TVector3 &local, bool reco=false) const
Convert a vector from local to global coordinates.
Base class to provide Sensor Information for PXD and SVD.
std::map< VxdID, TH1F * > m_h_sv
histograms of sv
bool m_useAlignment
if true alignment will be used!
void beginRun() override final
begin run function which resets histograms
StoreArray< PXDCluster > m_pxdclusters
store array of pxd clusters
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
int m_maskedDistance
Distance inside which no dead pixel or module border is allowed.
unsigned int m_minSVDHits
Required hits in SVD strips for tracks.
double m_momCut
Cut on fitted track momentum.
This is the Reconstruction Event-Data Model Track.
static const ChargedStable pion
charged pion particle
virtual double getPVal() const
Get the p value of the fit.
std::map< VxdID, TH1F * > m_h_su2
histrograms of su2
std::map< VxdID, TH1F * > m_h_pt2
histograms of pt2
Abstract base class for different kinds of events.
void event() override final
main function which fills trees and histograms
double m_pcut
pValue-Cut for tracks
double m_z0minCut
cut z0 minimum in cm (large negativ value eg -9999 disables)
bool isValid() const
Check wether the array was registered.
bool isDeadPixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
is a dead pixel close
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
double m_vFactor
factor for track-error on distcut comparison
baseType getSensorNumber() const
Get the sensor id.
std::map< VxdID, TH1F * > m_h_pt
histograms of transverse momenta
std::map< VxdID, TH2F * > m_h_matched_cluster
histograms of matched clusters
TVector3 pointToLocal(const TVector3 &global, bool reco=false) const
Convert a point from global to local coordinates.
void defineHisto() override final
actually defines the trees and histograms
Creates the basic histograms for PXD Efficiency DQM Simplified and adopted version of the testbeam px...
void initialize() override final
initializes the need store arrays, trees and histograms
std::string m_pxdClustersName
name of the store array of pxd clusters
bool m_cutBorders
cut borders
std::string m_histogramDirectoryName
Where to save the histograms too.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Class that bundles various TrackFitResults.
baseType getLayerNumber() const
Get the layer id.
double m_distcut
distance cut in cm!
std::map< VxdID, TH1F * > m_h_p
histograms of momenta
Class where important numbers and properties of a fit can be stored.
StoreArray< ROIid > m_ROIs
store array of ROIs
double m_z0maxCut
cut z0 maximum in cm (large positiv value eg 9999 disables)
double m_uFactor
factor for track-error on distcut comparison
int getEntries() const
Get the number of objects in the array.
bool inside(double u, double v, double uTolerance=DBL_EPSILON, double vTolerance=DBL_EPSILON) const
Check wether a given point is inside the active area.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
StoreArray< RecoTrack > m_tracks
store array of tracks
std::map< VxdID, TH1F * > m_h_su
histograms of su