Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:39

0001 #include <string>
0002 
0003 class TH3;
0004 class TH2;
0005 template <class T>
0006 class MultiArray;
0007 
0008 // since we are never in the position of adding very large numbers to very small, floats are sufficient precision here.
0009 class ChargeMapReader
0010 {
0011  public:
0012   ChargeMapReader();  // calls the below with default values.
0013   ChargeMapReader(int _n0, float _rmin, float _rmax, int _n1, float _phimin, float _phimax, int _n2, float _zmin, float _zmax);
0014   ~ChargeMapReader() = default;
0015 
0016  private:
0017   MultiArray<float>* charge = nullptr;
0018   TH3* hSourceCharge = nullptr;
0019   TH3* hChargeDensity = nullptr;
0020   float inputAxisScale = 1;    // multiply the r and z dimensions of the input histogram by this, when filling our internal array.  So if the input histogram is in mm and we want to fill our array in cm, inputUnit=0.1;
0021   float inputChargeScale = 1;  // multiply the content the input histogram bins by this, when filling our internal array.
0022   int nBins[3] = {1, 1, 1};    // r,phi,z bins of the output fixed-width array
0023   float lowerBound[3] = {0, 0, 0};
0024   float upperBound[3] = {999, 999, 999};
0025   float binWidth[3] = {999, 999, 999};
0026 
0027   bool CanInterpolateAt(float r, float phi, float z);  // checks whether it is okay to interpolate at this position in the charge density hist
0028 
0029   void RegenerateCharge();   // internal function to revise the internal array whenever the bounds change etc.
0030   void RegenerateDensity();  // internal function to rebuild the charge density map when the input map changes.
0031 
0032  public:
0033   static bool CanInterpolateAt(float x, float y, float z, TH3* h);  // checks whether it is okay to interpolate at this position in the supplied hist (a convenient utility)
0034 
0035   void FillChargeHistogram(TH3* h);  // fill the supplied histogram with the charge in the array.
0036 
0037   void AddChargeInBin(int r, int phi, int z, float q);
0038   void AddChargeAtPosition(float r, float phi, float z, float q);
0039 
0040   float GetChargeInBin(int r, int phi, int z);
0041   float GetChargeAtPosition(float r, float phi, float z);
0042   TH3* GetDensityHistogram() { return hChargeDensity; }  // returns the charge density hist if we still have it.
0043 
0044   bool ReadSourceCharge(const std::string& filename, const std::string& histname, float axisScale = 1., float contentScale = 1.);
0045   bool ReadSourceCharge(TH3* sourceHist, float axisScale = 1., float contentScale = 1.);
0046 
0047   bool ReadSourceAdc(const std::string& adcfilename, const std::string& adchistname, const std::string& ibfgainfilename, const std::string& ibfgainhistname, float axisScale = 1., float contentScale = 1.);
0048   bool ReadSourceAdc(TH3* adcHist, TH2* gainHist, float axisScale = 1., float contentScale = 1.);
0049 
0050   void SetChargeInBin(int r, int phi, int z, float q);
0051   void SetChargeAtPosition(float r, float phi, float z, float q);
0052 
0053   bool SetOutputParameters(int _nr, float _rmin, float _rmax, int _nphi, float _phimin, float _phimax, int _nz, float _zmin, float _zmax);
0054   bool SetOutputBounds(float _rmin, float _rmax, float _phimin, float _phimax, float _zmin, float _zmax);
0055   bool SetOutputBins(int _nr, int _nphi, int _nz);
0056 };