CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataMixingMuonWorker.cc
Go to the documentation of this file.
1 // File: DataMixingMuonWorker.cc
2 // Description: see DataMixingMuonWorker.h
3 // Author: Mike Hildreth, University of Notre Dame
4 //
5 //--------------------------------------------
6 
7 #include <map>
15 //
16 //
17 #include "DataMixingMuonWorker.h"
18 
19 
20 using namespace std;
21 
22 namespace edm
23 {
24 
25  // Virtual constructor
26 
27  DataMixingMuonWorker::DataMixingMuonWorker() { }
28 
29  // Constructor
30  DataMixingMuonWorker::DataMixingMuonWorker(const edm::ParameterSet& ps) :
31  label_(ps.getParameter<std::string>("Label"))
32 
33  {
34 
35  // get the subdetector names
36  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
37 
38  // Declare the products to produce
39 
40  DTDigiTagSig_ = ps.getParameter<edm::InputTag>("DTDigiTagSig");
41  RPCDigiTagSig_ = ps.getParameter<edm::InputTag>("RPCDigiTagSig");
42 
43  CSCstripdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCstripdigiCollectionSig");
44  CSCwiredigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCwiredigiCollectionSig");
45  CSCCompdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCCompdigiCollectionSig");
46 
47  DTPileInputTag_ = ps.getParameter<edm::InputTag>("DTPileInputTag");
48  RPCPileInputTag_ = ps.getParameter<edm::InputTag>("RPCPileInputTag");
49  CSCWirePileInputTag_ = ps.getParameter<edm::InputTag>("CSCWirePileInputTag");
50  CSCStripPileInputTag_ = ps.getParameter<edm::InputTag>("CSCStripPileInputTag");
51  CSCCompPileInputTag_ = ps.getParameter<edm::InputTag>("CSCCompPileInputTag");
52 
53  // outputs:
54 
55  DTDigiCollectionDM_ = ps.getParameter<std::string>("DTDigiCollectionDM");
56  RPCDigiCollectionDM_ = ps.getParameter<std::string>("RPCDigiCollectionDM");
57  CSCStripDigiCollectionDM_ = ps.getParameter<std::string>("CSCStripDigiCollectionDM");
58  CSCWireDigiCollectionDM_ = ps.getParameter<std::string>("CSCWireDigiCollectionDM");
59  CSCComparatorDigiCollectionDM_ = ps.getParameter<std::string>("CSCComparatorDigiCollectionDM");
60 
61 
62  }
63 
64 
65  // Virtual destructor needed.
67  }
68 
70  // fill in maps of hits
71 
72  LogDebug("DataMixingMuonWorker")<<"===============> adding MC signals for "<<e.id();
73 
74  // DT
75  //
76 
78  Handle<DTDigiCollection> pDTdigis;
79 
80  // Get the digis from the event
81  if( e.getByLabel(DTDigiTagSig_, pDTdigis) ) {
82 
83  // LogInfo("DataMixingMuonWorker") << "total # DT Digis: " << DTdigis->size();
84 
85  // Loop over digis, copying them to our own local storage
86  const DTDigiCollection* DTdigis = pDTdigis.product();
88  for (DLayerIt = DTdigis->begin(); DLayerIt != DTdigis->end(); ++DLayerIt) {
89  // The layerId
90  const DTLayerId& layerId = (*DLayerIt).first;
91 
92  // Get the iterators over the digis associated with this LayerId
93  const DTDigiCollection::Range& range = (*DLayerIt).second;
94 
95  OurDTDigis_->put(range, layerId);
96  }
97  }
98  // RPC
99  //
100 
102 
103  // Get the digis from the event
104  Handle<RPCDigiCollection> pRPCdigis;
105 
106  if( e.getByLabel(RPCDigiTagSig_, pRPCdigis) ) {
107 
108  // Loop over digis, copying them to our own local storage
109 
110  const RPCDigiCollection* RPCdigis = pRPCdigis.product();
112  for (RLayerIt = RPCdigis->begin(); RLayerIt != RPCdigis->end(); ++RLayerIt) {
113  // The layerId
114  const RPCDetId& layerId = (*RLayerIt).first;
115 
116  // Get the iterators over the digis associated with this LayerId
117  const RPCDigiCollection::Range& range = (*RLayerIt).second;
118 
119  OurRPCDigis_->put(range, layerId);
120 
121  }
122  }
123  // CSCStrip
124  //
125 
127 
128  // Get the digis from the event
129  Handle<CSCStripDigiCollection> pCSCStripdigis;
130 
131  if( e.getByLabel(CSCstripdigi_collectionSig_, pCSCStripdigis) ) {
132 
133  //if(pCSCStripdigis.isValid() ) { std::cout << "Signal: have CSCStripDigis" << std::endl;}
134  //else { std::cout << "Signal: NO CSCStripDigis" << std::endl;}
135 
136 
137  // Loop over digis, copying them to our own local storage
138 
139  const CSCStripDigiCollection* CSCStripdigis = pCSCStripdigis.product();
141  for (CSLayerIt = CSCStripdigis->begin(); CSLayerIt != CSCStripdigis->end(); ++CSLayerIt) {
142  // The layerId
143  const CSCDetId& layerId = (*CSLayerIt).first;
144 
145  // Get the iterators over the digis associated with this LayerId
146  const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
147 
148  OurCSCStripDigis_->put(range, layerId);
149  }
150  }
151  // CSCWire
152  //
153 
155 
156  // Get the digis from the event
157  Handle<CSCWireDigiCollection> pCSCWiredigis;
158 
159  if( e.getByLabel(CSCwiredigi_collectionSig_, pCSCWiredigis) ) {
160 
161 
162  //if(pCSCWiredigis.isValid() ) { std::cout << "Signal: have CSCWireDigis" << std::endl;}
163  //else { std::cout << "Signal: NO CSCWireDigis" << std::endl;}
164 
165  // Loop over digis, copying them to our own local storage
166 
167  const CSCWireDigiCollection* CSCWiredigis = pCSCWiredigis.product();
169  for (CWLayerIt = CSCWiredigis->begin(); CWLayerIt != CSCWiredigis->end(); ++CWLayerIt) {
170  // The layerId
171  const CSCDetId& layerId = (*CWLayerIt).first;
172 
173  // Get the iterators over the digis associated with this LayerId
174  const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
175 
176  OurCSCWireDigis_->put(range, layerId);
177 
178  }
179  }
180 
181  // CSCComparators
182  //
183 
185 
186  // Get the digis from the event
187  Handle<CSCComparatorDigiCollection> pCSCComparatordigis;
188 
189  //std::cout << "CSCComp label: " << CSCDigiTagSig_.label() << " " << CSCCompdigi_collectionSig_.label() << std::endl;
190 
191  if( e.getByLabel(CSCCompdigi_collectionSig_, pCSCComparatordigis) ) {
192 
193 
194  //if(pCSCComparatordigis.isValid() ) { std::cout << "Signal: have CSCComparatorDigis" << std::endl;}
195  //else { std::cout << "Signal: NO CSCComparatorDigis" << std::endl;}
196 
197  // Loop over digis, copying them to our own local storage
198 
199  const CSCComparatorDigiCollection* CSCComparatordigis = pCSCComparatordigis.product();
201  for (CWLayerIt = CSCComparatordigis->begin(); CWLayerIt != CSCComparatordigis->end(); ++CWLayerIt) {
202  // The layerId
203  const CSCDetId& layerId = (*CWLayerIt).first;
204 
205  // Get the iterators over the digis associated with this LayerId
206  const CSCComparatorDigiCollection::Range& range = (*CWLayerIt).second;
207 
208  OurCSCComparatorDigis_->put(range, layerId);
209 
210  }
211  }
212 
213 
214  } // end of addMuonSignals
215 
216  void DataMixingMuonWorker::addMuonPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr,
217  ModuleCallingContext const* mcc) {
218 
219  LogDebug("DataMixingMuonWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
220 
221  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
222 
223  // DT
224  //
225  // Get the digis from the event
226 
227  boost::shared_ptr<Wrapper<DTDigiCollection> const> DTDigisPTR =
228  getProductByTag<DTDigiCollection>(*ep, DTPileInputTag_, mcc);
229 
230  if(DTDigisPTR ) {
231 
232  const DTDigiCollection* DTDigis = const_cast< DTDigiCollection * >(DTDigisPTR->product());
233 
235  for (DTLayerIt = DTDigis->begin(); DTLayerIt != DTDigis->end(); ++DTLayerIt) {
236  // The layerId
237  const DTLayerId& layerId = (*DTLayerIt).first;
238 
239  // Get the iterators over the Digis associated with this LayerId
240  const DTDigiCollection::Range& range = (*DTLayerIt).second;
241 
242  OurDTDigis_->put(range, layerId);
243 
244  }
245  }
246  // RPC
247  //
248 
249  // Get the digis from the event
250 
251 
252  boost::shared_ptr<Wrapper<RPCDigiCollection> const> RPCDigisPTR =
253  getProductByTag<RPCDigiCollection>(*ep, RPCPileInputTag_, mcc);
254 
255  if(RPCDigisPTR ) {
256 
257  const RPCDigiCollection* RPCDigis = const_cast< RPCDigiCollection * >(RPCDigisPTR->product());
258 
260  for (RPCLayerIt = RPCDigis->begin(); RPCLayerIt != RPCDigis->end(); ++RPCLayerIt) {
261  // The layerId
262  const RPCDetId& layerId = (*RPCLayerIt).first;
263 
264  // Get the iterators over the digis associated with this LayerId
265  const RPCDigiCollection::Range& range = (*RPCLayerIt).second;
266 
267  OurRPCDigis_->put(range, layerId);
268 
269  }
270  }
271 
272  // CSCStrip
273  //
274 
275  // Get the digis from the event
276 
277  boost::shared_ptr<Wrapper<CSCStripDigiCollection> const> CSCStripDigisPTR =
278  getProductByTag<CSCStripDigiCollection>(*ep, CSCStripPileInputTag_, mcc);
279 
280  if(CSCStripDigisPTR ) {
281 
282  const CSCStripDigiCollection* CSCStripDigis = const_cast< CSCStripDigiCollection * >(CSCStripDigisPTR->product());
283 
285  for (CSCStripLayerIt = CSCStripDigis->begin(); CSCStripLayerIt != CSCStripDigis->end(); ++CSCStripLayerIt) {
286  // The layerId
287  const CSCDetId& layerId = (*CSCStripLayerIt).first;
288 
289  // Get the iterators over the digis associated with this LayerId
290  const CSCStripDigiCollection::Range& range = (*CSCStripLayerIt).second;
291 
292  OurCSCStripDigis_->put(range, layerId);
293 
294  }
295  }
296 
297  // CSCWire
298  //
299 
300  // Get the digis from the event
301 
302  boost::shared_ptr<Wrapper<CSCWireDigiCollection> const> CSCWireDigisPTR =
303  getProductByTag<CSCWireDigiCollection>(*ep, CSCWirePileInputTag_, mcc);
304 
305  if(CSCWireDigisPTR ) {
306 
307  const CSCWireDigiCollection* CSCWireDigis = const_cast< CSCWireDigiCollection * >(CSCWireDigisPTR->product());
308 
310  for (CSCWireLayerIt = CSCWireDigis->begin(); CSCWireLayerIt != CSCWireDigis->end(); ++CSCWireLayerIt) {
311  // The layerId
312  const CSCDetId& layerId = (*CSCWireLayerIt).first;
313 
314  // Get the iterators over the digis associated with this LayerId
315  const CSCWireDigiCollection::Range& range = (*CSCWireLayerIt).second;
316 
317  OurCSCWireDigis_->put(range, layerId);
318 
319  }
320  }
321 
322  // CSCComparators
323  //
324 
325  // Get the digis from the event
326 
327  boost::shared_ptr<Wrapper<CSCComparatorDigiCollection> const> CSCComparatorDigisPTR =
328  getProductByTag<CSCComparatorDigiCollection>(*ep, CSCCompPileInputTag_, mcc);
329 
330  if(CSCComparatorDigisPTR ) {
331 
332  const CSCComparatorDigiCollection* CSCComparatorDigis = const_cast< CSCComparatorDigiCollection * >(CSCComparatorDigisPTR->product());
333 
335  for (CSCComparatorLayerIt = CSCComparatorDigis->begin(); CSCComparatorLayerIt != CSCComparatorDigis->end(); ++CSCComparatorLayerIt) {
336  // The layerId
337  const CSCDetId& layerId = (*CSCComparatorLayerIt).first;
338 
339  // Get the iterators over the digis associated with this LayerId
340  const CSCComparatorDigiCollection::Range& range = (*CSCComparatorLayerIt).second;
341 
342  OurCSCComparatorDigis_->put(range, layerId);
343 
344  }
345  }
346 
347 
348  }
349 
351 
352  // collections of digis to put in the event
353  std::auto_ptr< DTDigiCollection > DTDigiMerge( new DTDigiCollection );
354  std::auto_ptr< RPCDigiCollection > RPCDigiMerge( new RPCDigiCollection );
355  std::auto_ptr< CSCStripDigiCollection > CSCStripDigiMerge( new CSCStripDigiCollection );
356  std::auto_ptr< CSCWireDigiCollection > CSCWireDigiMerge( new CSCWireDigiCollection );
357  std::auto_ptr< CSCComparatorDigiCollection > CSCComparatorDigiMerge( new CSCComparatorDigiCollection );
358 
359  // Loop over DT digis, copying them from our own local storage
360 
362  for (DLayerIt = OurDTDigis_->begin(); DLayerIt != OurDTDigis_->end(); ++DLayerIt) {
363  // The layerId
364  const DTLayerId& layerId = (*DLayerIt).first;
365 
366  // Get the iterators over the digis associated with this LayerId
367  const DTDigiCollection::Range& range = (*DLayerIt).second;
368 
369  DTDigiMerge->put(range, layerId);
370 
371  }
372 
373  // Loop over RPC digis, copying them from our own local storage
374 
376  for (RLayerIt = OurRPCDigis_->begin(); RLayerIt != OurRPCDigis_->end(); ++RLayerIt) {
377  // The layerId
378  const RPCDetId& layerId = (*RLayerIt).first;
379 
380  // Get the iterators over the digis associated with this LayerId
381  const RPCDigiCollection::Range& range = (*RLayerIt).second;
382 
383  RPCDigiMerge->put(range, layerId);
384 
385  }
386  // Loop over CSCStrip digis, copying them from our own local storage
387 
389  for (CSLayerIt = OurCSCStripDigis_->begin(); CSLayerIt != OurCSCStripDigis_->end(); ++CSLayerIt) {
390  // The layerId
391  const CSCDetId& layerId = (*CSLayerIt).first;
392 
393  // Get the iterators over the digis associated with this LayerId
394  const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
395 
396  CSCStripDigiMerge->put(range, layerId);
397 
398  }
399  // Loop over CSCStrip digis, copying them from our own local storage
400 
402  for (CWLayerIt = OurCSCWireDigis_->begin(); CWLayerIt != OurCSCWireDigis_->end(); ++CWLayerIt) {
403  // The layerId
404  const CSCDetId& layerId = (*CWLayerIt).first;
405 
406  // Get the iterators over the digis associated with this LayerId
407  const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
408 
409  CSCWireDigiMerge->put(range, layerId);
410 
411  }
412 
413  // Loop over CSCComparator digis, copying them from our own local storage
414 
416  for (CCLayerIt = OurCSCComparatorDigis_->begin(); CCLayerIt != OurCSCComparatorDigis_->end(); ++CCLayerIt) {
417  // The layerId
418  const CSCDetId& layerId = (*CCLayerIt).first;
419 
420  // Get the iterators over the digis associated with this LayerId
421  const CSCComparatorDigiCollection::Range& range = (*CCLayerIt).second;
422 
423  CSCComparatorDigiMerge->put(range, layerId);
424 
425  }
426 
427 
428  // put the collection of recunstructed hits in the event
429  // LogDebug("DataMixingMuonWorker") << "total # DT Merged Digis: " << DTDigiMerge->size() ;
430  // LogDebug("DataMixingMuonWorker") << "total # RPC Merged Digis: " << RPCDigiMerge->size() ;
431  // LogDebug("DataMixingMuonWorker") << "total # CSCStrip Merged Digis: " << CSCStripDigiMerge->size() ;
432  // LogDebug("DataMixingMuonWorker") << "total # CSCWire Merged Digis: " << CSCWireDigiMerge->size() ;
433 
434  e.put( DTDigiMerge );
435  e.put( RPCDigiMerge );
436  e.put( CSCStripDigiMerge, CSCStripDigiCollectionDM_ );
437  e.put( CSCWireDigiMerge, CSCWireDigiCollectionDM_ );
438  e.put( CSCComparatorDigiMerge, CSCComparatorDigiCollectionDM_ );
439 
440  // clear local storage for this event
441  delete OurDTDigis_;
442  delete OurRPCDigis_;
443  delete OurCSCStripDigis_;
444  delete OurCSCWireDigis_;
445  delete OurCSCComparatorDigis_;
446 
447  }
448 
449 } //edm
#define LogDebug(id)
T getParameter(std::string const &) const
void addMuonSignals(const edm::Event &e)
void addMuonPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId, ModuleCallingContext const *)
EventID const & id() const
edm::InputTag CSCwiredigi_collectionSig_
MuonDigiCollection< CSCDetId, CSCStripDigi > CSCStripDigiCollection
CSCStripDigiCollection * OurCSCStripDigis_
DTDigiCollection * OurDTDigis_
MuonDigiCollection< CSCDetId, CSCComparatorDigi > CSCComparatorDigiCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
RPCDigiCollection * OurRPCDigis_
CSCWireDigiCollection * OurCSCWireDigis_
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
CSCComparatorDigiCollection * OurCSCComparatorDigis_
T const * product() const
Definition: Handle.h:81
edm::EventID id() const
Definition: EventBase.h:56
MuonDigiCollection< DTLayerId, DTDigi > DTDigiCollection
edm::InputTag CSCCompdigi_collectionSig_
std::pair< const_iterator, const_iterator > Range
edm::InputTag CSCstripdigi_collectionSig_