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::make_unique<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
Handle.h
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11724
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
DataMixingGeneralTrackWorker.h
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle< reco::TrackCollection >
edm::EventPrincipal
Definition: EventPrincipal.h:48
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:176
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::Event
Definition: Event.h:73
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition: SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29