CMS 3D CMS Logo

DataMixingGeneralTrackWorker.cc
Go to the documentation of this file.
1 // File: DataMixingGeneralTrackWorker.cc
2 // Description: see DataMixingGeneralTrackWorker.h
3 // Author: Mike Hildreth, University of Notre Dame
4 //
5 //--------------------------------------------
6 
8 #include <map>
9 #include <memory>
10 
12 //
13 //
15 
16 using namespace std;
17 
18 namespace edm {
19 
20  // Virtual constructor
21 
22  DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker() {}
23 
24  // Constructor
25  DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker(const edm::ParameterSet &ps, edm::ConsumesCollector &&iC) {
26  // get the subdetector names
27  // this->getSubdetectorNames(); //something like this may be useful to
28  // check what we are supposed to do...
29 
30  // declare the products to produce
31 
32  GeneralTrackLabelSig_ = ps.getParameter<edm::InputTag>("GeneralTrackLabelSig");
33 
34  GeneralTrackPileInputTag_ = ps.getParameter<edm::InputTag>("GeneralTrackPileInputTag");
35 
36  GeneralTrackCollectionDM_ = ps.getParameter<std::string>("GeneralTrackDigiCollectionDM");
37 
38  GTrackSigToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackLabelSig_);
39  GTrackPileToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackPileInputTag_);
40  }
41 
42  // Virtual destructor needed.
43  DataMixingGeneralTrackWorker::~DataMixingGeneralTrackWorker() {}
44 
45  void DataMixingGeneralTrackWorker::addGeneralTrackSignals(const edm::Event &e) {
46  // Create new track list; Rely on the fact that addSignals gets called
47  // first...
48 
49  NewTrackList_ = std::unique_ptr<reco::TrackCollection>(new reco::TrackCollection());
50 
51  // grab tracks, store copy
52 
53  // edm::Handle<reco::TrackCollection> generalTrkHandle;
54  // e.getByLabel("generalTracks", generalTrkHandle);
56  e.getByToken(GTrackSigToken_, tracks);
57 
58  if (tracks.isValid()) {
59  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
60  NewTrackList_->push_back(*track);
61  }
62  }
63 
64  } // end of addGeneralTrackSignals
65 
66  void DataMixingGeneralTrackWorker::addGeneralTrackPileups(const int bcr,
67  const EventPrincipal *ep,
68  unsigned int eventNr,
69  ModuleCallingContext const *mcc) {
70  LogDebug("DataMixingGeneralTrackWorker")
71  << "\n===============> adding pileups from event " << ep->id() << " for bunchcrossing " << bcr;
72 
73  std::shared_ptr<Wrapper<reco::TrackCollection> const> inputPTR =
74  getProductByTag<reco::TrackCollection>(*ep, GeneralTrackPileInputTag_, mcc);
75 
76  if (inputPTR) {
77  const reco::TrackCollection *tracks = const_cast<reco::TrackCollection *>(inputPTR->product());
78 
79  // grab tracks, store copy
80 
81  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
82  NewTrackList_->push_back(*track);
83  }
84  }
85  }
86 
87  void DataMixingGeneralTrackWorker::putGeneralTrack(edm::Event &e) {
88  // collection of Tracks to put in the event
89 
90  // put the collection of digis in the event
91  LogInfo("DataMixingGeneralTrackWorker") << "total # Merged Tracks: " << NewTrackList_->size();
92 
93  // put collection
94 
95  e.put(std::move(NewTrackList_), GeneralTrackCollectionDM_);
96 
97  // clear local storage for this event
98  // NewTrackList_.clear();
99  }
100 
101 } // namespace edm
#define LogDebug(id)
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
EventID const & id() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:15
HLT enums.
def move(src, dest)
Definition: eostools.py:511