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_, vtxOffsetT45_;
65  double vtxOffsetX56_, vtxOffsetY56_, vtxOffsetZ56_, vtxOffsetT56_;
66  double vtxStddevX_, vtxStddevY_, vtxStddevZ_, vtxStddevT_;
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  vtxOffsetT45_(0.),
97  vtxOffsetX56_(0.),
98  vtxOffsetY56_(0.),
99  vtxOffsetZ56_(0.),
100  vtxOffsetT56_(0.),
101  vtxStddevX_(0.),
102  vtxStddevY_(0.),
103  vtxStddevZ_(0.),
104  vtxStddevT_(0.) {
105  if (setBeamPars_)
106  setBeamParameters(iConfig);
107 
108  setWhatProduced(this);
109  findingRecord<CTPPSBeamParametersRcd>();
110 }
111 
112 //----------------------------------------------------------------------------------------------------
113 
114 std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersESSource::produce(const CTPPSBeamParametersRcd&) {
115  // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object
116  auto bp = (setBeamPars_) ? fillBeamParameters() : std::make_unique<CTPPSBeamParameters>();
117 
118  edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp;
119 
120  return bp;
121 }
122 
123 //----------------------------------------------------------------------------------------------------
124 
126  beamMom45_ = iConfig.getParameter<double>("beamMom45");
127  beamMom56_ = iConfig.getParameter<double>("beamMom56");
128  betaStarX45_ = iConfig.getParameter<double>("betaStarX45");
129  betaStarX56_ = iConfig.getParameter<double>("betaStarX56");
130  betaStarY45_ = iConfig.getParameter<double>("betaStarY45");
131  betaStarY56_ = iConfig.getParameter<double>("betaStarY56");
132  beamDivX45_ = iConfig.getParameter<double>("beamDivX45");
133  beamDivX56_ = iConfig.getParameter<double>("beamDivX56");
134  beamDivY45_ = iConfig.getParameter<double>("beamDivY45");
135  beamDivY56_ = iConfig.getParameter<double>("beamDivY56");
136  halfXangleX45_ = iConfig.getParameter<double>("halfXangleX45");
137  halfXangleX56_ = iConfig.getParameter<double>("halfXangleX56");
138  halfXangleY45_ = iConfig.getParameter<double>("halfXangleY45");
139  halfXangleY56_ = iConfig.getParameter<double>("halfXangleY56");
140  vtxOffsetX45_ = iConfig.getParameter<double>("vtxOffsetX45");
141  vtxOffsetY45_ = iConfig.getParameter<double>("vtxOffsetY45");
142  vtxOffsetZ45_ = iConfig.getParameter<double>("vtxOffsetZ45");
143  vtxOffsetT45_ = iConfig.getParameter<double>("vtxOffsetT45");
144  vtxOffsetX56_ = iConfig.getParameter<double>("vtxOffsetX56");
145  vtxOffsetY56_ = iConfig.getParameter<double>("vtxOffsetY56");
146  vtxOffsetZ56_ = iConfig.getParameter<double>("vtxOffsetZ56");
147  vtxOffsetT56_ = iConfig.getParameter<double>("vtxOffsetT56");
148  vtxStddevX_ = iConfig.getParameter<double>("vtxStddevX");
149  vtxStddevY_ = iConfig.getParameter<double>("vtxStddevY");
150  vtxStddevZ_ = iConfig.getParameter<double>("vtxStddevZ");
151  vtxStddevT_ = iConfig.getParameter<double>("vtxStddevT");
152 }
153 
154 //----------------------------------------------------------------------------------------------------
155 
156 std::unique_ptr<CTPPSBeamParameters> CTPPSBeamParametersESSource::fillBeamParameters() {
157  auto p = std::make_unique<CTPPSBeamParameters>();
158 
159  p->setBeamMom45(beamMom45_);
160  p->setBeamMom56(beamMom56_);
161 
162  p->setBetaStarX45(betaStarX45_);
163  p->setBetaStarY45(betaStarY45_);
164  p->setBetaStarX56(betaStarX56_);
165  p->setBetaStarY56(betaStarY56_);
166 
167  p->setBeamDivergenceX45(beamDivX45_);
168  p->setBeamDivergenceY45(beamDivY45_);
169  p->setBeamDivergenceX56(beamDivX56_);
170  p->setBeamDivergenceY56(beamDivY56_);
171 
172  p->setHalfXangleX45(halfXangleX45_);
173  p->setHalfXangleY45(halfXangleY45_);
174  p->setHalfXangleX56(halfXangleX56_);
175  p->setHalfXangleY56(halfXangleY56_);
176 
177  p->setVtxOffsetX45(vtxOffsetX45_);
178  p->setVtxOffsetY45(vtxOffsetY45_);
179  p->setVtxOffsetZ45(vtxOffsetZ45_);
180  p->setVtxOffsetT45(vtxOffsetT45_);
181  p->setVtxOffsetX56(vtxOffsetX56_);
182  p->setVtxOffsetY56(vtxOffsetY56_);
183  p->setVtxOffsetZ56(vtxOffsetZ56_);
184  p->setVtxOffsetT56(vtxOffsetT56_);
185 
186  p->setVtxStddevX(vtxStddevX_);
187  p->setVtxStddevY(vtxStddevY_);
188  p->setVtxStddevZ(vtxStddevZ_);
189  p->setVtxStddevT(vtxStddevT_);
190 
191  return p;
192 }
193 
194 //----------------------------------------------------------------------------------------------------
195 
197  const edm::IOVSyncValue& iosv,
198  edm::ValidityInterval& oValidity) {
199  edm::LogInfo("CTPPSBeamParametersESSource")
200  << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n"
201  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
202 
204  oValidity = infinity;
205 }
206 
207 //----------------------------------------------------------------------------------------------------
208 
211  desc.add<bool>("setBeamPars", true);
212  // beam momentum (GeV)
213  desc.add<double>("beamMom45", 6500.);
214  desc.add<double>("beamMom56", 6500.);
215  // beta* (cm)
216  desc.add<double>("betaStarX45", 30.);
217  desc.add<double>("betaStarY45", 30.);
218  desc.add<double>("betaStarX56", 30.);
219  desc.add<double>("betaStarY56", 30.);
220  // beam divergence (rad)
221  desc.add<double>("beamDivX45", 0.1);
222  desc.add<double>("beamDivY45", 0.1);
223  desc.add<double>("beamDivX56", 0.1);
224  desc.add<double>("beamDivY56", 0.1);
225  // half crossing angle (rad)
226  desc.add<double>("halfXangleX45", 80.e-6);
227  desc.add<double>("halfXangleY45", 80.e-6);
228  desc.add<double>("halfXangleX56", 80.e-6);
229  desc.add<double>("halfXangleY56", 80.e-6);
230  // vertex offset (cm)
231  desc.add<double>("vtxOffsetX45", 1.e-2);
232  desc.add<double>("vtxOffsetY45", 1.e-2);
233  desc.add<double>("vtxOffsetZ45", 1.e-2);
234  desc.add<double>("vtxOffsetT45", 1.e-2);
235  desc.add<double>("vtxOffsetX56", 1.e-2);
236  desc.add<double>("vtxOffsetY56", 1.e-2);
237  desc.add<double>("vtxOffsetZ56", 1.e-2);
238  desc.add<double>("vtxOffsetT56", 1.e-2);
239  // vertex sigma (cm)
240  desc.add<double>("vtxStddevX", 2.e-2);
241  desc.add<double>("vtxStddevY", 2.e-2);
242  desc.add<double>("vtxStddevZ", 2.e-2);
243  desc.add<double>("vtxStddevT", 2.e-2);
244 
245  descriptions.add("ctppsBeamParametersESSource", desc);
246 }
247 
248 //----------------------------------------------------------------------------------------------------
249 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static const IOVSyncValue & endOfTime()
Definition: IOVSyncValue.cc:82
CTPPSBeamParametersESSource(const edm::ParameterSet &)
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
sets infinite validity of this data
static const IOVSyncValue & beginOfTime()
Definition: IOVSyncValue.cc:88
const double infinity
key
prepare the HTCondor submission files and eventually submit them
Log< level::Info, false > LogInfo
RunNumber_t run() const
Definition: EventID.h:38
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:92
static void fillDescriptions(edm::ConfigurationDescriptions &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const EventID & eventID() const
Definition: IOVSyncValue.h:40
std::unique_ptr< CTPPSBeamParameters > produce(const CTPPSBeamParametersRcd &)
std::unique_ptr< CTPPSBeamParameters > fillBeamParameters()
Fill CTPPSBeamParameters object with BP.
void setBeamParameters(const edm::ParameterSet &)
Set BP to their values from config.
EventNumber_t event() const
Definition: EventID.h:40
Loads CTPPSBeamParameters from a config file.