CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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

virtual void analyze (const edm::Event &event, const edm::EventSetup &es) override
 
virtual void beginJob () override
 
 PatBJetTrackAnalyzer (const edm::ParameterSet &params)
 constructor and destructor More...
 
 ~PatBJetTrackAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

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 79 of file PatBJetTrackAnalyzer.cc.

79  :
80  jetsToken_(consumes<pat::JetCollection>(params.getParameter<edm::InputTag>("jets"))),
81  tracksToken_(consumes<reco::TrackCollection>(params.getParameter<edm::InputTag>("tracks"))),
82  beamSpotToken_(consumes<reco::BeamSpot>(params.getParameter<edm::InputTag>("beamSpot"))),
83  primaryVerticesToken_(consumes<reco::VertexCollection>(params.getParameter<edm::InputTag>("primaryVertices"))),
84  jetPtCut_(params.getParameter<double>("jetPtCut")),
85  jetEtaCut_(params.getParameter<double>("jetEtaCut")),
86  maxDeltaR_(params.getParameter<double>("maxDeltaR")),
87  minPt_(params.getParameter<double>("minPt")),
88  minPixelHits_(params.getParameter<unsigned int>("minPixelHits")),
89  minTotalHits_(params.getParameter<unsigned int>("minTotalHits")),
90  nThTrack_(params.getParameter<unsigned int>("nThTrack"))
91 {
92 }
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::VertexCollection > primaryVerticesToken_
edm::EDGetTokenT< pat::JetCollection > jetsToken_
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
PatBJetTrackAnalyzer::~PatBJetTrackAnalyzer ( )

Definition at line 94 of file PatBJetTrackAnalyzer.cc.

95 {
96 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 179 of file PatBJetTrackAnalyzer.cc.

References funct::abs(), ALL_JETS, PatBJetTrackAnalyzer::Plots::allDeltaR, PatBJetTrackAnalyzer::Plots::allIP, PatBJetTrackAnalyzer::Plots::allIPErr, PatBJetTrackAnalyzer::Plots::allIPSig, B_JETS, SiPixelRawToDigiRegional_cfi::beamSpot, beamSpotToken_, C_JETS, deltaR(), Measurement1D::error(), reco::flavour(), flavours_, getDQMSummary::iter, 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(), python.multivaluedict::sort(), PatBJetTrackAnalyzer::Plots::trackIP, PatBJetTrackAnalyzer::Plots::trackIPErr, PatBJetTrackAnalyzer::Plots::trackIPSig, tracksToken_, UDSG_JETS, and Measurement1D::value().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 98 of file PatBJetTrackAnalyzer.cc.

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

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

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