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