CMS 3D CMS Logo

TrackCollectionCloner.h
Go to the documentation of this file.
1 #ifndef RecoTracker_FinalTrackSelectors_TrackCollectionCloner_H
2 #define RecoTracker_FinalTrackSelectors_TrackCollectionCloner_H
3 /*
4  *
5  * selects a subset of a track collection, copying extra information on demand
6  * to be used moslty as an helper in the produce method of selectors
7  *
8  * \author Giovanni Petrucciani
9  *
10  *
11  *
12  */
13 
14 #include <utility>
15 #include <memory>
16 #include <algorithm>
20 
24 
26 public:
31 
33 
34  TrackCollectionCloner(edm::ProducesCollector producesCollector, const edm::ParameterSet& cfg, bool copyDefault)
35  : copyExtras_(cfg.template getUntrackedParameter<bool>("copyExtras", copyDefault)),
36  copyTrajectories_(cfg.template getUntrackedParameter<bool>("copyTrajectories", copyDefault)) {
37  std::string alias(cfg.getParameter<std::string>("@module_label"));
38  producesCollector.produces<reco::TrackCollection>().setBranchAlias(alias + "Tracks");
39  if (copyExtras_) {
40  producesCollector.produces<reco::TrackExtraCollection>().setBranchAlias(alias + "TrackExtras");
41  producesCollector.produces<TrackingRecHitCollection>().setBranchAlias(alias + "RecHits");
42  }
43  if (copyTrajectories_) {
44  producesCollector.produces<std::vector<Trajectory> >().setBranchAlias(alias + "Trajectories");
45  producesCollector.produces<TrajTrackAssociationCollection>().setBranchAlias(alias +
46  "TrajectoryTrackAssociations");
47  }
48  }
49 
50  static void fill(edm::ParameterSetDescription& desc);
51 
52  struct Producer {
53  Producer(edm::Event& ievt, TrackCollectionCloner const& cloner);
54 
55  ~Producer();
56 
57  void operator()(Tokens const& tokens, std::vector<unsigned int> const& selected);
58 
63 
66  // some space
67  std::unique_ptr<reco::TrackCollection> selTracks_;
68  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
69  std::unique_ptr<TrackingRecHitCollection> selHits_;
70  std::unique_ptr<std::vector<Trajectory> > selTrajs_;
71  std::unique_ptr<TrajTrackAssociationCollection> selTTAss_;
72  };
73 };
74 
75 #endif
TrackCollectionTokens
Definition: TrackCollectionTokens.h:13
TrackExtra.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
TrackCollectionCloner::Producer
Definition: TrackCollectionCloner.h:52
TrackCollectionCloner::Producer::selTrajs_
std::unique_ptr< std::vector< Trajectory > > selTrajs_
Definition: TrackCollectionCloner.h:70
TrackCollectionCloner::Producer::selTrackExtras_
std::unique_ptr< reco::TrackExtraCollection > selTrackExtras_
Definition: TrackCollectionCloner.h:68
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ProducesCollector.h
TrackCollectionCloner::Producer::selTracks_
std::unique_ptr< reco::TrackCollection > selTracks_
Definition: TrackCollectionCloner.h:67
TrackCollectionCloner
Definition: TrackCollectionCloner.h:25
Track.h
reco::TrackExtraCollection
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
TrackCollectionCloner::copyExtras_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
Definition: TrackCollectionCloner.h:28
ParameterSetDescription.h
TrackCollectionCloner::fill
static void fill(edm::ParameterSetDescription &desc)
Definition: TrackCollectionCloner.cc:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackCollectionCloner::Producer::selHits_
std::unique_ptr< TrackingRecHitCollection > selHits_
Definition: TrackCollectionCloner.h:69
edm::ParameterSet
Definition: ParameterSet.h:36
TrackCollectionCloner::Producer::evt
edm::Event & evt
the event
Definition: TrackCollectionCloner.h:65
edm::AssociationMap< edm::OneToOne< std::vector< Trajectory >, reco::TrackCollection, unsigned short > >
TrackCollectionCloner::Producer::copyTrajectories_
bool copyTrajectories_
copy also trajectories and trajectory->track associations
Definition: TrackCollectionCloner.h:62
TrackCollectionCloner::Producer::copyExtras_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
Definition: TrackCollectionCloner.h:60
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
looper.cfg
cfg
Definition: looper.py:297
edm::ProducesCollector
Definition: ProducesCollector.h:43
TrackCollectionTokens.h
SiStripOfflineCRack_cfg.alias
alias
Definition: SiStripOfflineCRack_cfg.py:129
TrackCollectionCloner::copyTrajectories_
bool copyTrajectories_
copy also trajectories and trajectory->track associations
Definition: TrackCollectionCloner.h:30
ParameterSet.h
edm::Event
Definition: Event.h:73
TrackCollectionCloner::Producer::operator()
void operator()(Tokens const &tokens, std::vector< unsigned int > const &selected)
process one event
Definition: TrackCollectionCloner.cc:23
TrackCollectionCloner::Producer::selTTAss_
std::unique_ptr< TrajTrackAssociationCollection > selTTAss_
Definition: TrackCollectionCloner.h:71
TrackCollectionCloner::Producer::~Producer
~Producer()
Definition: TrackCollectionCloner.cc:84
TrackCollectionCloner::Producer::Producer
Producer(edm::Event &ievt, TrackCollectionCloner const &cloner)
Definition: TrackCollectionCloner.cc:8
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::OwnVector< TrackingRecHit >
TrackCollectionCloner::TrackCollectionCloner
TrackCollectionCloner(edm::ProducesCollector producesCollector, const edm::ParameterSet &cfg, bool copyDefault)
Definition: TrackCollectionCloner.h:34