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  setWhatProduced(this)
45  .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")
63  << "Magnetic field is " << theMagField;
64  //return get("", "3.8T");
65  return get("", "");
66  }
67  },
69  .setConsumes(magfieldToken_);
70 }
71 
72 std::shared_ptr<const SiPixelTemplateDBObject> SiPixelTemplateDBObjectESProducer::produce(
73  const SiPixelTemplateDBObjectESProducerRcd& iRecord) {
74  const GlobalPoint center(0.0, 0.0, 0.0);
75  const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
76 
77  const auto& dbobject = iRecord.get(templateToken_);
78 
79  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
80  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelTemplate")
81  << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject.sVector()[22];
82 
83  return std::shared_ptr<const SiPixelTemplateDBObject>(&dbobject, edm::do_nothing_deleter());
84 }
85 
SiPixelTemplateDBObjectESProducer::produce
std::shared_ptr< const SiPixelTemplateDBObject > produce(const SiPixelTemplateDBObjectESProducerRcd &)
Definition: SiPixelTemplateDBObjectESProducer.cc:72
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
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:112
edm::LogWarning
Definition: MessageLogger.h:141
edm::ParameterSet
Definition: ParameterSet.h:36
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:669
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:101
ParameterSet.h
do_nothing_deleter.h