CMS 3D CMS Logo

CTPPSBeamParametersESSource.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * CondFormats/CTPPSReadoutObjects/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 {
44 public:
45 
47  ~CTPPSBeamParametersESSource() override = default;
48 
49  std::unique_ptr<CTPPSBeamParameters> produce(const CTPPSBeamParametersRcd&);
51 
52 private:
53 
55 
57  void setBeamParameters(const edm::ParameterSet &);
59  std::unique_ptr<CTPPSBeamParameters> fillBeamParameters();
60 
61  // Beam parameters
62  double beamMom45_, beamMom56_;
63  double betaStarX45_, betaStarY45_, betaStarX56_, betaStarY56_;
64  double beamDivX45_, beamDivY45_, beamDivX56_, beamDivY56_;
65  double halfXangleX45_, halfXangleY45_;
66  double halfXangleX56_, halfXangleY56_;
67  double vtxOffsetX45_, vtxOffsetY45_, vtxOffsetZ45_;
68  double vtxOffsetX56_, vtxOffsetY56_, vtxOffsetZ56_;
69  double vtxStddevX_, vtxStddevY_, vtxStddevZ_;
70 
71 protected:
72 
74  void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&, const edm::IOVSyncValue&, edm::ValidityInterval&) override;
75 };
76 
77 //----------------------------------------------------------------------------------------------------
78 
80  setBeamPars_( iConfig.getParameter<bool>( "setBeamPars" ) ),
81  beamMom45_( 0. ), beamMom56_( 0. ),
82  betaStarX45_( 0. ), betaStarY45_( 0. ), betaStarX56_( 0. ), betaStarY56_( 0. ),
83  beamDivX45_( 0. ), beamDivY45_( 0. ), beamDivX56_( 0. ), beamDivY56_( 0. ),
84  halfXangleX45_( 0. ), halfXangleY45_( 0. ),
85  halfXangleX56_( 0. ), halfXangleY56_( 0. ),
86  vtxOffsetX45_( 0. ), vtxOffsetY45_( 0. ), vtxOffsetZ45_( 0. ),
87  vtxOffsetX56_( 0. ), vtxOffsetY56_( 0. ), vtxOffsetZ56_( 0. ),
88  vtxStddevX_( 0. ), vtxStddevY_( 0. ), vtxStddevZ_( 0. )
89 {
90  if ( setBeamPars_ )
91  setBeamParameters( iConfig );
92 
93  setWhatProduced(this);
94  findingRecord<CTPPSBeamParametersRcd>();
95 }
96 
97 //----------------------------------------------------------------------------------------------------
98 
99 std::unique_ptr<CTPPSBeamParameters>
101 {
102  // If beam parameters are available from the config file, fill their values into CTPPSBeamParameters object
103  auto bp = ( setBeamPars_ )
105  : std::make_unique<CTPPSBeamParameters>();
106 
107  edm::LogInfo("CTPPSBeamParametersESSource::produce") << "\n" << *bp;
108 
109  return bp;
110 }
111 
112 //----------------------------------------------------------------------------------------------------
113 
114 void
116 {
117  beamMom45_ = iConfig.getParameter<double>( "beamMom45" );
118  beamMom56_ = iConfig.getParameter<double>( "beamMom56" );
119  betaStarX45_ = iConfig.getParameter<double>( "betaStarX45" );
120  betaStarX56_ = iConfig.getParameter<double>( "betaStarX56" );
121  betaStarY45_ = iConfig.getParameter<double>( "betaStarY45" );
122  betaStarY56_ = iConfig.getParameter<double>( "betaStarY56" );
123  beamDivX45_ = iConfig.getParameter<double>( "beamDivX45" );
124  beamDivX56_ = iConfig.getParameter<double>( "beamDivX56" );
125  beamDivY45_ = iConfig.getParameter<double>( "beamDivY45" );
126  beamDivY56_ = iConfig.getParameter<double>( "beamDivY56" );
127  halfXangleX45_ = iConfig.getParameter<double>( "halfXangleX45" );
128  halfXangleX56_ = iConfig.getParameter<double>( "halfXangleX56" );
129  halfXangleY45_ = iConfig.getParameter<double>( "halfXangleY45" );
130  halfXangleY56_ = iConfig.getParameter<double>( "halfXangleY56" );
131  vtxOffsetX45_ = iConfig.getParameter<double>( "vtxOffsetX45" );
132  vtxOffsetY45_ = iConfig.getParameter<double>( "vtxOffsetY45" );
133  vtxOffsetZ45_ = iConfig.getParameter<double>( "vtxOffsetZ45" );
134  vtxOffsetX56_ = iConfig.getParameter<double>( "vtxOffsetX56" );
135  vtxOffsetY56_ = iConfig.getParameter<double>( "vtxOffsetY56" );
136  vtxOffsetZ56_ = iConfig.getParameter<double>( "vtxOffsetZ56" );
137  vtxStddevX_ = iConfig.getParameter<double>( "vtxStddevX" );
138  vtxStddevY_ = iConfig.getParameter<double>( "vtxStddevY" );
139  vtxStddevZ_ = iConfig.getParameter<double>( "vtxStddevZ" );
140 }
141 
142 //----------------------------------------------------------------------------------------------------
143 
144 std::unique_ptr<CTPPSBeamParameters>
146 {
147  auto p = std::make_unique<CTPPSBeamParameters>();
148 
149  p->setBeamMom45( beamMom45_ );
150  p->setBeamMom56( beamMom56_ );
151 
152  p->setBetaStarX45( betaStarX45_ );
153  p->setBetaStarY45( betaStarY45_ );
154  p->setBetaStarX56( betaStarX56_ );
155  p->setBetaStarY56( betaStarY56_ );
156 
157  p->setBeamDivergenceX45( beamDivX45_ );
158  p->setBeamDivergenceY45( beamDivY45_ );
159  p->setBeamDivergenceX56( beamDivX56_ );
160  p->setBeamDivergenceY56( beamDivY56_ );
161 
162  p->setHalfXangleX45( halfXangleX45_ );
163  p->setHalfXangleY45( halfXangleY45_ );
164  p->setHalfXangleX56( halfXangleX56_ );
165  p->setHalfXangleY56( halfXangleY56_ );
166 
167  p->setVtxOffsetX45( vtxOffsetX45_ );
168  p->setVtxOffsetY45( vtxOffsetY45_ );
169  p->setVtxOffsetZ45( vtxOffsetZ45_ );
170  p->setVtxOffsetX56( vtxOffsetX56_ );
171  p->setVtxOffsetY56( vtxOffsetY56_ );
172  p->setVtxOffsetZ56( vtxOffsetZ56_ );
173 
174  p->setVtxStddevX( vtxStddevX_ );
175  p->setVtxStddevY( vtxStddevY_ );
176  p->setVtxStddevZ( vtxStddevZ_ );
177 
178  return p;
179 }
180 
181 //----------------------------------------------------------------------------------------------------
182 
183 void
185  const edm::IOVSyncValue& iosv, edm::ValidityInterval& oValidity )
186 {
187  edm::LogInfo("CTPPSBeamParametersESSource")
188  << ">> CTPPSBeamParametersESSource::setIntervalFor(" << key.name() << ")\n"
189  << " run=" << iosv.eventID().run() << ", event=" << iosv.eventID().event();
190 
192  oValidity = infinity;
193 }
194 
195 //----------------------------------------------------------------------------------------------------
196 
197 void
199 {
201  desc.add<bool>( "setBeamPars", true );
202  // beam momentum (GeV)
203  desc.add<double>( "beamMom45", 6500. );
204  desc.add<double>( "beamMom56", 6500. );
205  // beta* (cm)
206  desc.add<double>( "betaStarX45", 30. );
207  desc.add<double>( "betaStarY45", 30. );
208  desc.add<double>( "betaStarX56", 30. );
209  desc.add<double>( "betaStarY56", 30. );
210  // beam divergence (rad)
211  desc.add<double>( "beamDivX45", 0.1 );
212  desc.add<double>( "beamDivY45", 0.1 );
213  desc.add<double>( "beamDivX56", 0.1 );
214  desc.add<double>( "beamDivY56", 0.1 );
215  // half crossing angle (rad)
216  desc.add<double>( "halfXangleX45", 80.e-6 );
217  desc.add<double>( "halfXangleY45", 80.e-6 );
218  desc.add<double>( "halfXangleX56", 80.e-6 );
219  desc.add<double>( "halfXangleY56", 80.e-6 );
220  // vertex offset (cm)
221  desc.add<double>( "vtxOffsetX45", 1.e-2 );
222  desc.add<double>( "vtxOffsetY45", 1.e-2 );
223  desc.add<double>( "vtxOffsetZ45", 1.e-2 );
224  desc.add<double>( "vtxOffsetX56", 1.e-2 );
225  desc.add<double>( "vtxOffsetY56", 1.e-2 );
226  desc.add<double>( "vtxOffsetZ56", 1.e-2 );
227  // vertex sigma (cm)
228  desc.add<double>( "vtxStddevX", 2.e-2 );
229  desc.add<double>( "vtxStddevY", 2.e-2 );
230  desc.add<double>( "vtxStddevZ", 2.e-2 );
231 
232  descriptions.add( "ctppsBeamParametersESSource", desc );
233 }
234 
235 //----------------------------------------------------------------------------------------------------
236 
238 
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:124
EventNumber_t event() const
Definition: EventID.h:41
const EventID & eventID() const
Definition: IOVSyncValue.h:40
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::unique_ptr< CTPPSBeamParameters > produce(const CTPPSBeamParametersRcd &)
std::unique_ptr< CTPPSBeamParameters > fillBeamParameters()
Fill CTPPSBeamParameters object with BP.
#define DEFINE_FWK_EVENTSETUP_SOURCE(type)
Definition: SourceFactory.h:91
void setBeamParameters(const edm::ParameterSet &)
Set BP to their values from config.
Loads CTPPSBeamParameters from a config file.