Belle II Software  release-08-01-10
CDCMCMap.h
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 #pragma once
9 
10 #include <tracking/trackFindingCDC/utilities/Range.h>
11 #include <tracking/trackFindingCDC/utilities/MayBePtr.h>
12 
13 #include <map>
14 #include <set>
15 
16 namespace Belle2 {
21  class MCParticle;
22  class CDCSimHit;
23  class CDCHit;
24 
25  namespace TrackFindingCDC {
26 
28  class CDCMCMap {
29 
30  public:
31 
33  CDCMCMap() = default;
35  CDCMCMap& operator=(const CDCMCMap&) = delete;
37  CDCMCMap(CDCMCMap&) = delete;
38 
39  public:
40 
42  void clear();
43 
45  void fill();
46 
47  private:
52  static bool indicatesReassignedSecondary(double weight)
53  {
54  return weight <= 0;
55  }
56 
58  void fillSimHitByHitMap();
59 
62 
65 
67  void validateRelations() const;
68 
70  void validateReassignedSecondaries() const;
71 
72  public:
74  MayBePtr<const CDCSimHit> getSimHit(const CDCHit* hit) const;
75 
77  MayBePtr<const CDCHit> getHit(const CDCSimHit* simHit) const;
78 
80  bool isBackground(const CDCSimHit* simHit) const;
81 
83  bool isBackground(const CDCHit* hit) const;
84 
89  MayBePtr<const MCParticle> getMCParticle(const CDCHit* hit) const;
90 
95  MayBePtr<const MCParticle> getMCParticle(const CDCSimHit* simHit) const;
96 
98  auto getSimHits(const MCParticle* mcParticle) const
99  {
100  return asRange(m_simHitsByMCParticle.equal_range(mcParticle));
101  }
102 
104  auto getHits(const MCParticle* mcParticle) const
105  {
106  return asRange(m_hitsByMCParticle.equal_range(mcParticle));
107  }
108 
110  bool isReassignedSecondary(const CDCSimHit* ptrSimHit) const
111  {
112  return m_reassignedSecondarySimHits.count(ptrSimHit) > 0;
113  }
114 
116  bool isReassignedSecondary(const CDCHit* ptrHit) const
117  {
118  return m_reassignedSecondaryHits.count(ptrHit) > 0;
119  }
120 
122  const std::set<const CDCHit*>& getReassignedSecondaryHits() const
123  {
125  }
126 
128  const std::set<const CDCSimHit*>& getReassignedSecondarySimHits() const
129  {
131  }
132 
134  const std::multimap<const CDCHit*, const CDCSimHit*>& getSimHitsByHit() const
135  {
136  return m_simHitsByHit;
137  }
138 
140  const std::multimap<const MCParticle*, const CDCHit*>& getHitsByMCParticle() const
141  {
142  return m_hitsByMCParticle;
143  }
144 
146  const std::multimap<const MCParticle*, const CDCSimHit*>& getSimHitsByMCParticle() const
147  {
148  return m_simHitsByMCParticle;
149  }
150 
151  private:
153  std::multimap<const CDCHit*, const CDCSimHit*> m_simHitsByHit;
154 
156  std::multimap<const MCParticle*, const CDCHit*> m_hitsByMCParticle;
157 
159  std::multimap<const MCParticle*, const CDCSimHit*> m_simHitsByMCParticle;
160 
162  std::set<const CDCHit*> m_reassignedSecondaryHits;
163 
165  std::set<const CDCSimHit*> m_reassignedSecondarySimHits;
166  };
167  }
169 }
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Example Detector.
Definition: CDCSimHit.h:21
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Class to organize and present the monte carlo hit information.
Definition: CDCMCMap.h:28
auto getHits(const MCParticle *mcParticle) const
Getter for the range MCParticle to CDCHits relations which come from the given MCParticle.
Definition: CDCMCMap.h:104
MayBePtr< const CDCSimHit > getSimHit(const CDCHit *hit) const
Seeks the CDCSimHit related to the CDCHit.
Definition: CDCMCMap.cc:249
std::set< const CDCHit * > m_reassignedSecondaryHits
The set of reassigned secondary CDCHits.
Definition: CDCMCMap.h:162
void fillSimHitByHitMap()
Retrieve the relations array from CDCSimHits to CDCHits and fill it in to the local map which does th...
Definition: CDCMCMap.cc:65
std::set< const CDCSimHit * > m_reassignedSecondarySimHits
The set of reassigned secondary CDCSimHits.
Definition: CDCMCMap.h:165
bool isReassignedSecondary(const CDCHit *ptrHit) const
Indicates if the CDCHit has been reassigned to a primary MCParticle.
Definition: CDCMCMap.h:116
std::multimap< const CDCHit *, const CDCSimHit * > m_simHitsByHit
Memory for a one to one relation from CDCHit to CDCSimHits.
Definition: CDCMCMap.h:153
const std::set< const CDCSimHit * > & getReassignedSecondarySimHits() const
Getter for all reassigned secondary CDCSimHits.
Definition: CDCMCMap.h:128
void validateRelations() const
Checks if the relations CDCHit -> MCParticle and CDCHit -> CDCSimHit -> MCParticle commute.
Definition: CDCMCMap.cc:219
void fillMCParticleByHitMap()
Retrieve the relations array from MCParticle to CDCHits and fill it in to the local map which does th...
Definition: CDCMCMap.cc:103
bool isBackground(const CDCSimHit *simHit) const
Indicates if the CDCSimHit is considered background.
Definition: CDCMCMap.cc:259
static bool indicatesReassignedSecondary(double weight)
Indicate if the given weight suggests that the corresponding hit to MCParticle relation has been redi...
Definition: CDCMCMap.h:52
CDCMCMap & operator=(const CDCMCMap &)=delete
Delete the assignement operator in order to avoid accidental copies.
MayBePtr< const CDCHit > getHit(const CDCSimHit *simHit) const
Seeks the CDCHit related to the CDCSimHit - nullptr if no CDCHit is related.
Definition: CDCMCMap.cc:254
void fillMCParticleBySimHitMap()
Retrieve the relations array from MCParticle to CDCSimHits and fill it in to the local map which does...
Definition: CDCMCMap.cc:185
MayBePtr< const MCParticle > getMCParticle(const CDCHit *hit) const
Seeks the MCParticle related to the CDCHit.
Definition: CDCMCMap.cc:269
std::multimap< const MCParticle *, const CDCHit * > m_hitsByMCParticle
Memory for a one to n relation from MCParticles to CDCHit.
Definition: CDCMCMap.h:156
CDCMCMap(CDCMCMap &)=delete
For the same reason, also delete copy constructor.
bool isReassignedSecondary(const CDCSimHit *ptrSimHit) const
Indicates if the CDCSimHit has been reassigned to a primary MCParticle.
Definition: CDCMCMap.h:110
const std::multimap< const MCParticle *, const CDCSimHit * > & getSimHitsByMCParticle() const
Getter for the MCParticle -> CDCSimHit relations.
Definition: CDCMCMap.h:146
const std::multimap< const CDCHit *, const CDCSimHit * > & getSimHitsByHit() const
Getter for the CDCHit -> CDCSimHit relations.
Definition: CDCMCMap.h:134
std::multimap< const MCParticle *, const CDCSimHit * > m_simHitsByMCParticle
Memory for a one to n relation from MCParticles to CDCSimHit.
Definition: CDCMCMap.h:159
void clear()
Clear all information from the former event.
Definition: CDCMCMap.cc:32
const std::multimap< const MCParticle *, const CDCHit * > & getHitsByMCParticle() const
Getter for the MCParticle -> CDCHit relations.
Definition: CDCMCMap.h:140
void validateReassignedSecondaries() const
Checks if each CDCHit is marked as reassigned secondary is related to a reassigned secondary CDCSimHi...
Definition: CDCMCMap.cc:238
auto getSimHits(const MCParticle *mcParticle) const
Getter for the range MCParticle to CDCSimHits relations which come from the given MCParticle.
Definition: CDCMCMap.h:98
CDCMCMap()=default
Default constructor, needs to be public for initialization in CDCMCManager.
void fill()
Fill the Monte Carlo information retrieved from the DataStore into the local multimaps.
Definition: CDCMCMap.cc:44
const std::set< const CDCHit * > & getReassignedSecondaryHits() const
Getter for all reassigned secondary CDCHits.
Definition: CDCMCMap.h:122
Abstract base class for different kinds of events.