CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
HLTGenValSource Class Reference
Inheritance diagram for HLTGenValSource:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

 HLTGenValSource (const edm::ParameterSet &)
 
 HLTGenValSource (const HLTGenValSource &)=delete
 
HLTGenValSourceoperator= (const HLTGenValSource &)=delete
 
 ~HLTGenValSource () override=default
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &run, edm::EventSetup const &c) override
 
void dqmBeginRun (const edm::Run &, const edm::EventSetup &) override
 
std::vector< HLTGenValObjectgetGenParticles (const edm::Event &)
 
reco::GenParticle getLastCopy (reco::GenParticle part)
 
reco::GenParticle getLastCopyPreFSR (reco::GenParticle part)
 
std::vector< HLTGenValObjectgetObjectCollection (const edm::Event &)
 

Private Attributes

const edm::EDGetTokenT< reco::GenJetCollectionak4genJetToken_
 
const edm::EDGetTokenT< reco::GenJetCollectionak8genJetToken_
 
std::vector< edm::ParameterSetbinnings_
 
std::vector< HLTGenValHistCollPathcollectionPath_
 
std::string dirName_
 
bool doOnlyLastFilter_
 
double dR2limit_
 
const edm::EDGetTokenT< reco::GenMETCollectiongenMETToken_
 
const edm::EDGetTokenT< reco::GenParticleCollectiongenParticleToken_
 
std::vector< edm::ParameterSethistConfigs2D_
 
std::vector< edm::ParameterSethistConfigs_
 
HLTConfigProvider hltConfig_
 
std::vector< std::string > hltPaths
 
std::vector< std::string > hltPathSpecificCuts
 
std::vector< std::string > hltPathsToCheck_
 
std::string hltProcessName_
 
std::string infoString_ = "{"
 
std::string objType_
 
const edm::EDGetTokenT< trigger::TriggerEventtrigEventToken_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

Definition at line 55 of file HLTGenValSource.cc.

Constructor & Destructor Documentation

◆ HLTGenValSource() [1/2]

HLTGenValSource::HLTGenValSource ( const edm::ParameterSet iConfig)
explicit

Definition at line 110 of file HLTGenValSource.cc.

References binnings_, dirName_, doOnlyLastFilter_, dR2limit_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSetVector(), histConfigs2D_, histConfigs_, hltPathsToCheck_, hltProcessName_, objType_, and AlCaHLTBitMon_QueryRunRegistry::string.

111  : genParticleToken_(consumes<reco::GenParticleCollection>(
112  iConfig.getParameterSet("inputCollections").getParameter<edm::InputTag>("genParticles"))),
113  genMETToken_(consumes<reco::GenMETCollection>(
114  iConfig.getParameterSet("inputCollections").getParameter<edm::InputTag>("genMET"))),
115  ak4genJetToken_(consumes<reco::GenJetCollection>(
116  iConfig.getParameterSet("inputCollections").getParameter<edm::InputTag>("ak4GenJets"))),
117  ak8genJetToken_(consumes<reco::GenJetCollection>(
118  iConfig.getParameterSet("inputCollections").getParameter<edm::InputTag>("ak8GenJets"))),
119  trigEventToken_(consumes<trigger::TriggerEvent>(
120  iConfig.getParameterSet("inputCollections").getParameter<edm::InputTag>("TrigEvent"))) {
121  // getting the histogram configurations
122  histConfigs_ = iConfig.getParameterSetVector("histConfigs");
123  histConfigs2D_ = iConfig.getParameterSetVector("histConfigs2D");
124  binnings_ = iConfig.getParameterSetVector("binnings");
125 
126  // getting all other configurations
127  dirName_ = iConfig.getParameter<std::string>("dqmDirName");
128  objType_ = iConfig.getParameter<std::string>("objType");
129  dR2limit_ = iConfig.getParameter<double>("dR2limit");
130  doOnlyLastFilter_ = iConfig.getParameter<bool>("doOnlyLastFilter");
131  hltProcessName_ = iConfig.getParameter<std::string>("hltProcessName");
132  hltPathsToCheck_ = iConfig.getParameter<std::vector<std::string>>("hltPathsToCheck");
133 }
std::string objType_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string hltProcessName_
ParameterSet const & getParameterSet(std::string const &) const
std::vector< edm::ParameterSet > binnings_
const edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
const edm::EDGetTokenT< reco::GenJetCollection > ak8genJetToken_
std::vector< std::string > hltPathsToCheck_
const edm::EDGetTokenT< trigger::TriggerEvent > trigEventToken_
const edm::EDGetTokenT< reco::GenJetCollection > ak4genJetToken_
std::vector< edm::ParameterSet > histConfigs_
std::string dirName_
std::vector< edm::ParameterSet > histConfigs2D_
VParameterSet const & getParameterSetVector(std::string const &name) const
const edm::EDGetTokenT< reco::GenMETCollection > genMETToken_

