Back to home page

sPhenix code displayed by LXR

 
 

    


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

0001 // @brief  Interaction record encoding BC, orbit, time
0002 // @sa <O2/DataFormats/common/include/CommonDataFormat/InteractionRecord.h>
0003 //     <29947a45e>
0004 
0005 #ifndef MVTXDECODER_INTERACTIONRECORD_H
0006 #define MVTXDECODER_INTERACTIONRECORD_H
0007 
0008 #include <cstdint>
0009 #include <string>
0010 
0011 namespace mvtx
0012 {
0013 namespace lhcConstants
0014 {
0015 constexpr int LHCMaxBunches = 3564;                              // max N bunches
0016 /*
0017 constexpr double LHCRFFreq = 400.789e6;                          // LHC RF frequency in MHz
0018 constexpr double LHCBunchSpacingNS = 10 * 1.e9 / LHCRFFreq;      // bunch spacing in ns (10 RFbuckets)
0019 constexpr double LHCOrbitNS = LHCMaxBunches * LHCBunchSpacingNS; // orbit duration in ns
0020 constexpr double LHCRevFreq = 1.e9 / LHCOrbitNS;                 // revolution frequency
0021 constexpr double LHCBunchSpacingMUS = LHCBunchSpacingNS * 1e-3;  // bunch spacing in \mus (10 RFbuckets)
0022 constexpr double LHCOrbitMUS = LHCOrbitNS * 1e-3;                // orbit duration in \mus
0023 
0024 constexpr int RHICMaxBunches = 120;                              // max N bunches
0025 constexpr double RHICFFreq = 9.839e6;                            // RHIC RF frequency in MHz
0026 constexpr double RHICOrbitNS = 1.e9 / RHICFFreq;                 // RHIC BCO in nS
0027 */
0028 } // namespace lhcConstants
0029 
0030 //!< TODO: Add RHIC constants
0031 
0032 struct InteractionRecord
0033 {
0034   // information about bunch crossing and orbit
0035   static constexpr uint64_t DummyOrbit = 0xffffffffff;
0036   static constexpr uint16_t DummyBC = 0xffff;
0037 
0038   uint64_t orbit = DummyOrbit; ///< RHIC orbit (BCO)
0039   uint16_t bc = DummyBC;       ///< bunch crossing ID of interaction
0040 
0041   InteractionRecord() = default;
0042 
0043   InteractionRecord( uint64_t orb, uint16_t b ) : orbit(orb), bc(b){};
0044 
0045   InteractionRecord(const InteractionRecord& src) = default;
0046 
0047   InteractionRecord& operator=(const InteractionRecord& src) = default;
0048 
0049   void clear()
0050   {
0051     orbit = DummyOrbit;
0052     bc = DummyBC;
0053   }
0054 
0055   bool isDummy() const
0056   {
0057     return bc > mvtx::lhcConstants::LHCMaxBunches;
0058   }
0059 
0060   bool operator==(const InteractionRecord& other) const
0061   {
0062     return (orbit == other.orbit) && (bc == other.bc);
0063   }
0064 
0065   bool operator!=(const InteractionRecord& other) const
0066   {
0067     return (orbit != other.orbit) || (bc != other.bc);
0068   }
0069 
0070   void print() const;
0071   std::string asString() const;
0072   friend std::ostream& operator<<(std::ostream& stream, InteractionRecord const& ir);
0073 // ClassDefNV(InteractionRecord, 3);
0074 };
0075 
0076 }
0077 #endif