CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Attributes
PatBJetVertexAnalyzer Class Reference
Inheritance diagram for PatBJetVertexAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  Plots
 

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &es) override
 
void beginJob () override
 
 PatBJetVertexAnalyzer (const edm::ParameterSet &params)
 constructor and destructor More...
 
 ~PatBJetVertexAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Types

enum  Flavour {
  ALL_JETS = 0, UDSG_JETS, C_JETS, B_JETS,
  NONID_JETS, N_JET_TYPES
}
 

Private Attributes

TH1 * flavours_
 
double jetEtaCut_
 
double jetPtCut_
 
edm::EDGetTokenT< pat::JetCollectionjetsToken_
 
double maxDeltaR_
 
struct PatBJetVertexAnalyzer::Plots plots_ [N_JET_TYPES]
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 33 of file PatBJetVertexAnalyzer.cc.

Member Enumeration Documentation

◆ Flavour

Enumerator
ALL_JETS 
UDSG_JETS 
C_JETS 
B_JETS 
NONID_JETS 
N_JET_TYPES 

Definition at line 53 of file PatBJetVertexAnalyzer.cc.

Constructor & Destructor Documentation

◆ PatBJetVertexAnalyzer()

PatBJetVertexAnalyzer::PatBJetVertexAnalyzer ( const edm::ParameterSet params)

constructor and destructor

Definition at line 65 of file PatBJetVertexAnalyzer.cc.

66  : jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
67  jetPtCut_(params.getParameter<double>("jetPtCut")),
68  jetEtaCut_(params.getParameter<double>("jetEtaCut")) {}

◆ ~PatBJetVertexAnalyzer()

PatBJetVertexAnalyzer::~PatBJetVertexAnalyzer ( )
override

Definition at line 70 of file PatBJetVertexAnalyzer.cc.

70 {}

Member Function Documentation

◆ analyze()

void PatBJetVertexAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup es 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 130 of file PatBJetVertexAnalyzer.cc.

130  {
131  // handle to the jets collection
133  event.getByToken(jetsToken_, jetsHandle);
134 
135  // now go through all jets
136  for (pat::JetCollection::const_iterator jet = jetsHandle->begin(); jet != jetsHandle->end(); ++jet) {
137  // only look at jets that pass the pt and eta cut
138  if (jet->pt() < jetPtCut_ || std::abs(jet->eta()) > jetEtaCut_)
139  continue;
140 
142  // find out the jet flavour (differs between quark and anti-quark)
143  switch (std::abs(jet->partonFlavour())) {
144  case 1:
145  case 2:
146  case 3:
147  case 21:
148  flavour = UDSG_JETS;
149  break;
150  case 4:
151  flavour = C_JETS;
152  break;
153  case 5:
154  flavour = B_JETS;
155  break;
156  default:
158  }
159 
160  // simply count the number of accepted jets
161  flavours_->Fill(ALL_JETS);
162  flavours_->Fill(flavour);
163 
164  // retrieve the "secondary vertex tag infos"
165  // this is the output of the b-tagging reconstruction code
166  // and contains secondary vertices in the jets
167  const reco::SecondaryVertexTagInfo &svTagInfo = *jet->tagInfoSecondaryVertex();
168 
169  // count the number of secondary vertices
170  plots_[ALL_JETS].nVertices->Fill(svTagInfo.nVertices());
171  plots_[flavour].nVertices->Fill(svTagInfo.nVertices());
172 
173  // ignore jets without SV from now on
174  if (svTagInfo.nVertices() < 1)
175  continue;
176 
177  // pick the first secondary vertex (the "best" one)
178  const reco::Vertex &sv = svTagInfo.secondaryVertex(0);
179 
180  // and plot number of tracks and chi^2
181  plots_[ALL_JETS].nTracks->Fill(sv.tracksSize());
182  plots_[flavour].nTracks->Fill(sv.tracksSize());
183 
184  plots_[ALL_JETS].chi2->Fill(sv.chi2());
185  plots_[flavour].chi2->Fill(sv.chi2());
186 
187  // the precomputed transverse distance to the primary vertex
188  Measurement1D distance = svTagInfo.flightDistance(0, true);
189 
190  plots_[ALL_JETS].dist->Fill(distance.value());
191  plots_[flavour].dist->Fill(distance.value());
192 
193  plots_[ALL_JETS].distErr->Fill(distance.error());
194  plots_[flavour].distErr->Fill(distance.error());
195 
196  plots_[ALL_JETS].distSig->Fill(distance.significance());
197  plots_[flavour].distSig->Fill(distance.significance());
198 
199  // the precomputed direction with respect to the primary vertex
200  const GlobalVector &dir = svTagInfo.flightDirection(0);
201 
202  // unfortunately CMSSW hsa all kinds of vectors,
203  // and sometimes we need to convert them *sigh*
204  math::XYZVector dir2(dir.x(), dir.y(), dir.z());
205 
206  // compute a few variables that we are plotting
207  double deltaR = ROOT::Math::VectorUtil::DeltaR(jet->momentum(), dir2);
208 
209  plots_[ALL_JETS].deltaR->Fill(deltaR);
210  plots_[flavour].deltaR->Fill(deltaR);
211 
212  // compute the invariant mass from a four-vector sum
213  math::XYZTLorentzVector trackFourVectorSum;
214 
215  // loop over all tracks in the vertex
216  for (reco::Vertex::trackRef_iterator track = sv.tracks_begin(); track != sv.tracks_end(); ++track) {
217  ROOT::Math::LorentzVector<ROOT::Math::PxPyPzM4D<double> > vec;
218  vec.SetPx((*track)->px());
219  vec.SetPy((*track)->py());
220  vec.SetPz((*track)->pz());
221  vec.SetM(0.13957); // pion mass
222  trackFourVectorSum += vec;
223  }
224 
225  // get the invariant mass: sqrt(E² - px² - py² - pz²)
226  double vertexMass = trackFourVectorSum.M();
227 
228  plots_[ALL_JETS].mass->Fill(vertexMass);
229  plots_[flavour].mass->Fill(vertexMass);
230  }
231 }