◆ ~HLTGenValSource()

HLTGenValSource::~HLTGenValSource ( )
overridedefault

◆ HLTGenValSource() [2/2]

HLTGenValSource::HLTGenValSource ( const HLTGenValSource )
delete

Member Function Documentation

◆ analyze()

void HLTGenValSource::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 239 of file HLTGenValSource.cc.

References collectionPath_, getObjectCollection(), iEvent, trigEventToken_, and PDWG_DiPhoton_SD_cff::triggerEvent.

239  {
240  // creating the collection of HLTGenValObjects
241  const std::vector<HLTGenValObject> objects = getObjectCollection(iEvent);
242 
243  // init triggerEvent, which is always needed
245  iEvent.getByToken(trigEventToken_, triggerEvent);
246 
247  // loop over all objects and fill hists
248  for (const auto& object : objects) {
249  for (auto& collection_path : collectionPath_) {
250  collection_path.fillHists(object, triggerEvent);
251  }
252  }
253 }
int iEvent
Definition: GenABIO.cc:224
std::vector< HLTGenValObject > getObjectCollection(const edm::Event &)
const edm::EDGetTokenT< trigger::TriggerEvent > trigEventToken_
std::vector< HLTGenValHistCollPath > collectionPath_

◆ bookHistograms()

void HLTGenValSource::bookHistograms ( DQMStore::IBooker iBooker,
edm::Run const &  run,
edm::EventSetup const &  c 
)
overrideprivatevirtual

Implements DQMEDAnalyzer.

Definition at line 256 of file HLTGenValSource.cc.

References binnings_, dqm::implementation::IBooker::bookString(), collectionPath_, dirName_, B2GTnPMonitor_cfi::histConfigs, histConfigs2D_, histConfigs_, hltPathSpecificCuts, mps_fire::i, infoString_, dqm::implementation::NavigatorBase::setCurrentFolder(), and AlCaHLTBitMon_QueryRunRegistry::string.

