CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 {
53  if (theMagField >= 3.9 || theMagField < 3.65)
54  edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelTemplate") << "Magnetic field is " << theMagField;
55  return get("", "");
56  }
57  },
59  magfieldToken_ = cc.consumes();
60 }
61 
62 std::shared_ptr<const SiPixelTemplateDBObject> SiPixelTemplateDBObjectESProducer::produce(
63  const SiPixelTemplateDBObjectESProducerRcd& iRecord) {
64  const GlobalPoint center(0.0, 0.0, 0.0);
65  const float theMagField = iRecord.get(magfieldToken_).inTesla(center).mag();
66 
67  const auto& dbobject = iRecord.get(templateToken_);
68 
69  if (std::fabs(theMagField - dbobject.sVector()[22]) > 0.1)
70  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelTemplate")
71  << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject.sVector()[22];
72 
73  return std::shared_ptr<const SiPixelTemplateDBObject>(&dbobject, edm::do_nothing_deleter());
74 }
75 
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > templateToken_
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
SiPixelTemplateDBObjectESProducer(const edm::ParameterSet &iConfig)
T mag() const
Definition: PV3DBase.h:64
std::shared_ptr< const SiPixelTemplateDBObject > produce(const SiPixelTemplateDBObjectESProducerRcd &)
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:61
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
HLT enums.
Log< level::Warning, false > LogWarning
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const