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