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 if (theMagField >= 1.0 && theMagField < 2.5)
52  return get("", "2T");
53  else if (theMagField >= 2.5 && theMagField < 3.25)
54  return get("", "3T");
55  else if (theMagField >= 3.25 && theMagField < 3.65)
56  return get("", "35T");
57  else if (theMagField >= 3.9 && theMagField < 4.1)
58  return get("", "4T");
59  else {
60  if (theMagField >= 4.1 || theMagField < -0.1)
61  edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelGenError") << "Magnetic field is " << theMagField;
62  //return get("", "3.8T");
63  return get("", "");
64  }
65  },
67  magfieldToken_ = cc.consumes();
68 }
69 
70 std::shared_ptr<const SiPixelGenErrorDBObject> SiPixelGenErrorDBObjectESProducer::produce(
71  const SiPixelGenErrorDBObjectESProducerRcd& iRecord) {
72  const GlobalPoint center(0.0, 0.0, 0.0);
73  const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
74 
75  const auto& dbobject = iRecord.get(genErrorToken_);
76 
77  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
78  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelGenError")
79  << "Magnetic field is " << theMagField << " GenError Magnetic field is " << dbobject.sVector()[22];
80 
81  return std::shared_ptr<const SiPixelGenErrorDBObject>(&dbobject, edm::do_nothing_deleter());
82 }
83 
SiPixelGenErrorDBObjectESProducer
Definition: SiPixelGenErrorDBObjectESProducer.cc:32
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
edm::ESProductTag
Definition: ESProductTag.h:29
SiPixelGenErrorDBObjectESProducerRcd.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::do_nothing_deleter
Definition: do_nothing_deleter.h:34
ESProducer.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
cc
SiPixelGenErrorDBObjectESProducer::produce
std::shared_ptr< const SiPixelGenErrorDBObject > produce(const SiPixelGenErrorDBObjectESProducerRcd &)
Definition: SiPixelGenErrorDBObjectESProducer.cc:70
SiPixelGenErrorDBObjectESProducer::SiPixelGenErrorDBObjectESProducer
SiPixelGenErrorDBObjectESProducer(const edm::ParameterSet &iConfig)
Definition: SiPixelGenErrorDBObjectESProducer.cc:42
Point3DBase< float, GlobalTag >
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
SiPixelGenErrorDBObjectESProducer::magfieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
Definition: SiPixelGenErrorDBObjectESProducer.cc:38
edm::ParameterSet
Definition: ParameterSet.h:47
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:679
MagneticField.h
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord >
edm::ESTransientHandle
Definition: ESTransientHandle.h:41
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
ModuleFactory.h
SiPixelGenErrorDBObject.h
SiPixelGenErrorDBObjectESProducerRcd
Definition: SiPixelGenErrorDBObjectESProducerRcd.h:11
ESProductTag.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::ESProducer
Definition: ESProducer.h:104
SiPixelGenErrorDBObjectESProducer::genErrorToken_
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrorToken_
Definition: SiPixelGenErrorDBObjectESProducer.cc:39
ParameterSet.h
do_nothing_deleter.h