9 #include <pxd/modules/pxdDQM/PXDDQMEfficiencyNtupleSelftrackModule.h>
10 #include <tracking/dataobjects/ROIid.h>
12 #include <pxd/reconstruction/PXDPixelMasker.h>
13 #include <mdst/dataobjects/Track.h>
14 #include <framework/gearbox/Const.h>
16 #include "TMatrixDSym.h"
29 m_vxdGeometry(VXD::GeoCache::getInstance())
32 setDescription(
"Create basic histograms for PXD efficiency");
37 addParam(
"pxdClustersName", m_pxdClustersName,
"name of StoreArray with PXD cluster", std::string(
""));
38 addParam(
"recoTracksName", m_recoTracksName,
"name of StoreArray with RecoTracks", std::string(
""));
39 addParam(
"tracksName", m_tracksName,
"name of StoreArray with Tracks", std::string(
""));
40 addParam(
"ROIsName", m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
41 addParam(
"useAlignment", m_useAlignment,
"if true the alignment will be used",
true);
42 addParam(
"pCut", m_pcut,
"Set a cut on the track fit p-value (0=no cut)",
double(0));
43 addParam(
"minSVDHits", m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
44 addParam(
"momCut", m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
45 addParam(
"pTCut", m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(0));
46 addParam(
"maskedDistance", m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
52 auto dir = gDirectory;
73 m_file =
new TFile(
"test.root",
"recreate");
75 m_tuple =
new TNtuple(
"effcontrol",
"effcontrol",
76 "vxdid:u:v:p:pt:distu:distv:sigu:sigv:dist:inroi:clborder:cldead:matched:z0:d0:svdhits:charge:phi:costheta");
90 B2INFO(
"PXDClusters array is missing, no efficiencies");
94 B2INFO(
"RecoTrack array is missing, no efficiencies");
98 B2INFO(
"Track array is missing, no efficiencies");
104 if (!recoTrack.
size())
continue;
106 auto a_track = recoTrack[0];
108 if (!a_track->wasFitSuccessful())
continue;
110 if (a_track->getNumberOfSVDHits() <
m_minSVDHits)
continue;
116 trackstate = a_track->getMeasuredStateOnPlaneFromFirstHit();
117 if (trackstate.getMom().Mag() <
m_momCut)
continue;
118 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
122 B2ERROR(
"expect a track fit result for mass");
128 for (
VxdID& aVxdID : sensors) {
139 TVector3 intersec_buff =
getTrackInterSec(info, *a_track, isgood, sigu, sigv);
145 double u_fit = intersec_buff.X();
146 double v_fit = intersec_buff.Y();
148 int ucell_fit = info.getUCellID(intersec_buff.X());
149 int vcell_fit = info.getVCellID(intersec_buff.Y());
151 bool closeToBoarder =
false;
153 closeToBoarder =
true;
156 bool closeToDead =
false;
161 bool fitInsideROI =
false;
165 for (
auto& roit :
m_ROIs) {
166 if (aVxdID != roit.getSensorID()) {
170 if (ucell_fit < roit.getMaxUid()
171 && ucell_fit > roit.getMinUid()
172 && vcell_fit < roit.getMaxVid()
173 && vcell_fit > roit.getMinVid()) {
186 bool matched =
false;
187 if (bestcluster >= 0) {
192 TVector3 dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
193 du_clus = u_fit - u_clus;
194 dv_clus = v_fit - v_clus;
195 d_clus = dist_clus.Mag();
199 float fill[22] = {float((
int)aVxdID), float(u_fit), float(v_fit), float(trackstate.getMom().Mag()), float(trackstate.getMom().Pt()),
200 float(du_clus), float(dv_clus), float(sigu), float(sigv), float(d_clus),
201 float(fitInsideROI), float(closeToBoarder), float(closeToDead), float(matched),
202 float(ptr2->
getZ0()), float(ptr2->
getD0()), float(a_track->getNumberOfSVDHits()),
203 charge, float(trackstate.getMom().Phi()), float(trackstate.getMom().CosTheta())
215 double& du,
double& dv)
220 TVector3 intersec(99999999, 9999999, 0);
227 TVector3 zeroVec(0, 0, 0);
228 TVector3 uVec(1, 0, 0);
229 TVector3 vVec(0, 1, 0);
239 gfTrackState.extrapolateToPlane(sensorPlaneSptr);
241 B2WARNING(
"Fitting failed: " << gfException.getExcString());
245 B2WARNING(
"Fitting failed: for some reason");
254 B2DEBUG(1,
"Fitted momentum on the plane p = " << gfTrackState.getMom().Mag());
257 double tolerance = 0.0;
258 bool inside = pxdSensorInfo.
inside(intersec.X(), intersec.Y(), tolerance, tolerance);
261 TMatrixDSym covMatrix = gfTrackState.getCov();
264 du = std::sqrt(covMatrix(3, 3));
265 dv = std::sqrt(covMatrix(4, 4));
267 if (inside) isgood =
true;
277 double mindist = 999999999999;
295 TVector3 current(u, v, 0);
298 double dist = (intersection - current).Mag();
299 if (dist < mindist) {
312 if (u - checkDistance < 0 || u + checkDistance >= 250 ||
313 v - checkDistance < 0 || v + checkDistance >= 768) {
323 for (
int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
324 for (
int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
static const ChargedStable pion
charged pion particle
Creates Ntuples for PXD Efficiency analysis.
void initialize() override final
initializes the need store arrays, trees and histograms
TVector3 getTrackInterSec(const VXD::SensorInfoBase &pxdSensorInfo, const RecoTrack &aTrack, bool &isgood, double &du, double &dv)
helper functions to do some of the calculations
bool isCloseToBorder(int u, int v, int checkDistance)
is it close to the border
unsigned int m_minSVDHits
Required hits in SVD strips for tracks.
StoreArray< PXDCluster > m_pxdclusters
store array of pxd clusters
double m_momCut
Cut on fitted track momentum.
bool isDeadPixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
is a dead pixel close
double m_pcut
pValue-Cut for tracks
void terminate() override final
terminate , save tuple to file if needed
void event() override final
main function which fills trees and histograms
std::string m_pxdClustersName
name of the store array of pxd clusters
StoreArray< Track > m_tracks
store array of tracks
std::string m_recoTracksName
name of the store array of recotracks
TFile * m_file
pointer to opened file
int m_maskedDistance
Distance inside which no dead pixel or module border is allowed.
double m_pTCut
Cut on fitted track pT.
std::string m_ROIsName
name of the store array of ROIs
StoreArray< RecoTrack > m_recoTracks
store array of reco tracks
bool m_useAlignment
if true alignment will be used!
VXD::GeoCache & m_vxdGeometry
the geometry
TNtuple * m_tuple
pointer to opened tuple
std::string m_tracksName
name of the store array of tracks
int findClosestCluster(const VxdID &vxdid, TVector3 intersection)
find the closest cluster
StoreArray< ROIid > m_ROIs
store array of ROIs
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
This is the Reconstruction Event-Data Model Track.
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...
Class for type safe access to objects that are referred to in relations.
size_t size() const
Get number of relations.
bool isOptional(const std::string &name="")
Tell the DataStore about an optional input.
bool isValid() const
Check wether the array was registered.
int getEntries() const
Get the number of objects in the array.
Values of the result of a track fit with a given particle hypothesis.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Base class to provide Sensor Information for PXD and SVD.
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.
TVector3 pointToLocal(const TVector3 &global, bool reco=false) const
Convert a point from global to local coordinates.
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
TVector3 vectorToGlobal(const TVector3 &local, bool reco=false) const
Convert a vector from local to global coordinates.
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.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Class where important numbers and properties of a fit can be stored.
virtual double getPVal() const
Get the p value of the fit.
#StateOnPlane with additional covariance matrix.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.