Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChargeMapReader.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ChargeMapReader.h
1 class TH3;
2 class TH2;
3 template <class T>
4 class MultiArray;
5 
6 // since we are never in the position of adding very large numbers to very small, floats are sufficient precision here.
8 {
9  public:
10  ChargeMapReader(); // calls the below with default values.
11  ChargeMapReader(int _n0, float _rmin, float _rmax, int _n1, float _phimin, float _phimax, int _n2, float _zmin, float _zmax);
13 
14  private:
16  TH3* hSourceCharge = nullptr;
17  TH3* hChargeDensity = nullptr;
18  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;
19  float inputChargeScale = 1; // multiply the content the input histogram bins by this, when filling our internal array.
20  int nBins[3] = {1, 1, 1}; // r,phi,z bins of the output fixed-width array
21  float lowerBound[3] = {0, 0, 0};
22  float upperBound[3] = {999, 999, 999};
23  float binWidth[3] = {999, 999, 999};
24 
25  bool CanInterpolateAt(float r, float phi, float z); // checks whether it is okay to interpolate at this position in the charge density hist
26 
27  void RegenerateCharge(); // internal function to revise the internal array whenever the bounds change etc.
28  void RegenerateDensity(); // internal function to rebuild the charge density map when the input map changes.
29 
30  public:
31  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)
32 
33  void FillChargeHistogram(TH3* h); // fill the supplied histogram with the charge in the array.
34 
35  void AddChargeInBin(int r, int phi, int z, float q);
36  void AddChargeAtPosition(float r, float phi, float z, float q);
37 
38  float GetChargeInBin(int r, int phi, int z);
39  float GetChargeAtPosition(float r, float phi, float z);
40  TH3* GetDensityHistogram() { return hChargeDensity; } // returns the charge density hist if we still have it.
41 
42  bool ReadSourceCharge(const char* filename, const char* histname, float axisScale = 1., float contentScale = 1.);
43  bool ReadSourceCharge(TH3* sourceHist, float axisScale = 1., float contentScale = 1.);
44 
45  bool ReadSourceAdc(const char* adcfilename, const char* adchistname, const char* ibfgainfilename, const char* ibfgainhistname, float axisScale = 1., float contentScale = 1.);
46  bool ReadSourceAdc(TH3* adcHist, TH2* gainHist, float axisScale = 1., float contentScale = 1.);
47 
48  void SetChargeInBin(int r, int phi, int z, float q);
49  void SetChargeAtPosition(float r, float phi, float z, float q);
50 
51  bool SetOutputParameters(int _nr, float _rmin, float _rmax, int _nphi, float _phimin, float _phimax, int _nz, float _zmin, float _zmax);
52  bool SetOutputBounds(float _rmin, float _rmax, float _phimin, float _phimax, float _zmin, float _zmax);
53  bool SetOutputBins(int _nr, int _nphi, int _nz);
54 };