CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/RecoMuon/MuonSeedGenerator/plugins/MuonSeedProducer.cc

Go to the documentation of this file.
00001 
00008 #include "RecoMuon/MuonSeedGenerator/plugins/MuonSeedProducer.h"
00009 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedBuilder.h"
00010 
00011 
00012 // Data Formats 
00013 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00014 
00015 // Magnetic Field
00016 #include "MagneticField/Engine/interface/MagneticField.h"
00017 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00018 
00019 // Geometry
00020 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00021 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00022 
00023 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
00024 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
00025 
00026 // Framework
00027 #include "FWCore/Framework/interface/EventSetup.h"
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00030 #include "FWCore/Framework/interface/ESHandle.h"
00031 #include <DataFormats/Common/interface/Handle.h>
00032 // C++
00033 #include <vector>
00034 
00035 
00036 
00037 /* 
00038  * Constructor
00039  */
00040 MuonSeedProducer::MuonSeedProducer(const edm::ParameterSet& pset){
00041 
00042   // Register what this produces
00043   produces<TrajectorySeedCollection>(); 
00044 
00045   // Local Debug flag
00046   debug              = pset.getParameter<bool>("DebugMuonSeed");
00047 
00048   // Builder which returns seed collection 
00049   muonSeedBuilder_   = new MuonSeedBuilder( pset ); 
00050 
00051 }
00052 
00053 
00054 /*
00055  * Destructor
00056  */
00057 MuonSeedProducer::~MuonSeedProducer(){
00058 
00059   delete muonSeedBuilder_;
00060 
00061 }
00062 
00063 
00064 /*
00065  * Producer (the main)
00066  */ 
00067 void MuonSeedProducer::produce(edm::Event& event, const edm::EventSetup& eSetup){
00068 
00069   // Muon Geometry
00070   edm::ESHandle<MuonDetLayerGeometry> muonLayers;
00071   eSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
00072   const MuonDetLayerGeometry* lgeom = &*muonLayers;
00073   muonSeedBuilder_->setGeometry( lgeom );
00074 
00075   // Magnetic field
00076   edm::ESHandle<MagneticField> field;
00077   eSetup.get<IdealMagneticFieldRecord>().get(field);
00078   const MagneticField* theField = &*field;
00079   muonSeedBuilder_->setBField( theField );
00080 
00081    // Create pointer to the seed container
00082 
00083   std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection() );
00084 
00085   int nSeeds = 0;
00086   nSeeds = muonSeedBuilder_->build( event, eSetup, *output);
00087 
00088   // Append muon seed collection to event
00089   event.put( output );
00090 
00091 }