00001 00008 #include "RPCRecHitProducer.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/RPCDigi/interface/RPCDigiCollection.h" 00016 00017 #include "Geometry/RPCGeometry/interface/RPCRoll.h" 00018 #include "Geometry/RPCGeometry/interface/RPCGeometry.h" 00019 #include "Geometry/Records/interface/MuonGeometryRecord.h" 00020 #include "DataFormats/MuonDetId/interface/RPCDetId.h" 00021 #include "DataFormats/RPCRecHit/interface/RPCRecHit.h" 00022 00023 #include "RecoLocalMuon/RPCRecHit/interface/RPCRecHitBaseAlgo.h" 00024 #include "RecoLocalMuon/RPCRecHit/interface/RPCRecHitAlgoFactory.h" 00025 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h" 00026 #include <string> 00027 00028 00029 using namespace edm; 00030 using namespace std; 00031 00032 00033 00034 00035 RPCRecHitProducer::RPCRecHitProducer(const ParameterSet& config){ 00036 // Set verbose output 00037 00038 produces<RPCRecHitCollection>(); 00039 00040 theRPCDigiLabel = config.getParameter<InputTag>("rpcDigiLabel"); 00041 00042 // Get the concrete reconstruction algo from the factory 00043 string theAlgoName = config.getParameter<string>("recAlgo"); 00044 theAlgo = RPCRecHitAlgoFactory::get()->create(theAlgoName, 00045 config.getParameter<ParameterSet>("recAlgoConfig")); 00046 } 00047 00048 RPCRecHitProducer::~RPCRecHitProducer(){ 00049 delete theAlgo; 00050 } 00051 00052 00053 00054 void RPCRecHitProducer::produce(Event& event, const EventSetup& setup) { 00055 // Get the RPC Geometry 00056 ESHandle<RPCGeometry> rpcGeom; 00057 setup.get<MuonGeometryRecord>().get(rpcGeom); 00058 00059 // Get the digis from the event 00060 Handle<RPCDigiCollection> digis; 00061 event.getByLabel(theRPCDigiLabel,digis); 00062 00063 // Pass the EventSetup to the algo 00064 theAlgo->setES(setup); 00065 00066 // Create the pointer to the collection which will store the rechits 00067 auto_ptr<RPCRecHitCollection> recHitCollection(new RPCRecHitCollection()); 00068 00069 00070 // Iterate through all digi collections ordered by LayerId 00071 RPCDigiCollection::DigiRangeIterator rpcdgIt; 00072 for (rpcdgIt = digis->begin(); rpcdgIt != digis->end(); 00073 ++rpcdgIt){ 00074 00075 // The layerId 00076 const RPCDetId& rpcId = (*rpcdgIt).first; 00077 // Get the GeomDet from the setup 00078 const RPCRoll* roll = rpcGeom->roll(rpcId); 00079 00080 // Get the iterators over the digis associated with this LayerId 00081 const RPCDigiCollection::Range& range = (*rpcdgIt).second; 00082 00083 OwnVector<RPCRecHit> recHits = 00084 theAlgo->reconstruct(*roll, rpcId, range); 00085 00086 if(recHits.size() > 0) //FIXME: is it really needed? 00087 recHitCollection->put(rpcId, recHits.begin(), recHits.end()); 00088 } 00089 00090 event.put(recHitCollection); 00091 } 00092 00093 00094