CMS 3D CMS Logo

AlCaIsolatedBunchSelector.cc
Go to the documentation of this file.
1 // system include files
2 #include <atomic>
3 #include <memory>
4 #include <cmath>
5 #include <iostream>
6 #include <sstream>
7 #include <fstream>
8 
9 // user include files
19 
21 //Triggers
24 //
25 // class declaration
26 //
27 
28 //#define EDM_ML_DEBUG
29 
30 namespace AlCaIsolatedBunch {
31  struct Counters {
32  Counters() : nAll_(0), nGood_(0) {}
33  mutable std::atomic<unsigned int> nAll_, nGood_;
34  };
35 } // namespace AlCaIsolatedBunch
36 
37 class AlCaIsolatedBunchSelector : public edm::stream::EDFilter<edm::GlobalCache<AlCaIsolatedBunch::Counters> > {
38 public:
40  ~AlCaIsolatedBunchSelector() override;
41 
42  static std::unique_ptr<AlCaIsolatedBunch::Counters> initializeGlobalCache(edm::ParameterSet const& iConfig) {
43  return std::make_unique<AlCaIsolatedBunch::Counters>();
44  }
45 
46  bool filter(edm::Event&, edm::EventSetup const&) override;
47  void endStream() override;
49  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
50 
51 private:
52  void beginRun(edm::Run const&, edm::EventSetup const&) override;
53  void endRun(edm::Run const&, edm::EventSetup const&) override;
54 
55  // ----------member data ---------------------------
60  unsigned int nRun_, nAll_, nGood_;
62 };
63 
64 //
65 // constructors and destructor
66 //
69  : nRun_(0), nAll_(0), nGood_(0) {
70  //now do what ever initialization is needed
71  trigName_ = iConfig.getParameter<std::string>("triggerName");
72  processName_ = iConfig.getParameter<std::string>("processName");
73  theTriggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultLabel");
74 
75  // define tokens for access
76  tok_trigRes_ = consumes<edm::TriggerResults>(theTriggerResultsLabel_);
77 
78  edm::LogVerbatim("AlCaIsoBunch") << "Input tag for trigger results " << theTriggerResultsLabel_
79  << " with trigger name " << trigName_ << " and process " << processName_
80  << std::endl;
81 }
82 
84 
85 //
86 // member functions
87 //
88 
89 // ------------ method called on each new Event ------------
91  bool accept(false);
92  ++nAll_;
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("AlCaIsoBunch") << "Run " << iEvent.id().run() << " Event " << iEvent.id().event() << " Luminosity "
95  << iEvent.luminosityBlock() << " Bunch " << iEvent.bunchCrossing() << std::endl;
96 #endif
97  //Step1: Find if the event passes the chosen trigger
99  iEvent.getByToken(tok_trigRes_, triggerResults);
100  if (triggerResults.isValid()) {
101  const edm::TriggerNames& triggerNames = iEvent.triggerNames(*triggerResults);
102  const std::vector<std::string>& triggerNames_ = triggerNames.triggerNames();
103  for (unsigned int iHLT = 0; iHLT < triggerResults->size(); iHLT++) {
104  int hlt = triggerResults->accept(iHLT);
105  if (triggerNames_[iHLT].find(trigName_) != std::string::npos) {
106  if (hlt > 0) {
107  accept = true;
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("AlCaIsoBunch")
110  << triggerNames_[iHLT] << " has got HLT flag " << hlt << ":" << accept << std::endl;
111 #endif
112  break;
113  }
114  }
115  }
116  }
117 
118  // Step 2: Return the acceptance flag
119  if (accept)
120  ++nGood_;
121  return accept;
122 
123 } // AlCaIsolatedBunchSelector::filter
124 // ------------ method called once each job just after ending the event loop ------------
126  globalCache()->nAll_ += nAll_;
127  globalCache()->nGood_ += nGood_;
128 }
129 
131  edm::LogVerbatim("AlCaIsoBunch") << "Selects " << count->nGood_ << " in " << count->nAll_ << " events" << std::endl;
132 }
133 
134 // ------------ method called when starting to processes a run ------------
136  bool changed(false);
137  edm::LogVerbatim("AlCaIsoBunch") << "Run[" << nRun_ << "] " << iRun.run() << " hltconfig.init "
138  << hltConfig_.init(iRun, iSetup, processName_, changed) << std::endl;
139 }
140 // ------------ method called when ending the processing of a run ------------
142  ++nRun_;
143  edm::LogVerbatim("AlCaIsoBunch") << "endRun[" << nRun_ << "] " << iRun.run() << std::endl;
144 }
145 
146 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
149  desc.add<edm::InputTag>("triggerResultLabel", edm::InputTag("TriggerResults", "", "HLT"));
150  desc.add<std::string>("processName", "HLT");
151  desc.add<std::string>("triggerName", "HLT_HcalIsolatedBunch");
152  descriptions.add("alcaIsolatedBunchSelector", desc);
153 }
154 
155 //define this as a plug-in
ConfigurationDescriptions.h
AlCaIsolatedBunchSelector::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: AlCaIsolatedBunchSelector.cc:135
AlCaIsolatedBunchSelector::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: AlCaIsolatedBunchSelector.cc:141
Handle.h
AlCaIsolatedBunchSelector::trigName_
std::string trigName_
Definition: AlCaIsolatedBunchSelector.cc:57
AlCaIsolatedBunchSelector::endStream
void endStream() override
Definition: AlCaIsolatedBunchSelector.cc:125
AlCaIsolatedBunchSelector::theTriggerResultsLabel_
edm::InputTag theTriggerResultsLabel_
Definition: AlCaIsolatedBunchSelector.cc:58
AlCaIsolatedBunchSelector::tok_trigRes_
edm::EDGetTokenT< edm::TriggerResults > tok_trigRes_
Definition: AlCaIsolatedBunchSelector.cc:61
MessageLogger.h
TriggerResults.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT< edm::TriggerResults >
LuminosityBlock.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
AlCaIsolatedBunchSelector::nRun_
unsigned int nRun_
Definition: AlCaIsolatedBunchSelector.cc:60
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
edm::Handle< edm::TriggerResults >
edm::RunBase::run
RunNumber_t run() const
Definition: RunBase.h:40
AlCaIsolatedBunchSelector::processName_
std::string processName_
Definition: AlCaIsolatedBunchSelector.cc:59
accept
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
MakerMacros.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
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
L1TEGammaOffline_cfi.triggerNames
triggerNames
Definition: L1TEGammaOffline_cfi.py:40
Run.h
AlCaIsolatedBunchSelector::~AlCaIsolatedBunchSelector
~AlCaIsolatedBunchSelector() override
Definition: AlCaIsolatedBunchSelector.cc:83
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
AlCaIsolatedBunchSelector
Definition: AlCaIsolatedBunchSelector.cc:37
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
AlCaIsolatedBunch::Counters::Counters
Counters()
Definition: AlCaIsolatedBunchSelector.cc:32
AlCaIsolatedBunchSelector::hltConfig_
HLTConfigProvider hltConfig_
Definition: AlCaIsolatedBunchSelector.cc:56
AlCaIsolatedBunch::Counters::nAll_
std::atomic< unsigned int > nAll_
Definition: AlCaIsolatedBunchFilter.cc:33
TriggerNames.h
iEvent
int iEvent
Definition: GenABIO.cc:224
AlCaIsolatedBunchSelector::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: AlCaIsolatedBunchSelector.cc:147
edm::EventSetup
Definition: EventSetup.h:58
AlCaIsolatedBunch::Counters
Definition: AlCaIsolatedBunchFilter.cc:31
AlCaIsolatedBunch
Definition: AlCaIsolatedBunchFilter.cc:30
HLTConfigProvider.h
AlCaIsolatedBunchSelector::AlCaIsolatedBunchSelector
AlCaIsolatedBunchSelector(edm::ParameterSet const &, const AlCaIsolatedBunch::Counters *count)
Definition: AlCaIsolatedBunchSelector.cc:67
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
HLTConfigProvider
Definition: HLTConfigProvider.h:29
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
AlCaIsolatedBunchSelector::globalEndJob
static void globalEndJob(const AlCaIsolatedBunch::Counters *counters)
Definition: AlCaIsolatedBunchSelector.cc:130
edm::TriggerNames
Definition: TriggerNames.h:55
AlCaIsolatedBunchSelector::nAll_
unsigned int nAll_
Definition: AlCaIsolatedBunchSelector.cc:60
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlCaIsolatedBunchSelector::filter
bool filter(edm::Event &, edm::EventSetup const &) override
Definition: AlCaIsolatedBunchSelector.cc:90
EDFilter.h
AlCaIsolatedBunch::Counters::nGood_
std::atomic< unsigned int > nGood_
Definition: AlCaIsolatedBunchFilter.cc:33
ParameterSet.h
edm::stream::EDFilter
Definition: EDFilter.h:38
edm::Event
Definition: Event.h:73
AlCaIsolatedBunchSelector::nGood_
unsigned int nGood_
Definition: AlCaIsolatedBunchSelector.cc:60
AlCaIsolatedBunchSelector::initializeGlobalCache
static std::unique_ptr< AlCaIsolatedBunch::Counters > initializeGlobalCache(edm::ParameterSet const &iConfig)
Definition: AlCaIsolatedBunchSelector.cc:42
edm::InputTag
Definition: InputTag.h:15
ValidationMatrix.hlt
hlt
Definition: ValidationMatrix.py:459