Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-03-03 02:23:23

0001 #ifndef CondFormats_RunInfo_LHCInfo_H
0002 #define CondFormats_RunInfo_LHCInfo_H
0003 
0004 #include "CondFormats/Serialization/interface/Serializable.h"
0005 #include "CondFormats/Common/interface/Time.h"
0006 #include <bitset>
0007 #include <iostream>
0008 #include <string>
0009 #include <sstream>
0010 #include <vector>
0011 
0012 class LHCInfo {
0013 public:
0014   enum FillType { UNKNOWN = 0, PROTONS = 1, IONS = 2, COSMICS = 3, GAP = 4 };
0015   enum ParticleType { NONE = 0, PROTON = 1, PB82 = 2, AR18 = 3, D = 4, XE54 = 5 };
0016 
0017   enum IntParamIndex {
0018     LHC_FILL = 0,
0019     BUNCHES_1 = 1,
0020     BUNCHES_2 = 2,
0021     COLLIDING_BUNCHES = 3,
0022     TARGET_BUNCHES = 4,
0023     FILL_TYPE = 5,
0024     PARTICLES_1 = 6,
0025     PARTICLES_2 = 7,
0026     LUMI_SECTION = 8,
0027     ISIZE = 9
0028   };
0029   enum FloatParamIndex {
0030     CROSSING_ANGLE = 0,
0031     BETA_STAR = 1,
0032     INTENSITY_1 = 2,
0033     INTENSITY_2 = 3,
0034     ENERGY = 4,
0035     DELIV_LUMI = 5,
0036     REC_LUMI = 7,
0037     LUMI_PER_B = 8,
0038     BEAM1_VC = 9,
0039     BEAM2_VC = 10,
0040     BEAM1_RF = 11,
0041     BEAM2_RF = 12,
0042     INST_LUMI = 13,
0043     INST_LUMI_ERR = 14,
0044     FSIZE = 15
0045   };
0046   enum TimeParamIndex { CREATE_TIME = 0, BEGIN_TIME = 1, END_TIME = 2, TSIZE = 3 };
0047   enum StringParamIndex { INJECTION_SCHEME = 0, LHC_STATE = 1, LHC_COMMENT = 2, CTPPS_STATUS = 3, SSIZE = 4 };
0048 
0049   typedef FillType FillTypeId;
0050   typedef ParticleType ParticleTypeId;
0051   LHCInfo();
0052   LHCInfo(const LHCInfo& rhs);
0053   ~LHCInfo();
0054 
0055   LHCInfo* cloneFill() const;
0056 
0057   //constant static unsigned integer hosting the maximum number of LHC bunch slots
0058   static size_t const bunchSlots = 3564;
0059 
0060   //constant static unsigned integer hosting the available number of LHC bunch slots
0061   static size_t const availableBunchSlots = 2808;
0062 
0063   void setFillNumber(unsigned short lhcFill);
0064 
0065   //getters
0066   unsigned short const fillNumber() const;
0067 
0068   unsigned short const bunchesInBeam1() const;
0069 
0070   unsigned short const bunchesInBeam2() const;
0071 
0072   unsigned short const collidingBunches() const;
0073 
0074   unsigned short const targetBunches() const;
0075 
0076   FillTypeId const fillType() const;
0077 
0078   ParticleTypeId const particleTypeForBeam1() const;
0079 
0080   ParticleTypeId const particleTypeForBeam2() const;
0081 
0082   float const crossingAngle() const;
0083 
0084   float const betaStar() const;
0085 
0086   float const intensityForBeam1() const;
0087 
0088   float const intensityForBeam2() const;
0089 
0090   float const energy() const;
0091 
0092   float const delivLumi() const;
0093 
0094   float const recLumi() const;
0095 
0096   float const instLumi() const;
0097 
0098   float const instLumiError() const;
0099 
0100   cond::Time_t const createTime() const;
0101 
0102   cond::Time_t const beginTime() const;
0103 
0104   cond::Time_t const endTime() const;
0105 
0106   std::string const& injectionScheme() const;
0107 
0108   std::vector<float> const& lumiPerBX() const;
0109 
0110   std::string const& lhcState() const;
0111 
0112   std::string const& lhcComment() const;
0113 
0114   std::string const& ctppsStatus() const;
0115 
0116   unsigned int const& lumiSection() const;
0117 
0118   std::vector<float> const& beam1VC() const;
0119 
0120   std::vector<float> const& beam2VC() const;
0121 
0122   std::vector<float> const& beam1RF() const;
0123 
0124   std::vector<float> const& beam2RF() const;
0125 
0126   std::vector<float>& beam1VC();
0127 
0128   std::vector<float>& beam2VC();
0129 
0130   std::vector<float>& beam1RF();
0131 
0132   std::vector<float>& beam2RF();
0133 
0134   //returns a boolean, true if the injection scheme has a leading 25ns
0135   //TODO: parse the circulating bunch configuration, instead of the string.
0136   bool is25nsBunchSpacing() const;
0137 
0138   //returns a boolean, true if the bunch slot number is in the circulating bunch configuration
0139   bool isBunchInBeam1(size_t const& bunch) const;
0140 
0141   bool isBunchInBeam2(size_t const& bunch) const;
0142 
0143   //member functions returning *by value* a vector with all filled bunch slots
0144   std::vector<unsigned short> bunchConfigurationForBeam1() const;
0145 
0146   std::vector<unsigned short> bunchConfigurationForBeam2() const;
0147 
0148   //setters
0149   void setBunchesInBeam1(unsigned short const& bunches);
0150 
0151   void setBunchesInBeam2(unsigned short const& bunches);
0152 
0153   void setCollidingBunches(unsigned short const& collidingBunches);
0154 
0155   void setTargetBunches(unsigned short const& targetBunches);
0156 
0157   void setFillType(FillTypeId const& fillType);
0158 
0159   void setParticleTypeForBeam1(ParticleTypeId const& particleType);
0160 
0161   void setParticleTypeForBeam2(ParticleTypeId const& particleType);
0162 
0163   void setCrossingAngle(float const& angle);
0164 
0165   void setBetaStar(float const& betaStar);
0166 
0167   void setIntensityForBeam1(float const& intensity);
0168 
0169   void setIntensityForBeam2(float const& intensity);
0170 
0171   void setEnergy(float const& energy);
0172 
0173   void setDelivLumi(float const& delivLumi);
0174 
0175   void setRecLumi(float const& recLumi);
0176 
0177   void setInstLumi(float const& instLumi);
0178 
0179   void setInstLumiError(float const& instLumiError);
0180 
0181   void setCreationTime(cond::Time_t const& createTime);
0182 
0183   void setBeginTime(cond::Time_t const& beginTime);
0184 
0185   void setEndTime(cond::Time_t const& endTime);
0186 
0187   void setInjectionScheme(std::string const& injectionScheme);
0188 
0189   void setLumiPerBX(std::vector<float> const& lumiPerBX);
0190 
0191   void setLhcState(std::string const& lhcState);
0192 
0193   void setLhcComment(std::string const& lhcComment);
0194 
0195   void setCtppsStatus(std::string const& ctppsStatus);
0196 
0197   void setLumiSection(unsigned int const& lumiSection);
0198 
0199   void setBeam1VC(std::vector<float> const& beam1VC);
0200 
0201   void setBeam2VC(std::vector<float> const& beam2VC);
0202 
0203   void setBeam1RF(std::vector<float> const& beam1RF);
0204 
0205   void setBeam2RF(std::vector<float> const& beam2RF);
0206 
0207   //sets all values in one go
0208   void setInfo(unsigned short const& bunches1,
0209                unsigned short const& bunches2,
0210                unsigned short const& collidingBunches,
0211                unsigned short const& targetBunches,
0212                FillTypeId const& fillType,
0213                ParticleTypeId const& particleType1,
0214                ParticleTypeId const& particleType2,
0215                float const& angle,
0216                float const& beta,
0217                float const& intensity1,
0218                float const& intensity2,
0219                float const& energy,
0220                float const& delivLumi,
0221                float const& recLumi,
0222                float const& instLumi,
0223                float const& instLumiError,
0224                cond::Time_t const& createTime,
0225                cond::Time_t const& beginTime,
0226                cond::Time_t const& endTime,
0227                std::string const& scheme,
0228                std::vector<float> const& lumiPerBX,
0229                std::string const& lhcState,
0230                std::string const& lhcComment,
0231                std::string const& ctppsStatus,
0232                unsigned int const& lumiSection,
0233                std::vector<float> const& beam1VC,
0234                std::vector<float> const& beam2VC,
0235                std::vector<float> const& beam1RF,
0236                std::vector<float> const& beam2RF,
0237                std::bitset<bunchSlots + 1> const& bunchConf1,
0238                std::bitset<bunchSlots + 1> const& bunchConf2);
0239 
0240   bool equals(const LHCInfo& rhs) const;
0241 
0242   bool empty() const;
0243 
0244   //dumping values on output stream
0245   void print(std::stringstream& ss) const;
0246 
0247   std::bitset<bunchSlots + 1> const& bunchBitsetForBeam1() const;
0248 
0249   std::bitset<bunchSlots + 1> const& bunchBitsetForBeam2() const;
0250 
0251   void setBunchBitsetForBeam1(std::bitset<bunchSlots + 1> const& bunchConfiguration);
0252 
0253   void setBunchBitsetForBeam2(std::bitset<bunchSlots + 1> const& bunchConfiguration);
0254 
0255 private:
0256   bool m_isData = false;
0257   std::vector<std::vector<unsigned int> > m_intParams;
0258   std::vector<std::vector<float> > m_floatParams;
0259   std::vector<std::vector<unsigned long long> > m_timeParams;
0260   std::vector<std::vector<std::string> > m_stringParams;
0261   std::bitset<bunchSlots + 1> m_bunchConfiguration1, m_bunchConfiguration2;
0262 
0263   COND_SERIALIZABLE;
0264 };
0265 
0266 std::ostream& operator<<(std::ostream&, LHCInfo lhcInfo);
0267 
0268 #endif  // CondFormats_RunInfo_LHCInfo_H