CMS 3D CMS Logo

SiPixelGenErrorDBObjectESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelGenErrorDBObjectESProducer
4 // Class: SiPixelGenErrorDBObjectESProducer
5 //
12 //
13 // Original Author: D.Fehling
14 // Created: Tue Sep 29 14:49:31 CET 2009
15 //
16 //
17 
23 
27 
28 #include <memory>
29 
30 using namespace edm;
31 
33 public:
35  std::shared_ptr<const SiPixelGenErrorDBObject> produce(const SiPixelGenErrorDBObjectESProducerRcd&);
36 
37 private:
40 };
41 
43  auto cc = setWhatProduced(this);
44  cc.setMayConsume(
45  genErrorToken_,
46  [](const auto& get, edm::ESTransientHandle<MagneticField> iMagfield) {
47  const GlobalPoint center(0.0, 0.0, 0.0);
48  const float theMagField = iMagfield->inTesla(center).mag();
49  if (theMagField >= -0.1 && theMagField < 1.0)
50  return get("", "0T");
51  else {
52  if (theMagField >= 3.9 || theMagField < 3.65)
53  edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelGenError") << "Magnetic field is " << theMagField;
54  return get("", "");
55  }
56  },
58  magfieldToken_ = cc.consumes();
59 }
60 
61 std::shared_ptr<const SiPixelGenErrorDBObject> SiPixelGenErrorDBObjectESProducer::produce(
62  const SiPixelGenErrorDBObjectESProducerRcd& iRecord) {
63  const GlobalPoint center(0.0, 0.0, 0.0);
64  const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
65 
66  const auto& dbobject = iRecord.get(genErrorToken_);
67 
68  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
69  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelGenError")
70  << "Magnetic field is " << theMagField << " GenError Magnetic field is " << dbobject.sVector()[22];
71 
72  return std::shared_ptr<const SiPixelGenErrorDBObject>(&dbobject, edm::do_nothing_deleter());
73 }
74 
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
std::shared_ptr< const SiPixelGenErrorDBObject > produce(const SiPixelGenErrorDBObjectESProducerRcd &)
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrorToken_
SiPixelGenErrorDBObjectESProducer(const edm::ParameterSet &iConfig)
T mag() const
Definition: PV3DBase.h:64
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
HLT enums.
Log< level::Warning, false > LogWarning
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const