CMS 3D CMS Logo

SiPixel2DTemplateDBObjectESProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // Package: SiPixelESProducers
3 // Class: SiPixel2DTemplateDBObjectESProducer
4 // Original Author: D.Fehling
5 // Created: Tue Sep 29 14:49:31 CET 2009
6 //
7 
9 
14 
15 #include <memory>
16 #include "boost/mpl/vector.hpp"
17 
20 
21 using namespace edm;
22 
24  setWhatProduced(this);
25 }
26 
27 
29 }
30 
31 
32 
33 
34 std::shared_ptr<SiPixel2DTemplateDBObject> SiPixel2DTemplateDBObjectESProducer::produce(const SiPixel2DTemplateDBObjectESProducerRcd & iRecord) {
35 
36  ESHandle<MagneticField> magfield;
37  iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield);
38 
39  GlobalPoint center(0.0, 0.0, 0.0);
40  float theMagField = magfield.product()->inTesla(center).mag();
41 
42  // std::string label = "numerator"; // &&& Temporary: matches Barrel Layer1 for 2017 data
43  // std::string label = "denominator"; // &&& Temporary: matches Barrel Layer1 fullsim MC
44  std::string label = ""; // the correct default
45 
46  if( theMagField>=-0.1 && theMagField<1.0 ) label = "0T";
47  else if(theMagField>=1.0 && theMagField<2.5 ) label = "2T";
48  else if(theMagField>=2.5 && theMagField<3.25) label = "3T";
49  else if(theMagField>=3.25 && theMagField<3.65) label = "35T";
50  else if(theMagField>=3.9 && theMagField<4.1 ) label = "4T";
51  else {
52  //label = "3.8T";
53  if(theMagField>=4.1 || theMagField<-0.1) edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixel2DTemplate") << "Magnetic field is " << theMagField;
54  }
56  iRecord.getRecord<SiPixel2DTemplateDBObjectRcd>().get(label,dbobject);
57 
58  if(std::fabs(theMagField-dbobject->sVector()[22])>0.1)
59  edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixel2DTemplate") << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject->sVector()[22];
60 
61  return std::shared_ptr<SiPixel2DTemplateDBObject>(const_cast<SiPixel2DTemplateDBObject*>(&(*dbobject)), edm::do_nothing_deleter());
62 }
63 
std::shared_ptr< SiPixel2DTemplateDBObject > produce(const SiPixel2DTemplateDBObjectESProducerRcd &)
std::vector< float > sVector() const
T mag() const
Definition: PV3DBase.h:67
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
SiPixel2DTemplateDBObjectESProducer(const edm::ParameterSet &iConfig)
HLT enums.
T const * product() const
Definition: ESHandle.h:86