Skip to content

Commit a408998

Browse files
authored
Merge pull request #145 from johnalison/mergeTo12_1_X
Merge updates for 12_1_x and BTV HLT Dev
2 parents 03e8183 + ad4912f commit a408998

File tree

108 files changed

+4027990
-1809
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+4027990
-1809
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.pyc
2+
*.root
3+
*.txt
4+
*.*~
5+
#*.*#
6+
__init__.py
7+
*.log
8+
9+
pydump.py
10+
test/CRAB/crab_projects_*

BuildFile.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
<use name="JetMETCorrections/Objects"/>
1919
<use name="RecoBTag/BTagTools"/>
2020
<use name="RecoMuon/TrackingTools"/>
21+
<use name="SimGeneral/HepPDTRecord"/>
22+
<use name="fastjet"/>
23+
<use name="fastjet-contrib"/>
2124
<use name="SimDataFormats/Track"/>
25+
<!--
2226
<use name="SimDataFormats/JetMatching"/>
27+
-->
2328
<use name="SimTracker/TrackAssociation"/>
2429
<use name="SimTracker/Records"/>
2530
<use name="TrackingTools/TransientTrack"/>

DQMStudy.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Following are instructions for detailed DQM studies :
2+
3+
Setup the RecoBTag-PerformanceMeasurements pactkage as described in the README.md
4+
5+
# Make Target Reference BTagAnalyzer NTuple
6+
```
7+
cp RecoBTag/PerformanceMeasurements/python/defaults/Run3.py RecoBTag/PerformanceMeasurements/python/defaults/Run3Reference.py
8+
[ edit Run3Refernce to point to the right file ]
9+
cd RecoBTag/PerformanceMeasurements/test/
10+
cmsRun runBTagAnalyzer_cfg.py defaults=Run3Reference runOnData=(True or False, depending on your needs)
11+
cd -
12+
```
13+
14+
# Make Target Reference BTagAnalyzer NTuple
15+
```
16+
cp RecoBTag/PerformanceMeasurements/python/defaults/Run3.py RecoBTag/PerformanceMeasurements/python/defaults/Run3Target.py
17+
[ edit Run3Target to point to the right file ]
18+
cd RecoBTag/PerformanceMeasurements/test/
19+
cmsRun runBTagAnalyzer_cfg.py defaults=Run3Target runOnData=(True or False, depending on your needs)
20+
cd -
21+
```
22+
23+
### Process Ntuples To make ROOT file with histograms
24+
25+
Additional Software setup to process BTagNtuples for offline validation monitoring
26+
27+
```
28+
git cms-merge-topic johnalison:MakePy3Bind11ParameterSetsIncludingCommandLineArguments
29+
git clone -b BTVDQM git@github.com:patrickbryant/nTupleAnalysis.git
30+
git clone -b 12_1_X git@github.com:johnalison/TriggerStudies.git
31+
```
32+
33+
```
34+
BTagAnalyzer TriggerStudies/NtupleAna/scripts/BTagAnalyzer_cfg.py \
35+
--inputRAW path/to/target/BTagAnalyzer/Ntuple/JetTree.root \
36+
--inputAOD path/to/reference/BTagAnalyzer/Ntuple/JetTree.root \
37+
-o $PWD \
38+
-y Run3 \
39+
--histogramming 1 \
40+
--histFile hists_Run3_offlineValidation.root \
41+
--isMC \
42+
--doTracks \
43+
--jetDetailString matchedJet.allTaggers.innerPixHit.noInnerPixHit.DeepJetBins \
44+
--pfJetName "" \
45+
--nevents -1
46+
```
47+
48+
49+
50+
### Make plots presentation
51+
```
52+
git clone -b 12_1_X git@github.com:johnalison/ROOTHelp.git
53+
source ROOTHelp/setup.sh
54+
source TriggerStudies/plotting/offlineDQMPlots.sh hists_Run3_offlineValidation.root hists_Run3_offlineValidation targetName [python3]
55+
```
56+
Outpus a slides in hists_Run3_offlineValidation directory
57+
give the option python3 to actually make the plots

README.md

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,20 @@
33
## Software setup
44

