CMS 3D CMS Logo

SiPixelTemplateDBObjectESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiPixelTemplateDBObjectESProducer
4 // Class: SiPixelTemplateDBObjectESProducer
5 //
12 //
13 // Original Author: D.Fehling
14 // Created: Tue Sep 29 14:49:31 CET 2009
15 //
16 //
17 
18 #include <memory>
19 
24 
27 
30 
31 using namespace edm;
32 
34 public:
36  std::shared_ptr<const SiPixelTemplateDBObject> produce(const SiPixelTemplateDBObjectESProducerRcd&);
37 
38 private:
41 };
42 
44  auto cc = setWhatProduced(this);
45  cc.setMayConsume(
46  templateToken_,
47  [](const auto& get, edm::ESTransientHandle<MagneticField> iMagfield) {
48  const GlobalPoint center(0.0, 0.0, 0.0);
49  const float theMagField = iMagfield->inTesla(center).mag();
50  if (theMagField >= -0.1 && theMagField < 1.0)
51  return get("", "0T");
52  else if (theMagField >= 1.0 && theMagField < 2.5)
53  return get("", "2T");
54  else if (theMagField >= 2.5 && theMagField < 3.25)
55  return get("", "3T");
56  else if (theMagField >= 3.25 && theMagField < 3.65)
57  return get("", "35T");
58  else if (theMagField >= 3.9 && theMagField < 4.1)
59  return get("", "4T");
60  else {
61  if (theMagField >= 4.1 || theMagField < -0.1)
62  edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelTemplate") << "Magnetic field is " << theMagField;
63  //return get("", "3.8T");
64  return get("", "");
65  }
66  },
68  magfieldToken_ = cc.consumes();
69 }
70 
71 std::shared_ptr<const SiPixelTemplateDBObject> SiPixelTemplateDBObjectESProducer::produce(
72  const SiPixelTemplateDBObjectESProducerRcd& 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(templateToken_);
77 
78  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
79  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelTemplate")
80  << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject.sVector()[22];
81 
82  return std::shared_ptr<const SiPixelTemplateDBObject>(&dbobject, edm::do_nothing_deleter());
83 }
84 
SiPixelTemplateDBObjectESProducer::produce
std::shared_ptr< const SiPixelTemplateDBObject > produce(const SiPixelTemplateDBObjectESProducerRcd &)
Definition: SiPixelTemplateDBObjectESProducer.cc:71
MagneticField::inTesla
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
edm::ESProductTag
Definition: ESProductTag.h:29
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
SiPixelTemplateDBObjectESProducer::SiPixelTemplateDBObjectESProducer
SiPixelTemplateDBObjectESProducer(const edm::ParameterSet &iConfig)
Definition: SiPixelTemplateDBObjectESProducer.cc:43
SiPixelTemplateDBObjectESProducerRcd.h
Point3DBase< float, GlobalTag >
edm::eventsetup::DependentRecordImplementation::get
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
Definition: DependentRecordImplementation.h:109
edm::ParameterSet
Definition: ParameterSet.h:47
SiPixelTemplateDBObject.h
SiPixelTemplateDBObjectESProducer::templateToken_
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > templateToken_
Definition: SiPixelTemplateDBObjectESProducer.cc:40
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
SiPixelTemplateDBObjectESProducerRcd
Definition: SiPixelTemplateDBObjectESProducerRcd.h:11
PV3DBase::mag
T mag() const
Definition: PV3DBase.h:64
ModuleFactory.h
ESProductTag.h
DEFINE_FWK_EVENTSETUP_MODULE
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
SiPixelTemplateDBObjectESProducer::magfieldToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
Definition: SiPixelTemplateDBObjectESProducer.cc:39
SiPixelTemplateDBObjectESProducer
Definition: SiPixelTemplateDBObjectESProducer.cc:33
edm::ESProducer
Definition: ESProducer.h:104
ParameterSet.h
do_nothing_deleter.h