9 #include <ecl/modules/eclMatchingPerformance/ECLMatchingPerformanceExpertModule.h>
11 #include <ecl/geometry/ECLGeometryPar.h>
12 #include <framework/datastore/RelationVector.h>
14 #include <root/TFile.h>
15 #include <root/TTree.h>
24 ECLMatchingPerformanceExpertModule::ECLMatchingPerformanceExpertModule() :
25 Module(), m_trackProperties()
27 setDescription(
"Module to test the matching efficiency between tracks and ECLClusters. Additionally, information about the tracks are written into a ROOT file.");
28 setPropertyFlags(c_ParallelProcessingCertified);
30 addParam(
"outputFileName", m_outputFileName,
"Name of output root file.",
31 std::string(
"ECLMatchingPerformanceOutput.root"));
32 addParam(
"minimalCalDigitEnergy", m_minCalDigitEnergy,
"minimal energy deposition in crystal to distinguish true signal from noise",
34 addParam(
"innerDistanceEnergy", m_innerDistanceEnergy,
"determine distance to closest crystal with at least this deposited energy",
38 void ECLMatchingPerformanceExpertModule::initialize()
53 TDirectory* oldDir = gDirectory;
69 TVector3 pos_enter, pos_exit, pos_center;
77 B2ASSERT(
"Related Belle2 Track has no related track fit result!", fitResult);
103 for (
auto& eclCluster : track.getRelationsTo<
ECLCluster>()) {
105 if (!(eclCluster.isTrack()))
continue;
111 bool found_first_enter =
false;
112 std::set<int> uniqueECLCalDigits;
115 for (
const auto& extHit : track.getRelationsTo<
ExtHit>()) {
116 int copyid = extHit.getCopyID();
117 if (copyid == -1)
continue;
118 if (extHit.getDetectorID() != Const::EDetector::ECL)
continue;
120 if (eclClusterNear) {
126 const int cell = copyid + 1;
127 if (extHit.getStatus() == EXT_ENTER) {
129 inserted = (uniqueECLCalDigits.insert(cell)).second;
132 if (eclCalDigit.getCellId() == cell) {
140 if (!found_first_enter) {
141 pos_enter = extHit.getPosition();
144 found_first_enter =
true;
157 geometry->Mapping(cell - 1);
158 thetaID = geometry->GetThetaID();
160 phiID = geometry->GetPhiID();
161 const short int phiInc = (((phiID + 1) > (crystalsPerRing - 1)) ? phiID + 1 - crystalsPerRing : phiID + 1);
162 const double fractionalPhiInc =
static_cast < double >(phiInc) / crystalsPerRing;
163 const short int phiDec = ((phiID - 1 < 0) ? crystalsPerRing + phiID - 1 : phiID - 1);
164 const double fractionalPhiDec =
static_cast < double >(phiDec) / crystalsPerRing;
178 const short int thisPhiInc = std::lround(fractionalPhiInc * crystalsPerRing);
182 short int thisPhiDec = std::lround(fractionalPhiDec * crystalsPerRing);
183 if (thisPhiDec == crystalsPerRing) thisPhiDec = 0;
195 short int thisPhiDec = std::lround(fractionalPhiDec * crystalsPerRing);
196 if (thisPhiDec == crystalsPerRing) thisPhiDec = 0;
200 const short int thisPhiInc = std::lround(fractionalPhiInc * crystalsPerRing);
215 }
else if (extHit.getStatus() == EXT_EXIT) {
217 pos_exit = extHit.getPosition();
223 int cellid = eclCalDigit.getCellId();
224 TVector3 cvec = geometry->GetCrystalPos(cellid - 1);
225 distance = (cvec - 0.5 * (pos_enter + pos_exit)).Mag();
247 B2FATAL(
"Data tree was not created.");
317 TDirectory* oldDir = gDirectory;
376 std::stringstream leaf;
377 leaf << varName <<
"/D";
378 m_dataTree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
383 std::stringstream leaf;
384 leaf << varName <<
"/I";
385 m_dataTree->Branch(varName.c_str(), &varReference, leaf.str().c_str());
389 int& matchedToNeighbours,
const int& cell)
391 const auto& vec_of_neighbouring_cells = eclneighbours->
getNeighbours(cell);
392 for (
const auto& neighbouringcell : vec_of_neighbouring_cells) {
394 [&](
const ECLCalDigit & d) { return (d.getCellId() == neighbouringcell && d.getEnergy() > m_minCalDigitEnergy); }
398 matchedToNeighbours = 1;
407 [&](
const ECLCalDigit & d) { return (d.getCellId() == cell && d.getEnergy() > m_minCalDigitEnergy); }
static const ChargedStable muon
muon particle
Class to store calibrated ECLDigits: ECLCalDigits.
TVector3 getClusterPosition() const
Return TVector3 on cluster position (x,y,z)
@ c_nPhotons
CR is split into n photons (N1)
The Class for ECL Geometry Parameters.
static ECLGeometryPar * Instance()
Static method to get a reference to the ECLGeometryPar instance.
Class to get the neighbours for a given cell id.
const std::vector< short int > & getNeighbours(short int cid) const
Return the neighbours for a given cell ID.
short int getCrystalsPerRing(const short int thetaid) const
return number of crystals in a given theta ring
Store one Ext hit as a ROOT object.
This is the Reconstruction Event-Data Model Track.
const genfit::FitStatus * getTrackFitStatus(const genfit::AbsTrackRep *representation=nullptr) const
Return the track fit status for the given representation or for the cardinal one. You are not allowed...
unsigned int getNumberOfSVDHits() const
Return the number of svd hits.
unsigned int getNumberOfCDCHits() const
Return the number of cdc hits.
unsigned int getNumberOfPXDHits() const
Return the number of pxd hits.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getPValue() const
Getter for Chi2 Probability of the track fit.
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
TVector3 getPosition() const
Getter for vector of position at closest approach of track in r/phi projection.
double getZ0() const
Getter for z0.
Class that bundles various TrackFitResults.
double getNdf() const
Get the degrees of freedom of the fit.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.
double pt
measured transverse momentum
int nCDChits
Number of CDC hits in reconstructed track
double pz
measured momentum in z direction
int nPXDhits
Number of PXD hits in reconstructed track
int nSVDhits
Number of SVD hits in reconstructed track
double px
measured momentum in x direction
double z
measured z value of position
double y
measured y value of position
double py
measured momentum in y direction
double phi
azimuthal angle of measured momentum vector
double cosTheta
polar angle of measured momentum vector
double x
measured x value of position
double ptot
measured total momentum