CMS 3D CMS Logo

AlCaGammaJetSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Calibration/HcalAlCaRecoProducers/AlCaGammaJetSelector
4 // Class: AlCaGammaJetSelector
5 //
13 //
14 // Original Author: Andrius Juodagalvis
15 // Created: Fri, 15 Aug 2015 12:09:55 GMT
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 
23 // user include files
30 
34 //#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
35 
36 //
37 // class declaration
38 //
39 
40 namespace AlCaGammaJet {
41  struct Counters {
43  mutable std::atomic<unsigned int> nProcessed_, nSelected_;
44  };
45 } // namespace AlCaGammaJet
46 
47 class AlCaGammaJetSelector : public edm::stream::EDFilter<edm::GlobalCache<AlCaGammaJet::Counters> > {
48 public:
50  ~AlCaGammaJetSelector() override;
51 
52  static std::unique_ptr<AlCaGammaJet::Counters> initializeGlobalCache(edm::ParameterSet const&) {
53  return std::make_unique<AlCaGammaJet::Counters>();
54  }
55 
56  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
57  bool filter(edm::Event&, const edm::EventSetup&) override;
58  void endStream() override;
59  static void globalEndJob(const AlCaGammaJet::Counters* counters);
60 
61 private:
62  void beginRun(edm::Run const&, edm::EventSetup const&) override {}
63  void endRun(edm::Run const&, edm::EventSetup const&) override {}
65  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override {}
67 
68  // ----------member data ---------------------------
69 
70  unsigned int nProcessed_, nSelected_;
71 
76 };
77 
78 //
79 // constants, enums and typedefs
80 //
81 
82 //
83 // static data member definitions
84 //
85 
86 //
87 // constructors and destructor
88 //
90  nProcessed_ = 0;
91  nSelected_ = 0;
92 
93  // get input
94  labelPhoton_ = iConfig.getParameter<edm::InputTag>("PhoInput");
95  labelPFJet_ = iConfig.getParameter<edm::InputTag>("PFjetInput");
96  minPtJet_ = iConfig.getParameter<double>("MinPtJet");
97  minPtPhoton_ = iConfig.getParameter<double>("MinPtPhoton");
98 
99  // Register consumption
100  tok_Photon_ = consumes<reco::PhotonCollection>(labelPhoton_);
101  tok_PFJet_ = consumes<reco::PFJetCollection>(labelPFJet_);
102 }
103 
105 
106 //
107 // member functions
108 //
109 
110 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
112  //The following says we do not know what parameters are allowed so do no validation
113  // Please change this to state exactly what you do use, even if it is no parameters
115  desc.add<edm::InputTag>("PhoInput", edm::InputTag("gedPhotons"));
116  desc.add<edm::InputTag>("PFjetInput", edm::InputTag("ak4PFJetsCHS"));
117  desc.add<double>("MinPtJet", 10.0);
118  desc.add<double>("MinPtPhoton", 10.0);
119  descriptions.addDefault(desc);
120 }
121 
122 // ------------ method called on each new Event ------------
124  nProcessed_++;
125 
126  // Access the collections from iEvent
128  iEvent.getByToken(tok_Photon_, phoHandle);
129  if (!phoHandle.isValid()) {
130  edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get the product " << labelPhoton_;
131  return false; // do not filter
132  }
133  const reco::PhotonCollection photons = *(phoHandle.product());
134 
136  iEvent.getByToken(tok_PFJet_, pfjetHandle);
137  if (!pfjetHandle.isValid()) {
138  edm::LogWarning("AlCaGammaJet") << "AlCaGammaJetProducer: Error! can't get product " << labelPFJet_;
139  return false; // do not filter
140  }
141  const reco::PFJetCollection pfjets = *(pfjetHandle.product());
142 
143  // Check the conditions for a good event
144  if (!(select(photons, pfjets)))
145  return false;
146 
147  edm::LogVerbatim("AlCaGammaJet") << "good event\n";
148  nSelected_++;
149  return true;
150 }
151 
153  globalCache()->nProcessed_ += nProcessed_;
154  globalCache()->nSelected_ += nSelected_;
155 }
156 
157 // ------------ method called once each job just after ending the event loop ------------
158 
160  edm::LogWarning("AlCaGammaJet") << "Finds " << count->nSelected_ << " good events out of " << count->nProcessed_;
161 }
162 
164  // Check the requirement for minimum pT
165  if (photons.empty())
166  return false;
167  bool ok(false);
168  for (reco::PFJetCollection::const_iterator itr = jets.begin(); itr != jets.end(); ++itr) {
169  if (itr->pt() >= minPtJet_) {
170  ok = true;
171  break;
172  }
173  }
174  if (!ok)
175  return ok;
176  for (reco::PhotonCollection::const_iterator itr = photons.begin(); itr != photons.end(); ++itr) {
177  if (itr->pt() >= minPtPhoton_)
178  return ok;
179  }
180  return false;
181 }
182 
183 //define this as a plug-in
AlCaGammaJetSelector::endStream
void endStream() override
Definition: AlCaGammaJetSelector.cc:152
AlCaGammaJetSelector::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: AlCaGammaJetSelector.cc:65
AlCaGammaJetSelector::minPtPhoton_
double minPtPhoton_
Definition: AlCaGammaJetSelector.cc:73
MessageLogger.h
AlCaGammaJetSelector::labelPhoton_
edm::InputTag labelPhoton_
Definition: AlCaGammaJetSelector.cc:72
AlCaGammaJetSelector::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
Definition: AlCaGammaJetSelector.cc:64
edm::Handle::product
T const * product() const
Definition: Handle.h:70
AlCaGammaJet::Counters
Definition: AlCaGammaJetSelector.cc:41
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< reco::PhotonCollection >
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
PFJetCollection.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
AlCaGammaJetSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: AlCaGammaJetSelector.cc:111
PhotonFwd.h
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
AlCaGammaJetSelector::filter
bool filter(edm::Event &, const edm::EventSetup &) override
Definition: AlCaGammaJetSelector.cc:123
AlCaGammaJet::Counters::nSelected_
std::atomic< unsigned int > nSelected_
Definition: AlCaGammaJetSelector.cc:43
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
edm::Handle< reco::PhotonCollection >
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
AlCaGammaJetSelector::tok_PFJet_
edm::EDGetTokenT< reco::PFJetCollection > tok_PFJet_
Definition: AlCaGammaJetSelector.cc:75
AlCaGammaJetSelector::AlCaGammaJetSelector
AlCaGammaJetSelector(const edm::ParameterSet &, const AlCaGammaJet::Counters *count)
Definition: AlCaGammaJetSelector.cc:89
MakerMacros.h
Photon.h
counters
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter const GPUCACell *__restrict__ const uint32_t *__restrict__ const gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell *__restrict__ uint32_t uint32_t CAHitNtupletGeneratorKernelsGPU::Counters * counters
Definition: CAHitNtupletGeneratorKernelsImpl.h:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
AlCaGammaJetSelector::nProcessed_
unsigned int nProcessed_
Definition: AlCaGammaJetSelector.cc:70
AlCaGammaJetSelector::nSelected_
unsigned int nSelected_
Definition: AlCaGammaJetSelector.cc:70
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaGammaJet
Definition: AlCaGammaJetSelector.cc:40
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
AlCaGammaJetSelector::~AlCaGammaJetSelector
~AlCaGammaJetSelector() override
Definition: AlCaGammaJetSelector.cc:104
iEvent
int iEvent
Definition: GenABIO.cc:224
AlCaGammaJetSelector::select
bool select(const reco::PhotonCollection &, const reco::PFJetCollection &)
Definition: AlCaGammaJetSelector.cc:163
BPHMonitor_cfi.photons
photons
Definition: BPHMonitor_cfi.py:91
edm::EventSetup
Definition: EventSetup.h:58
AlCaGammaJetSelector::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: AlCaGammaJetSelector.cc:63
AlCaGammaJetSelector::tok_Photon_
edm::EDGetTokenT< reco::PhotonCollection > tok_Photon_
Definition: AlCaGammaJetSelector.cc:74
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
AlCaGammaJet::Counters::Counters
Counters()
Definition: AlCaGammaJetSelector.cc:42
reco::PFJetCollection
std::vector< PFJet > PFJetCollection
collection of PFJet objects
Definition: PFJetCollection.h:14
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
AlCaGammaJetSelector::initializeGlobalCache
static std::unique_ptr< AlCaGammaJet::Counters > initializeGlobalCache(edm::ParameterSet const &)
Definition: AlCaGammaJetSelector.cc:52
AlCaGammaJet::Counters::nProcessed_
std::atomic< unsigned int > nProcessed_
Definition: AlCaGammaJetSelector.cc:43
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlCaGammaJetSelector::minPtJet_
double minPtJet_
Definition: AlCaGammaJetSelector.cc:73
reco::PhotonCollection
std::vector< Photon > PhotonCollection
collectin of Photon objects
Definition: PhotonFwd.h:9
EDFilter.h
AlCaGammaJetSelector::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: AlCaGammaJetSelector.cc:62
ParameterSet.h
AlCaGammaJetSelector
Definition: AlCaGammaJetSelector.cc:47
AlCaGammaJetSelector::globalEndJob
static void globalEndJob(const AlCaGammaJet::Counters *counters)
Definition: AlCaGammaJetSelector.cc:159
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::stream::EDFilter
Definition: EDFilter.h:38
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
AlCaGammaJetSelector::labelPFJet_
edm::InputTag labelPFJet_
Definition: AlCaGammaJetSelector.cc:72
edm::InputTag
Definition: InputTag.h:15