Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <memory>
00023
00024 #include "FWCore/Framework/interface/Frameworkfwd.h"
00025 #include "FWCore/Framework/interface/EDProducer.h"
00026 #include "FWCore/Framework/interface/Event.h"
00027 #include "FWCore/Framework/interface/MakerMacros.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029
00030 #include "FWCore/Utilities/interface/InputTag.h"
00031 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00032 #include "RecoMuon/TransientTrackingRecHit/interface/MuonTransientTrackingRecHit.h"
00033 #include "DataFormats/RPCRecHit/interface/RPCRecHitCollection.h"
00034 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00035 #include <vector>
00036
00037 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedPattern.h"
00038 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedFinder.h"
00039 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedrecHitFinder.h"
00040 #include "RecoMuon/MuonSeedGenerator/src/RPCCosmicSeedrecHitFinder.h"
00041 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedLayerFinder.h"
00042 #include "RecoMuon/MuonSeedGenerator/src/RPCSeedOverlapper.h"
00043
00044 #include "TrackingTools/DetLayers/interface/DetLayer.h"
00045 #include "RecoMuon/MeasurementDet/interface/MuonDetLayerMeasurements.h"
00046 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
00047 #include "RecoMuon/Records/interface/MuonRecoGeometryRecord.h"
00048
00049 #include "FWCore/Framework/interface/EventSetup.h"
00050 #include "FWCore/Framework/interface/ESHandle.h"
00051
00052 #include "math.h"
00053
00054 #include <vector>
00055
00056
00057
00058
00059 using namespace std;
00060 using namespace edm;
00061
00062 typedef MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer;
00063 typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer;
00064 typedef MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer;
00065 typedef MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer;
00066 typedef RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed;
00067
00068 #ifndef RPCLayerNumber
00069 #define RPCLayerNumber 12
00070 #endif
00071
00072 #ifndef BarrelLayerNumber
00073 #define BarrelLayerNumber 6
00074 #endif
00075
00076 #ifndef EachEndcapLayerNumber
00077 #define EachEndcapLayerNumber 3
00078 #endif
00079
00080
00081
00082
00083
00084 class RPCSeedFinder;
00085
00086 class RPCSeedGenerator : public edm::EDProducer {
00087 public:
00088 explicit RPCSeedGenerator(const edm::ParameterSet& iConfig);
00089 ~RPCSeedGenerator();
00090
00091 private:
00092 virtual void beginJob();
00093 virtual void beginRun(const edm::Run&, const edm::EventSetup& iSetup);
00094 virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
00095 virtual void endJob();
00096
00097
00098 RPCSeedFinder Finder;
00099 RPCSeedrecHitFinder recHitFinder;
00100 RPCCosmicSeedrecHitFinder CosmicrecHitFinder;
00101 RPCSeedLayerFinder LayerFinder;
00102 RPCSeedOverlapper Overlapper;
00103 std::vector<weightedTrajectorySeed> candidateweightedSeeds;
00104 std::vector<weightedTrajectorySeed> goodweightedSeeds;
00105 edm::InputTag theRPCRecHits;
00106 };
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 RPCSeedGenerator::RPCSeedGenerator(const edm::ParameterSet& iConfig)
00122 {
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 Finder.configure(iConfig);
00134 recHitFinder.configure(iConfig);
00135 CosmicrecHitFinder.configure(iConfig);
00136 LayerFinder.configure(iConfig);
00137 Overlapper.configure(iConfig);
00138
00139 produces<TrajectorySeedCollection>("goodSeeds");
00140 produces<TrajectorySeedCollection>("candidateSeeds");
00141
00142 theRPCRecHits = iConfig.getParameter<edm::InputTag>("RPCRecHitsLabel");
00143
00144 cout << endl << "[RPCSeedGenerator] --> Constructor called" << endl;
00145 }
00146
00147
00148 RPCSeedGenerator::~RPCSeedGenerator()
00149 {
00150
00151
00152 cout << "[RPCSeedGenerator] --> Destructor called" << endl;
00153 }
00154
00155
00156
00157
00158
00159
00160
00161 void
00162 RPCSeedGenerator::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00163 {
00164 using namespace edm;
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 goodweightedSeeds.clear();
00184 candidateweightedSeeds.clear();
00185
00186
00187 auto_ptr<TrajectorySeedCollection> goodCollection(new TrajectorySeedCollection());
00188 auto_ptr<TrajectorySeedCollection> candidateCollection(new TrajectorySeedCollection());
00189
00190
00191 edm::ESHandle<MuonDetLayerGeometry> muonLayers;
00192 iSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
00193
00194
00195 vector<DetLayer*> RPCBarrelLayers = muonLayers->barrelRPCLayers();
00196 const DetLayer* RB4L = RPCBarrelLayers[5];
00197 const DetLayer* RB3L = RPCBarrelLayers[4];
00198 const DetLayer* RB22L = RPCBarrelLayers[3];
00199 const DetLayer* RB21L = RPCBarrelLayers[2];
00200 const DetLayer* RB12L = RPCBarrelLayers[1];
00201 const DetLayer* RB11L = RPCBarrelLayers[0];
00202 vector<DetLayer*> RPCEndcapLayers = muonLayers->endcapRPCLayers();
00203 const DetLayer* REM3L = RPCEndcapLayers[0];
00204 const DetLayer* REM2L = RPCEndcapLayers[1];
00205 const DetLayer* REM1L = RPCEndcapLayers[2];
00206 const DetLayer* REP1L = RPCEndcapLayers[3];
00207 const DetLayer* REP2L = RPCEndcapLayers[4];
00208 const DetLayer* REP3L = RPCEndcapLayers[5];
00209
00210
00211 MuonDetLayerMeasurements muonMeasurements(edm::InputTag(), edm::InputTag(), theRPCRecHits, false, false, true);
00212
00213
00214 MuonRecHitContainer recHitsRPC[RPCLayerNumber];
00215 recHitsRPC[0] = muonMeasurements.recHits(RB11L, iEvent);
00216 recHitsRPC[1] = muonMeasurements.recHits(RB12L, iEvent);
00217 recHitsRPC[2] = muonMeasurements.recHits(RB21L, iEvent);
00218 recHitsRPC[3] = muonMeasurements.recHits(RB22L, iEvent);
00219 recHitsRPC[4] = muonMeasurements.recHits(RB3L, iEvent);
00220 recHitsRPC[5] = muonMeasurements.recHits(RB4L, iEvent);
00221 recHitsRPC[6] = muonMeasurements.recHits(REM1L, iEvent);
00222 recHitsRPC[7] = muonMeasurements.recHits(REM2L, iEvent);
00223 recHitsRPC[8] = muonMeasurements.recHits(REM3L, iEvent);
00224 recHitsRPC[9] = muonMeasurements.recHits(REP1L, iEvent);
00225 recHitsRPC[10] = muonMeasurements.recHits(REP2L, iEvent);
00226 recHitsRPC[11] = muonMeasurements.recHits(REP3L, iEvent);
00227
00228
00229 cout << "RB1in " << recHitsRPC[0].size() << " recHits" << endl;
00230 cout << "RB1out " << recHitsRPC[1].size() << " recHits" << endl;
00231 cout << "RB2in " << recHitsRPC[2].size() << " recHits" << endl;
00232 cout << "RB2out " << recHitsRPC[3].size() << " recHits" << endl;
00233 cout << "RB3 " << recHitsRPC[4].size() << " recHits" << endl;
00234 cout << "RB4 " << recHitsRPC[5].size() << " recHits" << endl;
00235 cout << "REM1 " << recHitsRPC[6].size() << " recHits" << endl;
00236 cout << "REM2 " << recHitsRPC[7].size() << " recHits" << endl;
00237 cout << "REM3 " << recHitsRPC[8].size() << " recHits" << endl;
00238 cout << "REP1 " << recHitsRPC[9].size() << " recHits" << endl;
00239 cout << "REP2 " << recHitsRPC[10].size() << " recHits" << endl;
00240 cout << "REP3 " << recHitsRPC[11].size() << " recHits" << endl;
00241
00242
00243 recHitFinder.setInput(recHitsRPC);
00244 CosmicrecHitFinder.setInput(recHitsRPC);
00245 LayerFinder.setInput(recHitsRPC);
00246
00247
00248 Finder.setEventSetup(iSetup);
00249
00250
00251 LayerFinder.fill();
00252 Overlapper.run();
00253
00254
00255 for(vector<weightedTrajectorySeed>::iterator weightedseed = goodweightedSeeds.begin(); weightedseed != goodweightedSeeds.end(); ++weightedseed)
00256 goodCollection->push_back((*weightedseed).first);
00257 for(vector<weightedTrajectorySeed>::iterator weightedseed = candidateweightedSeeds.begin(); weightedseed != candidateweightedSeeds.end(); ++weightedseed)
00258 candidateCollection->push_back((*weightedseed).first);
00259
00260
00261 iEvent.put(goodCollection, "goodSeeds");
00262 iEvent.put(candidateCollection, "candidateSeeds");
00263
00264
00265 recHitFinder.unsetInput();
00266 CosmicrecHitFinder.unsetInput();
00267 LayerFinder.unsetInput();
00268
00269 }
00270
00271 void RPCSeedGenerator::beginJob() {
00272
00273
00274 cout << "set link and Geometry EventSetup of RPCSeedFinder, RPCSeedrecHitFinder, RPCCosmicSeedrecHitFinder, RPCSeedLayerFinder and RPCSeedOverlapper" << endl;
00275
00276 Finder.setOutput(&goodweightedSeeds, &candidateweightedSeeds);
00277 recHitFinder.setOutput(&Finder);
00278 CosmicrecHitFinder.setOutput(&Finder);
00279 LayerFinder.setOutput(&recHitFinder, &CosmicrecHitFinder);
00280 }
00281 void RPCSeedGenerator::beginRun(const edm::Run&, const edm::EventSetup& iSetup){
00282 CosmicrecHitFinder.setEdge(iSetup);
00283 Overlapper.setEventSetup(iSetup);
00284 Overlapper.setIO(&goodweightedSeeds, &candidateweightedSeeds);
00285 }
00286
00287 void RPCSeedGenerator::endJob() {
00288
00289 cout << "All jobs completed" << endl;
00290 }
00291
00292
00293 DEFINE_FWK_MODULE(RPCSeedGenerator);