CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Private Types | Private Attributes
PatBJetTrackAnalyzer Class Reference
Inheritance diagram for PatBJetTrackAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  Plots
 

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &es) override
 
void beginJob () override
 
 PatBJetTrackAnalyzer (const edm::ParameterSet &params)
 constructor and destructor More...
 
 ~PatBJetTrackAnalyzer () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::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

edm::EDGetTokenT< reco::BeamSpotbeamSpotToken_
 
TH1 * flavours_
 
double jetEtaCut_
 
double jetPtCut_
 
edm::EDGetTokenT
< pat::JetCollection
jetsToken_
 
double maxDeltaR_
 
unsigned int minPixelHits_
 
double minPt_
 
unsigned int minTotalHits_
 
unsigned int nThTrack_
 
struct PatBJetTrackAnalyzer::Plots plots_ [N_JET_TYPES]
 
edm::EDGetTokenT
< reco::VertexCollection
primaryVerticesToken_
 
edm::EDGetTokenT
< reco::TrackCollection
tracksToken_
 

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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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< B > consumes (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 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)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
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 30 of file PatBJetTrackAnalyzer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

PatBJetTrackAnalyzer::PatBJetTrackAnalyzer ( const edm::ParameterSet params)

constructor and destructor

Definition at line 72 of file PatBJetTrackAnalyzer.cc.

73  : jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
74  tracksToken_(consumes<reco::TrackCollection>(params.getParameter<edm::InputTag>("tracks"))),
75  beamSpotToken_(consumes<reco::BeamSpot>(params.getParameter<edm::InputTag>("beamSpot"))),
76  primaryVerticesToken_(consumes<reco::VertexCollection>(params.getParameter<edm::InputTag>("primaryVertices"))),
77  jetPtCut_(params.getParameter<double>("jetPtCut")),
78  jetEtaCut_(params.getParameter<double>("jetEtaCut")),
79  maxDeltaR_(params.getParameter<double>("maxDeltaR")),
80  minPt_(params.getParameter<double>("minPt")),
81  minPixelHits_(params.getParameter<unsigned int>("minPixelHits")),
82  minTotalHits_(params.getParameter<unsigned int>("minTotalHits")),
83  nThTrack_(params.getParameter<unsigned int>("nThTrack")) {}
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
edm::EDGetTokenT< reco::VertexCollection > primaryVerticesToken_
edm::EDGetTokenT< pat::JetCollection > jetsToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
PatBJetTrackAnalyzer::~PatBJetTrackAnalyzer ( )
override

Definition at line 85 of file PatBJetTrackAnalyzer.cc.

85 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 167 of file PatBJetTrackAnalyzer.cc.

References funct::abs(), ALL_JETS, PatBJetTrackAnalyzer::Plots::allDeltaR, PatBJetTrackAnalyzer::Plots::allIP, PatBJetTrackAnalyzer::Plots::allIPErr, PatBJetTrackAnalyzer::Plots::allIPSig, B_JETS, beam_dqm_sourceclient-live_cfg::beamSpot, beamSpotToken_, C_JETS, HLT_FULL_cff::DeltaR, HLT_FULL_cff::deltaR, Measurement1D::error(), flavours_, metsig::jet, jetEtaCut_, jetPtCut_, jetsToken_, maxDeltaR_, minPixelHits_, minPt_, minTotalHits_, PatBJetTrackAnalyzer::Plots::negativeIP, PatBJetTrackAnalyzer::Plots::negativeIPErr, PatBJetTrackAnalyzer::Plots::negativeIPSig, NONID_JETS, nThTrack_, PatBJetTrackAnalyzer::Plots::nTracks, plots_, primaryVerticesToken_, MetAnalyzer::pv(), jetcorrextractor::sign(), Measurement1D::significance(), significanceHigher(), HLT_FULL_cff::track, PatBJetTrackAnalyzer::Plots::trackIP, PatBJetTrackAnalyzer::Plots::trackIPErr, PatBJetTrackAnalyzer::Plots::trackIPSig, tracksToken_, UDSG_JETS, and Measurement1D::value().

