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"
30 m_vxdGeometry(VXD::GeoCache::getInstance())
41 addParam(
"ROIsName",
m_ROIsName,
"name of the list of HLT ROIs, if available in output", std::string(
""));
43 addParam(
"pCut",
m_pcut,
"Set a cut on the track fit p-value (0=no cut)",
double(0));
44 addParam(
"minSVDHits",
m_minSVDHits,
"Number of SVD hits required in a track to be considered", 0u);
45 addParam(
"momCut",
m_momCut,
"Set a cut on the track momentum in GeV/c, 0 disables",
double(0));
46 addParam(
"pTCut",
m_pTCut,
"Set a cut on the track pT in GeV/c, 0 disables",
double(0));
47 addParam(
"maskedDistance",
m_maskedDistance,
"Distance inside which no masked pixel or sensor border is allowed",
int(10));
53 auto dir = gDirectory;
74 m_file =
new TFile(
"test.root",
"recreate");
76 m_tuple =
new TNtuple(
"effcontrol",
"effcontrol",
77 "vxdid:u:v:p:pt:distu:distv:sigu:sigv:dist:inroi:clborder:cldead:matched:z0:d0:svdhits:charge:phi:costheta");
91 B2INFO(
"PXDClusters array is missing, no efficiencies");
95 B2INFO(
"RecoTrack array is missing, no efficiencies");
99 B2INFO(
"Track array is missing, no efficiencies");
105 if (!recoTrack.
size())
continue;
107 auto a_track = recoTrack[0];
109 if (!a_track->wasFitSuccessful())
continue;
111 if (a_track->getNumberOfSVDHits() <
m_minSVDHits)
continue;
114 if (fitstatus->getPVal() <
m_pcut)
continue;
117 trackstate = a_track->getMeasuredStateOnPlaneFromFirstHit();
118 if (trackstate.getMom().Mag() <
m_momCut)
continue;
119 if (trackstate.getMom().Pt() <
m_pTCut)
continue;
123 B2ERROR(
"expect a track fit result for mass");
129 for (
VxdID& aVxdID : sensors) {
140 ROOT::Math::XYZVector intersec_buff =
getTrackInterSec(info, *a_track, isgood, sigu, sigv);
146 double u_fit = intersec_buff.X();
147 double v_fit = intersec_buff.Y();
149 int ucell_fit = info.getUCellID(intersec_buff.X());
150 int vcell_fit = info.getVCellID(intersec_buff.Y());
152 bool closeToBoarder =
false;
154 closeToBoarder =
true;
157 bool closeToDead =
false;
162 bool fitInsideROI =
false;
166 for (
auto& roit :
m_ROIs) {
167 if (aVxdID != roit.getSensorID()) {
171 if (ucell_fit < roit.getMaxUid()
172 && ucell_fit > roit.getMinUid()
173 && vcell_fit < roit.getMaxVid()
174 && vcell_fit > roit.getMinVid()) {
187 bool matched =
false;
188 if (bestcluster >= 0) {
193 TVector3 dist_clus(u_fit - u_clus, v_fit - v_clus, 0);
194 du_clus = u_fit - u_clus;
195 dv_clus = v_fit - v_clus;
196 d_clus = dist_clus.Mag();
200 float fill[22] = {float((
int)aVxdID), float(u_fit), float(v_fit), float(trackstate.getMom().Mag()), float(trackstate.getMom().Pt()),
201 float(du_clus), float(dv_clus), float(sigu), float(sigv), float(d_clus),
202 float(fitInsideROI), float(closeToBoarder), float(closeToDead), float(matched),
203 float(ptr2->
getZ0()), float(ptr2->
getD0()), float(a_track->getNumberOfSVDHits()),
204 charge, float(trackstate.getMom().Phi()), float(trackstate.getMom().CosTheta())
214 ROOT::Math::XYZVector
216 bool& isgood,
double& du,
double& dv)
221 ROOT::Math::XYZVector intersec(99999999, 9999999, 0);
228 ROOT::Math::XYZVector zeroVec(0, 0, 0);
229 ROOT::Math::XYZVector uVec(1, 0, 0);
230 ROOT::Math::XYZVector 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();
269 if (inside) isgood =
true;
279 double mindist = 999999999999;
297 ROOT::Math::XYZVector current(u, v, 0);
300 double dist = (intersection - current).
R();
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) {
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.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Class where important numbers and properties of a fit can be stored.
#StateOnPlane with additional covariance matrix.
REG_MODULE(arichBtest)
Register the Module.
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.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.