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::shared_ptr<Propagator> produce(const TrackingComponentsRecord &);
24  private:
25  std::shared_ptr<Propagator> _propagator;
27 };
28 
29 
30 
31 using namespace edm;
32 
34 {
35  std::string myname = p.getParameter<std::string>("ComponentName");
36  pset_ = p;
37  setWhatProduced(this,myname);
38 }
39 
41 
42 std::shared_ptr<Propagator>
44 // if (_propagator){
45 // delete _propagator;
46 // _propagator = 0;
47 // }
48  ESHandle<MagneticField> magfield;
49  iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield );
50 
51  std::string pdir = pset_.getParameter<std::string>("PropagationDirection");
52 
54 
55  if (pdir == "oppositeToMomentum") dir = oppositeToMomentum;
56  if (pdir == "alongMomentum") dir = alongMomentum;
57  if (pdir == "anyDirection") dir = anyDirection;
58 
59  SteppingHelixPropagator* shProp = new SteppingHelixPropagator(&(*magfield), dir);
60 
61  bool useInTeslaFromMagField = pset_.getParameter<bool>("useInTeslaFromMagField");
62  bool setVBFPointer = pset_.getParameter<bool>("SetVBFPointer");
63  bool useMagVolumes = pset_.getParameter<bool>("useMagVolumes");
64 
65  // if useMagVolumes == true and an alternate VBF field is not specified with setVBFPointer,
66  // Force "useInTeslaFromMagField=true" for a B=0 VBF map.
67  if (useMagVolumes==true && !useInTeslaFromMagField && !setVBFPointer && magfield->nominalValue() == 0) {
68  const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&(*magfield));
69  if (vbfCPtr ==nullptr ){
70  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;
71  } else {
72  edm::LogInfo("SteppingHelixPropagator") << "Config specifies useMagVolumes==true and VBF field available: Forcing useInTeslaFromMagField = True." <<std::endl;
73  useInTeslaFromMagField = true;
74  }
75  }
76 
77  if (setVBFPointer){
78  std::string vbfName = pset_.getParameter<std::string>("VBFName");
79  ESHandle<MagneticField> vbfField;
80  iRecord.getRecord<IdealMagneticFieldRecord>().get(vbfName, vbfField );
81  const VolumeBasedMagneticField* vbfCPtr = dynamic_cast<const VolumeBasedMagneticField*>(&(*vbfField));
82  if (vbfField.isValid()) shProp->setVBFPointer(vbfCPtr);
83  }
84 
85  shProp->setUseInTeslaFromMagField(useInTeslaFromMagField);
86 
87  bool haveX0Corr = pset_.getParameter<bool>("ApplyRadX0Correction");
88  shProp->applyRadX0Correction(haveX0Corr);
89 
90  bool assumeNoMaterial = pset_.getParameter<bool>("AssumeNoMaterial");
91  shProp->setMaterialMode(assumeNoMaterial);
92 
93  bool noErrorPropagation = pset_.getParameter<bool>("NoErrorPropagation");
94  shProp->setNoErrorPropagation(noErrorPropagation);
95 
96  bool debugMode = pset_.getParameter<bool>("debug");
97  shProp->setDebug(debugMode);
98 
99  shProp->setUseMagVolumes(useMagVolumes);
100 
101  bool useMatVolumes = pset_.getParameter<bool>("useMatVolumes");
102  shProp->setUseMatVolumes(useMatVolumes);
103 
104  bool useIsYokeFlag = pset_.getParameter<bool>("useIsYokeFlag");
105  shProp->setUseIsYokeFlag(useIsYokeFlag);
106 
107  bool returnTangentPlane = pset_.getParameter<bool>("returnTangentPlane");
108  shProp->setReturnTangentPlane(returnTangentPlane);
109 
110  bool sendLogWarning = pset_.getParameter<bool>("sendLogWarning");
111  shProp->setSendLogWarning(sendLogWarning);
112 
113  bool useTuningForL2Speed = pset_.getParameter<bool>("useTuningForL2Speed");
114  shProp->setUseTuningForL2Speed(useTuningForL2Speed);
115 
116 
117  bool useECoffsets = pset_.getParameter<bool>("useEndcapShiftsInZ");
118  if (useECoffsets){
119  double valPos = pset_.getParameter<double>("endcapShiftInZPos");
120  double valNeg = pset_.getParameter<double>("endcapShiftInZNeg");
121  shProp->setEndcapShiftsInZPosNeg(valPos, valNeg);
122  }
123 
124  _propagator = std::shared_ptr<Propagator>(shProp);
125  return _propagator;
126 }
127 
129 
131 
T getParameter(std::string const &) const
void setDebug(bool debug)
Switch debug printouts (to cout) .. very verbose.
void setVBFPointer(const VolumeBasedMagneticField *val)
int nominalValue() const
The nominal field value for this map in kGauss.
Definition: MagneticField.h:58
PropagationDirection
void setWhatProduced(T *iThis, const es::Label &iLabel=es::Label())
Definition: ESProducer.h:115
void setUseMagVolumes(bool val)
Switch to using MagneticField Volumes .. as in VolumeBasedMagneticField.
void applyRadX0Correction(bool applyRadX0Correction)
SteppingHelixPropagatorESProducer(const edm::ParameterSet &p)
void setUseMatVolumes(bool val)
Switch to using Material Volumes .. internally defined for now.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
std::shared_ptr< Propagator > produce(const TrackingComponentsRecord &)
HLT enums.
void setReturnTangentPlane(bool val)
flag to return tangent plane for non-plane input
void setSendLogWarning(bool val)
flag to send LogWarning on failures
void setUseInTeslaFromMagField(bool val)
force getting field value from MagneticField, not the geometric one
dbl *** dir
Definition: mlp_gen.cc:35
void setEndcapShiftsInZPosNeg(double valPos, double valNeg)
set shifts in Z for endcap pieces (includes EE, HE, ME, YE)
void setMaterialMode(bool noMaterial)
Switch for material effects mode: no material effects if true.
void setNoErrorPropagation(bool noErrorPropagation)
Force no error propagation.