diff --git a/offline/packages/bcolumicount/BcoLumiCheck.cc b/offline/packages/bcolumicount/BcoLumiCheck.cc deleted file mode 100644 index 3ba12f1776..0000000000 --- a/offline/packages/bcolumicount/BcoLumiCheck.cc +++ /dev/null @@ -1,71 +0,0 @@ -#include "BcoLumiCheck.h" - -#include "BcoInfo.h" - -#include -#include - -#include - -#include -#include // for SubsysReco - -#include -#include // for PHNode -#include // for PHNodeIterator -#include -#include // for PHWHERE - -#include - -BcoLumiCheck::BcoLumiCheck(const std::string &name) - : SubsysReco(name) -{ - return; -} - -int BcoLumiCheck::Init(PHCompositeNode *topNode) -{ - int iret = CreateNodeTree(topNode); - return iret; -} - -int BcoLumiCheck::InitRun(PHCompositeNode * /*topNode*/) -{ - return Fun4AllReturnCodes::EVENT_OK; -} - -int BcoLumiCheck::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 BcoLumiCheck::process_event(PHCompositeNode *topNode) -{ - BcoInfo *bcoinfo = findNode::getClass(topNode, "BCOINFO"); - SyncObject *syncobject = findNode::getClass(topNode, syncdefs::SYNCNODENAME); - Gl1Packet *gl1packet = findNode::getClass(topNode, 14001); - if (gl1packet) - { - std::cout << "Event No: " << syncobject->EventNumber() << std::hex - << " gl1: bco 0x" << gl1packet->lValue(0, "BCO") << std::dec << std::endl; - if (bcoinfo) - { - std::cout << "prev event: " << bcoinfo->get_previous_evtno() << std::hex - << " bco: 0x" << bcoinfo->get_previous_bco() << std::dec << std::endl; - std::cout << "curr event: " << bcoinfo->get_current_evtno() << std::hex - << " bco: 0x" << bcoinfo->get_current_bco() << std::dec << std::endl; - std::cout << "futu event: " << bcoinfo->get_future_evtno() << std::hex - << " bco: 0x" << bcoinfo->get_future_bco() << std::dec << std::endl; - } - } - return Fun4AllReturnCodes::EVENT_OK; -} diff --git a/offline/packages/bcolumicount/BcoLumiCheck.h b/offline/packages/bcolumicount/BcoLumiCheck.h deleted file mode 100644 index 75477dea98..0000000000 --- a/offline/packages/bcolumicount/BcoLumiCheck.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef BCOLUMICOUNT_BCOLUMICHECK_H -#define BCOLUMICOUNT_BCOLUMICHECK_H - -#include - -#include - -class BcoLumiCheck : public SubsysReco -{ - public: - BcoLumiCheck(const std::string &name = "BCOLUMICHECK"); - ~BcoLumiCheck() 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_BCOLUMICHECK_H diff --git a/offline/packages/bcolumicount/Makefile.am b/offline/packages/bcolumicount/Makefile.am index 70afc9b224..fb546ed53a 100644 --- a/offline/packages/bcolumicount/Makefile.am +++ b/offline/packages/bcolumicount/Makefile.am @@ -21,11 +21,16 @@ libbcolumicount_la_LIBADD = \ libbcolumicount_io.la \ -lffaobjects \ -lffarawobjects \ - -lSubsysReco + -lSubsysReco \ + -lfun4all ROOTDICTS = \ BcoInfo_Dict.cc \ - BcoInfov1_Dict.cc + BcoInfov1_Dict.cc \ + StreamingBcoInfo_Dict.cc \ + StreamingBcoInfov1_Dict.cc \ + StreamingLumiInfo_Dict.cc \ + StreamingLumiInfov1_Dict.cc pcmdir = $(libdir) # more elegant way to create pcm files (without listing them) @@ -34,18 +39,28 @@ nobase_dist_pcm_DATA = $(ROOTDICTS:.cc=_rdict.pcm) pkginclude_HEADERS = \ BcoInfo.h \ BcoInfov1.h \ - BcoLumiCheck.h \ - BcoLumiReco.h + BcoLumiReco.h \ + StreamingBcoInfo.h \ + StreamingBcoInfov1.h \ + StreamingLumiInfo.h \ + StreamingLumiInfov1.h \ + StreamingBcoLumiReco.h \ + StreamingBcoLumiCheck.h libbcolumicount_io_la_SOURCES = \ $(ROOTDICTS) \ BcoInfo.cc \ - BcoInfov1.cc + BcoInfov1.cc \ + StreamingBcoInfo.cc \ + StreamingBcoInfov1.cc \ + StreamingLumiInfo.cc \ + StreamingLumiInfov1.cc libbcolumicount_la_SOURCES = \ - BcoLumiCheck.cc \ - BcoLumiReco.cc + BcoLumiReco.cc \ + StreamingBcoLumiReco.cc \ + StreamingBcoLumiCheck.cc BUILT_SOURCES = testexternals.cc diff --git a/offline/packages/bcolumicount/StreamingBcoInfo.cc b/offline/packages/bcolumicount/StreamingBcoInfo.cc new file mode 100644 index 0000000000..1519f90368 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfo.cc @@ -0,0 +1,23 @@ +#include "StreamingBcoInfo.h" + +#include + +#include + +void StreamingBcoInfo::Reset() +{ + std::cout << PHWHERE << "ERROR Reset() not implemented by daughter class" << std::endl; + return; +} + +void StreamingBcoInfo::identify(std::ostream& os) const +{ + os << "identify yourself: virtual StreamingBcoInfo Object" << std::endl; + return; +} + +//int BcoStreamingLumiInfo::isValid() const +//{ +// std::cout << PHWHERE << "isValid not implemented by daughter class" << std::endl; +// return 0; +//} diff --git a/offline/packages/bcolumicount/StreamingBcoInfo.h b/offline/packages/bcolumicount/StreamingBcoInfo.h new file mode 100644 index 0000000000..5b8fe2b943 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfo.h @@ -0,0 +1,53 @@ +// Tell emacs that this is a C++ source +// -*- C++ -*-. +#ifndef BCOLLUMICOUNT_STREAMINGBCOINFO_H +#define BCOLLUMICOUNT_STREAMINGBCOINFO_H + +#include + +#include +#include +#include + + +/// +class StreamingBcoInfo : public PHObject +{ + public: + /// ctor - daughter class copy ctor needs this + StreamingBcoInfo() = default; + /// dtor + ~StreamingBcoInfo() override = default; + /// Clear Sync + void Reset() override; + + /** identify Function from PHObject + @param os Output Stream + */ + void identify(std::ostream& os = std::cout) const override; + + /// isValid returns non zero if object contains valid data + //int isValid() const override; + + virtual uint64_t get_bco() const { return 0; } + + virtual void set_bco(uint64_t /*val*/) { return; } + + virtual int get_evtno() const { return 0; } + + virtual void set_evtno(int /*val*/) { return; } + + virtual bool get_usable_bco_tag() const { return 0; } + + virtual void set_usable_bco_tag(bool /*val*/) { return; } + + virtual std::pair get_bco_streaming_window() const { return std::make_pair(0, 0); } + + virtual void set_bco_streaming_window(std::pair /*val*/) { return; } + + + private: + ClassDefOverride(StreamingBcoInfo, 1) +}; + +#endif diff --git a/offline/packages/bcolumicount/StreamingBcoInfoLinkDef.h b/offline/packages/bcolumicount/StreamingBcoInfoLinkDef.h new file mode 100644 index 0000000000..d01df73556 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfoLinkDef.h @@ -0,0 +1,5 @@ +#ifdef __CINT__ + +#pragma link C++ class StreamingBcoInfo + ; + +#endif diff --git a/offline/packages/bcolumicount/StreamingBcoInfov1.cc b/offline/packages/bcolumicount/StreamingBcoInfov1.cc new file mode 100644 index 0000000000..9b97dd855e --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfov1.cc @@ -0,0 +1,24 @@ +#include "StreamingBcoInfov1.h" + +#include + +#include + +void StreamingBcoInfov1::Reset() +{ + set_bco(0); + set_usable_bco_tag(false); + set_bco_streaming_window(std::make_pair(0, 0)); + return; +} + +void StreamingBcoInfov1::identify(std::ostream& os) const +{ + os << "identify yourself: I am a StreamingBcoInfov1 Object\n"; return; +} + +//int StreamingBcoInfov1::isValid() const +//{ +// std::cout << PHWHERE << "isValid not implemented by daughter class" << std::endl; +// return 0; +//} diff --git a/offline/packages/bcolumicount/StreamingBcoInfov1.h b/offline/packages/bcolumicount/StreamingBcoInfov1.h new file mode 100644 index 0000000000..ebbcadd123 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfov1.h @@ -0,0 +1,55 @@ +// Tell emacs that this is a C++ source +// -*- C++ -*-. +#ifndef BCOLLUMICOUNT_STREAMINGBCOINFOV1_H +#define BCOLLUMICOUNT_STREAMINGBCOINFOV1_H + +#include "StreamingBcoInfo.h" + + +#include +#include +#include + + +/// +class StreamingBcoInfov1 : public StreamingBcoInfo +{ + public: + /// ctor - daughter class copy ctor needs this + StreamingBcoInfov1() = default; + /// dtor + ~StreamingBcoInfov1() override = default; + /// Clear Sync + void Reset() override; + + /** identify Function from PHObject + @param os Output Stream + */ + void identify(std::ostream& os = std::cout) const override; + + /// isValid returns non zero if object contains valid data + //int isValid() const override; + + virtual uint64_t get_bco() const override { return m_bco; } + virtual void set_bco(uint64_t val) override { m_bco = val; } + + virtual int get_evtno() const override { return m_evtno; } + virtual void set_evtno(int val) override { m_evtno = val; } + + virtual bool get_usable_bco_tag() const override { return m_usable_bco_tag; } + virtual void set_usable_bco_tag(bool val) override { m_usable_bco_tag = val; } + + virtual std::pair get_bco_streaming_window() const override { return m_bco_streaming_window; } + virtual void set_bco_streaming_window(std::pair val) override { m_bco_streaming_window = val; } + + + private: + uint64_t m_bco{0}; + int m_evtno{0}; + bool m_usable_bco_tag{false}; + std::pair m_bco_streaming_window; + + ClassDefOverride(StreamingBcoInfov1, 1) +}; + +#endif diff --git a/offline/packages/bcolumicount/StreamingBcoInfov1LinkDef.h b/offline/packages/bcolumicount/StreamingBcoInfov1LinkDef.h new file mode 100644 index 0000000000..dc98f8629e --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoInfov1LinkDef.h @@ -0,0 +1,6 @@ +#ifdef __CINT__ + +#pragma link C++ class StreamingBcoInfov1 + ; +#pragma link C++ class std::pair + ; + +#endif diff --git a/offline/packages/bcolumicount/StreamingBcoLumiCheck.cc b/offline/packages/bcolumicount/StreamingBcoLumiCheck.cc new file mode 100644 index 0000000000..f6bf88b584 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoLumiCheck.cc @@ -0,0 +1,81 @@ +#include "StreamingBcoLumiCheck.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 + +StreamingBcoLumiCheck::StreamingBcoLumiCheck(const std::string &name) + : SubsysReco(name) +{ + return; +} + +int StreamingBcoLumiCheck::Init(PHCompositeNode *topNode) +{ + int iret = CreateNodeTree(topNode); + + return iret; +} + +int StreamingBcoLumiCheck::InitRun(PHCompositeNode *topNode) +{ + StreamingLumiInfo *streaming_lumi_info = findNode::getClass(topNode, "STREAMINGLUMIINFO"); + if (streaming_lumi_info) + { + std::cout << " raw lumi : " << streaming_lumi_info->get_lumi_raw() << std::endl; + std::cout << " live lumi : " << streaming_lumi_info->get_lumi_live() << std::endl; + std::cout << " scaled lumi : " << streaming_lumi_info->get_lumi_scaled() << std::endl; + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingBcoLumiCheck::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 StreamingBcoLumiCheck::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/StreamingBcoLumiCheck.h b/offline/packages/bcolumicount/StreamingBcoLumiCheck.h new file mode 100644 index 0000000000..579ca524c0 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoLumiCheck.h @@ -0,0 +1,26 @@ +#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/StreamingBcoLumiReco.cc new file mode 100644 index 0000000000..29b6ae794b --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoLumiReco.cc @@ -0,0 +1,281 @@ +#include "StreamingBcoLumiReco.h" + +#include "BcoInfo.h" +#include "StreamingBcoInfo.h" +#include "StreamingBcoInfov1.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 +#include +#include // for Packet + +#include + +StreamingBcoLumiReco::StreamingBcoLumiReco(const std::string &name) + : SubsysReco(name) +{ + hm = new Fun4AllHistoManager("bco_histos"); + Fun4AllServer *se = Fun4AllServer::instance(); + se->registerHistoManager(hm); + return; +} + +int StreamingBcoLumiReco::Init(PHCompositeNode *topNode) +{ + int iret = CreateNodeTree(topNode); + h_bco_diff = new TH1I("h_bco_diff", ";bco diff;", 3500, 0, 3500); + std::string hist_name = "h_bco_diff_bit"; + for (int bit=0; bitregisterHisto(h_bco_diff_trigbits[bit]); + } + h_bco_tag = new TH1I("h_bco_tag", ";usable bco tag;", 2, -0.5, 1.5); + hm->registerHisto(h_bco_diff); + hm->registerHisto(h_bco_tag); + + 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) +{ + 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; + } + StreamingBcoInfo *streaming_bco_info = findNode::getClass(topNode, "STREAMINGBCOINFO"); + if (!streaming_bco_info) + { + streaming_bco_info = new StreamingBcoInfov1(); + PHIODataNode *bconode = new PHIODataNode(streaming_bco_info, "STREAMINGBCOINFO", "PHObject"); + dstNode->addNode(bconode); + } + return Fun4AllReturnCodes::EVENT_OK; +} + +int StreamingBcoLumiReco::process_event(PHCompositeNode *topNode) +{ + BcoInfo *bcoinfo = findNode::getClass(topNode, "BCOINFO"); + SyncObject *syncobject = findNode::getClass(topNode, syncdefs::SYNCNODENAME); + //Gl1Packet *gl1packet = findNode::getClass(topNode, 14001); + 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"); + uint64_t gl1_scaledvec = packet->lValue(0, "ScaledVector"); + //uint64_t gl1_livevec = packet->lValue(0, "TriggerVector"); + + int bunchno = packet->lValue(0,"BunchNumber"); + + // 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) + { + std::cout << "Event No: " << syncobject->EventNumber() /*<< std::hex*/ + << " gl1 bco: " << gtm_bco < 2) + { + std::cout << "prev event: " << bcoinfo->get_previous_evtno() /*<< std::hex*/ + << " bco: " << bcoinfo->get_previous_bco() << std::dec << std::endl; + std::cout << "curr event: " << bcoinfo->get_current_evtno() /*<< std::hex*/ + << " bco: " << bcoinfo->get_current_bco() << std::dec << std::endl; + std::cout << "futu event: " << bcoinfo->get_future_evtno() /*<< std::hex*/ + << " bco: " << bcoinfo->get_future_bco() << std::dec << std::endl; + } + + StreamingBcoInfo *streaming_bco_info = findNode::getClass(topNode, "STREAMINGBCOINFO"); + m_bco = bcoinfo->get_current_bco(); + if (gtm_bco != m_bco) { std::cout << "BCO MISMATCH!!! : gtm_bco : " << gtm_bco << " m_bco " << m_bco << std::endl;} + uint64_t bco_prev = bcoinfo->get_previous_bco(); + uint64_t bco_futu = bcoinfo->get_future_bco(); + uint64_t bco_diff_prev = m_bco - bco_prev; + uint64_t bco_diff_futu = bco_futu - m_bco; + + // TODO: Set BCO window length in the macro + // TODO: Set BCO Negative window length in the macro + // window length: 360, negative window length: 20 + // Therefore, should check if BCO is within 340 + // special case if BCO is within 20 of previous BCO? + if (bco_diff_prev < 340) + { + m_usable_bco_tag = true; + } + else + { + m_usable_bco_tag = false; + } + if (bco_diff_futu < 340) + { + // double check boundaries for overlap!! + m_bco_streaming_window = std::make_pair(get_bco() - 20, bco_futu - 21); + } + else + { + m_bco_streaming_window = std::make_pair(get_bco() - 20, get_bco() + 340); + } + if (Verbosity() > 2) + { + std::cout << "bco_diff_prev : " << bco_diff_prev << std::endl; + std::cout << "bco_diff_futu : " << bco_diff_futu << std::endl; + } + h_bco_diff->Fill(bco_diff_prev); + h_bco_tag->Fill(m_usable_bco_tag); + for (int bit=0; bit> static_cast(bit)) & 0x1U) == 0x1U; + //bool scaled_trigger_fired = ((gl1_scaledvec >> bit) & 0x1U) == 0x1U; + + if (trigger_fired) + { + 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()); + streaming_bco_info->set_bco_streaming_window(get_bco_streaming_window()); + } + } + 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; + } + } + 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); + + return Fun4AllReturnCodes::EVENT_OK; +} diff --git a/offline/packages/bcolumicount/StreamingBcoLumiReco.h b/offline/packages/bcolumicount/StreamingBcoLumiReco.h new file mode 100644 index 0000000000..51b6f349ef --- /dev/null +++ b/offline/packages/bcolumicount/StreamingBcoLumiReco.h @@ -0,0 +1,78 @@ +#ifndef BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H +#define BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H + +#include +#include +#include "StreamingLumiInfo.h" + +#include +#include +#include + +#include + + +class StreamingBcoLumiReco : public SubsysReco +{ + public: + StreamingBcoLumiReco(const std::string &name = "BCOLUMICHECK"); + ~StreamingBcoLumiReco() 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 double get_lumi_raw() const { return m_lumi_raw; } + virtual double get_lumi_live() const { return m_lumi_live; } + virtual double get_lumi_scaled() const { return m_lumi_scaled; } + + + + + + private: + static int CreateNodeTree(PHCompositeNode *topNode); + const int trigbits = 40; + Fun4AllHistoManager *hm = nullptr; + TH1I *h_bco_diff = nullptr; + TH1I *h_bco_diff_trigbits[40] = {nullptr}; + TH1I *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; + + double m_xsec_MBDNS = 24.07*1e9; //convert to pb from Vernier scan DOUBLE CHECK VALUE! + + uint64_t m_rawgl1scaler{0}; + + std::array m_bunchnumber_MBDNS_raw{0}; + std::array m_bunchnumber_MBDNS_live{0}; + std::array m_bunchnumber_MBDNS_scaled{0}; + + std::array m_bunchnumber_crossings{0}; + + 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.}; + + StreamingLumiInfo *m_streaming_lumi_info = nullptr; + +}; + +#endif // BCOLUMICOUNT_STREAMINGBCOLUMIRECO_H diff --git a/offline/packages/bcolumicount/StreamingLumiInfo.cc b/offline/packages/bcolumicount/StreamingLumiInfo.cc new file mode 100644 index 0000000000..753f82a858 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfo.cc @@ -0,0 +1,23 @@ +#include "StreamingLumiInfo.h" + +#include + +#include + +void StreamingLumiInfo::Reset() +{ + std::cout << PHWHERE << "ERROR Reset() not implemented by daughter class" << std::endl; + return; +} + +void StreamingLumiInfo::identify(std::ostream& os) const +{ + os << "identify yourself: virtual StreamingLumiInfo Object" << std::endl; + return; +} + +//int StreamingLumiInfo::isValid() const +//{ +// std::cout << PHWHERE << "isValid not implemented by daughter class" << std::endl; +// return 0; +//} diff --git a/offline/packages/bcolumicount/StreamingLumiInfo.h b/offline/packages/bcolumicount/StreamingLumiInfo.h new file mode 100644 index 0000000000..8c68be22d9 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfo.h @@ -0,0 +1,46 @@ +// Tell emacs that this is a C++ source +// -*- C++ -*-. +#ifndef BCOLLUMICOUNT_STREAMINGLUMIINFO_H +#define BCOLLUMICOUNT_STREAMINGLUMIINFO_H + +#include + +#include +#include +#include + + +/// +class StreamingLumiInfo : public PHObject +{ + public: + /// ctor - daughter class copy ctor needs this + StreamingLumiInfo() = default; + /// dtor + ~StreamingLumiInfo() override = default; + /// Clear Sync + void Reset() override; + + /** identify Function from PHObject + @param os Output Stream + */ + void identify(std::ostream& os = std::cout) const override; + + /// isValid returns non zero if object contains valid data + //int isValid() const override; + + virtual double get_lumi_raw() const { return 0; } + virtual void set_lumi_raw(double /*val*/) { return; } + + virtual double get_lumi_live() const { return 0; } + virtual void set_lumi_live(double /*val*/) { return; } + + virtual double get_lumi_scaled() const { return 0; } + virtual void set_lumi_scaled(double /*val*/) { return; } + + + private: + ClassDefOverride(StreamingLumiInfo, 1) +}; + +#endif diff --git a/offline/packages/bcolumicount/StreamingLumiInfoLinkDef.h b/offline/packages/bcolumicount/StreamingLumiInfoLinkDef.h new file mode 100644 index 0000000000..098d7b8de3 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfoLinkDef.h @@ -0,0 +1,5 @@ +#ifdef __CINT__ + +#pragma link C++ class StreamingLumiInfo + ; + +#endif diff --git a/offline/packages/bcolumicount/StreamingLumiInfov1.cc b/offline/packages/bcolumicount/StreamingLumiInfov1.cc new file mode 100644 index 0000000000..8b554564ce --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfov1.cc @@ -0,0 +1,26 @@ +#include "StreamingLumiInfov1.h" + +#include + +#include + +void StreamingLumiInfov1::Reset() +{ + // Double check that this is only called once per run!! Or... it should just be called in the InitRun hook? + set_lumi_raw(0.); + set_lumi_live(0.); + set_lumi_scaled(0.); + + return; +} + +void StreamingLumiInfov1::identify(std::ostream& os) const +{ + os << "identify yourself: I am a StreamingLumiInfov1 Object\n"; return; +} + +//int StreamingLumiInfov1::isValid() const +//{ +// std::cout << PHWHERE << "isValid not implemented by daughter class" << std::endl; +// return 0; +//} diff --git a/offline/packages/bcolumicount/StreamingLumiInfov1.h b/offline/packages/bcolumicount/StreamingLumiInfov1.h new file mode 100644 index 0000000000..b25f1af295 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfov1.h @@ -0,0 +1,53 @@ +// Tell emacs that this is a C++ source +// -*- C++ -*-. +#ifndef BCOLLUMICOUNT_STREAMINGLUMIINFOV1_H +#define BCOLLUMICOUNT_STREAMINGLUMIINFOV1_H + +#include "StreamingLumiInfo.h" + + +#include +#include +#include + + +/// +class StreamingLumiInfov1 : public StreamingLumiInfo +{ + public: + /// ctor - daughter class copy ctor needs this + StreamingLumiInfov1() = default; + /// dtor + ~StreamingLumiInfov1() override = default; + /// Clear Sync + void Reset() override; + + /** identify Function from PHObject + @param os Output Stream + */ + void identify(std::ostream& os = std::cout) const override; + + /// isValid returns non zero if object contains valid data + //int isValid() const override; + + virtual double get_lumi_raw() const override { return m_lumi_raw; } + virtual void set_lumi_raw(double val) override { m_lumi_raw = val; } + + virtual double get_lumi_live() const override { return m_lumi_live; } + virtual void set_lumi_live(double val) override { m_lumi_live = val; } + + virtual double get_lumi_scaled() const override { return m_lumi_scaled; } + virtual void set_lumi_scaled(double val) override { m_lumi_scaled = val; } + + + private: + double m_lumi_raw{0.}; + double m_lumi_live{0.}; + double m_lumi_scaled{0.}; + + + + ClassDefOverride(StreamingLumiInfov1, 1) +}; + +#endif diff --git a/offline/packages/bcolumicount/StreamingLumiInfov1LinkDef.h b/offline/packages/bcolumicount/StreamingLumiInfov1LinkDef.h new file mode 100644 index 0000000000..7f59d1e0d1 --- /dev/null +++ b/offline/packages/bcolumicount/StreamingLumiInfov1LinkDef.h @@ -0,0 +1,5 @@ +#ifdef __CINT__ + +#pragma link C++ class StreamingLumiInfov1 + ; + +#endif