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
47 
48 // Framework
51 // Math
52 #include <cmath>
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);
89  ~RPCSeedGenerator() override;
90 
91 private:
92  void beginStream(edm::StreamID) override;
93  void beginRun(const edm::Run&, const edm::EventSetup& iSetup) override;
94  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
95  void endStream() override;
96 
97  // ----------member data ---------------------------
103  std::vector<weightedTrajectorySeed> candidateweightedSeeds;
104  std::vector<weightedTrajectorySeed> goodweightedSeeds;
106  std::unique_ptr<MuonDetLayerMeasurements> muonMeasurements;
107 
112 };
113 
114 //
115 // constants, enums and typedefs
116 //
117 
118 //
119 // static data member definitions
120 //
121 
122 //
123 // constructors and destructor
124 //
126  : brRPCGeometryToken(esConsumes<edm::Transition::BeginRun>()),
127  muonLayersToken(esConsumes()),
128  fieldToken(esConsumes()),
129  rpcGeometryToken(esConsumes()) {
130  //register your products
131  /* Examples
132  produces<ExampleData2>();
133 
134  //if do put with a label
135  produces<ExampleData2>("label");
136  */
137 
138  // Now do what ever other initialization is needed
139  // Configure other modules
140  Finder.configure(iConfig);
141  recHitFinder.configure(iConfig);
142  CosmicrecHitFinder.configure(iConfig);
143  LayerFinder.configure(iConfig);
144  Overlapper.configure(iConfig);
145  // Register the production
146  produces<TrajectorySeedCollection>("goodSeeds");
147  produces<TrajectorySeedCollection>("candidateSeeds");
148  // Get event data Tag
149  theRPCRecHits = iConfig.getParameter<edm::InputTag>("RPCRecHitsLabel");
150 
151  // Get RPC recHits by MuonDetLayerMeasurements, while CSC and DT is set to false and with empty InputTag
152  edm::ConsumesCollector iC = consumesCollector();
153 
154  muonMeasurements = std::make_unique<MuonDetLayerMeasurements>(edm::InputTag(),
155  edm::InputTag(),
157  edm::InputTag(),
158  edm::InputTag(),
159  iC,
160  false,
161  false,
162  true,
163  false,
164  false);
165 
166  cout << endl << "[RPCSeedGenerator] --> Constructor called" << endl;
167 }
168 
170  // do anything here that needs to be done at desctruction time
171  // (e.g. close files, deallocate resources etc.)
172  cout << "[RPCSeedGenerator] --> Destructor called" << endl;
173 }
174 
175 //
176 // member functions
177 //
178 
179 // ------------ method called to produce the data ------------
181  using namespace edm;
182  goodweightedSeeds.clear();
183  candidateweightedSeeds.clear();
184 
185  // Create the pointer to the Seed container
186  auto goodCollection = std::make_unique<TrajectorySeedCollection>();
187  auto candidateCollection = std::make_unique<TrajectorySeedCollection>();
188 
189  // Muon Geometry - DT, CSC and RPC
190  MuonDetLayerGeometry const& muonLayers = iSetup.getData(muonLayersToken);
191 
192  // Get the RPC layers
193  vector<const DetLayer*> RPCBarrelLayers = muonLayers.barrelRPCLayers();
194  const DetLayer* RB4L = RPCBarrelLayers[5];
195  const DetLayer* RB3L = RPCBarrelLayers[4];
196  const DetLayer* RB22L = RPCBarrelLayers[3];
197  const DetLayer* RB21L = RPCBarrelLayers[2];
198  const DetLayer* RB12L = RPCBarrelLayers[1];
199  const DetLayer* RB11L = RPCBarrelLayers[0];
200  vector<const DetLayer*> RPCEndcapLayers = muonLayers.endcapRPCLayers();
201  const DetLayer* REM3L = RPCEndcapLayers[0];
202  const DetLayer* REM2L = RPCEndcapLayers[1];
203  const DetLayer* REM1L = RPCEndcapLayers[2];
204  const DetLayer* REP1L = RPCEndcapLayers[3];
205  const DetLayer* REP2L = RPCEndcapLayers[4];
206  const DetLayer* REP3L = RPCEndcapLayers[5];
207 
208  // Dispatch RPC recHits to the corresponding DetLayer, 6 layers for barrel and 3 layers for each endcap
210  recHitsRPC[0] = muonMeasurements->recHits(RB11L, iEvent);
211  recHitsRPC[1] = muonMeasurements->recHits(RB12L, iEvent);
212  recHitsRPC[2] = muonMeasurements->recHits(RB21L, iEvent);
213  recHitsRPC[3] = muonMeasurements->recHits(RB22L, iEvent);
214  recHitsRPC[4] = muonMeasurements->recHits(RB3L, iEvent);
215  recHitsRPC[5] = muonMeasurements->recHits(RB4L, iEvent);
216  recHitsRPC[6] = muonMeasurements->recHits(REM1L, iEvent);
217  recHitsRPC[7] = muonMeasurements->recHits(REM2L, iEvent);
218  recHitsRPC[8] = muonMeasurements->recHits(REM3L, iEvent);
219  recHitsRPC[9] = muonMeasurements->recHits(REP1L, iEvent);
220  recHitsRPC[10] = muonMeasurements->recHits(REP2L, iEvent);
221  recHitsRPC[11] = muonMeasurements->recHits(REP3L, iEvent);
222 
223  // Print the size of recHits in each DetLayer
224  cout << "RB1in " << recHitsRPC[0].size() << " recHits" << endl;
225  cout << "RB1out " << recHitsRPC[1].size() << " recHits" << endl;
226  cout << "RB2in " << recHitsRPC[2].size() << " recHits" << endl;
227  cout << "RB2out " << recHitsRPC[3].size() << " recHits" << endl;
228  cout << "RB3 " << recHitsRPC[4].size() << " recHits" << endl;
229  cout << "RB4 " << recHitsRPC[5].size() << " recHits" << endl;
230  cout << "REM1 " << recHitsRPC[6].size() << " recHits" << endl;
231  cout << "REM2 " << recHitsRPC[7].size() << " recHits" << endl;
232  cout << "REM3 " << recHitsRPC[8].size() << " recHits" << endl;
233  cout << "REP1 " << recHitsRPC[9].size() << " recHits" << endl;
234  cout << "REP2 " << recHitsRPC[10].size() << " recHits" << endl;
235  cout << "REP3 " << recHitsRPC[11].size() << " recHits" << endl;
236 
237  // Set Input of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
238  recHitFinder.setInput(recHitsRPC);
239  CosmicrecHitFinder.setInput(recHitsRPC);
240  LayerFinder.setInput(recHitsRPC);
241 
242  // Set Magnetic Field EventSetup of RPCSeedFinder
243  const MagneticField& Field = iSetup.getData(fieldToken);
244 
245  const RPCGeometry& rpcGeom = iSetup.getData(rpcGeometryToken);
246  Finder.setEventSetup(Field, rpcGeom);
247 
248  // Start from filling layers to filling seeds
249  LayerFinder.fill();
250  Overlapper.run();
251 
252  // Save seeds to event
253  for (vector<weightedTrajectorySeed>::iterator weightedseed = goodweightedSeeds.begin();
254  weightedseed != goodweightedSeeds.end();
255  ++weightedseed)
256  goodCollection->push_back((*weightedseed).first);
257  for (vector<weightedTrajectorySeed>::iterator weightedseed = candidateweightedSeeds.begin();
258  weightedseed != candidateweightedSeeds.end();
259  ++weightedseed)
260  candidateCollection->push_back((*weightedseed).first);
261 
262  // Put the seed to event
263  iEvent.put(std::move(goodCollection), "goodSeeds");
264  iEvent.put(std::move(candidateCollection), "candidateSeeds");
265 
266  // Unset the input of RPCSeedFinder, PCSeedrecHitFinder, RPCSeedLayerFinder
270 }
271 
273  // Set link and EventSetup of RPCSeedFinder, PCSeedrecHitFinder, CosmicrecHitFinder, RPCSeedLayerFinder
274  cout << "set link and Geometry EventSetup of RPCSeedFinder, RPCSeedrecHitFinder, RPCCosmicSeedrecHitFinder, "
275  "RPCSeedLayerFinder and RPCSeedOverlapper"
276  << endl;
277 
282 }
284  // Get RPCGeometry
285  RPCGeometry const& rpcGeometry = iSetup.getData(brRPCGeometryToken);
286 
287  CosmicrecHitFinder.setEdge(rpcGeometry);
288  Overlapper.setGeometry(rpcGeometry);
290 }
291 
292 void RPCSeedGenerator::endStream() { cout << "All jobs completed" << endl; }
293 
294 //define this as a plug-in
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > fieldToken
void setEdge(const RPCGeometry &)
void setGeometry(const RPCGeometry &iGeom)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
edm::InputTag theRPCRecHits
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void configure(const edm::ParameterSet &iConfig)
void setInput(MuonRecHitContainer(&recHits)[12])
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void beginStream(edm::StreamID) override
RPCCosmicSeedrecHitFinder CosmicrecHitFinder
void setOutput(std::vector< weightedTrajectorySeed > *goodweightedRef, std::vector< weightedTrajectorySeed > *candidateweightedRef)
RPCSeedrecHitFinder recHitFinder
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > brRPCGeometryToken
~RPCSeedGenerator() override
void setInput(MuonRecHitContainer(&recHits)[12])
void endStream() override
MuonTransientTrackingRecHit::ConstMuonRecHitContainer ConstMuonRecHitContainer
std::unique_ptr< MuonDetLayerMeasurements > muonMeasurements
#define RPCLayerNumber
MuonTransientTrackingRecHit::MuonRecHitPointer MuonRecHitPointer
void beginRun(const edm::Run &, const edm::EventSetup &iSetup) override
int iEvent
Definition: GenABIO.cc:224
void configure(const edm::ParameterSet &iConfig)
std::shared_ptr< MuonTransientTrackingRecHit > MuonRecHitPointer
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
void setInput(MuonRecHitContainer(&recHitsRPC)[12])
Transition
Definition: Transition.h:12
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void setEventSetup(const MagneticField &field, const RPCGeometry &rpcGeom)
void setOutput(RPCSeedrecHitFinder *Ref, RPCCosmicSeedrecHitFinder *CosmicRef)
std::pair< TrajectorySeed, double > weightedTrajectorySeed
std::vector< ConstMuonRecHitPointer > ConstMuonRecHitContainer
void setOutput(RPCSeedFinder *Seed)
RPCSeedPattern::weightedTrajectorySeed weightedTrajectorySeed
void configure(const edm::ParameterSet &iConfig)
const edm::ESGetToken< RPCGeometry, MuonGeometryRecord > rpcGeometryToken
void configure(const edm::ParameterSet &iConfig)
RPCSeedOverlapper Overlapper
RPCSeedGenerator(const edm::ParameterSet &iConfig)
HLT enums.
void setOutput(RPCSeedFinder *Seed)
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
void setIO(std::vector< weightedTrajectorySeed > *goodweightedRef, std::vector< weightedTrajectorySeed > *candidateweightedRef)
def move(src, dest)
Definition: eostools.py:511
const edm::ESGetToken< MuonDetLayerGeometry, MuonRecoGeometryRecord > muonLayersToken
Definition: Run.h:45
RPCSeedLayerFinder LayerFinder
void configure(const edm::ParameterSet &iConfig)