88
99#include " FWCore/MessageLogger/interface/MessageLogger.h"
1010
11- #include " CondFormats/DataRecord/interface/LHCInfoRcd.h"
11+ #include " CondTools/RunInfo/interface/LHCInfoCombined.h"
12+
1213#include " CondFormats/DataRecord/interface/CTPPSOpticsRcd.h"
1314#include " CondFormats/DataRecord/interface/CTPPSInterpolatedOpticsRcd.h"
1415
@@ -28,19 +29,26 @@ class CTPPSInterpolatedOpticalFunctionsESSource : public edm::ESProducer {
2829private:
2930 edm::ESGetToken<LHCOpticalFunctionsSetCollection, CTPPSOpticsRcd> opticsToken_;
3031 edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;
32+ edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> lhcInfoPerLSToken_;
33+ edm::ESGetToken<LHCInfoPerFill, LHCInfoPerFillRcd> lhcInfoPerFillToken_;
3134 std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> currentData_;
3235 float currentCrossingAngle_;
3336 bool currentDataValid_;
37+ const bool useNewLHCInfo_;
3438};
3539
3640// ----------------------------------------------------------------------------------------------------
3741// ----------------------------------------------------------------------------------------------------
3842
3943CTPPSInterpolatedOpticalFunctionsESSource::CTPPSInterpolatedOpticalFunctionsESSource (const edm::ParameterSet &iConfig)
40- : currentCrossingAngle_(-1 .), currentDataValid_(false ) {
44+ : currentCrossingAngle_(LHCInfoCombined::crossingAngleInvalid),
45+ currentDataValid_(false ),
46+ useNewLHCInfo_(iConfig.getParameter<bool >(" useNewLHCInfo" )) {
4147 auto cc = setWhatProduced (this , iConfig.getParameter <std::string>(" opticsLabel" ));
4248 opticsToken_ = cc.consumes (edm::ESInputTag (" " , iConfig.getParameter <std::string>(" opticsLabel" )));
4349 lhcInfoToken_ = cc.consumes (edm::ESInputTag (" " , iConfig.getParameter <std::string>(" lhcInfoLabel" )));
50+ lhcInfoPerLSToken_ = cc.consumes (edm::ESInputTag (" " , iConfig.getParameter <std::string>(" lhcInfoPerLSLabel" )));
51+ lhcInfoPerFillToken_ = cc.consumes (edm::ESInputTag (" " , iConfig.getParameter <std::string>(" lhcInfoPerFillLabel" )));
4452}
4553
4654// ----------------------------------------------------------------------------------------------------
@@ -49,7 +57,10 @@ void CTPPSInterpolatedOpticalFunctionsESSource::fillDescriptions(edm::Configurat
4957 edm::ParameterSetDescription desc;
5058
5159 desc.add <std::string>(" lhcInfoLabel" , " " )->setComment (" label of the LHCInfo record" );
60+ desc.add <std::string>(" lhcInfoPerFillLabel" , " " )->setComment (" label of the LHCInfoPerFill record" );
61+ desc.add <std::string>(" lhcInfoPerLSLabel" , " " )->setComment (" label of the LHCInfoPerLS record" );
5262 desc.add <std::string>(" opticsLabel" , " " )->setComment (" label of the optics records" );
63+ desc.add <bool >(" useNewLHCInfo" , false )->setComment (" flag whether to use new LHCInfoPer* records or old LHCInfo" );
5364
5465 descriptions.add (" ctppsInterpolatedOpticalFunctionsESSource" , desc);
5566}
@@ -61,26 +72,29 @@ std::shared_ptr<LHCInterpolatedOpticalFunctionsSetCollection> CTPPSInterpolatedO
6172 // get the input data
6273 LHCOpticalFunctionsSetCollection const &ofColl = iRecord.get (opticsToken_);
6374
64- LHCInfo const &lhcInfo = iRecord.get (lhcInfoToken_);
75+ auto lhcInfoCombined = LHCInfoCombined::createLHCInfoCombined<
76+ CTPPSInterpolatedOpticsRcd,
77+ edm::mpl::Vector<CTPPSOpticsRcd, LHCInfoRcd, LHCInfoPerFillRcd, LHCInfoPerLSRcd>>(
78+ iRecord, lhcInfoPerLSToken_, lhcInfoPerFillToken_, lhcInfoToken_, useNewLHCInfo_);
6579
6680 // is there anything to do?
67- if (currentDataValid_ && lhcInfo .crossingAngle () == currentCrossingAngle_)
81+ if (currentDataValid_ && lhcInfoCombined .crossingAngle () == currentCrossingAngle_)
6882 return currentData_;
6983
7084 // is crossing angle reasonable (LHCInfo is correctly filled in DB)?
71- if (lhcInfo. crossingAngle () == 0 . ) {
85+ if (lhcInfoCombined. isCrossingAngleInvalid () ) {
7286 edm::LogInfo (" CTPPSInterpolatedOpticalFunctionsESSource" )
7387 << " Invalid crossing angle, no optical functions produced." ;
7488
7589 currentDataValid_ = false ;
76- currentCrossingAngle_ = - 1 ;
90+ currentCrossingAngle_ = LHCInfoCombined::crossingAngleInvalid ;
7791 currentData_ = std::make_shared<LHCInterpolatedOpticalFunctionsSetCollection>();
7892
7993 return currentData_;
8094 }
8195
8296 // set new crossing angle
83- currentCrossingAngle_ = lhcInfo .crossingAngle ();
97+ currentCrossingAngle_ = lhcInfoCombined .crossingAngle ();
8498 edm::LogInfo (" CTPPSInterpolatedOpticalFunctionsESSource" )
8599 << " Crossing angle has changed to " << currentCrossingAngle_ << " ." ;
86100
0 commit comments