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 
218  LogDebug("DataMixingMuonWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
219 
220  // fill in maps of hits; same code as addSignals, except now applied to the pileup events
221 
222  // DT
223  //
224  // Get the digis from the event
225 
226  boost::shared_ptr<Wrapper<DTDigiCollection> const> DTDigisPTR =
227  getProductByTag<DTDigiCollection>(*ep, DTPileInputTag_ );
228 
229  if(DTDigisPTR ) {
230 
231  const DTDigiCollection* DTDigis = const_cast< DTDigiCollection * >(DTDigisPTR->product());
232 
234  for (DTLayerIt = DTDigis->begin(); DTLayerIt != DTDigis->end(); ++DTLayerIt) {
235  // The layerId
236  const DTLayerId& layerId = (*DTLayerIt).first;
237 
238  // Get the iterators over the Digis associated with this LayerId
239  const DTDigiCollection::Range& range = (*DTLayerIt).second;
240 
241  OurDTDigis_->put(range, layerId);
242 
243  }
244  }
245  // RPC
246  //
247 
248  // Get the digis from the event
249 
250 
251  boost::shared_ptr<Wrapper<RPCDigiCollection> const> RPCDigisPTR =
252  getProductByTag<RPCDigiCollection>(*ep, RPCPileInputTag_ );
253 
254  if(RPCDigisPTR ) {
255 
256  const RPCDigiCollection* RPCDigis = const_cast< RPCDigiCollection * >(RPCDigisPTR->product());
257 
259  for (RPCLayerIt = RPCDigis->begin(); RPCLayerIt != RPCDigis->end(); ++RPCLayerIt) {
260  // The layerId
261  const RPCDetId& layerId = (*RPCLayerIt).first;
262 
263  // Get the iterators over the digis associated with this LayerId
264  const RPCDigiCollection::Range& range = (*RPCLayerIt).second;
265 
266  OurRPCDigis_->put(range, layerId);
267 
268  }
269  }
270 
271  // CSCStrip
272  //
273 
274  // Get the digis from the event
275 
276  boost::shared_ptr<Wrapper<CSCStripDigiCollection> const> CSCStripDigisPTR =
277  getProductByTag<CSCStripDigiCollection>(*ep, CSCStripPileInputTag_ );
278 
279  if(CSCStripDigisPTR ) {
280 
281  const CSCStripDigiCollection* CSCStripDigis = const_cast< CSCStripDigiCollection * >(CSCStripDigisPTR->product());
282 
284  for (CSCStripLayerIt = CSCStripDigis->begin(); CSCStripLayerIt != CSCStripDigis->end(); ++CSCStripLayerIt) {
285  // The layerId
286  const CSCDetId& layerId = (*CSCStripLayerIt).first;
287 
288  // Get the iterators over the digis associated with this LayerId
289  const CSCStripDigiCollection::Range& range = (*CSCStripLayerIt).second;
290 
291  OurCSCStripDigis_->put(range, layerId);
292 
293  }
294  }
295 
296  // CSCWire
297  //
298 
299  // Get the digis from the event
300 
301  boost::shared_ptr<Wrapper<CSCWireDigiCollection> const> CSCWireDigisPTR =
302  getProductByTag<CSCWireDigiCollection>(*ep, CSCWirePileInputTag_ );
303 
304  if(CSCWireDigisPTR ) {
305 
306  const CSCWireDigiCollection* CSCWireDigis = const_cast< CSCWireDigiCollection * >(CSCWireDigisPTR->product());
307 
309  for (CSCWireLayerIt = CSCWireDigis->begin(); CSCWireLayerIt != CSCWireDigis->end(); ++CSCWireLayerIt) {
310  // The layerId
311  const CSCDetId& layerId = (*CSCWireLayerIt).first;
312 
313  // Get the iterators over the digis associated with this LayerId
314  const CSCWireDigiCollection::Range& range = (*CSCWireLayerIt).second;
315 
316  OurCSCWireDigis_->put(range, layerId);
317 
318  }
319  }
320 
321  // CSCComparators
322  //
323 
324  // Get the digis from the event
325 
326  boost::shared_ptr<Wrapper<CSCComparatorDigiCollection> const> CSCComparatorDigisPTR =
327  getProductByTag<CSCComparatorDigiCollection>(*ep, CSCCompPileInputTag_ );
328 
329  if(CSCComparatorDigisPTR ) {
330 
331  const CSCComparatorDigiCollection* CSCComparatorDigis = const_cast< CSCComparatorDigiCollection * >(CSCComparatorDigisPTR->product());
332 
334  for (CSCComparatorLayerIt = CSCComparatorDigis->begin(); CSCComparatorLayerIt != CSCComparatorDigis->end(); ++CSCComparatorLayerIt) {
335  // The layerId
336  const CSCDetId& layerId = (*CSCComparatorLayerIt).first;
337 
338  // Get the iterators over the digis associated with this LayerId
339  const CSCComparatorDigiCollection::Range& range = (*CSCComparatorLayerIt).second;
340 
341  OurCSCComparatorDigis_->put(range, layerId);
342 
343  }
344  }
345 
346 
347  }
348 
350 
351  // collections of digis to put in the event
352  std::auto_ptr< DTDigiCollection > DTDigiMerge( new DTDigiCollection );
353  std::auto_ptr< RPCDigiCollection > RPCDigiMerge( new RPCDigiCollection );
354  std::auto_ptr< CSCStripDigiCollection > CSCStripDigiMerge( new CSCStripDigiCollection );
355  std::auto_ptr< CSCWireDigiCollection > CSCWireDigiMerge( new CSCWireDigiCollection );
356  std::auto_ptr< CSCComparatorDigiCollection > CSCComparatorDigiMerge( new CSCComparatorDigiCollection );
357 
358  // Loop over DT digis, copying them from our own local storage
359 
361  for (DLayerIt = OurDTDigis_->begin(); DLayerIt != OurDTDigis_->end(); ++DLayerIt) {
362  // The layerId
363  const DTLayerId& layerId = (*DLayerIt).first;
364 
365  // Get the iterators over the digis associated with this LayerId
366  const DTDigiCollection::Range& range = (*DLayerIt).second;
367 
368  DTDigiMerge->put(range, layerId);
369 
370  }
371 
372  // Loop over RPC digis, copying them from our own local storage
373 
375  for (RLayerIt = OurRPCDigis_->begin(); RLayerIt != OurRPCDigis_->end(); ++RLayerIt) {
376  // The layerId
377  const RPCDetId& layerId = (*RLayerIt).first;
378 
379  // Get the iterators over the digis associated with this LayerId
380  const RPCDigiCollection::Range& range = (*RLayerIt).second;
381 
382  RPCDigiMerge->put(range, layerId);
383 
384  }
385  // Loop over CSCStrip digis, copying them from our own local storage
386 
388  for (CSLayerIt = OurCSCStripDigis_->begin(); CSLayerIt != OurCSCStripDigis_->end(); ++CSLayerIt) {
389  // The layerId
390  const CSCDetId& layerId = (*CSLayerIt).first;
391 
392  // Get the iterators over the digis associated with this LayerId
393  const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
394 
395  CSCStripDigiMerge->put(range, layerId);
396 
397  }
398  // Loop over CSCStrip digis, copying them from our own local storage
399 
401  for (CWLayerIt = OurCSCWireDigis_->begin(); CWLayerIt != OurCSCWireDigis_->end(); ++CWLayerIt) {
402  // The layerId
403  const CSCDetId& layerId = (*CWLayerIt).first;
404 
405  // Get the iterators over the digis associated with this LayerId
406  const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
407 
408  CSCWireDigiMerge->put(range, layerId);
409 
410  }
411 
412  // Loop over CSCComparator digis, copying them from our own local storage
413 
415  for (CCLayerIt = OurCSCComparatorDigis_->begin(); CCLayerIt != OurCSCComparatorDigis_->end(); ++CCLayerIt) {
416  // The layerId
417  const CSCDetId& layerId = (*CCLayerIt).first;
418 
419  // Get the iterators over the digis associated with this LayerId
420  const CSCComparatorDigiCollection::Range& range = (*CCLayerIt).second;
421 
422  CSCComparatorDigiMerge->put(range, layerId);
423 
424  }
425 
426 
427  // put the collection of recunstructed hits in the event
428  // LogDebug("DataMixingMuonWorker") << "total # DT Merged Digis: " << DTDigiMerge->size() ;
429  // LogDebug("DataMixingMuonWorker") << "total # RPC Merged Digis: " << RPCDigiMerge->size() ;
430  // LogDebug("DataMixingMuonWorker") << "total # CSCStrip Merged Digis: " << CSCStripDigiMerge->size() ;
431  // LogDebug("DataMixingMuonWorker") << "total # CSCWire Merged Digis: " << CSCWireDigiMerge->size() ;
432 
433  e.put( DTDigiMerge );
434  e.put( RPCDigiMerge );
435  e.put( CSCStripDigiMerge, CSCStripDigiCollectionDM_ );
436  e.put( CSCWireDigiMerge, CSCWireDigiCollectionDM_ );
437  e.put( CSCComparatorDigiMerge, CSCComparatorDigiCollectionDM_ );
438 
439  // clear local storage for this event
440  delete OurDTDigis_;
441  delete OurRPCDigis_;
442  delete OurCSCStripDigis_;
443  delete OurCSCWireDigis_;
444  delete OurCSCComparatorDigis_;
445 
446  }
447 
448 } //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:94
MuonDigiCollection< RPCDetId, RPCDigi > RPCDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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_