CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/TrackingTools/MaterialEffects/plugins/PropagatorWithMaterialESProducer.cc

Go to the documentation of this file.
00001 #include "PropagatorWithMaterialESProducer.h"
00002 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00003 #include "MagneticField/Engine/interface/MagneticField.h"
00004 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00005 
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/ModuleFactory.h"
00009 #include "FWCore/Framework/interface/ESProducer.h"
00010 
00011 #include <string>
00012 #include <memory>
00013 
00014 using namespace edm;
00015 
00016 PropagatorWithMaterialESProducer::PropagatorWithMaterialESProducer(const edm::ParameterSet & p) 
00017 {
00018   std::string myname = p.getParameter<std::string>("ComponentName");
00019   pset_ = p;
00020   setWhatProduced(this,myname);
00021 }
00022 
00023 PropagatorWithMaterialESProducer::~PropagatorWithMaterialESProducer() {}
00024 
00025 boost::shared_ptr<Propagator> 
00026 PropagatorWithMaterialESProducer::produce(const TrackingComponentsRecord & iRecord){ 
00027 //   if (_propagator){
00028 //     delete _propagator;
00029 //     _propagator = 0;
00030 //   }
00031   ESHandle<MagneticField> magfield;
00032   iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield );
00033 
00034 
00035   std::string pdir = pset_.getParameter<std::string>("PropagationDirection");
00036   double mass      = pset_.getParameter<double>("Mass");
00037   double maxDPhi   = pset_.getParameter<double>("MaxDPhi");
00038   bool useRK       = pset_.getParameter<bool>("useRungeKutta");
00039   double ptMin     = pset_.existsAs<double>("ptMin") ? pset_.getParameter<double>("ptMin") : -1.0;
00040 
00041   PropagationDirection dir = alongMomentum;
00042   
00043   if (pdir == "oppositeToMomentum") dir = oppositeToMomentum;
00044   if (pdir == "alongMomentum") dir = alongMomentum;
00045   if (pdir == "anyDirection") dir = anyDirection;
00046   
00047   _propagator  = boost::shared_ptr<Propagator>(new PropagatorWithMaterial(dir, mass, &(*magfield),maxDPhi,useRK,ptMin));
00048   return _propagator;
00049 }
00050 
00051