55
```
6-
cmsrel CMSSW_10_6_20
7-
cd CMSSW_10_6_20/src
6+
cmsrel CMSSW_12_1_0_pre2
7+
cd CMSSW_12_1_0_pre2/src
88
cmsenv
99
10-
for bash
1110
export CMSSW_GIT_REFERENCE=/cvmfs/cms.cern.ch/cmssw.git.daily
1211
1312
for tcsh
1413
setenv CMSSW_GIT_REFERENCE /cvmfs/cms.cern.ch/cmssw.git.daily
1514
1615
git cms-init
1716
18-
git clone -b 10_6_X_UL2016_PreliminaryJECs --depth 1 https://github.com/cms-btv-pog/RecoBTag-PerformanceMeasurements.git RecoBTag/PerformanceMeasurements
17+
git clone -b 12_1_X --recursive https://github.com/johnalison/RecoBTag-PerformanceMeasurements.git RecoBTag/PerformanceMeasurements
1918
20-
scram b -j8
19+
scram b -j12
2120
2221
```
2322

@@ -30,6 +29,7 @@ NOTE1: due to the structure of the preliminary JECs, there are 2 different "defa
3029
3130
This means in your crab configuration file, you will have to check which file you are running on, and pick the correct default set accordingly. As an example, one might do something like:
3231