References funct::abs(), ALL_JETS, B_JETS, C_JETS, PatBJetVertexAnalyzer::Plots::chi2, electronAnalyzer_cfi::DeltaR, PatBJetVertexAnalyzer::Plots::deltaR, PbPb_ZMuSkimMuonDPG_cff::deltaR, DeadROC_duringRun::dir, L1TDiffHarvesting_cfi::dir2, PatBJetVertexAnalyzer::Plots::dist, HLT_2018_cff::distance, PatBJetVertexAnalyzer::Plots::distErr, PatBJetVertexAnalyzer::Plots::distSig, GenHFHadronMatcher_cff::flavour, flavours_, reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::flightDirection(), reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::flightDistance(), metsig::jet, jetEtaCut_, jetPtCut_, jetsToken_, PatBJetVertexAnalyzer::Plots::mass, NONID_JETS, PatBJetVertexAnalyzer::Plots::nTracks, PatBJetVertexAnalyzer::Plots::nVertices, reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::nVertices(), plots_, reco::TemplatedSecondaryVertexTagInfo< IPTI, VTX >::secondaryVertex(), pfDeepBoostedJetPreprocessParams_cfi::sv, HLT_2018_cff::track, UDSG_JETS, and reco::btau::vertexMass.

◆ beginJob()

void PatBJetVertexAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 72 of file PatBJetVertexAnalyzer.cc.

