Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
b606d97
adding initial skeleton of source
Sam-Harper Sep 23, 2021
42a6f83
First try playing around with the code
Oct 5, 2021
17818a3
First tries with a client module
Oct 18, 2021
f66e924
Last commit playing around
Oct 21, 2021
dba8f84
deleting everything to get a clean start
Oct 21, 2021
5b2de12
First GEN hist test code
Oct 22, 2021
da2774a
implemented before hists
Oct 27, 2021
34d7f26
First working filter application
Nov 2, 2021
6320ffa
code cleanup
Nov 5, 2021
8f7fd12
config file split
Nov 10, 2021
739d7ce
added client
Nov 10, 2021
de3c4d7
added EDtoEDM
Nov 10, 2021
a718b0b
using DQMGenericClient for efficiencies
Nov 11, 2021
6773d7e
moved config file to test dir
Nov 11, 2021
b9a05b4
Created copy of DQMGenericClient
Nov 11, 2021
6e72d41
Auto-detect which efficiencies to calculate in client
Nov 11, 2021
1afd674
Added intermediate HLTGenValObject
Nov 16, 2021
295e700
Included GenJets, first working version
Nov 16, 2021
caec0e2
Fixes to GenJet case
Nov 16, 2021
e0b058e
removed not needed code from client module
Nov 18, 2021
dc61925
Added GenParticle status check
Nov 18, 2021
53a9eaa
Removed useless lines in config gile
Nov 18, 2021
1f3afe0
Added pset descriptions and defaults
Nov 24, 2021
600e75f
Small fix in test file
Nov 24, 2021
d7ae619
Removed not needed definition from test config
Nov 24, 2021
98239b1
Removed debugging cout in Client
Nov 24, 2021
1f874fb
Simplified filter determination from path
Nov 25, 2021
15a6232
Now splitting between AK4 and AK8
Nov 25, 2021
851c5c9
first try identifying only hard process
Nov 26, 2021
697b951
Added cuts to hists and small bugfix
Dec 3, 2021
2cd9cb0
removed some debugging couts
Dec 3, 2021
7846f51
Added GenVal HT handling
Dec 3, 2021
e247fa6
Added deltaR2 as variable parameter
Dec 14, 2021
50507c9
Added 2D histogram functionality
Dec 14, 2021
dc07589
Removed more useless code from client
Dec 14, 2021
82f83c6
Added 2D efficienc plots
Dec 14, 2021
e4727d2
Major code cleanup
Jan 19, 2022
7ceede7
added MET handling
Jan 19, 2022
44af71b
Added doOnlyLastFilter option
Jan 19, 2022
38eab7e
Updated histogram naming scheme
Jan 21, 2022
c95bcec
Put 'before' hists to top level
Jan 21, 2022
5b6b425
changed underscore names to camelCase
Jan 21, 2022
8ae40bc
Removed namespaces usings
Jan 21, 2022
8ed3b42
Moved code to cc files
Jan 24, 2022
1b8b72c
Renaming to fulfill CMS coding rules
Jan 28, 2022
7a051bd
misssed one name
Jan 28, 2022
a74bcee
bugfix from error in renaming
Jan 28, 2022
45570b1
Removing useless code from client
Jan 28, 2022
02250dc
re-added setEfficiencyFlag now that I know what it does
Feb 3, 2022
bf5451b
new test sample in config
Feb 3, 2022
0ed5f46
fixed wrong file format in config
Feb 3, 2022
1057333
moved all plots to top level
Feb 3, 2022
b9a08df
Collections are now configured by single PSET
Feb 10, 2022
5446d54
added pset descriptions to coll classes
Feb 10, 2022
58a8524
Polishing code to fulfill CMS style. adding comments
Feb 11, 2022
d98d33b
Basic muon trigger test case
Feb 11, 2022
b0aa765
Removing leading - from filter names
Feb 22, 2022
834a0d4
Removed status == 1, isHardProcess is enough
Feb 22, 2022
acfe760
many small changes to address Sams comments
Feb 22, 2022
57574ff
small style changes in type derivation of efficHist
Feb 28, 2022
f4b8027
Adding option to give add a tag
Mar 3, 2022
70a4c95
Adding GEN jet pt and eta thresholds for GEN HT
Mar 3, 2022
1b1b202
Added strings containing filters for each path to output file
Mar 3, 2022
6c38207
fixed bug in path-string creation
Mar 13, 2022
de38045
removed leading - also in pathstrings
Mar 13, 2022
bbb64d0
Added objType to pathstring name
Mar 14, 2022
481a2dc
Full example
Mar 31, 2022
28b431a
Added run 4 test config file
Apr 22, 2022
222fa2a
Preventing double-filling with a quick and dirty solution
Jun 8, 2022
9c1e540
undo ugly fix
Jun 13, 2022
4dee005
Proper fix for efficiencies > 1
Jun 14, 2022
fe6aed0
First version of path-specific cuts
Jun 16, 2022
4c7e46f
Passing path-specific cuts on via histConfig pset
Jun 17, 2022
4ac22c7
Join cuts on pset level, not VarRangeCutColl level
Jun 17, 2022
b7dcbc5
Added more path-specific cut options
Jun 17, 2022
d574085
moved path-specific cut parser to its own class
Jun 28, 2022
78d8e95
Adding variable binning
Jun 28, 2022
d21f055
added path to histogram names to allow varied cuts
Jun 29, 2022
fe57a44
Adding error-handling to prevent setting multiple binnings
Jun 29, 2022
a2fe9cf
allow to specify binnings for each path, using config file definition
Jul 1, 2022
dfb756d
code cleanup
Jul 1, 2022
3b7f6c2
adding renamed pathspecific settings
Jul 1, 2022
894e219
Coding style changes
Jul 1, 2022
bc7b837
more style fixes
Jul 1, 2022
dfd181d
Updated region definition
Jul 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions DQMOffline/Trigger/src/FunctionDefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ std::function<float(const reco::Photon&)> hltdqm::getUnaryFuncExtraFloat<reco::P
varFunc = [](const reco::Photon& pho) -> float { return pho.hadTowOverEm(); };
return varFunc;
}

