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:303
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 238 of file HLTGenValSource.cc.

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

238  {
239  // creating the collection of HLTGenValObjects
240  const std::vector<HLTGenValObject> objects = getObjectCollection(iEvent);
241 
242  // init triggerEvent, which is always needed
244  iEvent.getByToken(trigEventToken_, triggerEvent);
245 
246  // loop over all objects and fill hists
247  for (const auto& object : objects) {
248  for (auto& collection_path : collectionPath_) {
249  collection_path.fillHists(object, triggerEvent);
250  }
251  }
252 }
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 255 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.

255  {
256  iBooker.setCurrentFolder(dirName_);
257 
258  if (infoString_.back() == ',')
259  infoString_.pop_back();
260  infoString_ += "}"; // adding the closing bracked to the JSON string
261  iBooker.bookString("HLTGenValInfo", infoString_);
262 
263  // booking all histograms
264  for (long unsigned int i = 0; i < collectionPath_.size(); i++) {
265  std::vector<edm::ParameterSet> histConfigs = histConfigs_;
266  for (auto& histConfig : histConfigs) {
267  histConfig.addParameter<std::string>("pathSpecificCuts", hltPathSpecificCuts.at(i));
268  histConfig.addParameter<std::vector<edm::ParameterSet>>("binnings",
269  binnings_); // passing along the user-defined binnings
270  }
271 
272  collectionPath_.at(i).bookHists(iBooker, histConfigs, histConfigs2D_);
273  }
274 }
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_, castor_dqm_sourceclient_file_cfg::path, AlCaHLTBitMon_QueryRunRegistry::string, 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  std::string cmsswVersion = std::getenv("CMSSW_VERSION");
148  infoString_ += std::string("\"CMSSW release\":\"") + cmsswVersion + "\",";
149 
150  // Initialize hltConfig, for cross-checking whether chosen paths exist
151  bool changedConfig;
152  if (!hltConfig_.init(iRun, iSetup, hltProcessName_, changedConfig)) {
153  edm::LogError("HLTGenValSource") << "Initialization of HLTConfigProvider failed!";
154  return;
155  }
156 
157  // global tag
158  infoString_ += std::string("\"global tag\":\"") + hltConfig_.globalTag() + "\",";
159 
160  // confDB table name
161  infoString_ += std::string("\"HLT ConfDB table\":\"") + hltConfig_.tableName() + "\",";
162 
163  // Get the set of trigger paths we want to make plots for
164  std::vector<std::string> notFoundPaths;
165  for (auto const& pathToCheck : hltPathsToCheck_) {
166  // It is possible to add additional requirements to each path, seperated by a colon from the path name
167  // these additional requirements are split from the path name here
168  std::string cleanedPathToCheck;
169  std::string pathSpecificCuts = "";
170  if (pathToCheck.find(':') != std::string::npos) {
171  // splitting the string
172  std::stringstream hltPathToCheckInputStream(pathToCheck);
173  std::string hltPathToCheckInputSegment;
174  std::vector<std::string> hltPathToCheckInputSeglist;
175  while (std::getline(hltPathToCheckInputStream, hltPathToCheckInputSegment, ':')) {
176  hltPathToCheckInputSeglist.push_back(hltPathToCheckInputSegment);
177  }
178 
179  // here, exactly two parts are expected
180  if (hltPathToCheckInputSeglist.size() != 2)
181  throw cms::Exception("InputError")
182  << "Path string can not be properly split into path and cuts: please use exactly one colon!.\n";
183 
184  // the first part is the name of the path
185  cleanedPathToCheck = hltPathToCheckInputSeglist.at(0);
186 
187  // second part are the cuts, to be parsed later
188  pathSpecificCuts = hltPathToCheckInputSeglist.at(1);
189 
190  } else {
191  cleanedPathToCheck = pathToCheck;
192  }
193 
194  bool pathfound = false;
195  for (auto const& pathFromConfig : hltConfig_.triggerNames()) {
196  if (pathFromConfig.find(cleanedPathToCheck) != std::string::npos) {
197  hltPaths.push_back(pathFromConfig);
198 
199  // in case the path was added twice, we'll add a tag automatically
200  int count = std::count(hltPaths.begin(), hltPaths.end(), pathFromConfig);
201  if (count > 1) {
202  pathSpecificCuts += std::string(",autotag=v") + std::to_string(count);
203  }
204  hltPathSpecificCuts.push_back(pathSpecificCuts);
205  pathfound = true;
206  }
207  }
208  if (!pathfound)
209  notFoundPaths.push_back(cleanedPathToCheck);
210  }
211  if (!notFoundPaths.empty()) {
212  // error handling in case some paths do not exist
213  std::string notFoundPathsMessage = "";
214  for (const auto& path : notFoundPaths)
215  notFoundPathsMessage += "- " + path + "\n";
216  edm::LogError("HLTGenValSource") << "The following paths could not be found and will not be used: \n"
217  << notFoundPathsMessage << std::endl;
218  }
219 
220  // before creating the collections for each path, we'll store the needed configurations in a pset
221  // we'll copy this base multiple times and add the respective path
222  // most of these options are not needed in the pathColl, but in the filterColls created in the pathColl
223  edm::ParameterSet pathCollConfig;
224  pathCollConfig.addParameter<std::string>("objType", objType_);
225  pathCollConfig.addParameter<double>("dR2limit", dR2limit_);
226  pathCollConfig.addParameter<bool>("doOnlyLastFilter", doOnlyLastFilter_);
227  pathCollConfig.addParameter<std::string>("hltProcessName", hltProcessName_);
228 
229  // creating a histogram collection for each path
230  for (const auto& path : hltPaths) {
231  edm::ParameterSet pathCollConfigStep = pathCollConfig;
232  pathCollConfigStep.addParameter<std::string>("triggerPath", path);
233  collectionPath_.emplace_back(HLTGenValHistCollPath(pathCollConfigStep, hltConfig_));
234  }
235 }
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:135
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 277 of file HLTGenValSource.cc.

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

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

