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