11 #include <pxd/modules/pxdDQM/PXDDQMEfficiencyNtupleSelftrackModule.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 "TMatrixDSym.h"
31 m_vxdGeometry(VXD::GeoCache::getInstance())
34 setDescription(
"Create basic histograms for PXD efficiency");
39 addParam(
"pxdClustersName", m_pxdClustersName,
"name of StoreArray with PXD cluster", std::string(
""));
40 addParam(
"recoTracksName", m_recoTracksName,
"name of StoreArray with RecoTracks", std::string(
""));
41 addParam(
"tracksName", m_tracksName,
"name of StoreArray with Tracks", std::string(
""));
42 addParam(
"ROIsName", m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
43 addParam(
"useAlignment", m_useAlignment,
"if true the alignment will be used",
true);
44 addParam(
"pCut", m_pcut,
"Set a cut on the track fit p-value (0=no cut)",
double(0));
45 addParam(
"minSVDHits", m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
46 addParam(
"momCut", m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
47 addParam(
"pTCut", m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(0));
48 addParam(
"maskedDistance", m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
54 auto dir = gDirectory;
75 m_file =
new TFile(
"test.root",
"recreate");
77 m_tuple =
new TNtuple(
"effcontrol",
"effcontrol",
78 "vxdid:u:v:p:pt:distu:distv:sigu:sigv:dist:inroi:clborder:cldead:matched:z0:d0:svdhits:charge:phi:costheta");
92 B2INFO(
"PXDClusters array is missing, no efficiencies");
96 B2INFO(
"RecoTrack array is missing, no efficiencies");
100 B2INFO(
"Track array is missing, no efficiencies");
106 if (!recoTrack.
size())
continue;
108 auto a_track = recoTrack[0];
110 if (!a_track->wasFitSuccessful())
continue;
112 if (a_track->getNumberOfSVDHits() <
m_minSVDHits)
continue;
118 trackstate = a_track->getMeasuredStateOnPlaneFromFirstHit();
119 if (trackstate.getMom().Mag() <
m_momCut)
continue;
120 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
124 B2ERROR(
"expect a track fit result for mass");
130 for (
VxdID& aVxdID : sensors) {
141 TVector3 intersec_buff =
getTrackInterSec(info, *a_track, isgood, sigu, sigv);
147 double u_fit = intersec_buff.X();
148 double v_fit = intersec_buff.Y();
150 int ucell_fit = info.getUCellID(intersec_buff.X());
151 int vcell_fit = info.getVCellID(intersec_buff.Y());
153 bool closeToBoarder =
false;
155 closeToBoarder =
true;
158 bool closeToDead =
false;
163 bool fitInsideROI =
false;
167 for (
auto& roit :
m_ROIs) {
168 if (aVxdID != roit.getSensorID()) {
172 if (ucell_fit < roit.getMaxUid()
173 && ucell_fit > roit.getMinUid()
174 && vcell_fit < roit.getMaxVid()
175 && vcell_fit > roit.getMinVid()) {
188 bool matched =
false;
189 if (bestcluster >= 0) {
194 TVector3 dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
195 du_clus = u_fit - u_clus;
196 dv_clus = v_fit - v_clus;
197 d_clus = dist_clus.Mag();
201 float fill[22] = {float((
int)aVxdID), float(u_fit), float(v_fit), float(trackstate.getMom().Mag()), float(trackstate.getMom().Pt()),
202 float(du_clus), float(dv_clus), float(sigu), float(sigv), float(d_clus),
203 float(fitInsideROI), float(closeToBoarder), float(closeToDead), float(matched),
204 float(ptr2->
getZ0()), float(ptr2->
getD0()), float(a_track->getNumberOfSVDHits()),
205 charge, float(trackstate.getMom().Phi()), float(trackstate.getMom().CosTheta())
217 double& du,
double& dv)
222 TVector3 intersec(99999999, 9999999, 0);
229 TVector3 zeroVec(0, 0, 0);
230 TVector3 uVec(1, 0, 0);
231 TVector3 vVec(0, 1, 0);
241 gfTrackState.extrapolateToPlane(sensorPlaneSptr);
243 B2WARNING(
"Fitting failed: " << gfException.getExcString());
247 B2WARNING(
"Fitting failed: for some reason");
256 B2DEBUG(1,
"Fitted momentum on the plane p = " << gfTrackState.getMom().Mag());
259 double tolerance = 0.0;
260 bool inside = pxdSensorInfo.
inside(intersec.X(), intersec.Y(), tolerance, tolerance);
263 TMatrixDSym covMatrix = gfTrackState.getCov();
266 du = std::sqrt(covMatrix(3, 3));
267 dv = std::sqrt(covMatrix(4, 4));
269 if (inside) isgood =
true;
279 double mindist = 999999999999;
297 TVector3 current(u, v, 0);
300 double dist = (intersection - current).Mag();
301 if (dist < mindist) {
314 if (u - checkDistance < 0 || u + checkDistance >= 250 ||
315 v - checkDistance < 0 || v + checkDistance >= 768) {
325 for (
int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
326 for (
int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {