Go to the documentation of this file.00001 #include "SteppingHelixPropagatorESProducer.h"
00002 #include "MagneticField/Engine/interface/MagneticField.h"
00003 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00004 #include "MagneticField/VolumeBasedEngine/interface/VolumeBasedMagneticField.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 "FWCore/MessageLogger/interface/MessageLogger.h"
00012
00013 #include <string>
00014 #include <memory>
00015
00016 using namespace edm;
00017
00018 SteppingHelixPropagatorESProducer::SteppingHelixPropagatorESProducer(const edm::ParameterSet & p)
00019 {
00020 std::string myname = p.getParameter<std::string>("ComponentName");
00021 pset_ = p;
00022 setWhatProduced(this,myname);
00023 }
00024
00025 SteppingHelixPropagatorESProducer::~SteppingHelixPropagatorESProducer() {}
00026
00027 boost::shared_ptr<Propagator>
00028 SteppingHelixPropagatorESProducer::produce(const TrackingComponentsRecord & iRecord){
00029
00030
00031
00032
00033 ESHandle<MagneticField> magfield;
00034 iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield );
00035
00036 std::string pdir = pset_.getParameter<std::string>("PropagationDirection");
00037
00038 PropagationDirection dir = alongMomentum;
00039
00040 if (pdir == "oppositeToMomentum") dir = oppositeToMomentum;
00041 if (pdir == "alongMomentum") dir = alongMomentum;
00042 if (pdir == "anyDirection") dir = anyDirection;
00043
00044 SteppingHelixPropagator* shProp = new SteppingHelixPropagator(&(*magfield), dir);
00045
00046 bool useInTeslaFromMagField = pset_.getParameter<bool>("useInTeslaFromMagField");
00047 bool setVBFPointer = pset_.getParameter<bool>("SetVBFPointer");
00048 bool useMagVolumes = pset_.getParameter<bool>("useMagVolumes");
00049
00050
00051
00052 if (useMagVolumes==true && !useInTeslaFromMagField && !setVBFPointer && magfield->nominalValue() == 0) {
00053 const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&(*magfield));
00054 if (vbfCPtr ==0 ){
00055 edm::LogWarning("SteppingHelixPropagator") << "Config specifies useMagVolumes==True but no VBF field available: SHP has no access to yoke material properties. Use setVBFPointer=true and VBFName cards to set a VBF field, otherwise set useMagVolumes==False." << std::endl;
00056 } else {
00057 edm::LogInfo("SteppingHelixPropagator") << "Config specifies useMagVolumes==true and VBF field available: Forcing useInTeslaFromMagField = True." <<std::endl;
00058 useInTeslaFromMagField = true;
00059 }
00060 }
00061
00062 if (setVBFPointer){
00063 std::string vbfName = pset_.getParameter<std::string>("VBFName");
00064 ESHandle<MagneticField> vbfField;
00065 iRecord.getRecord<IdealMagneticFieldRecord>().get(vbfName, vbfField );
00066 const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&(*vbfField));
00067 if (vbfField.isValid()) shProp->setVBFPointer(vbfCPtr);
00068 }
00069
00070 shProp->setUseInTeslaFromMagField(useInTeslaFromMagField);
00071
00072 bool haveX0Corr = pset_.getParameter<bool>("ApplyRadX0Correction");
00073 shProp->applyRadX0Correction(haveX0Corr);
00074
00075 bool assumeNoMaterial = pset_.getParameter<bool>("AssumeNoMaterial");
00076 shProp->setMaterialMode(assumeNoMaterial);
00077
00078 bool noErrorPropagation = pset_.getParameter<bool>("NoErrorPropagation");
00079 shProp->setNoErrorPropagation(noErrorPropagation);
00080
00081 bool debugMode = pset_.getParameter<bool>("debug");
00082 shProp->setDebug(debugMode);
00083
00084 shProp->setUseMagVolumes(useMagVolumes);
00085
00086 bool useMatVolumes = pset_.getParameter<bool>("useMatVolumes");
00087 shProp->setUseMatVolumes(useMatVolumes);
00088
00089 bool useIsYokeFlag = pset_.getParameter<bool>("useIsYokeFlag");
00090 shProp->setUseIsYokeFlag(useIsYokeFlag);
00091
00092 bool returnTangentPlane = pset_.getParameter<bool>("returnTangentPlane");
00093 shProp->setReturnTangentPlane(returnTangentPlane);
00094
00095 bool sendLogWarning = pset_.getParameter<bool>("sendLogWarning");
00096 shProp->setSendLogWarning(sendLogWarning);
00097
00098 bool useTuningForL2Speed = pset_.getParameter<bool>("useTuningForL2Speed");
00099 shProp->setUseTuningForL2Speed(useTuningForL2Speed);
00100
00101
00102 bool useECoffsets = pset_.getParameter<bool>("useEndcapShiftsInZ");
00103 if (useECoffsets){
00104 double valPos = pset_.getParameter<double>("endcapShiftInZPos");
00105 double valNeg = pset_.getParameter<double>("endcapShiftInZNeg");
00106 shProp->setEndcapShiftsInZPosNeg(valPos, valNeg);
00107 }
00108
00109 _propagator = boost::shared_ptr<Propagator>(shProp);
00110 return _propagator;
00111 }