167  {
168  // handle to the primary vertex collection
170  event.getByToken(primaryVerticesToken_, pvHandle);
171 
172  // handle to the tracks collection
174  event.getByToken(tracksToken_, tracksHandle);
175 
176  // handle to the jets collection
178  event.getByToken(jetsToken_, jetsHandle);
179 
180  // handle to the beam spot
182  event.getByToken(beamSpotToken_, beamSpot);
183 
184  // rare case of no reconstructed primary vertex
185  if (pvHandle->empty())
186  return;
187 
188  // extract the position of the (most probable) reconstructed vertex
189  math::XYZPoint pv = (*pvHandle)[0].position();
190 
191  // now go through all jets
192  for (pat::JetCollection::const_iterator jet = jetsHandle->begin(); jet != jetsHandle->end(); ++jet) {
193  // only look at jets that pass the pt and eta cut
194  if (jet->pt() < jetPtCut_ || std::abs(jet->eta()) > jetEtaCut_)
195  continue;
196 
198  // find out the jet flavour (differs between quark and anti-quark)
199  switch (std::abs(jet->partonFlavour())) {
200  case 1:
201  case 2:
202  case 3:
203  case 21:
204  flavour = UDSG_JETS;
205  break;
206  case 4:
207  flavour = C_JETS;
208  break;
209  case 5:
210  flavour = B_JETS;
211  break;
212  default:
213  flavour = NONID_JETS;
214  }
215 
216  // simply count the number of accepted jets
217  flavours_->Fill(ALL_JETS);
218  flavours_->Fill(flavour);
219 
220  // this vector will contain IP value / error pairs
221  std::vector<Measurement1D> ipValErr;
222 
223  // Note: PAT is also able to store associated tracks
224  // within the jet object, so we don't have to do the
225  // matching ourselves
226  // (see ->associatedTracks() method)
227  // However, using this we can't play with the DeltaR cone
228  // withour rerunning the PAT producer
229 
230  // now loop through all tracks
231  for (reco::TrackCollection::const_iterator track = tracksHandle->begin(); track != tracksHandle->end(); ++track) {
232  // check the quality criteria
233  if (track->pt() < minPt_ || track->hitPattern().numberOfValidHits() < (int)minTotalHits_ ||
234  track->hitPattern().numberOfValidPixelHits() < (int)minPixelHits_)
235  continue;
236 
237  // check the Delta R between jet axis and track
238  // (Delta_R^2 = Delta_Eta^2 + Delta_Phi^2)
239  double deltaR = ROOT::Math::VectorUtil::DeltaR(jet->momentum(), track->momentum());
240 
241  plots_[ALL_JETS].allDeltaR->Fill(deltaR);
242  plots_[flavour].allDeltaR->Fill(deltaR);
243 
244  // only look at tracks in jet cone
245  if (deltaR > maxDeltaR_)
246  continue;
247 
248  // What follows here is an approximation!
249  //
250  // The dxy() method of the tracks does a linear
251  // extrapolation from the track reference position
252  // given as the closest point to the beam spot
253  // with respect to the given vertex.
254  // Since we are using primary vertices, this
255  // approximation works well
256  //
257  // In order to get better results, the
258  // "TransientTrack" and specialised methods have
259  // to be used.
260  // Or look at the "impactParameterTagInfos",
261  // which contains the precomputed information
262  // from the official b-tagging algorithms
263  //
264  // see ->tagInfoTrackIP() method
265 
266  double ipError = track->dxyError();
267  double ipValue = std::abs(track->dxy(pv));
268 
269  // in order to compute the sign, we check if
270  // the point of closest approach to the vertex
271  // is in front or behind the vertex.
272  // Again, we a linear approximation
273  //
274  // dot product between reference point and jet axis
275 
276  math::XYZVector closestPoint = track->referencePoint() - beamSpot->position();
277  // only interested in transverse component, z -> 0
278  closestPoint.SetZ(0.);
279  double sign = closestPoint.Dot(jet->momentum());
280 
281  if (sign < 0)
282  ipValue = -ipValue;
283 
284  ipValErr.push_back(Measurement1D(ipValue, ipError));
285  }
286 
287  // now order all tracks by significance (highest first)
288  std::sort(ipValErr.begin(), ipValErr.end(), significanceHigher);
289 
290  plots_[ALL_JETS].nTracks->Fill(ipValErr.size());
291  plots_[flavour].nTracks->Fill(ipValErr.size());
292 
293  // plot all tracks
294 
295  for (std::vector<Measurement1D>::const_iterator iter = ipValErr.begin(); iter != ipValErr.end(); ++iter) {
296  plots_[ALL_JETS].allIP->Fill(iter->value());
297  plots_[flavour].allIP->Fill(iter->value());
298 
299  plots_[ALL_JETS].allIPErr->Fill(iter->error());
300  plots_[flavour].allIPErr->Fill(iter->error());
301 
302  // significance (is really just value / error)
303  plots_[ALL_JETS].allIPSig->Fill(iter->significance());
304  plots_[flavour].allIPSig->Fill(iter->significance());
305  }
306 
307  // check if we have enough tracks to fulfill the
308  // n-th track requirement
309  if (ipValErr.size() < nThTrack_)
310  continue;
311 
312  // pick the n-th highest track
313  const Measurement1D *trk = &ipValErr[nThTrack_ - 1];
314 
315  plots_[ALL_JETS].trackIP->Fill(trk->value());
316  plots_[flavour].trackIP->Fill(trk->value());
317 
318  plots_[ALL_JETS].trackIPErr->Fill(trk->error());
319  plots_[flavour].trackIPErr->Fill(trk->error());
320 
321  plots_[ALL_JETS].trackIPSig->Fill(trk->significance());
322  plots_[flavour].trackIPSig->Fill(trk->significance());
323 
324  // here we define a "negative tagger", i.e. we take
325  // the track with the n-lowest signed IP
326  // (i.e. preferrably select tracks that appear to become
327  // from "behind" the primary vertex, supposedly mismeasured
328  // tracks really coming from the primary vertex, and
329  // the contamination of displaced tracks should be small)
330  trk = &ipValErr[ipValErr.size() - nThTrack_];
331 
332  plots_[ALL_JETS].negativeIP->Fill(trk->value());
333  plots_[flavour].negativeIP->Fill(trk->value());
334 
335  plots_[ALL_JETS].negativeIPErr->Fill(trk->error());
336  plots_[flavour].negativeIPErr->Fill(trk->error());
337 
338  plots_[ALL_JETS].negativeIPSig->Fill(trk->significance());
339  plots_[flavour].negativeIPSig->Fill(trk->significance());
340  }
341 }
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
edm::EDGetTokenT< reco::VertexCollection > primaryVerticesToken_
static bool significanceHigher(const Measurement1D &meas1, const Measurement1D &meas2)
edm::EDGetTokenT< pat::JetCollection > jetsToken_
double sign(double x)
double error() const
Definition: Measurement1D.h:27
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double significance() const
Definition: Measurement1D.h:29
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
struct PatBJetTrackAnalyzer::Plots plots_[N_JET_TYPES]
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
double value() const
Definition: Measurement1D.h:25
void PatBJetTrackAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 87 of file PatBJetTrackAnalyzer.cc.

