Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 #include "LL1Packetv1.h"
0002 
0003 #include <Event/packetConstants.h>
0004 
0005 #include <TSystem.h>
0006 
0007 #include <iomanip>
0008 
0009 LL1Packetv1::LL1Packetv1()
0010 {
0011   for (auto &row : samples)
0012   {
0013     row.fill(0);
0014   }
0015 }
0016 
0017 void LL1Packetv1::Reset()
0018 {
0019   OfflinePacketv1::Reset();
0020   PacketEvtSequence = 0;
0021   NrChannels = 0;
0022   NrSamples = 0;
0023   TriggerWords = 0;
0024   SlotNr = 0;
0025   CardNr = 0;
0026   for (auto &row : samples)
0027   {
0028     row.fill(0);
0029   }
0030   return;
0031 }
0032 
0033 int LL1Packetv1::iValue(const int /*n*/, const std::string &what) const
0034 {
0035   if (what == "CLOCK")
0036   {
0037     return getBCO();
0038   }
0039 
0040   if (what == "EVTNR")
0041   {
0042     return getPacketEvtSequence();
0043   }
0044 
0045   if (what == "SAMPLES")
0046   {
0047     return getNrSamples();
0048   }
0049   if (what == "Channels")
0050   {
0051     return getNrChannels();
0052   }
0053   if (what == "TRIGGERWORDS")
0054   {
0055     return getTriggerWords();
0056   }
0057   if (what == "SLOTNR")
0058   {
0059     return getSlotNr();
0060   }
0061   if (what == "CARDNR")
0062   {
0063     return getCardNr();
0064   }
0065   if (what == "MONITOR")
0066   {
0067     return getMonitor();
0068   }
0069   if (what == "FIBERS")
0070   {
0071     return getFibers();
0072   }
0073   if (what == "SUMS")
0074   {
0075     return getSums();
0076   }
0077   if (what == "FEMWORDS")
0078   {
0079     return getFemWords();
0080   }
0081 
0082   std::cout << "invalid selection " << what << std::endl;
0083   return std::numeric_limits<int>::min();
0084 }
0085 
0086 int LL1Packetv1::iValue(const int channel, const int sample) const
0087 {
0088   return samples.at(channel).at(sample);
0089 }
0090 
0091 void LL1Packetv1::identify(std::ostream &os) const
0092 {
0093   os << "LL1Packetv1: " << std::endl;
0094   OfflinePacketv1::identify(os);
0095   os << "Pkt Event no: " << getPacketEvtSequence() << std::endl;
0096   os << "Hitformat: " << getHitFormat() << std::endl;
0097   os << "Number of Channels: " << getNrChannels() << std::endl;
0098   os << "Number of Samples: " << getNrSamples() << std::endl;
0099 }
0100 
0101 void LL1Packetv1::dump(std::ostream &os) const
0102 {
0103   os << std::dec << std::setprecision(2) << "Trigger Module = " << (iValue(0, "SLOTNR") * 2) + iValue(0, "CARDNR") << std::endl;
0104   os << std::dec << std::setprecision(4) << "Evt Nr = " << iValue(0, "EVTNR") << std::endl;
0105   os << std::dec << std::setprecision(4) << "Clock = " << iValue(0, "CLOCK") << std::endl;
0106   os << std::dec << std::setprecision(4) << "Monitor = " << iValue(0, "MONITOR") << std::endl;
0107 
0108   switch (getHitFormat())
0109   {
0110   case IDLL1_MBD:
0111     dump_idll1_mbd(os);
0112     break;
0113   case IDLL1_EMCAL_MON3:
0114     dump_idll1_emcal_mon3(os);
0115     break;
0116   case IDLL1_JET_EMCAL_MON1:
0117     dump_idll1_jet_emcal_mon1(os);
0118     break;
0119   default:
0120     std::cout << "unknown hit format: "
0121               << getHitFormat() << std::endl;
0122     //    gSystem->Exit(1);
0123   }
0124   return;
0125 }
0126 
0127 void LL1Packetv1::dump_idll1_mbd(std::ostream &os) const
0128 {
0129   for (int ifem = 0; ifem < 4; ifem++)
0130   {
0131     os << std::dec << "FEM : " << ifem << std::endl;
0132     for (int iq = 0; iq < 8; iq++)
0133     {
0134       os << std::dec << "Q" << iq << "\t||  \t";
0135       for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0136       {
0137         os << std::hex << iValue(is, (ifem * 13) + iq) << "\t";
0138       }
0139       os << " |" << std::endl;
0140     }
0141     os << std::dec << "NH \t||  \t";
0142     for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0143     {
0144       os << std::hex << iValue(is, (ifem * 13) + 8) << "\t";
0145     }
0146     os << " |" << std::endl;
0147 
0148     for (int iq = 0; iq < 4; iq++)
0149     {
0150       os << std::dec << "T" << iq << "\t||  \t";
0151       for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0152       {
0153         os << std::hex << iValue(is, (ifem * 13) + 9 + iq) << "\t";
0154       }
0155       os << " |" << std::endl;
0156     }
0157     os << " " << std::endl;
0158   }
0159 
0160   for (int iw = 0; iw < iValue(0, "TRIGGERWORDS"); iw++)
0161   {
0162     os << std::dec << "W " << iw << "\t||  \t";
0163     for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0164     {
0165       os << std::hex << iValue(is, 52 + iw) << "\t";
0166     }
0167 
0168     os << " |" << std::endl;
0169   }
0170 }
0171 //  Packet_iddigitizerv3
0172 void LL1Packetv1::dump_idll1_emcal_mon3(std::ostream &os) const
0173 {
0174   os << "-------------------------------------------------------------- " << std::endl;
0175   for (int ch = 0; ch < 24; ch++)
0176   {
0177     os << std::dec << "Fiber: " << ch << std::endl;
0178     for (int ic = 0; ic < iValue(0, "SUMS"); ic++)
0179     {
0180       os << std::dec << " Sum " << ic << " |";
0181       for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0182       {
0183         os << std::hex << " " << iValue(is, (ch * iValue(0, "SUMS")) + ic);
0184       }
0185 
0186       os << " |" << std::endl;
0187       os << "-------------------------------------------------------------- " << std::endl;
0188     }
0189   }
0190   for (int ic = 0; ic < iValue(0, "TRIGGERWORDS"); ic++)
0191   {
0192     os << std::dec << "SUM " << ic << std::endl;
0193     for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0194     {
0195       os << std::hex << " " << iValue(is, iValue(0, "FEMWORDS") + ic);
0196     }
0197     os << " |" << std::endl;
0198     os << "-------------------------------------------------------------- " << std::endl;
0199   }
0200 }
0201 
0202 void LL1Packetv1::dump_idll1_jet_emcal_mon1(std::ostream &os) const
0203 {
0204   os << " -------------- " << (iValue(0, "MONITOR") ? "HCAL Data Map" : "EMCAL Data Map") << " -------------- " << std::endl;
0205 
0206   for (int sample = 0; sample < iValue(0, "SAMPLES"); sample++)
0207   {
0208     os << std::dec << "BC : " << sample << std::endl;
0209     os << std::dec << "phibin --> ";
0210     for (int ic = 0; ic < 32; ic++)
0211     {
0212       os << std::dec << "\t" << ic;
0213     }
0214     os << " " << std::endl;
0215     os << std::dec << "etabin\t||  \t" << std::endl;
0216     for (int ic = 0; ic < 12; ic++)
0217     {
0218       os << std::dec << ic << "\t||";
0219       for (int is = 0; is < 32; is++)
0220       {
0221         os << std::hex << "\t" << iValue(sample, (ic * 32) + is);
0222       }
0223       os << " |" << std::endl;
0224     }
0225     os << " " << std::endl;
0226   }
0227 
0228   for (int is = 0; is < iValue(0, "SAMPLES"); is++)
0229   {
0230     os << std::dec << "Sample: " << is << std::endl;
0231     for (int ic = 0; ic < 9; ic++)
0232     {
0233       for (int ie = 0; ie < 32; ie++)
0234       {
0235         os << std::hex << " " << iValue(is, iValue(0, "FEMWORDS") + (ic * 32) + ie);
0236       }
0237 
0238       os << " |" << std::endl;
0239       os << "-------------------------------------------------------------- " << std::endl;
0240     }
0241   }
0242 }