CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Attributes
PatBJetVertexAnalyzer Class Reference
Inheritance diagram for PatBJetVertexAnalyzer:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase 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::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 33 of file PatBJetVertexAnalyzer.cc.

Member Enumeration Documentation

◆ Flavour

Constructor & Destructor Documentation

◆ PatBJetVertexAnalyzer()

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

constructor and destructor

Definition at line 65 of file PatBJetVertexAnalyzer.cc.

References TFileService::kSharedResource.

66  : jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
67  jetPtCut_(params.getParameter<double>("jetPtCut")),
68  jetEtaCut_(params.getParameter<double>("jetEtaCut")) {
69  usesResource(TFileService::kSharedResource);
70 }
static const std::string kSharedResource
Definition: TFileService.h:76
edm::EDGetTokenT< pat::JetCollection > jetsToken_

◆ ~PatBJetVertexAnalyzer()

PatBJetVertexAnalyzer::~PatBJetVertexAnalyzer ( )
override

Definition at line 72 of file PatBJetVertexAnalyzer.cc.

72 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 132 of file PatBJetVertexAnalyzer.cc.

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_2024v10_cff::distance, PatBJetVertexAnalyzer::Plots::distErr, PatBJetVertexAnalyzer::Plots::distSig, flavours_, metsig::jet, jetEtaCut_, jetPtCut_, jetsToken_, PatBJetVertexAnalyzer::Plots::mass, NONID_JETS, PatBJetVertexAnalyzer::Plots::nTracks, PatBJetVertexAnalyzer::Plots::nVertices, plots_, pfDeepBoostedJetPreprocessParams_cfi::sv, bTagMiniDQM_cff::svTagInfo, HLT_2024v10_cff::track, UDSG_JETS, and reco::btau::vertexMass.

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

◆ beginJob()

void PatBJetVertexAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 74 of file PatBJetVertexAnalyzer.cc.

References ALL_JETS, B_JETS, C_JETS, flavours_, compareTotals::fs, mps_fire::i, N_JET_TYPES, Skims_PA_cff::name, HLTObjectsMonitor_cfi::plots, plots_, and UDSG_JETS.

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

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().