CMS 3D CMS Logo

MagneticFieldFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Alignment/CommonAlignment
4 // Class: MagneticFieldFilter
5 //
20 //
21 // Original Author: Gregor Mittag
22 // Created: Wed, 25 Nov 2015 12:59:02 GMT
23 //
24 //
25 
26 
27 // user include files
36 
37 //
38 // class declaration
39 //
40 
42 public:
43  explicit MagneticFieldFilter(const edm::ParameterSet&);
44  ~MagneticFieldFilter() override = default;
45 
47 
48 private:
49  bool filter(edm::Event&, const edm::EventSetup&) override;
50  void beginRun(const edm::Run&, const edm::EventSetup&) override;
51 
53  float currentToField(const float& current) const;
54 
55  // ----------member data ---------------------------
57  static constexpr float linearCoeffCurrentToField_ = 2.084287e-04;
59  static constexpr float constantTermCurrentToField_ = 1.704418e-02;
60 
61  const int magneticField_;
63 };
64 
65 //
66 // static data member definitions
67 //
70 
71 
72 //
73 // constructor
74 //
76  magneticField_(iConfig.getUntrackedParameter<int>("magneticField")),
77  magneticFieldCurrentRun_(-10000) {
78 }
79 
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called on each new Event ------------
86 bool
89 }
90 
91 // ------------ method called when starting to processes a run ------------
92 
93 void
96  iSetup.get<RunInfoRcd>().get(sum);
97  auto summary = sum.product();
98  // convert from Tesla to kGauss (multiply with 10) and
99  // round off to whole kGauss (add 0.5 and cast to int) as is done in
100  // 'MagneticField::computeNominalValue()':
102  static_cast<int>(currentToField(summary->m_avg_current)*10.0 + 0.5);
103 }
104 
105 
106 float
107 MagneticFieldFilter::currentToField(const float& current) const {
109 }
110 
111 
112 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
113 void
116  desc.setComment("Filters events with a magnetic field of 'magneticField'.");
117  desc.addUntracked<int>("magneticField", 38)
118  ->setComment("In units of kGauss (= 0.1 Tesla).");
119  descriptions.add("magneticFieldFilter", desc);
120 }
121 
122 //define this as a plug-in
static float constantTermCurrentToField_
see: https://hypernews.cern.ch/HyperNews/CMS/get/magnetic-field/63/1/1/1.html
static float linearCoeffCurrentToField_
see: https://hypernews.cern.ch/HyperNews/CMS/get/magnetic-field/63/1/1/1.html
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void beginRun(const edm::Run &, const edm::EventSetup &) override
int magneticFieldCurrentRun_
magnetic field that is filtered
~MagneticFieldFilter() override=default
void setComment(std::string const &value)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
float currentToField(const float &current) const
convert Ampere (A) to Tesla (T)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool filter(edm::Event &, const edm::EventSetup &) override
T get() const
Definition: EventSetup.h:71
static void fillDescriptions(edm::ConfigurationDescriptions &)
T const * product() const
Definition: ESHandle.h:86
MagneticFieldFilter(const edm::ParameterSet &)
#define constexpr
Definition: Run.h:45