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 
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > templateToken_
SiPixelTemplateDBObjectESProducer(const edm::ParameterSet &iConfig)
T mag() const
Definition: PV3DBase.h:64
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::shared_ptr< const SiPixelTemplateDBObject > produce(const SiPixelTemplateDBObjectESProducerRcd &)
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
HLT enums.