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 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
T mag() const
Definition: PV3DBase.h:64
ProductT const & get(ESGetToken< ProductT, DepRecordT > const &iToken) const
std::shared_ptr< const SiPixelGenErrorDBObject > produce(const SiPixelGenErrorDBObjectESProducerRcd &)
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrorToken_
SiPixelGenErrorDBObjectESProducer(const edm::ParameterSet &iConfig)
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
HLT enums.