256  {
257  iBooker.setCurrentFolder(dirName_);
258 
259  if (infoString_.back() == ',')
260  infoString_.pop_back();
261  infoString_ += "}"; // adding the closing bracked to the JSON string
262  iBooker.bookString("HLTGenValInfo", infoString_);
263 
264  // booking all histograms
265  for (long unsigned int i = 0; i < collectionPath_.size(); i++) {
266  std::vector<edm::ParameterSet> histConfigs = histConfigs_;
267  for (auto& histConfig : histConfigs) {
268  histConfig.addParameter<std::string>("pathSpecificCuts", hltPathSpecificCuts.at(i));
269  histConfig.addParameter<std::vector<edm::ParameterSet>>("binnings",
270  binnings_); // passing along the user-defined binnings
271  }
272 
273  collectionPath_.at(i).bookHists(iBooker, histConfigs, histConfigs2D_);
274  }
275 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::vector< edm::ParameterSet > binnings_
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
Definition: DQMStore.h:87
std::string infoString_
std::vector< edm::ParameterSet > histConfigs_
std::string dirName_
std::vector< edm::ParameterSet > histConfigs2D_
std::vector< std::string > hltPathSpecificCuts
std::vector< HLTGenValHistCollPath > collectionPath_

◆ dqmBeginRun()

void HLTGenValSource::dqmBeginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 135 of file HLTGenValSource.cc.

References edm::ParameterSet::addParameter(), testInputFiles_cff::cmsswVersion, collectionPath_, submitPVResolutionJobs::count, doOnlyLastFilter_, dR2limit_, HLTConfigProvider::globalTag(), hltConfig_, hltPaths, hltPathSpecificCuts, hltPathsToCheck_, hltProcessName_, infoString_, HLTConfigProvider::init(), objType_, EnsembleCalibrationLA_cfg::path, AlCaHLTBitMon_QueryRunRegistry::string, suppress, submitPVValidationJobs::t, HLTConfigProvider::tableName(), hcalRecHitTable_cff::time, to_string(), and HLTConfigProvider::triggerNames().

135  {
136  // writing general information to info JSON
137  auto t = std::time(nullptr);
138  auto tm = *std::localtime(&t);
139 
140  // date and time of running this
141  std::ostringstream timeStringStream;
142  timeStringStream << std::put_time(&tm, "%d-%m-%Y %H-%M-%S");
143  auto timeString = timeStringStream.str();
144  infoString_ += "\"date & time\":\"" + timeString + "\",";
145 
146  // CMSSW version
147  [[clang::suppress]]
148  std::string cmsswVersion = std::getenv("CMSSW_VERSION");
149  infoString_ += std::string("\"CMSSW release\":\"") + cmsswVersion + "\",";
150 
151  // Initialize hltConfig, for cross-checking whether chosen paths exist
152  bool changedConfig;
153  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
154  edm::LogError("HLTGenValSource") << "Initialization of HLTConfigProvider failed!";
155  return;
156  }
157 
158  // global tag
159  infoString_ += std::string("\"global tag\":\"") + hltConfig_.globalTag() + "\",";
160 
161  // confDB table name
162  infoString_ += std::string("\"HLT ConfDB table\":\"") + hltConfig_.tableName() + "\",";
163 
164  // Get the set of trigger paths we want to make plots for
165  std::vector<std::string> notFoundPaths;
166  for (auto const& pathToCheck : hltPathsToCheck_) {
167  // It is possible to add additional requirements to each path, seperated by a colon from the path name
168  // these additional requirements are split from the path name here
169  std::string cleanedPathToCheck;
170  std::string pathSpecificCuts = "";
171  if (pathToCheck.find(':') != std::string::npos) {
172  // splitting the string
173  std::stringstream hltPathToCheckInputStream(pathToCheck);
174  std::string hltPathToCheckInputSegment;
175  std::vector<std::string> hltPathToCheckInputSeglist;
176  while (std::getline(hltPathToCheckInputStream, hltPathToCheckInputSegment, ':')) {
177  hltPathToCheckInputSeglist.push_back(hltPathToCheckInputSegment);
178  }
179 
180  // here, exactly two parts are expected
181  if (hltPathToCheckInputSeglist.size() != 2)
182  throw cms::Exception("InputError")
183  << "Path string can not be properly split into path and cuts: please use exactly one colon!.\n";
184 
185  // the first part is the name of the path
186  cleanedPathToCheck = hltPathToCheckInputSeglist.at(0);
187 
188  // second part are the cuts, to be parsed later
189  pathSpecificCuts = hltPathToCheckInputSeglist.at(1);
190 
191  } else {
192  cleanedPathToCheck = pathToCheck;
193  }
194 
195  bool pathfound = false;
196  for (auto const& pathFromConfig : hltConfig_.triggerNames()) {
197  if (pathFromConfig.find(cleanedPathToCheck) != std::string::npos) {
198  hltPaths.push_back(pathFromConfig);
199 
200  // in case the path was added twice, we'll add a tag automatically
201  int count = std::count(hltPaths.begin(), hltPaths.end(), pathFromConfig);
202  if (count > 1) {
203  pathSpecificCuts += std::string(",autotag=v") + std::to_string(count);
204  }
205  hltPathSpecificCuts.push_back(pathSpecificCuts);
206  pathfound = true;
207  }
208  }
209  if (!pathfound)
210  notFoundPaths.push_back(cleanedPathToCheck);
211  }
212  if (!notFoundPaths.empty()) {
213  // error handling in case some paths do not exist
214  std::string notFoundPathsMessage = "";
215  for (const auto& path : notFoundPaths)
216  notFoundPathsMessage += "- " + path + "\n";
217  edm::LogError("HLTGenValSource") << "The following paths could not be found and will not be used: \n"
218  << notFoundPathsMessage << std::endl;
219  }
220 
221  // before creating the collections for each path, we'll store the needed configurations in a pset
222  // we'll copy this base multiple times and add the respective path
223  // most of these options are not needed in the pathColl, but in the filterColls created in the pathColl
224  edm::ParameterSet pathCollConfig;
225  pathCollConfig.addParameter<std::string>("objType", objType_);
226  pathCollConfig.addParameter<double>("dR2limit", dR2limit_);
227  pathCollConfig.addParameter<bool>("doOnlyLastFilter", doOnlyLastFilter_);
228  pathCollConfig.addParameter<std::string>("hltProcessName", hltProcessName_);
229 
230  // creating a histogram collection for each path
231  for (const auto& path : hltPaths) {
232  edm::ParameterSet pathCollConfigStep = pathCollConfig;
233  pathCollConfigStep.addParameter<std::string>("triggerPath", path);
234  collectionPath_.emplace_back(HLTGenValHistCollPath(pathCollConfigStep, hltConfig_));
235  }
236 }
std::string objType_
std::string hltProcessName_
const std::string & globalTag() const
global tag
std::vector< std::string > hltPaths
Log< level::Error, false > LogError
static std::string to_string(const XMLCh *ch)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
std::string infoString_
std::vector< std::string > hltPathsToCheck_
HLTConfigProvider hltConfig_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< std::string > hltPathSpecificCuts
const std::vector< std::string > & triggerNames() const
names of trigger paths
const std::string & tableName() const
HLT ConfDB table name.
std::vector< HLTGenValHistCollPath > collectionPath_

