Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:03

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef TPC_TPCRAWDATATREE_H
0004 #define TPC_TPCRAWDATATREE_H
0005 
0006 #include <tpc/TpcMap.h>
0007 
0008 #include <fun4all/SubsysReco.h>
0009 
0010 #include <string>
0011 #include <vector>
0012 
0013 class PHCompositeNode;
0014 class TFile;
0015 class TTree;
0016 class TH1;
0017 class TH2;
0018 
0019 //! Dump TPC raw data in PRDF format to a TTree for online debugging and seeding formal Fun4All reco/calib modules
0020 class TpcRawDataTree : public SubsysReco
0021 {
0022  public:
0023   explicit TpcRawDataTree(const std::string &fname = "TpcRawDataTree.root");
0024 
0025   ~TpcRawDataTree() override {}
0026 
0027   /** Called for first event when run number is known.
0028       Typically this is where you may want to fetch data from
0029       database, because you know the run number. A place
0030       to book histograms which have to know the run number.
0031   */
0032   int InitRun(PHCompositeNode *topNode) override;
0033 
0034   /** Called for each event.
0035       This is where you do the real work.
0036   */
0037   int process_event(PHCompositeNode *topNode) override;
0038 
0039   /// Called at the end of all processing.
0040   int End(PHCompositeNode *topNode) override;
0041 
0042   void AddPacket(int packet)
0043   {
0044     m_packets.push_back(packet);
0045   }
0046   void includeXYPos(bool doInclude)
0047   {
0048     m_includeXYPos = doInclude;
0049   }
0050 
0051  private:
0052   TH1 *R1_hist{nullptr};
0053   TH1 *R2_hist{nullptr};
0054   TH1 *R3_hist{nullptr};
0055   TH1 *TotalFEE{nullptr};
0056   TH1 *TotalFEEsampa{nullptr};
0057   TH1 *TotalFRAME{nullptr};
0058   TH1 *checksumError_fee{nullptr};
0059   TH1 *checksumError_feesampa{nullptr};
0060   TH1 *checksumError_frame{nullptr};
0061 
0062   TH2 *R1_time{nullptr};
0063   TH2 *R2_time{nullptr};
0064   TH2 *R3_time{nullptr};
0065 
0066   TFile *m_file{nullptr};
0067 
0068   TTree *m_SampleTree{nullptr};
0069   TTree *m_PacketTree{nullptr};
0070   TTree *m_TaggerTree{nullptr};
0071 
0072   uint64_t m_bco{0};
0073   uint64_t m_last_bco{0};
0074 
0075   double m_xPos{0.};
0076   double m_yPos{0.};
0077 
0078   uint32_t m_lvl1_count{0};
0079   uint32_t m_endat_count{0};
0080 
0081   int m_packet{0};
0082   int m_frame{0};
0083   int m_nWaveormInFrame{0};
0084   int m_maxFEECount{0};
0085   int m_nSamples{0};
0086   int m_fee{0};
0087   int m_sampaAddress{0};
0088   int m_sampaChannel{0};
0089   int m_Channel{0};
0090   int m_BCO{0};
0091   int m_checksum{0};
0092   int m_checksumError{0};
0093   int side{0};
0094   int m_nTaggerInFrame{0};
0095   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};
0096   int FEE_map[26]{3, 2, 5, 3, 4, 0, 2, 1, 3, 4, 5, 7, 6, 2, 0, 1, 0, 1, 4, 5, 11, 9, 10, 8, 6, 7};
0097 
0098   uint16_t m_tagger_type{0};
0099 
0100   uint8_t m_is_endat{0};
0101   uint8_t m_is_lvl1{0};
0102   uint8_t m_modebits{0};
0103 
0104   bool m_includeXYPos{true};
0105 
0106   std::string m_fname;
0107   std::string sectorNum;
0108 
0109   //! which packet to decode
0110   std::vector<int> m_packets;
0111   std::vector<unsigned short> m_adcSamples;
0112 
0113   TpcMap M;
0114 };
0115 
0116 #endif  // TpcRawDataTree_H