Belle II Software  release-05-01-25
WireHitMCMultiLoopBlocker.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/trackFindingCDC/findlets/minimal/WireHitMCMultiLoopBlocker.h>
11 
12 #include <tracking/trackFindingCDC/mclookup/CDCMCManager.h>
13 
14 #include <tracking/trackFindingCDC/mclookup/CDCMCHitLookUp.h>
15 
16 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
17 
18 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
19 
20 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
21 
22 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
23 #include <framework/core/ModuleParamList.templateDetails.h>
24 
25 #include <cdc/dataobjects/CDCSimHit.h>
26 #include <mdst/dataobjects/MCParticle.h>
27 
28 #include <root/TVector3.h>
29 
30 using namespace Belle2;
31 using namespace TrackFindingCDC;
32 
34 {
35  return "Marks all hits that were not reached after the specified number of loops as background "
36  "based on MC information.";
37 }
38 
40  const std::string& prefix)
41 {
42  moduleParamList->addParameter(prefixed(prefix, "UseNLoops"),
44  "Maximal number of loops accepted",
46 }
47 
49 {
51  if (std::isfinite(m_param_useNLoops)) {
53  }
54 }
55 
57 {
59  if (std::isfinite(m_param_useNLoops)) {
61  }
62 }
63 
64 void WireHitMCMultiLoopBlocker::apply(std::vector<CDCWireHit>& wireHits)
65 {
66  if (not std::isfinite(m_param_useNLoops)) return;
67 
68  const CDCMCHitLookUp& mcHitLookUp = CDCMCHitLookUp::getInstance();
69  double nLoops = m_param_useNLoops;
70  auto isWithinMCLoops = [&mcHitLookUp, nLoops](const CDCWireHit & wireHit) {
71 
72  // Reject hits with no assoziated CDCSimHit.
73  const CDCSimHit* simHit = mcHitLookUp.getClosestPrimarySimHit(wireHit.getHit());
74  if (not simHit) return false;
75 
76  const double tof = simHit->getFlightTime();
77 
78  // Accept hits with no assoziated MCParticle (e.g. beam background.)
79  const MCParticle* mcParticle = simHit->getRelated<MCParticle>();
80  if (not mcParticle) return true;
81 
82  const double speed = mcParticle->get4Vector().Beta() * Const::speedOfLight;
83 
84  const TVector3 mom3D = mcParticle->getMomentum();
85  const float absMom2D = mom3D.Perp();
86  const float absMom3D = mom3D.Mag();
87 
88  const Vector3D pos3D(0.0, 0.0, 0.0);
89  const double bendRadius = CDCBFieldUtil::absMom2DToBendRadius(absMom2D, pos3D);
90  const double bendCircumfence = 2 * M_PI * bendRadius;
91  const double loopLength = bendCircumfence * absMom3D / absMom2D;
92  const double loopTOF = loopLength / speed;
93 
94  if (tof > loopTOF * nLoops) {
95  return false;
96  } else {
97  return true;
98  }
99  };
100 
101  for (CDCWireHit& wireHit : wireHits) {
102  if (not isWithinMCLoops(wireHit)) {
103  wireHit->setBackgroundFlag();
104  wireHit->setTakenFlag();
105  }
106  }
107 }
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::initialize
void initialize() final
Signals the start of the event processing.
Definition: WireHitMCMultiLoopBlocker.cc:48
Belle2::CDCSimHit::getFlightTime
double getFlightTime() const
The method to get flight time.
Definition: CDCSimHit.h:201
Belle2::TrackFindingCDC::CDCMCHitLookUp::getClosestPrimarySimHit
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...
Definition: CDCMCHitLookUp.cc:103
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::getDescription
std::string getDescription() final
Short description of the findlet.
Definition: WireHitMCMultiLoopBlocker.cc:33
Belle2::RelationsInterface::getRelated
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
Definition: RelationsObject.h:280
Belle2::CDCSimHit
Example Detector.
Definition: CDCSimHit.h:33
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::initialize
void initialize() override
Receive and dispatch signal before the start of the event processing.
Definition: CompositeProcessingSignalListener.cc:17
Belle2::TrackFindingCDC::CDCMCManager::requireTruthInformation
void requireTruthInformation()
Require the mc information store arrays.
Definition: CDCMCManager.cc:117
Belle2::TrackFindingCDC::CDCMCManager::fill
void fill()
Fill Monte Carlo look up maps from the DataStore.
Definition: CDCMCManager.cc:137
Belle2::Const::speedOfLight
static const double speedOfLight
[cm/ns]
Definition: Const.h:568
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCMCHitLookUp
Interface class to the Monte Carlo information for individual hits.
Definition: CDCMCHitLookUp.h:41
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
Definition: WireHitMCMultiLoopBlocker.cc:39
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::TrackFindingCDC::CDCMCManager::getInstance
static CDCMCManager & getInstance()
Getter for the singletone instance.
Definition: CDCMCManager.cc:76
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::apply
void apply(std::vector< CDCWireHit > &wireHits) final
Main algorithm marking the hit of higher loops as background.
Definition: WireHitMCMultiLoopBlocker.cc:64
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::beginEvent
void beginEvent() override
Receive and dispatch signal for the start of a new event.
Definition: CompositeProcessingSignalListener.cc:33
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::m_param_useNLoops
double m_param_useNLoops
Parameter : Maximal fraction of loops of the mc particles trajectory needs to the hit to unblock it.
Definition: WireHitMCMultiLoopBlocker.h:68
Belle2::TrackFindingCDC::CDCMCHitLookUp::getInstance
static const CDCMCHitLookUp & getInstance()
Getter for the singletone instance.
Definition: CDCMCHitLookUp.cc:32
Belle2::MCParticle::get4Vector
TLorentzVector get4Vector() const
Return 4Vector of particle.
Definition: MCParticle.h:218
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::WireHitMCMultiLoopBlocker::beginEvent
void beginEvent() final
Prepare the Monte Carlo information at the start of the event.
Definition: WireHitMCMultiLoopBlocker.cc:56
Belle2::TrackFindingCDC::CDCBFieldUtil::absMom2DToBendRadius
static double absMom2DToBendRadius(double absMom2D, double bZ)
Conversion helper for momenta to two dimensional (absolute) bend radius.
Definition: CDCBFieldUtil.cc:92