CMS 3D CMS Logo

AlCaDiJetsProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <string>
4 // user include files
12 
30 
33 #include <iostream>
34 
35 //
36 // class declaration
37 //
38 
40 public:
41  explicit AlCaDiJetsProducer(const edm::ParameterSet&);
42  ~AlCaDiJetsProducer() override;
43  void beginJob() override;
44  void produce(edm::Event&, const edm::EventSetup&) override;
45  void endJob() override;
46 
47 private:
49 
50  // ----------member data ---------------------------
51 
53  double minPtJet_;
55 
60  //edm::EDGetTokenT<edm::TriggerResults> tok_TrigRes_;
63 };
64 
65 AlCaDiJetsProducer::AlCaDiJetsProducer(const edm::ParameterSet& iConfig) : nAll_(0), nSelect_(0) {
66  // Take input
67  labelPFJet_ = iConfig.getParameter<edm::InputTag>("PFjetInput");
68  labelHBHE_ = iConfig.getParameter<edm::InputTag>("HBHEInput");
69  labelHF_ = iConfig.getParameter<edm::InputTag>("HFInput");
70  labelHO_ = iConfig.getParameter<edm::InputTag>("HOInput");
71  //labelTrigger_ = iConfig.getParameter<edm::InputTag>("TriggerResults");
72  labelPFCandidate_ = iConfig.getParameter<edm::InputTag>("particleFlowInput");
73  labelVertex_ = iConfig.getParameter<edm::InputTag>("VertexInput");
74  minPtJet_ = iConfig.getParameter<double>("MinPtJet");
75 
76  tok_PFJet_ = consumes<reco::PFJetCollection>(labelPFJet_);
77  tok_HBHE_ = consumes<edm::SortedCollection<HBHERecHit, edm::StrictWeakOrdering<HBHERecHit>>>(labelHBHE_);
78  tok_HF_ = consumes<edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>>(labelHF_);
79  tok_HO_ = consumes<edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>>(labelHO_);
80  //tok_TrigRes_= consumes<edm::TriggerResults>(labelTrigger_);
81  tok_PFCand_ = consumes<reco::PFCandidateCollection>(labelPFCandidate_);
82  tok_Vertex_ = consumes<reco::VertexCollection>(labelVertex_);
83 
84  // register your products
85  produces<reco::PFJetCollection>(labelPFJet_.encode());
86  produces<edm::SortedCollection<HBHERecHit, edm::StrictWeakOrdering<HBHERecHit>>>(labelHBHE_.encode());
87  produces<edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>>(labelHF_.encode());
88  produces<edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>>(labelHO_.encode());
89  //produces<edm::TriggerResults>(labelTrigger_.encode());
90  produces<reco::PFCandidateCollection>(labelPFCandidate_.encode());
91  produces<reco::VertexCollection>(labelVertex_.encode());
92 }
93 
95 
97 
99  edm::LogVerbatim("AlcaDiJets") << "Accepts " << nSelect_ << " events from a total of " << nAll_ << " events";
100 }
101 
103  if (jt.size() < 2)
104  return false;
105  if (((jt.at(0)).pt()) < minPtJet_)
106  return false;
107  return true;
108 }
109 // ------------ method called to produce the data ------------
111  nAll_++;
112 
113  // Access the collections from iEvent
115  iEvent.getByToken(tok_PFJet_, pfjet);
116  if (!pfjet.isValid()) {
117  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelPFJet_;
118  return;
119  }
120  const reco::PFJetCollection pfjets = *(pfjet.product());
121 
123  iEvent.getByToken(tok_PFCand_, pfc);
124  if (!pfc.isValid()) {
125  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelPFCandidate_;
126  return;
127  }
128  const reco::PFCandidateCollection pfcand = *(pfc.product());
129 
131  iEvent.getByToken(tok_Vertex_, vt);
132  if (!vt.isValid()) {
133  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelVertex_;
134  return;
135  }
136  const reco::VertexCollection vtx = *(vt.product());
137 
139  iEvent.getByToken(tok_HBHE_, hbhe);
140  if (!hbhe.isValid()) {
141  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHBHE_;
142  return;
143  }
145 
147  iEvent.getByToken(tok_HO_, ho);
148  if (!ho.isValid()) {
149  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHO_;
150  return;
151  }
153 
155  iEvent.getByToken(tok_HF_, hf);
156  if (!hf.isValid()) {
157  edm::LogWarning("AlCaDiJets") << "AlCaDiJetsProducer: Error! can't get product " << labelHF_;
158  return;
159  }
161 
162  // See if this event is useful
163  bool accept = select(pfjets);
164  if (accept) {
165  nSelect_++;
166 
167  //Copy from standard place
168  auto miniPFjetCollection = std::make_unique<reco::PFJetCollection>();
169  for (reco::PFJetCollection::const_iterator pfjetItr = pfjets.begin(); pfjetItr != pfjets.end(); pfjetItr++) {
170  miniPFjetCollection->push_back(*pfjetItr);
171  }
172 
173  auto miniPFCandCollection = std::make_unique<reco::PFCandidateCollection>();
174  for (reco::PFCandidateCollection::const_iterator pfcItr = pfcand.begin(); pfcItr != pfcand.end(); pfcItr++) {
175  miniPFCandCollection->push_back(*pfcItr);
176  }
177 
178  auto miniVtxCollection = std::make_unique<reco::VertexCollection>();
179  for (reco::VertexCollection::const_iterator vtxItr = vtx.begin(); vtxItr != vtx.end(); vtxItr++) {
180  miniVtxCollection->push_back(*vtxItr);
181  }
182 
183  auto miniHBHECollection =
184  std::make_unique<edm::SortedCollection<HBHERecHit, edm::StrictWeakOrdering<HBHERecHit>>>();
186  Hithbhe.begin();
187  hbheItr != Hithbhe.end();
188  hbheItr++) {
189  miniHBHECollection->push_back(*hbheItr);
190  }
191 
192  auto miniHOCollection = std::make_unique<edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>>();
193  for (edm::SortedCollection<HORecHit, edm::StrictWeakOrdering<HORecHit>>::const_iterator hoItr = Hitho.begin();
194  hoItr != Hitho.end();
195  hoItr++) {
196  miniHOCollection->push_back(*hoItr);
197  }
198 
199  auto miniHFCollection = std::make_unique<edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>>();
200  for (edm::SortedCollection<HFRecHit, edm::StrictWeakOrdering<HFRecHit>>::const_iterator hfItr = Hithf.begin();
201  hfItr != Hithf.end();
202  hfItr++) {
203  miniHFCollection->push_back(*hfItr);
204  }
205 
206  //Put them in the event
207  iEvent.put(std::move(miniPFjetCollection), labelPFJet_.encode());
208  iEvent.put(std::move(miniHBHECollection), labelHBHE_.encode());
209  iEvent.put(std::move(miniHFCollection), labelHF_.encode());
210  iEvent.put(std::move(miniHOCollection), labelHO_.encode());
211  //iEvent.put(std::move(miniTriggerCollection), labelTrigger_.encode());
212  iEvent.put(std::move(miniPFCandCollection), labelPFCandidate_.encode());
213  iEvent.put(std::move(miniVtxCollection), labelVertex_.encode());
214  }
215  return;
216 }
217 
AlCaDiJetsProducer::tok_HF_
edm::EDGetTokenT< edm::SortedCollection< HFRecHit, edm::StrictWeakOrdering< HFRecHit > > > tok_HF_
Definition: AlCaDiJetsProducer.cc:58
AlCaDiJetsProducer::tok_HO_
edm::EDGetTokenT< edm::SortedCollection< HORecHit, edm::StrictWeakOrdering< HORecHit > > > tok_HO_
Definition: AlCaDiJetsProducer.cc:59
AlCaDiJetsProducer
Definition: AlCaDiJetsProducer.cc:39
MessageLogger.h
AlCaDiJetsProducer::tok_PFCand_
edm::EDGetTokenT< reco::PFCandidateCollection > tok_PFCand_
Definition: AlCaDiJetsProducer.cc:61
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
TriggerResults.h
PFCandidate.h
AlCaDiJetsProducer::nSelect_
int nSelect_
Definition: AlCaDiJetsProducer.cc:54
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
HORecHit
Definition: HORecHit.h:11
TriggerEvent.h
edm::EDGetTokenT< reco::PFJetCollection >
AlCaDiJetsProducer::labelPFJet_
edm::InputTag labelPFJet_
Definition: AlCaDiJetsProducer.cc:52
HBHERecHit
Definition: HBHERecHit.h:13
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
AlCaDiJetsProducer::AlCaDiJetsProducer
AlCaDiJetsProducer(const edm::ParameterSet &)
Definition: AlCaDiJetsProducer.cc:65
PFJetCollection.h
edm::SortedCollection
Definition: SortedCollection.h:49
PhotonFwd.h
AlCaDiJetsProducer::labelPFCandidate_
edm::InputTag labelPFCandidate_
Definition: AlCaDiJetsProducer.cc:52
AlCaDiJetsProducer::beginJob
void beginJob() override
Definition: AlCaDiJetsProducer.cc:96
PFMETCollection.h
edm::Handle< reco::PFJetCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
AlCaDiJetsProducer::labelVertex_
edm::InputTag labelVertex_
Definition: AlCaDiJetsProducer.cc:52
pfDeepBoostedJetPreprocessParams_cfi.pfcand
pfcand
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:8
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
MakerMacros.h
Photon.h
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
HFRecHit
Definition: HFRecHit.h:11
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HFRecHit.h
AlCaDiJetsProducer::tok_Vertex_
edm::EDGetTokenT< reco::VertexCollection > tok_Vertex_
Definition: AlCaDiJetsProducer.cc:62
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
AlCaDiJetsProducer::minPtJet_
double minPtJet_
Definition: AlCaDiJetsProducer.cc:53
AlCaDiJetsProducer::select
bool select(reco::PFJetCollection)
Definition: AlCaDiJetsProducer.cc:102
AlCaDiJetsProducer::labelHBHE_
edm::InputTag labelHBHE_
Definition: AlCaDiJetsProducer.cc:52
CaloGeometryRecord.h
AlCaDiJetsProducer::labelHF_
edm::InputTag labelHF_
Definition: AlCaDiJetsProducer.cc:52
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaDiJetsProducer::nAll_
int nAll_
Definition: AlCaDiJetsProducer.cc:54
Event.h
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
PFMET.h
AlCaDiJetsProducer::endJob
void endJob() override
Definition: AlCaDiJetsProducer.cc:98
iEvent
int iEvent
Definition: GenABIO.cc:224
photonIsolationHIProducer_cfi.ho
ho
Definition: photonIsolationHIProducer_cfi.py:10
edm::InputTag::encode
std::string encode() const
Definition: InputTag.cc:159
edm::EventSetup
Definition: EventSetup.h:58
AlCaDiJetsProducer::tok_PFJet_
edm::EDGetTokenT< reco::PFJetCollection > tok_PFJet_
Definition: AlCaDiJetsProducer.cc:56
TriggerObject.h
ValueMap.h
photonIsolationHIProducer_cfi.hbhe
hbhe
Definition: photonIsolationHIProducer_cfi.py:8
HBHERecHit.h
VertexFwd.h
AlCaDiJetsProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: AlCaDiJetsProducer.cc:110
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
extraflags_cff.vtx
vtx
Definition: extraflags_cff.py:19
Vertex.h
DetId.h
Frameworkfwd.h
edm::StrictWeakOrdering
Definition: SortedCollection.h:47
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
AlCaDiJetsProducer::~AlCaDiJetsProducer
~AlCaDiJetsProducer() override
Definition: AlCaDiJetsProducer.cc:94
CaloGeometry.h
reco::PFCandidateCollection
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
Definition: PFCandidateFwd.h:12
EventSetup.h
edm::EDProducer
Definition: EDProducer.h:35
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HORecHit.h
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
AlCaDiJetsProducer::tok_HBHE_
edm::EDGetTokenT< edm::SortedCollection< HBHERecHit, edm::StrictWeakOrdering< HBHERecHit > > > tok_HBHE_
Definition: AlCaDiJetsProducer.cc:57
AlCaDiJetsProducer::labelHO_
edm::InputTag labelHO_
Definition: AlCaDiJetsProducer.cc:52
GlobalPoint.h
edm::InputTag
Definition: InputTag.h:15