Go to the documentation of this file.00001
00008 #include "DTRecHitProducer.h"
00009
00010
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014
00015 #include "DataFormats/DTDigi/interface/DTDigiCollection.h"
00016
00017 #include "Geometry/DTGeometry/interface/DTLayer.h"
00018 #include "Geometry/DTGeometry/interface/DTGeometry.h"
00019 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00020 #include "DataFormats/MuonDetId/interface/DTLayerId.h"
00021 #include "DataFormats/DTRecHit/interface/DTRecHit1DPair.h"
00022
00023 #include "RecoLocalMuon/DTRecHit/interface/DTRecHitBaseAlgo.h"
00024 #include "RecoLocalMuon/DTRecHit/interface/DTRecHitAlgoFactory.h"
00025 #include "DataFormats/DTRecHit/interface/DTRecHitCollection.h"
00026 #include <string>
00027
00028
00029 using namespace edm;
00030 using namespace std;
00031
00032
00033
00034
00035 DTRecHitProducer::DTRecHitProducer(const ParameterSet& config){
00036
00037 debug = config.getUntrackedParameter<bool>("debug", false);
00038
00039 if(debug)
00040 cout << "[DTRecHitProducer] Constructor called" << endl;
00041
00042 produces<DTRecHitCollection>();
00043
00044 theDTDigiLabel = config.getParameter<InputTag>("dtDigiLabel");
00045
00046
00047 string theAlgoName = config.getParameter<string>("recAlgo");
00048 theAlgo = DTRecHitAlgoFactory::get()->create(theAlgoName,
00049 config.getParameter<ParameterSet>("recAlgoConfig"));
00050 }
00051
00052 DTRecHitProducer::~DTRecHitProducer(){
00053 if(debug)
00054 cout << "[DTRecHitProducer] Destructor called" << endl;
00055 delete theAlgo;
00056 }
00057
00058
00059
00060 void DTRecHitProducer::produce(Event& event, const EventSetup& setup) {
00061
00062 ESHandle<DTGeometry> dtGeom;
00063 setup.get<MuonGeometryRecord>().get(dtGeom);
00064
00065
00066 Handle<DTDigiCollection> digis;
00067 event.getByLabel(theDTDigiLabel, digis);
00068
00069
00070 theAlgo->setES(setup);
00071
00072
00073 auto_ptr<DTRecHitCollection> recHitCollection(new DTRecHitCollection());
00074
00075
00076
00077 DTDigiCollection::DigiRangeIterator dtLayerIt;
00078 for (dtLayerIt = digis->begin();
00079 dtLayerIt != digis->end();
00080 ++dtLayerIt){
00081
00082 const DTLayerId& layerId = (*dtLayerIt).first;
00083
00084 const DTLayer* layer = dtGeom->layer(layerId);
00085
00086
00087 const DTDigiCollection::Range& range = (*dtLayerIt).second;
00088
00089 OwnVector<DTRecHit1DPair> recHits =
00090 theAlgo->reconstruct(layer, layerId, range);
00091
00092 if(debug)
00093 cout << "Number of hits in this layer: " << recHits.size() << endl;
00094 if(recHits.size() > 0)
00095 recHitCollection->put(layerId, recHits.begin(), recHits.end());
00096 }
00097
00098 event.put(recHitCollection);
00099 }
00100
00101
00102
00103 bool
00104 DTRecHitProducer::debug;