CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
18 
22 
23 
24 
26 public:
27 
32 
33 
35 
36 
37  template<typename Producer>
38  TrackCollectionCloner(Producer & producer, const edm::ParameterSet & cfg, bool copyDefault ) :
39  copyExtras_(cfg.template getUntrackedParameter<bool>("copyExtras", copyDefault)),
40  copyTrajectories_(cfg.template getUntrackedParameter<bool>("copyTrajectories", copyDefault)) {
41  std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
42  producer.template produces<reco::TrackCollection>().setBranchAlias( alias + "Tracks" );
43  if (copyExtras_) {
44  producer.template produces<reco::TrackExtraCollection>().setBranchAlias( alias + "TrackExtras" );
45  producer.template produces<TrackingRecHitCollection>().setBranchAlias( alias + "RecHits" );
46  }
47  if (copyTrajectories_) {
48  producer.template produces< std::vector<Trajectory> >().setBranchAlias( alias + "Trajectories" );
49  producer.template produces< TrajTrackAssociationCollection >().setBranchAlias( alias + "TrajectoryTrackAssociations" );
50  }
51  }
52 
53  struct Producer {
54  Producer(edm::Event& ievt, TrackCollectionCloner const & cloner);
55 
56  ~Producer();
57 
58  void operator()(Tokens const & tokens, std::vector<unsigned int> const & selected);
59 
64 
67  // some space
68  std::unique_ptr<reco::TrackCollection> selTracks_;
69  std::unique_ptr<reco::TrackExtraCollection> selTrackExtras_;
70  std::unique_ptr<TrackingRecHitCollection> selHits_;
71  std::unique_ptr< std::vector<Trajectory> > selTrajs_;
72  std::unique_ptr< TrajTrackAssociationCollection > selTTAss_;
73  };
74 
75 
76 };
77 
78 #endif
T getParameter(std::string const &) const
tuple cfg
Definition: looper.py:293
std::unique_ptr< std::vector< Trajectory > > selTrajs_
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
std::unique_ptr< reco::TrackExtraCollection > selTrackExtras_
std::unique_ptr< reco::TrackCollection > selTracks_
std::unique_ptr< TrackingRecHitCollection > selHits_
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
bool copyExtras_
copy only the tracks, not extras and rechits (for AOD)
TrackCollectionCloner(Producer &producer, const edm::ParameterSet &cfg, bool copyDefault)
Producer(edm::Event &ievt, TrackCollectionCloner const &cloner)
bool copyTrajectories_
copy also trajectories and trajectory-&gt;track associations
def template
Definition: svgfig.py:520
void operator()(Tokens const &tokens, std::vector< unsigned int > const &selected)
process one event
std::unique_ptr< TrajTrackAssociationCollection > selTTAss_