72  {
73  // retrieve handle to auxiliary service
74  // used for storing histograms into ROOT file
76 
77  flavours_ = fs->make<TH1F>("flavours", "jet flavours", 5, 0, 5);
78 
79  // book histograms for all jet flavours
80  for (unsigned int i = 0; i < N_JET_TYPES; i++) {
81  Plots &plots = plots_[i];
82  const char *flavour, *name;
83 
84  switch ((Flavour)i) {
85  case ALL_JETS:
86  flavour = "all jets";
87  name = "all";
88  break;
89  case UDSG_JETS:
90  flavour = "light flavour jets";
91  name = "udsg";
92  break;
93  case C_JETS:
94  flavour = "charm jets";
95  name = "c";
96  break;
97  case B_JETS:
98  flavour = "bottom jets";
99  name = "b";
100  break;
101  default:
102  flavour = "unidentified jets";
103  name = "ni";
104  break;
105  }
106 
107  plots.nVertices =
108  fs->make<TH1F>(Form("nVertices_%s", name), Form("number of secondary vertices in %s", flavour), 5, 0, 5);
109  plots.deltaR = fs->make<TH1F>(Form("deltaR_%s", name),
110  Form("\\DeltaR between vertex direction and jet direction in %s", flavour),
111  100,
112  0,
113  0.5);
114  plots.mass = fs->make<TH1F>(Form("mass_%s", name), Form("vertex mass in %s", flavour), 100, 0, 10);
115  plots.dist =
116  fs->make<TH1F>(Form("dist_%s", name), Form("Transverse distance between PV and SV in %s", flavour), 100, 0, 2);
117  plots.distErr = fs->make<TH1F>(
118  Form("distErr_%s", name), Form("Transverse distance error between PV and SV in %s", flavour), 100, 0, 0.5);
119  plots.distSig = fs->make<TH1F>(
120  Form("distSig_%s", name), Form("Transverse distance significance between PV and SV in %s", flavour), 100, 0, 50);
121  plots.nTracks = fs->make<TH1F>(
122  Form("nTracks_%s", name), Form("number of tracks at secondary vertex in %s", flavour), 20, 0, 20);
123  plots.chi2 =
124  fs->make<TH1F>(Form("chi2_%s", name), Form("secondary vertex fit \\chi^{2} in %s", flavour), 100, 0, 50);
125  }
126 }

References ALL_JETS, B_JETS, C_JETS, GenHFHadronMatcher_cff::flavour, flavours_, mps_fire::i, TFileService::make(), N_JET_TYPES, Skims_PA_cff::name, HLTObjectsMonitor_cfi::plots, plots_, and UDSG_JETS.

Member Data Documentation

◆ flavours_

TH1* PatBJetVertexAnalyzer::flavours_
private

Definition at line 55 of file PatBJetVertexAnalyzer.cc.

Referenced by analyze(), and beginJob().

◆ jetEtaCut_

double PatBJetVertexAnalyzer::jetEtaCut_
private

Definition at line 48 of file PatBJetVertexAnalyzer.cc.

Referenced by analyze().

◆ jetPtCut_

double PatBJetVertexAnalyzer::jetPtCut_
private

Definition at line 47 of file PatBJetVertexAnalyzer.cc.

Referenced by analyze().

◆ jetsToken_

edm::EDGetTokenT<pat::JetCollection> PatBJetVertexAnalyzer::jetsToken_
private

Definition at line 45 of file PatBJetVertexAnalyzer.cc.

Referenced by analyze().

◆ maxDeltaR_

double PatBJetVertexAnalyzer::maxDeltaR_
private

Definition at line 49 of file PatBJetVertexAnalyzer.cc.

◆ plots_

struct PatBJetVertexAnalyzer::Plots PatBJetVertexAnalyzer::plots_[N_JET_TYPES]
private

Referenced by analyze(), and beginJob().