//hack to put the function definitions in the non-plugin libary
//so they can be used by other packages
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/MuonReco/interface/Muon.h"
auto testPho = hltdqm::getUnaryFuncFloat<reco::Photon>("et");
auto testEle = hltdqm::getUnaryFuncFloat<reco::GsfElectron>("et");
auto testMu = hltdqm::getUnaryFuncFloat<reco::Muon>("et");
13 changes: 13 additions & 0 deletions Validation/HLTrigger/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<use name="CommonTools/TriggerUtils"/>
<use name="DQMOffline/Trigger"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/ServiceRegistry"/>
<use name="DataFormats/HLTReco"/>
<use name="HLTrigger/HLTcore"/>
<use name="DQMServices/Core"/>
<use name="CommonTools/Utils"/>
<use name="root"/>
<export>
<lib name="1"/>
</export>
84 changes: 84 additions & 0 deletions Validation/HLTrigger/interface/HLTGenValHist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#ifndef Validation_HLTrigger_HLTGenValHist_h
#define Validation_HLTrigger_HLTGenValHist_h

//********************************************************************************
//
// Description:
// Histogram holder class for the GEN-level HLT validation
// Handling and filling of 1D and 2D histograms is done by this class.
//
//
// Author : Finn Labe, UHH, Jul. 2022
// (Strongly inspired by Sam Harpers HLTDQMHist class)
//
//***********************************************************************************

#include "DQMOffline/Trigger/interface/FunctionDefs.h"

#include "DQMOffline/Trigger/interface/VarRangeCutColl.h"

#include "FWCore/Framework/interface/Event.h"

#include "Validation/HLTrigger/interface/HLTGenValObject.h"

#include <TH1.h>
#include <TH2.h>

// base histogram class, with specific implementations following below
class HLTGenValHist {
public:
HLTGenValHist() = default;
virtual ~HLTGenValHist() = default;
virtual void fill(const HLTGenValObject& objType) = 0;
};

// specific implimentation of a HLTGenValHist for 1D histograms
// it takes the histogram which it will fill
// it takes the variable to plot (func) and its name (varName)
// also, it takes additional cuts (rangeCuts) applied before filling
// to fill the histogram, an object is passed in the Fill function
class HLTGenValHist1D : public HLTGenValHist {
public:
HLTGenValHist1D(TH1* hist,
std::string varName,
std::function<float(const HLTGenValObject&)> func,
VarRangeCutColl<HLTGenValObject> rangeCuts)
: var_(std::move(func)), varName_(std::move(varName)), rangeCuts_(std::move(rangeCuts)), hist_(hist) {}

void fill(const HLTGenValObject& obj) override {
if(rangeCuts_(obj)) hist_->Fill(var_(obj));
}

private:
std::function<float(const HLTGenValObject&)> var_;
std::string varName_;
VarRangeCutColl<HLTGenValObject> rangeCuts_;
TH1* hist_; //we do not own this
};