◆ fillDescriptions()

void HLTGenValSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 278 of file HLTGenValSource.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addDefault(), edm::ParameterSet::addParameter(), submitPVResolutionJobs::desc, ProducerED_cfi::InputTag, and AlCaHLTBitMon_QueryRunRegistry::string.

278  {
280 
281  // basic parameter strings
282  desc.add<std::string>(
283  "objType"); // this deliberately has no default, as this is the main thing the user needs to chose
284  desc.add<std::vector<std::string>>(
285  "hltPathsToCheck"); // this for the moment also has no default: maybe there can be some way to handle this later?
286  desc.add<std::string>("dqmDirName", "HLTGenVal");
287  desc.add<std::string>("hltProcessName", "HLT");
288  desc.add<double>("dR2limit", 0.1);
289  desc.add<bool>("doOnlyLastFilter", false);
290 
291  // input collections, a PSet
292  edm::ParameterSetDescription inputCollections;
293  inputCollections.add<edm::InputTag>("genParticles", edm::InputTag("genParticles"));
294  inputCollections.add<edm::InputTag>("genMET", edm::InputTag("genMetTrue"));
295  inputCollections.add<edm::InputTag>("ak4GenJets", edm::InputTag("ak4GenJets"));
296  inputCollections.add<edm::InputTag>("ak8GenJets", edm::InputTag("ak8GenJets"));
297  inputCollections.add<edm::InputTag>("TrigEvent", edm::InputTag("hltTriggerSummaryAOD"));
298  desc.add<edm::ParameterSetDescription>("inputCollections", inputCollections);
299 
300  // hist descriptors, which are a vector of PSets
301 
302  // defining single histConfig
303  // this is generally without default, but a default set of histConfigs is specified below
304  edm::ParameterSetDescription histConfig;
305  histConfig.add<std::string>("vsVar");
306  histConfig.add<std::vector<double>>("binLowEdges");
307  histConfig.addVPSet(
308  "rangeCuts", VarRangeCut<HLTGenValObject>::makePSetDescription(), std::vector<edm::ParameterSet>());
309 
310  // default set of histConfigs
311  std::vector<edm::ParameterSet> histConfigDefaults;
312 
313  edm::ParameterSet histConfigDefault0;
314  histConfigDefault0.addParameter<std::string>("vsVar", "pt");
315  std::vector<double> defaultPtBinning{0, 5, 10, 12.5, 15, 17.5, 20, 22.5, 25, 30, 35, 40,
316  45, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400};
317  histConfigDefault0.addParameter<std::vector<double>>("binLowEdges", defaultPtBinning);
318  histConfigDefaults.push_back(histConfigDefault0);
319 
320  edm::ParameterSet histConfigDefault1;
321  histConfigDefault1.addParameter<std::string>("vsVar", "eta");
322  std::vector<double> defaultetaBinning{-10, -8, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 8, 10};
323  histConfigDefault1.addParameter<std::vector<double>>("binLowEdges", defaultetaBinning);
324  histConfigDefaults.push_back(histConfigDefault1);
325 
326  desc.addVPSet("histConfigs", histConfig, histConfigDefaults);
327 
328  // defining single histConfig2D
329  edm::ParameterSetDescription histConfig2D;
330  histConfig2D.add<std::string>("vsVarX");
331  histConfig2D.add<std::string>("vsVarY");
332  histConfig2D.add<std::vector<double>>("binLowEdgesX");
333  histConfig2D.add<std::vector<double>>("binLowEdgesY");
334 
335  // default set of histConfigs
336  std::vector<edm::ParameterSet> histConfigDefaults2D;
337 
338  edm::ParameterSet histConfigDefault2D0;
339  histConfigDefault2D0.addParameter<std::string>("vsVarX", "pt");
340  histConfigDefault2D0.addParameter<std::string>("vsVarY", "eta");
341  histConfigDefault2D0.addParameter<std::vector<double>>("binLowEdgesX", defaultPtBinning);
342  histConfigDefault2D0.addParameter<std::vector<double>>("binLowEdgesY", defaultetaBinning);
343  histConfigDefaults2D.push_back(histConfigDefault2D0);
344 
345  desc.addVPSet("histConfigs2D", histConfig2D, histConfigDefaults2D);
346 
347  // binnings, which are vectors of PSets
348  // there are no default for this
349  edm::ParameterSetDescription binningConfig;
350  binningConfig.add<std::string>("name");
351  binningConfig.add<std::string>("vsVar");
352  binningConfig.add<std::vector<double>>("binLowEdges");
353 
354  // this by default is empty
355  std::vector<edm::ParameterSet> binningConfigDefaults;
356 
357  desc.addVPSet("binnings", binningConfig, binningConfigDefaults);
358 
359  descriptions.addDefault(desc);
360 }
void addDefault(ParameterSetDescription const &psetDescription)
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ getGenParticles()

