CMS 3D CMS Logo

GsfMaterialEffectsESProducer.cc
Go to the documentation of this file.
5 
8 
11 
18 
19 #include <string>
20 #include <memory>
21 #include <optional>
22 
30 public:
32 
33  std::unique_ptr<GsfMaterialEffectsUpdator> produce(const TrackingComponentsRecord&);
34 
35  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
36 
37 private:
39  BetheHeitlerInit(std::string iName, int iCorrection) : fileName(std::move(iName)), correction(iCorrection) {}
42  };
43 
44  std::optional<BetheHeitlerInit> doInit(const edm::ParameterSet& p) {
45  if (p.getParameter<std::string>("EnergyLossUpdator") != "GsfBetheHeitlerUpdator") {
46  return std::optional<BetheHeitlerInit>();
47  }
48  return std::make_optional<BetheHeitlerInit>(p.getParameter<std::string>("BetheHeitlerParametrization"),
49  p.getParameter<int>("BetheHeitlerCorrection"));
50  }
51 
52  std::optional<BetheHeitlerInit> betheHeitlerInit_;
53  const double mass_;
55 };
56 
57 using namespace edm;
58 
60  : betheHeitlerInit_(doInit(p)),
61  mass_(p.getParameter<double>("Mass")),
62  useMultipleScattering_(p.getParameter<std::string>("MultipleScatteringUpdator") == "GsfMultipleScatteringUpdator")
63 
64 {
65  std::string myname = p.getParameter<std::string>("ComponentName");
66  setWhatProduced(this, myname);
67 }
68 
69 std::unique_ptr<GsfMaterialEffectsUpdator> GsfMaterialEffectsESProducer::produce(
70  const TrackingComponentsRecord& iRecord) {
71  std::unique_ptr<GsfMaterialEffectsUpdator> msUpdator;
73  msUpdator = std::make_unique<GsfMultipleScatteringUpdator>(mass_);
74  } else {
75  msUpdator = std::make_unique<GsfMaterialEffectsAdapter>(MultipleScatteringUpdator(mass_));
76  }
77 
78  std::unique_ptr<GsfMaterialEffectsUpdator> elUpdator;
79  if (betheHeitlerInit_) {
80  elUpdator = std::make_unique<GsfBetheHeitlerUpdator>(betheHeitlerInit_->fileName, betheHeitlerInit_->correction);
81  } else {
82  elUpdator = std::make_unique<GsfMaterialEffectsAdapter>(EnergyLossUpdator(mass_));
83  }
84 
85  auto updator = std::make_unique<GsfCombinedMaterialEffectsUpdator>(*msUpdator, *elUpdator);
86 
87  return updator;
88 }
89 
92 
93  desc.add<std::string>("ComponentName");
94  desc.add<double>("Mass");
95  desc.add<std::string>("MultipleScatteringUpdator");
96  //Depending on the value of "EnergyLossUpdator", different parameters are allowed
97  desc.ifValue(
98  edm::ParameterDescription<std::string>("EnergyLossUpdator", "GsfBetheHeitlerUpdator", true),
99  "GsfBetheHeitlerUpdator" >> (edm::ParameterDescription<std::string>("BetheHeitlerParametrization", true) and
100  edm::ParameterDescription<int>("BetheHeitlerCorrection", true)) or
101  "EnergyLossUpdator" >> edm::EmptyGroupDescription() //No additional parameters needed
102  );
103  descriptions.addDefault(desc);
104 }
105 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:166
std::optional< BetheHeitlerInit > betheHeitlerInit_
std::unique_ptr< GsfMaterialEffectsUpdator > produce(const TrackingComponentsRecord &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addDefault(ParameterSetDescription const &psetDescription)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
std::optional< BetheHeitlerInit > doInit(const edm::ParameterSet &p)
GsfMaterialEffectsESProducer(const edm::ParameterSet &p)
HLT enums.
def move(src, dest)
Definition: eostools.py:511