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