CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ReduceHcalRecHitCollectionProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ReduceHcalRecHitCollectionProducer
4 // Class: ReduceHcalRecHitCollectionProducer
5 //
6 /*\class ReduceHcalRecHitCollectionProducer ReduceHcalRecHitCollectionProducer.cc
7 
8  Description: [one line class summary]
9 
10  Implementation:
11  [Notes on implementation]
12 */
13 //
14 // Original Author: Jie Chen
15 // Created: Mon Apr 12 16:41:46 CDT 2010
16 // $Id: ReduceHcalRecHitCollectionProducer.cc,v 1.1 2010/04/14 14:30:38 jiechen Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
32 
33 
38 
42 
51 
55 
59 
60 #include <iostream>
61 
62 //
63 // class declaration
64 //
65 
67  public:
70  virtual void produce(edm::Event&, const edm::EventSetup&);
71  private:
77  double ptcut_;
78  // ----------member data ---------------------------
79 };
80 
81 //
82 // constants, enums and typedefs
83 //
84 
85 
86 //
87 // static data member definitions
88 //
89 
90 //
91 // constructors and destructor
92 //
94 {
95  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");
96 
97  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
98 
99  //register your products
100  produces< HBHERecHitCollection > (reducedHitsCollection_) ;
101 
102  inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection"); ptcut_= iConfig.getParameter< double >("TrackPt");
103 
104  produces< DetIdCollection >() ;
105  // TrackAssociator parameters
106  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
107  parameters_.loadParameters( parameters );
109 
110 }
111 
112 
114 {
115 
116  // do anything here that needs to be done at desctruction time
117  // (e.g. close files, deallocate resources etc.)
118 
119 }
120 
121 
122 //
123 // member functions
124 //
125 
126 // ------------ method called to produce the data ------------
127 void
129 {
130  using namespace edm;
131 
132  using namespace std;
133 
134  using reco::TrackCollection;
135 
136  Handle<HBHERecHitCollection> recHitsHandle;
137  iEvent.getByLabel(recHitsLabel_,recHitsHandle);
138  if( !recHitsHandle.isValid() )
139  {
140  edm::LogError("ReduceHcalRecHitCollectionProducer") << "RecHit collection not found";
141  return;
142  }
143 
144  //Create empty output collections
145  std::auto_ptr< HBHERecHitCollection > miniRecHitCollection (new HBHERecHitCollection) ;
146 
147 //loop through tracks.
148  Handle<TrackCollection> tkTracks;
149  iEvent.getByLabel(inputCollection_,tkTracks);
150  std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
151  for(TrackCollection::const_iterator itTrack = tkTracks->begin();
152  itTrack != tkTracks->end();
153  ++itTrack) {
154  if(itTrack->pt()>ptcut_){
155 
157 
158  if(info.crossedHcalIds.size()>0){
159  //loop through hits in the cone
160  for(std::vector<const HBHERecHit*>::const_iterator hit = info.hcalRecHits.begin();
161  hit != info.hcalRecHits.end(); ++hit)
162  {
163  DetId hitid=(*hit)->id();
164  HBHERecHitCollection::const_iterator iRecHit = recHitsHandle->find(hitid);
165  if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(hitid) == miniRecHitCollection->end()) )
166  miniRecHitCollection->push_back(*iRecHit);
167  }
168 
169 
170  }
171  }
172  }
173 
174  iEvent.put( miniRecHitCollection,reducedHitsCollection_ );
175 
176 
177 
178 }
179 //define this as a plug-in
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
dictionary parameters
Definition: Parameters.py:2
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void useDefaultPropagator()
use the default propagator
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
std::vector< T >::const_iterator const_iterator
std::vector< DetId > crossedHcalIds
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< const HBHERecHit * > hcalRecHits
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
Definition: DetId.h:20
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
edm::EDCollection< DetId > DetIdCollection
void loadParameters(const edm::ParameterSet &)