File indexing completed on 2024-04-06 12:30:32
0001
0002
0003
0004
0005
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include <map>
0009 #include <memory>
0010
0011 #include "DataFormats/Common/interface/Handle.h"
0012
0013
0014 #include "DataMixingGeneralTrackWorker.h"
0015
0016 using namespace std;
0017
0018 namespace edm {
0019
0020
0021
0022 DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker() {}
0023
0024
0025 DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC) {
0026
0027
0028
0029
0030
0031
0032 GeneralTrackLabelSig_ = ps.getParameter<edm::InputTag>("GeneralTrackLabelSig");
0033
0034 GeneralTrackPileInputTag_ = ps.getParameter<edm::InputTag>("GeneralTrackPileInputTag");
0035
0036 GeneralTrackCollectionDM_ = ps.getParameter<std::string>("GeneralTrackDigiCollectionDM");
0037
0038 GTrackSigToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackLabelSig_);
0039 GTrackPileToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackPileInputTag_);
0040 }
0041
0042
0043 DataMixingGeneralTrackWorker::~DataMixingGeneralTrackWorker() {}
0044
0045 void DataMixingGeneralTrackWorker::addGeneralTrackSignals(const edm::Event &e) {
0046
0047
0048
0049 NewTrackList_ = std::make_unique<reco::TrackCollection>();
0050
0051
0052
0053
0054
0055 edm::Handle<reco::TrackCollection> tracks;
0056 e.getByToken(GTrackSigToken_, tracks);
0057
0058 if (tracks.isValid()) {
0059 for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
0060 NewTrackList_->push_back(*track);
0061 }
0062 }
0063
0064 }
0065
0066 void DataMixingGeneralTrackWorker::addGeneralTrackPileups(const int bcr,
0067 const EventPrincipal *ep,
0068 unsigned int eventNr,
0069 ModuleCallingContext const *mcc) {
0070 LogDebug("DataMixingGeneralTrackWorker")
0071 << "\n===============> adding pileups from event " << ep->id() << " for bunchcrossing " << bcr;
0072
0073 std::shared_ptr<Wrapper<reco::TrackCollection> const> inputPTR =
0074 getProductByTag<reco::TrackCollection>(*ep, GeneralTrackPileInputTag_, mcc);
0075
0076 if (inputPTR) {
0077 const reco::TrackCollection *tracks = const_cast<reco::TrackCollection *>(inputPTR->product());
0078
0079
0080
0081 for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
0082 NewTrackList_->push_back(*track);
0083 }
0084 }
0085 }
0086
0087 void DataMixingGeneralTrackWorker::putGeneralTrack(edm::Event &e) {
0088
0089
0090
0091 LogInfo("DataMixingGeneralTrackWorker") << "total # Merged Tracks: " << NewTrackList_->size();
0092
0093
0094
0095 e.put(std::move(NewTrackList_), GeneralTrackCollectionDM_);
0096
0097
0098
0099 }
0100
0101 }