std::vector< HLTGenValObject > HLTGenValSource::getGenParticles ( const edm::Event iEvent)
private

Definition at line 419 of file HLTGenValSource.cc.

References funct::abs(), AJJGenJetFilter_cfi::genParticles, genParticleToken_, getLastCopy(), getLastCopyPreFSR(), mps_fire::i, iEvent, L1TPhase2Offline_cfi::objects, objType_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by getObjectCollection().

419  {
420  std::vector<HLTGenValObject> objects; // vector to be filled
421 
422  const auto& genParticles = iEvent.getHandle(genParticleToken_); // getting all GenParticles
423 
424  // we need to ge the ID corresponding to the desired GenParticle type
425  int pdgID = -1; // setting to -1 should not be needed, but prevents the compiler warning :)
426  if (objType_ == "ele")
427  pdgID = 11;
428  else if (objType_ == "pho")
429  pdgID = 22;
430  else if (objType_ == "mu")
431  pdgID = 13;
432  else if (objType_ == "tau")
433  pdgID = 15;
434 
435  // main loop over GenParticles
436  for (size_t i = 0; i < genParticles->size(); ++i) {
437  const reco::GenParticle p = (*genParticles)[i];
438 
439  // only GenParticles with correct ID
440  if (std::abs(p.pdgId()) != pdgID)
441  continue;
442 
443  // checking if particle comes from "hard process"
444  if (p.isHardProcess()) {
445  // depending on the particle type, last particle before or after FSR is chosen
446  if ((objType_ == "ele") || (objType_ == "pho"))
447  objects.emplace_back(getLastCopyPreFSR(p));
448  else if ((objType_ == "mu") || (objType_ == "tau"))
449  objects.emplace_back(getLastCopy(p));
450  }
451  }
452 
453  return objects;
454 }
std::string objType_
reco::GenParticle getLastCopy(reco::GenParticle part)
const edm::EDGetTokenT< reco::GenParticleCollection > genParticleToken_
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::GenParticle getLastCopyPreFSR(reco::GenParticle part)

◆ getLastCopy()

reco::GenParticle HLTGenValSource::getLastCopy ( reco::GenParticle  part)
private

Definition at line 466 of file HLTGenValSource.cc.

Referenced by getGenParticles().

