Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <map>
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "FWCore/Utilities/interface/EDMException.h"
00010 #include "FWCore/Framework/interface/ConstProductRegistry.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "DataFormats/Common/interface/Handle.h"
00013 #include "DataFormats/Provenance/interface/Provenance.h"
00014 #include "DataFormats/Provenance/interface/BranchDescription.h"
00015
00016
00017 #include "DataMixingMuonWorker.h"
00018
00019
00020 using namespace std;
00021
00022 namespace edm
00023 {
00024
00025
00026
00027 DataMixingMuonWorker::DataMixingMuonWorker() { sel_=0;}
00028
00029
00030 DataMixingMuonWorker::DataMixingMuonWorker(const edm::ParameterSet& ps) :
00031 label_(ps.getParameter<std::string>("Label"))
00032
00033 {
00034
00035
00036
00037
00038
00039 if (label_.size()>0){
00040 sel_=new Selector( ModuleLabelSelector(label_));
00041 }
00042 else {
00043 sel_=new Selector( MatchAllSelector());
00044 }
00045
00046
00047
00048 DTDigiTagSig_ = ps.getParameter<edm::InputTag>("DTDigiTagSig");
00049 RPCDigiTagSig_ = ps.getParameter<edm::InputTag>("RPCDigiTagSig");
00050
00051 CSCstripdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCstripdigiCollectionSig");
00052 CSCwiredigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCwiredigiCollectionSig");
00053 CSCCompdigi_collectionSig_ = ps.getParameter<edm::InputTag>("CSCCompdigiCollectionSig");
00054
00055 DTPileInputTag_ = ps.getParameter<edm::InputTag>("DTPileInputTag");
00056 RPCPileInputTag_ = ps.getParameter<edm::InputTag>("RPCPileInputTag");
00057 CSCWirePileInputTag_ = ps.getParameter<edm::InputTag>("CSCWirePileInputTag");
00058 CSCStripPileInputTag_ = ps.getParameter<edm::InputTag>("CSCStripPileInputTag");
00059 CSCCompPileInputTag_ = ps.getParameter<edm::InputTag>("CSCCompPileInputTag");
00060
00061
00062
00063 DTDigiCollectionDM_ = ps.getParameter<std::string>("DTDigiCollectionDM");
00064 RPCDigiCollectionDM_ = ps.getParameter<std::string>("RPCDigiCollectionDM");
00065 CSCStripDigiCollectionDM_ = ps.getParameter<std::string>("CSCStripDigiCollectionDM");
00066 CSCWireDigiCollectionDM_ = ps.getParameter<std::string>("CSCWireDigiCollectionDM");
00067 CSCComparatorDigiCollectionDM_ = ps.getParameter<std::string>("CSCComparatorDigiCollectionDM");
00068
00069
00070 }
00071
00072
00073
00074 DataMixingMuonWorker::~DataMixingMuonWorker() {
00075 delete sel_;
00076 sel_=0;
00077 }
00078
00079 void DataMixingMuonWorker::addMuonSignals(const edm::Event &e) {
00080
00081
00082 LogDebug("DataMixingMuonWorker")<<"===============> adding MC signals for "<<e.id();
00083
00084
00085
00086
00087 OurDTDigis_ = new DTDigiCollection();
00088 Handle<DTDigiCollection> pDTdigis;
00089
00090
00091 if( e.getByLabel(DTDigiTagSig_, pDTdigis) ) {
00092
00093
00094
00095
00096 const DTDigiCollection* DTdigis = pDTdigis.product();
00097 DTDigiCollection::DigiRangeIterator DLayerIt;
00098 for (DLayerIt = DTdigis->begin(); DLayerIt != DTdigis->end(); ++DLayerIt) {
00099
00100 const DTLayerId& layerId = (*DLayerIt).first;
00101
00102
00103 const DTDigiCollection::Range& range = (*DLayerIt).second;
00104
00105 OurDTDigis_->put(range, layerId);
00106 }
00107 }
00108
00109
00110
00111 OurRPCDigis_ = new RPCDigiCollection();
00112
00113
00114 Handle<RPCDigiCollection> pRPCdigis;
00115
00116 if( e.getByLabel(RPCDigiTagSig_, pRPCdigis) ) {
00117
00118
00119
00120 const RPCDigiCollection* RPCdigis = pRPCdigis.product();
00121 RPCDigiCollection::DigiRangeIterator RLayerIt;
00122 for (RLayerIt = RPCdigis->begin(); RLayerIt != RPCdigis->end(); ++RLayerIt) {
00123
00124 const RPCDetId& layerId = (*RLayerIt).first;
00125
00126
00127 const RPCDigiCollection::Range& range = (*RLayerIt).second;
00128
00129 OurRPCDigis_->put(range, layerId);
00130
00131 }
00132 }
00133
00134
00135
00136 OurCSCStripDigis_ = new CSCStripDigiCollection();
00137
00138
00139 Handle<CSCStripDigiCollection> pCSCStripdigis;
00140
00141 if( e.getByLabel(CSCstripdigi_collectionSig_, pCSCStripdigis) ) {
00142
00143
00144
00145
00146
00147
00148
00149 const CSCStripDigiCollection* CSCStripdigis = pCSCStripdigis.product();
00150 CSCStripDigiCollection::DigiRangeIterator CSLayerIt;
00151 for (CSLayerIt = CSCStripdigis->begin(); CSLayerIt != CSCStripdigis->end(); ++CSLayerIt) {
00152
00153 const CSCDetId& layerId = (*CSLayerIt).first;
00154
00155
00156 const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
00157
00158 OurCSCStripDigis_->put(range, layerId);
00159 }
00160 }
00161
00162
00163
00164 OurCSCWireDigis_ = new CSCWireDigiCollection();
00165
00166
00167 Handle<CSCWireDigiCollection> pCSCWiredigis;
00168
00169 if( e.getByLabel(CSCwiredigi_collectionSig_, pCSCWiredigis) ) {
00170
00171
00172
00173
00174
00175
00176
00177 const CSCWireDigiCollection* CSCWiredigis = pCSCWiredigis.product();
00178 CSCWireDigiCollection::DigiRangeIterator CWLayerIt;
00179 for (CWLayerIt = CSCWiredigis->begin(); CWLayerIt != CSCWiredigis->end(); ++CWLayerIt) {
00180
00181 const CSCDetId& layerId = (*CWLayerIt).first;
00182
00183
00184 const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
00185
00186 OurCSCWireDigis_->put(range, layerId);
00187
00188 }
00189 }
00190
00191
00192
00193
00194 OurCSCComparatorDigis_ = new CSCComparatorDigiCollection();
00195
00196
00197 Handle<CSCComparatorDigiCollection> pCSCComparatordigis;
00198
00199
00200
00201 if( e.getByLabel(CSCCompdigi_collectionSig_, pCSCComparatordigis) ) {
00202
00203
00204
00205
00206
00207
00208
00209 const CSCComparatorDigiCollection* CSCComparatordigis = pCSCComparatordigis.product();
00210 CSCComparatorDigiCollection::DigiRangeIterator CWLayerIt;
00211 for (CWLayerIt = CSCComparatordigis->begin(); CWLayerIt != CSCComparatordigis->end(); ++CWLayerIt) {
00212
00213 const CSCDetId& layerId = (*CWLayerIt).first;
00214
00215
00216 const CSCComparatorDigiCollection::Range& range = (*CWLayerIt).second;
00217
00218 OurCSCComparatorDigis_->put(range, layerId);
00219
00220 }
00221 }
00222
00223
00224 }
00225
00226 void DataMixingMuonWorker::addMuonPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr) {
00227
00228 LogDebug("DataMixingMuonWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
00229
00230
00231
00232
00233
00234
00235
00236 boost::shared_ptr<Wrapper<DTDigiCollection> const> DTDigisPTR =
00237 getProductByTag<DTDigiCollection>(*ep, DTPileInputTag_ );
00238
00239 if(DTDigisPTR ) {
00240
00241 const DTDigiCollection* DTDigis = const_cast< DTDigiCollection * >(DTDigisPTR->product());
00242
00243 DTDigiCollection::DigiRangeIterator DTLayerIt;
00244 for (DTLayerIt = DTDigis->begin(); DTLayerIt != DTDigis->end(); ++DTLayerIt) {
00245
00246 const DTLayerId& layerId = (*DTLayerIt).first;
00247
00248
00249 const DTDigiCollection::Range& range = (*DTLayerIt).second;
00250
00251 OurDTDigis_->put(range, layerId);
00252
00253 }
00254 }
00255
00256
00257
00258
00259
00260
00261 boost::shared_ptr<Wrapper<RPCDigiCollection> const> RPCDigisPTR =
00262 getProductByTag<RPCDigiCollection>(*ep, RPCPileInputTag_ );
00263
00264 if(RPCDigisPTR ) {
00265
00266 const RPCDigiCollection* RPCDigis = const_cast< RPCDigiCollection * >(RPCDigisPTR->product());
00267
00268 RPCDigiCollection::DigiRangeIterator RPCLayerIt;
00269 for (RPCLayerIt = RPCDigis->begin(); RPCLayerIt != RPCDigis->end(); ++RPCLayerIt) {
00270
00271 const RPCDetId& layerId = (*RPCLayerIt).first;
00272
00273
00274 const RPCDigiCollection::Range& range = (*RPCLayerIt).second;
00275
00276 OurRPCDigis_->put(range, layerId);
00277
00278 }
00279 }
00280
00281
00282
00283
00284
00285
00286 boost::shared_ptr<Wrapper<CSCStripDigiCollection> const> CSCStripDigisPTR =
00287 getProductByTag<CSCStripDigiCollection>(*ep, CSCStripPileInputTag_ );
00288
00289 if(CSCStripDigisPTR ) {
00290
00291 const CSCStripDigiCollection* CSCStripDigis = const_cast< CSCStripDigiCollection * >(CSCStripDigisPTR->product());
00292
00293 CSCStripDigiCollection::DigiRangeIterator CSCStripLayerIt;
00294 for (CSCStripLayerIt = CSCStripDigis->begin(); CSCStripLayerIt != CSCStripDigis->end(); ++CSCStripLayerIt) {
00295
00296 const CSCDetId& layerId = (*CSCStripLayerIt).first;
00297
00298
00299 const CSCStripDigiCollection::Range& range = (*CSCStripLayerIt).second;
00300
00301 OurCSCStripDigis_->put(range, layerId);
00302
00303 }
00304 }
00305
00306
00307
00308
00309
00310
00311 boost::shared_ptr<Wrapper<CSCWireDigiCollection> const> CSCWireDigisPTR =
00312 getProductByTag<CSCWireDigiCollection>(*ep, CSCWirePileInputTag_ );
00313
00314 if(CSCWireDigisPTR ) {
00315
00316 const CSCWireDigiCollection* CSCWireDigis = const_cast< CSCWireDigiCollection * >(CSCWireDigisPTR->product());
00317
00318 CSCWireDigiCollection::DigiRangeIterator CSCWireLayerIt;
00319 for (CSCWireLayerIt = CSCWireDigis->begin(); CSCWireLayerIt != CSCWireDigis->end(); ++CSCWireLayerIt) {
00320
00321 const CSCDetId& layerId = (*CSCWireLayerIt).first;
00322
00323
00324 const CSCWireDigiCollection::Range& range = (*CSCWireLayerIt).second;
00325
00326 OurCSCWireDigis_->put(range, layerId);
00327
00328 }
00329 }
00330
00331
00332
00333
00334
00335
00336 boost::shared_ptr<Wrapper<CSCComparatorDigiCollection> const> CSCComparatorDigisPTR =
00337 getProductByTag<CSCComparatorDigiCollection>(*ep, CSCCompPileInputTag_ );
00338
00339 if(CSCComparatorDigisPTR ) {
00340
00341 const CSCComparatorDigiCollection* CSCComparatorDigis = const_cast< CSCComparatorDigiCollection * >(CSCComparatorDigisPTR->product());
00342
00343 CSCComparatorDigiCollection::DigiRangeIterator CSCComparatorLayerIt;
00344 for (CSCComparatorLayerIt = CSCComparatorDigis->begin(); CSCComparatorLayerIt != CSCComparatorDigis->end(); ++CSCComparatorLayerIt) {
00345
00346 const CSCDetId& layerId = (*CSCComparatorLayerIt).first;
00347
00348
00349 const CSCComparatorDigiCollection::Range& range = (*CSCComparatorLayerIt).second;
00350
00351 OurCSCComparatorDigis_->put(range, layerId);
00352
00353 }
00354 }
00355
00356
00357 }
00358
00359 void DataMixingMuonWorker::putMuon(edm::Event &e) {
00360
00361
00362 std::auto_ptr< DTDigiCollection > DTDigiMerge( new DTDigiCollection );
00363 std::auto_ptr< RPCDigiCollection > RPCDigiMerge( new RPCDigiCollection );
00364 std::auto_ptr< CSCStripDigiCollection > CSCStripDigiMerge( new CSCStripDigiCollection );
00365 std::auto_ptr< CSCWireDigiCollection > CSCWireDigiMerge( new CSCWireDigiCollection );
00366 std::auto_ptr< CSCComparatorDigiCollection > CSCComparatorDigiMerge( new CSCComparatorDigiCollection );
00367
00368
00369
00370 DTDigiCollection::DigiRangeIterator DLayerIt;
00371 for (DLayerIt = OurDTDigis_->begin(); DLayerIt != OurDTDigis_->end(); ++DLayerIt) {
00372
00373 const DTLayerId& layerId = (*DLayerIt).first;
00374
00375
00376 const DTDigiCollection::Range& range = (*DLayerIt).second;
00377
00378 DTDigiMerge->put(range, layerId);
00379
00380 }
00381
00382
00383
00384 RPCDigiCollection::DigiRangeIterator RLayerIt;
00385 for (RLayerIt = OurRPCDigis_->begin(); RLayerIt != OurRPCDigis_->end(); ++RLayerIt) {
00386
00387 const RPCDetId& layerId = (*RLayerIt).first;
00388
00389
00390 const RPCDigiCollection::Range& range = (*RLayerIt).second;
00391
00392 RPCDigiMerge->put(range, layerId);
00393
00394 }
00395
00396
00397 CSCStripDigiCollection::DigiRangeIterator CSLayerIt;
00398 for (CSLayerIt = OurCSCStripDigis_->begin(); CSLayerIt != OurCSCStripDigis_->end(); ++CSLayerIt) {
00399
00400 const CSCDetId& layerId = (*CSLayerIt).first;
00401
00402
00403 const CSCStripDigiCollection::Range& range = (*CSLayerIt).second;
00404
00405 CSCStripDigiMerge->put(range, layerId);
00406
00407 }
00408
00409
00410 CSCWireDigiCollection::DigiRangeIterator CWLayerIt;
00411 for (CWLayerIt = OurCSCWireDigis_->begin(); CWLayerIt != OurCSCWireDigis_->end(); ++CWLayerIt) {
00412
00413 const CSCDetId& layerId = (*CWLayerIt).first;
00414
00415
00416 const CSCWireDigiCollection::Range& range = (*CWLayerIt).second;
00417
00418 CSCWireDigiMerge->put(range, layerId);
00419
00420 }
00421
00422
00423
00424 CSCComparatorDigiCollection::DigiRangeIterator CCLayerIt;
00425 for (CCLayerIt = OurCSCComparatorDigis_->begin(); CCLayerIt != OurCSCComparatorDigis_->end(); ++CCLayerIt) {
00426
00427 const CSCDetId& layerId = (*CCLayerIt).first;
00428
00429
00430 const CSCComparatorDigiCollection::Range& range = (*CCLayerIt).second;
00431
00432 CSCComparatorDigiMerge->put(range, layerId);
00433
00434 }
00435
00436
00437
00438
00439
00440
00441
00442
00443 e.put( DTDigiMerge );
00444 e.put( RPCDigiMerge );
00445 e.put( CSCStripDigiMerge, CSCStripDigiCollectionDM_ );
00446 e.put( CSCWireDigiMerge, CSCWireDigiCollectionDM_ );
00447 e.put( CSCComparatorDigiMerge, CSCComparatorDigiCollectionDM_ );
00448
00449
00450 delete OurDTDigis_;
00451 delete OurRPCDigis_;
00452 delete OurCSCStripDigis_;
00453 delete OurCSCWireDigis_;
00454 delete OurCSCComparatorDigis_;
00455
00456 }
00457
00458 }