LArPandoraInput.h
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraInterface/LArPandoraInput.h
3  *
4  * @brief Helper functions for providing inputs to pandora
5  */
6 
7 #ifndef LAR_PANDORA_INPUT_H
8 #define LAR_PANDORA_INPUT_H 1
9 
11 namespace detinfo {
12  class DetectorPropertiesData;
13 }
14 
18 
20 
21 namespace lar_pandora {
22 
23  /**
24  * @brief LArPandoraInput class
25  */
27  public:
28  /**
29  * @brief Settings class
30  */
31  class Settings {
32  public:
33  /**
34  * @brief Default constructor
35  */
36  Settings();
37 
38  const pandora::Pandora* m_pPrimaryPandora; ///<
39  bool m_useHitWidths; ///<
42  int m_uidOffset; ///<
44  double m_dx_cm; ///<
45  double m_int_cm; ///<
46  double m_rad_cm; ///<
47  double m_dEdX_mip; ///<
48  double m_mips_max; ///<
49  double m_mips_if_negative; ///<
50  double m_mips_to_gev; ///<
52  };
53 
54  /**
55  * @brief Create the Pandora 2D hits from the ART hits
56  *
57  * @param evt art event being processed
58  * @param settings the settings
59  * @param driftVolumeMap the mapping from volume id to drift volume
60  * @param hits the input list of ART hits for this event
61  * @param idToHitMap to receive the mapping from Pandora hit ID to ART hit
62  */
63  static void CreatePandoraHits2D(const art::Event& evt,
64  const Settings& settings,
65  const LArDriftVolumeMap& driftVolumeMap,
66  const HitVector& hitVector,
67  IdToHitMap& idToHitMap);
68 
69  /**
70  * @brief Create pandora LArTPCs to represent the different drift volumes in use
71  *
72  * @param settings the settings
73  * @param driftVolumeList the drift volume list
74  */
75  static void CreatePandoraLArTPCs(const Settings& settings,
76  const LArDriftVolumeList& driftVolumeList);
77 
78  /**
79  * @brief Create pandora line gaps to cover dead regions between TPCs in a global drift volume approach
80  *
81  * @param settings the settings
82  * @param driftVolumeList the drift volume list
83  * @param listOfGaps the list of gaps
84  */
85  static void CreatePandoraDetectorGaps(const Settings& settings,
86  const LArDriftVolumeList& driftVolumeList,
87  const LArDetectorGapList& listOfGaps);
88 
89  /**
90  * @brief Create pandora line gaps to cover any (continuous regions of) bad channels
91  *
92  * @param settings the settings
93  * @param driftVolumeMap the mapping from volume id to drift volume
94  */
95  static void CreatePandoraReadoutGaps(const Settings& settings,
96  const LArDriftVolumeMap& driftVolumeMap);
97 
98  /**
99  * @brief Create the Pandora MC particles from the MC particles
100  *
101  * @param settings the settings
102  * @param truthToParticles mapping from MC truth to MC particles
103  * @param particlesToTruth mapping from MC particles to MC truth
104  */
105  static void CreatePandoraMCParticles(const Settings& settings,
106  const MCTruthToMCParticles& truthToParticles,
107  const MCParticlesToMCTruth& particlesToTruth,
108  const RawMCParticleVector& generatorMCParticleVector);
109 
110  /**
111  * @brief Find all primary MCParticles in a given vector of MCParticles
112  *
113  * @param mcParticleVector vector of all MCParticles to consider
114  * @param primaryMCParticleMap map containing primary MCParticles and bool indicating whether particle has been accounted for
115  */
116  static void FindPrimaryParticles(const RawMCParticleVector& mcParticleVector,
117  std::map<const simb::MCParticle, bool>& primaryMCParticleMap);
118 
119  /**
120  * @brief Check whether an MCParticle can be found in a given map
121  *
122  * @param mcParticle target MCParticle
123  * @param primaryMCParticleMap map containing primary MCParticles and bool indicating whether particle has been accounted for
124  */
125  static bool IsPrimaryMCParticle(const art::Ptr<simb::MCParticle>& mcParticle,
126  std::map<const simb::MCParticle, bool>& primaryMCParticleMap);
127 
128  /**
129  * @brief Create links between the 2D hits and Pandora MC particles
130  *
131  * @param settings the settings
132  * @param hitMap mapping from Pandora hit addresses to ART hits
133  * @param hitToParticleMap mapping from each ART hit to its underlying G4 track ID
134  */
135  static void CreatePandoraMCLinks2D(const Settings& settings,
136  const HitMap& hitMap,
137  const HitsToTrackIDEs& hitToParticleMap);
138 
139  private:
140  typedef std::map<std::string, lar_content::MCProcess> MCProcessMap;
141 
142  /**
143  * @brief Loop over MC trajectory points and identify start and end points within the detector
144  *
145  * @param settings the settings
146  * @param particle the true particle
147  * @param startT the first trajectory point in the detector
148  * @param endT the last trajectory point in the detector
149  */
150  static void GetTrueStartAndEndPoints(const Settings& settings,
151  const art::Ptr<simb::MCParticle>& particle,
152  int& startT,
153  int& endT);
154 
155  /**
156  * @brief Loop over MC trajectory points and identify start and end points within a given cryostat and TPC
157  *
158  * @param cstat the cryostat
159  * @param tpc the TPC
160  * @param particle the true particle
161  * @param startT the first trajectory point in the detector
162  * @param endT the last trajectory point in the detector
163  */
164  static void GetTrueStartAndEndPoints(const unsigned int cstat,
165  const unsigned int tpc,
166  const art::Ptr<simb::MCParticle>& particle,
167  int& startT,
168  int& endT);
169 
170  /**
171  * @brief Use detector and time services to get a true X offset for a given trajectory point
172  *
173  * @param evt event currently being processing by art
174  * @param particle the true particle
175  * @param nT the trajectory point
176  */
177  static float GetTrueX0(const art::Event& evt,
178  const art::Ptr<simb::MCParticle>& particle,
179  const int nT);
180 
181  /**
182  * @brief Convert charge in ADCs to approximate MIPs
183  *
184  * @param settings the settings
185  * @param hit_Charge the input charge
186  * @param hit_View the input view number
187  */
188  static double GetMips(const detinfo::DetectorPropertiesData& detProp,
189  const Settings& settings,
190  const double hit_Charge,
191  const geo::View_t hit_View);
192 
193  /**
194  * @brief Populate a map from MC process string to enumeration
195  *
196  * @param processMap the output map from MC process string to enumeration
197  */
198  static void FillMCProcessMap(MCProcessMap& processMap);
199  };
200 
201 } // namespace lar_pandora
202 
203 #endif // #ifndef LAR_PANDORA_INPUT_H
Interface class for LArPandora producer modules, which reconstruct recob::PFParticles from recob::Hit...
Helper functions for extracting detector geometry for use in reconsruction.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
std::map< unsigned int, LArDriftVolume > LArDriftVolumeMap
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::vector< LArDriftVolume > LArDriftVolumeList
const pandora::Pandora * m_pPrimaryPandora
std::map< int, art::Ptr< recob::Hit > > IdToHitMap
Definition: ILArPandora.h:21
std::unordered_map< std::string, int > processMap
Definition: AnaUtils.cxx:89
std::map< int, art::Ptr< recob::Hit > > HitMap
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
std::vector< simb::MCParticle > RawMCParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
General LArSoft Utilities.
Header file for the lar mc particle class.
std::vector< art::Ptr< recob::Hit > > HitVector
std::map< std::string, lar_content::MCProcess > MCProcessMap
std::vector< LArDetectorGap > LArDetectorGapList
TCEvent evt
Definition: DataStructs.cxx:7
helper function for LArPandoraInterface producer module
LArPandoraInput class.