9#include <pxd/modules/pxdDQM/PXDDQMEfficiencyModule.h>
10#include <pxd/dataobjects/PXDCluster.h>
11#include <tracking/dataobjects/ROIid.h>
12#include <tracking/dataobjects/RecoTrack.h>
13#include <tracking/dataobjects/PXDIntercept.h>
15#include <pxd/reconstruction/PXDPixelMasker.h>
16#include <mdst/dataobjects/Track.h>
17#include <framework/gearbox/Const.h>
19#include <Math/Vector3D.h>
20#include "TDirectory.h"
21#include "TMatrixDSym.h"
44 addParam(
"ROIsName",
m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
47 std::string(
"PXDEFF"));
50 addParam(
"distCut",
m_distcut,
"max distance in [cm] for cluster to be counted to a track",
double(0.0500));
51 addParam(
"pCut",
m_pcut,
"Set a cut on the track p-value",
double(1e-20));
54 addParam(
"maskDeadPixels",
m_maskDeadPixels,
"Do not consider tracks going through known dead or hot pixels for the efficiency",
56 addParam(
"minSVDHits",
m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
57 addParam(
"momCut",
m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
58 addParam(
"pTCut",
m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(1));
59 addParam(
"cutBorders",
m_cutBorders,
"Do not use tracks near the borders of the sensor",
bool(
true));
60 addParam(
"maskedDistance",
m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
61 addParam(
"trackUFactorDistCut",
m_uFactor,
"Set a cut on u error of track (factor*err<dist), 0 disables",
double(2.0));
62 addParam(
"trackVFactorDistCut",
m_vFactor,
"Set a cut on v error of track (factor*err<dist), 0 disables",
double(2.0));
63 addParam(
"z0minCut",
m_z0minCut,
"Set a cut z0 minimum in cm (large negative value eg -9999 disables)",
double(-1));
64 addParam(
"z0maxCut",
m_z0maxCut,
"Set a cut z0 maximum in cm (large positive value eg 9999 disables)",
double(1));
65 addParam(
"d0Cut",
m_d0Cut,
"Set a cut abs(d0) in cm (large positive value eg 9999 disables)",
double(0.5));
66 addParam(
"verboseHistos",
m_verboseHistos,
"Add more verbose histograms for cuts (not for ereoc)",
bool(
false));
88 for (
auto& h :
m_h_p)
if (h.second) h.second->Reset();
89 for (
auto& h :
m_h_pt)
if (h.second) h.second->Reset();
90 for (
auto& h :
m_h_su)
if (h.second) h.second->Reset();
91 for (
auto& h :
m_h_sv)
if (h.second) h.second->Reset();
92 for (
auto& h :
m_h_p2)
if (h.second) h.second->Reset();
93 for (
auto& h :
m_h_pt2)
if (h.second) h.second->Reset();
94 for (
auto& h :
m_h_su2)
if (h.second) h.second->Reset();
95 for (
auto& h :
m_h_sv2)
if (h.second) h.second->Reset();
101 B2INFO(
"PXDClusters array is missing, no efficiencies");
105 B2INFO(
"RecoTrack array is missing, no efficiencies");
109 B2INFO(
"ROI array is missing but required hits in ROIs, aborting");
113 B2INFO(
"Intercept array is missing, no efficiencies");
121 if (!a_track.wasFitSuccessful())
continue;
123 if (a_track.getNumberOfSVDHits() <
m_minSVDHits)
continue;
126 if (!interceptList.
size())
continue;
128 const genfit::FitStatus* fitstatus = a_track.getTrackFitStatus();
129 if (fitstatus->getPVal() <
m_pcut)
continue;
131 genfit::MeasuredStateOnPlane trackstate;
132 trackstate = a_track.getMeasuredStateOnPlaneFromFirstHit();
133 if (trackstate.getMom().Mag() <
m_momCut)
continue;
134 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
139 B2ERROR(
"expect a track for fitted recotracks");
144 B2ERROR(
"expect a track fit result for mass");
152 for (
auto intercept : interceptList) {
153 auto const aVxdID = intercept.getSensorID();
164 if (
m_h_p[aVxdID])
m_h_p[aVxdID]->Fill(trackstate.getMom().Mag());
165 if (
m_h_pt[aVxdID])
m_h_pt[aVxdID]->Fill(trackstate.getMom().Pt());
172 double u_fit = intercept.getCoorU();
173 double v_fit = intercept.getCoorV();
176 int ucell_fit = info.getUCellID(u_fit);
177 int vcell_fit = info.getVCellID(v_fit);
190 bool fitInsideROI =
false;
191 for (
auto& roit :
m_ROIs) {
192 if (aVxdID != (roit.getSensorID()).getID()) {
196 if (ucell_fit < roit.getMaxUid()
197 && ucell_fit > roit.getMinUid()
198 && vcell_fit < roit.getMaxVid()
199 && vcell_fit > roit.getMinVid()) {
210 auto sensor_index =
revLUT[aVxdID];
216 if (bestcluster >= 0) {
221 ROOT::Math::XYZVector dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
226 if (
m_h_p2[aVxdID])
m_h_p2[aVxdID]->Fill(trackstate.getMom().Mag());
227 if (
m_h_pt2[aVxdID])
m_h_pt2[aVxdID]->Fill(trackstate.getMom().Pt());
241 TDirectory* oldDir = gDirectory;
247 std::vector<VxdID> sensors =
m_vxdGeometry.getListOfSensors();
248 std::sort(sensors.begin(), sensors.end());
249 int sensor_index = 0;
250 for (
VxdID& avxdid : sensors) {
254 revLUT[avxdid] = sensor_index++;
256 TString buff = (std::string)avxdid;
257 buff.ReplaceAll(
".",
"_");
259 int nu = info.getUCells();
260 int nv = info.getVCells();
263 m_h_track_hits[avxdid] =
new TH2F(
"track_hits_" + buff,
"tracks through sensor " + buff,
265 m_h_matched_cluster[avxdid] =
new TH2F(
"matched_cluster_" + buff,
"clusters matched to track intersections " + buff,
269 m_h_p[avxdid] =
new TH1F(
"p_" + buff,
"p " + buff, 100, 0, 10);
270 m_h_pt[avxdid] =
new TH1F(
"pt_" + buff,
"pt " + buff, 100, 0, 10);
271 m_h_su[avxdid] =
new TH1F(
"su_" + buff,
"su " + buff, 1000, 0, 1);
272 m_h_sv[avxdid] =
new TH1F(
"sv_" + buff,
"sv " + buff, 1000, 0, 1);
273 m_h_p2[avxdid] =
new TH1F(
"p2_" + buff,
"p2 " + buff, 100, 0, 10);
274 m_h_pt2[avxdid] =
new TH1F(
"pt2_" + buff,
"pt2 " + buff, 100, 0, 10);
275 m_h_su2[avxdid] =
new TH1F(
"su2_" + buff,
"su2 " + buff, 1000, 0, 1);
276 m_h_sv2[avxdid] =
new TH1F(
"sv2_" + buff,
"sv2 " + buff, 1000, 0, 1);
289 double mindist = 999999999999;
294 for (
int iclus = 0; iclus <
m_pxdclusters.getEntries(); iclus++) {
307 ROOT::Math::XYZVector current(u, v, 0);
310 double dist = (intersection - current).
R();
311 if (dist < mindist) {
324 if (u - checkDistance < 0 || u + checkDistance >= 250 ||
325 v - checkDistance < 0 || v + checkDistance >= 768) {
335 for (
int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
336 for (
int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
static const ChargedStable pion
charged pion particle
HistoModule()
Constructor.
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...
PXDDQMEfficiencyModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::map< VxdID, TH1F * > m_h_su
histograms of su
void initialize() override final
initializes the need store arrays, trees and histograms
std::map< VxdID, TH2F * > m_h_track_hits
histograms of track hits
double m_d0Cut
cut abs(d0) in cm (large positive value eg 9999 disables)
bool isCloseToBorder(int u, int v, int checkDistance)
is it close to the border
std::map< VxdID, TH1F * > m_h_su2
histrograms of su2
bool m_maskDeadPixels
mask dead pixels
double m_vFactor
factor for track-error on distcut comparison
double m_distcut
distance cut in cm!
unsigned int m_minSVDHits
Required hits in SVD strips for tracks.
StoreArray< PXDCluster > m_pxdclusters
store array of pxd clusters
bool m_verboseHistos
add some verbose histograms for cuts
std::string m_PXDInterceptListName
intercept list name
double m_momCut
Cut on fitted track momentum.
std::map< VxdID, int > revLUT
reverse lookup sensor id -> index in histogram
std::map< VxdID, TH1F * > m_h_sv2
histrograms of sv2
int findClosestCluster(const VxdID &vxdid, ROOT::Math::XYZVector intersection)
find the closest cluster
void defineHisto() override final
actually defines the trees and histograms
bool isDeadPixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
is a dead pixel close
double m_z0maxCut
cut z0 maximum in cm (large positive value eg 9999 disables)
double m_pcut
pValue-Cut for tracks
std::map< VxdID, TH1F * > m_h_pt2
histograms of pt2
bool m_requireROIs
Require tracks going through ROIs.
void event() override final
main function which fills trees and histograms
std::map< VxdID, TH1F * > m_h_sv
histograms of sv
std::string m_pxdClustersName
name of the store array of pxd clusters
std::string m_histogramDirectoryName
Where to save the histograms too.
TH1D * m_h_combined
combined histograms to workaround dqm glitch
double m_z0minCut
cut z0 minimum in cm (large negative value eg -9999 disables)
int m_maskedDistance
Distance inside which no dead pixel or module border is allowed.
bool m_cutBorders
cut borders
double m_pTCut
Cut on fitted track pT.
StoreArray< PXDIntercept > m_intercepts
store array of PXD Intercepts
std::string m_ROIsName
name of the store array of ROIs
std::map< VxdID, TH2F * > m_h_matched_cluster
histograms of matched clusters
std::map< VxdID, TH1F * > m_h_p2
histograms of p2
bool m_useAlignment
if true alignment will be used!
void beginRun() override final
begin run function which resets histograms
VXD::GeoCache & m_vxdGeometry
the geometry
StoreArray< RecoTrack > m_tracks
store array of tracks
double m_uFactor
factor for track-error on distcut comparison
std::map< VxdID, TH1F * > m_h_p
histograms of momenta
std::map< VxdID, TH1F * > m_h_pt
histograms of transverse momenta
std::string m_tracksName
name of the store array of tracks
StoreArray< ROIid > m_ROIs
store array of ROIs
PXDIntercept stores the U,V coordinates and uncertainties of the intersection of a track with an PXD ...
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Class that bundles various TrackFitResults.
const TrackFitResult * getTrackFitResultWithClosestMass(const Const::ChargedStable &requestedType) const
Return the track fit for the fit hypothesis with the closest mass.
Base class to provide Sensor Information for PXD and SVD.
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.
Namespace to provide code needed by both Vertex Detectors, PXD and SVD, and also testbeam telescopes.
Abstract base class for different kinds of events.