Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "PropagatorWithMaterialESProducer.h"
0002 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
0003 
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/ModuleFactory.h"
0007 #include "FWCore/Framework/interface/ESProducer.h"
0008 #include "FWCore/Utilities/interface/ESInputTag.h"
0009 
0010 #include <string>
0011 #include <memory>
0012 
0013 using namespace edm;
0014 
0015 namespace {
0016   PropagationDirection stringToDirection(std::string const& iName) {
0017     PropagationDirection dir = alongMomentum;
0018 
0019     if (iName == "oppositeToMomentum")
0020       dir = oppositeToMomentum;
0021     if (iName == "alongMomentum")
0022       dir = alongMomentum;
0023     if (iName == "anyDirection")
0024       dir = anyDirection;
0025     return dir;
0026   }
0027 }  // namespace
0028 
0029 PropagatorWithMaterialESProducer::PropagatorWithMaterialESProducer(const edm::ParameterSet& p)
0030     : mfToken_(setWhatProduced(this, p.getParameter<std::string>("ComponentName"))
0031                    .consumesFrom<MagneticField, IdealMagneticFieldRecord>(
0032                        edm::ESInputTag("", p.getParameter<std::string>("SimpleMagneticField")))),
0033       mass_(p.getParameter<double>("Mass")),
0034       maxDPhi_(p.getParameter<double>("MaxDPhi")),
0035       ptMin_(p.getParameter<double>("ptMin")),
0036       dir_(stringToDirection(p.getParameter<std::string>("PropagationDirection"))),
0037       useRK_(p.getParameter<bool>("useRungeKutta")),
0038       useOldAnalPropLogic_(p.getParameter<bool>("useOldAnalPropLogic")) {}
0039 
0040 std::unique_ptr<Propagator> PropagatorWithMaterialESProducer::produce(const TrackingComponentsRecord& iRecord) {
0041   //  edm::ESInputTag mfESInputTag(mfName);
0042   //  iRecord.getRecord<IdealMagneticFieldRecord>().get(mfESInputTag,magfield);
0043   //fixme check that useRK is false when using SimpleMagneticField
0044 
0045   return std::make_unique<PropagatorWithMaterial>(
0046       dir_, mass_, &iRecord.get(mfToken_), maxDPhi_, useRK_, ptMin_, useOldAnalPropLogic_);
0047 }
0048 
0049 void PropagatorWithMaterialESProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0050   ParameterSetDescription desc;
0051   desc.add<std::string>("PropagationDirection");
0052   desc.add<std::string>("SimpleMagneticField", "");
0053   desc.add<std::string>("ComponentName");
0054   desc.add<double>("Mass");
0055   desc.add<double>("MaxDPhi");
0056   desc.add<bool>("useRungeKutta");
0057   desc.add<bool>("useOldAnalPropLogic", true);
0058   desc.add<double>("ptMin", -1.0);
0059   descriptions.addDefault(desc);
0060 }