Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "Fun4AllStreamingLumiCountingInputManager.h"
0002 
0003 #include <fun4allraw/InputManagerType.h>
0004 #include "SingleStreamingInputv2.h"
0005 
0006 #include <ffarawobjects/Gl1Packet.h>
0007 
0008 #include <fun4all/Fun4AllHistoManager.h>
0009 #include <fun4all/Fun4AllInputManager.h>  // for Fun4AllInputManager
0010 #include <fun4all/Fun4AllReturnCodes.h>
0011 #include <fun4all/Fun4AllServer.h>
0012 #include <fun4all/Fun4AllSyncManager.h>
0013 
0014 #include <ffaobjects/SyncObject.h>  // for SyncObject
0015 #include <ffaobjects/SyncObjectv1.h>
0016 
0017 #include <frog/FROG.h>
0018 #include <qautils/QAHistManagerDef.h>
0019 #include <qautils/QAUtil.h>
0020 
0021 #include <phool/PHObject.h>  // for PHObject
0022 #include <phool/getClass.h>
0023 #include <phool/phool.h>  // for PHWHERE
0024 #include <boost/format.hpp>
0025 
0026 #include <TFile.h>
0027 #include <TH1.h>
0028 #include <TSystem.h>
0029 #include <TTree.h>
0030 
0031 #include <algorithm>  // for max
0032 #include <cassert>
0033 #include <cstdint>  // for uint64_t, uint16_t
0034 #include <cstdlib>
0035 #include <iostream>  // for operator<<, basic_ostream, endl
0036 #include <utility>   // for pair
0037 
0038 Fun4AllStreamingLumiCountingInputManager::Fun4AllStreamingLumiCountingInputManager(const std::string &name, const std::string &dstnodename, const std::string &topnodename)
0039   : Fun4AllInputManager(name, dstnodename, topnodename)
0040   , m_SyncObject(new SyncObjectv1())
0041 {
0042   Fun4AllServer *se = Fun4AllServer::instance();
0043   m_topNode = se->topNode(TopNodeName());
0044 
0045   createLuminosityHistos();
0046   return;
0047 }
0048 
0049 Fun4AllStreamingLumiCountingInputManager::~Fun4AllStreamingLumiCountingInputManager()
0050 {
0051   if (IsOpen())
0052   {
0053     fileclose();
0054   }
0055   //  std::cout<<"----Write? files to output.root"<<std::endl;
0056 
0057   delete m_SyncObject;
0058   // clear leftover raw event maps and vectors with poolreaders
0059   // GL1
0060   for (auto iter : m_Gl1InputVector)
0061   {
0062     delete iter;
0063   }
0064 
0065   m_Gl1InputVector.clear();
0066 }
0067 
0068 int Fun4AllStreamingLumiCountingInputManager::run(const int /*nevents*/)
0069 {
0070   int iret = 0;
0071   if (m_gl1_registered_flag)  // Gl1 first to get the reference
0072   {
0073     iret += FillGl1();
0074   }
0075   /*   std::cout<<"----Storing files to output.root"<<std::endl;
0076     tfile = TFile::Open(m_outputFileName.c_str(), "RECREATE", "");//UPDATE
0077     ttree->Write("", TObject::kOverwrite);
0078     h_lumibco->Write("", TObject::kOverwrite);
0079     h_bunchnumber->Write("", TObject::kOverwrite);
0080     h_bunchnumber_occur->Write("", TObject::kOverwrite);
0081     tfile->Close();
0082     delete tfile;
0083   */
0084   return iret;
0085 }
0086 
0087 void Fun4AllStreamingLumiCountingInputManager::SetOutputFileName(const std::string &fileName)
0088 {
0089   m_outputFileName = fileName;  // Update the filename
0090 }
0091 
0092 int Fun4AllStreamingLumiCountingInputManager::fileclose()
0093 {
0094   //  std::cout<<"----fileclose()"<<std::endl;
0095   //  QAHistManagerDef::saveQARootFile(m_output_file);
0096   return 0;
0097 }
0098 
0099 void Fun4AllStreamingLumiCountingInputManager::Print(const std::string &what) const
0100 {
0101   if (what == "ALL" || what == "INPUTFILES")
0102   {
0103     std::cout << "-----------------------------" << std::endl;
0104     for (const auto &iter : m_Gl1InputVector)
0105     {
0106       std::cout << "Single Streaming Input Manager " << iter->Name() << " reads run "
0107                 << iter->RunNumber()
0108                 << " from file " << iter->FileName()
0109                 << std::endl;
0110     }
0111   }
0112   Fun4AllInputManager::Print(what);
0113   return;
0114 }
0115 
0116 int Fun4AllStreamingLumiCountingInputManager::ResetEvent()
0117 {
0118   // zhiwan
0119   // m_RefBCO = 0;
0120   return 0;
0121 }
0122 
0123 int Fun4AllStreamingLumiCountingInputManager::PushBackEvents(const int /*i*/)
0124 {
0125   return 0;
0126 }
0127 
0128 int Fun4AllStreamingLumiCountingInputManager::GetSyncObject(SyncObject **mastersync)
0129 {
0130   // here we copy the sync object from the current file to the
0131   // location pointed to by mastersync. If mastersync is a 0 pointer
0132   // the syncobject is cloned. If mastersync allready exists the content
0133   // of syncobject is copied
0134   if (!(*mastersync))
0135   {
0136     if (m_SyncObject)
0137     {
0138       *mastersync = dynamic_cast<SyncObject *>(m_SyncObject->CloneMe());
0139       assert(*mastersync);
0140     }
0141   }
0142   else
0143   {
0144     *(*mastersync) = *m_SyncObject;  // copy syncobject content
0145   }
0146   return Fun4AllReturnCodes::SYNC_OK;
0147 }
0148 
0149 int Fun4AllStreamingLumiCountingInputManager::SyncIt(const SyncObject *mastersync)
0150 {
0151   if (!mastersync)
0152   {
0153     std::cout << PHWHERE << Name() << " No MasterSync object, cannot perform synchronization" << std::endl;
0154     std::cout << "Most likely your first file does not contain a SyncObject and the file" << std::endl;
0155     std::cout << "opened by the Fun4AllDstInputManager with Name " << Name() << " has one" << std::endl;
0156     std::cout << "Change your macro and use the file opened by this input manager as first input" << std::endl;
0157     std::cout << "and you will be okay. Fun4All will not process the current configuration" << std::endl
0158               << std::endl;
0159     return Fun4AllReturnCodes::SYNC_FAIL;
0160   }
0161   int iret = m_SyncObject->Different(mastersync);
0162   if (iret)
0163   {
0164     std::cout << "big problem" << std::endl;
0165     exit(1);
0166   }
0167   return Fun4AllReturnCodes::SYNC_OK;
0168 }
0169 
0170 std::string Fun4AllStreamingLumiCountingInputManager::GetString(const std::string &what) const
0171 {
0172   std::cout << PHWHERE << " called with " << what << " , returning empty string" << std::endl;
0173   return "";
0174 }
0175 
0176 void Fun4AllStreamingLumiCountingInputManager::registerStreamingInput(SingleStreamingInputv2 *evtin, InputManagerType::enu_subsystem system)
0177 {
0178   evtin->StreamingLumiInputManager(this);
0179   // if the streaming flag is set, we only want the first event from the GL1 to
0180   // get the starting BCO of that run which enables us to dump all the junk which
0181   // is taken before the run starts in the streaming systems. But we don't want the
0182   // GL1 in the output, so we do not create its dst node if running in streaming
0183   if (system == InputManagerType::GL1)
0184   {
0185     if (!m_StreamingFlag)
0186     {
0187       evtin->CreateDSTNode(m_topNode);
0188     }
0189   }
0190   else
0191   {
0192     evtin->CreateDSTNode(m_topNode);
0193   }
0194   evtin->ConfigureStreamingInputManager();
0195   if (system == InputManagerType::GL1)
0196   {
0197     m_gl1_registered_flag = true;
0198     m_Gl1InputVector.push_back(evtin);
0199   }
0200   else
0201   {
0202     std::cout << "invalid subsystem flag " << system << std::endl;
0203     gSystem->Exit(1);
0204     exit(1);
0205   }
0206   if (Verbosity() > 3)
0207   {
0208     std::cout << "registering " << evtin->Name()
0209               << " number of registered inputs: "
0210               << m_Gl1InputVector.size()
0211               << std::endl;
0212   }
0213   std::cout << m_Gl1InputVector.size() << std::endl;
0214 }
0215 
0216 void Fun4AllStreamingLumiCountingInputManager::AddGl1RawHit(uint64_t bclk, Gl1Packet *hit)
0217 {
0218   m_Gl1RawHitMap[bclk].Gl1RawHitVector.push_back(hit);
0219 }
0220 
0221 void Fun4AllStreamingLumiCountingInputManager::AddGl1Window(uint64_t bco_trim, int negative_window, int positive_window)
0222 {
0223   m_BCOWindows[bco_trim] = std::make_pair(bco_trim - negative_window, bco_trim + positive_window);
0224 }
0225 
0226 void Fun4AllStreamingLumiCountingInputManager::AddGl1BunchNumber(uint64_t bco_trim, int bunch_number)
0227 {
0228   m_BCOBunchNumber[bco_trim] = bunch_number;
0229 }
0230 
0231 int Fun4AllStreamingLumiCountingInputManager::FillGl1()
0232 {
0233   // unsigned int alldone = 0;
0234   for (auto iter : m_Gl1InputVector)
0235   {
0236     if (Verbosity() > 0)
0237     {
0238       std::cout << "Fun4AllStreamingLumiCountingInputManager::FillGl1 - fill pool for " << iter->Name() << std::endl;
0239       std::cout << "Run number " << iter->RunNumber() << std::endl;
0240     }
0241     iter->FillPool();
0242 
0243     if (m_RunNumber == 0)
0244     {
0245       m_RunNumber = iter->RunNumber();
0246       SetRunNumber(m_RunNumber);
0247     }
0248     else
0249     {
0250       if (m_RunNumber != iter->RunNumber())
0251       {
0252         std::cout << PHWHERE << " Run Number mismatch, run is "
0253                   << m_RunNumber << ", " << iter->Name() << " reads "
0254                   << iter->RunNumber() << std::endl;
0255         std::cout << "You are likely reading files from different runs, do not do that" << std::endl;
0256         Print("INPUTFILES");
0257         gSystem->Exit(1);
0258         exit(1);
0259       }
0260     }
0261   }
0262 
0263   if (Verbosity() > 0)
0264   {
0265     std::cout << "Here BCO " << m_BCOWindows.begin()->first << " left " << m_BCOWindows.begin()->second.first << " right " << m_BCOWindows.begin()->second.second << std::endl;
0266   }
0267   /*
0268   for (const auto &entry : m_BCOWindows) {
0269       uint64_t key = entry.first;
0270       uint64_t valueFirst = entry.second.first;
0271       uint64_t valueSecond = entry.second.second;
0272       std::cout << "Key: " << key
0273                 << ", Value First: " << valueFirst
0274                 << ", Value Second: " << valueSecond
0275                 << std::endl;
0276   }
0277 
0278   for (const auto& [bco_trim, bunch_number] : m_BCOBunchNumber) {
0279       std::cout << "Here BCO " << bco_trim << " Bunch Number " << bunch_number << std::endl;
0280   }
0281   */
0282   // std::cout << "Here BCO " <<m_BCOWindows.begin()->first <<std::endl;
0283 
0284   if (m_BCOWindows.size() > 1)
0285   {
0286     auto first_element = m_BCOWindows.begin();
0287     auto second_element = std::next(m_BCOWindows.begin());
0288     //  std::cout<<"Key 1: "<<first_element->first<<" Value ( "<<first_element->second.first<<" , "<<first_element->second.second<<std::endl;
0289     //  std::cout<<"Key 2: "<<second_element->first<<" Value ( "<<second_element->second.first<<" , "<<second_element->second.second<<std::endl;
0290     //  std::cout<<second_element->first - first_element->first<<" compared with window "<< m_negative_bco_window+m_positive_bco_window <<std::endl;
0291     // constexpr uint64_t MAX_40BIT_VALUE = 0xFFFFFFFFFF;
0292 
0293     // special case for overflow: second_element - first_element > 1099511000000, then switch them
0294     m_diffBCO = second_element->first - first_element->first;
0295 
0296     if (second_element->first - first_element->first > 1099510000000)
0297     {
0298       flat_overflow = true;
0299       // int temp_m_diffBCO=first_element->first+1099511627775+1-second_element->first;
0300       bco_temp = first_element->first;
0301       m_BCOWindows.erase(m_BCOWindows.begin());
0302       bco_temp += 1099511627775 + 1;
0303       m_BCOWindows[bco_temp] = std::make_pair(bco_temp - m_negative_bco_window, bco_temp + m_positive_bco_window);
0304       first_element = m_BCOWindows.begin();
0305       second_element = std::next(m_BCOWindows.begin());
0306       m_diffBCO = second_element->first - first_element->first;
0307       std::cout << "overflow new diff " << m_diffBCO << " new first element " << first_element->first << " new second element " << second_element->first << std::endl;
0308     }
0309     h_diffbco->Fill(m_diffBCO);
0310     if (m_diffBCO < static_cast<int>(m_negative_bco_window + m_positive_bco_window))
0311     {
0312       m_BCOWindows.begin()->second.second = second_element->second.first;
0313       std::cout << "*** new Key 1 BCO " << m_BCOWindows.begin()->first << " left " << m_BCOWindows.begin()->second.first << " right " << m_BCOWindows.begin()->second.second << std::endl;
0314     }
0315   }
0316 
0317   m_bco_trim = m_BCOWindows.begin()->first;
0318   m_lower_bound = m_BCOWindows.begin()->second.first;
0319   m_upper_bound = m_BCOWindows.begin()->second.second;
0320   m_bunch_number = m_BCOBunchNumber[m_BCOWindows.begin()->first];
0321   // ttree->Fill();
0322   h_bunchnumber->Fill(m_BCOBunchNumber[m_BCOWindows.begin()->first]);
0323   h_lumibco->Fill(m_BCOWindows.begin()->second.second - m_BCOWindows.begin()->second.first);
0324 
0325   int lower = -1 * static_cast<int>(m_bco_trim - m_lower_bound);
0326   int upper = (m_upper_bound > m_bco_trim) ? static_cast<int>(m_upper_bound - m_bco_trim) : -1 * static_cast<int>(m_bco_trim - m_upper_bound);  // it is possible that upper is <0
0327                                                                                                                                                 // std::cout<<"lower="<<lower<<", upper = "<<upper<<std::endl;//<<" or upper2 = "<<lower+(m_BCOWindows.begin()->second.second - m_BCOWindows.begin()->second.first)<<std::endl;
0328   for (int i = lower; i < upper; i++)
0329   {
0330     int adjusted_bunch = m_bunch_number + i;
0331     while (adjusted_bunch < 0)
0332     {
0333       adjusted_bunch += 120;
0334     }
0335     while (adjusted_bunch > 119)
0336     {
0337       adjusted_bunch -= 120;
0338     }
0339     if (i != 0)
0340     {
0341       h_bunchnumber_occur->Fill(adjusted_bunch);
0342     }  // else{std::cout<<"same gl1 removed"<<std::endl;}
0343   }
0344 
0345   if (!m_BCOBunchNumber.empty())
0346   {
0347     m_BCOBunchNumber.erase(m_BCOWindows.begin()->first);
0348     // m_BCOBunchNumber.erase(m_BCOBunchNumber.begin());
0349   }
0350   if (!m_BCOWindows.empty())
0351   {
0352     m_BCOWindows.erase(m_BCOWindows.begin());
0353   }
0354   if (flat_overflow)
0355   {
0356     m_BCOWindows.erase(m_BCOWindows.begin());
0357     bco_temp -= 1099511627775 + 1;
0358     m_BCOWindows[bco_temp] = std::make_pair(bco_temp - m_negative_bco_window, bco_temp + m_positive_bco_window);
0359     std::cout << " Change back, new bco window map  " << m_BCOBunchNumber.begin()->first << std::endl;
0360     flat_overflow = false;
0361   }
0362 
0363   // mow use new
0364 
0365   Gl1Packet *gl1packet = findNode::getClass<Gl1Packet>(m_topNode, "GL1RAWHIT");
0366   for (auto gl1hititer : m_Gl1RawHitMap.begin()->second.Gl1RawHitVector)
0367   {
0368     if (!m_StreamingFlag)  // if streaming flag is set, the gl1packet is a nullptr
0369     {
0370       gl1packet->FillFrom(gl1hititer);
0371       MySyncManager()->CurrentEvent(gl1packet->getEvtSequence());
0372     }
0373   }
0374 
0375   // add for mbd p_gl1
0376   Gl1Packet *p_gl1 = findNode::getClass<Gl1Packet>(m_topNode, "GL1RAWHIT");  //"GL1Packet");
0377   if (!p_gl1)
0378   {
0379     std::cout << "CAN not find this Gl1Packet" << std::endl;
0380   }
0381   else
0382   {
0383     int bunchnumber = p_gl1->getBunchNumber();
0384     //  uint64_t evtBCO_gl1 = p_gl1->getBCO() & 0xFFFFFFFFFFU;
0385     //        for (int i = 0; i <9;i++)// int(GL1PScaler_raw_vec.size()); i++)
0386     //        {
0387     if (p_gl1->lValue(0, "GL1PRAW"))  // 0-8, 0 is MBDSN
0388     {
0389       //    GL1PScaler_raw_vec[i][bunchnumber] = p_gl1->lValue(i, "GL1PRAW");
0390       //        std::cout<<"evtBCO: "<<evtBCO_gl1<<" bunchnumber ="<<bunchnumber<<" i = "<<i<<" ,gl1praw = " <<p_gl1->lValue(i, "GL1PRAW")<<std::endl;
0391       m_bunchnumber_MBDNS_raw[bunchnumber] = p_gl1->lValue(0, "GL1PRAW");
0392       m_bunchnumber_MBDNS_live[bunchnumber] = p_gl1->lValue(0, "GL1PLIVE");
0393       m_bunchnumber_MBDNS_scaled[bunchnumber] = p_gl1->lValue(0, "GL1PSCALED");
0394       m_bunchnumber_ZDCCoin_raw[bunchnumber] = p_gl1->lValue(5, "GL1PRAW");  // zdc coincidence
0395       // h_gl1p_MBDSN_bunchid->Fill(bunchnumber, p_gl1->lValue(0, "GL1PRAW"));
0396       // std::cout<<" bunchnumber ="<<bunchnumber<<" ,gl1praw = " <<p_gl1->lValue(0, "GL1PRAW")<<std::endl;
0397     }
0398     //      }
0399     if (p_gl1->lValue(0, 0))
0400     {
0401       //        m_bunchnumber_rawgl1scaler[bunchnumber] = p_gl1->lValue(0, 0);
0402       //    std::cout<<" bunchnumber ="<<bunchnumber<<" ,gl1rawscaler = "<< p_gl1->lValue(0, 0)<<std::endl;
0403       m_rawgl1scaler = p_gl1->lValue(0, 0);
0404     }
0405   }
0406   ttree->Fill();
0407 
0408   if (m_lastevent_flag)
0409   {
0410     for (const auto &[bunchnumber, mbdns_value] : m_bunchnumber_MBDNS_raw)
0411     {
0412       h_gl1p_MBDSN_bunchid_raw->Fill(bunchnumber, mbdns_value);
0413     }
0414     for (const auto &[bunchnumber, mbdns_value] : m_bunchnumber_MBDNS_live)
0415     {
0416       h_gl1p_MBDSN_bunchid_live->Fill(bunchnumber, mbdns_value);
0417     }
0418     for (const auto &[bunchnumber, mbdns_value] : m_bunchnumber_MBDNS_scaled)
0419     {
0420       h_gl1p_MBDSN_bunchid_scaled->Fill(bunchnumber, mbdns_value);
0421     }
0422     // for (const auto &[bunchnumber, mbdns_value] : m_bunchnumber_rawgl1scaler) {
0423     h_gl1p_rawgl1scaler->Fill(1, m_rawgl1scaler);
0424     //}
0425     for (const auto &[bunchnumber, mbdns_value] : m_bunchnumber_ZDCCoin_raw)
0426     {
0427       h_gl1p_ZDCCoin_bunchid_raw->Fill(bunchnumber, mbdns_value);
0428     }
0429   }
0430   // if we run streaming, we only need the first gl1 bco to skip over all the junk
0431   // which is taken before the daq actually starts. But once we have the first event
0432   // and set the refBCO to the beginning of the run, we don't want the gl1 anymore
0433   // so we delete its input manager(s) and unregister it
0434   // deleting it also deletes all its allocated memory, so we don't have to worry
0435   // about clearing all gl1 related maps
0436   if (m_StreamingFlag)
0437   {
0438     for (auto iter : m_Gl1InputVector)
0439     {
0440       delete iter;
0441     }
0442     m_gl1_registered_flag = false;
0443     m_Gl1InputVector.clear();
0444   }
0445   else
0446   {
0447     for (auto iter : m_Gl1InputVector)
0448     {
0449       iter->CleanupUsedPackets(m_Gl1RawHitMap.begin()->first);
0450     }
0451     m_Gl1RawHitMap.begin()->second.Gl1RawHitVector.clear();
0452     m_Gl1RawHitMap.erase(m_Gl1RawHitMap.begin());
0453   }
0454   // std::cout << "size  m_Gl1RawHitMap: " <<  m_Gl1RawHitMap.size()
0455   //        << std::endl;
0456 
0457   if (Verbosity() > 0)
0458   {
0459     if (m_alldone_flag)
0460     {
0461       std::cout << "all done is true" << std::endl;
0462     }
0463   }
0464 
0465   if (m_alldone_flag)
0466   {
0467     std::cout << m_event_number << " Events -- Storing files to output.root" << std::endl;
0468     std::string updatedFileName = m_outputFileName + "_" + std::to_string(m_event_number) + ".root";
0469     if (TFile::Open(updatedFileName.c_str(), "READ"))
0470     {
0471       updatedFileName = m_outputFileName + "_" + std::to_string(m_event_number + 1) + ".root";
0472     }
0473     tfile = TFile::Open(updatedFileName.c_str(), "RECREATE", "");
0474     ttree->Write("", TObject::kOverwrite);
0475     h_lumibco->Write("", TObject::kOverwrite);
0476     h_bunchnumber->Write("", TObject::kOverwrite);
0477     h_bunchnumber_occur->Write("", TObject::kOverwrite);
0478     h_diffbco->Write("", TObject::kOverwrite);
0479     h_gl1p_MBDSN_bunchid_raw->Write("", TObject::kOverwrite);
0480     h_gl1p_MBDSN_bunchid_live->Write("", TObject::kOverwrite);
0481     h_gl1p_MBDSN_bunchid_scaled->Write("", TObject::kOverwrite);
0482     h_gl1p_rawgl1scaler->Write("", TObject::kOverwrite);
0483     h_gl1p_ZDCCoin_bunchid_raw->Write("", TObject::kOverwrite);
0484     tfile->Close();
0485     delete tfile;
0486 
0487     ttree->Reset();
0488     h_lumibco->Reset();
0489     h_bunchnumber->Reset();
0490     h_bunchnumber_occur->Reset();
0491     h_diffbco->Reset();
0492     h_gl1p_MBDSN_bunchid_raw->Reset();
0493     h_gl1p_MBDSN_bunchid_live->Reset();
0494     h_gl1p_MBDSN_bunchid_scaled->Reset();
0495     h_gl1p_rawgl1scaler->Reset();
0496     h_gl1p_ZDCCoin_bunchid_raw->Reset();
0497   }
0498 
0499   return 0;
0500 }
0501 
0502 void Fun4AllStreamingLumiCountingInputManager::SetNegativeWindow(const unsigned int i)
0503 {
0504   m_negative_bco_window = std::max(i, m_negative_bco_window);
0505 }
0506 
0507 void Fun4AllStreamingLumiCountingInputManager::SetPositiveWindow(const unsigned int i)
0508 {
0509   m_positive_bco_window = std::max(i, m_positive_bco_window);
0510 }
0511 
0512 void Fun4AllStreamingLumiCountingInputManager::createLuminosityHistos()
0513 {
0514   auto hm = QAHistManagerDef::getHistoManager();
0515   assert(hm);
0516   // zhiwan
0517   {
0518     auto tr = new TTree("BCOWindowTree", "BCO Window Data");
0519     tr->Branch("bco_trim", &m_bco_trim);
0520     tr->Branch("lower_bound", &m_lower_bound);
0521     tr->Branch("upper_bound", &m_upper_bound);
0522     tr->Branch("bunch_number", &m_bunch_number);
0523     //  tr->Branch("rawgl1scaler", &m_rawgl1scaler);
0524     tr->SetAutoFlush(100000);
0525     hm->registerHisto(tr);
0526   }
0527 
0528   {
0529     auto h = new TH1I("h_LumiBCO", "Lumi BCO", 500, 0, 500);
0530     h->GetXaxis()->SetTitle(" Lumi BCO per event");
0531     h->SetTitle("Number of BCO matched");
0532     hm->registerHisto(h);
0533   }
0534   {
0535     auto h = new TH1I("h_BunchNumber", "Bunch Number Lumi BCO", 121, -0.5, 120.5);
0536     h->GetXaxis()->SetTitle("Bunch Number per event");
0537     h->SetTitle("Number of crossing");
0538     hm->registerHisto(h);
0539   }
0540   {
0541     auto h = new TH1D("h_BunchNumberOccurance", "Bunch Number Lumi BCO", 120, -0.5, 119.5);
0542     h->GetXaxis()->SetTitle("Bunch Number per time window");
0543     h->SetTitle("Number of crossing");
0544     hm->registerHisto(h);
0545   }
0546   {
0547     auto h = new TH1I("h_diffBCO", "gl1 bco 1-2", 3500, 0, 3500);
0548     h->GetXaxis()->SetTitle("GL1 BCO difference");
0549     h->SetTitle("Number of crossing");
0550     hm->registerHisto(h);
0551   }
0552   {
0553     auto h = new TH1D("h_MBDSNraw_BunchID", "Bunch Number Lumi BCO", 121, -0.5, 120.5);
0554     h->GetXaxis()->SetTitle("Bunch Number per event");
0555     h->SetTitle("MBDSN Number of crossing");
0556     hm->registerHisto(h);
0557   }
0558   {
0559     auto h = new TH1D("h_MBDSNlive_BunchID", "Bunch Number Lumi BCO", 121, -0.5, 120.5);
0560     h->GetXaxis()->SetTitle("Bunch Number per event");
0561     h->SetTitle("MBDSN Number of crossing");
0562     hm->registerHisto(h);
0563   }
0564   {
0565     auto h = new TH1D("h_MBDSNscaled_BunchID", "Bunch Number Lumi BCO", 121, -0.5, 120.5);
0566     h->GetXaxis()->SetTitle("Bunch Number per event");
0567     h->SetTitle("MBDSN Number of crossing");
0568     hm->registerHisto(h);
0569   }
0570   {
0571     auto h = new TH1D("h_rawgl1scalerBunchID", "Bunch Number Lumi BCO", 10, -0.5, 9.5);
0572     h->GetXaxis()->SetTitle("Bunch Number per event");
0573     h->SetTitle("raw GL1 scaler");
0574     hm->registerHisto(h);
0575   }
0576   {
0577     auto h = new TH1D("h_gl1p_ZDCCoin_BunchID", "Bunch Number Lumi BCO", 121, -0.5, 120.5);
0578     h->GetXaxis()->SetTitle("Bunch Number per event");
0579     h->SetTitle("raw GL1 scaler");
0580     hm->registerHisto(h);
0581   }
0582   // Get the global pointers
0583   h_lumibco = dynamic_cast<TH1 *>(hm->getHisto("h_LumiBCO"));
0584   h_bunchnumber = dynamic_cast<TH1 *>(hm->getHisto("h_BunchNumber"));
0585   h_bunchnumber_occur = dynamic_cast<TH1 *>(hm->getHisto("h_BunchNumberOccurance"));
0586   ttree = dynamic_cast<TTree *>(hm->getHisto("BCOWindowTree"));
0587   h_diffbco = dynamic_cast<TH1 *>(hm->getHisto("h_diffBCO"));
0588   h_gl1p_MBDSN_bunchid_raw = dynamic_cast<TH1 *>(hm->getHisto("h_MBDSNraw_BunchID"));
0589   h_gl1p_MBDSN_bunchid_live = dynamic_cast<TH1 *>(hm->getHisto("h_MBDSNlive_BunchID"));
0590   h_gl1p_MBDSN_bunchid_scaled = dynamic_cast<TH1 *>(hm->getHisto("h_MBDSNscaled_BunchID"));
0591   h_gl1p_rawgl1scaler = dynamic_cast<TH1 *>(hm->getHisto("h_rawgl1scalerBunchID"));
0592   h_gl1p_ZDCCoin_bunchid_raw = dynamic_cast<TH1 *>(hm->getHisto("h_gl1p_ZDCCoin_BunchID"));
0593 }