References ALL_JETS, PatBJetTrackAnalyzer::Plots::allDeltaR, PatBJetTrackAnalyzer::Plots::allIP, PatBJetTrackAnalyzer::Plots::allIPErr, PatBJetTrackAnalyzer::Plots::allIPSig, B_JETS, C_JETS, flavours_, mps_fire::i, TFileService::make(), N_JET_TYPES, mergeVDriftHistosByStation::name, PatBJetTrackAnalyzer::Plots::negativeIP, PatBJetTrackAnalyzer::Plots::negativeIPErr, PatBJetTrackAnalyzer::Plots::negativeIPSig, PatBJetTrackAnalyzer::Plots::nTracks, L1TEGammaDiff_cfi::plots, plots_, PatBJetTrackAnalyzer::Plots::trackIP, PatBJetTrackAnalyzer::Plots::trackIPErr, PatBJetTrackAnalyzer::Plots::trackIPSig, and UDSG_JETS.

87  {
88  // retrieve handle to auxiliary service
89  // used for storing histograms into ROOT file
91 
92  flavours_ = fs->make<TH1F>("flavours", "jet flavours", 5, 0, 5);
93 
94  // book histograms for all jet flavours
95  for (unsigned int i = 0; i < N_JET_TYPES; i++) {
96  Plots &plots = plots_[i];
97  const char *flavour, *name;
98 
99  switch ((Flavour)i) {
100  case ALL_JETS:
101  flavour = "all jets";
102  name = "all";
103  break;
104  case UDSG_JETS:
105  flavour = "light flavour jets";
106  name = "udsg";
107  break;
108  case C_JETS:
109  flavour = "charm jets";
110  name = "c";
111  break;
112  case B_JETS:
113  flavour = "bottom jets";
114  name = "b";
115  break;
116  default:
117  flavour = "unidentified jets";
118  name = "ni";
119  break;
120  }
121 
122  plots.allIP =
123  fs->make<TH1F>(Form("allIP_%s", name), Form("signed IP for all tracks in %s", flavour), 100, -0.1, 0.2);
124  plots.allIPErr = fs->make<TH1F>(
125  Form("allIPErr_%s", name), Form("error of signed IP for all tracks in %s", flavour), 100, 0, 0.05);
126  plots.allIPSig = fs->make<TH1F>(
127  Form("allIPSig_%s", name), Form("signed IP significance for all tracks in %s", flavour), 100, -10, 20);
128 
129  plots.trackIP = fs->make<TH1F>(
130  Form("trackIP_%s", name), Form("signed IP for selected positive track in %s", flavour), 100, -0.1, 0.2);
131  plots.trackIPErr = fs->make<TH1F>(Form("trackIPErr_%s", name),
132  Form("error of signed IP for selected positive track in %s", flavour),
133  100,
134  0,
135  0.05);
136  plots.trackIPSig = fs->make<TH1F>(Form("trackIPSig_%s", name),
137  Form("signed IP significance for selected positive track in %s", flavour),
138  100,
139  -10,
140  20);
141 
142  plots.negativeIP = fs->make<TH1F>(
143  Form("negativeIP_%s", name), Form("signed IP for selected negative track in %s", flavour), 100, -0.2, 0.1);
144  plots.negativeIPErr = fs->make<TH1F>(Form("negativeIPErr_%s", name),
145  Form("error of signed IP for selected negative track in %s", flavour),
146  100,
147  0,
148  0.05);
149  plots.negativeIPSig = fs->make<TH1F>(Form("negativeIPSig_%s", name),
150  Form("signed IP significance for selected negative track in %s", flavour),
151  100,
152  -20,
153  10);
154 
155  plots.nTracks = fs->make<TH1F>(Form("nTracks_%s", name), Form("number of usable tracks in %s", flavour), 30, 0, 30);
156  plots.allDeltaR =
157  fs->make<TH1F>(Form("allDeltaR_%s", name), Form("\\DeltaR between track and %s", flavour), 100, 0, 1);
158  }
159 }
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
struct PatBJetTrackAnalyzer::Plots plots_[N_JET_TYPES]

