00001 // -*- C++ -*- 00002 // Package: SiPixelESProducers 00003 // Class: SiPixelTemplateDBObjectESProducer 00004 // Original Author: D.Fehling 00005 // Created: Tue Sep 29 14:49:31 CET 2009 00006 // 00007 00008 #include "CalibTracker/SiPixelESProducers/interface/SiPixelTemplateDBObjectESProducer.h" 00009 00010 #include "FWCore/Framework/interface/ESHandle.h" 00011 #include "FWCore/Framework/interface/EventSetup.h" 00012 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00013 #include "FWCore/Utilities/interface/do_nothing_deleter.h" 00014 00015 #include <boost/shared_ptr.hpp> 00016 #include "boost/mpl/vector.hpp" 00017 00018 #include "FWCore/Framework/interface/ModuleFactory.h" 00019 #include "MagneticField/Engine/interface/MagneticField.h" 00020 00021 using namespace edm; 00022 00023 SiPixelTemplateDBObjectESProducer::SiPixelTemplateDBObjectESProducer(const edm::ParameterSet& iConfig) { 00024 setWhatProduced(this); 00025 } 00026 00027 00028 SiPixelTemplateDBObjectESProducer::~SiPixelTemplateDBObjectESProducer(){ 00029 } 00030 00031 00032 00033 00034 boost::shared_ptr<SiPixelTemplateDBObject> SiPixelTemplateDBObjectESProducer::produce(const SiPixelTemplateDBObjectESProducerRcd & iRecord) { 00035 00036 ESHandle<MagneticField> magfield; 00037 iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield); 00038 00039 GlobalPoint center(0.0, 0.0, 0.0); 00040 float theMagField = magfield.product()->inTesla(center).mag(); 00041 00042 std::string label = ""; 00043 00044 if( theMagField>=-0.1 && theMagField<1.0 ) label = "0T"; 00045 else if(theMagField>=1.0 && theMagField<2.5 ) label = "2T"; 00046 else if(theMagField>=2.5 && theMagField<3.25) label = "3T"; 00047 else if(theMagField>=3.25 && theMagField<3.65) label = "35T"; 00048 else if(theMagField>=3.9 && theMagField<4.1 ) label = "4T"; 00049 else { 00050 //label = "3.8T"; 00051 if(theMagField>=4.1 || theMagField<-0.1) edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelTemplate") << "Magnetic field is " << theMagField; 00052 } 00053 ESHandle<SiPixelTemplateDBObject> dbobject; 00054 iRecord.getRecord<SiPixelTemplateDBObjectRcd>().get(label,dbobject); 00055 00056 if(std::fabs(theMagField-dbobject->sVector()[22])>0.1) 00057 edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelTemplate") << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject->sVector()[22]; 00058 00059 return boost::shared_ptr<SiPixelTemplateDBObject>(const_cast<SiPixelTemplateDBObject*>(&(*dbobject)), edm::do_nothing_deleter()); 00060 } 00061 00062 DEFINE_FWK_EVENTSETUP_MODULE(SiPixelTemplateDBObjectESProducer);