File indexing completed on 2024-04-06 12:03:17
0001 #ifndef CondTools_RunInfo_LHCInfoCombined_H
0002 #define CondTools_RunInfo_LHCInfoCombined_H
0003
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/DependentRecordImplementation.h"
0006
0007 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0008 #include "CondFormats/RunInfo/interface/LHCInfoPerLS.h"
0009 #include "CondFormats/RunInfo/interface/LHCInfoPerFill.h"
0010
0011 #include "CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h"
0012 #include "CondFormats/DataRecord/interface/LHCInfoPerFillRcd.h"
0013 #include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
0014
0015 #include <bitset>
0016 #include <iostream>
0017 #include <string>
0018 #include <sstream>
0019 #include <vector>
0020
0021 class LHCInfoCombined {
0022 public:
0023 LHCInfoCombined() = default;
0024
0025 LHCInfoCombined(const LHCInfo& lhcInfo);
0026 LHCInfoCombined(const LHCInfoPerLS& infoPerLS, const LHCInfoPerFill& infoPerFill);
0027 LHCInfoCombined(const edm::EventSetup& iSetup,
0028 const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd>& tokenInfoPerLS,
0029 const edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd>& tokenInfoPerFill,
0030 const edm::ESGetToken<LHCInfo, LHCInfoRcd>& tokenInfo,
0031 bool useNewLHCInfo);
0032
0033
0034 template <class RecordT, class ListT>
0035 static LHCInfoCombined createLHCInfoCombined(
0036 const edm::eventsetup::DependentRecordImplementation<RecordT, ListT>& iRecord,
0037 const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd>& tokenInfoPerLS,
0038 const edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd>& tokenInfoPerFill,
0039 const edm::ESGetToken<LHCInfo, LHCInfoRcd>& tokenInfo,
0040 bool useNewLHCInfo);
0041
0042 void setFromLHCInfo(const LHCInfo& lhcInfo);
0043 void setFromPerLS(const LHCInfoPerLS& infoPerLS);
0044 void setFromPerFill(const LHCInfoPerFill& infoPerFill);
0045
0046 float crossingAngle() const;
0047 static constexpr float crossingAngleInvalid = -1.;
0048 bool isCrossingAngleInvalid();
0049
0050 float crossingAngleX;
0051 float crossingAngleY;
0052 float betaStarX;
0053 float betaStarY;
0054 float energy;
0055 unsigned short fillNumber;
0056
0057 void print(std::ostream& os) const;
0058 };
0059
0060 std::ostream& operator<<(std::ostream& os, LHCInfoCombined beamInfo);
0061
0062 template <class RecordT, class ListT>
0063 LHCInfoCombined LHCInfoCombined::createLHCInfoCombined(
0064 const edm::eventsetup::DependentRecordImplementation<RecordT, ListT>& iRecord,
0065 const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd>& tokenInfoPerLS,
0066 const edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd>& tokenInfoPerFill,
0067 const edm::ESGetToken<LHCInfo, LHCInfoRcd>& tokenInfo,
0068 bool useNewLHCInfo) {
0069 LHCInfoCombined lhcInfoCombined;
0070 if (useNewLHCInfo) {
0071 LHCInfoPerLS const& lhcInfoPerLS = iRecord.get(tokenInfoPerLS);
0072 LHCInfoPerFill const& lhcInfoPerFill = iRecord.get(tokenInfoPerFill);
0073 lhcInfoCombined.setFromPerLS(lhcInfoPerLS);
0074 lhcInfoCombined.setFromPerFill(lhcInfoPerFill);
0075 } else {
0076 LHCInfo const& lhcInfo = iRecord.get(tokenInfo);
0077 lhcInfoCombined.setFromLHCInfo(lhcInfo);
0078 }
0079 return lhcInfoCombined;
0080 }
0081
0082 #endif