Belle II Software  release-06-00-14
ECLLocalMaximumFinderModule.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 
9 #pragma once
10 
11 // FRAMEWORK
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/gearbox/Unit.h>
15 #include <framework/geometry/B2Vector3.h> // faster than TVector3
16 
17 class TTree;
18 class TFile;
19 
20 namespace Belle2 {
26  class MCParticle;
27  class ECLHit;
28  class ECLDigit;
29  class ECLCalDigit;
30  class ECLLocalMaximum;
31  class ECLConnectedRegion;
32 
33  namespace ECL {
34  class ECLNeighbours;
35  class ECLGeometryPar;
36  }
37 
43 
44  public:
47 
50 
52  virtual void initialize() override;
53 
55  virtual void beginRun() override;
56 
58  virtual void event() override;
59 
61  virtual void endRun() override;
62 
64  virtual void terminate() override;
65 
68 
71 
74 
77 
80 
83 
85  virtual const char* mcParticleArrayName() const
86  { return "MCParticles" ; }
87 
89  virtual const char* eclHitArrayName() const
90  { return "ECLHits" ; }
91 
93  virtual const char* eclDigitArrayName() const
94  { return "ECLDigits" ; }
95 
97  virtual const char* eclCalDigitArrayName() const
98  { return "ECLCalDigits" ; }
99 
101  virtual const char* eclConnectedRegionArrayName() const
102  { return "ECLConnectedRegions" ; }
103 
105  virtual const char* eclLocalMaximumArrayName() const
106  { return "ECLLocalMaximums" ; }
107 
110 
112  void resetTrainingVariables();
113 
115  void makeLocalMaximum(const ECLConnectedRegion& aCR, const int cellId, const int lmId);
116 
118  void addToSignalEnergy(int motherpdg, int motherindex, int pi0index, double weight);
119 
121  bool isEnteringECL(const B2Vector3D& vec);
122 
124  void getEnteringMother(const MCParticle& particle, int& pdg, int& arrayindex, int& pi0arrayindex);
125 
127  int getIdPosition(const int type, const int id);
128 
130  void getMax(int& maxtype, int& maxpos);
131 
132  private:
133 
134  // Module parameters
135  double m_energyCut;
137  std::string m_outfileName;
138  std::string m_method;
140  double m_cutOffset;
141  double m_cutSlope;
144  // Constants
145  const double c_minEnergyCut = 5.0 * Belle2::Unit::MeV;
148  std::vector< int > m_StoreArrPosition;
149 
152 
155 
157  TFile* m_outfile{nullptr};
158  TTree* m_tree{nullptr};
161  const static unsigned c_nMaxNeighbours = 12;
163  float m_time = 0.0;
166  float m_energy = 0.0;
167  float m_thetaId = 0.0;
168  float m_phiId = 0.0;
169  float m_cellId = 0.0;
170  float m_maxNeighbourEnergy = 0.0;
171  float m_timeResolution = 0.0;
172  float m_timeFitFailed = 0.0;
173  float m_CRId = 0.0;
174  float m_LMId = 0.0;
177  float m_target = 0.0;
178  float m_targetindex = 0.0;
179  float m_targetpi0index = 0.0;
182  float m_nNeighbours10 = 0.0;
183  float m_maxEnergyRatio = 0.0;
185  double m_totalSignalEnergy = 0.0;
186  double m_signalEnergy[10][5] {};
187  int m_signalId[10][5] {};
188  };
189 
192  public:
194  //virtual const char* eclHitArrayName() const override
195  //{ return "ECLHitsPureCsI" ; }
196 
198  virtual const char* eclDigitArrayName() const override
199  { return "ECLDigitsPureCsI" ; }
200 
202  virtual const char* eclCalDigitArrayName() const override
203  { return "ECLCalDigitsPureCsI" ; }
204 
206  virtual const char* eclConnectedRegionArrayName() const override
207  { return "ECLConnectedRegionsPureCsI" ; }
208 
210  virtual const char* eclLocalMaximumArrayName() const override
211  { return "ECLLocalMaximumsPureCsI" ; }
212 
213  }; // end of ECLLocalMaximumFinderPureCsIModule
214 
216 } // end of Belle2 namespace
Class to store connected regions (CRs)
virtual const char * eclDigitArrayName() const
Name to be used for default or PureCsI option: ECLDigits.
TTree * m_tree
tree that contain information for MVA training
double m_cutRatioCorrection
correction for nominator and denominator of the ratio.
double m_signalEnergy[10][5]
total energy per MC matching type of this digit
void getEnteringMother(const MCParticle &particle, int &pdg, int &arrayindex, int &pi0arrayindex)
Get enterging mother of this particle.
StoreArray< ECLConnectedRegion > m_eclConnectedRegions
Store array: ECLConnectedRegion.
float m_energyRatioNeighbour[c_nMaxNeighbours]
energy ratio of neighbour 0..9 to center
double m_totalSignalEnergy
total energy of this digit
float m_phiId
local maximum center theta Id
virtual void initialize() override
Initialize.
StoreArray< ECLLocalMaximum > m_eclLocalMaximums
Store array: ECLLocalMaximum.
float m_cellId
local maximum center cell Id
int getIdPosition(const int type, const int id)
Get Id position in the vector.
float m_energy
Variables to monitor the MVA training.
std::string m_method
Method to find the local maximum.
virtual void terminate() override
Terminate (close ROOT files here if you have opened any).
std::string m_outfileName
file name prefix of the training output file
StoreArray< ECLDigit > m_eclDigits
Store array: ECLDigit.
ECL::ECLNeighbours * m_neighbourMap
Neighbour maps.
void makeLocalMaximum(const ECLConnectedRegion &aCR, const int cellId, const int lmId)
Make local maximum for a given connected region.
void resetClassifierVariables()
Reset Classifier Variables.
float m_thetaId
local maximum center theta Id
float m_maxNeighbourEnergy
highest energy of all neighbours
bool isEnteringECL(const B2Vector3D &vec)
Check if particle is produced outside of the ECL.
TFile * m_outfile
Output training files and trees.
void addToSignalEnergy(int motherpdg, int motherindex, int pi0index, double weight)
Add energy to vector.
virtual const char * mcParticleArrayName() const
MCParticles.
StoreArray< ECLHit > m_eclHits
Store array: ECLHit.
virtual const char * eclHitArrayName() const
Name to be used for default or PureCsI option: ECLHits.
static const unsigned c_nMaxNeighbours
Variables (possibly) used for MVA classification.
StoreArray< MCParticle > m_mcParticles
Store array: MCParticle.
float m_maxEnergyRatio
Highest energetic neighbour energy divided by LM energy.
int m_signalId[10][5]
total energy per MC matching type of this digit
const double c_minEnergyCut
Minimum LM energy.
virtual const char * eclCalDigitArrayName() const
Name to be used for default or PureCsI option: ECLCalDigits.
std::vector< int > m_StoreArrPosition
vector (8736+1 entries) with cell id to store array positions
void resetTrainingVariables()
Reset Debug Variables.
void getMax(int &maxtype, int &maxpos)
Get the highest energy deposition particle type.
StoreArray< ECLCalDigit > m_eclCalDigits
Store array: ECLCalDigit.
int m_isTrainingMode
training mode for MVA methods (i.e.
float m_nNeighbours10
Variables (possibly) used for cut classification.
virtual const char * eclConnectedRegionArrayName() const
Name to be used for default option: ECLConnectedRegions.
virtual const char * eclLocalMaximumArrayName() const
Name to be used for default option: ECLLocalMaximums.
Class to find connected regions, pureCsI version.
virtual const char * eclConnectedRegionArrayName() const override
Name to be used for PureCsI option: ECLConnectedRegionsPureCsI.
virtual const char * eclLocalMaximumArrayName() const override
Name to be used for PureCsI option: ECLLocalMaximumsPureCsI.
virtual const char * eclCalDigitArrayName() const override
Name to be used for PureCsI option: ECLCalDigitsPureCsI.
virtual const char * eclDigitArrayName() const override
Name to be used for PureCsI option: ECLHitsPureCsI.
The Class for ECL Geometry Parameters.
Class to get the neighbours for a given cell id.
Definition: ECLNeighbours.h:23
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
static const double MeV
[megaelectronvolt]
Definition: Unit.h:114
Abstract base class for different kinds of events.