11 #include <framework/datastore/StoreArray.h>
12 #include <mdst/dataobjects/MCParticle.h>
13 #include <mdst/dataobjects/KLMCluster.h>
14 #include <mdst/dataobjects/ECLCluster.h>
15 #include <mdst/dataobjects/TrackFitResult.h>
17 #include <framework/gearbox/Const.h>
18 #include <framework/logging/Logger.h>
19 #include <tracking/dataobjects/RecoTrack.h>
20 #include <genfit/Exception.h>
30 const TVector3& pos = cluster.getClusterPosition();
34 const TVector3& trackPos = track.getPosition();
36 if (trackPos.Angle(pos) < angle) {
37 B2DEBUG(20,
"BelleFlagTracklAngle::" << trackPos.Angle(pos));
48 const TVector3& pos = cluster.getClusterPosition();
53 const TVector3& clusterPos = eclcluster.getClusterPosition();
55 if (clusterPos.Angle(pos) < angle) {
56 B2DEBUG(20,
"BelleFlagECLAngle::" << clusterPos.Angle(pos));
66 if (part ==
nullptr) {
76 unsigned int hirachy_counter = 0;
84 return hirachy_counter;
86 if ((part -> getMother() ==
nullptr)) {
89 part = part -> getMother();
98 const auto mcParticleWeightPair = cluster.getRelatedToWithWeight<
Belle2::MCParticle>();
100 if (!part) {
return false; }
101 float mcWeight = mcParticleWeightPair.second;
112 const auto mcParticleWeightPair = cluster.getRelatedToWithWeight<
Belle2::MCParticle>();
114 if (!part) {
return false; }
115 float mcWeight = mcParticleWeightPair.second;
128 if (std::abs(part -> getPDG()) == pdg) {
131 if ((part -> getMother() ==
nullptr)) {
134 part = part -> getMother();
186 if ((part -> getMother() ==
nullptr)) {
189 part = part -> getMother();
192 return part ->getPDG();
204 double closestECLAngleDist = 1e10;
209 int indexOfClosestCluster = -1;
212 if (eclcluster.hasHypothesis(eclhypothesis)) {
214 const TVector3& eclclusterPos = eclcluster.getClusterPosition();
215 double angularDist = eclclusterPos.Angle(klmClusterPosition);
216 if (angularDist < closestECLAngleDist) {
217 closestECLAngleDist = angularDist;
218 indexOfClosestCluster = index;
223 if (indexOfClosestCluster > -1)
224 closestECL = eclClusters[indexOfClosestCluster];
226 return std::make_pair(closestECL, closestECLAngleDist);
236 double closestKLMDist = 1e10;
237 double avInterClusterDist = 0;
238 double nKLMCluster = klmClusters.
getEntries();
240 if (nKLMCluster > 1) {
242 unsigned int index = 0;
243 unsigned int indexOfClosestCluster = 0;
246 const TVector3& nextClusterPos = nextCluster.getClusterPosition();
247 const TVector3& clustDistanceVec = nextClusterPos - klmClusterPosition;
249 double nextClusterDist = clustDistanceVec.Mag2();
250 avInterClusterDist = avInterClusterDist + nextClusterDist;
252 if ((nextClusterDist < closestKLMDist) and not(nextClusterDist == 0)) {
253 closestKLMDist = nextClusterDist ;
254 indexOfClosestCluster = index;
259 closestKLM = klmClusters[indexOfClosestCluster];
260 avInterClusterDist = avInterClusterDist / (1. * nKLMCluster);
263 return std::make_tuple(closestKLM, closestKLMDist, avInterClusterDist);
268 std::tuple<Belle2::RecoTrack*, double, std::unique_ptr<const TVector3> >
findClosestTrack(
const TVector3& clusterPosition,
272 double oldDistance = 10000000;
274 TVector3 poca = TVector3(0, 0, 0);
282 state_for_cut = track.getMeasuredStateOnPlaneFromFirstHit();
285 if (clusterPosition.Angle(state_for_cut.getPos()) < cutAngle) {
286 state = track.getMeasuredStateOnPlaneFromLastHit();
287 state.extrapolateToPoint(clusterPosition);
288 const TVector3& trackPos = state.getPos();
290 const TVector3& distanceVecCluster = clusterPosition - trackPos;
291 double newDistance = distanceVecCluster.Mag2();
294 if (newDistance < oldDistance) {
295 oldDistance = newDistance;
296 closestTrack = &track;
304 if (not closestTrack) {
305 return std::make_tuple(
nullptr, oldDistance, std::unique_ptr<const TVector3>(
nullptr));
309 return std::make_tuple(closestTrack, oldDistance, std::unique_ptr<const TVector3>(
new TVector3(poca)));
int getPDGCode() const
PDG code.
static const ParticleType neutron
neutron particle
static const ParticleType pi0
neutral pion particle
static const ChargedStable muon
muon particle
static const ChargedStable pion
charged pion particle
static const ParticleType Klong
K^0_L particle.
static const ChargedStable proton
proton particle
static const ParticleType Kshort
K^0_S particle.
static const ChargedStable kaon
charged kaon particle
static const ParticleType photon
photon particle
static const ChargedStable electron
electron particle
EHypothesisBit
The hypothesis bits for this ECLCluster (Connected region (CR) is split using this hypothesis.
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
A Class to store the Monte Carlo particle information.
This is the Reconstruction Event-Data Model Track.
int getEntries() const
Get the number of objects in the array.
Values of the result of a track fit with a given particle hypothesis.
Exception class for error handling in GENFIT (provides storage for diagnostic information)
#StateOnPlane with additional covariance matrix.
Helper functions for all klid modules to improve readability of the code.
int mcParticleIsBeamBKG(Belle2::MCParticle *part)
return if MCparticle is beambkg
bool isKLMClusterSignal(const Belle2::KLMCluster &cluster, float mcWeigthCut=0.66)
checks if a cluster is signal under the mcWeightcondition (mcWeight = energy deposition)
int BelleTrackFlag(const Belle2::KLMCluster &cluster, const float angle=0.26)
get Belle stle track flag
bool isECLClusterSignal(const Belle2::ECLCluster &cluster, float mcWeigthCut=0.66)
checks if a cluster is signal under the mcWeightcondition (mcWeight = energy deposition)
int isMCParticlePDG(Belle2::MCParticle *part, int pdg)
return if mc particle has a certain pdg in the decay chain
int BelleECLFlag(const Belle2::KLMCluster &cluster, const float angle=0.26)
get Belle stle ECL flag
int getPrimaryPDG(Belle2::MCParticle *part)
return if mc particles primary pdg.
std::tuple< const Belle2::KLMCluster *, double, double > findClosestKLMCluster(const TVector3 &klmClusterPosition)
find nearest KLMCluster, tis distance and the av intercluster distance
int mcParticleIsKlong(Belle2::MCParticle *part)
return the mc hirachy of the klong 0:not a klong 1:final particle, 2: klong is mother etc
std::tuple< Belle2::RecoTrack *, double, std::unique_ptr< const TVector3 > > findClosestTrack(const TVector3 &clusterPosition, float cutAngle)
find nearest genfit track and return it and its distance
std::pair< Belle2::ECLCluster *, double > findClosestECLCluster(const TVector3 &klmClusterPosition, const Belle2::ECLCluster::EHypothesisBit eclhypothesis=Belle2::ECLCluster::EHypothesisBit::c_neutralHadron)
Find the closest ECLCluster with a neutral hadron hypothesis, and return it with its distance.