CMS 3D CMS Logo

Skim_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 // system include files
20 #include <memory>
21 
22 // user include files
25 
30 
35 
39 
48 
52 
56 
57 #include <iostream>
58 
59 //
60 // class declaration
61 //
62 
64 public:
67  void produce(edm::Event&, const edm::EventSetup&) override;
68 
69 private:
75  double ptcut_;
76  // ----------member data ---------------------------
77 };
78 
79 //
80 // constants, enums and typedefs
81 //
82 
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
91  recHitsToken_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("recHitsLabel"));
92 
93  reducedHitsCollection_ = iConfig.getParameter<std::string>("reducedHitsCollection");
94 
95  //register your products
96  produces<HBHERecHitCollection>(reducedHitsCollection_);
97 
98  inputCollectionToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputCollection"));
99  ptcut_ = iConfig.getParameter<double>("TrackPt");
100 
101  produces<DetIdCollection>();
102  // TrackAssociator parameters
103  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
107 }
108 
110  // do anything here that needs to be done at desctruction time
111  // (e.g. close files, deallocate resources etc.)
112 }
113 
114 //
115 // member functions
116 //
117 
118 // ------------ method called to produce the data ------------
120  using namespace edm;
121 
122  using namespace std;
123 
124  using reco::TrackCollection;
125 
126  Handle<HBHERecHitCollection> recHitsHandle;
127  iEvent.getByToken(recHitsToken_, recHitsHandle);
128  if (!recHitsHandle.isValid()) {
129  edm::LogError("ReduceHcalRecHitCollectionProducer") << "RecHit collection not found";
130  return;
131  }
132 
133  //Create empty output collections
134  std::unique_ptr<HBHERecHitCollection> miniRecHitCollection(new HBHERecHitCollection);
135 
136  //loop through tracks.
137  Handle<TrackCollection> tkTracks;
138  iEvent.getByToken(inputCollectionToken_, tkTracks);
139  std::unique_ptr<DetIdCollection> interestingDetIdCollection(new DetIdCollection());
140  for (TrackCollection::const_iterator itTrack = tkTracks->begin(); itTrack != tkTracks->end(); ++itTrack) {
141  if (itTrack->pt() > ptcut_) {
144 
145  if (!info.crossedHcalIds.empty()) {
146  //loop through hits in the cone
147  for (std::vector<const HBHERecHit*>::const_iterator hit = info.hcalRecHits.begin();
148  hit != info.hcalRecHits.end();
149  ++hit) {
150  DetId hitid = (*hit)->id();
151  HBHERecHitCollection::const_iterator iRecHit = recHitsHandle->find(hitid);
152  if ((iRecHit != recHitsHandle->end()) && (miniRecHitCollection->find(hitid) == miniRecHitCollection->end()))
153  miniRecHitCollection->push_back(*iRecHit);
154  }
155  }
156  }
157  }
158 
159  iEvent.put(std::move(miniRecHitCollection), reducedHitsCollection_);
160 }
161 //define this as a plug-in
TrackExtra.h
Handle.h
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
ReduceHcalRecHitCollectionProducer::~ReduceHcalRecHitCollectionProducer
~ReduceHcalRecHitCollectionProducer() override
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:109
EDProducer.h
ESHandle.h
TrackDetectorAssociator.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackDetectorAssociator::useDefaultPropagator
void useDefaultPropagator()
use the default propagator
Definition: TrackDetectorAssociator.cc:120
EBDetId.h
EEDetId.h
edm::SortedCollection
Definition: SortedCollection.h:49
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
ReduceHcalRecHitCollectionProducer::recHitsToken_
edm::EDGetTokenT< HBHERecHitCollection > recHitsToken_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:70
ReduceHcalRecHitCollectionProducer::trackAssociator_
TrackDetectorAssociator trackAssociator_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:73
edm::Handle
Definition: AssociativeIterator.h:50
EcalRecHitCollections.h
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
DetId
Definition: DetId.h:17
MakerMacros.h
Track.h
TrackFwd.h
ReduceHcalRecHitCollectionProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:119
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ReduceHcalRecHitCollectionProducer::ptcut_
double ptcut_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:75
ReduceHcalRecHitCollectionProducer::ReduceHcalRecHitCollectionProducer
ReduceHcalRecHitCollectionProducer(const edm::ParameterSet &)
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:90
TrackAssociatorParameters::loadParameters
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: TrackAssociatorParameters.cc:18
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:36
edm::LogError
Definition: MessageLogger.h:183
Event.h
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
HcalDetId.h
TrackDetectorAssociator
Definition: TrackDetectorAssociator.h:49
CaloTopologyRecord.h
iEvent
int iEvent
Definition: GenABIO.cc:224
ReduceHcalRecHitCollectionProducer::inputCollectionToken_
edm::EDGetTokenT< reco::TrackCollection > inputCollectionToken_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:72
edm::EventSetup
Definition: EventSetup.h:57
HcalSubdetector.h
TrackDetectorAssociator::InsideOut
Definition: TrackDetectorAssociator.h:55
EcalRecHit.h
InputTag.h
CaloTopology.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CaloSubdetectorTopology.h
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:14
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
DetIdCollection
edm::EDCollection< DetId > DetIdCollection
Definition: DetIdCollection.h:7
Frameworkfwd.h
ReduceHcalRecHitCollectionProducer
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:63
ReduceHcalRecHitCollectionProducer::reducedHitsCollection_
std::string reducedHitsCollection_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:71
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:36
HcalRecHitCollections.h
TrackDetectorAssociator::associate
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
Definition: TrackDetectorAssociator.cc:154
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
TrackAssociatorParameters.h
interestingDetIdCollectionProducer_cfi.interestingDetIdCollection
interestingDetIdCollection
Definition: interestingDetIdCollectionProducer_cfi.py:11
edm::InputTag
Definition: InputTag.h:15
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
DetIdCollection.h
TrackDetMatchInfo.h
ReduceHcalRecHitCollectionProducer::parameters_
TrackAssociatorParameters parameters_
Definition: Skim_ReduceHcalRecHitCollectionProducer.cc:74
hit
Definition: SiStripHitEffFromCalibTree.cc:88
TrackAssociatorParameters
Definition: TrackAssociatorParameters.h:34