CMS 3D CMS Logo

SteppingHelixPropagatorESProducer.cc
Go to the documentation of this file.
5 
10 
12 
13 #include <string>
14 #include <memory>
15 
18 
20 public:
23  std::unique_ptr<Propagator> produce(const TrackingComponentsRecord&);
24 
25 private:
29  const bool setVBFPointer_;
30 };
31 
32 using namespace edm;
33 
35  : pset_{p}, setVBFPointer_{pset_.getParameter<bool>("SetVBFPointer")} {
36  std::string myname = p.getParameter<std::string>("ComponentName");
37  auto c = setWhatProduced(this, myname);
38  magToken_ = c.consumes();
39  if (setVBFPointer_) {
40  vbMagToken_ = c.consumes(edm::ESInputTag("", pset_.getParameter<std::string>("VBFName")));
41  }
42 }
43 
45 
46 std::unique_ptr<Propagator> SteppingHelixPropagatorESProducer::produce(const TrackingComponentsRecord& iRecord) {
47  // if (_propagator){
48  // delete _propagator;
49  // _propagator = 0;
50  // }
51  auto const& magfield = iRecord.get(magToken_);
52 
53  std::string pdir = pset_.getParameter<std::string>("PropagationDirection");
54 
56 
57  if (pdir == "oppositeToMomentum")
59  if (pdir == "alongMomentum")
61  if (pdir == "anyDirection")
62  dir = anyDirection;
63 
64  std::unique_ptr<SteppingHelixPropagator> shProp;
65  shProp = std::make_unique<SteppingHelixPropagator>(&magfield, dir);
66 
67  bool useInTeslaFromMagField = pset_.getParameter<bool>("useInTeslaFromMagField");
68  bool useMagVolumes = pset_.getParameter<bool>("useMagVolumes");
69 
70  // if useMagVolumes == true and an alternate VBF field is not specified with setVBFPointer_,
71  // Force "useInTeslaFromMagField=true" for a B=0 VBF map.
72  if (useMagVolumes == true && !useInTeslaFromMagField && !setVBFPointer_ && magfield.nominalValue() == 0) {
73  const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&magfield);
74  if (vbfCPtr == nullptr) {
75  edm::LogWarning("SteppingHelixPropagator")
76  << "Config specifies useMagVolumes==True but no VBF field available: SHP has no access to yoke material "
77  "properties. Use setVBFPointer=true and VBFName cards to set a VBF field, otherwise set "
78  "useMagVolumes==False."
79  << std::endl;
80  } else {
81  edm::LogInfo("SteppingHelixPropagator")
82  << "Config specifies useMagVolumes==true and VBF field available: Forcing useInTeslaFromMagField = True."
83  << std::endl;
85  }
86  }
87 
88  if (setVBFPointer_) {
89  auto const& vbfField = iRecord.get(vbMagToken_);
90  const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&vbfField);
91  shProp->setVBFPointer(vbfCPtr);
92  }
93 
94  shProp->setUseInTeslaFromMagField(useInTeslaFromMagField);
95 
96  bool haveX0Corr = pset_.getParameter<bool>("ApplyRadX0Correction");
97  shProp->applyRadX0Correction(haveX0Corr);
98 
99  bool assumeNoMaterial = pset_.getParameter<bool>("AssumeNoMaterial");
100  shProp->setMaterialMode(assumeNoMaterial);
101 
102  bool noErrorPropagation = pset_.getParameter<bool>("NoErrorPropagation");
103  shProp->setNoErrorPropagation(noErrorPropagation);
104 
105  bool debugMode = pset_.getParameter<bool>("debug");
106  shProp->setDebug(debugMode);
107 
108  shProp->setUseMagVolumes(useMagVolumes);
109 
110  bool useMatVolumes = pset_.getParameter<bool>("useMatVolumes");
111  shProp->setUseMatVolumes(useMatVolumes);
112 
113  bool useIsYokeFlag = pset_.getParameter<bool>("useIsYokeFlag");
114  shProp->setUseIsYokeFlag(useIsYokeFlag);
115 
116  bool returnTangentPlane = pset_.getParameter<bool>("returnTangentPlane");
117  shProp->setReturnTangentPlane(returnTangentPlane);
118 
119  bool sendLogWarning = pset_.getParameter<bool>("sendLogWarning");
120  shProp->setSendLogWarning(sendLogWarning);
121 
122  bool useTuningForL2Speed = pset_.getParameter<bool>("useTuningForL2Speed");
123  shProp->setUseTuningForL2Speed(useTuningForL2Speed);
124 
125  bool useECoffsets = pset_.getParameter<bool>("useEndcapShiftsInZ");
126  if (useECoffsets) {
127  double valPos = pset_.getParameter<double>("endcapShiftInZPos");
128  double valNeg = pset_.getParameter<double>("endcapShiftInZNeg");
129  shProp->setEndcapShiftsInZPosNeg(valPos, valNeg);
130  }
131 
132  return shProp;
133 }
134 
136 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magToken_
std::unique_ptr< Propagator > produce(const TrackingComponentsRecord &)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
PropagationDirection
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
SteppingHelixPropagatorESProducer(const edm::ParameterSet &p)
Log< level::Info, false > LogInfo
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > vbMagToken_
HLT enums.
Log< level::Warning, false > LogWarning
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const