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>
15#include <framework/geometry/VectorUtil.h>
17#include "TMatrixDSym.h"
18#include <Math/Vector3D.h>
32 m_vxdGeometry(VXD::GeoCache::getInstance())
43 addParam(
"ROIsName",
m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
45 addParam(
"pCut",
m_pcut,
"Set a cut on the track fit p-value (0=no cut)",
double(0));
46 addParam(
"minSVDHits",
m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
47 addParam(
"momCut",
m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
48 addParam(
"pTCut",
m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(0));
49 addParam(
"maskedDistance",
m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
55 auto dir = gDirectory;
76 m_file =
new TFile(
"test.root",
"recreate");
78 m_tuple =
new TNtuple(
"effcontrol",
"effcontrol",
79 "vxdid:u:v:p:pt:distu:distv:sigu:sigv:dist:inroi:clborder:cldead:matched:z0:d0:svdhits:charge:phi:costheta");
93 B2INFO(
"PXDClusters array is missing, no efficiencies");
97 B2INFO(
"RecoTrack array is missing, no efficiencies");
101 B2INFO(
"Track array is missing, no efficiencies");
107 if (!recoTrack.
size())
continue;
109 auto a_track = recoTrack[0];
111 if (!a_track->wasFitSuccessful())
continue;
113 if (a_track->getNumberOfSVDHits() <
m_minSVDHits)
continue;
115 const genfit::FitStatus* fitstatus = a_track->getTrackFitStatus();
116 if (fitstatus->getPVal() <
m_pcut)
continue;
118 genfit::MeasuredStateOnPlane trackstate;
119 trackstate = a_track->getMeasuredStateOnPlaneFromFirstHit();
120 if (trackstate.getMom().Mag() <
m_momCut)
continue;
121 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
125 B2ERROR(
"expect a track fit result for mass");
131 for (
VxdID& aVxdID : sensors) {
142 ROOT::Math::XYZVector intersec_buff =
getTrackInterSec(info, *a_track, isgood, sigu, sigv);
148 double u_fit = intersec_buff.X();
149 double v_fit = intersec_buff.Y();
151 int ucell_fit = info.getUCellID(intersec_buff.X());
152 int vcell_fit = info.getVCellID(intersec_buff.Y());
154 bool closeToBoarder =
false;
156 closeToBoarder =
true;
159 bool closeToDead =
false;
164 bool fitInsideROI =
false;
168 for (
auto& roit :
m_ROIs) {
169 if (aVxdID != roit.getSensorID()) {
173 if (ucell_fit < roit.getMaxUid()
174 && ucell_fit > roit.getMinUid()
175 && vcell_fit < roit.getMaxVid()
176 && vcell_fit > roit.getMinVid()) {
189 bool matched =
false;
190 if (bestcluster >= 0) {
195 ROOT::Math::XYZVector dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
196 du_clus = u_fit - u_clus;
197 dv_clus = v_fit - v_clus;
198 d_clus = dist_clus.R();
202 float fill[22] = {float((
int)aVxdID), float(u_fit), float(v_fit), float(trackstate.getMom().Mag()), float(trackstate.getMom().Pt()),
203 float(du_clus), float(dv_clus), float(sigu), float(sigv), float(d_clus),
204 float(fitInsideROI), float(closeToBoarder), float(closeToDead), float(matched),
205 float(ptr2->
getZ0()), float(ptr2->
getD0()), float(a_track->getNumberOfSVDHits()),
206 charge, float(trackstate.getMom().Phi()), float(trackstate.getMom().CosTheta())
218 bool& isgood,
double& du,
double& dv)
223 ROOT::Math::XYZVector intersec(99999999, 9999999, 0);
230 ROOT::Math::XYZVector zeroVec(0, 0, 0);
231 ROOT::Math::XYZVector uVec(1, 0, 0);
232 ROOT::Math::XYZVector vVec(0, 1, 0);
234 genfit::DetPlane* sensorPlane =
new genfit::DetPlane();
240 genfit::SharedPlanePtr sensorPlaneSptr(sensorPlane);
243 gfTrackState.extrapolateToPlane(sensorPlaneSptr);
244 }
catch (genfit::Exception& gfException) {
245 B2WARNING(
"Fitting failed: " << gfException.getExcString());
249 B2WARNING(
"Fitting failed: for some reason");
258 B2DEBUG(1,
"Fitted momentum on the plane p = " << gfTrackState.getMom().Mag());
261 double tolerance = 0.0;
262 bool inside = pxdSensorInfo.
inside(intersec.X(), intersec.Y(), tolerance, tolerance);
265 TMatrixDSym covMatrix = gfTrackState.getCov();
268 du = std::sqrt(covMatrix(3, 3));
269 dv = std::sqrt(covMatrix(4, 4));
271 if (inside) isgood =
true;
281 double mindist = 999999999999;
299 ROOT::Math::XYZVector current(u, v, 0);
302 double dist = (intersection - current).
R();
303 if (dist < mindist) {
316 if (u - checkDistance < 0 || u + checkDistance >= 250 ||
317 v - checkDistance < 0 || v + checkDistance >= 768) {
327 for (
int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
328 for (
int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
static const ChargedStable pion
charged pion particle
void setDescription(const std::string &description)
Sets the description of the module.
void initialize() override final
initializes the need store arrays, trees and histograms
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.
int findClosestCluster(const VxdID &vxdid, ROOT::Math::XYZVector intersection)
find the closest cluster
ROOT::Math::XYZVector getTrackInterSec(const VXD::SensorInfoBase &pxdSensorInfo, const RecoTrack &aTrack, bool &isgood, double &du, double &dv)
helper functions to do some of the calculations
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
PXDDQMEfficiencyNtupleSelftrackModule()
Constructor: Sets the description, the properties and the parameters of the module.
std::string m_tracksName
name of the store array of tracks
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.
ROOT::Math::XYZVector pointToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a point from global to local coordinates.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
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.
ROOT::Math::XYZVector vectorToGlobal(const ROOT::Math::XYZVector &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.
static constexpr auto XYZToTVector
Helper function to convert XYZVector to TVector3.
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.
Abstract base class for different kinds of events.