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  setWhatProduced(this)
44  .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")
62  << "Magnetic field is " << theMagField;
63  //return get("", "3.8T");
64  return get("", "");
65  }
66  },
68  .setConsumes(magfieldToken_);
69 }
70 
71 std::shared_ptr<const SiPixelGenErrorDBObject> SiPixelGenErrorDBObjectESProducer::produce(
72  const SiPixelGenErrorDBObjectESProducerRcd& iRecord) {
73  const GlobalPoint center(0.0, 0.0, 0.0);
74  const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
75 
76  const auto& dbobject = iRecord.get(genErrorToken_);
77 
78  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
79  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelGenError")
80  << "Magnetic field is " << theMagField << " GenError Magnetic field is " << dbobject.sVector()[22];
81 
82  return std::shared_ptr<const SiPixelGenErrorDBObject>(&dbobject, edm::do_nothing_deleter());
83 }
84 
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
SiPixelGenErrorDBObjectESProducer::produce
std::shared_ptr< const SiPixelGenErrorDBObject > produce(const SiPixelGenErrorDBObjectESProducerRcd &)
Definition: SiPixelGenErrorDBObjectESProducer.cc:71
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:112
SiPixelGenErrorDBObjectESProducer::magfieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
Definition: SiPixelGenErrorDBObjectESProducer.cc:38
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
edm::get
T const & get(Event const &event, InputTag const &tag) noexcept(false)
Definition: Event.h:669
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:101
SiPixelGenErrorDBObjectESProducer::genErrorToken_
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrorToken_
Definition: SiPixelGenErrorDBObjectESProducer.cc:39
ParameterSet.h
do_nothing_deleter.h