CMS 3D CMS Logo

RPCSeedGenerator.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RPCSeedGenerator
4 // Class: RPCSeedGenerator
5 //
13 //
14 // Original Author: Haiyun Teng
15 // Created: Wed Oct 29 17:24:36 CET 2008
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 // user include files
27 // special include files
33 #include <vector>
34 // Using other classes
41 // Geometry
46 
47 // Framework
50 // Math
51 #include <cmath>
52 // C++
53 #include <vector>
54 
55 //
56 // constants, enums and typedefs
57 //
58 using namespace std;
59 using namespace edm;
60 
66 
67 #ifndef RPCLayerNumber
68 #define RPCLayerNumber 12
69 #endif
70 
71 #ifndef BarrelLayerNumber
72 #define BarrelLayerNumber 6
73 #endif
74 
75 #ifndef EachEndcapLayerNumber
76 #define EachEndcapLayerNumber 3
77 #endif
78 
79 //
80 // class decleration
81 //
82 
83 class RPCSeedFinder;
84 
86 public:
87  explicit RPCSeedGenerator(const edm::ParameterSet& iConfig);
88  ~RPCSeedGenerator() override;
89 
90 private:
91  void beginJob() override;
92  void beginRun(const edm::Run&, const edm::EventSetup& iSetup) override;
93  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
94  void endJob() override;
95 
96  // ----------member data ---------------------------
102  std::vector<weightedTrajectorySeed> candidateweightedSeeds;
103  std::vector<weightedTrajectorySeed> goodweightedSeeds;
106 };
107 
108 //
109 // constants, enums and typedefs
110 //
111 
112 //
113 // static data member definitions
114 //
115 
116 //
117 // constructors and destructor
118 //
120  //register your products
121  /* Examples
122  produces<ExampleData2>();
123 
124  //if do put with a label
125  produces<ExampleData2>("label");
126  */
127 
128  // Now do what ever other initialization is needed
129  // Configure other modules
130  Finder.configure(iConfig);
131  recHitFinder.configure(iConfig);
132  CosmicrecHitFinder.configure(iConfig);
133  LayerFinder.configure(iConfig);
134  Overlapper.configure(iConfig);
135  // Register the production
136  produces<TrajectorySeedCollection>("goodSeeds");
137  produces<TrajectorySeedCollection>("candidateSeeds");
138  // Get event data Tag
139  theRPCRecHits = iConfig.getParameter<edm::InputTag>("RPCRecHitsLabel");
140 
141  // Get RPC recHits by MuonDetLayerMeasurements, while CSC and DT is set to false and with empty InputTag
142  edm::ConsumesCollector iC = consumesCollector();
143 
144  muonMeasurements = new MuonDetLayerMeasurements(edm::InputTag(),
145  edm::InputTag(),
147  edm::InputTag(),
148  edm::InputTag(),
149  iC,
150  false,
151  false,
152  true,
153  false,
154  false);
155 
156  cout << endl << "[RPCSeedGenerator] --> Constructor called" << endl;
157 }
158 
160  // do anything here that needs to be done at desctruction time
161  // (e.g. close files, deallocate resources etc.)
162  cout << "[RPCSeedGenerator] --> Destructor called" << endl;
163 
164  if (muonMeasurements)
165  delete muonMeasurements;
166 }
167 
168 //
169 // member functions
170 //
171 
172 // ------------ method called to produce the data ------------
174  using namespace edm;
175  goodweightedSeeds.clear();
176  candidateweightedSeeds.clear();
177 
178  // Create the pointer to the Seed container
179  auto goodCollection = std::make_unique<TrajectorySeedCollection>();
180  auto candidateCollection = std::make_unique<TrajectorySeedCollection>();
181 
182  // Muon Geometry - DT, CSC and RPC
184  iSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
185 
186  // Get the RPC layers
187  vector<const DetLayer*> RPCBarrelLayers = muonLayers->barrelRPCLayers();
188  const DetLayer* RB4L = RPCBarrelLayers[5];
189  const DetLayer* RB3L = RPCBarrelLayers[4];
190  const DetLayer* RB22L = RPCBarrelLayers[3];
191  const DetLayer* RB21L = RPCBarrelLayers[2];
192  const DetLayer* RB12L = RPCBarrelLayers[1];
193  const DetLayer* RB11L = RPCBarrelLayers[0];
194  vector<const DetLayer*> RPCEndcapLayers = muonLayers->endcapRPCLayers();
195  const DetLayer* REM3L = RPCEndcapLayers[0];
196  const DetLayer* REM2L = RPCEndcapLayers[1];
197  const DetLayer* REM1L = RPCEndcapLayers[2];
198  const DetLayer* REP1L = RPCEndcapLayers[3];
199  const DetLayer* REP2L = RPCEndcapLayers[4];
200  const DetLayer* REP3L = RPCEndcapLayers[5];
201 
202  // Dispatch RPC recHits to the corresponding DetLayer, 6 layers for barrel and 3 layers for each endcap
204  recHitsRPC[0] = muonMeasurements->recHits(RB11L, iEvent);
205  recHitsRPC[1] = muonMeasurements->recHits(RB12L, iEvent);
206  recHitsRPC[2] = muonMeasurements->recHits(RB21L, iEvent);
207  recHitsRPC[3] = muonMeasurements->recHits(RB22L, iEvent);
208  recHitsRPC[4] = muonMeasurements->recHits(RB3L, iEvent);
209  recHitsRPC[5] = muonMeasurements->recHits(RB4L, iEvent);
210  recHitsRPC[6] = muonMeasurements->recHits(REM1L, iEvent);
211  recHitsRPC[7] = muonMeasurements->recHits(REM2L, iEvent);
212  recHitsRPC[8] = muonMeasurements->recHits(REM3L, iEvent);
213  recHitsRPC[9] = muonMeasurements->recHits(REP1L, iEvent);
214  recHitsRPC[10] = muonMeasurements->recHits(REP2L, iEvent);
215  recHitsRPC[11] = muonMeasurements->recHits(REP3L, iEvent);
216 
217  // Print the size of recHits in each DetLayer
218  cout << "RB1in " << recHitsRPC[0].size() << " recHits" << endl;
219  cout << "RB1out " << recHitsRPC[1].size() << " recHits" << endl;
220  cout << "RB2in " << recHitsRPC[2].size() << " recHits" << endl;
221  cout << "RB2out " << recHitsRPC[3].size() << " recHits" << endl;
222  cout << "RB3 " << recHitsRPC[4].size() << " recHits" << endl;
223  cout << "RB4 " << recHitsRPC[5].size() << " recHits" << endl;
224  cout << "REM1 " << recHitsRPC[6].size() << " recHits" << endl;
225  cout << "REM2 " << recHitsRPC[7].size() << " recHits" << endl;
226  cout << "REM3 " << recHitsRPC[8].size() << " recHits" << endl;
227  cout << "REP1 " << recHitsRPC[9].size() << " recHits" << endl;
228  cout << "REP2 " << recHitsRPC[10].size() << " recHits" << endl;
229  cout << "REP3 " << recHitsRPC[11].size() << " recHits" << endl;
230 
231  // Set Input of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
232  recHitFinder.setInput(recHitsRPC);
233  CosmicrecHitFinder.setInput(recHitsRPC);
234  LayerFinder.setInput(recHitsRPC);
235 
236  // Set Magnetic Field EventSetup of RPCSeedFinder
237  Finder.setEventSetup(iSetup);
238 
239  // Start from filling layers to filling seeds
240  LayerFinder.fill();
241  Overlapper.run();
242 
243  // Save seeds to event
244  for (vector<weightedTrajectorySeed>::iterator weightedseed = goodweightedSeeds.begin();
245  weightedseed != goodweightedSeeds.end();
246  ++weightedseed)
247  goodCollection->push_back((*weightedseed).first);
248  for (vector<weightedTrajectorySeed>::iterator weightedseed = candidateweightedSeeds.begin();
249  weightedseed != candidateweightedSeeds.end();
250  ++weightedseed)
251  candidateCollection->push_back((*weightedseed).first);
252 
253  // Put the seed to event
254  iEvent.put(std::move(goodCollection), "goodSeeds");
255  iEvent.put(std::move(candidateCollection), "candidateSeeds");
256 
257  // Unset the input of RPCSeedFinder, PCSeedrecHitFinder, RPCSeedLayerFinder
258  recHitFinder.unsetInput();
259  CosmicrecHitFinder.unsetInput();
260  LayerFinder.unsetInput();
261 }
262 
264  // Set link and EventSetup of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
265  cout << "set link and Geometry EventSetup of RPCSeedFinder, RPCSeedrecHitFinder, RPCCosmicSeedrecHitFinder, "
266  "RPCSeedLayerFinder and RPCSeedOverlapper"
267  << endl;
268 
269  Finder.setOutput(&goodweightedSeeds, &candidateweightedSeeds);
270  recHitFinder.setOutput(&Finder);
271  CosmicrecHitFinder.setOutput(&Finder);
272  LayerFinder.setOutput(&recHitFinder, &CosmicrecHitFinder);
273 }
275  // Get RPCGeometry
276  edm::ESHandle<RPCGeometry> rpcGeometry;
277  iSetup.get<MuonGeometryRecord>().get(rpcGeometry);
278 
279  CosmicrecHitFinder.setEdge(*rpcGeometry);
280  Overlapper.setGeometry(*rpcGeometry);
281  Overlapper.setIO(&goodweightedSeeds, &candidateweightedSeeds);
282 }
283 
284 void RPCSeedGenerator::endJob() { cout << "All jobs completed" << endl; }
285 
286 //define this as a plug-in
RPCSeedFinder.h
bk::beginJob
void beginJob()
Definition: Breakpoints.cc:14
RPCSeedGenerator
Definition: RPCSeedGenerator.cc:85
MuonTransientTrackingRecHit::ConstMuonRecHitPointer
std::shared_ptr< MuonTransientTrackingRecHit const > ConstMuonRecHitPointer
Definition: MuonTransientTrackingRecHit.h:22
RPCSeedrecHitFinder.h
EDProducer.h
MuonRecHitContainer
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
Definition: CosmicMuonSmoother.h:31
ESHandle.h
DetLayer
Definition: DetLayer.h:21
MuonDetLayerGeometry::barrelRPCLayers
const std::vector< const DetLayer * > & barrelRPCLayers() const
return the barrel RPC DetLayers, inside-out
Definition: MuonDetLayerGeometry.cc:179
RPCSeedGenerator::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &iSetup) override
Definition: RPCSeedGenerator.cc:274
edm::Run
Definition: Run.h:45
MuonDetLayerMeasurements
Definition: MuonDetLayerMeasurements.h:41
edm
HLT enums.
Definition: AlignableModifier.h:19
RPCSeedGenerator::LayerFinder
RPCSeedLayerFinder LayerFinder
Definition: RPCSeedGenerator.cc:100
gather_cfg.cout
cout
Definition: gather_cfg.py:144
RPCCosmicSeedrecHitFinder.h
RPCSeedGenerator::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition: RPCSeedGenerator.cc:173
MuonTransientTrackingRecHit::ConstMuonRecHitContainer
std::vector< ConstMuonRecHitPointer > ConstMuonRecHitContainer
Definition: MuonTransientTrackingRecHit.h:27
MuonTransientTrackingRecHit::MuonRecHitContainer
std::vector< MuonRecHitPointer > MuonRecHitContainer
Definition: MuonTransientTrackingRecHit.h:26
RPCSeedPattern::weightedTrajectorySeed
std::pair< TrajectorySeed, double > weightedTrajectorySeed
Definition: RPCSeedPattern.h:36
ConstMuonRecHitContainer
MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer
Definition: RPCSeedGenerator.cc:64
MuonDetLayerGeometry.h
MuonTransientTrackingRecHit.h
RPCSeedGenerator::goodweightedSeeds
std::vector< weightedTrajectorySeed > goodweightedSeeds
Definition: RPCSeedGenerator.cc:103
RPCSeedGenerator::muonMeasurements
MuonDetLayerMeasurements * muonMeasurements
Definition: RPCSeedGenerator.cc:105
RPCSeedLayerFinder
Definition: RPCSeedLayerFinder.h:28
MuonRecoGeometryRecord
Definition: MuonRecoGeometryRecord.h:17
RPCSeedGenerator::beginJob
void beginJob() override
Definition: RPCSeedGenerator.cc:263
MakerMacros.h
MuonRecHitContainer
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
Definition: RPCSeedGenerator.cc:63
MuonTransientTrackingRecHit::MuonRecHitPointer
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
Definition: MuonTransientTrackingRecHit.h:21
RPCSeedrecHitFinder
Definition: RPCSeedrecHitFinder.h:27
RPCLayerNumber
#define RPCLayerNumber
Definition: RPCCosmicSeedrecHitFinder.h:18
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ConstMuonRecHitPointer
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer
Definition: RPCSeedGenerator.cc:62
RPCSeedGenerator::theRPCRecHits
edm::InputTag theRPCRecHits
Definition: RPCSeedGenerator.cc:104
RPCSeedGenerator::RPCSeedGenerator
RPCSeedGenerator(const edm::ParameterSet &iConfig)
Definition: RPCSeedGenerator.cc:119
edm::ESHandle< MuonDetLayerGeometry >
RPCSeedFinder
Definition: RPCSeedFinder.h:23
RPCSeedGenerator::Finder
RPCSeedFinder Finder
Definition: RPCSeedGenerator.cc:97
HLT_FULL_cff.Finder
Finder
Definition: HLT_FULL_cff.py:9907
TrajectorySeed.h
RPCSeedOverlapper
Definition: RPCSeedOverlapper.h:18
RPCRecHitCollection.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
RPCSeedGenerator::Overlapper
RPCSeedOverlapper Overlapper
Definition: RPCSeedGenerator.cc:101
RPCCosmicSeedrecHitFinder
Definition: RPCCosmicSeedrecHitFinder.h:29
MuonRecoGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
TrajectorySeedCollection.h
weightedTrajectorySeed
RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed
Definition: RPCSeedGenerator.cc:65
RPCSeedLayerFinder.h
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
RPCSeedGenerator::CosmicrecHitFinder
RPCCosmicSeedrecHitFinder CosmicrecHitFinder
Definition: RPCSeedGenerator.cc:99
RPCSeedGenerator::recHitFinder
RPCSeedrecHitFinder recHitFinder
Definition: RPCSeedGenerator.cc:98
RPCSeedGenerator::candidateweightedSeeds
std::vector< weightedTrajectorySeed > candidateweightedSeeds
Definition: RPCSeedGenerator.cc:102
MuonDetLayerMeasurements.h
Frameworkfwd.h
dtChamberEfficiency_cfi.theRPCRecHits
theRPCRecHits
Definition: dtChamberEfficiency_cfi.py:14
DetLayer.h
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
MuonRecHitPointer
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
Definition: RPCSeedGenerator.cc:61
ParameterSet.h
RPCSeedOverlapper.h
RPCSeedGenerator::~RPCSeedGenerator
~RPCSeedGenerator() override
Definition: RPCSeedGenerator.cc:159
RPCSeedPattern.h
MuonDetLayerGeometry::endcapRPCLayers
const std::vector< const DetLayer * > & endcapRPCLayers() const
return the endcap RPC DetLayers, -Z to +Z
Definition: MuonDetLayerGeometry.cc:181
edm::Event
Definition: Event.h:73
RPCSeedGenerator::endJob
void endJob() override
Definition: RPCSeedGenerator.cc:284
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45