test
CMS 3D CMS Logo

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