466  {
467  for (const auto& daughter : part.daughterRefVector()) {
468  if (daughter->pdgId() == part.pdgId())
469  return getLastCopy(*daughter.get());
470  }
471  return part;
472 }
reco::GenParticle getLastCopy(reco::GenParticle part)
part
Definition: HCALResponse.h:20

◆ getLastCopyPreFSR()

reco::GenParticle HLTGenValSource::getLastCopyPreFSR ( reco::GenParticle  part)
private

Definition at line 457 of file HLTGenValSource.cc.

References BPhysicsValidation_cfi::daughters.

Referenced by getGenParticles().

457  {
458  const auto& daughters = part.daughterRefVector();
459  if (daughters.size() == 1 && daughters.at(0)->pdgId() == part.pdgId())
460  return getLastCopyPreFSR(*daughters.at(0).get()); // recursion, whooo
461  else
462  return part;
463 }
part
Definition: HCALResponse.h:20
reco::GenParticle getLastCopyPreFSR(reco::GenParticle part)

◆ getObjectCollection()

std::vector< HLTGenValObject > HLTGenValSource::getObjectCollection ( const edm::Event iEvent)
private

Definition at line 363 of file HLTGenValSource.cc.

References funct::abs(), ak4genJetToken_, ak8genJetToken_, Exception, spr::find(), l1tCaloJetHTTProducer_cfi::genJets, genMETToken_, getGenParticles(), mps_fire::i, iEvent, L1TPhase2Offline_cfi::objects, objType_, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by analyze().

363  {
364  std::vector<HLTGenValObject> objects; // the vector of objects to be filled
365 
366  // handle object type
367  std::vector<std::string> implementedGenParticles = {"ele", "pho", "mu", "tau"};
368  if (std::find(implementedGenParticles.begin(), implementedGenParticles.end(), objType_) !=
369  implementedGenParticles.end()) {
371  } else if (objType_ == "AK4jet") { // ak4 jets, using the ak4GenJets collection
372  const auto& genJets = iEvent.getHandle(ak4genJetToken_);
373  for (size_t i = 0; i < genJets->size(); i++) {
374  const reco::GenJet p = (*genJets)[i];
375  objects.emplace_back(p);
376  }
377  } else if (objType_ == "AK8jet") { // ak8 jets, using the ak8GenJets collection
378  const auto& genJets = iEvent.getHandle(ak8genJetToken_);
379  for (size_t i = 0; i < genJets->size(); i++) {
380  const reco::GenJet p = (*genJets)[i];
381  objects.emplace_back(p);
382  }
383  } else if (objType_ == "AK4HT") { // ak4-based HT, using the ak4GenJets collection
384  const auto& genJets = iEvent.getHandle(ak4genJetToken_);
385  if (!genJets->empty()) {
386  double HTsum = 0.;
387  for (const auto& genJet : *genJets) {
388  if (genJet.pt() > 30 && std::abs(genJet.eta()) < 2.5)
389  HTsum += genJet.pt();
390  }
391  if (HTsum > 0)
392  objects.emplace_back(reco::Candidate::PolarLorentzVector(HTsum, 0, 0, 0));
393  }
394  } else if (objType_ == "AK8HT") { // ak8-based HT, using the ak8GenJets collection
395  const auto& genJets = iEvent.getHandle(ak8genJetToken_);
396  if (!genJets->empty()) {
397  double HTsum = 0.;
398  for (const auto& genJet : *genJets) {
399  if (genJet.pt() > 200 && std::abs(genJet.eta()) < 2.5)
400  HTsum += genJet.pt();
401  }
402  if (HTsum > 0)
403  objects.emplace_back(reco::Candidate::PolarLorentzVector(HTsum, 0, 0, 0));
404  }
405  } else if (objType_ == "MET") { // MET, using genMET
406  const auto& genMET = iEvent.getHandle(genMETToken_);
407  if (!genMET->empty()) {
408  auto genMETpt = (*genMET)[0].pt();
409  objects.emplace_back(reco::Candidate::PolarLorentzVector(genMETpt, 0, 0, 0));
410  }
411  } else
412  throw cms::Exception("InputError") << "Generator-level validation is not available for type " << objType_ << ".\n"
413  << "Please check for a potential spelling error.\n";
414 
415  return objects;
416 }
std::string objType_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Jets made from MC generator particles.
Definition: GenJet.h:23
const edm::EDGetTokenT< reco::GenJetCollection > ak8genJetToken_
const edm::EDGetTokenT< reco::GenJetCollection > ak4genJetToken_
std::vector< HLTGenValObject > getGenParticles(const edm::Event &)
const edm::EDGetTokenT< reco::GenMETCollection > genMETToken_
math::PtEtaPhiMLorentzVector PolarLorentzVector
Lorentz vector.
Definition: Candidate.h:38

