Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:16:07

0001 #include "Gl1Packetv1.h"
0002 
0003 #include <phool/phool.h>
0004 
0005 #include <iomanip>
0006 
0007 void Gl1Packetv1::Reset()
0008 {
0009   OfflinePacketv1::Reset();
0010   packet_nr = 0;
0011   BunchNumber = std::numeric_limits<uint64_t>::max();
0012   TriggerInput = 0;
0013   TriggerVector = 0;
0014   for (auto &row : scaler)
0015   {
0016     row.fill(0);
0017   }
0018   return;
0019 }
0020 
0021 void Gl1Packetv1::identify(std::ostream &os) const
0022 {
0023   os << "Gl1Packetv1: " << std::endl;
0024   OfflinePacketv1::identify(os);
0025   os << "bunch number: " << BunchNumber << std::endl;
0026   return;
0027 }
0028 
0029 void Gl1Packetv1::FillFrom(const Gl1Packet *pkt)
0030 {
0031   setBunchNumber(pkt->getBunchNumber());
0032   setPacketNumber(pkt->getPacketNumber());
0033   setTriggerInput(pkt->getTriggerInput());
0034   setTriggerVector(pkt->getTriggerVector());
0035   for (int i = 0; i < 64; i++)
0036   {
0037     for (int j = 0; j < 3; j++)
0038     {
0039       setScaler(i, j, pkt->lValue(i, j));
0040     }
0041   }
0042   OfflinePacketv1::FillFrom(pkt);
0043 }
0044 
0045 int Gl1Packetv1::iValue(const int i) const
0046 {
0047   if (i == 0)
0048   {
0049     return packet_nr;
0050   }
0051   std::cout << PHWHERE << " Bad argument for iValue: " << i << std::endl;
0052   return std::numeric_limits<int>::min();
0053 }
0054 
0055 long long Gl1Packetv1::lValue(const int i, const int j) const
0056 {
0057   return scaler.at(i).at(j);
0058 }
0059 
0060 long long Gl1Packetv1::lValue(const int /*i*/, const std::string &what) const
0061 {
0062   if (what == "BCO")
0063   {
0064     return getBCO();
0065   }
0066   if (what == "TriggerInput")
0067   {
0068     return getTriggerInput();
0069   }
0070   if (what == "LiveVector")
0071   {
0072     return getLiveVector();
0073   }
0074   if (what == "TriggerVector")  // compatibility
0075   {
0076     return getLiveVector();
0077   }
0078   if (what == "ScaledVector")  // to avoid the "not implemented" warning
0079   {
0080     return 0;
0081   }
0082 
0083   if (what == "BunchNumber")
0084   {
0085     return getBunchNumber();
0086   }
0087   std::cout << "option " << what << " not implemented" << std::endl;
0088   return std::numeric_limits<uint64_t>::max();
0089 }
0090 
0091 void Gl1Packetv1::dump(std::ostream &os) const
0092 {
0093   // to avoid confusion, we continue to call it "Trigger Vector" here.
0094 
0095   os << "packet nr:       " << iValue(0) << std::endl;
0096   os << "Beam Clock:      "
0097      << "0x" << std::hex << lValue(0, "BCO") << std::dec << "   " << lValue(0, "BCO") << std::endl;
0098   os << "Trigger Input:   "
0099      << "0x" << std::hex << lValue(0, "TriggerInput") << std::dec << "   " << lValue(0, "TriggerInput") << std::endl;
0100   os << "Trigger Vector:  "
0101      << "0x" << std::hex << lValue(0, "TriggerVector") << std::dec << "   " << lValue(0, "TriggerVector") << std::endl;
0102   os << "Bunch Number:    " << lValue(0, "BunchNumber") << std::endl
0103      << std::endl;
0104   os << "Trg #                  raw              live              scaled" << std::endl;
0105   os << "----------------------------------------------------------------" << std::endl;
0106 
0107   int i;
0108 
0109   for (i = 0; i < 64; i++)
0110   {
0111     if (lValue(i, 0) || lValue(i, 1) || lValue(i, 2))
0112     {
0113       os << std::setw(3) << i << "    ";
0114       os << " " << std::setw(18) << lValue(i, 0)
0115          << " " << std::setw(18) << lValue(i, 1)
0116          << " " << std::setw(18) << lValue(i, 2)
0117          << std::endl;
0118     }
0119   }
0120   os << std::endl;
0121 }