File indexing completed on 2025-08-06 08:17:31
0001 #ifndef CALORECO_BEMCREC_H
0002 #define CALORECO_BEMCREC_H
0003
0004
0005
0006
0007
0008 #include "BEmcCluster.h"
0009 #include "calobase/RawTowerGeom.h"
0010 #include "calobase/RawTowerGeomv5.h"
0011
0012 #include <algorithm> // for max
0013 #include <limits>
0014 #include <map>
0015 #include <string>
0016 #include <vector>
0017
0018 class BEmcProfile;
0019
0020 typedef struct TowerGeom
0021 {
0022 float Xcenter;
0023 float Ycenter;
0024 float Zcenter;
0025 float dX[2];
0026 float dY[2];
0027 float dZ[2];
0028 float rotX;
0029 float rotY;
0030 float rotZ;
0031
0032 } TowerGeom;
0033
0034
0035
0036 class BEmcRec
0037 {
0038 public:
0039 BEmcRec();
0040 BEmcRec &operator=(const BEmcRec &) = delete;
0041 virtual ~BEmcRec();
0042
0043 void SetVertex(const float *vv)
0044 {
0045 fVx = vv[0];
0046 fVy = vv[1];
0047 fVz = vv[2];
0048 }
0049 void SetDim(int nx, int ny)
0050 {
0051 fNx = nx;
0052 fNy = ny;
0053 }
0054
0055 bool SetTowerGeometry(int ix, int iy, const RawTowerGeom& raw_geom0);
0056 bool GetTowerGeometry(int ix, int iy, TowerGeom &geom);
0057 bool CompleteTowerGeometry();
0058 void PrintTowerGeometry(const std::string &fname);
0059 void PrintTowerGeometryDetailed(const std::string &fname);
0060
0061 void SetPlanarGeometry() { bCYL = false; }
0062 void SetCylindricalGeometry() { bCYL = true; }
0063 bool isCylindrical() const { return bCYL; }
0064
0065 void SetProfileProb(bool bprob) { bProfileProb = bprob; }
0066 void SetCalotype(int caloid) { Calorimeter_ID = caloid; }
0067 void SetScinSize(float S_S) { Scin_size = S_S; }
0068
0069 int GetNx() const { return fNx; }
0070 int GetNy() const { return fNy; }
0071 int GetCalotype() const { return Calorimeter_ID; }
0072 float GetScinSize() const { return Scin_size; }
0073 float GetVx() const { return fVx; }
0074 float GetVy() const { return fVy; }
0075 float GetVz() const { return fVz; }
0076 void SetPeakThreshold(float Thresh) { fgMinPeakEnergy = Thresh; }
0077 float GetPeakThreshold() { return fgMinPeakEnergy; }
0078 void SetTowerThreshold(float Thresh) { fgTowerThresh = Thresh; }
0079 float GetTowerThreshold() { return fgTowerThresh; }
0080
0081 void SetModules(const std::vector<EmcModule> *modules) { *fModules = *modules; }
0082 std::vector<EmcModule> *GetModules() { return fModules; }
0083 std::vector<EmcCluster> *GetClusters() { return fClusters; }
0084
0085 int iTowerDist(int ix1, int ix2) const;
0086 float fTowerDist(float x1, float x2) const;
0087
0088 int FindClusters();
0089
0090 void Momenta(std::vector<EmcModule> *, float &, float &, float &, float &, float &,
0091 float &, float thresh = 0) const;
0092
0093 void Tower2Global(float E, float xC, float yC, float &xA, float &yA, float &zA);
0094 float GetTowerEnergy(int iy, int iz, std::vector<EmcModule> *plist) const;
0095
0096 float PredictEnergy(float, float, float, int, int);
0097 float PredictEnergyProb(float en, float xcg, float ycg, int ix, int iy);
0098 virtual float PredictEnergyParam(float, float, float);
0099
0100
0101 virtual void CorrectEnergy(float energy, float , float , float &ecorr) { ecorr = energy; }
0102 virtual void CorrectECore(float ecore, float , float , float &ecorecorr) { ecorecorr = ecore; }
0103 virtual void CorrectPosition(float , float x, float y, float &xcorr, float &ycorr)
0104 {
0105 xcorr = x;
0106 ycorr = y;
0107 }
0108 virtual void CorrectShowerDepth(int , int , float , float x, float y, float z, float &xc, float &yc, float &zc)
0109 {
0110 xc = x;
0111 yc = y;
0112 zc = z;
0113 }
0114 virtual void LoadProfile(const std::string &fname);
0115 virtual void GetImpactThetaPhi(float , float , float , float &theta, float &phi)
0116 {
0117 theta = 0;
0118 phi = 0;
0119 }
0120
0121 float GetProb(std::vector<EmcModule> HitList, float e, float xg, float yg, float zg, float &chi2, int &ndf);
0122 void SetProbNoiseParam(float rn) { fgProbNoiseParam = rn; }
0123 float GetProbNoiseParam() { return fgProbNoiseParam; }
0124
0125 virtual std::string Name() const { return m_ThisName; }
0126 virtual void Name(const std::string &name) { m_ThisName = name; }
0127
0128 void set_UseDetailedGeometry(const bool useDetailedGeometry)
0129 {
0130 m_UseDetailedGeometry = useDetailedGeometry;
0131 }
0132
0133
0134 static int HitNCompare(const void *, const void *);
0135 static int HitACompare(const void *, const void *);
0136 static void CopyVector(const int *, int *, int);
0137 static void CopyVector(const EmcModule *, EmcModule *, int);
0138 static void ZeroVector(int *, int);
0139 static void ZeroVector(float *, int);
0140 static void ZeroVector(EmcModule *, int);
0141
0142 void set_UseCorrectPosition(bool useCorrectPosition) { m_UseCorrectPosition = useCorrectPosition; }
0143 void set_UseCorrectShowerDepth(bool useCorrectShowerDepth) { m_UseCorrectShowerDepth = useCorrectShowerDepth; }
0144
0145 protected:
0146
0147 bool bCYL {true};
0148 bool bProfileProb {false};
0149 int fNx {-1};
0150 int fNy {-1};
0151 std::map<int, TowerGeom> fTowerGeom;
0152 std::map<int, RawTowerGeom*> fTowerGeomDetailed;
0153 float fVx {0.};
0154 float fVy {0.};
0155 float fVz {0.};
0156
0157 std::vector<EmcModule> *fModules;
0158 std::vector<EmcCluster> *fClusters;
0159
0160 float fgProbNoiseParam {0.04};
0161 float fgTowerThresh {0.01};
0162 float fgMinPeakEnergy {0.08};
0163 static int const fgMaxLen {1000};
0164
0165 BEmcProfile *_emcprof {nullptr};
0166
0167 protected:
0168 bool m_UseDetailedGeometry {false};
0169
0170
0171
0172 bool m_UseCorrectPosition = true;
0173 bool m_UseCorrectShowerDepth = true;
0174
0175 private:
0176 std::string m_ThisName {"NOTSET"};
0177 int Calorimeter_ID {0};
0178 float Scin_size {std::numeric_limits<float>::quiet_NaN()};
0179
0180
0181 BEmcRec(const BEmcRec &) = delete;
0182 };
0183
0184 #endif