CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/Geometry/EcalMapping/plugins/EcalElectronicsMappingBuilder.cc

Go to the documentation of this file.
00001 
00002 // user include files
00003 #include "EcalElectronicsMappingBuilder.h"
00004 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00005 #include "DataFormats/EcalDetId/interface/EcalElectronicsId.h"
00006 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h"
00007 
00008 #include <iostream>
00009 #include <fstream>
00010 
00011 
00012 #include <vector>
00013 
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "CondFormats/EcalObjects/interface/EcalMappingElectronics.h"
00017 #include "CondFormats/DataRecord/interface/EcalMappingElectronicsRcd.h"
00018 
00019 
00020 
00021 using namespace edm;
00022 
00023 
00024 //
00025 // constructors and destructor
00026 //
00027 EcalElectronicsMappingBuilder::EcalElectronicsMappingBuilder(const edm::ParameterSet& iConfig) :
00028   Mapping_ ( 0 )
00029 {
00030   //the following line is needed to tell the framework what
00031   // data is being produced
00032   // setWhatProduced(this);
00033   setWhatProduced(this, (dependsOn (&EcalElectronicsMappingBuilder::DBCallback)) );
00034   //now do what ever other initialization is needed
00035 }
00036 
00037 
00038 EcalElectronicsMappingBuilder::~EcalElectronicsMappingBuilder()
00039 { 
00040 }
00041 
00042 //
00043 // member functions
00044 //
00045 
00046 void EcalElectronicsMappingBuilder::DBCallback (const EcalMappingElectronicsRcd& fRecord)
00047 {
00048 
00049   edm::ESHandle <EcalMappingElectronics> item;
00050   fRecord.get (item);
00051   Mapping_ = item.product () ;
00052 }
00053 
00054 
00055 // ------------ method called to produce the data  ------------
00056 EcalElectronicsMappingBuilder::ReturnType
00057 // EcalElectronicsMappingBuilder::produce(const IdealGeometryRecord& iRecord)
00058 EcalElectronicsMappingBuilder::produce(const EcalMappingRcd& iRecord)
00059 {
00060    using namespace edm::es;
00061    std::auto_ptr<EcalElectronicsMapping> prod(new EcalElectronicsMapping());
00062    const std::vector<EcalMappingElement>& ee = Mapping_ -> endcapItems();
00063    FillFromDatabase(ee,*prod);
00064    return prod;
00065 
00066 }
00067 
00068 void EcalElectronicsMappingBuilder::FillFromDatabase(const std::vector<EcalMappingElement>& ee,
00069                                                      EcalElectronicsMapping& theMap)   
00070 {
00071   //  std::cout << " --- Reading the EE mapping from Database --- " << std::endl;
00072   for (unsigned int i=0; i < ee.size(); i++) 
00073     {
00074       if (ee[i].electronicsid == 0)
00075         continue;
00076       if (ee[i].triggerid == 0)
00077         continue;
00078       theMap.assign(EEDetId::unhashIndex(i).rawId(),ee[i].electronicsid,ee[i].triggerid);
00079     }
00080   return;
00081 }
00082 
00083 
00084 
00085 
00086