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 00014 #include <boost/shared_ptr.hpp> 00015 #include "boost/mpl/vector.hpp" 00016 #include "FWCore/Framework/interface/ModuleFactory.h" 00017 #include "MagneticField/Engine/interface/MagneticField.h" 00018 00019 using namespace edm; 00020 00021 SiPixelTemplateDBObjectESProducer::SiPixelTemplateDBObjectESProducer(const edm::ParameterSet& iConfig) { 00022 setWhatProduced(this); 00023 } 00024 00025 00026 SiPixelTemplateDBObjectESProducer::~SiPixelTemplateDBObjectESProducer(){ 00027 } 00028 00029 00030 00031 00032 boost::shared_ptr<SiPixelTemplateDBObject> SiPixelTemplateDBObjectESProducer::produce(const SiPixelTemplateDBObjectESProducerRcd & iRecord) { 00033 00034 ESHandle<MagneticField> magfield; 00035 iRecord.getRecord<IdealMagneticFieldRecord>().get(magfield); 00036 00037 GlobalPoint center(0.0, 0.0, 0.0); 00038 float theMagField = magfield.product()->inTesla(center).mag(); 00039 00040 std::string label = ""; 00041 00042 if( theMagField>=-0.1 && theMagField<1.0 ) label = "0T"; 00043 else if(theMagField>=1.0 && theMagField<2.5 ) label = "2T"; 00044 else if(theMagField>=2.5 && theMagField<3.25) label = "3T"; 00045 else if(theMagField>=3.25 && theMagField<3.65) label = "35T"; 00046 else if(theMagField>=3.9 && theMagField<4.1 ) label = "4T"; 00047 else { 00048 //label = "3.8T"; 00049 if(theMagField>=4.1 || theMagField<-0.1) edm::LogWarning("UnexpectedMagneticFieldUsingDefaultPixelTemplate") << "Magnetic field is " << theMagField; 00050 } 00051 ESHandle<SiPixelTemplateDBObject> dbobject; 00052 iRecord.getRecord<SiPixelTemplateDBObjectRcd>().get(label,dbobject); 00053 00054 if(std::fabs(theMagField-dbobject->sVector()[22])>0.1) 00055 edm::LogWarning("UnexpectedMagneticFieldUsingNonIdealPixelTemplate") << "Magnetic field is " << theMagField << " Template Magnetic field is " << dbobject->sVector()[22]; 00056 00057 boost::shared_ptr<SiPixelTemplateDBObject> dbptr(new SiPixelTemplateDBObject(*(dbobject))); 00058 return dbptr; 00059 } 00060 00061 DEFINE_FWK_EVENTSETUP_MODULE(SiPixelTemplateDBObjectESProducer);