Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:19:48

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