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 "DataMixingGeneralTrackWorker.h"
00018
00019 using namespace std;
00020
00021 namespace edm
00022 {
00023
00024
00025
00026 DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker() { }
00027
00028
00029 DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker(const edm::ParameterSet& ps)
00030 {
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 GeneralTrackLabelSig_ = ps.getParameter<edm::InputTag>("GeneralTrackLabelSig");
00045
00046 GeneralTrackPileInputTag_ = ps.getParameter<edm::InputTag>("GeneralTrackPileInputTag");
00047
00048 GeneralTrackCollectionDM_ = ps.getParameter<std::string>("GeneralTrackDigiCollectionDM");
00049
00050 }
00051
00052
00053
00054 DataMixingGeneralTrackWorker::~DataMixingGeneralTrackWorker() {
00055 }
00056
00057
00058
00059 void DataMixingGeneralTrackWorker::addGeneralTrackSignals(const edm::Event &e) {
00060
00061
00062
00063 NewTrackList_ = std::auto_ptr<reco::TrackCollection>(new reco::TrackCollection());
00064
00065
00066
00067
00068
00069 edm::Handle<reco::TrackCollection> tracks;
00070 e.getByLabel(GeneralTrackLabelSig_, tracks);
00071
00072 if (tracks.isValid()) {
00073 for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
00074 NewTrackList_->push_back(*track);
00075 }
00076
00077 }
00078
00079 }
00080
00081
00082
00083 void DataMixingGeneralTrackWorker::addGeneralTrackPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr) {
00084 LogDebug("DataMixingGeneralTrackWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
00085
00086
00087 boost::shared_ptr<Wrapper<reco::TrackCollection > const> inputPTR =
00088 getProductByTag<reco::TrackCollection >(*ep, GeneralTrackPileInputTag_ );
00089
00090 if(inputPTR ) {
00091
00092 const reco::TrackCollection *tracks = const_cast< reco::TrackCollection * >(inputPTR->product());
00093
00094
00095
00096
00097 for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
00098 NewTrackList_->push_back(*track);
00099 }
00100
00101 }
00102
00103 }
00104
00105
00106
00107 void DataMixingGeneralTrackWorker::putGeneralTrack(edm::Event &e) {
00108
00109
00110
00111
00112 LogInfo("DataMixingGeneralTrackWorker") << "total # Merged Tracks: " << NewTrackList_->size() ;
00113
00114
00115
00116 e.put( NewTrackList_, GeneralTrackCollectionDM_ );
00117
00118
00119
00120 }
00121
00122 }