32+
# Make Target Reference BTagAnalyzer NTuple
3333
```
3434
For MC samples:
3535
...
@@ -51,14 +51,50 @@ else:
5151

5252
NOTE2: The preliminary JECs are only available for AK4PFCHS jets, and therefore you **_can not have any FatJet observables listed in you varGroup!_**. Otherwise the BTA will automatically assume you are running over FatJets and it will use the JECs included in the global tag, rather than in the local SQLite .db files!
5353

54-
55-
56-
To run the tests for integrating changes run:
54+
# To run the tests for integrating changes run:
5755

5856
```
5957
cd RecoBTag/PerformanceMeasurements/test/
6058
./run_tests.sh
6159
```
60+
61+
62+
## BTagAnalyzer General information
63+
6264
The content of the output ntuple is by default empty and has to be configured according to your needs. The ```store*Variables``` options have been removed.
6365
The new variable configuration can be customized in the file ```RecoBTag/PerformanceMeasurements/python/varGroups_cfi.py```.
6466
New variables need also to be added (apart from adding them in the code) in ```RecoBTag/PerformanceMeasurements/python/variables_cfi.py```
67+
68+
69+
## How to get the latest HLT configuration
70+
For MC:
71+
```
72+
hltGetConfiguration /dev/CMSSW_12_0_0/GRun/V2 \
73+
--full \
74+
--offline \
75+
--unprescale \
76+
--mc \
77+
--process HLT2 \
78+
--globaltag auto:phase1_2021_realistic \
79+
--max-events 10 \
80+
> tmp.py
81+
```
82+
```
83+
edmConfigDump tmp.py > HLT_dev_CMSSW_12_0_0_GRun_V3_configDump_MC.py
84+
```
85+
For data:
86+
```
87+
hltGetConfiguration /dev/CMSSW_12_0_0/GRun \
88+
--full \
89+
--offline \
90+
--unprescale \
91+
--data \
92+
--process HLT2 \
93+
--globaltag auto:run3_hlt \
94+
--max-events 10 \
95+
--customise HLTrigger/Configuration/customizeHLTforCMSSW.customiseFor2018Input \
96+
> tmp_data.py
97+
```
98+
```
99+
edmConfigDump tmp_data.py > HLT_dev_CMSSW_12_0_0_GRun_V3_configDump_Data.py
100+
```

data/PhaseIIFall17_V3_MC.db

112 KB
Binary file not shown.

data/PhaseIIFall17_V5b_MC.db

296 KB
Binary file not shown.

interface/AnalyzerBase.h

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
#ifndef ANALYZERBASE_H
2+
#define ANALYZERBASE_H
3+
4+
// system include files
5+
#include <memory>
6+
7+
// user include files
8+
#include "FWCore/Framework/interface/Frameworkfwd.h"
9+
#include "FWCore/Framework/interface/EDAnalyzer.h"
10+
#include "FWCore/Framework/interface/Event.h"
11+
#include "FWCore/Framework/interface/MakerMacros.h"
12+
#include "FWCore/ParameterSet/interface/ParameterSet.h"
13+
14+
#include "DataFormats/Common/interface/RefToPtr.h"
15+
#include "DataFormats/JetReco/interface/JetTracksAssociation.h"
16+
#include "DataFormats/BTauReco/interface/CandIPTagInfo.h"
17+
#include "DataFormats/BTauReco/interface/CandSoftLeptonTagInfo.h"
18+
#include "DataFormats/BTauReco/interface/BoostedDoubleSVTagInfo.h"
19+
#include "DataFormats/BTauReco/interface/TrackIPTagInfo.h"
20+
#include "DataFormats/Math/interface/deltaR.h"
21+
22+
#include "DataFormats/GeometrySurface/interface/Line.h"
23+
#include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
24+
25+
//#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
26+
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
27+
28+
#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
29+
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
30+
#include "RecoBTag/PerformanceMeasurements/interface/CategoryFinder.h"
31+
32+
// reco track and vertex
33+
#include "DataFormats/Candidate/interface/VertexCompositePtrCandidate.h"
34+
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
35+
#include "DataFormats/TrackReco/interface/Track.h"
36+
#include "DataFormats/VertexReco/interface/Vertex.h"
37+
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
38+
#include "DataFormats/BTauReco/interface/JetTag.h"
39+
#include "DataFormats/JetReco/interface/JetCollection.h"
40+
#include "DataFormats/JetReco/interface/Jet.h"
41+
42+
#include "DataFormats/TrackReco/interface/TrackFwd.h"
43+
#include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
44+
#include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
45+
#include "TH1F.h"
46+
#include "TH2F.h"
47+
#include "TFile.h"
48+
#include "TTree.h"
49+
#include "TVector3.h"
50+
#include "TLorentzVector.h"
51+
#include "Math/GenVector/VectorUtil.h"
52+
#include "Math/GenVector/PxPyPzE4D.h"
53+
#include "TGraphErrors.h"
54+
55+
#include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
56+
57+
#include "SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h"
58+
#include "SimTracker/TrackHistory/interface/TrackCategories.h"
59+
#include "SimTracker/TrackHistory/interface/TrackClassifier.h"
60+
#include "DataFormats/BTauReco/interface/SoftLeptonTagInfo.h"
61+
#include "DataFormats/BTauReco/interface/DeepFlavourFeatures.h"
62+
#include "DataFormats/BTauReco/interface/DeepDoubleXFeatures.h"
63+
#include "DataFormats/BTauReco/interface/DeepBoostedJetFeatures.h"
64+
#include "DataFormats/MuonReco/interface/Muon.h"
65+
#include "DataFormats/PatCandidates/interface/Electron.h"
66+
#include "DataFormats/PatCandidates/interface/MET.h"
67+
68+
// trigger
69+
#include "DataFormats/Common/interface/TriggerResults.h"
70+
#include "FWCore/Framework/interface/TriggerNamesService.h"
71+
#include "FWCore/ServiceRegistry/interface/Service.h"
72+
#include "CommonTools/UtilAlgos/interface/TFileService.h"
73+
74+
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
75+
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
76+
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
77+
#include "DataFormats/JetReco/interface/JetCollection.h"
78+
#include "DataFormats/JetReco/interface/GenJetCollection.h"
79+
#include "DataFormats/PatCandidates/interface/Jet.h"
80+
#include "DataFormats/PatCandidates/interface/Muon.h"
81+
82+
// reconstruct IP
83+
#include "TrackingTools/IPTools/interface/IPTools.h"
84+
85+
// Math clusters to TrackingParticles
86+
#include "SimTracker/TrackerHitAssociation/interface/ClusterTPAssociation.h"
87+
88+
#include "RecoBTau/JetTagComputer/interface/GenericMVAJetTagComputer.h"
89+
#include "RecoBTau/JetTagComputer/interface/GenericMVAJetTagComputerWrapper.h"
90+
#include "RecoBTau/JetTagComputer/interface/JetTagComputer.h"
91+
#include "RecoBTau/JetTagComputer/interface/JetTagComputerRecord.h"
92+
#include "RecoBTag/SecondaryVertex/interface/CombinedSVComputer.h"
93+
#include "RecoBTag/SecondaryVertex/interface/TrackKinematics.h"
94+
#include "RecoBTag/SecondaryVertex/interface/V0Filter.h"
95+
// #include "RecoBTag/ImpactParameter/plugins/IPProducer.h"
96+
#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h"
97+
98+
#include "TrackingTools/GeomPropagators/interface/AnalyticalImpactPointExtrapolator.h"
99+
100+
#include "FWCore/Utilities/interface/RegexMatch.h"
101+
#include <boost/regex.hpp>
102+
103+
#include "RecoBTag/PerformanceMeasurements/interface/JetInfoBranches.h"
104+
#include "RecoBTag/PerformanceMeasurements/interface/EventInfoBranches.h"
105+
#include "RecoBTag/PerformanceMeasurements/interface/BookHistograms.h"
106+
#include "RecoBTag/PerformanceMeasurements/interface/VariableParser.h"
107+
108+
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
109+
#include "FWCore/Common/interface/Provenance.h"
110+
#include "PhysicsTools/SelectorUtils/interface/PFJetIDSelectionFunctor.h"
111+
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
112+
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
113+
114+
#include "TrackingTools/TransientTrack/interface/TransientTrackBuilder.h"
115+
#include "TrackingTools/Records/interface/TransientTrackRecord.h"
116+
#include "TrackingTools/IPTools/interface/IPTools.h"
117+
118+
#include "fastjet/contrib/Njettiness.hh"
119+
120+
// #include "RecoBTag/SecondaryVertex/interface/CombinedSVSoftLeptonComputer.h"
121+
#include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h"
122+
#include "DataFormats/BTauReco/interface/DeepDoubleXTagInfo.h"
123+
#include "DataFormats/BTauReco/interface/DeepBoostedJetTagInfo.h"
124+
125+
126+
127+
namespace analyzerBase{
128+
129+
//
130+
// constants, enums and typedefs
131+
//
132+
typedef edm::View<pat::Jet> PatJetCollection;
133+
typedef std::vector<edm::Ptr<pat::Jet> > PatJetPtrCollection;
134+
135+
//
136+
// class declaration
137+
//
138+
139+
struct orderByPt {
140+
const std::string mCorrLevel;
141+
orderByPt(const std::string& fCorrLevel) : mCorrLevel(fCorrLevel) {}
142+
bool operator ()(edm::Ptr<pat::Jet> const& a, edm::Ptr<pat::Jet> const& b) {
143+
if( mCorrLevel=="Uncorrected" )
144+
return a->correctedJet("Uncorrected").pt() > b->correctedJet("Uncorrected").pt();
145+
else
146+
return a->pt() > b->pt();
147+
}
148+
};
149+
150+
class simPrimaryVertex {
151+
public:
152+
simPrimaryVertex(double x1,double y1,double z1):x(x1),y(y1),z(z1),ptsq(0),nGenTrk(0){};
153+
double x,y,z;
154+
HepMC::FourVector ptot;
155+
//HepLorentzVector ptot;
156+
double ptsq;
157+
int nGenTrk;
158+
std::vector<int> finalstateParticles;
159+
std::vector<int> simTrackIndex;
160+
std::vector<int> genVertex;
161+
const reco::Vertex *recVtx;
162+
};
163+
164+
const reco::TrackBaseRef toTrackRef(const reco::TrackRef & trk);
165+
const reco::TrackBaseRef toTrackRef(const edm::Ptr<reco::Candidate> & cnd);
166+
167+
const math::XYZPoint & position(const reco::Vertex & sv);
168+
const math::XYZPoint & position(const reco::VertexCompositePtrCandidate & sv);
169+
const double xError(const reco::Vertex & sv);
170+
const double xError(const reco::VertexCompositePtrCandidate & sv);
171+
const double yError(const reco::Vertex & sv);
172+
const double yError(const reco::VertexCompositePtrCandidate & sv);
173+
const double zError(const reco::Vertex & sv);
174+
const double zError(const reco::VertexCompositePtrCandidate & sv);
175+
const double chi2(const reco::Vertex & sv);
176+
const double chi2(const reco::VertexCompositePtrCandidate & sv);
177+
const double ndof(const reco::Vertex & sv);
178+
const double ndof(const reco::VertexCompositePtrCandidate & sv);
179+
const unsigned int vtxTracks(const reco::Vertex & sv);
180+
const unsigned int vtxTracks(const reco::VertexCompositePtrCandidate & sv);
181+
182+
// This is needed to get a TrackingParticle --> Cluster match (instead of Cluster-->TP) (only needed in processJets)
183+
using P = std::pair<OmniClusterRef, TrackingParticleRef>;
184+
bool compare(const P& i, const P& j);
185+
186+
187+
enum JetFlavor {UNDEFINED, G, UD, S, C, GCC, CC, B, GBB, BB, LeptonicB, LeptonicB_C, TAU};
188+
189+
JetFlavor jet_flavour(const pat::Jet& jet,
190+
const std::vector<reco::GenParticle>& gToBB,
191+
const std::vector<reco::GenParticle>& gToCC,
192+
const std::vector<reco::GenParticle>& neutrinosLepB,
193+
const std::vector<reco::GenParticle>& neutrinosLepB_C,
194+
const std::vector<reco::GenParticle>& alltaus,
195+
bool usePhysForLightAndUndefined=false);
196+
197+
}
198+
#endif

0 commit comments

Comments
 (0)