Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:01

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #pragma once
0004 
0005 // std libraries
0006 #include <string>
0007 #include <iostream>
0008 #include <iomanip>
0009 #include <vector>
0010 #include <fstream>
0011 
0012 // ROOT libraries
0013 #include <TH2D.h>
0014 #include <TH1D.h>
0015 #include <TCanvas.h>
0016 #include <TStyle.h>
0017 #include <TFile.h>
0018 
0019 // Fun4All libraries
0020 #include <fun4all/SubsysReco.h>
0021 #include <fun4all/Fun4AllReturnCodes.h>
0022 
0023 #include <phool/PHCompositeNode.h>
0024 #include <phool/getClass.h>
0025 #include <phool/recoConsts.h>
0026 
0027 #include <trackbase/InttDefs.h>
0028 //#include <trackbase/InttEventInfo.h>
0029 #include <trackbase/InttEventInfov1.h>
0030 //#include <trackbase/TrkrHitSetContainer.h>
0031 #include <trackbase/TrkrHitSetContainerv1.h>
0032 //#include <trackbase/TrkrHitSetContainerv2.h>
0033 #include <trackbase/TrkrHitSetv1.h>
0034 #include <trackbase/TrkrHitv1.h>
0035 #include <trackbase/TrkrDefs.h>
0036 
0037 #include <ffaobjects/FlagSavev1.h>
0038 #include <ffarawobjects/InttRawHit.h>
0039 #include <ffarawobjects/InttRawHitContainer.h>
0040 #include <ffarawobjects/Gl1RawHitv2.h> // v2 <-- v1 <-- v0 : confirmed, it has to be so
0041 #include <ffarawobjects/Gl1Packetv2.h>
0042 
0043 #include <intt/InttMapping.h>
0044 #include <intt/InttDacMap.h>
0045 
0046 #include "InttQaCommon.h"
0047 
0048 class PHCompositeNode;
0049 
0050 class InttStreamingTiming : public SubsysReco
0051 {
0052 private:
0053 
0054   // general variables
0055   int run_num_ = 0;
0056   int event_counter_ = 0;
0057   int event_counter_by_myself_  = 0; // because the event counter is not reliable, I count it by myself for histogram normalization
0058   int required_trigger_bit_ = -1;
0059   
0060   // variables for the output
0061   std::string output_dir_ = "./results/";
0062   std::string output_basename_ = "InttStreamingTiming_run";
0063   std::string output_root_ = "";
0064   std::string output_txt_ = "";
0065   std::ofstream ofs_;
0066   TFile* tf_output_;
0067   
0068   // objects to be output
0069   TH1D* hist_fphx_bco_; // no ADC0
0070   TH1D* hist_fphx_bco_raw_; // includes all hits
0071   TH1D* hist_streaming_offset_; // INTT hit BCO - GL1 BCO = (INTT GTM BCO + FPHX BCO) - GL1 BCO
0072   
0073   int event_max_ = 10000;
0074   
0075   // nodes
0076   Gl1Packet* gl1_;
0077   InttRawHitContainer* node_inttrawhit_map_;
0078   TrkrHitSetContainer* node_trkrhitset_map_; // // TRKR_HITSET (IO,TrkrHitSetContainerv1)
0079   
0080   // functions
0081   void DrawHists();
0082   vector < InttRawHit* > GetRawHits();
0083   vector < InttRawHit* > GetRawHitsWithoutClone();
0084   std::vector < std::pair < InttNameSpace::Online_s, unsigned int > >
0085     GetHits( TrkrHitSetContainer::ConstRange hitsets ); //! Draw hits and save them into a PDF file
0086   std::vector < std::pair < uint16_t, int > >
0087   GetBcoEventCounter();
0088   std::vector < int > GetTriggerBits();
0089   bool IsSame( InttRawHit* hit1, InttRawHit* hit2 );
0090   
0091   int GetNodes(PHCompositeNode *topNode);
0092 
0093   string trigger_names_[32]
0094   = {
0095     "Clock"          , "ZDC South"              , "ZDC North"               , "ZDC N&S"                 , "HCAL Singles",
0096     "HCAL Coincidence"       , ""                       , ""                        , "MBD S>=1"                , "MBD N>=1",
0097     "MBD N&S>=1"         , "MBD N&S>=2"             , "MBD N&S>=1, vtx<10cm"    , "MBD N&S>=1, vtx<30cm"    , "MBD N&S>=1, vtx<60cm",
0098     "HCAL Singles+MBD NS>=1" , "Jet 6GeV+MBD NS>=1"     , "Jet 8GeV+MBD NS>=1"      , "Jet 10GeV+MBD NS>=1"     , "Jet 12GeV+MBD NS>=1",
0099     "Jet 6GeV"           , "Jet 8GeV"               , "Jet 10GeV"               , "Jet 12GeV"               , "Photon 2GeV+MBD NS>=1",
0100     "Photon 3GeV+MBD NS>=1"  , "Photon 4GeV+MBD NS>=1"  , "Photon 5GeV+MBD NS>=1"
0101   };
0102 
0103 public:
0104 
0105   InttStreamingTiming(const std::string &name = "InttStreamingTiming" );
0106 
0107   ~InttStreamingTiming() override;
0108 
0109   int Init(PHCompositeNode *topNode) override;
0110 
0111   int InitRun(PHCompositeNode *topNode) override;
0112 
0113   int process_event(PHCompositeNode *topNode) override;
0114 
0115   /// Clean up internals after each event.
0116   int ResetEvent(PHCompositeNode *topNode) override;
0117 
0118   /// Called at the end of each run.
0119   int EndRun(const int runnumber) override;
0120 
0121   /// Called at the end of all processing.
0122   int End(PHCompositeNode *topNode) override;
0123 
0124   /// Reset
0125   int Reset(PHCompositeNode * /*topNode*/) override;
0126 
0127   void Print(const std::string &what = "ALL") const override;
0128 
0129   // 
0130   int GetEventMax(){ return event_max_;};
0131 
0132   void SetOutputDir( std::string dir = "" );
0133   void SetMaxEvent( int num ){ event_max_ = num;};
0134   void SetTriggerRequirement( int val ){ required_trigger_bit_ = val;};
0135 
0136 };