Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:31:54

0001 #include "GeantPropagatorESProducer.h"
0002 
0003 #include "TrackPropagation/Geant4e/interface/Geant4ePropagator.h"
0004 
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/ESProducer.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/ModuleFactory.h"
0009 
0010 #include <memory>
0011 #include <string>
0012 
0013 using namespace edm;
0014 
0015 GeantPropagatorESProducer::GeantPropagatorESProducer(const edm::ParameterSet &p)
0016     : magFieldToken_(setWhatProduced(this, p.getParameter<std::string>("ComponentName"))
0017                          .consumesFrom<MagneticField, IdealMagneticFieldRecord>(edm::ESInputTag("", ""))) {
0018   pset_ = p;
0019   plimit_ = pset_.getParameter<double>("PropagationPtotLimit");
0020 }
0021 
0022 GeantPropagatorESProducer::~GeantPropagatorESProducer() {}
0023 
0024 std::unique_ptr<Propagator> GeantPropagatorESProducer::produce(const TrackingComponentsRecord &iRecord) {
0025   std::string pdir = pset_.getParameter<std::string>("PropagationDirection");
0026   std::string particleName = pset_.getParameter<std::string>("ParticleName");
0027 
0028   PropagationDirection dir = alongMomentum;
0029 
0030   if (pdir == "oppositeToMomentum") {
0031     dir = oppositeToMomentum;
0032   } else if (pdir == "alongMomentum") {
0033     dir = alongMomentum;
0034   } else if (pdir == "anyDirection") {
0035     dir = anyDirection;
0036   }
0037 
0038   return std::make_unique<Geant4ePropagator>(&(iRecord.get(magFieldToken_)), particleName, dir, plimit_);
0039 }