◆ operator=()

HLTGenValSource& HLTGenValSource::operator= ( const HLTGenValSource )
delete

Member Data Documentation

◆ ak4genJetToken_

const edm::EDGetTokenT<reco::GenJetCollection> HLTGenValSource::ak4genJetToken_
private

Definition at line 80 of file HLTGenValSource.cc.

Referenced by getObjectCollection().

◆ ak8genJetToken_

const edm::EDGetTokenT<reco::GenJetCollection> HLTGenValSource::ak8genJetToken_
private

Definition at line 81 of file HLTGenValSource.cc.

Referenced by getObjectCollection().

◆ binnings_

std::vector<edm::ParameterSet> HLTGenValSource::binnings_
private

Definition at line 89 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and HLTGenValSource().

◆ collectionPath_

std::vector<HLTGenValHistCollPath> HLTGenValSource::collectionPath_
private

Definition at line 97 of file HLTGenValSource.cc.

Referenced by analyze(), bookHistograms(), and dqmBeginRun().

◆ dirName_

std::string HLTGenValSource::dirName_
private

Definition at line 86 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and HLTGenValSource().

◆ doOnlyLastFilter_

bool HLTGenValSource::doOnlyLastFilter_
private

Definition at line 107 of file HLTGenValSource.cc.

Referenced by dqmBeginRun(), and HLTGenValSource().

◆ dR2limit_

double HLTGenValSource::dR2limit_
private

Definition at line 106 of file HLTGenValSource.cc.

Referenced by dqmBeginRun(), and HLTGenValSource().

◆ genMETToken_

const edm::EDGetTokenT<reco::GenMETCollection> HLTGenValSource::genMETToken_
private

Definition at line 79 of file HLTGenValSource.cc.

Referenced by getObjectCollection().

◆ genParticleToken_

const edm::EDGetTokenT<reco::GenParticleCollection> HLTGenValSource::genParticleToken_
private

Definition at line 78 of file HLTGenValSource.cc.

Referenced by getGenParticles().

◆ histConfigs2D_

std::vector<edm::ParameterSet> HLTGenValSource::histConfigs2D_
private

Definition at line 88 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and HLTGenValSource().

◆ histConfigs_

std::vector<edm::ParameterSet> HLTGenValSource::histConfigs_
private

Definition at line 87 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and HLTGenValSource().

◆ hltConfig_

HLTConfigProvider HLTGenValSource::hltConfig_
private

Definition at line 100 of file HLTGenValSource.cc.

Referenced by dqmBeginRun().

◆ hltPaths

std::vector<std::string> HLTGenValSource::hltPaths
private

Definition at line 104 of file HLTGenValSource.cc.

Referenced by dqmBeginRun().

◆ hltPathSpecificCuts

std::vector<std::string> HLTGenValSource::hltPathSpecificCuts
private

Definition at line 105 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and dqmBeginRun().

◆ hltPathsToCheck_

std::vector<std::string> HLTGenValSource::hltPathsToCheck_
private

Definition at line 103 of file HLTGenValSource.cc.

Referenced by dqmBeginRun(), and HLTGenValSource().

◆ hltProcessName_

std::string HLTGenValSource::hltProcessName_
private

Definition at line 90 of file HLTGenValSource.cc.

Referenced by dqmBeginRun(), and HLTGenValSource().

◆ infoString_

std::string HLTGenValSource::infoString_ = "{"
private

Definition at line 94 of file HLTGenValSource.cc.

Referenced by bookHistograms(), and dqmBeginRun().

◆ objType_

std::string HLTGenValSource::objType_
private

◆ trigEventToken_

const edm::EDGetTokenT<trigger::TriggerEvent> HLTGenValSource::trigEventToken_
private

Definition at line 82 of file HLTGenValSource.cc.

Referenced by analyze().