CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoMuon/MuonSeedGenerator/plugins/MuonSeedGenerator.cc

Go to the documentation of this file.
00001 
00014 #include "RecoMuon/MuonSeedGenerator/plugins/MuonSeedGenerator.h"
00015 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedFinder.h"
00016 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedOrcaPatternRecognition.h"
00017 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedFinder.h"
00018 #include "RecoMuon/MuonSeedGenerator/src/MuonSeedSimpleCleaner.h"
00019 
00020 
00021 // Data Formats 
00022 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00023 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00024 
00025 #include "DataFormats/Common/interface/Handle.h"
00026 
00027 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
00028 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
00029 
00030 // Geometry
00031 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00032 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00033 
00034 #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h"
00035 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
00036 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
00037 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00038 
00039 
00040 // Framework
00041 #include "FWCore/Framework/interface/EventSetup.h"
00042 #include "FWCore/Framework/interface/Event.h"
00043 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00044 #include "FWCore/Framework/interface/ESHandle.h"
00045 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00046 
00047 
00048 // C++
00049 #include <vector>
00050 
00051 using namespace std;
00052 
00053 typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer;
00054 typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer;
00055 typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
00056 
00057 // Constructor
00058 MuonSeedGenerator::MuonSeedGenerator(const edm::ParameterSet& pset)
00059 : thePatternRecognition(new MuonSeedOrcaPatternRecognition(pset)),
00060   theSeedFinder(new MuonSeedFinder(pset)),
00061   theSeedCleaner(new MuonSeedSimpleCleaner()),
00062   theBeamSpotTag(pset.getParameter<edm::InputTag>("beamSpotTag"))
00063 {
00064   produces<TrajectorySeedCollection>(); 
00065 }
00066 
00067 // Destructor
00068 MuonSeedGenerator::~MuonSeedGenerator(){
00069   delete thePatternRecognition;
00070   delete theSeedFinder;
00071   delete theSeedCleaner;
00072 }
00073 
00074 
00075 // reconstruct muon's seeds
00076 void MuonSeedGenerator::produce(edm::Event& event, const edm::EventSetup& eSetup)
00077 {
00078   // create the pointer to the Seed container
00079   auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());
00080   
00081   edm::ESHandle<MagneticField> field;
00082   eSetup.get<IdealMagneticFieldRecord>().get(field);
00083   theSeedFinder->setBField(&*field);
00084 
00085   reco::BeamSpot beamSpot;
00086   edm::Handle<reco::BeamSpot> beamSpotHandle;
00087   event.getByLabel(theBeamSpotTag, beamSpotHandle);
00088   if ( beamSpotHandle.isValid() )
00089   {
00090     beamSpot = *beamSpotHandle;
00091 
00092   } else
00093   {
00094     edm::LogInfo("MuonSeedGenerator")
00095       << "No beam spot available from EventSetup \n";
00096   }
00097 
00098   // make it a vector so we can subtract it from position vectors
00099   GlobalVector gv(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
00100   theSeedFinder->setBeamSpot(gv);
00101 
00102   std::vector<MuonRecHitContainer> patterns;
00103   thePatternRecognition->produce(event, eSetup, patterns);
00104 
00105   for(std::vector<MuonRecHitContainer>::const_iterator seedSegments = patterns.begin();
00106       seedSegments != patterns.end(); ++seedSegments)
00107   {
00108     theSeedFinder->seeds(*seedSegments, *output);
00109   }
00110 
00111   theSeedCleaner->clean(*output);
00112 
00113   event.put(output);
00114 }
00115 
00116