ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BEmcRec.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BEmcRec.h
1 #ifndef CALORECO_BEMCREC_H
2 #define CALORECO_BEMCREC_H
3 
4 // Name: BEmcRec.h
5 // Author: A. Bazilevsky, Apr 2012
6 // Modified from EmcSectorRec.h and EmcScSectorRec.h
7 
8 #include "BEmcCluster.h"
9 
10 #include <map>
11 #include <string>
12 #include <vector>
13 
14 class BEmcProfile;
15 
16 typedef struct TowerGeom
17 {
18  float Xcenter; // Tower center position
19  float Ycenter;
20  float Zcenter;
21  float dX[2]; // Tower i-th trans. dimension spread in global coord X
22  float dY[2];
23  float dZ[2];
24 
25 } TowerGeom;
26 
27 // ///////////////////////////////////////////////////////////////////////////
28 
29 class BEmcRec
30 {
31  public:
32  BEmcRec();
33  virtual ~BEmcRec();
34 
35  void SetVertex(float *vv)
36  {
37  fVx = vv[0];
38  fVy = vv[1];
39  fVz = vv[2];
40  }
41  void SetDim(int nx, int ny)
42  {
43  fNx = nx;
44  fNy = ny;
45  }
46 
47  bool SetTowerGeometry(int ix, int iy, float xx, float yy, float zz);
48  bool GetTowerGeometry(int ix, int iy, TowerGeom &geom);
49  bool CompleteTowerGeometry();
50  void PrintTowerGeometry(const std::string &fname);
51 
52  void SetPlanarGeometry() { bCYL = false; }
53  void SetCylindricalGeometry() { bCYL = true; }
54  bool isCylindrical() const { return bCYL; }
55 
56  void SetProfileProb(bool bprob) { bProfileProb = bprob; }
57  void SetCalotype(int caloid) { Calorimeter_ID = caloid; }
58  void SetScinSize(float S_S) { Scin_size = S_S; }
59 
60  int GetNx() const { return fNx; }
61  int GetNy() const { return fNy; }
62  int GetCalotype() const { return Calorimeter_ID; }
63  float GetScinSize() const { return Scin_size; }
64  float GetVx() const { return fVx; }
65  float GetVy() const { return fVy; }
66  float GetVz() const { return fVz; }
67  void SetPeakThreshold(float Thresh) { fgMinPeakEnergy = Thresh; }
68  float GetPeakThreshold() { return fgMinPeakEnergy; }
69  void SetTowerThreshold(float Thresh) { fgTowerThresh = Thresh; }
70  float GetTowerThreshold() { return fgTowerThresh; }
71 
72  void SetModules(std::vector<EmcModule> const *modules) { *fModules = *modules; }
73  std::vector<EmcModule> *GetModules() { return fModules; }
74  std::vector<EmcCluster> *GetClusters() { return fClusters; }
75 
76  int iTowerDist(int ix1, int ix2);
77  float fTowerDist(float x1, float x2);
78 
79  int FindClusters();
80 
81  void Momenta(std::vector<EmcModule> *, float &, float &, float &, float &, float &,
82  float &, float thresh = 0);
83 
84  void Tower2Global(float E, float xC, float yC, float &xA, float &yA, float &zA);
85  float GetTowerEnergy(int iy, int iz, std::vector<EmcModule> *plist);
86 
87  float PredictEnergy(float, float, float, int, int);
88  float PredictEnergyProb(float en, float xcg, float ycg, int ix, int iy);
89  virtual float PredictEnergyParam(float, float, float);
90 
91  // Calorimeter specific functions to be specified in respective inherited object
92  virtual void CorrectEnergy(float energy, float /*x*/, float /*y*/, float &ecorr) { ecorr = energy; }
93  virtual void CorrectECore(float ecore, float /*x*/, float /*y*/, float &ecorecorr) { ecorecorr = ecore; }
94  virtual void CorrectPosition(float /*energy*/, float x, float y, float &xcorr, float &ycorr)
95  {
96  xcorr = x;
97  ycorr = y;
98  }
99  virtual void CorrectShowerDepth(float /*energy*/, float x, float y, float z, float &xc, float &yc, float &zc)
100  {
101  xc = x;
102  yc = y;
103  zc = z;
104  }
105  virtual void LoadProfile(const std::string &fname);
106  virtual void GetImpactThetaPhi(float /*xg*/, float /*yg*/, float /*zg*/, float &theta, float &phi)
107  {
108  theta = 0;
109  phi = 0;
110  }
111 
112  float GetProb(std::vector<EmcModule> HitList, float e, float xg, float yg, float zg, float &chi2, int &ndf);
113  void SetProbNoiseParam(float rn) { fgProbNoiseParam = rn; }
115 
116  virtual std::string Name() const { return m_ThisName; }
117  virtual void Name(const std::string &name) { m_ThisName = name; }
118 
119  // Auxiliary static functions
120  static int HitNCompare(const void *, const void *);
121  static int HitACompare(const void *, const void *);
122  static void CopyVector(int *, int *, int);
123  static void CopyVector(EmcModule *, EmcModule *, int);
124  static void ZeroVector(int *, int);
125  static void ZeroVector(float *, int);
126  static void ZeroVector(EmcModule *, int);
127 
128  protected:
129  // Geometry
130  bool bCYL = true; // Cylindrical?
131  bool bProfileProb = false;
132  int fNx = -1; // length in X direction
133  int fNy = -1; // length in Y direction
134  std::map<int, TowerGeom> fTowerGeom;
135  float fVx = 0.; // vertex position (cm)
136  float fVy = 0.;
137  float fVz = 0.;
138 
139  std::vector<EmcModule> *fModules;
140  std::vector<EmcCluster> *fClusters;
141 
142  float fgProbNoiseParam = 0.04;
143  float fgTowerThresh = 0.01;
144  float fgMinPeakEnergy = 0.08;
145  static int const fgMaxLen = 1000;
146 
147  BEmcProfile *_emcprof = nullptr;
148 
149  private:
150  std::string m_ThisName = "NOTSET";
151  int Calorimeter_ID = 0;
152  float Scin_size = NAN;
153  // the default copy ctor will not work
154  // we do not use a copy ctor, so just delete it
155  BEmcRec(const BEmcRec &) = delete;
156 };
157 
158 #endif