CMS 3D CMS Logo

MFProducer.cc
Go to the documentation of this file.
10 #include <iostream>
11 
13 {
14 public:
15  explicit MFProducer( const edm::ParameterSet& );
16  ~MFProducer( void ) override;
17 
18 private:
19  void beginJob( void ) override;
20  void produce( edm::Event&, const edm::EventSetup& ) override;
21  void endJob( void ) override;
22  void evaluate( const double point[3], double field[3] ) const;
23  unsigned m_mapDensityX;
24  unsigned m_mapDensityY;
25  unsigned m_mapDensityZ;
26  double m_minX;
27  double m_maxX;
28  double m_minY;
29  double m_maxY;
30  double m_minZ;
31  double m_maxZ;
32  double m_xBaseDir;
33  double m_yBaseDir;
34  double m_zBaseDir;
35  bool m_valid;
37 };
38 
40  : m_valid( false )
41 {
42  m_mapDensityX = iPset.getUntrackedParameter<unsigned>( "mapDensityX", 10 );
43  m_mapDensityY = iPset.getUntrackedParameter<unsigned>( "mapDensityY", 10 );
44  m_mapDensityZ = iPset.getUntrackedParameter<unsigned>( "mapDensityY", 10 );
45  m_minX = iPset.getUntrackedParameter<double>( "minX", -18.0 );
46  m_maxX = iPset.getUntrackedParameter<double>( "maxX", 18.0 );
47  m_minY = iPset.getUntrackedParameter<double>( "minY", -18.0 );
48  m_maxY = iPset.getUntrackedParameter<double>( "maxY", 18.0 );
49  m_minZ = iPset.getUntrackedParameter<double>( "minZ", -18.0 );
50  m_maxZ = iPset.getUntrackedParameter<double>( "maxZ", 18.0 );
51 
52  m_xBaseDir = ( m_maxX - m_minX ) / m_mapDensityX;
53  m_yBaseDir = ( m_maxY - m_minY ) / m_mapDensityY;
54  m_zBaseDir = ( m_maxZ - m_minZ ) / m_mapDensityZ;
55 }
56 
58 {}
59 
60 void
62 {
63  iSetup.get<IdealMagneticFieldRecord>().get( m_mf );
64  m_mf.isValid() ? m_valid = true : m_valid = false;
65 
66  for( unsigned i = 0; i <= m_mapDensityX; ++i )
67  {
68  for( unsigned j = 0; j <= m_mapDensityY; ++j )
69  {
70  // Prepare field position and get value.
71  double x = m_minX + m_xBaseDir * i;
72  double y = m_minY + m_yBaseDir * j;
73  double z = 0.;
74  double pt[3] = { x, y, z };
75  double val[3];
76  evaluate( pt, val );
77  std::cout << "(" << x << ", " << y << ", " << z << ") " << val[0] << ":" << val[1] << ":" << val[2] << "; ";
78  }
79  std::cout << std::endl;
80  }
81 }
82 
83 void
84 MFProducer::evaluate (const double point [3], double field [3]) const
85 {
86  GlobalVector b = m_mf->inTesla( GlobalPoint( point[0], point[1], point[2] ));
87 
88  field [0] = b.x();
89  field [1] = b.y();
90  field [2] = b.z();
91 }
92 
93 void
95 {}
96 
97 void
99 {}
100 
T getUntrackedParameter(std::string const &, T const &) const
unsigned m_mapDensityZ
Definition: MFProducer.cc:25
double m_minX
Definition: MFProducer.cc:26
MFProducer(const edm::ParameterSet &)
Definition: MFProducer.cc:39
void produce(edm::Event &, const edm::EventSetup &) override
Definition: MFProducer.cc:61
void endJob(void) override
Definition: MFProducer.cc:98
double m_minZ
Definition: MFProducer.cc:30
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
unsigned m_mapDensityY
Definition: MFProducer.cc:24
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
unsigned m_mapDensityX
Definition: MFProducer.cc:23
double m_maxX
Definition: MFProducer.cc:27
bool m_valid
Definition: MFProducer.cc:35
double m_xBaseDir
Definition: MFProducer.cc:32
double m_maxZ
Definition: MFProducer.cc:31
int iEvent
Definition: GenABIO.cc:230
double m_maxY
Definition: MFProducer.cc:29
T z() const
Definition: PV3DBase.h:64
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
void evaluate(const double point[3], double field[3]) const
Definition: MFProducer.cc:84
double m_zBaseDir
Definition: MFProducer.cc:34
edm::ESHandle< MagneticField > m_mf
Definition: MFProducer.cc:36
const T & get() const
Definition: EventSetup.h:58
double b
Definition: hdecay.h:120
~MFProducer(void) override
Definition: MFProducer.cc:57
void beginJob(void) override
Definition: MFProducer.cc:94
bool isValid() const
Definition: ESHandle.h:47
T x() const
Definition: PV3DBase.h:62
*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:33
double m_minY
Definition: MFProducer.cc:28