Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
0004 #define FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <cmath>  // for sin, asin, cos, floor, M_PI
0009 #include <map>
0010 #include <set>
0011 #include <string>
0012 #include <vector>
0013 
0014 // Forward declerations
0015 class Fun4AllHistoManager;
0016 class PHCompositeNode;
0017 class TFile;
0018 class TH1;
0019 class TH2;
0020 class TH3;
0021 class TTree;
0022 
0023 class fillSpaceChargeMaps : public SubsysReco
0024 {
0025  public:
0026   fillSpaceChargeMaps(const std::string &name = "fillSpaceChargeMaps", const std::string &filename = "Hist.root");
0027 
0028   virtual ~fillSpaceChargeMaps();
0029 
0030   /** Called during initialization.
0031       Typically this is where you can book histograms, and e.g.
0032       register them to Fun4AllServer (so they can be output to file
0033       using Fun4AllServer::dumpHistos() method).
0034    */
0035   int Init(PHCompositeNode * /*topNode*/) override;
0036 
0037   /** Called for first event when run number is known.
0038       Typically this is where you may want to fetch data from
0039       database, because you know the run number. A place
0040       to book histograms which have to know the run number.
0041    */
0042   int InitRun(PHCompositeNode * /*topNode*/) override;
0043 
0044   /** Called for each event.
0045       This is where you do the real work.
0046    */
0047   int process_event(PHCompositeNode *topNode) override;
0048 
0049   /// Called at the end of all processing.
0050   int End(PHCompositeNode * /*topNode*/) override;
0051 
0052   void SetFrequency(int freq);
0053   void SetBeamXing(const std::vector<int> &beamXs);
0054   void SetEvtStart(int newEvtStart);
0055   void SetUseIBFMap(bool useIBFMap = true);
0056   void SetGain(float ampGain = 2e3);
0057   void SetIBF(float ampIBFfrac = 0.004);
0058   void SetCollSyst(int coll_syst = 0);
0059   void SetAvg(int fAvg = 0);
0060   void UseSliming(int fSliming = 0);
0061   void UseFieldMaps(int shiftElectrons = 0);
0062 
0063  private:
0064   std::vector<double> getNewWeights(TH3 *_h_SC_ibf, TH2 *_h_modules_anode, TH2 *_h_modules_measuredibf, double _hit_r, double _hit_phi, double dr_bin, double dphi_bin, bool _fUseIBFMap);
0065   bool IsOverFrame(double r, double phi);
0066   std::vector<double> putOnPlane(double r, double phi);
0067 
0068   Fun4AllHistoManager *hm = nullptr;
0069   std::string _filename;
0070   std::set<std::string> _node_postfix;
0071   std::map<int, int> _timestamps;
0072   std::vector<int> _keys;
0073   TFile *outfile = nullptr;
0074   float _ampGain = 2e3;
0075   float _ampIBFfrac = 0.02;
0076   int _collSyst = 0;
0077   int _shiftElectrons = 0;
0078 
0079   double _freqKhz = 22;
0080   // int _beamxing = 0;
0081   std::vector<int> _beamxing;
0082   // std::vector<int> _beamxing_end;
0083 
0084   int _evtstart = 0;
0085   int _fAvg = 0;
0086   int _fSliming = 0;
0087   TTree *_rawHits = nullptr;
0088   int _isOnPlane = 0;
0089   float _hit_z = 0;
0090   float _hit_r = 0;
0091   float _hit_phi = 0;
0092   float _hit_eion = 0;
0093   float _ibf_vol = 0;
0094   float _amp_ele_vol = 0;
0095   float _event_timestamp = 0;
0096   float _event_bunchXing = 0;
0097 
0098   bool _fUseIBFMap = false;
0099   TH2 *_h_modules_anode = nullptr;
0100   TH2 *_h_modules_measuredibf = nullptr;
0101   TH1 *_h_hits = nullptr;
0102   TH1 *_h_R = nullptr;
0103   TH2 *_h_DC_E = nullptr;
0104   TH2 *_h_SC_XY = nullptr;
0105   static const int nFrames = 30;
0106   TH3 *_h_SC_prim[nFrames] = {nullptr};
0107   TH3 *_h_SC_ibf[nFrames] = {nullptr};
0108 
0109   // PHG4TpcPadPlaneReadout *padplane = nullptr;
0110   // PHG4TpcCylinderGeomContainer *seggeo = nullptr;
0111 
0112   float f = 0.5;                          // for now, just pick the middle of the hit.  Do better later.
0113   float ns = 1e-9, s = 1.0;               // us=1e-6,ms=1e-3,
0114   float mm = 1.0, cm = 10.0, m = 1000.0;  // um=1e-3,//changed to make 'cm' 1.0, for convenience.
0115   float kHz = 1e3, MHz = 1e6;             // Hz=1,
0116   float V = 1.0;
0117   // used two ways:  1) to apply units to variables when defined
0118   //                 2) to divide by certain units so that those variables are expressed in those units.
0119 
0120   // float ionMobility=3.37*cm*cm/V/s;
0121   float ionMobility = 1.65 * cm * cm / V / s;
0122   float vIon = ionMobility * 400 * V / cm;
0123   // float vIon=16.0*um/us;
0124   float mbRate = _freqKhz * kHz;
0125   float xingRate = 9.383 * MHz;
0126   // float mean = mbRate/xingRate;
0127   // float z_rdo=105.5*cm;
0128   // float rmin=20*cm;
0129   // float rmax=78*cm;
0130 
0131   double Ne_dEdx = 1.56 / cm;    // keV/cm
0132   double CF4_dEdx = 7.00 / cm;   // keV/cm
0133   double Ne_NTotal = 43 / cm;    // Number/cm
0134   double CF4_NTotal = 100 / cm;  // Number/cm
0135   // double Tpc_NTot = 0.90 * Ne_NTotal + 0.10 * CF4_NTotal;
0136   // double Tpc_dEdx = 0.90 * Ne_dEdx + 0.10 * CF4_dEdx;
0137   double Tpc_NTot = 0.50 * Ne_NTotal + 0.50 * CF4_NTotal;
0138   double Tpc_dEdx = 0.50 * Ne_dEdx + 0.50 * CF4_dEdx;
0139 
0140   // double Tpc_ElectronsPerKeV = Tpc_NTot / Tpc_dEdx;
0141   double Tpc_ElectronsPerGeV = Tpc_NTot / Tpc_dEdx * 1e6;  // electrons per gev.
0142   double phi_dead_bins[24] = {6.5314 - 2 * M_PI, 6.545 - 2 * M_PI,
0143                               0.7718, 0.7854,
0144                               1.2954, 1.309,
0145                               1.819, 1.8326,
0146                               2.3426, 2.3562,
0147                               2.8662, 2.8798,
0148                               3.3898, 3.4034,
0149                               3.9134, 3.927,
0150                               4.437, 4.4506,
0151                               4.9606, 4.9742,
0152                               5.4842, 5.4978,
0153                               6.0078, 6.0214};
0154   // int nr=159;
0155   // int nphi=360;
0156   // int nz=62*2;
0157 
0158   // double hrstep=(rmax-rmin)/nr;
0159   // double hphistep=2*pi/nphi;
0160   // double hzstep=z_rdo/nz;
0161 
0162   // int nBeams = z_rdo/(vIon/xingRate); //numaber of beamcrossings to fill TPC
0163 
0164   float _mbRate = 0;
0165   float _xingRate = 0;
0166   float _mean = 0;
0167 };
0168 
0169 #endif  // FILLSPACECHARGEMAPS_FILLSPACECHARGEMAPS_H