Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:16:32

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef SMDHISTGEN_H
0004 #define SMDHISTGEN_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <string>
0009 #include <vector>
0010 
0011 class PHCompositeNode;
0012 class TFile;
0013 class TTree;
0014 class TH1;
0015 class TH2;
0016 class TGraphErrors;
0017 /* class Packet; */
0018 class CaloWaveformFitting;
0019 class RunHeaderv1;
0020 class TowerInfoContainer;
0021 class CaloPacketContainerv1;
0022 class CaloPacket;
0023 
0024 class SmdHistGen : public SubsysReco
0025 {
0026  public:
0027 
0028   SmdHistGen(const std::string &name = "SmdHistGen", const std::string& which_mode = "dst", const char* outname = "SmdHists.root");
0029 
0030   ~SmdHistGen() override;
0031 
0032   /** Called during initialization.
0033       Typically this is where you can book histograms, and e.g.
0034       register them to Fun4AllServer (so they can be output to file
0035       using Fun4AllServer::dumpHistos() method).
0036   */
0037   int Init(PHCompositeNode *topNode) override;
0038 
0039   /** Called for first event when run number is known.
0040       Typically this is where you may want to fetch data from
0041       database, because you know the run number. A place
0042       to book histograms which have to know the run number.
0043   */
0044   int InitRun(PHCompositeNode *topNode) override;
0045 
0046   /** Called for each event.
0047       This is where you do the real work.
0048   */
0049   int process_event(PHCompositeNode *topNode) override;
0050 
0051   /// Clean up internals after each event.
0052   int ResetEvent(PHCompositeNode *topNode) override;
0053 
0054   /// Called at the end of each run.
0055   int EndRun(const int runnumber) override;
0056 
0057   /// Called at the end of all processing.
0058   int End(PHCompositeNode *topNode) override;
0059 
0060   /// Reset
0061   int Reset(PHCompositeNode * /*topNode*/) override;
0062 
0063   void Print(const std::string &what = "ALL") const override;
0064 
0065  private:
0066   std::string mode;
0067   const char* outfilename;
0068   TFile *outfile;
0069 
0070   void GetRunNumber();
0071   int GetSpinPatterns();
0072   void GetAdcs();
0073   void GetAdcsDst();
0074   void GetAdcsRaw();
0075   void CompSmdAdc();
0076   void CompSmdPos();
0077   void CompSmdPosCorr();
0078   void CompSumSmd();
0079   void CountSMDHits();
0080   bool NeutronSelection(std::string which, bool centerCorrected = false);
0081   std::vector<float> anaWaveformFast(CaloPacket *p, const int channel);
0082   int CountAdjacentHits(std::vector<int> channels);
0083 
0084   double PI = 3.14159;
0085   static const int NBUNCHES = 120;
0086   // packet id numbers
0087   const int packet_GL1 = 14001;
0088   const int packet_blue = 14902;
0089   const int packet_yellow = 14903;
0090   const int packet_smd = 12001;
0091 
0092   // spin info
0093   int spinPatternBlue[NBUNCHES] = {0};
0094   int spinPatternYellow[NBUNCHES] = {0};
0095   int bunchNum = 0;
0096   int crossingShift = 0;
0097 
0098   // run and ZDC containers
0099   RunHeaderv1 *runHeader = nullptr;
0100   int runNum = 0;
0101   int evtctr = 0;
0102   int gl1event = 0;
0103   int smdevent = 0;
0104   TowerInfoContainer *towerinfosZDC = nullptr;
0105   CaloPacketContainerv1 *packetsZDC = nullptr;
0106   CaloWaveformFitting *WaveformProcessingFast = nullptr;
0107 
0108   // ADC and timing info
0109   float smd_adc[32] = {0.0f};
0110   float zdc_adc[16] = {0.0f};
0111   float veto_adc[4] = {0.0f};
0112   float smd_time[32] = {0.0f};
0113   float zdc_time[16] = {0.0f};
0114   float veto_time[4] = {0.0f};
0115   float smd_sum[4] = {0.0f}; 
0116   float smd_pos[4] = {0.0f};
0117   float smd_pos_corr[4] = {0.0f};
0118 
0119   float gain[32] = {0.0f};
0120   float smd_south_rgain[16] = {0.0f};
0121   float smd_north_rgain[16] = {0.0f};
0122 
0123   int n_hor_numhits  = 0;
0124   int n_ver_numhits  = 0;
0125   int s_hor_numhits = 0;
0126   int s_ver_numhits = 0;
0127 
0128   // ADC and timing cuts
0129   int minSMDcut = 5;
0130   int minZDC1cut = 100;
0131   int minZDC2cut = 15;
0132   int maxVetocut = 150;
0133   int minSMDhits = 2;
0134   float zdc_t_low = 5.5;
0135   float zdc_t_high = 9.5;
0136   float smd_north_t_low = 9.0;
0137   float smd_north_t_high = 14.5;
0138   float smd_south_t_low = 6.5;
0139   float smd_south_t_high = 12.5;
0140   float veto_north_t_low = 5.5;
0141   float veto_north_t_high = 9.5;
0142   float veto_south_t_low = 6.5;
0143   float veto_south_t_high = 12.5;
0144   float radius_low = 2.0;
0145   float radius_high = 4.0;
0146 
0147   // Histograms and graphs
0148   // hits per channel and hit multiply
0149   TH1 *smd_hor_north_total_hits = nullptr;
0150   TH1 *smd_ver_north_total_hits = nullptr;
0151   TH1 *smd_hor_north_neutron_hits = nullptr;
0152   TH1 *smd_ver_north_neutron_hits = nullptr;
0153   TH1 *smd_hor_north_multiplicity = nullptr;
0154   TH1 *smd_ver_north_multiplicity = nullptr;
0155   TH1 *smd_hor_south_total_hits = nullptr;
0156   TH1 *smd_ver_south_total_hits = nullptr;
0157   TH1 *smd_hor_south_neutron_hits = nullptr;
0158   TH1 *smd_ver_south_neutron_hits = nullptr;
0159   TH1 *smd_hor_south_multiplicity = nullptr;
0160   TH1 *smd_ver_south_multiplicity = nullptr;
0161 
0162   // signals and waveforms
0163   TH1* smd_north_signal = nullptr;
0164   TH1* smd_south_signal = nullptr;
0165   TH1* smd_north_signals[15] = {nullptr};
0166   TH1* smd_south_signals[15] = {nullptr};
0167   TH1 *smd_sum_hor_north = nullptr;
0168   TH1 *smd_sum_ver_north = nullptr;
0169   TH1 *smd_sum_hor_south = nullptr;
0170   TH1 *smd_sum_ver_south = nullptr;
0171   TH2* smd_north_waveforms = nullptr;
0172   TH2* smd_north_waveforms_zoomed = nullptr;
0173   TH2* smd_north_waveforms_raw = nullptr;
0174   TH2* smd_north_channel_waveforms[15] = {nullptr};
0175   TH2* smd_south_waveforms = nullptr;
0176   TH2* smd_south_waveforms_zoomed = nullptr;
0177   TH2* smd_south_waveforms_raw = nullptr;
0178   TH2* smd_south_channel_waveforms[15] = {nullptr};
0179   TH1* smd_north_pedestal = nullptr;
0180   TH1* smd_south_pedestal = nullptr;
0181   TH1 *zdc1_north = nullptr;
0182   TH1 *zdc2_north = nullptr;
0183   TH2* zdc_north_waveforms = nullptr;
0184   TH1 *zdc1_south = nullptr;
0185   TH1 *zdc2_south = nullptr;
0186   TH2* zdc_south_waveforms = nullptr;
0187   TH1 *vetofront_north = nullptr;
0188   TH1 *vetoback_north = nullptr;
0189   TH2* veto_north_waveforms = nullptr;
0190   TH1 *vetofront_south = nullptr;
0191   TH1 *vetoback_south = nullptr;
0192   TH2* veto_south_waveforms = nullptr;
0193 
0194   // xy distributions
0195   TH2 *smd_xy_all_north = nullptr;
0196   TH2 *smd_xy_all_corrected_north = nullptr;
0197   TH2 *smd_xy_neutron_north = nullptr;
0198   TH2 *smd_xy_neutron_corrected_north = nullptr;
0199   TH2 *smd_xy_all_south = nullptr;
0200   TH2 *smd_xy_all_corrected_south = nullptr;
0201   TH2 *smd_xy_neutron_south = nullptr;
0202   TH2 *smd_xy_neutron_corrected_south = nullptr;
0203 
0204   // 1D spin dependent x and y
0205   TH1 *smd_hor_north = nullptr;
0206   TH1 *smd_ver_north = nullptr;
0207   TH1 *smd_hor_north_up = nullptr;
0208   TH1 *smd_ver_north_up = nullptr;
0209   TH1 *smd_hor_north_down = nullptr;
0210   TH1 *smd_ver_north_down = nullptr;
0211   TH1 *smd_hor_south = nullptr;
0212   TH1 *smd_ver_south = nullptr;
0213   TH1 *smd_hor_south_up = nullptr;
0214   TH1 *smd_ver_south_up = nullptr;
0215   TH1 *smd_hor_south_down = nullptr;
0216   TH1 *smd_ver_south_down = nullptr;
0217 
0218   // beam center correction
0219   TH1 *smd_hor_north_corrected = nullptr;
0220   TH1 *smd_ver_north_corrected = nullptr;
0221   TH1 *smd_hor_north_corrected_up = nullptr;
0222   TH1 *smd_ver_north_corrected_up = nullptr;
0223   TH1 *smd_hor_north_corrected_down = nullptr;
0224   TH1 *smd_ver_north_corrected_down = nullptr;
0225   TH1 *smd_hor_south_corrected = nullptr;
0226   TH1 *smd_ver_south_corrected = nullptr;
0227   TH1 *smd_hor_south_corrected_up = nullptr;
0228   TH1 *smd_ver_south_corrected_up = nullptr;
0229   TH1 *smd_hor_south_corrected_down = nullptr;
0230   TH1 *smd_ver_south_corrected_down = nullptr;
0231 
0232   // phi distributions for asymmetry
0233   TH1 *smd_north_phi_up = nullptr;
0234   TH1 *smd_north_phi_down = nullptr;
0235   TH1 *smd_north_phi_sum = nullptr;
0236   TH1 *smd_north_phi_diff = nullptr;
0237   TH1 *smd_north_phi_L_up = nullptr;
0238   TH1 *smd_north_phi_L_down = nullptr;
0239   TH1 *smd_north_phi_R_up = nullptr;
0240   TH1 *smd_north_phi_R_down = nullptr;
0241   TH1 *smd_south_phi_up = nullptr;
0242   TH1 *smd_south_phi_down = nullptr;
0243   TH1 *smd_south_phi_sum = nullptr;
0244   TH1 *smd_south_phi_diff = nullptr;
0245   TH1 *smd_south_phi_L_up = nullptr;
0246   TH1 *smd_south_phi_L_down = nullptr;
0247   TH1 *smd_south_phi_R_up = nullptr;
0248   TH1 *smd_south_phi_R_down = nullptr;
0249 
0250   // beam center correction
0251   TH1 *smd_north_phi_up_corrected = nullptr;
0252   TH1 *smd_north_phi_down_corrected = nullptr;
0253   TH1 *smd_north_phi_sum_corrected = nullptr;
0254   TH1 *smd_north_phi_diff_corrected = nullptr;
0255   TH1 *smd_north_phi_L_up_corrected = nullptr;
0256   TH1 *smd_north_phi_L_down_corrected = nullptr;
0257   TH1 *smd_north_phi_R_up_corrected = nullptr;
0258   TH1 *smd_north_phi_R_down_corrected = nullptr;
0259   TH1 *smd_south_phi_up_corrected = nullptr;
0260   TH1 *smd_south_phi_down_corrected = nullptr;
0261   TH1 *smd_south_phi_sum_corrected = nullptr;
0262   TH1 *smd_south_phi_diff_corrected = nullptr;
0263   TH1 *smd_south_phi_L_up_corrected = nullptr;
0264   TH1 *smd_south_phi_L_down_corrected = nullptr;
0265   TH1 *smd_south_phi_R_up_corrected = nullptr;
0266   TH1 *smd_south_phi_R_down_corrected = nullptr;
0267 
0268 };
0269 
0270 #endif // SMDHISTGEN_H