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 InttTriggerTiming : 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_ = "InttTriggerTiming_run";
0063   std::string output_root_ = "";
0064   std::string output_txt_ = "";
0065   TFile* tf_output_;
0066   
0067   // objects to be output
0068   TH1D* hist_bco_diff_; // no ADC0
0069   TH1D* hist_bco_diff_raw_; // includes all hits
0070   
0071   // nodes
0072   Gl1Packet* gl1_;
0073   InttRawHitContainer* node_inttrawhit_map_;
0074   TrkrHitSetContainer* node_trkrhitset_map_; // // TRKR_HITSET (IO,TrkrHitSetContainerv1)
0075   
0076   // functions
0077   void DrawHists();
0078   vector < InttRawHit* > GetRawHits();
0079   vector < InttRawHit* > GetRawHitsWithoutClone();
0080   std::vector < std::pair < InttNameSpace::Online_s, unsigned int > >
0081     GetHits( TrkrHitSetContainer::ConstRange hitsets ); //! Draw hits and save them into a PDF file
0082   std::vector < std::pair < uint16_t, int > >
0083   GetBcoEventCounter();
0084   std::vector < int > GetTriggerBits();
0085   bool IsSame( InttRawHit* hit1, InttRawHit* hit2 );
0086   
0087   int GetNodes(PHCompositeNode *topNode);
0088 
0089   string trigger_names_[32]
0090   = {
0091     "Clock"          , "ZDC South"              , "ZDC North"               , "ZDC N&S"                 , "HCAL Singles",
0092     "HCAL Coincidence"       , ""                       , ""                        , "MBD S>=1"                , "MBD N>=1",
0093     "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",
0094     "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",
0095     "Jet 6GeV"           , "Jet 8GeV"               , "Jet 10GeV"               , "Jet 12GeV"               , "Photon 2GeV+MBD NS>=1",
0096     "Photon 3GeV+MBD NS>=1"  , "Photon 4GeV+MBD NS>=1"  , "Photon 5GeV+MBD NS>=1"
0097   };
0098 
0099 public:
0100 
0101   InttTriggerTiming(const std::string &name = "InttTriggerTiming" );
0102 
0103   ~InttTriggerTiming() override;
0104 
0105   int Init(PHCompositeNode *topNode) override;
0106 
0107   int InitRun(PHCompositeNode *topNode) override;
0108 
0109   int process_event(PHCompositeNode *topNode) override;
0110 
0111   /// Clean up internals after each event.
0112   int ResetEvent(PHCompositeNode *topNode) override;
0113 
0114   /// Called at the end of each run.
0115   int EndRun(const int runnumber) override;
0116 
0117   /// Called at the end of all processing.
0118   int End(PHCompositeNode *topNode) override;
0119 
0120   /// Reset
0121   int Reset(PHCompositeNode * /*topNode*/) override;
0122 
0123   void Print(const std::string &what = "ALL") const override;
0124 
0125   void SetOutputDir( std::string dir = "" );
0126   void SetTriggerRequirement( int val ){ required_trigger_bit_ = val;};
0127 
0128 };