Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:20:06

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
0018     frequency in MHz constexpr double LHCBunchSpacingNS = 10 * 1.e9 / LHCRFFreq; //
0019     bunch spacing in ns (10 RFbuckets) constexpr double LHCOrbitNS = LHCMaxBunches *
0020     LHCBunchSpacingNS; // orbit duration in ns constexpr double LHCRevFreq = 1.e9 /
0021     LHCOrbitNS;                 // revolution frequency constexpr double
0022     LHCBunchSpacingMUS = LHCBunchSpacingNS * 1e-3;  // bunch spacing in \mus (10
0023     RFbuckets) constexpr double LHCOrbitMUS = LHCOrbitNS * 1e-3;                //
0024     orbit duration in \mus
0025 
0026     constexpr int RHICMaxBunches = 120;                              // max N
0027     bunches constexpr double RHICFFreq = 9.839e6;                            // RHIC
0028     RF frequency in MHz constexpr double RHICOrbitNS = 1.e9 / RHICFFreq; // RHIC BCO
0029     in nS
0030     */
0031   }  // namespace lhcConstants
0032 
0033   //!< TODO: Add RHIC constants
0034 
0035   struct InteractionRecord
0036   {
0037     // information about bunch crossing and orbit
0038     static constexpr uint64_t DummyOrbit = 0xffffffffff;
0039     static constexpr uint16_t DummyBC = 0xffff;
0040 
0041     uint64_t orbit = DummyOrbit;  ///< RHIC orbit (BCO)
0042     uint16_t bc = DummyBC;        ///< bunch crossing ID of interaction
0043 
0044     InteractionRecord() = default;
0045 
0046     InteractionRecord(uint64_t orb, uint16_t b)
0047       : orbit(orb)
0048       , bc(b) {};
0049 
0050     InteractionRecord(const InteractionRecord &src) = default;
0051 
0052     InteractionRecord &operator=(const InteractionRecord &src) = default;
0053 
0054     void clear()
0055     {
0056       orbit = DummyOrbit;
0057       bc = DummyBC;
0058     }
0059 
0060     bool isDummy() const { return bc > mvtx::lhcConstants::LHCMaxBunches; }
0061 
0062     bool operator==(const InteractionRecord &other) const
0063     {
0064       return (orbit == other.orbit) && (bc == other.bc);
0065     }
0066 
0067     bool operator!=(const InteractionRecord &other) const
0068     {
0069       return (orbit != other.orbit) || (bc != other.bc);
0070     }
0071 
0072     void print() const;
0073     std::string asString() const;
0074     friend std::ostream &operator<<(std::ostream &stream,
0075                                     InteractionRecord const &ir);
0076     // ClassDefNV(InteractionRecord, 3);
0077   };
0078 
0079 }  // namespace mvtx
0080 #endif