Belle II Software development
WireHitMCMultiLoopBlocker.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/findlets/minimal/WireHitMCMultiLoopBlocker.h>
9
10#include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
11
12#include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
13
14#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
15
16#include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
17
18#include <tracking/trackFindingCDC/geometry/Vector3D.h>
19
20#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
21#include <framework/core/ModuleParamList.templateDetails.h>
22
23#include <cdc/dataobjects/CDCSimHit.h>
24#include <mdst/dataobjects/MCParticle.h>
25
26using namespace Belle2;
27using namespace TrackFindingCDC;
28
30{
31 return "Marks all hits that were not reached after the specified number of loops as background "
32 "based on MC information.";
33}
34
36 const std::string& prefix)
37{
38 moduleParamList->addParameter(prefixed(prefix, "UseNLoops"),
40 "Maximal number of loops accepted",
42}
43
45{
47 if (std::isfinite(m_param_useNLoops)) {
49 }
50}
51
53{
55 if (std::isfinite(m_param_useNLoops)) {
57 }
58}
59
60void WireHitMCMultiLoopBlocker::apply(std::vector<CDCWireHit>& wireHits)
61{
62 if (not std::isfinite(m_param_useNLoops)) return;
63
64 const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
65 double nLoops = m_param_useNLoops;
66 auto isWithinMCLoops = [&mcHitLookUp, nLoops](const CDCWireHit & wireHit) {
67
68 // Reject hits with no associated CDCSimHit.
69 const CDCSimHit* simHit = mcHitLookUp.getClosestPrimarySimHit(wireHit.getHit());
70 if (not simHit) return false;
71
72 const double tof = simHit->getFlightTime();
73
74 // Accept hits with no associated MCParticle (e.g. beam background.)
75 const MCParticle* mcParticle = simHit->getRelated<MCParticle>();
76 if (not mcParticle) return true;
77
78 const double speed = mcParticle->get4Vector().Beta() * Const::speedOfLight;
79
80 const ROOT::Math::XYZVector mom3D = mcParticle->getMomentum();
81 const float absMom2D = mom3D.Rho();
82 const float absMom3D = mom3D.R();
83
84 const Vector3D pos3D(0.0, 0.0, 0.0);
85 const double bendRadius = CDCBFieldUtil::absMom2DToBendRadius(absMom2D, pos3D);
86 const double bendCircumfence = 2 * M_PI * bendRadius;
87 const double loopLength = bendCircumfence * absMom3D / absMom2D;
88 const double loopTOF = loopLength / speed;
89
90 if (tof > loopTOF * nLoops) {
91 return false;
92 } else {
93 return true;
94 }
95 };
96
97 for (CDCWireHit& wireHit : wireHits) {
98 if (not isWithinMCLoops(wireHit)) {
99 wireHit->setBackgroundFlag();
100 wireHit->setTakenFlag();
101 }
102 }
103}
Example Detector.
Definition: CDCSimHit.h:21
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:184
static const double speedOfLight
[cm/ns]
Definition: Const.h:695
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
ROOT::Math::PxPyPzEVector get4Vector() const
Return 4Vector of particle.
Definition: MCParticle.h:207
ROOT::Math::XYZVector getMomentum() const
Return momentum.
Definition: MCParticle.h:198
The Module parameter list class.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
static double absMom2DToBendRadius(double absMom2D, double bZ)
Conversion helper for momenta to two dimensional (absolute) bend radius.
Interface class to the Monte Carlo information for individual hits.
const CDCSimHit * getClosestPrimarySimHit(const CDCHit *ptrHit) const
Getter for the closest simulated hit of a primary particle to the given hit - may return nullptr of n...
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
void requireTruthInformation()
Require the MC information store arrays.
void fill()
Fill Monte Carlo look up maps from the DataStore.
static CDCMCManager & getInstance()
Getter for the singleton instance.
Definition: CDCMCManager.cc:74
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
void initialize() override
Receive and dispatch signal before the start of the event processing.
void beginEvent() override
Receive and dispatch signal for the start of a new event.
A three dimensional vector.
Definition: Vector3D.h:33
void apply(std::vector< CDCWireHit > &wireHits) final
Main algorithm marking the hit of higher loops as background.
void initialize() final
Signals the start of the event processing.
void beginEvent() final
Prepare the Monte Carlo information at the start of the event.
std::string getDescription() final
Short description of the findlet.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
double m_param_useNLoops
Parameter : Maximal fraction of loops of the mc particles trajectory needs to the hit to unblock it.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.