Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:17:23

0001 #ifndef FUN4ALLRAW_SINGLEMICROMEGASPOOLINPUT_V1_H
0002 #define FUN4ALLRAW_SINGLEMICROMEGASPOOLINPUT_V1_H
0003 
0004 #include "MicromegasBcoMatchingInformation_v1.h"
0005 #include "SingleStreamingInput.h"
0006 
0007 #include <phool/PHTimer.h>
0008 
0009 #include <array>
0010 #include <list>
0011 #include <map>
0012 #include <memory>
0013 #include <set>
0014 #include <string>
0015 #include <vector>
0016 
0017 class MicromegasRawHit;
0018 class Packet;
0019 
0020 class TFile;
0021 class TH1;
0022 
0023 class SingleMicromegasPoolInput_v1 : public SingleStreamingInput
0024 {
0025  public:
0026   explicit SingleMicromegasPoolInput_v1(const std::string &name = "SingleMicromegasPoolInput_v1");
0027   ~SingleMicromegasPoolInput_v1() override;
0028   void FillPool(const unsigned int nevents = 1) override;
0029 
0030   void CleanupUsedPackets(const uint64_t bclk) override
0031   { CleanupUsedPackets(bclk,false); }
0032 
0033   void CleanupUsedPackets(const uint64_t bclk, bool /*dropped */) override;
0034 
0035   void ClearCurrentEvent() override;
0036   bool GetSomeMoreEvents();
0037   void Print(const std::string &what = "ALL") const override;
0038   void CreateDSTNode(PHCompositeNode *topNode) override;
0039 
0040   void SetBcoRange(const unsigned int value) { m_BcoRange = value; }
0041   void ConfigureStreamingInputManager() override;
0042   void SetNegativeBco(const unsigned int value) { m_NegativeBco = value; }
0043 
0044   //! define minimum pool size in terms of how many BCO are stored
0045   void SetBcoPoolSize(const unsigned int value) { m_BcoPoolSize = value; }
0046 
0047   //! save some statistics for BCO QA
0048   void FillBcoQA(uint64_t /*gtm_bco*/) override;
0049 
0050   // write the initial histograms for QA manager
0051   void createQAHistos() override;
0052 
0053  private:
0054   std::array<Packet *, 10> plist{};
0055   unsigned int m_NumSpecialEvents{0};
0056   unsigned int m_BcoRange{0};
0057   unsigned int m_NegativeBco{0};
0058 
0059   //! minimum number of BCO required in Micromegas Pools
0060   unsigned int m_BcoPoolSize{1};
0061 
0062   //! store list of packets that have data for a given beam clock
0063   /**
0064    * all packets in taggers are stored,
0065    * disregarding whether there is data associated to it or not
0066    * this allows to keep track of dropped data, also in zero-suppression mode
0067    */
0068   std::map<uint64_t, std::set<int>> m_BeamClockPacket;
0069 
0070   //! store list of FEE that have data for a given beam clock
0071   std::map<uint64_t, std::set<int>> m_BeamClockFEE;
0072 
0073   //! store list of raw hits matching a given bco
0074   std::map<uint64_t, std::vector<MicromegasRawHit *>> m_MicromegasRawHitMap;
0075 
0076   //! store current list of BCO on a per fee basis.
0077   /** only packets for which a given FEE have data are stored */
0078   std::map<int, uint64_t> m_FEEBclkMap;
0079 
0080   //! store current list of BCO
0081   /**
0082    * all packets in taggers are stored,
0083    * disregarding whether there is data associated to it or not
0084    * this allows to keep track of dropped data, also in zero-suppression mode
0085    */
0086   std::set<uint64_t> m_BclkStack;
0087 
0088   //! map bco_information_t to packet id
0089   using bco_matching_information_map_t = std::map<unsigned int, MicromegasBcoMatchingInformation_v1>;
0090   bco_matching_information_map_t m_bco_matching_information_map;
0091 
0092   // keep track of total number of waveforms per fee
0093   std::map<int,uint64_t> m_fee_waveform_count_total{};
0094 
0095   // keep track of dropped waveforms per fee, due to BCO mismatched
0096   std::map<int,uint64_t> m_fee_waveform_count_dropped_bco{};
0097 
0098   // keep track of total number of waveforms per packet
0099   std::map<int,uint64_t> m_waveform_count_total{};
0100 
0101   // keep track of dropped waveforms per packet, due to BCO mismatched
0102   std::map<int,uint64_t> m_waveform_count_dropped_bco{};
0103 
0104   // keep track of dropped waveforms per packet, due to fun4all pool mismatch
0105   std::map<int,uint64_t> m_waveform_count_dropped_pool{};
0106 
0107   // timer
0108   PHTimer m_timer{ "SingleMicromegasPoolInput_v1" };
0109 
0110   //!@name QA histograms
0111   //@{
0112 
0113   //! keeps track of how often a given (or all) packets are found for a given BCO
0114   TH1 *h_packet_stat{nullptr};
0115 
0116   //! keeps track of how many packets are found for a given BCO
0117   TH1 *h_packet{nullptr};
0118 
0119   //! keeps track of how many waveforms are found for a given BCO
0120   TH1 *h_waveform{nullptr};
0121 
0122   //! total number of waveforms per packet
0123   TH1 *h_waveform_count_total{nullptr};
0124 
0125   //! total number of dropped waveforms per packet due to bco mismatch
0126   /*! waveforms are dropped when their FEE-BCO cannot be associated to any global BCO */
0127   TH1 *h_waveform_count_dropped_bco{nullptr};
0128 
0129   //! total number of dropped waveforms per packet due to fun4all pool mismatch
0130   TH1 *h_waveform_count_dropped_pool{nullptr};
0131 
0132   //@}
0133 
0134 };
0135 
0136 #endif