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