CMS 3D CMS Logo

CTPPSBeamParametersESSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CondFormats/PPSObjects/plugins/CTPPSBeamParametersESSource.cc
4  *
5  * Description : - Loads CTPPSBeamParameters from the CTPPSBeamParametersESSource_cfi.py
6  * config file.
7  * - Currently, one single set of beam parameters is provided. Just to be
8  * ready in time for 10_4_0 and allow simple tests.
9  * - To be further developed to provide multiple sets of parameters
10  * - Needed while CTPPSBeamParameters is not available in database
11  *
12  *
13  * Author:
14  * Wagner Carvalho wcarvalh@cern.ch
15  *
16  ****************************************************************************/
17 
21 
28 
31 
32 #include <memory>
33 
34 //----------------------------------------------------------------------------------------------------
35 
36 using namespace std;
37 
43 public:
45  ~CTPPSBeamParametersESSource() override = default;
46 
47  std::unique_ptr<CTPPSBeamParameters> produce(const CTPPSBeamParametersRcd&);
49 
50 private:
52 
54  void setBeamParameters(const edm::ParameterSet&);
56  std::unique_ptr<CTPPSBeamParameters> fillBeamParameters();
57 
58  // Beam parameters
59  double beamMom45_, beamMom56_;
60  double betaStarX45_, betaStarY45_, betaStarX56_, betaStarY56_;
61  double beamDivX45_, beamDivY45_, beamDivX56_, beamDivY56_;
62  double halfXangleX45_, halfXangleY45_;
63  double halfXangleX56_, halfXangleY56_;
64  double vtxOffsetX45_, vtxOffsetY45_, vtxOffsetZ45_;
65  double vtxOffsetX56_, vtxOffsetY56_, vtxOffsetZ56_;
66  double vtxStddevX_, vtxStddevY_, vtxStddevZ_;
67 
68 protected:
70  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
71  const edm::IOVSyncValue&,
72  edm::ValidityInterval&) override;
73 };
74 
75 //----------------------------------------------------------------------------------------------------
76 
78  : setBeamPars_(iConfig.getParameter<bool>("setBeamPars")),
79  beamMom45_(0.),
80  beamMom56_(0.),
81  betaStarX45_(0.),
82  betaStarY45_(0.),
83  betaStarX56_(0.),
84  betaStarY56_(0.),
85  beamDivX45_(0.),
86  beamDivY45_(0.),
87  beamDivX56_(0.),
88  beamDivY56_(0.),
89  halfXangleX45_(0.),
90  halfXangleY45_(0.),
91  halfXangleX56_(0.),
92  halfXangleY56_(0.),
93  vtxOffsetX45_(0.),
94  vtxOffsetY45_(0.),
95  vtxOffsetZ45_(0.),
96  vtxOffsetX56_(0.),
97  vtxOffsetY56_(0.),
98  vtxOffsetZ56_(0.),
99  vtxStddevX_(0.),
100  vtxStddevY_(0.),
101  vtxStddevZ_(0.) {
102  if (setBeamPars_)
103  setBeamParameters(iConfig);
104 
105  setWhatProduced(this);
106  findingRecord<CTPPSBeamParametersRcd>();
107 }
108 
109 //----------------------------------------------------------------------------------------------------
110 
111 std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersESSource::produce(const CTPPSBeamParametersRcd&) {
112  // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object
113  auto bp = (setBeamPars_) ? fillBeamParameters() : std::make_unique<CTPPSBeamParameters>();
114 
115  edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp;
116 
117  return bp;
118 }
119 
120 //----------------------------------------------------------------------------------------------------
121 
123  beamMom45_ = iConfig.getParameter<double>("beamMom45");
124  beamMom56_ = iConfig.getParameter<double>("beamMom56");
125  betaStarX45_ = iConfig.getParameter<double>("betaStarX45");
126  betaStarX56_ = iConfig.getParameter<double>("betaStarX56");
127  betaStarY45_ = iConfig.getParameter<double>("betaStarY45");
128  betaStarY56_ = iConfig.getParameter<double>("betaStarY56");
129  beamDivX45_ = iConfig.getParameter<double>("beamDivX45");
130  beamDivX56_ = iConfig.getParameter<double>("beamDivX56");
131  beamDivY45_ = iConfig.getParameter<double>("beamDivY45");
132  beamDivY56_ = iConfig.getParameter<double>("beamDivY56");
133  halfXangleX45_ = iConfig.getParameter<double>("halfXangleX45");
134  halfXangleX56_ = iConfig.getParameter<double>("halfXangleX56");
135  halfXangleY45_ = iConfig.getParameter<double>("halfXangleY45");
136  halfXangleY56_ = iConfig.getParameter<double>("halfXangleY56");
137  vtxOffsetX45_ = iConfig.getParameter<double>("vtxOffsetX45");
138  vtxOffsetY45_ = iConfig.getParameter<double>("vtxOffsetY45");
139  vtxOffsetZ45_ = iConfig.getParameter<double>("vtxOffsetZ45");
140  vtxOffsetX56_ = iConfig.getParameter<double>("vtxOffsetX56");
141  vtxOffsetY56_ = iConfig.getParameter<double>("vtxOffsetY56");
142  vtxOffsetZ56_ = iConfig.getParameter<double>("vtxOffsetZ56");
143  vtxStddevX_ = iConfig.getParameter<double>("vtxStddevX");
144  vtxStddevY_ = iConfig.getParameter<double>("vtxStddevY");
145  vtxStddevZ_ = iConfig.getParameter<double>("vtxStddevZ");
146 }
147 
148 //----------------------------------------------------------------------------------------------------
149 
150 std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersESSource::fillBeamParameters() {
151  auto p = std::make_unique<CTPPSBeamParameters>();
152 
153  p->setBeamMom45(beamMom45_);
154  p->setBeamMom56(beamMom56_);
155 
156  p->setBetaStarX45(betaStarX45_);
157  p->setBetaStarY45(betaStarY45_);
158  p->setBetaStarX56(betaStarX56_);
159  p->setBetaStarY56(betaStarY56_);
160 
161  p->setBeamDivergenceX45(beamDivX45_);
162  p->setBeamDivergenceY45(beamDivY45_);
163  p->setBeamDivergenceX56(beamDivX56_);
164  p->setBeamDivergenceY56(beamDivY56_);
165 
166  p->setHalfXangleX45(halfXangleX45_);
167  p->setHalfXangleY45(halfXangleY45_);
168  p->setHalfXangleX56(halfXangleX56_);
169  p->setHalfXangleY56(halfXangleY56_);
170 
171  p->setVtxOffsetX45(vtxOffsetX45_);
172  p->setVtxOffsetY45(vtxOffsetY45_);
173  p->setVtxOffsetZ45(vtxOffsetZ45_);
174  p->setVtxOffsetX56(vtxOffsetX56_);
175  p->setVtxOffsetY56(vtxOffsetY56_);
176  p->setVtxOffsetZ56(vtxOffsetZ56_);
177 
178  p->setVtxStddevX(vtxStddevX_);
179  p->setVtxStddevY(vtxStddevY_);
180  p->setVtxStddevZ(vtxStddevZ_);
181 
182  return p;
183 }
184 
185 //----------------------------------------------------------------------------------------------------
186 
188  const edm::IOVSyncValue& iosv,
189  edm::ValidityInterval& oValidity) {
190  edm::LogInfo("CTPPSBeamParametersESSource")
191  << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n"
192  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
193 
195  oValidity = infinity;
196 }
197 
198 //----------------------------------------------------------------------------------------------------
199 
202  desc.add<bool>("setBeamPars", true);
203  // beam momentum (GeV)
204  desc.add<double>("beamMom45", 6500.);
205  desc.add<double>("beamMom56", 6500.);
206  // beta* (cm)
207  desc.add<double>("betaStarX45", 30.);
208  desc.add<double>("betaStarY45", 30.);
209  desc.add<double>("betaStarX56", 30.);
210  desc.add<double>("betaStarY56", 30.);
211  // beam divergence (rad)
212  desc.add<double>("beamDivX45", 0.1);
213  desc.add<double>("beamDivY45", 0.1);
214  desc.add<double>("beamDivX56", 0.1);
215  desc.add<double>("beamDivY56", 0.1);
216  // half crossing angle (rad)
217  desc.add<double>("halfXangleX45", 80.e-6);
218  desc.add<double>("halfXangleY45", 80.e-6);
219  desc.add<double>("halfXangleX56", 80.e-6);
220  desc.add<double>("halfXangleY56", 80.e-6);
221  // vertex offset (cm)
222  desc.add<double>("vtxOffsetX45", 1.e-2);
223  desc.add<double>("vtxOffsetY45", 1.e-2);
224  desc.add<double>("vtxOffsetZ45", 1.e-2);
225  desc.add<double>("vtxOffsetX56", 1.e-2);
226  desc.add<double>("vtxOffsetY56", 1.e-2);
227  desc.add<double>("vtxOffsetZ56", 1.e-2);
228  // vertex sigma (cm)
229  desc.add<double>("vtxStddevX", 2.e-2);
230  desc.add<double>("vtxStddevY", 2.e-2);
231  desc.add<double>("vtxStddevZ", 2.e-2);
232 
233  descriptions.add("ctppsBeamParametersESSource", desc);
234 }
235 
236 //----------------------------------------------------------------------------------------------------
237 
CTPPSBeamParametersESSource::produce
std::unique_ptr< CTPPSBeamParameters > produce(const CTPPSBeamParametersRcd &)
Definition: CTPPSBeamParametersESSource.cc:111
CTPPSBeamParametersESSource::betaStarX56_
double betaStarX56_
Definition: CTPPSBeamParametersESSource.cc:60
CTPPSBeamParameters.h
CTPPSBeamParametersESSource::CTPPSBeamParametersESSource
CTPPSBeamParametersESSource(const edm::ParameterSet &)
Definition: CTPPSBeamParametersESSource.cc:77
electrons_cff.bool
bool
Definition: electrons_cff.py:372
CTPPSBeamParametersESSource::betaStarY56_
double betaStarY56_
Definition: CTPPSBeamParametersESSource.cc:60
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
CTPPSBeamParametersESSource::beamDivY56_
double beamDivY56_
Definition: CTPPSBeamParametersESSource.cc:61
CTPPSBeamParametersRcd.h
MessageLogger.h
ESHandle.h
CTPPSBeamParametersESSource::betaStarX45_
double betaStarX45_
Definition: CTPPSBeamParametersESSource.cc:60
CTPPSBeamParametersESSource
Loads CTPPSBeamParameters from a config file.
Definition: CTPPSBeamParametersESSource.cc:42
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
CTPPSBeamParametersESSource::beamDivX45_
double beamDivX45_
Definition: CTPPSBeamParametersESSource.cc:61
edm::LogInfo
Definition: MessageLogger.h:254
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::ValidityInterval
Definition: ValidityInterval.h:28
ESProducer.h
infinity
const double infinity
Definition: CSCChamberFitter.cc:10
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::eventsetup::EventSetupRecordKey
Definition: EventSetupRecordKey.h:30
MakerMacros.h
CTPPSBeamParametersESSource::halfXangleX45_
double halfXangleX45_
Definition: CTPPSBeamParametersESSource.cc:62
CTPPSBeamParametersESSource::halfXangleY56_
double halfXangleY56_
Definition: CTPPSBeamParametersESSource.cc:63
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
CTPPSBeamParametersESSource::vtxOffsetZ45_
double vtxOffsetZ45_
Definition: CTPPSBeamParametersESSource.cc:64
fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
CTPPSBeamParametersESSource::vtxStddevX_
double vtxStddevX_
Definition: CTPPSBeamParametersESSource.cc:66
edm::IOVSyncValue
Definition: IOVSyncValue.h:31
edm::EventID::run
RunNumber_t run() const
Definition: EventID.h:38
DEFINE_FWK_EVENTSETUP_SOURCE
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
EventSetupRecordIntervalFinder.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
ESProducts.h
CTPPSBeamParametersESSource::beamDivY45_
double beamDivY45_
Definition: CTPPSBeamParametersESSource.cc:61
SourceFactory.h
CTPPSBeamParametersESSource::vtxStddevZ_
double vtxStddevZ_
Definition: CTPPSBeamParametersESSource.cc:66
edm::IOVSyncValue::eventID
const EventID & eventID() const
Definition: IOVSyncValue.h:40
CTPPSBeamParametersESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
sets infinite validity of this data
Definition: CTPPSBeamParametersESSource.cc:187
edm::ParameterSet
Definition: ParameterSet.h:36
CTPPSBeamParametersESSource::beamMom45_
double beamMom45_
Definition: CTPPSBeamParametersESSource.cc:59
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
edm::EventID::event
EventNumber_t event() const
Definition: EventID.h:40
CTPPSBeamParametersESSource::beamMom56_
double beamMom56_
Definition: CTPPSBeamParametersESSource.cc:59
CTPPSBeamParametersESSource::vtxOffsetY56_
double vtxOffsetY56_
Definition: CTPPSBeamParametersESSource.cc:65
CTPPSBeamParametersESSource::setBeamParameters
void setBeamParameters(const edm::ParameterSet &)
Set BP to their values from config.
Definition: CTPPSBeamParametersESSource.cc:122
CTPPSBeamParametersESSource::betaStarY45_
double betaStarY45_
Definition: CTPPSBeamParametersESSource.cc:60
CTPPSBeamParametersRcd
Definition: CTPPSBeamParametersRcd.h:14
CTPPSBeamParametersESSource::setBeamPars_
bool setBeamPars_
Definition: CTPPSBeamParametersESSource.cc:51
CTPPSBeamParametersESSource::vtxOffsetX45_
double vtxOffsetX45_
Definition: CTPPSBeamParametersESSource.cc:64
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ModuleFactory.h
CTPPSBeamParametersESSource::beamDivX56_
double beamDivX56_
Definition: CTPPSBeamParametersESSource.cc:61
std
Definition: JetResolutionObject.h:76
CTPPSBeamParametersESSource::vtxStddevY_
double vtxStddevY_
Definition: CTPPSBeamParametersESSource.cc:66
CTPPSBeamParametersESSource::vtxOffsetY45_
double vtxOffsetY45_
Definition: CTPPSBeamParametersESSource.cc:64
CTPPSBeamParametersESSource::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &)
Definition: CTPPSBeamParametersESSource.cc:200
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
edm::ESProducer
Definition: ESProducer.h:101
CTPPSBeamParametersESSource::vtxOffsetZ56_
double vtxOffsetZ56_
Definition: CTPPSBeamParametersESSource.cc:65
ParameterSet.h
CTPPSBeamParametersESSource::vtxOffsetX56_
double vtxOffsetX56_
Definition: CTPPSBeamParametersESSource.cc:65
crabWrapper.key
key
Definition: crabWrapper.py:19
CTPPSBeamParametersESSource::halfXangleY45_
double halfXangleY45_
Definition: CTPPSBeamParametersESSource.cc:62
CTPPSBeamParametersESSource::fillBeamParameters
std::unique_ptr< CTPPSBeamParameters > fillBeamParameters()
Fill CTPPSBeamParameters object with BP.
Definition: CTPPSBeamParametersESSource.cc:150
CTPPSBeamParametersESSource::halfXangleX56_
double halfXangleX56_
Definition: CTPPSBeamParametersESSource.cc:63