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() { sel_=0;}
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  // create input selector
39  if (label_.size()>0){
41  }
42  else {
44  }
45 
46  // Declare the products to produce
47 
48  DTDigiTagSig_ = ps.getParameter<edm::InputTag>("DTDigiTagSig");
49  RPCDigiTagSig_ = ps.getParameter<edm::InputTag>("RPCDigiTagSig");
50 
51  CSCstripdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCstripdigiCollectionSig");
52  CSCwiredigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCwiredigiCollectionSig");
53  CSCCompdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCCompdigiCollectionSig");
54 
55  DTPileInputTag_ = ps.getParameter<edm::InputTag>("DTPileInputTag");
56  RPCPileInputTag_ = ps.getParameter<edm::InputTag>("RPCPileInputTag");
57  CSCWirePileInputTag_ = ps.getParameter<edm::InputTag>("CSCWirePileInputTag");
58  CSCStripPileInputTag_ = ps.getParameter<edm::InputTag>("CSCStripPileInputTag");
59  CSCCompPileInputTag_ = ps.getParameter<edm::InputTag>("CSCCompPileInputTag");
60 
61  // outputs:
62 
63  DTDigiCollectionDM_ = ps.getParameter<std::string>("DTDigiCollectionDM");
64  RPCDigiCollectionDM_ = ps.getParameter<std::string>("RPCDigiCollectionDM");
65  CSCStripDigiCollectionDM_ = ps.getParameter<std::string>("CSCStripDigiCollectionDM");
66  CSCWireDigiCollectionDM_ = ps.getParameter<std::string>("CSCWireDigiCollectionDM");
67  CSCComparatorDigiCollectionDM_ = ps.getParameter<std::string>("CSCComparatorDigiCollectionDM");
68 
69 
70  }
71 
72 
73  // Virtual destructor needed.
75  delete sel_;
76  sel_=0;
77  }
78 
80  // fill in maps of hits
81 
82  LogDebug("DataMixingMuonWorker")<<"===============> adding MC signals for "<<e.id();
83 
84  // DT
85  //
86 
88  Handle<DTDigiCollection> pDTdigis;
89 
90  // Get the digis from the event
91  if( e.getByLabel(DTDigiTagSig_, pDTdigis) ) {
92 
93  // LogInfo("DataMixingMuonWorker") << "total # DT Digis: " << DTdigis->size();
94 
95  // Loop over digis, copying them to our own local storage
96  const DTDigiCollection* DTdigis = pDTdigis.product();
98  for (DLayerIt = DTdigis->begin(); DLayerIt != DTdigis->end(); ++DLayerIt) {
99  // The layerId
100  const DTLayerId& layerId = (*DLayerIt).first;
101 
102  // Get the iterators over the digis associated with this LayerId
103  const DTDigiCollection::Range& range = (*DLayerIt).second;
104 
105  OurDTDigis_->put(range, layerId);
106  }
107  }
108  // RPC
109  //
110 
112 
113  // Get the digis from the event
114  Handle<RPCDigiCollection> pRPCdigis;
115 
116  if( e.getByLabel(RPCDigiTagSig_, pRPCdigis) ) {
117 
118  // Loop over digis, copying them to our own local storage
119 
120  const RPCDigiCollection* RPCdigis = pRPCdigis.product();
122  for (RLayerIt = RPCdigis->begin(); RLayerIt != RPCdigis->end(); ++RLayerIt) {
123  // The layerId
124  const RPCDetId& layerId = (*RLayerIt).first;
125 
126  // Get the iterators over the digis associated with this LayerId
127  const RPCDigiCollection::Range& range = (*RLayerIt).second;
128 
129  OurRPCDigis_->put(range, layerId);
130 
131  }
132  }
133  // CSCStrip
134  //
135 
137 
138  // Get the digis from the event
139  Handle<CSCStripDigiCollection> pCSCStripdigis;
140 
141  if( e.getByLabel(CSCstripdigi_collectionSig_, pCSCStripdigis) ) {
142 
143  //if(pCSCStripdigis.isValid() ) { std::cout << "Signal: have CSCStripDigis" << std::endl;}
144  //else { std::cout << "Signal: NO CSCStripDigis" << std::endl;}
145 
146 
147  // Loop over digis, copying them to our own local storage
148 
149  const CSCStripDigiCollection* CSCStripdigis = pCSCStripdigis.product();
151  for (CSLayerIt = CSCStripdigis->begin(); CSLayerIt != CSCStripdigis->end(); ++CSLayerIt) {
152  // The layerId
153  const CSCDetId& layerId = (*CSLayerIt).first;
154 
155  // Get the iterators over the digis associated with this LayerId
156  const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
157 
158  OurCSCStripDigis_->put(range, layerId);
159  }
160  }
161  // CSCWire
162  //
163 
165 
166  // Get the digis from the event
167  Handle<CSCWireDigiCollection> pCSCWiredigis;
168 
169  if( e.getByLabel(CSCwiredigi_collectionSig_, pCSCWiredigis) ) {
170 
171 
172  //if(pCSCWiredigis.isValid() ) { std::cout << "Signal: have CSCWireDigis" << std::endl;}
173  //else { std::cout << "Signal: NO CSCWireDigis" << std::endl;}
174 
175  // Loop over digis, copying them to our own local storage
176 
177  const CSCWireDigiCollection* CSCWiredigis = pCSCWiredigis.product();
179  for (CWLayerIt = CSCWiredigis->begin(); CWLayerIt != CSCWiredigis->end(); ++CWLayerIt) {
180  // The layerId
181  const CSCDetId& layerId = (*CWLayerIt).first;
182 
183  // Get the iterators over the digis associated with this LayerId
184  const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
185 
186  OurCSCWireDigis_->put(range, layerId);
187 
188  }
189  }
190 
191  // CSCComparators
192  //
193 
195 
196  // Get the digis from the event
197  Handle<CSCComparatorDigiCollection> pCSCComparatordigis;
198 
199  //std::cout << "CSCComp label: " << CSCDigiTagSig_.label() << " " << CSCCompdigi_collectionSig_.label() << std::endl;
200 
201  if( e.getByLabel(CSCCompdigi_collectionSig_, pCSCComparatordigis) ) {
202 
203 
204  //if(pCSCComparatordigis.isValid() ) { std::cout << "Signal: have CSCComparatorDigis" << std::endl;}
205  //else { std::cout << "Signal: NO CSCComparatorDigis" << std::endl;}
206 
207  // Loop over digis, copying them to our own local storage
208 
209  const CSCComparatorDigiCollection* CSCComparatordigis = pCSCComparatordigis.product();
211  for (CWLayerIt = CSCComparatordigis->begin(); CWLayerIt != CSCComparatordigis->end(); ++CWLayerIt) {
212  // The layerId
213  const CSCDetId& layerId = (*CWLayerIt).first;
214 
215  // Get the iterators over the digis associated with this LayerId
216  const CSCComparatorDigiCollection::Range& range = (*CWLayerIt).second;
217 
218  OurCSCComparatorDigis_->put(range, layerId);
219 
220  }
221  }
222 
223 
224  } // end of addMuonSignals
225 
226  void DataMixingMuonWorker::addMuonPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr) {
227 
228  LogDebug("DataMixingMuonWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
229 
230  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
231 
232  // DT
233  //
234  // Get the digis from the event
235 
236  boost::shared_ptr<Wrapper<DTDigiCollection> const> DTDigisPTR =
237  getProductByTag<DTDigiCollection>(*ep, DTPileInputTag_ );
238 
239  if(DTDigisPTR ) {
240 
241  const DTDigiCollection* DTDigis = const_cast< DTDigiCollection * >(DTDigisPTR->product());
242 
244  for (DTLayerIt = DTDigis->begin(); DTLayerIt != DTDigis->end(); ++DTLayerIt) {
245  // The layerId
246  const DTLayerId& layerId = (*DTLayerIt).first;
247 
248  // Get the iterators over the Digis associated with this LayerId
249  const DTDigiCollection::Range& range = (*DTLayerIt).second;
250 
251  OurDTDigis_->put(range, layerId);
252 
253  }
254  }
255  // RPC
256  //
257 
258  // Get the digis from the event
259 
260 
261  boost::shared_ptr<Wrapper<RPCDigiCollection> const> RPCDigisPTR =
262  getProductByTag<RPCDigiCollection>(*ep, RPCPileInputTag_ );
263 
264  if(RPCDigisPTR ) {
265 
266  const RPCDigiCollection* RPCDigis = const_cast< RPCDigiCollection * >(RPCDigisPTR->product());
267 
269  for (RPCLayerIt = RPCDigis->begin(); RPCLayerIt != RPCDigis->end(); ++RPCLayerIt) {
270  // The layerId
271  const RPCDetId& layerId = (*RPCLayerIt).first;
272 
273  // Get the iterators over the digis associated with this LayerId
274  const RPCDigiCollection::Range& range = (*RPCLayerIt).second;
275 
276  OurRPCDigis_->put(range, layerId);
277 
278  }
279  }
280 
281  // CSCStrip
282  //
283 
284  // Get the digis from the event
285 
286  boost::shared_ptr<Wrapper<CSCStripDigiCollection> const> CSCStripDigisPTR =
287  getProductByTag<CSCStripDigiCollection>(*ep, CSCStripPileInputTag_ );
288 
289  if(CSCStripDigisPTR ) {
290 
291  const CSCStripDigiCollection* CSCStripDigis = const_cast< CSCStripDigiCollection * >(CSCStripDigisPTR->product());
292 
294  for (CSCStripLayerIt = CSCStripDigis->begin(); CSCStripLayerIt != CSCStripDigis->end(); ++CSCStripLayerIt) {
295  // The layerId
296  const CSCDetId& layerId = (*CSCStripLayerIt).first;
297 
298  // Get the iterators over the digis associated with this LayerId
299  const CSCStripDigiCollection::Range& range = (*CSCStripLayerIt).second;
300 
301  OurCSCStripDigis_->put(range, layerId);
302 
303  }
304  }
305 
306  // CSCWire
307  //
308 
309  // Get the digis from the event
310 
311  boost::shared_ptr<Wrapper<CSCWireDigiCollection> const> CSCWireDigisPTR =
312  getProductByTag<CSCWireDigiCollection>(*ep, CSCWirePileInputTag_ );
313 
314  if(CSCWireDigisPTR ) {
315 
316  const CSCWireDigiCollection* CSCWireDigis = const_cast< CSCWireDigiCollection * >(CSCWireDigisPTR->product());
317 
319  for (CSCWireLayerIt = CSCWireDigis->begin(); CSCWireLayerIt != CSCWireDigis->end(); ++CSCWireLayerIt) {
320  // The layerId
321  const CSCDetId& layerId = (*CSCWireLayerIt).first;
322 
323  // Get the iterators over the digis associated with this LayerId
324  const CSCWireDigiCollection::Range& range = (*CSCWireLayerIt).second;
325 
326  OurCSCWireDigis_->put(range, layerId);
327 
328  }
329  }
330 
331  // CSCComparators
332  //
333 
334  // Get the digis from the event
335 
336  boost::shared_ptr<Wrapper<CSCComparatorDigiCollection> const> CSCComparatorDigisPTR =
337  getProductByTag<CSCComparatorDigiCollection>(*ep, CSCCompPileInputTag_ );
338 
339  if(CSCComparatorDigisPTR ) {
340 
341  const CSCComparatorDigiCollection* CSCComparatorDigis = const_cast< CSCComparatorDigiCollection * >(CSCComparatorDigisPTR->product());
342 
344  for (CSCComparatorLayerIt = CSCComparatorDigis->begin(); CSCComparatorLayerIt != CSCComparatorDigis->end(); ++CSCComparatorLayerIt) {
345  // The layerId
346  const CSCDetId& layerId = (*CSCComparatorLayerIt).first;
347 
348  // Get the iterators over the digis associated with this LayerId
349  const CSCComparatorDigiCollection::Range& range = (*CSCComparatorLayerIt).second;
350 
351  OurCSCComparatorDigis_->put(range, layerId);
352 
353  }
354  }
355 
356 
357  }
358 
360 
361  // collections of digis to put in the event
362  std::auto_ptr< DTDigiCollection > DTDigiMerge( new DTDigiCollection );
363  std::auto_ptr< RPCDigiCollection > RPCDigiMerge( new RPCDigiCollection );
364  std::auto_ptr< CSCStripDigiCollection > CSCStripDigiMerge( new CSCStripDigiCollection );
365  std::auto_ptr< CSCWireDigiCollection > CSCWireDigiMerge( new CSCWireDigiCollection );
366  std::auto_ptr< CSCComparatorDigiCollection > CSCComparatorDigiMerge( new CSCComparatorDigiCollection );
367 
368  // Loop over DT digis, copying them from our own local storage
369 
371  for (DLayerIt = OurDTDigis_->begin(); DLayerIt != OurDTDigis_->end(); ++DLayerIt) {
372  // The layerId
373  const DTLayerId& layerId = (*DLayerIt).first;
374 
375  // Get the iterators over the digis associated with this LayerId
376  const DTDigiCollection::Range& range = (*DLayerIt).second;
377 
378  DTDigiMerge->put(range, layerId);
379 
380  }
381 
382  // Loop over RPC digis, copying them from our own local storage
383 
385  for (RLayerIt = OurRPCDigis_->begin(); RLayerIt != OurRPCDigis_->end(); ++RLayerIt) {
386  // The layerId
387  const RPCDetId& layerId = (*RLayerIt).first;
388 
389  // Get the iterators over the digis associated with this LayerId
390  const RPCDigiCollection::Range& range = (*RLayerIt).second;
391 
392  RPCDigiMerge->put(range, layerId);
393 
394  }
395  // Loop over CSCStrip digis, copying them from our own local storage
396 
398  for (CSLayerIt = OurCSCStripDigis_->begin(); CSLayerIt != OurCSCStripDigis_->end(); ++CSLayerIt) {
399  // The layerId
400  const CSCDetId& layerId = (*CSLayerIt).first;
401 
402  // Get the iterators over the digis associated with this LayerId
403  const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
404 
405  CSCStripDigiMerge->put(range, layerId);
406 
407  }
408  // Loop over CSCStrip digis, copying them from our own local storage
409 
411  for (CWLayerIt = OurCSCWireDigis_->begin(); CWLayerIt != OurCSCWireDigis_->end(); ++CWLayerIt) {
412  // The layerId
413  const CSCDetId& layerId = (*CWLayerIt).first;
414 
415  // Get the iterators over the digis associated with this LayerId
416  const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
417 
418  CSCWireDigiMerge->put(range, layerId);
419 
420  }
421 
422  // Loop over CSCComparator digis, copying them from our own local storage
423 
425  for (CCLayerIt = OurCSCComparatorDigis_->begin(); CCLayerIt != OurCSCComparatorDigis_->end(); ++CCLayerIt) {
426  // The layerId
427  const CSCDetId& layerId = (*CCLayerIt).first;
428 
429  // Get the iterators over the digis associated with this LayerId
430  const CSCComparatorDigiCollection::Range& range = (*CCLayerIt).second;
431 
432  CSCComparatorDigiMerge->put(range, layerId);
433 
434  }
435 
436 
437  // put the collection of recunstructed hits in the event
438  // LogDebug("DataMixingMuonWorker") << "total # DT Merged Digis: " << DTDigiMerge->size() ;
439  // LogDebug("DataMixingMuonWorker") << "total # RPC Merged Digis: " << RPCDigiMerge->size() ;
440  // LogDebug("DataMixingMuonWorker") << "total # CSCStrip Merged Digis: " << CSCStripDigiMerge->size() ;
441  // LogDebug("DataMixingMuonWorker") << "total # CSCWire Merged Digis: " << CSCWireDigiMerge->size() ;
442 
443  e.put( DTDigiMerge );
444  e.put( RPCDigiMerge );
445  e.put( CSCStripDigiMerge, CSCStripDigiCollectionDM_ );
446  e.put( CSCWireDigiMerge, CSCWireDigiCollectionDM_ );
447  e.put( CSCComparatorDigiMerge, CSCComparatorDigiCollectionDM_ );
448 
449  // clear local storage for this event
450  delete OurDTDigis_;
451  delete OurRPCDigis_;
452  delete OurCSCStripDigis_;
453  delete OurCSCWireDigis_;
454  delete OurCSCComparatorDigis_;
455 
456  }
457 
458 } //edm
#define LogDebug(id)
T getParameter(std::string const &) const
void addMuonSignals(const edm::Event &e)
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:85
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
RPCDigiCollection * OurRPCDigis_
CSCWireDigiCollection * OurCSCWireDigis_
MuonDigiCollection< CSCDetId, CSCWireDigi > CSCWireDigiCollection
CSCComparatorDigiCollection * OurCSCComparatorDigis_
T const * product() const
Definition: Handle.h:74
void addMuonPileups(const int bcr, const edm::EventPrincipal *, unsigned int EventId)
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_