CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: RPCSeedGenerator.cc,v 1.7 2010/02/16 17:08:43 wmtan Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 // user include files
29 // special include files
35 #include <vector>
36 // Using other classes
43 // Geometry
48 // Framework
51 // Math
52 #include "math.h"
53 // C++
54 #include <vector>
55 
56 //
57 // constants, enums and typedefs
58 //
59 using namespace std;
60 using namespace edm;
61 
67 
68 #ifndef RPCLayerNumber
69 #define RPCLayerNumber 12
70 #endif
71 
72 #ifndef BarrelLayerNumber
73 #define BarrelLayerNumber 6
74 #endif
75 
76 #ifndef EachEndcapLayerNumber
77 #define EachEndcapLayerNumber 3
78 #endif
79 
80 //
81 // class decleration
82 //
83 
84 class RPCSeedFinder;
85 
87  public:
88  explicit RPCSeedGenerator(const edm::ParameterSet& iConfig);
90 
91  private:
92  virtual void beginJob();
93  virtual void beginRun(const edm::Run&, const edm::EventSetup& iSetup);
94  virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
95  virtual void endJob();
96 
97  // ----------member data ---------------------------
103  std::vector<weightedTrajectorySeed> candidateweightedSeeds;
104  std::vector<weightedTrajectorySeed> goodweightedSeeds;
106 };
107 
108 
109 //
110 // constants, enums and typedefs
111 //
112 
113 
114 //
115 // static data member definitions
116 //
117 
118 //
119 // constructors and destructor
120 //
122 {
123  //register your products
124  /* Examples
125  produces<ExampleData2>();
126 
127  //if do put with a label
128  produces<ExampleData2>("label");
129  */
130 
131  // Now do what ever other initialization is needed
132  // Configure other modules
133  Finder.configure(iConfig);
134  recHitFinder.configure(iConfig);
135  CosmicrecHitFinder.configure(iConfig);
136  LayerFinder.configure(iConfig);
137  Overlapper.configure(iConfig);
138  // Register the production
139  produces<TrajectorySeedCollection>("goodSeeds");
140  produces<TrajectorySeedCollection>("candidateSeeds");
141  // Get event data Tag
142  theRPCRecHits = iConfig.getParameter<edm::InputTag>("RPCRecHitsLabel");
143 
144  cout << endl << "[RPCSeedGenerator] --> Constructor called" << endl;
145 }
146 
147 
149 {
150  // do anything here that needs to be done at desctruction time
151  // (e.g. close files, deallocate resources etc.)
152  cout << "[RPCSeedGenerator] --> Destructor called" << endl;
153 }
154 
155 
156 //
157 // member functions
158 //
159 
160 // ------------ method called to produce the data ------------
161  void
163 {
164  using namespace edm;
165  /* This is an event example
166  //Read 'ExampleData' from the Event
167  Handle<ExampleData> pIn;
168  iEvent.getByLabel("example",pIn);
169 
170  //Use the ExampleData to create an ExampleData2 which
171  // is put into the Event
172  std::auto_ptr<ExampleData2> pOut(new ExampleData2(*pIn));
173  iEvent.put(pOut);
174  */
175 
176  /* this is an EventSetup example
177  //Read SetupData from the SetupRecord in the EventSetup
178  ESHandle<SetupData> pSetup;
179  iSetup.get<SetupRecord>().get(pSetup);
180  */
181 
182  // clear weighted Seeds from last reconstruction
183  goodweightedSeeds.clear();
184  candidateweightedSeeds.clear();
185 
186  // Create the pointer to the Seed container
187  auto_ptr<TrajectorySeedCollection> goodCollection(new TrajectorySeedCollection());
188  auto_ptr<TrajectorySeedCollection> candidateCollection(new TrajectorySeedCollection());
189 
190  // Muon Geometry - DT, CSC and RPC
192  iSetup.get<MuonRecoGeometryRecord>().get(muonLayers);
193 
194  // Get the RPC layers
195  vector<DetLayer*> RPCBarrelLayers = muonLayers->barrelRPCLayers();
196  const DetLayer* RB4L = RPCBarrelLayers[5];
197  const DetLayer* RB3L = RPCBarrelLayers[4];
198  const DetLayer* RB22L = RPCBarrelLayers[3];
199  const DetLayer* RB21L = RPCBarrelLayers[2];
200  const DetLayer* RB12L = RPCBarrelLayers[1];
201  const DetLayer* RB11L = RPCBarrelLayers[0];
202  vector<DetLayer*> RPCEndcapLayers = muonLayers->endcapRPCLayers();
203  const DetLayer* REM3L = RPCEndcapLayers[0];
204  const DetLayer* REM2L = RPCEndcapLayers[1];
205  const DetLayer* REM1L = RPCEndcapLayers[2];
206  const DetLayer* REP1L = RPCEndcapLayers[3];
207  const DetLayer* REP2L = RPCEndcapLayers[4];
208  const DetLayer* REP3L = RPCEndcapLayers[5];
209 
210  // Get RPC recHits by MuonDetLayerMeasurements, while CSC and DT is set to false and with empty InputTag
211  MuonDetLayerMeasurements muonMeasurements(edm::InputTag(), edm::InputTag(), theRPCRecHits, false, false, true);
212 
213  // Dispatch RPC recHits to the corresponding DetLayer, 6 layers for barrel and 3 layers for each endcap
215  recHitsRPC[0] = muonMeasurements.recHits(RB11L, iEvent);
216  recHitsRPC[1] = muonMeasurements.recHits(RB12L, iEvent);
217  recHitsRPC[2] = muonMeasurements.recHits(RB21L, iEvent);
218  recHitsRPC[3] = muonMeasurements.recHits(RB22L, iEvent);
219  recHitsRPC[4] = muonMeasurements.recHits(RB3L, iEvent);
220  recHitsRPC[5] = muonMeasurements.recHits(RB4L, iEvent);
221  recHitsRPC[6] = muonMeasurements.recHits(REM1L, iEvent);
222  recHitsRPC[7] = muonMeasurements.recHits(REM2L, iEvent);
223  recHitsRPC[8] = muonMeasurements.recHits(REM3L, iEvent);
224  recHitsRPC[9] = muonMeasurements.recHits(REP1L, iEvent);
225  recHitsRPC[10] = muonMeasurements.recHits(REP2L, iEvent);
226  recHitsRPC[11] = muonMeasurements.recHits(REP3L, iEvent);
227 
228  // Print the size of recHits in each DetLayer
229  cout << "RB1in " << recHitsRPC[0].size() << " recHits" << endl;
230  cout << "RB1out " << recHitsRPC[1].size() << " recHits" << endl;
231  cout << "RB2in " << recHitsRPC[2].size() << " recHits" << endl;
232  cout << "RB2out " << recHitsRPC[3].size() << " recHits" << endl;
233  cout << "RB3 " << recHitsRPC[4].size() << " recHits" << endl;
234  cout << "RB4 " << recHitsRPC[5].size() << " recHits" << endl;
235  cout << "REM1 " << recHitsRPC[6].size() << " recHits" << endl;
236  cout << "REM2 " << recHitsRPC[7].size() << " recHits" << endl;
237  cout << "REM3 " << recHitsRPC[8].size() << " recHits" << endl;
238  cout << "REP1 " << recHitsRPC[9].size() << " recHits" << endl;
239  cout << "REP2 " << recHitsRPC[10].size() << " recHits" << endl;
240  cout << "REP3 " << recHitsRPC[11].size() << " recHits" << endl;
241 
242  // Set Input of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
243  recHitFinder.setInput(recHitsRPC);
244  CosmicrecHitFinder.setInput(recHitsRPC);
245  LayerFinder.setInput(recHitsRPC);
246 
247  // Set Magnetic Field EventSetup of RPCSeedFinder
248  Finder.setEventSetup(iSetup);
249 
250  // Start from filling layers to filling seeds
251  LayerFinder.fill();
252  Overlapper.run();
253 
254  // Save seeds to event
255  for(vector<weightedTrajectorySeed>::iterator weightedseed = goodweightedSeeds.begin(); weightedseed != goodweightedSeeds.end(); ++weightedseed)
256  goodCollection->push_back((*weightedseed).first);
257  for(vector<weightedTrajectorySeed>::iterator weightedseed = candidateweightedSeeds.begin(); weightedseed != candidateweightedSeeds.end(); ++weightedseed)
258  candidateCollection->push_back((*weightedseed).first);
259 
260  // Put the seed to event
261  iEvent.put(goodCollection, "goodSeeds");
262  iEvent.put(candidateCollection, "candidateSeeds");
263 
264  // Unset the input of RPCSeedFinder, PCSeedrecHitFinder, RPCSeedLayerFinder
265  recHitFinder.unsetInput();
266  CosmicrecHitFinder.unsetInput();
267  LayerFinder.unsetInput();
268 
269 }
270 
272 
273  // Set link and EventSetup of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
274  cout << "set link and Geometry EventSetup of RPCSeedFinder, RPCSeedrecHitFinder, RPCCosmicSeedrecHitFinder, RPCSeedLayerFinder and RPCSeedOverlapper" << endl;
275 
276  Finder.setOutput(&goodweightedSeeds, &candidateweightedSeeds);
277  recHitFinder.setOutput(&Finder);
278  CosmicrecHitFinder.setOutput(&Finder);
279  LayerFinder.setOutput(&recHitFinder, &CosmicrecHitFinder);
280 }
282  CosmicrecHitFinder.setEdge(iSetup);
283  Overlapper.setEventSetup(iSetup);
284  Overlapper.setIO(&goodweightedSeeds, &candidateweightedSeeds);
285 }
286 
288 
289  cout << "All jobs completed" << endl;
290 }
291 
292 //define this as a plug-in
T getParameter(std::string const &) const
edm::InputTag theRPCRecHits
RPCCosmicSeedrecHitFinder CosmicrecHitFinder
RPCSeedrecHitFinder recHitFinder
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginJob()
virtual void beginRun(const edm::Run &, const edm::EventSetup &iSetup)
virtual void endJob()
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:243
std::vector< TrajectorySeed > TrajectorySeedCollection
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer
std::pair< TrajectorySeed, double > weightedTrajectorySeed
std::vector< ConstMuonRecHitPointer > ConstMuonRecHitContainer
#define RPCLayerNumber
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed
const T & get() const
Definition: EventSetup.h:55
RPCSeedOverlapper Overlapper
RPCSeedGenerator(const edm::ParameterSet &iConfig)
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
tuple cout
Definition: gather_cfg.py:121
RPCSeedFinder Finder
std::vector< weightedTrajectorySeed > goodweightedSeeds
std::vector< weightedTrajectorySeed > candidateweightedSeeds
std::vector< MuonRecHitPointer > MuonRecHitContainer
Definition: Run.h:33
RPCSeedLayerFinder LayerFinder
MuonTransientTrackingRecHit::ConstMuonRecHitPointer ConstMuonRecHitPointer