CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackSelector.h
Go to the documentation of this file.
1 #ifndef RecoAlgos_TrackSelector_h
2 #define RecoAlgos_TrackSelector_h
3 
28 
29 
30 namespace helper {
31 
32  //------------------------------------------------------------------
34  //------------------------------------------------------------------
36  public:
38 
40 
41  //------------------------------------------------------------------
46  //------------------------------------------------------------------
47  inline bool cloneClusters() {return cloneClusters_ ; }
48  inline void setCloneClusters(bool w) { cloneClusters_ = w; }
49 
50  //------------------------------------------------------------------
52  //------------------------------------------------------------------
54 
55  //------------------------------------------------------------------
57  //------------------------------------------------------------------
58  inline size_t size() const { return selTracks_->size(); }
59 
60 
61  //------------------------------------------------------------------
65  //------------------------------------------------------------------
66  template<typename I>
67  void cloneAndStore( const I & begin, const I & end, edm::Event & evt ) ;
68 
69  private:
70  //--- Collections to store:
71  std::auto_ptr<reco::TrackCollection> selTracks_;
72  std::auto_ptr<reco::TrackExtraCollection> selTrackExtras_;
73  std::auto_ptr<TrackingRecHitCollection> selHits_;
74  std::auto_ptr< edmNew::DetSetVector<SiStripCluster> > selStripClusters_;
75  std::auto_ptr< edmNew::DetSetVector<SiPixelCluster> > selPixelClusters_;
76 
77  //--- References to products (i.e. to collections):
84 
85  //--- Indices into collections handled with RefProd
86  size_t idx_ ;
87  size_t hidx_ ;
88 
89  //--- Switches
91 
92  //--- Methods
93  //------------------------------------------------------------------
95  //------------------------------------------------------------------
96  void processTrack( const reco::Track & trk );
97  };
98  // (end of struct TrackCollectionStoreManager)
99 
100 
101  template<typename I>
102  void
104  {
105  using namespace reco;
106 
107  rTracks_ = evt.template getRefBeforePut<TrackCollection>();
108  rTrackExtras_ = evt.template getRefBeforePut<TrackExtraCollection>();
109  rHits_ = evt.template getRefBeforePut<TrackingRecHitCollection>();
110  //--- New: save clusters too
112  = evt.template getRefBeforePut<edmNew::DetSetVector<SiPixelCluster> >();
114  = evt.template getRefBeforePut<edmNew::DetSetVector<SiStripCluster> >();
115 
116  //--- Indices into collections handled with RefProd
117  idx_ = 0;
118  hidx_ = 0;
120 
121  //--- Loop over tracks
122  for( I i = begin; i != end; ++ i ) {
123  //--- Whatever type the iterator i is, deref to reco::Track &
124  const reco::Track & trk = * * i;
125  //--- Clone this track, and store references aside
126  processTrack( trk );
127  }
128  //--- Clone the clusters and fixup refs
130  *selStripClusters_, rStripClusters);
131  }
132 
133 
134  //----------------------------------------------------------------------
136  public:
138  std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
139  produces<reco::TrackCollection>().setBranchAlias( alias + "Tracks" );
140  produces<reco::TrackExtraCollection>().setBranchAlias( alias + "TrackExtras" );
141  produces<TrackingRecHitCollection>().setBranchAlias( alias + "RecHits" );
142  //--- New: save clusters too
143  produces< edmNew::DetSetVector<SiPixelCluster> >().setBranchAlias( alias + "PixelClusters" );
144  produces< edmNew::DetSetVector<SiStripCluster> >().setBranchAlias( alias + "StripClusters" );
145  }
146  }; // (end of class TrackSelectorBase)
147 
148 
149  template<>
153  };
154 
155 }
156 
157 #endif
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
Class to manage copying of RecHits and Clusters from Tracks.
Definition: TrackSelector.h:35
tuple cfg
Definition: looper.py:293
const double w
Definition: UKUtility.cc:23
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
bool cloneClusters_
Clone clusters, or not? Default: true.
Definition: TrackSelector.h:90
void cloneAndStore(const I &begin, const I &end, edm::Event &evt)
Method to clone tracks, track extras and their hits and clusters. typename I = this is an interator o...
size_t size() const
Get the size.
Definition: TrackSelector.h:58
void processTrack(const reco::Track &trk)
Process a single track.
const std::complex< double > I
Definition: I.h:8
#define end
Definition: vmac.h:37
TrackCollectionStoreManager(const edm::Handle< reco::TrackCollection > &)
Definition: TrackSelector.cc:9
size_t hidx_
index to tracking rec hits
Definition: TrackSelector.h:87
reco::TrackExtraRefProd rTrackExtras_
Definition: TrackSelector.h:79
std::auto_ptr< reco::TrackCollection > selTracks_
Definition: TrackSelector.h:71
std::auto_ptr< reco::TrackExtraCollection > selTrackExtras_
Definition: TrackSelector.h:72
void clear()
clear records
TrackSelectorBase(const edm::ParameterSet &cfg)
edm::OrphanHandle< reco::TrackCollection > put(edm::Event &evt)
Put tracks, track extras and hits+clusters into the event.
#define begin
Definition: vmac.h:30
void processAllClusters(edmNew::DetSetVector< SiPixelCluster > &pixelDsvToFill, edm::RefProd< edmNew::DetSetVector< SiPixelCluster > > refPixelClusters, edmNew::DetSetVector< SiStripCluster > &stripDsvToFill, edm::RefProd< edmNew::DetSetVector< SiStripCluster > > refStripClusters)
std::auto_ptr< TrackingRecHitCollection > selHits_
Definition: TrackSelector.h:73
reco::TrackCollection collection
Definition: TrackSelector.h:37
std::auto_ptr< edmNew::DetSetVector< SiPixelCluster > > selPixelClusters_
Definition: TrackSelector.h:75
size_t idx_
index to track extra coll
Definition: TrackSelector.h:86
std::auto_ptr< edmNew::DetSetVector< SiStripCluster > > selStripClusters_
Definition: TrackSelector.h:74