// specific implimentation of a HLTGenValHist for 2D histograms
// it takes the histogram which it will fill
// it takes the two variable to plot (func) and their name (varName)
// to fill the histogram, two objects are passed in the Fill function
class HLTGenValHist2D : public HLTGenValHist {
public:
HLTGenValHist2D(TH2* hist,
std::string varNameX,
std::string varNameY,
std::function<float(const HLTGenValObject&)> funcX,
std::function<float(const HLTGenValObject&)> funcY)
: varX_(std::move(funcX)), varY_(std::move(funcY)), varNameX_(std::move(varNameX)), varNameY_(std::move(varNameY)), hist_(hist) {}

void fill(const HLTGenValObject& obj) override {
hist_->Fill(varX_(obj), varY_(obj));
}

private:
std::function<float(const HLTGenValObject&)> varX_;
std::function<float(const HLTGenValObject&)> varY_;
std::string varNameX_;
std::string varNameY_;
TH2* hist_; //we do not own this
};

#endif
61 changes: 61 additions & 0 deletions Validation/HLTrigger/interface/HLTGenValHistCollFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef Validation_HLTrigger_HLTGenValHistCollFilter_h
#define Validation_HLTrigger_HLTGenValHistCollFilter_h

//********************************************************************************
//
// Description:
// This class contains a collection of HLTGenvalHists used to measure the efficiency of a
// specified filter. It is resonsible for booking and filling the histograms of all vsVars
// histograms that are created for a specific filter.
//
// Author : Finn Labe, UHH, Jul. 2022
// (Strongly inspired by Sam Harpers HLTDQMFilterEffHists class)
//
//***********************************************************************************

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DQMServices/Core/interface/DQMStore.h"

#include "DataFormats/HLTReco/interface/TriggerEvent.h"

#include "Validation/HLTrigger/interface/HLTGenValHist.h"
#include "DQMOffline/Trigger/interface/FunctionDefs.h"
#include "DQMOffline/Trigger/interface/UtilFuncs.h"

#include "Validation/HLTrigger/interface/HLTGenValObject.h"
#include "Validation/HLTrigger/interface/HLTGenValPathSpecificSettingParser.h"

#include "DataFormats/Math/interface/deltaR.h"

#include <utility>

// class containing a collection of HLTGenValHist for a specific filter
// functions for initial booking of hists, and filling of hists for a single object are available
class HLTGenValHistCollFilter {
public:
typedef dqm::legacy::MonitorElement MonitorElement;
typedef dqm::legacy::DQMStore DQMStore;

explicit HLTGenValHistCollFilter(edm::ParameterSet filterCollConfig);

static edm::ParameterSetDescription makePSetDescription();

void bookHists(DQMStore::IBooker& iBooker, const std::vector<edm::ParameterSet>& histConfigs, const std::vector<edm::ParameterSet>& histConfigs2D);
void fillHists(const HLTGenValObject& obj, edm::Handle<trigger::TriggerEvent>& triggerEvent);

private:
void book1D(DQMStore::IBooker& iBooker, const edm::ParameterSet& histConfig);
void book2D(DQMStore::IBooker& iBooker, const edm::ParameterSet& histConfig2D);

std::vector<std::unique_ptr<HLTGenValHist>> hists_; // the collection of histograms
std::string objType_;
std::string tag_;
std::string filter_;
std::string path_;
std::string hltProcessName_;
double dR2limit_;
};

#endif
59 changes: 59 additions & 0 deletions Validation/HLTrigger/interface/HLTGenValHistCollPath.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#ifndef Validation_HLTrigger_HLTGenValHistCollPath_h
#define Validation_HLTrigger_HLTGenValHistCollPath_h

//********************************************************************************
//
// Description:
// This contains a collection of HLTGenValHistCollFilter used to measure the efficiencies of all
// filters in a specified path. The actual booking and filling happens in the respective HLTGenValHistCollFilters.
//
// Author : Finn Labe, UHH, Oct. 2021
// (Heavily borrowed from Sam Harpers HLTDQMFilterEffHists)
//
//***********************************************************************************

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DQMServices/Core/interface/DQMStore.h"

#include "DataFormats/HLTReco/interface/TriggerEvent.h"

#include "DQMOffline/Trigger/interface/FunctionDefs.h"
#include "DQMOffline/Trigger/interface/UtilFuncs.h"

#include "Validation/HLTrigger/interface/HLTGenValHistCollFilter.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"

#include "Validation/HLTrigger/interface/HLTGenValObject.h"

