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 
7 #include <map>
8 #include <memory>
13 
17 //
18 //
20 
21 using namespace std;
22 
23 namespace edm
24 {
25 
26  // Virtual constructor
27 
28  DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker() { }
29 
30  // Constructor
31  DataMixingGeneralTrackWorker::DataMixingGeneralTrackWorker(const edm::ParameterSet& ps, edm::ConsumesCollector && iC)
32  {
33 
34  // get the subdetector names
35  // this->getSubdetectorNames(); //something like this may be useful to check what we are supposed to do...
36 
37  // declare the products to produce
38 
39  GeneralTrackLabelSig_ = ps.getParameter<edm::InputTag>("GeneralTrackLabelSig");
40 
41  GeneralTrackPileInputTag_ = ps.getParameter<edm::InputTag>("GeneralTrackPileInputTag");
42 
43  GeneralTrackCollectionDM_ = ps.getParameter<std::string>("GeneralTrackDigiCollectionDM");
44 
45  GTrackSigToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackLabelSig_);
46  GTrackPileToken_ = iC.consumes<reco::TrackCollection>(GeneralTrackPileInputTag_);
47 
48  }
49 
50 
51  // Virtual destructor needed.
52  DataMixingGeneralTrackWorker::~DataMixingGeneralTrackWorker() {
53  }
54 
55 
56 
57  void DataMixingGeneralTrackWorker::addGeneralTrackSignals(const edm::Event &e) {
58 
59  // Create new track list; Rely on the fact that addSignals gets called first...
60 
61  NewTrackList_ = std::unique_ptr<reco::TrackCollection>(new reco::TrackCollection());
62 
63  // grab tracks, store copy
64 
65  //edm::Handle<reco::TrackCollection> generalTrkHandle;
66  //e.getByLabel("generalTracks", generalTrkHandle);
68  e.getByToken(GTrackSigToken_, tracks);
69 
70  if (tracks.isValid()) {
71  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
72  NewTrackList_->push_back(*track);
73  }
74 
75  }
76 
77  } // end of addGeneralTrackSignals
78 
79 
80 
81  void DataMixingGeneralTrackWorker::addGeneralTrackPileups(const int bcr, const EventPrincipal *ep, unsigned int eventNr,
82  ModuleCallingContext const* mcc) {
83  LogDebug("DataMixingGeneralTrackWorker") <<"\n===============> adding pileups from event "<<ep->id()<<" for bunchcrossing "<<bcr;
84 
85 
86  std::shared_ptr<Wrapper<reco::TrackCollection > const> inputPTR =
87  getProductByTag<reco::TrackCollection >(*ep, GeneralTrackPileInputTag_, mcc);
88 
89  if(inputPTR ) {
90 
91  const reco::TrackCollection *tracks = const_cast< reco::TrackCollection * >(inputPTR->product());
92 
93  // grab tracks, store copy
94 
95 
96  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
97  NewTrackList_->push_back(*track);
98  }
99 
100  }
101 
102  }
103 
104 
105 
106  void DataMixingGeneralTrackWorker::putGeneralTrack(edm::Event &e) {
107 
108  // collection of Tracks to put in the event
109 
110  // put the collection of digis in the event
111  LogInfo("DataMixingGeneralTrackWorker") << "total # Merged Tracks: " << NewTrackList_->size() ;
112 
113  // put collection
114 
115  e.put(std::move(NewTrackList_), GeneralTrackCollectionDM_);
116 
117  // clear local storage for this event
118  //NewTrackList_.clear();
119  }
120 
121 } //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:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
EventID const & id() const
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
HLT enums.
def move(src, dest)
Definition: eostools.py:510