Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:20:24

0001 // Tell emacs that this is a C++ source
0002 // //  -*- C++ -*-.
0003 #ifndef TPC_COMBINEDRAWDATAUNPACKERDEBUG_H
0004 #define TPC_COMBINEDRAWDATAUNPACKERDEBUG_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <limits>
0009 #include <map>
0010 #include <string>
0011 #include <vector>
0012 
0013 class PHCompositeNode;
0014 class CDBTTree;
0015 class CDBInterface;
0016 class TH2I;
0017 class TFile;
0018 class TNtuple;
0019 
0020 class TpcCombinedRawDataUnpackerDebug : public SubsysReco
0021 {
0022  public:
0023   TpcCombinedRawDataUnpackerDebug(std::string const &name = "TpcCombinedRawDataUnpackerDebug", std::string const &outF = "TpcCombinedRawDataUnpackerDebugOutput.root");
0024 
0025   int Init(PHCompositeNode *topNode) override;
0026   int InitRun(PHCompositeNode *) override;
0027   int process_event(PHCompositeNode *) override;
0028   int End(PHCompositeNode *topNode) override;
0029   void writeTree() { m_writeTree = true; }
0030   void do_zero_suppression(bool b) { m_do_zerosup = b; }
0031   void set_pedestalSigmaCut(float b) { m_ped_sig_cut = b; }
0032   void do_noise_rejection(bool b) { m_do_noise_rejection = b; }
0033   void doBaselineCorr(bool val) { m_do_baseline_corr = val; }
0034   void doZSEmulation(bool val) { m_do_zs_emulation = val; }
0035   void ReadZeroSuppressedData() { 
0036     m_do_zs_emulation = true;
0037     m_zs_threshold = 20;
0038   }
0039   void set_presampleShift(int b) { m_presampleShift = b; }
0040   void set_zs_threshold(int b) { m_zs_threshold = b; }
0041   void skipNevent(int b) { startevt = b; }
0042   void useRawHitNodeName(const std::string &name) { m_TpcRawNodeName = name; }
0043 
0044   void event_range(int a, int b)
0045   {
0046     startevt = a;
0047     endevt = b;
0048   }
0049   struct chan_info
0050   {
0051     unsigned int fee = std::numeric_limits<unsigned int>::max();
0052     float ped = -1;
0053     float width = -1;
0054   };
0055   unsigned int get_rx(unsigned int layer)
0056   {
0057     return (layer - 7) / 16;
0058   }
0059 
0060   unsigned int create_fee_key(unsigned int side, unsigned int sector, unsigned int rx, unsigned int fee)
0061   {
0062     unsigned int key = rx;
0063     key += side * 10;
0064     key += sector * 100;
0065     key += fee * 10000;
0066     return key;
0067   }
0068   void unpack_fee_key(unsigned int &side, unsigned int &sector, unsigned int &rx, unsigned int &fee, unsigned int fee_key)
0069   {
0070     rx = fee_key % 10;
0071     side = (fee_key % 100) / 10;
0072     sector = ((fee_key - side * 10 - rx) / 100) / 100;
0073     fee = fee_key / 10000;
0074     return;
0075   }
0076   unsigned int create_pad_key(unsigned int side, unsigned int layer, unsigned int padnum)
0077   {
0078     unsigned int key = side;
0079     key += layer * 10;
0080     key += padnum * 1000;
0081     return key;
0082   }
0083   void unpack_pad_key(unsigned int &side, unsigned int &layer, unsigned int &pad_num, unsigned int pad_key)
0084   {
0085     side = pad_key % 10;
0086     layer = (pad_key % 1000) / 10;
0087     pad_num = (pad_key - layer * 10 - side) / 1000;
0088     return;
0089   }
0090 
0091  private:
0092   TNtuple *m_ntup{nullptr};
0093   TNtuple *m_ntup_hits = nullptr;
0094   TNtuple *m_ntup_hits_corr = nullptr;
0095   TFile *m_file{nullptr};
0096   CDBTTree *m_cdbttree{nullptr};
0097   CDBInterface *m_cdb{nullptr};
0098 
0099   int m_presampleShift = 40;  // number of presamples shifted to line up t0
0100   int _ievent{0};
0101   int startevt{-1};
0102   int endevt{9999999};
0103   int mc_sectors[12]{5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6};
0104   int FEE_map[26]{4, 5, 0, 2, 1, 11, 9, 10, 8, 7, 6, 0, 1, 3, 7, 6, 5, 4, 3, 2, 0, 2, 1, 3, 5, 4};
0105   int FEE_R[26]{2, 2, 1, 1, 1, 3, 3, 3, 3, 3, 3, 2, 2, 1, 2, 2, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3};
0106 
0107   float m_ped_sig_cut{4.0};
0108 
0109   bool m_writeTree{false};
0110   bool m_do_zerosup{true};
0111   bool m_do_noise_rejection{true};
0112   bool m_do_baseline_corr{false};
0113   bool m_do_zs_emulation{false};
0114   int pedestal_offset{30};
0115   int m_zs_threshold{30};
0116   std::string m_TpcRawNodeName{"TPCRAWHIT"};
0117   std::string outfile_name;
0118   std::map<unsigned int, chan_info> chan_map;                  // stays in place
0119   std::map<unsigned int, TH2I *> feeadc_map;                   // histos reset after each event
0120   std::map<unsigned int, std::vector<float>> feebaseline_map;  // cleared after each event
0121 };
0122 
0123 #endif  // TPC_COMBINEDRAWDATAUNPACKER_H