// class containing a collection of HLTGenValHistCollFilters for a specific path
// at object creation time, the object type (used for systematically naming the histogram),
// triggerPath, hltConfig and dR2limit (for deltaR matching) need to be specified
// functions for initial booking of hists, and filling of hists for a single object, are available
class HLTGenValHistCollPath {
public:
typedef dqm::legacy::MonitorElement MonitorElement;
typedef dqm::legacy::DQMStore DQMStore;

explicit HLTGenValHistCollPath(edm::ParameterSet pathCollConfig, HLTConfigProvider& hltConfig);

static edm::ParameterSetDescription makePSetDescription();

void bookHists(DQMStore::IBooker& iBooker, std::vector<edm::ParameterSet>& histConfigs, std::vector<edm::ParameterSet>& histConfigs2D);
void fillHists(const HLTGenValObject& obj, edm::Handle<trigger::TriggerEvent>& triggerEvent);

private:
std::string triggerPath_;
std::vector<HLTGenValHistCollFilter> collectionFilter_;
std::vector<std::string> filters_;
HLTConfigProvider hltConfig_;
bool doOnlyLastFilter_;

// we will add a string to the root file that is named after the path
// it will contain the filters of that path divided by semicola
std::string pathStringName_;
std::string pathString_;
};

#endif
51 changes: 51 additions & 0 deletions Validation/HLTrigger/interface/HLTGenValObject.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#ifndef Validation_HLTrigger_HLTGenValObject_h
#define Validation_HLTrigger_HLTGenValObject_h

//********************************************************************************
//
// Description:
// This class is an object wrapper for the Generator level validation code.
// It handles the different type of objects the code needs to run on: GenParticles, GenJets and event-level energy sums
//
// Author : Finn Labe, UHH, Nov. 2021
//
//********************************************************************************


#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/JetReco/interface/GenJet.h"

#include "DataFormats/Math/interface/LorentzVector.h"
#include <vector>

class HLTGenValObject {
public:

// empty constructor
HLTGenValObject() {}

// constructor from GenParticle
HLTGenValObject(const reco::GenParticle &p)
: p4Polar_(p.p4()), p4Cartesian_(p.p4()) {}

// constructor from GenJet
HLTGenValObject(const reco::GenJet &p)
: p4Polar_(p.p4()), p4Cartesian_(p.p4()) {}

// constructor from LorentzVector (for energy sums)
HLTGenValObject(const reco::Candidate::PolarLorentzVector& p)
: p4Polar_(p), p4Cartesian_(p) {}

// object functions, for usage of HLTGenValObjects by other modules
double pt() const { return p4Polar_.pt(); }
double eta() const { return p4Polar_.eta(); }
double phi() const { return p4Polar_.phi(); }
double et() const { return (pt() <= 0) ? 0 : p4Cartesian_.Et(); }

private:
// containing information in two "shapes"
math::PtEtaPhiMLorentzVector p4Polar_;
math::XYZTLorentzVector p4Cartesian_;
};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef Validation_HLTrigger_HLTGenValPathSpecificSettingParser_h
#define Validation_HLTrigger_HLTGenValSpecificCutParser_h

//********************************************************************************
//
// Description:
// This class handles parsing of additional settings that can be set for each path in the generator-level validation module
// Mainly, these are cuts in addition to the ones specified in the module. Passing a pre-defined region is also possible
// The binning of a certain variable can be changed through this class, as well as setting a tag for all histograms of a path.
//
// Author : Finn Labe, UHH, Jul. 2022
//
//********************************************************************************

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"

#include "DQMServices/Core/interface/DQMStore.h"

#include <vector>

class HLTGenValPathSpecificSettingParser {
public:

// constructor
HLTGenValPathSpecificSettingParser(std::string pathSpecificSettings, std::vector<edm::ParameterSet> binnings, std::string vsVar);

std::vector<edm::ParameterSet> getPathSpecificCuts() {return pathSpecificCutsVector_;}
std::vector<double> getPathSpecificBins() {return pathSpecificBins_;}
bool havePathSpecificBins() { return (!pathSpecificBins_.empty()); }
std::string getTag() {return tag_;}

private:
std::vector<edm::ParameterSet> pathSpecificCutsVector_;
std::vector<double> pathSpecificBins_;
std::string tag_ = "";

};

#endif
15 changes: 15 additions & 0 deletions Validation/HLTrigger/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<use name="DataFormats/TrackReco"/>
<use name="FWCore/Framework"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/PluginManager"/>
<use name="CommonTools/UtilAlgos"/>
<use name="PhysicsTools/UtilAlgos"/>
<use name="DQMServices/Core"/>
<use name="CommonTools/TriggerUtils"/>
<use name="DQMOffline/Trigger"/>
<use name="FWCore/ServiceRegistry"/>
<use name="DataFormats/HLTReco"/>
<use name="HLTrigger/HLTcore"/>
<use name="CommonTools/Utils"/>
<use name="Validation/HLTrigger"/>
<flags EDM_PLUGIN="1"/>
Loading