Member Data Documentation

edm::EDGetTokenT<reco::BeamSpot> PatBJetTrackAnalyzer::beamSpotToken_
private

Definition at line 44 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

TH1* PatBJetTrackAnalyzer::flavours_
private

Definition at line 61 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze(), and beginJob().

double PatBJetTrackAnalyzer::jetEtaCut_
private

Definition at line 48 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

double PatBJetTrackAnalyzer::jetPtCut_
private

Definition at line 47 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

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

Definition at line 42 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

double PatBJetTrackAnalyzer::maxDeltaR_
private

Definition at line 49 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

unsigned int PatBJetTrackAnalyzer::minPixelHits_
private

Definition at line 52 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

double PatBJetTrackAnalyzer::minPt_
private

Definition at line 51 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

unsigned int PatBJetTrackAnalyzer::minTotalHits_
private

Definition at line 53 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

unsigned int PatBJetTrackAnalyzer::nThTrack_
private

Definition at line 55 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

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

Referenced by analyze(), and beginJob().

edm::EDGetTokenT<reco::VertexCollection> PatBJetTrackAnalyzer::primaryVerticesToken_
private

Definition at line 45 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().

edm::EDGetTokenT<reco::TrackCollection> PatBJetTrackAnalyzer::tracksToken_
private

Definition at line 43 of file PatBJetTrackAnalyzer.cc.

Referenced by analyze().