CMS 3D CMS Logo

MFProducer.cc
Go to the documentation of this file.
10 #include <iostream>
11 
12 class MFProducer : public edm::one::EDProducer<> {
13 public:
14  explicit MFProducer(const edm::ParameterSet&);
15  ~MFProducer(void) override;
16 
17 private:
18  void beginJob(void) override;
19  void produce(edm::Event&, const edm::EventSetup&) override;
20  void endJob(void) override;
21  void evaluate(const double point[3], double field[3]) const;
22  unsigned m_mapDensityX;
23  unsigned m_mapDensityY;
24  unsigned m_mapDensityZ;
25  double m_minX;
26  double m_maxX;
27  double m_minY;
28  double m_maxY;
29  double m_minZ;
30  double m_maxZ;
31  double m_xBaseDir;
32  double m_yBaseDir;
33  double m_zBaseDir;
34  bool m_valid;
37 };
38 
39 MFProducer::MFProducer(const edm::ParameterSet& iPset) : m_valid(false), m_mfToken(esConsumes()) {
40  m_mapDensityX = iPset.getUntrackedParameter<unsigned>("mapDensityX", 10);
41  m_mapDensityY = iPset.getUntrackedParameter<unsigned>("mapDensityY", 10);
42  m_mapDensityZ = iPset.getUntrackedParameter<unsigned>("mapDensityY", 10);
43  m_minX = iPset.getUntrackedParameter<double>("minX", -18.0);
44  m_maxX = iPset.getUntrackedParameter<double>("maxX", 18.0);
45  m_minY = iPset.getUntrackedParameter<double>("minY", -18.0);
46  m_maxY = iPset.getUntrackedParameter<double>("maxY", 18.0);
47  m_minZ = iPset.getUntrackedParameter<double>("minZ", -18.0);
48  m_maxZ = iPset.getUntrackedParameter<double>("maxZ", 18.0);
49 
53 }
54 
56 
58  m_mf = iSetup.getHandle(m_mfToken);
59  m_mf.isValid() ? m_valid = true : m_valid = false;
60 
61  for (unsigned i = 0; i <= m_mapDensityX; ++i) {
62  for (unsigned j = 0; j <= m_mapDensityY; ++j) {
63  // Prepare field position and get value.
64  double x = m_minX + m_xBaseDir * i;
65  double y = m_minY + m_yBaseDir * j;
66  double z = 0.;
67  double pt[3] = {x, y, z};
68  double val[3];
69  evaluate(pt, val);
70  std::cout << "(" << x << ", " << y << ", " << z << ") " << val[0] << ":" << val[1] << ":" << val[2] << "; ";
71  }
72  std::cout << std::endl;
73  }
74 }
75 
76 void MFProducer::evaluate(const double point[3], double field[3]) const {
78 
79  field[0] = b.x();
80  field[1] = b.y();
81  field[2] = b.z();
82 }
83 
84 void MFProducer::beginJob(void) {}
85 
86 void MFProducer::endJob(void) {}
87 
unsigned m_mapDensityZ
Definition: MFProducer.cc:24
double m_minX
Definition: MFProducer.cc:25
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
MFProducer(const edm::ParameterSet &)
Definition: MFProducer.cc:39
void produce(edm::Event &, const edm::EventSetup &) override
Definition: MFProducer.cc:57
void endJob(void) override
Definition: MFProducer.cc:86
double m_minZ
Definition: MFProducer.cc:29
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > m_mfToken
Definition: MFProducer.cc:35
unsigned m_mapDensityY
Definition: MFProducer.cc:23
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
unsigned m_mapDensityX
Definition: MFProducer.cc:22
double m_maxX
Definition: MFProducer.cc:26
bool m_valid
Definition: MFProducer.cc:34
double m_xBaseDir
Definition: MFProducer.cc:31
double m_maxZ
Definition: MFProducer.cc:30
void evaluate(const double point[3], double field[3]) const
Definition: MFProducer.cc:76
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
double m_maxY
Definition: MFProducer.cc:28
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
bool isValid() const
Definition: ESHandle.h:44
double m_zBaseDir
Definition: MFProducer.cc:33
edm::ESHandle< MagneticField > m_mf
Definition: MFProducer.cc:36
double b
Definition: hdecay.h:118
~MFProducer(void) override
Definition: MFProducer.cc:55
void beginJob(void) override
Definition: MFProducer.cc:84
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
double m_yBaseDir
Definition: MFProducer.cc:32
double m_minY
Definition: MFProducer.cc:27