◆ getGenParticles()

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

Definition at line 418 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().

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

Referenced by getGenParticles().

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

◆ getLastCopyPreFSR()

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

Definition at line 456 of file HLTGenValSource.cc.

References BPhysicsValidation_cfi::daughters.

Referenced by getGenParticles().

456  {
457  const auto& daughters = part.daughterRefVector();
458  if (daughters.size() == 1 && daughters.at(0)->pdgId() == part.pdgId())
459  return getLastCopyPreFSR(*daughters.at(0).get()); // recursion, whooo
460  else
461  return part;
462 }
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 362 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().

362  {
363  std::vector<HLTGenValObject> objects; // the vector of objects to be filled
364 
365  // handle object type
366  std::vector<std::string> implementedGenParticles = {"ele", "pho", "mu", "tau"};
367  if (std::find(implementedGenParticles.begin(), implementedGenParticles.end(), objType_) !=
368  implementedGenParticles.end()) {
370  } else if (objType_ == "AK4jet") { // ak4 jets, using the ak4GenJets collection
371  const auto& genJets = iEvent.getHandle(ak4genJetToken_);
372  for (size_t i = 0; i < genJets->size(); i++) {
373  const reco::GenJet p = (*genJets)[i];
374  objects.emplace_back(p);
375  }
376  } else if (objType_ == "AK8jet") { // ak8 jets, using the ak8GenJets collection
377  const auto& genJets = iEvent.getHandle(ak8genJetToken_);
378  for (size_t i = 0; i < genJets->size(); i++) {
379  const reco::GenJet p = (*genJets)[i];
380  objects.emplace_back(p);
381  }
382  } else if (objType_ == "AK4HT") { // ak4-based HT, using the ak4GenJets collection
383  const auto& genJets = iEvent.getHandle(ak4genJetToken_);
384  if (!genJets->empty()) {
385  double HTsum = 0.;
386  for (const auto& genJet : *genJets) {
387  if (genJet.pt() > 30 && std::abs(genJet.eta()) < 2.5)
388  HTsum += genJet.pt();
389  }
390  if (HTsum > 0)
391  objects.emplace_back(reco::Candidate::PolarLorentzVector(HTsum, 0, 0, 0));
392  }
393  } else if (objType_ == "AK8HT") { // ak8-based HT, using the ak8GenJets collection
394  const auto& genJets = iEvent.getHandle(ak8genJetToken_);
395  if (!genJets->empty()) {
396  double HTsum = 0.;
397  for (const auto& genJet : *genJets) {
398  if (genJet.pt() > 200 && std::abs(genJet.eta()) < 2.5)
399  HTsum += genJet.pt();
400  }
401  if (HTsum > 0)
402  objects.emplace_back(reco::Candidate::PolarLorentzVector(HTsum, 0, 0, 0));
403  }
404  } else if (objType_ == "MET") { // MET, using genMET
405  const auto& genMET = iEvent.getHandle(genMETToken_);
406  if (!genMET->empty()) {
407  auto genMETpt = (*genMET)[0].pt();
408  objects.emplace_back(reco::Candidate::PolarLorentzVector(genMETpt, 0, 0, 0));
409  }
410  } else
411  throw cms::Exception("InputError") << "Generator-level validation is not available for type " << objType_ << ".\n"
412  << "Please check for a potential spelling error.\n";
413 
414  return objects;
415 }
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().