Vector3DBase
Definition: Vector3DBase.h:8
PatBJetVertexAnalyzer::B_JETS
Definition: PatBJetVertexAnalyzer.cc:53
reco::Vertex::trackRef_iterator
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
GenHFHadronMatcher_cff.flavour
flavour
Definition: GenHFHadronMatcher_cff.py:8
L1TDiffHarvesting_cfi.dir2
dir2
Definition: L1TDiffHarvesting_cfi.py:12
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:355
PatBJetVertexAnalyzer::N_JET_TYPES
Definition: PatBJetVertexAnalyzer.cc:53
PatBJetVertexAnalyzer::Plots::dist
TH1 * dist
Definition: PatBJetVertexAnalyzer.cc:60
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
PatBJetVertexAnalyzer::plots_
struct PatBJetVertexAnalyzer::Plots plots_[N_JET_TYPES]
reco::TemplatedSecondaryVertexTagInfo
Definition: TemplatedSecondaryVertexTagInfo.h:47
reco::TemplatedSecondaryVertexTagInfo::nVertices
unsigned int nVertices() const
Definition: TemplatedSecondaryVertexTagInfo.h:112
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
PatBJetVertexAnalyzer::UDSG_JETS
Definition: PatBJetVertexAnalyzer.cc:53
PatBJetVertexAnalyzer::jetPtCut_
double jetPtCut_
Definition: PatBJetVertexAnalyzer.cc:47
edm::Handle
Definition: AssociativeIterator.h:50
heavyFlavorValidationHarvestingSequence_cff.Plots
Plots
Definition: heavyFlavorValidationHarvestingSequence_cff.py:109
PatBJetVertexAnalyzer::Plots::distSig
TH1 * distSig
Definition: PatBJetVertexAnalyzer.cc:60
PatBJetVertexAnalyzer::Plots::mass
TH1 * mass
Definition: PatBJetVertexAnalyzer.cc:60
PatBJetVertexAnalyzer::Plots::chi2
TH1 * chi2
Definition: PatBJetVertexAnalyzer.cc:61
PatBJetVertexAnalyzer::Flavour
Flavour
Definition: PatBJetVertexAnalyzer.cc:53
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:226
PatBJetVertexAnalyzer::Plots::nVertices
TH1 * nVertices
Definition: PatBJetVertexAnalyzer.cc:59
PatBJetVertexAnalyzer::Plots::deltaR
TH1 * deltaR
Definition: PatBJetVertexAnalyzer.cc:60
PbPb_ZMuSkimMuonDPG_cff.deltaR
deltaR
Definition: PbPb_ZMuSkimMuonDPG_cff.py:63
HLTObjectsMonitor_cfi.plots
plots
Definition: HLTObjectsMonitor_cfi.py:17
PatBJetVertexAnalyzer::ALL_JETS
Definition: PatBJetVertexAnalyzer.cc:53
PatBJetVertexAnalyzer::flavours_
TH1 * flavours_
Definition: PatBJetVertexAnalyzer.cc:55
reco::TemplatedSecondaryVertexTagInfo::secondaryVertex
const VTX & secondaryVertex(unsigned int index) const
Definition: TemplatedSecondaryVertexTagInfo.h:107
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
edm::Service< TFileService >
PatBJetVertexAnalyzer::jetEtaCut_
double jetEtaCut_
Definition: PatBJetVertexAnalyzer.cc:48
PatBJetVertexAnalyzer::C_JETS
Definition: PatBJetVertexAnalyzer.cc:53
electronAnalyzer_cfi.DeltaR
DeltaR
Definition: electronAnalyzer_cfi.py:33
PatBJetVertexAnalyzer::NONID_JETS
Definition: PatBJetVertexAnalyzer.cc:53
reco::TemplatedSecondaryVertexTagInfo::flightDistance
Measurement1D flightDistance(unsigned int index, int dim=0) const
Definition: TemplatedSecondaryVertexTagInfo.h:131
PatBJetVertexAnalyzer::Plots::nTracks
TH1 * nTracks
Definition: PatBJetVertexAnalyzer.cc:61
math::XYZTLorentzVector
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
metsig::jet
Definition: SignAlgoResolutions.h:47
PatBJetVertexAnalyzer::Plots::distErr
TH1 * distErr
Definition: PatBJetVertexAnalyzer.cc:60
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PatBJetVertexAnalyzer::jetsToken_
edm::EDGetTokenT< pat::JetCollection > jetsToken_
Definition: PatBJetVertexAnalyzer.cc:45
edm::InputTag
Definition: InputTag.h:15
reco::btau::vertexMass
Definition: TaggingVariable.h:75
reco::Vertex
Definition: Vertex.h:35
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
reco::TemplatedSecondaryVertexTagInfo::flightDirection
const GlobalVector & flightDirection(unsigned int index) const
Definition: TemplatedSecondaryVertexTagInfo.h:139