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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
31 
32 
37 
41 
50 
54 
58 
59 #include <iostream>
60 
61 //
62 // class declaration
63 //
64 
66  public:
69  virtual void produce(edm::Event&, const edm::EventSetup&) override;
70  private:
76  double ptcut_;
77  // ----------member data ---------------------------
78 };
79 
80 //
81 // constants, enums and typedefs
82 //
83 
84 
85 //
86 // static data member definitions
87 //
88 
89 //
90 // constructors and destructor
91 //
93 {
94  recHitsLabel_ = iConfig.getParameter< edm::InputTag > ("recHitsLabel");
95 
96  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
97 
98  //register your products
99  produces< HBHERecHitCollection > (reducedHitsCollection_) ;
100 
101  inputCollection_ = iConfig.getParameter< edm::InputTag >("inputCollection"); ptcut_= iConfig.getParameter< double >("TrackPt");
102 
103  produces< DetIdCollection >() ;
104  // TrackAssociator parameters
105  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
106  parameters_.loadParameters( parameters );
108 
109 }
110 
111 
113 {
114 
115  // do anything here that needs to be done at desctruction time
116  // (e.g. close files, deallocate resources etc.)
117 
118 }
119 
120 
121 //
122 // member functions
123 //
124 
125 // ------------ method called to produce the data ------------
126 void
128 {
129  using namespace edm;
130 
131  using namespace std;
132 
133  using reco::TrackCollection;
134 
135  Handle<HBHERecHitCollection> recHitsHandle;
136  iEvent.getByLabel(recHitsLabel_,recHitsHandle);
137  if( !recHitsHandle.isValid() )
138  {
139  edm::LogError("ReduceHcalRecHitCollectionProducer") << "RecHit collection not found";
140  return;
141  }
142 
143  //Create empty output collections
144  std::auto_ptr< HBHERecHitCollection > miniRecHitCollection (new HBHERecHitCollection) ;
145 
146 //loop through tracks.
147  Handle<TrackCollection> tkTracks;
148  iEvent.getByLabel(inputCollection_,tkTracks);
149  std::auto_ptr< DetIdCollection > interestingDetIdCollection( new DetIdCollection() ) ;
150  for(TrackCollection::const_iterator itTrack = tkTracks->begin();
151  itTrack != tkTracks->end();
152  ++itTrack) {
153  if(itTrack->pt()>ptcut_){
154 
156 
157  if(info.crossedHcalIds.size()>0){
158  //loop through hits in the cone
159  for(std::vector<const HBHERecHit*>::const_iterator hit = info.hcalRecHits.begin();
160  hit != info.hcalRecHits.end(); ++hit)
161  {
162  DetId hitid=(*hit)->id();
163  HBHERecHitCollection::const_iterator iRecHit = recHitsHandle->find(hitid);
164  if ( (iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(hitid) == miniRecHitCollection->end()) )
165  miniRecHitCollection->push_back(*iRecHit);
166  }
167 
168 
169  }
170  }
171  }
172 
173  iEvent.put( miniRecHitCollection,reducedHitsCollection_ );
174 
175 
176 
177 }
178 //define this as a plug-in
T getParameter(std::string const &) const
dictionary parameters
Definition: Parameters.py:2
static const TGPicture * info(bool iBackgroundIsBlack)
#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< HBHERecHit >::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:116
std::vector< const HBHERecHit * > hcalRecHits
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
Definition: DetId.h:18
virtual void produce(edm::Event &, const edm::EventSetup &) override
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
edm::EDCollection< DetId > DetIdCollection
void loadParameters(const edm::ParameterSet &)