diff --git a/offline/packages/bcolumicount/Makefile.am b/offline/packages/bcolumicount/Makefile.am index fb546ed53a..297fc5f840 100644 --- a/offline/packages/bcolumicount/Makefile.am +++ b/offline/packages/bcolumicount/Makefile.am @@ -44,8 +44,10 @@ pkginclude_HEADERS = \ StreamingBcoInfov1.h \ StreamingLumiInfo.h \ StreamingLumiInfov1.h \ - StreamingBcoLumiReco.h \ - StreamingBcoLumiCheck.h + StreamingBcoReco.h \ + StreamingBcoCheck.h \ + StreamingLumiReco.h \ + StreamingLumiCheck.h libbcolumicount_io_la_SOURCES = \ @@ -59,8 +61,10 @@ libbcolumicount_io_la_SOURCES = \ libbcolumicount_la_SOURCES = \ BcoLumiReco.cc \ - StreamingBcoLumiReco.cc \ - StreamingBcoLumiCheck.cc + StreamingBcoReco.cc \ + StreamingBcoCheck.cc \ + StreamingLumiReco.cc \ + StreamingLumiCheck.cc BUILT_SOURCES = testexternals.cc diff --git a/offline/packages/bcolumicount/StreamingBcoCheck.cc b/offline/packages/bcolumicount/StreamingBcoCheck.cc new file mode 100644 index 0000000000..e18dfb7333 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoCheck.cc @@ -0,0 +1,69 @@ +#include "StreamingBcoCheck.h" + +//#include "BcoInfo.h" +#include "StreamingBcoInfo.h" +#include "StreamingLumiInfo.h" +//#include "BcoStreamingLumiInfov1.h" + + +#include +#include + +#include + +#include +#include // for SubsysReco +#include +#include + + +#include +#include // for PHNode +#include // for PHNodeIterator +#include +#include // for PHWHERE + + +#include + +StreamingBcoCheck::StreamingBcoCheck(const std::string &name) + : SubsysReco(name) +{ + return; +} + +int StreamingBcoCheck::Init(PHCompositeNode *topNode) +{ + int iret = CreateNodeTree(topNode); + + return iret; +} + +int StreamingBcoCheck::CreateNodeTree(PHCompositeNode *topNode) +{ + PHNodeIterator iter(topNode); + PHCompositeNode *dstNode; + dstNode = dynamic_cast(iter.findFirst("PHCompositeNode", "DST")); + if (!dstNode) + { + std::cout << PHWHERE << " DST Node is missing doing nothing" << std::endl; + return Fun4AllReturnCodes::ABORTRUN; + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingBcoCheck::process_event(PHCompositeNode *topNode) +{ + StreamingBcoInfo *streaming_bco_info = findNode::getClass(topNode, "STREAMINGBCOINFO"); + if (streaming_bco_info) + { + if (Verbosity() > 1) + { + std::cout << "bco : " << streaming_bco_info->get_bco() << std::endl; + std::cout << "usable bco tag : " << streaming_bco_info->get_usable_bco_tag() << std::endl; + std::cout << "bco streaming window : (" << streaming_bco_info->get_bco_streaming_window().first << ", " << streaming_bco_info->get_bco_streaming_window().second << ")" << std::endl; + } + } + + return Fun4AllReturnCodes::EVENT_OK; +} \ No newline at end of file diff --git a/offline/packages/bcolumicount/StreamingBcoCheck.h b/offline/packages/bcolumicount/StreamingBcoCheck.h new file mode 100644 index 0000000000..5def0f329c --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoCheck.h @@ -0,0 +1,25 @@ +#ifndef BCOLUMICOUNT_STREAMINGBCOCHECK_H +#define BCOLUMICOUNT_STREAMINGBCOCHECK_H + +#include +#include + +#include + +#include + + +class StreamingBcoCheck : public SubsysReco +{ + public: + StreamingBcoCheck(const std::string &name = "BCOCHECKSTREAMINGOUTPUT"); + ~StreamingBcoCheck() override = default; + + int Init(PHCompositeNode *topNode) override; + int process_event(PHCompositeNode *topNode) override; + + private: + static int CreateNodeTree(PHCompositeNode *topNode); +}; + +#endif // BCOLUMICOUNT_STREAMINGBCOCHECK_H diff --git a/offline/packages/bcolumicount/StreamingBcoLumiCheck.h b/offline/packages/bcolumicount/StreamingBcoLumiCheck.h deleted file mode 100644 index 579ca524c0..0000000000 --- a/offline/packages/bcolumicount/StreamingBcoLumiCheck.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef BCOLUMICOUNT_STREAMINGBCOLUMICHECK_H -#define BCOLUMICOUNT_STREAMINGBCOLUMICHECK_H - -#include -#include - -#include - -#include - - -class StreamingBcoLumiCheck : public SubsysReco -{ - public: - StreamingBcoLumiCheck(const std::string &name = "BCOLUMICHECKSTREAMINGOUTPUT"); - ~StreamingBcoLumiCheck() override = default; - - int Init(PHCompositeNode *topNode) override; - int InitRun(PHCompositeNode *topNode) override; - int process_event(PHCompositeNode *topNode) override; - - private: - static int CreateNodeTree(PHCompositeNode *topNode); -}; - -#endif // BCOLUMICOUNT_STREAMINGBCOLUMICHECK_H diff --git a/offline/packages/bcolumicount/StreamingBcoLumiReco.cc b/offline/packages/bcolumicount/StreamingBcoReco.cc similarity index 60% rename from offline/packages/bcolumicount/StreamingBcoLumiReco.cc rename to offline/packages/bcolumicount/StreamingBcoReco.cc index 1e3c66d47f..262750fcd5 100644 --- a/offline/packages/bcolumicount/StreamingBcoLumiReco.cc +++ b/offline/packages/bcolumicount/StreamingBcoReco.cc @@ -1,10 +1,8 @@ -#include "StreamingBcoLumiReco.h" +#include "StreamingBcoReco.h" #include "BcoInfo.h" #include "StreamingBcoInfo.h" #include "StreamingBcoInfov1.h" -#include "StreamingLumiInfo.h" -#include "StreamingLumiInfov1.h" #include @@ -32,7 +30,7 @@ #include -StreamingBcoLumiReco::StreamingBcoLumiReco(const std::string &name) +StreamingBcoReco::StreamingBcoReco(const std::string &name) : SubsysReco(name) { hm = new Fun4AllHistoManager("bco_histos"); @@ -41,7 +39,7 @@ StreamingBcoLumiReco::StreamingBcoLumiReco(const std::string &name) return; } -int StreamingBcoLumiReco::Init(PHCompositeNode *topNode) +int StreamingBcoReco::Init(PHCompositeNode *topNode) { int iret = CreateNodeTree(topNode); h_bco_diff = new TH1I("h_bco_diff", ";bco diff;", 3500, 0, 3500); @@ -59,27 +57,7 @@ int StreamingBcoLumiReco::Init(PHCompositeNode *topNode) return iret; } -int StreamingBcoLumiReco::InitRun(PHCompositeNode * topNode) -{ - PHNodeIterator iter(topNode); - PHCompositeNode *runNode; - runNode = dynamic_cast(iter.findFirst("PHCompositeNode", "RUN")); - if (!runNode) - { - std::cout << PHWHERE << " Run Node is missing doing nothing" << std::endl; - return Fun4AllReturnCodes::ABORTRUN; - } - m_streaming_lumi_info = findNode::getClass(topNode, "STREAMINGLUMIINFO"); - if (!m_streaming_lumi_info) - { - m_streaming_lumi_info = new StreamingLumiInfov1(); - PHIODataNode *luminode = new PHIODataNode(m_streaming_lumi_info, "STREAMINGLUMIINFO", "PHObject"); - runNode->addNode(luminode); - } - return Fun4AllReturnCodes::EVENT_OK; -} - -int StreamingBcoLumiReco::CreateNodeTree(PHCompositeNode *topNode) +int StreamingBcoReco::CreateNodeTree(PHCompositeNode *topNode) { PHNodeIterator iter(topNode); PHCompositeNode *dstNode; @@ -99,7 +77,7 @@ int StreamingBcoLumiReco::CreateNodeTree(PHCompositeNode *topNode) return Fun4AllReturnCodes::EVENT_OK; } -int StreamingBcoLumiReco::process_event(PHCompositeNode *topNode) +int StreamingBcoReco::process_event(PHCompositeNode *topNode) { BcoInfo *bcoinfo = findNode::getClass(topNode, "BCOINFO"); SyncObject *syncobject = findNode::getClass(topNode, syncdefs::SYNCNODENAME); @@ -140,17 +118,6 @@ int StreamingBcoLumiReco::process_event(PHCompositeNode *topNode) return Fun4AllReturnCodes::ABORTEVENT; } - // SYNTAX TAKEN FROM ZHIWANS CODE, why = and not +=? If this is correct it seems like a waste to call it for every event (would just need it for the last event in a particular crossing?) - m_bunchnumber_MBDNS_raw[bunchno] = packet->lValue(0, "GL1PRAW"); - m_bunchnumber_MBDNS_live[bunchno] = packet->lValue(0, "GL1PLIVE"); - m_bunchnumber_MBDNS_scaled[bunchno] = packet->lValue(0, "GL1PSCALED"); - - - if(packet->lValue(0, 0)) - { - m_rawgl1scaler = packet->lValue(0, 0); - } - delete packet; if (Verbosity() > 2) @@ -223,33 +190,6 @@ int StreamingBcoLumiReco::process_event(PHCompositeNode *topNode) h_bco_diff_trigbits[bit]->Fill(bco_diff_prev); } } - // Double check Zhiwan's logic for assigning the adjusted bunch! - int lower = m_bco_streaming_window.first - m_bco; - int upper = m_bco_streaming_window.second - m_bco; - for(int i = lower; i< upper;i++) - { - int adjusted_bunch = bunchno + i; - while (adjusted_bunch < 0) - { - adjusted_bunch += 120; - } - while (adjusted_bunch > 119) - { - adjusted_bunch -= 120; - } - // ABORT GAP! - if (adjusted_bunch>110) { continue; } - - // Make sure this is the correct way to count crossings! Need to zero out for each run! - if(i!=0 || m_usable_bco_tag) - { - m_bunchnumber_crossings[adjusted_bunch] += 1; - } - //else if (m_usable_bco_tag) - //{ - // m_bunchnumber_crossings[adjusted_bunch] += 1; - //} - } streaming_bco_info->set_bco(get_bco()); streaming_bco_info->set_usable_bco_tag(get_usable_bco_tag()); @@ -262,50 +202,3 @@ int StreamingBcoLumiReco::process_event(PHCompositeNode *topNode) } return Fun4AllReturnCodes::EVENT_OK; } - -int StreamingBcoLumiReco::EndRun(int /*runnumber*/) -{ - uint64_t rawgl1scalers_per_bunch = m_rawgl1scaler/120.; - for (int i=0; i 1) - { - std::cout << "bunchno : " << i << " lumi_raw : " << m_bunchnumber_lumi_raw[i] << std::endl; - } - } - if (!m_streaming_lumi_info) - { - std::cout << PHWHERE << " STREAMINGLUMIINFO node missing in EndRun" << std::endl; - return Fun4AllReturnCodes::ABORTRUN; - } - m_streaming_lumi_info->set_lumi_raw(get_lumi_raw()); - m_streaming_lumi_info->set_lumi_live(get_lumi_live()); - m_streaming_lumi_info->set_lumi_scaled(get_lumi_scaled()); - if (Verbosity() > 1) - { - std::cout << "MBD xsec : " << m_xsec_MBDNS << std::endl; - std::cout << "total lumi (raw) : " << m_lumi_raw << std::endl; - } - - m_bunchnumber_lumi_raw.fill(0); - m_bunchnumber_lumi_live.fill(0); - m_bunchnumber_lumi_scaled.fill(0); - m_bunchnumber_crossings.fill(0); - m_bunchnumber_MBDNS_raw.fill(0); - m_bunchnumber_MBDNS_live.fill(0); - m_bunchnumber_MBDNS_scaled.fill(0); - m_lumi_raw = 0.; - m_lumi_live = 0.; - m_lumi_scaled = 0.; - m_rawgl1scaler = 0; - - return Fun4AllReturnCodes::EVENT_OK; -} diff --git a/offline/packages/bcolumicount/StreamingBcoReco.h b/offline/packages/bcolumicount/StreamingBcoReco.h new file mode 100644 index 0000000000..b5ff71d6e7 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoReco.h @@ -0,0 +1,52 @@ +#ifndef BCOLUMICOUNT_STREAMINGBCORECO_H +#define BCOLUMICOUNT_STREAMINGBCORECO_H + +#include +#include + +#include +#include +#include + +class TH1; + +class StreamingBcoReco : public SubsysReco +{ + public: + StreamingBcoReco(const std::string &name = "STREAMINGBCOLUMIRECO"); + ~StreamingBcoReco() override = default; + + int Init(PHCompositeNode *topNode) override; + int process_event(PHCompositeNode *topNode) override; + + virtual int get_evtno() const { return m_evtno; } + + virtual uint64_t get_bco() const { return m_bco; } + + virtual bool get_usable_bco_tag() const { return m_usable_bco_tag; } + + virtual std::pair get_bco_streaming_window() const { return m_bco_streaming_window; } + + virtual void set_default_positive_window_length(int val) { m_default_positive_window_length = val; } + virtual void set_default_negative_window_length(int val) { m_default_negative_window_length = val; } + + + + private: + static int CreateNodeTree(PHCompositeNode *topNode); + const int trigbits = 40; + Fun4AllHistoManager *hm = nullptr; + TH1 *h_bco_diff = nullptr; + TH1 *h_bco_diff_trigbits[40] = {nullptr}; + TH1 *h_bco_tag = nullptr; + + uint64_t m_bco{0}; + int m_bunches = 120; + int m_evtno{0}; + bool m_usable_bco_tag = false; + std::pair m_bco_streaming_window; + unsigned int m_default_positive_window_length{340}; + unsigned int m_default_negative_window_length{20}; +}; + +#endif // BCOLUMICOUNT_STREAMINGBCORECO_H diff --git a/offline/packages/bcolumicount/StreamingBcoLumiCheck.cc b/offline/packages/bcolumicount/StreamingLumiCheck.cc similarity index 85% rename from offline/packages/bcolumicount/StreamingBcoLumiCheck.cc rename to offline/packages/bcolumicount/StreamingLumiCheck.cc index f6bf88b584..b2527bb24d 100644 --- a/offline/packages/bcolumicount/StreamingBcoLumiCheck.cc +++ b/offline/packages/bcolumicount/StreamingLumiCheck.cc @@ -1,4 +1,4 @@ -#include "StreamingBcoLumiCheck.h" +#include "StreamingLumiCheck.h" //#include "BcoInfo.h" #include "StreamingBcoInfo.h" @@ -26,20 +26,20 @@ #include -StreamingBcoLumiCheck::StreamingBcoLumiCheck(const std::string &name) +StreamingLumiCheck::StreamingLumiCheck(const std::string &name) : SubsysReco(name) { return; } -int StreamingBcoLumiCheck::Init(PHCompositeNode *topNode) +int StreamingLumiCheck::Init(PHCompositeNode *topNode) { int iret = CreateNodeTree(topNode); return iret; } -int StreamingBcoLumiCheck::InitRun(PHCompositeNode *topNode) +int StreamingLumiCheck::InitRun(PHCompositeNode *topNode) { StreamingLumiInfo *streaming_lumi_info = findNode::getClass(topNode, "STREAMINGLUMIINFO"); if (streaming_lumi_info) @@ -51,7 +51,7 @@ int StreamingBcoLumiCheck::InitRun(PHCompositeNode *topNode) return Fun4AllReturnCodes::EVENT_OK; } -int StreamingBcoLumiCheck::CreateNodeTree(PHCompositeNode *topNode) +int StreamingLumiCheck::CreateNodeTree(PHCompositeNode *topNode) { PHNodeIterator iter(topNode); PHCompositeNode *dstNode; @@ -63,8 +63,8 @@ int StreamingBcoLumiCheck::CreateNodeTree(PHCompositeNode *topNode) } return Fun4AllReturnCodes::EVENT_OK; } - -int StreamingBcoLumiCheck::process_event(PHCompositeNode *topNode) +/* +int StreamingLumiCheck::process_event(PHCompositeNode *topNode) { StreamingBcoInfo *streaming_bco_info = findNode::getClass(topNode, "STREAMINGBCOINFO"); if (streaming_bco_info) @@ -78,4 +78,5 @@ int StreamingBcoLumiCheck::process_event(PHCompositeNode *topNode) } return Fun4AllReturnCodes::EVENT_OK; -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/offline/packages/bcolumicount/StreamingLumiCheck.h b/offline/packages/bcolumicount/StreamingLumiCheck.h new file mode 100644 index 0000000000..8fc89ff5e9 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiCheck.h @@ -0,0 +1,26 @@ +#ifndef BCOLUMICOUNT_STREAMINGLUMICHECK_H +#define BCOLUMICOUNT_STREAMINGLUMICHECK_H + +#include +#include + +#include + +#include + + +class StreamingLumiCheck : public SubsysReco +{ + public: + StreamingLumiCheck(const std::string &name = "LUMICHECKSTREAMINGOUTPUT"); + ~StreamingLumiCheck() override = default; + + int Init(PHCompositeNode *topNode) override; + int InitRun(PHCompositeNode *topNode) override; + //int process_event(PHCompositeNode *topNode) override; + + private: + static int CreateNodeTree(PHCompositeNode *topNode); +}; + +#endif // BCOLUMICOUNT_STREAMINGLUMICHECK_H diff --git a/offline/packages/bcolumicount/StreamingLumiInfo.h b/offline/packages/bcolumicount/StreamingLumiInfo.h index 1644b91d3b..9bea6a3dff 100644 --- a/offline/packages/bcolumicount/StreamingLumiInfo.h +++ b/offline/packages/bcolumicount/StreamingLumiInfo.h @@ -8,6 +8,7 @@ #include #include #include +#include /// @@ -27,6 +28,15 @@ class StreamingLumiInfo : public PHObject /// isValid returns non zero if object contains valid data //int isValid() const override; + virtual const std::array get_bunchnumber_lumi_raw() const { return std::array{}; } + virtual void set_bunchnumber_lumi_raw(const std::array& /*vals*/) { return; } + + virtual const std::array get_bunchnumber_lumi_live() const { return std::array{}; } + virtual void set_bunchnumber_lumi_live(const std::array& /*vals*/) { return; } + + virtual const std::array get_bunchnumber_lumi_scaled() const { return std::array{}; } + virtual void set_bunchnumber_lumi_scaled(const std::array& /*vals*/) { return; } + virtual double get_lumi_raw() const { return 0; } virtual void set_lumi_raw(double /*val*/) { return; } diff --git a/offline/packages/bcolumicount/StreamingLumiInfov1.h b/offline/packages/bcolumicount/StreamingLumiInfov1.h index b18a8a8c89..b8993c1f8d 100644 --- a/offline/packages/bcolumicount/StreamingLumiInfov1.h +++ b/offline/packages/bcolumicount/StreamingLumiInfov1.h @@ -28,6 +28,15 @@ class StreamingLumiInfov1 : public StreamingLumiInfo /// isValid returns non zero if object contains valid data //int isValid() const override; + virtual const std::array get_bunchnumber_lumi_raw() const override { return m_bunchnumber_lumi_raw; } + virtual void set_bunchnumber_lumi_raw(const std::array& vals) override { m_bunchnumber_lumi_raw = vals; } + + virtual const std::array get_bunchnumber_lumi_live() const override { return m_bunchnumber_lumi_live; } + virtual void set_bunchnumber_lumi_live(const std::array& vals) override { m_bunchnumber_lumi_live = vals; } + + virtual const std::array get_bunchnumber_lumi_scaled() const override { return m_bunchnumber_lumi_scaled; } + virtual void set_bunchnumber_lumi_scaled(const std::array& vals) override { m_bunchnumber_lumi_scaled = vals; } + virtual double get_lumi_raw() const override { return m_lumi_raw; } virtual void set_lumi_raw(double val) override { m_lumi_raw = val; } @@ -39,12 +48,15 @@ class StreamingLumiInfov1 : public StreamingLumiInfo private: + std::array m_bunchnumber_lumi_raw{0.}; + std::array m_bunchnumber_lumi_live{0.}; + std::array m_bunchnumber_lumi_scaled{0.}; + double m_lumi_raw{0.}; double m_lumi_live{0.}; double m_lumi_scaled{0.}; - ClassDefOverride(StreamingLumiInfov1, 1) }; diff --git a/offline/packages/bcolumicount/StreamingLumiReco.cc b/offline/packages/bcolumicount/StreamingLumiReco.cc new file mode 100644 index 0000000000..d78aa69c0e --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiReco.cc @@ -0,0 +1,217 @@ +#include "StreamingLumiReco.h" + +#include "StreamingBcoInfo.h" +#include "StreamingLumiInfo.h" +#include "StreamingLumiInfov1.h" + + +#include +#include + +#include + +#include +#include // for SubsysReco +#include +#include + + +#include +#include // for PHNode +#include // for PHNodeIterator +#include +#include // for PHWHERE +#include // for MDB_NS_xsec + + +#include +#include +#include // for Packet + +#include + +#include + +StreamingLumiReco::StreamingLumiReco(const std::string &name) + : SubsysReco(name) +{ + return; +} + +int StreamingLumiReco::Init(PHCompositeNode *topNode) +{ + int iret = CreateNodeTree(topNode); + return iret; +} + +int StreamingLumiReco::InitRun(PHCompositeNode * topNode) +{ + PHNodeIterator iter(topNode); + PHCompositeNode *runNode; + runNode = dynamic_cast(iter.findFirst("PHCompositeNode", "RUN")); + if (!runNode) + { + std::cout << PHWHERE << " Run Node is missing doing nothing" << std::endl; + return Fun4AllReturnCodes::ABORTRUN; + } + m_streaming_lumi_info = findNode::getClass(topNode, "STREAMINGLUMIINFO"); + if (!m_streaming_lumi_info) + { + m_streaming_lumi_info = new StreamingLumiInfov1(); + PHIODataNode *luminode = new PHIODataNode(m_streaming_lumi_info, "STREAMINGLUMIINFO", "PHObject"); + runNode->addNode(luminode); + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingLumiReco::CreateNodeTree(PHCompositeNode *topNode) +{ + PHNodeIterator iter(topNode); + PHCompositeNode *dstNode; + dstNode = dynamic_cast(iter.findFirst("PHCompositeNode", "DST")); + if (!dstNode) + { + std::cout << PHWHERE << " DST Node is missing doing nothing" << std::endl; + return Fun4AllReturnCodes::ABORTRUN; + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingLumiReco::process_event(PHCompositeNode *topNode) +{ + StreamingBcoInfo *streaming_bcoinfo = findNode::getClass(topNode, "STREAMINGBCOINFO"); + Event *evt = findNode::getClass(topNode, "PRDF"); + if (evt) + { + if (Verbosity() > 2) + { + evt->identify(); + } + if (evt->getEvtType() != DATAEVENT) + { + return Fun4AllReturnCodes::ABORTEVENT; + } + Packet *packet = evt->getPacket(14001); + if (!packet) + { + if (Verbosity() > 0) + { + std::cout << "no gl1 packet 14001" << std::endl; + evt->identify(); + } + return Fun4AllReturnCodes::ABORTEVENT; + } + uint64_t gtm_bco = packet->lValue(0, "BCO"); + + int bunchno = packet->lValue(0,"BunchNumber"); + if (bunchno < 0 || bunchno >= m_bunches) + { + if (Verbosity() > 0) + { + std::cout << PHWHERE << " invalid bunch number: " << bunchno << std::endl; + } + delete packet; + return Fun4AllReturnCodes::ABORTEVENT; + } + + // SYNTAX TAKEN FROM ZHIWANS CODE, why = and not +=? If this is correct it seems like a waste to call it for every event (would just need it for the last event in a particular crossing?) + m_bunchnumber_MBDNS_raw[bunchno] = packet->lValue(0, "GL1PRAW"); + m_bunchnumber_MBDNS_live[bunchno] = packet->lValue(0, "GL1PLIVE"); + m_bunchnumber_MBDNS_scaled[bunchno] = packet->lValue(0, "GL1PSCALED"); + + + if(packet->lValue(0, 0)) + { + m_rawgl1scaler = packet->lValue(0, 0); + } + + delete packet; + + if (streaming_bcoinfo) + { + if (gtm_bco != streaming_bcoinfo->get_bco()) { std::cout << "BCO MISMATCH!!! : gtm_bco : " << gtm_bco << " bco " << streaming_bcoinfo->get_bco() << std::endl;} + + // Double check Zhiwan's logic for assigning the adjusted bunch! + int lower = streaming_bcoinfo->get_bco_streaming_window().first - streaming_bcoinfo->get_bco(); + int upper = streaming_bcoinfo->get_bco_streaming_window().second - streaming_bcoinfo->get_bco(); + for(int i = lower; i< upper;i++) + { + int adjusted_bunch = bunchno + i; + while (adjusted_bunch < 0) + { + adjusted_bunch += 120; + } + while (adjusted_bunch > 119) + { + adjusted_bunch -= 120; + } + // ABORT GAP! + if (adjusted_bunch>110) { continue; } + + // Make sure this is the correct way to count crossings! Need to zero out for each run! + if(i!=0 || streaming_bcoinfo->get_usable_bco_tag()) + { + m_bunchnumber_crossings[adjusted_bunch] += 1; + } + //else if (m_usable_bco_tag) + //{ + // m_bunchnumber_crossings[adjusted_bunch] += 1; + //} + } + } + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingLumiReco::EndRun(int /*runnumber*/) +{ + uint64_t rawgl1scalers_per_bunch = m_rawgl1scaler/120.; + for (int i=0; i 1) + { + std::cout << "bunchno : " << i << " lumi_raw : " << m_bunchnumber_lumi_raw[i] << std::endl; + } + } + if (!m_streaming_lumi_info) + { + std::cout << PHWHERE << " STREAMINGLUMIINFO node missing in EndRun" << std::endl; + return Fun4AllReturnCodes::ABORTRUN; + } + + m_streaming_lumi_info->set_bunchnumber_lumi_raw(get_bunchnumber_lumi_raw()); + m_streaming_lumi_info->set_bunchnumber_lumi_live(get_bunchnumber_lumi_live()); + m_streaming_lumi_info->set_bunchnumber_lumi_scaled(get_bunchnumber_lumi_scaled()); + + m_streaming_lumi_info->set_lumi_raw(get_lumi_raw()); + m_streaming_lumi_info->set_lumi_live(get_lumi_live()); + m_streaming_lumi_info->set_lumi_scaled(get_lumi_scaled()); + + if (Verbosity() > 1) + { + std::cout << "MBD xsec : " << sphenix_constants::m_xsec_MBDNS << std::endl; + std::cout << "total lumi (raw) : " << m_lumi_raw << std::endl; + } + + m_bunchnumber_lumi_raw.fill(0); + m_bunchnumber_lumi_live.fill(0); + m_bunchnumber_lumi_scaled.fill(0); + m_bunchnumber_crossings.fill(0); + m_bunchnumber_MBDNS_raw.fill(0); + m_bunchnumber_MBDNS_live.fill(0); + m_bunchnumber_MBDNS_scaled.fill(0); + m_lumi_raw = 0.; + m_lumi_live = 0.; + m_lumi_scaled = 0.; + m_rawgl1scaler = 0; + + return Fun4AllReturnCodes::EVENT_OK; +} diff --git a/offline/packages/bcolumicount/StreamingBcoLumiReco.h b/offline/packages/bcolumicount/StreamingLumiReco.h similarity index 61% rename from offline/packages/bcolumicount/StreamingBcoLumiReco.h rename to offline/packages/bcolumicount/StreamingLumiReco.h index 77e4e27f0e..7f74a30367 100644 --- a/offline/packages/bcolumicount/StreamingBcoLumiReco.h +++ b/offline/packages/bcolumicount/StreamingLumiReco.h @@ -1,5 +1,5 @@ -#ifndef BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H -#define BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H +#ifndef BCOLUMICOUNT_STREAMINGLUMIRECO_H +#define BCOLUMICOUNT_STREAMINGLUMIRECO_H #include "StreamingLumiInfo.h" @@ -12,24 +12,20 @@ class TH1; -class StreamingBcoLumiReco : public SubsysReco +class StreamingLumiReco : public SubsysReco { public: - StreamingBcoLumiReco(const std::string &name = "STREAMINGBCOLUMIRECO"); - ~StreamingBcoLumiReco() override = default; + StreamingLumiReco(const std::string &name = "STREAMINGBCOLUMIRECO"); + ~StreamingLumiReco() override = default; int Init(PHCompositeNode *topNode) override; int InitRun(PHCompositeNode *topNode) override; int process_event(PHCompositeNode *topNode) override; int EndRun(const int runnumber) override; - virtual uint64_t get_bco() const { return m_bco; } - - virtual int get_evtno() const { return m_evtno; } - - virtual bool get_usable_bco_tag() const { return m_usable_bco_tag; } - - virtual std::pair get_bco_streaming_window() const { return m_bco_streaming_window; } + virtual const std::array get_bunchnumber_lumi_raw() const { return m_bunchnumber_lumi_raw; } + virtual const std::array get_bunchnumber_lumi_live() const { return m_bunchnumber_lumi_live; } + virtual const std::array get_bunchnumber_lumi_scaled() const { return m_bunchnumber_lumi_scaled; } virtual double get_lumi_raw() const { return m_lumi_raw; } virtual double get_lumi_live() const { return m_lumi_live; } @@ -39,24 +35,14 @@ class StreamingBcoLumiReco : public SubsysReco virtual void set_default_negative_window_length(int val) { m_default_negative_window_length = val; } - private: static int CreateNodeTree(PHCompositeNode *topNode); - const int trigbits = 40; - Fun4AllHistoManager *hm = nullptr; - TH1 *h_bco_diff = nullptr; - TH1 *h_bco_diff_trigbits[40] = {nullptr}; - TH1 *h_bco_tag = nullptr; - uint64_t m_bco{0}; int m_bunches = 120; - int m_evtno{0}; - bool m_usable_bco_tag = false; - std::pair m_bco_streaming_window; unsigned int m_default_positive_window_length{340}; unsigned int m_default_negative_window_length{20}; - double m_xsec_MBDNS = 24.07*1e9; //convert to pb from Vernier scan DOUBLE CHECK VALUE! + //double m_xsec_MBDNS = 24.07*1e9; //convert to pb from Vernier scan DOUBLE CHECK VALUE! uint64_t m_rawgl1scaler{0}; @@ -78,4 +64,4 @@ class StreamingBcoLumiReco : public SubsysReco }; -#endif // BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H +#endif // BCOLUMICOUNT_STREAMINGLUMIRECO_H