Belle II Software  release-08-01-10
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 /* Basf2 headers. */
12 #include <framework/core/Module.h>
13 #include <framework/datastore/StoreArray.h>
14 #include <framework/datastore/StoreObjPtr.h>
15 #include <framework/gearbox/Unit.h>
16 #include <framework/geometry/B2Vector3.h>
17 #include <mdst/dataobjects/EventLevelClusteringInfo.h>
18 
19 class TTree;
20 class TFile;
21 
22 namespace Belle2 {
28  class MCParticle;
29  class ECLHit;
30  class ECLDigit;
31  class ECLCalDigit;
32  class ECLLocalMaximum;
33  class ECLConnectedRegion;
34 
35  namespace ECL {
36  class ECLNeighbours;
37  class ECLGeometryPar;
38  }
39 
45 
46  public:
49 
52 
54  virtual void initialize() override;
55 
57  virtual void beginRun() override;
58 
60  virtual void event() override;
61 
63  virtual void endRun() override;
64 
66  virtual void terminate() override;
67 
70 
73 
76 
79 
82 
85 
88 
90  virtual const char* mcParticleArrayName() const
91  { return "MCParticles" ; }
92 
94  virtual const char* eclHitArrayName() const
95  { return "ECLHits" ; }
96 
98  virtual const char* eclDigitArrayName() const
99  { return "ECLDigits" ; }
100 
102  virtual const char* eclCalDigitArrayName() const
103  { return "ECLCalDigits" ; }
104 
106  virtual const char* eclConnectedRegionArrayName() const
107  { return "ECLConnectedRegions" ; }
108 
110  virtual const char* eclLocalMaximumArrayName() const
111  { return "ECLLocalMaximums" ; }
112 
115 
117  void resetTrainingVariables();
118 
120  void makeLocalMaximum(const ECLConnectedRegion& aCR, const int cellId, const int lmId);
121 
123  void addToSignalEnergy(int motherpdg, int motherindex, int pi0index, double weight);
124 
126  bool isEnteringECL(const B2Vector3D& vec);
127 
129  void getEnteringMother(const MCParticle& particle, int& pdg, int& arrayindex, int& pi0arrayindex);
130 
132  int getIdPosition(const int type, const int id);
133 
135  void getMax(int& maxtype, int& maxpos);
136 
137  private:
138 
139  // Module parameters
140  double m_energyCut;
142  std::string m_outfileName;
143  std::string m_method;
145  double m_cutOffset;
146  double m_cutSlope;
149  // Constants
150  const double c_minEnergyCut = 5.0 * Belle2::Unit::MeV;
153  std::vector< int > m_StoreArrPosition;
154 
157 
160 
162  TFile* m_outfile{nullptr};
163  TTree* m_tree{nullptr};
166  const static unsigned c_nMaxNeighbours = 12;
168  float m_time = 0.0;
171  float m_energy = 0.0;
172  float m_thetaId = 0.0;
173  float m_phiId = 0.0;
174  float m_cellId = 0.0;
175  float m_maxNeighbourEnergy = 0.0;
176  float m_timeResolution = 0.0;
177  float m_timeFitFailed = 0.0;
178  float m_CRId = 0.0;
179  float m_LMId = 0.0;
182  float m_target = 0.0;
183  float m_targetindex = 0.0;
184  float m_targetpi0index = 0.0;
187  float m_nNeighbours10 = 0.0;
188  float m_maxEnergyRatio = 0.0;
190  double m_totalSignalEnergy = 0.0;
191  double m_signalEnergy[10][5] {};
192  int m_signalId[10][5] {};
193  };
194 
197  public:
199  //virtual const char* eclHitArrayName() const override
200  //{ return "ECLHitsPureCsI" ; }
201 
203  virtual const char* eclDigitArrayName() const override
204  { return "ECLDigitsPureCsI" ; }
205 
207  virtual const char* eclCalDigitArrayName() const override
208  { return "ECLCalDigitsPureCsI" ; }
209 
211  virtual const char* eclConnectedRegionArrayName() const override
212  { return "ECLConnectedRegionsPureCsI" ; }
213 
215  virtual const char* eclLocalMaximumArrayName() const override
216  { return "ECLLocalMaximumsPureCsI" ; }
217 
218  }; // end of ECLLocalMaximumFinderPureCsIModule
219 
221 } // 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 (ECLElementNumbers::c_NCrystals + 1 entries) with cell id to store array positions
StoreObjPtr< EventLevelClusteringInfo > m_eventLevelClusteringInfo
EventLevelClusteringInfo.
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:25
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:32
Base class for Modules.
Definition: Module.h:72
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
static const double MeV
[megaelectronvolt]
Definition: Unit.h:114
Abstract base class for different kinds of events.