Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:31

0001 #ifndef CondFormats_RunInfo_FillInfo_H
0002 #define CondFormats_RunInfo_FillInfo_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 
0006 #include "CondFormats/Common/interface/Time.h"
0007 #include <bitset>
0008 #include <iostream>
0009 #include <string>
0010 #include <sstream>
0011 #include <vector>
0012 
0013 class FillInfo {
0014 public:
0015   enum FillType { UNKNOWN = 0, PROTONS = 1, IONS = 2, COSMICS = 3, GAP = 4 };
0016   enum ParticleType { NONE = 0, PROTON = 1, PB82 = 2, AR18 = 3, D = 4, XE54 = 5 };
0017   typedef FillType FillTypeId;
0018   typedef ParticleType ParticleTypeId;
0019   FillInfo();
0020   FillInfo(unsigned short const &lhcFill, bool const &fromData = true);
0021   ~FillInfo();
0022 
0023   //constant static unsigned integer hosting the maximum number of LHC bunch slots
0024   static size_t const bunchSlots = 3564;
0025 
0026   //constant static unsigned integer hosting the available number of LHC bunch slots
0027   static size_t const availableBunchSlots = 2808;
0028 
0029   //reset instance
0030   void setFill(unsigned short const &lhcFill, bool const &fromData = true);
0031 
0032   //getters
0033   unsigned short const fillNumber() const;
0034 
0035   bool const isData() const;
0036 
0037   unsigned short const bunchesInBeam1() const;
0038 
0039   unsigned short const bunchesInBeam2() const;
0040 
0041   unsigned short const collidingBunches() const;
0042 
0043   unsigned short const targetBunches() const;
0044 
0045   FillTypeId const fillType() const;
0046 
0047   ParticleTypeId const particleTypeForBeam1() const;
0048 
0049   ParticleTypeId const particleTypeForBeam2() const;
0050 
0051   float const crossingAngle() const;
0052 
0053   float const betaStar() const;
0054 
0055   float const intensityForBeam1() const;
0056 
0057   float const intensityForBeam2() const;
0058 
0059   float const energy() const;
0060 
0061   cond::Time_t const createTime() const;
0062 
0063   cond::Time_t const beginTime() const;
0064 
0065   cond::Time_t const endTime() const;
0066 
0067   std::string const &injectionScheme() const;
0068 
0069   //returns a boolean, true if the injection scheme has a leading 25ns
0070   //TODO: parse the circulating bunch configuration, instead of the string.
0071   bool is25nsBunchSpacing() const;
0072 
0073   //returns a boolean, true if the bunch slot number is in the circulating bunch configuration
0074   bool isBunchInBeam1(size_t const &bunch) const;
0075 
0076   bool isBunchInBeam2(size_t const &bunch) const;
0077 
0078   //member functions returning *by value* a vector with all filled bunch slots
0079   std::vector<unsigned short> bunchConfigurationForBeam1() const;
0080 
0081   std::vector<unsigned short> bunchConfigurationForBeam2() const;
0082 
0083   //setters
0084   void setBunchesInBeam1(unsigned short const &bunches);
0085 
0086   void setBunchesInBeam2(unsigned short const &bunches);
0087 
0088   void setCollidingBunches(unsigned short const &collidingBunches);
0089 
0090   void setTargetBunches(unsigned short const &targetBunches);
0091 
0092   void setFillType(FillTypeId const &fillType);
0093 
0094   void setParticleTypeForBeam1(ParticleTypeId const &particleType);
0095 
0096   void setParticleTypeForBeam2(ParticleTypeId const &particleType);
0097 
0098   void setCrossingAngle(float const &angle);
0099 
0100   void setBetaStar(float const &betaStar);
0101 
0102   void setIntensityForBeam1(float const &intensity);
0103 
0104   void setIntensityForBeam2(float const &intensity);
0105 
0106   void setEnergy(float const &energy);
0107 
0108   void setCreationTime(cond::Time_t const &createTime);
0109 
0110   void setBeginTime(cond::Time_t const &beginTime);
0111 
0112   void setEndTime(cond::Time_t const &endTime);
0113 
0114   void setInjectionScheme(std::string const &injectionScheme);
0115 
0116   //sets all values in one go
0117   void setBeamInfo(unsigned short const &bunches1,
0118                    unsigned short const &bunches2,
0119                    unsigned short const &collidingBunches,
0120                    unsigned short const &targetBunches,
0121                    FillTypeId const &fillType,
0122                    ParticleTypeId const &particleType1,
0123                    ParticleTypeId const &particleType2,
0124                    float const &angle,
0125                    float const &beta,
0126                    float const &intensity1,
0127                    float const &intensity2,
0128                    float const &energy,
0129                    cond::Time_t const &createTime,
0130                    cond::Time_t const &beginTime,
0131                    cond::Time_t const &endTime,
0132                    std::string const &scheme,
0133                    std::bitset<bunchSlots + 1> const &bunchConf1,
0134                    std::bitset<bunchSlots + 1> const &bunchConf2);
0135 
0136   //dumping values on output stream
0137   void print(std::stringstream &ss) const;
0138 
0139 protected:
0140   std::bitset<bunchSlots + 1> const &bunchBitsetForBeam1() const;
0141 
0142   std::bitset<bunchSlots + 1> const &bunchBitsetForBeam2() const;
0143 
0144   void setBunchBitsetForBeam1(std::bitset<bunchSlots + 1> const &bunchConfiguration);
0145 
0146   void setBunchBitsetForBeam2(std::bitset<bunchSlots + 1> const &bunchConfiguration);
0147 
0148 private:
0149   bool m_isData;
0150   unsigned short m_lhcFill;
0151   unsigned short m_bunches1, m_bunches2, m_collidingBunches, m_targetBunches;
0152   FillTypeId m_fillType;
0153   ParticleTypeId m_particles1, m_particles2;
0154   float m_crossingAngle, m_betastar, m_intensity1, m_intensity2, m_energy;
0155   cond::Time_t m_createTime, m_beginTime, m_endTime;
0156   std::string m_injectionScheme;
0157   //BEWARE: since CMS counts bunches starting from one,
0158   //the size of the bitset must be incremented by one,
0159   //in order to avoid off-by-one
0160   std::bitset<bunchSlots + 1> m_bunchConfiguration1, m_bunchConfiguration2;
0161 
0162   COND_SERIALIZABLE;
0163 };
0164 
0165 std::ostream &operator<<(std::ostream &, FillInfo fillInfo);
0166 
0167 #endif  // CondFormats_RunInfo_FillInfo_H