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 Member Functions | Private Attributes
QualityCutsAnalyzer Class Reference
Inheritance diagram for QualityCutsAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  histogram_element_t
 
class  histogram_t
 

Public Member Functions

 QualityCutsAnalyzer (const edm::ParameterSet &)
 
 ~QualityCutsAnalyzer ()
 
- 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

typedef std::vector
< std::vector
< histogram_element_t > > 
histogram_data_t
 
typedef std::vector< int > vint
 
typedef std::vector< std::string > vstring
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
virtual void beginJob () override
 
virtual void endJob () override
 
void LoopOverJetTracksAssociation (const edm::ESHandle< TransientTrackBuilder > &, const edm::Handle< reco::VertexCollection > &, const edm::Handle< reco::JetTracksAssociationCollection > &)
 

Private Attributes

TrackClassifier classifier_
 
histogram_data_t histogram_data_
 
edm::InputTag jetTracksAssociation_
 
double maximumChiSquared_
 
int minimumNumberOfHits_
 
int minimumNumberOfPixelHits_
 
double minimumTransverseMomentum_
 
edm::InputTag primaryVertexProducer_
 
std::string rootFile_
 
edm::InputTag trackProducer_
 
reco::TrackBase::TrackQuality trackQuality_
 
bool useAllQualities_
 

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 36 of file QualityCutsAnalyzer.cc.

Member Typedef Documentation

typedef std::vector<std::vector<histogram_element_t> > QualityCutsAnalyzer::histogram_data_t
private

Definition at line 115 of file QualityCutsAnalyzer.cc.

typedef std::vector<int> QualityCutsAnalyzer::vint
private

Definition at line 52 of file QualityCutsAnalyzer.cc.

typedef std::vector<std::string> QualityCutsAnalyzer::vstring
private

Definition at line 53 of file QualityCutsAnalyzer.cc.

Constructor & Destructor Documentation

QualityCutsAnalyzer::QualityCutsAnalyzer ( const edm::ParameterSet config)
explicit

Definition at line 222 of file QualityCutsAnalyzer.cc.

References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), jetTracksAssociation_, maximumChiSquared_, minimumNumberOfHits_, minimumNumberOfPixelHits_, minimumTransverseMomentum_, primaryVertexProducer_, reco::TrackBase::qualityByName(), rootFile_, AlCaHLTBitMon_QueryRunRegistry::string, trackProducer_, trackQuality_, create_public_lumi_plots::transform, and useAllQualities_.

222  : classifier_(config)
223 {
224  trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
225  primaryVertexProducer_ = config.getUntrackedParameter<edm::InputTag> ( "primaryVertexProducer" );
226  jetTracksAssociation_ = config.getUntrackedParameter<edm::InputTag> ( "jetTracksAssociation" );
227 
228  rootFile_ = config.getUntrackedParameter<std::string> ( "rootFile" );
229 
230  minimumNumberOfHits_ = config.getUntrackedParameter<int> ( "minimumNumberOfHits" );
231  minimumNumberOfPixelHits_ = config.getUntrackedParameter<int> ( "minimumNumberOfPixelHits" );
232  minimumTransverseMomentum_ = config.getUntrackedParameter<double> ( "minimumTransverseMomentum" );
233  maximumChiSquared_ = config.getUntrackedParameter<double> ( "maximumChiSquared" );
234 
235  std::string trackQualityType = config.getUntrackedParameter<std::string>("trackQualityClass"); //used
236  trackQuality_ = reco::TrackBase::qualityByName(trackQualityType);
237  useAllQualities_ = false;
238 
239  std::transform(trackQualityType.begin(), trackQualityType.end(), trackQualityType.begin(), (int(*)(int)) std::tolower);
240  if (trackQualityType == "any")
241  {
242  std::cout << "Using any" << std::endl;
243  useAllQualities_ = true;
244  }
245 }
T getUntrackedParameter(std::string const &, T const &) const
reco::TrackBase::TrackQuality trackQuality_
TrackClassifier classifier_
edm::InputTag trackProducer_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:46
edm::InputTag primaryVertexProducer_
tuple cout
Definition: gather_cfg.py:121
edm::InputTag jetTracksAssociation_
QualityCutsAnalyzer::~QualityCutsAnalyzer ( )

Definition at line 247 of file QualityCutsAnalyzer.cc.

247 {}

Member Function Documentation

void QualityCutsAnalyzer::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 255 of file QualityCutsAnalyzer.cc.

References classifier_, edm::EventSetup::get(), jetTracksAssociation_, LoopOverJetTracksAssociation(), TrackClassifier::newEvent(), primaryVertexProducer_, and trackProducer_.

256 {
257  // Track collection
258  edm::Handle<edm::View<reco::Track> > trackCollection;
259  event.getByLabel(trackProducer_,trackCollection);
260  // Primary vertex
261  edm::Handle<reco::VertexCollection> primaryVertexCollection;
262  event.getByLabel(primaryVertexProducer_, primaryVertexCollection);
263  // Jet to tracks associator
265  event.getByLabel(jetTracksAssociation_, jetTracks);
266  // Trasient track builder
268  setup.get<TransientTrackRecord>().get("TransientTrackBuilder", TTbuilder);
269 
270  // Setting up event information for the track categories.
271  classifier_.newEvent(event, setup);
272 
274  TTbuilder,
275  primaryVertexCollection,
276  jetTracks
277  );
278 }
void LoopOverJetTracksAssociation(const edm::ESHandle< TransientTrackBuilder > &, const edm::Handle< reco::VertexCollection > &, const edm::Handle< reco::JetTracksAssociationCollection > &)
TrackClassifier classifier_
void newEvent(edm::Event const &, edm::EventSetup const &)
Pre-process event information (for accessing reconstraction information)
edm::InputTag trackProducer_
const T & get() const
Definition: EventSetup.h:55
edm::InputTag primaryVertexProducer_
edm::InputTag jetTracksAssociation_
void QualityCutsAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 283 of file QualityCutsAnalyzer.cc.

References histogram_data_.

284 {
285  histogram_data_.resize(6);
286 }
histogram_data_t histogram_data_
void QualityCutsAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 291 of file QualityCutsAnalyzer.cc.

References mergeVDriftHistosByStation::file, QualityCutsAnalyzer::histogram_t::Fill(), histogram_data_, i, j, rootFile_, AlCaHLTBitMon_QueryRunRegistry::string, and QualityCutsAnalyzer::histogram_t::Write().

292 {
293  TFile file(rootFile_.c_str(), "RECREATE");
294  file.cd();
295 
296  // saving the histograms
297  for (std::size_t i=0; i<6; i++)
298  {
299  std::string particle;
300  if (i == 0)
301  particle = std::string("B_tracks");
302  else if (i == 1)
303  particle = std::string("C_tracks");
304  else if (i == 2)
305  particle = std::string("nonB_tracks");
306  else if (i == 3)
307  particle = std::string("displaced_tracks");
308  else if (i == 4)
309  particle = std::string("bad_tracks");
310  else
311  particle = std::string("fake_tracks");
312 
313  histogram_t histogram(particle);
314 
315  for (std::size_t j=0; j<histogram_data_[i].size(); j++)
316  histogram.Fill(histogram_data_[i][j]);
317 
318  histogram.Write();
319  }
320 
321  file.Flush();
322 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
histogram_data_t histogram_data_
void QualityCutsAnalyzer::LoopOverJetTracksAssociation ( const edm::ESHandle< TransientTrackBuilder > &  TTbuilder,
const edm::Handle< reco::VertexCollection > &  primaryVertexProducer_,
const edm::Handle< reco::JetTracksAssociationCollection > &  jetTracksAssociation 
)
private

Definition at line 326 of file QualityCutsAnalyzer.cc.

References TrackCategories::Bad, TransientTrackBuilder::build(), TrackCategories::BWeakDecay, classifier_, TrackCategories::CWeakDecay, alignCSCRings::e, TrackClassifier::evaluate(), TrackCategories::Fake, histogram_data_, i, cmsHarvester::index, TrackCategories::is(), IPTools::jetTrackDistance(), maximumChiSquared_, minimumNumberOfHits_, minimumNumberOfPixelHits_, minimumTransverseMomentum_, AlCaHLTBitMon_ParallelJobs::p, TrackCategories::PrimaryVertex, edm::Handle< T >::product(), edm::ESHandle< class >::product(), RecoTauCleanerPlugins::pt, IPTools::signedDecayLength3D(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), PrimaryVertexSorter::sortedList(), trackQuality_, testEve_cfg::tracks, useAllQualities_, and reco::Vertex::z().

Referenced by analyze().

331 {
332  const TransientTrackBuilder * bproduct = TTbuilder.product();
333 
334  // getting the primary vertex
335  // use first pv of the collection
336  reco::Vertex pv;
337 
338  if (primaryVertexProducer_->size() != 0)
339  {
341  std::vector<reco::Vertex> sortedList = pvs.sortedList(*(primaryVertexProducer_.product()));
342  pv = (sortedList.front());
343  }
344  else
345  { // create a dummy PV
346  // cout << "NO PV FOUND" << endl;
348  e(0,0)=0.0015*0.0015;
349  e(1,1)=0.0015*0.0015;
350  e(2,2)=15.*15.;
351  reco::Vertex::Point p(0,0,0);
352  pv = reco::Vertex(p,e,1,1,1);
353  }
354 
355  reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
356 
357  int i=0;
358 
359  for (; it != jetTracksAssociation->end(); it++, i++)
360  {
361  // get jetTracks object
362  reco::JetTracksAssociationRef jetTracks(jetTracksAssociation, i);
363 
364  double pvZ = pv.z();
365  GlobalVector direction(jetTracks->first->px(), jetTracks->first->py(), jetTracks->first->pz());
366 
367  // get the tracks associated to the jet
368  reco::TrackRefVector tracks = jetTracks->second;
369  for (std::size_t index = 0; index < tracks.size(); index++)
370  {
371  edm::RefToBase<reco::Track> track(tracks[index]);
372 
373  double pt = tracks[index]->pt();
374  double chi2 = tracks[index]->normalizedChi2();
375  int hits = tracks[index]->hitPattern().numberOfValidHits();
376  int pixelHits = tracks[index]->hitPattern().numberOfValidPixelHits();
377 
378  if (
379  hits < minimumNumberOfHits_ ||
380  pixelHits < minimumNumberOfPixelHits_ ||
382  chi2 > maximumChiSquared_ ||
383  (!useAllQualities_ && !tracks[index]->quality(trackQuality_))
384  ) continue;
385 
386  const reco::TransientTrack transientTrack = bproduct->build(&(*tracks[index]));
387  double dta = - IPTools::jetTrackDistance(transientTrack, direction, pv).second.value();
388  double sdl = IPTools::signedDecayLength3D(transientTrack, direction, pv).second.value();
389  double ips = IPTools::signedImpactParameter3D(transientTrack, direction, pv).second.value();
390  double d0 = IPTools::signedTransverseImpactParameter(transientTrack, direction, pv).second.value();
391  double dz = tracks[index]->dz() - pvZ;
392 
393  // Classify the reco track;
395 
396  // Check for the different categories
398  histogram_data_[5].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
400  histogram_data_[0].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
401  else if ( classifier_.is(TrackClassifier::Bad) )
402  histogram_data_[4].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
403  else if (
406  )
407  histogram_data_[3].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
409  histogram_data_[1].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
410  else
411  histogram_data_[2].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
412 
413  }
414  }
415 }
int i
Definition: DBlmapReader.cc:9
std::vector< reco::Vertex > sortedList(const reco::VertexCollection &primaryVertex) const
transient_vector_type::const_iterator const_iterator
reco::TrackBase::TrackQuality trackQuality_
std::pair< bool, Measurement1D > signedTransverseImpactParameter(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:50
std::pair< bool, Measurement1D > signedDecayLength3D(const TrajectoryStateOnSurface &state, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:94
reco::TransientTrack build(const reco::Track *p) const
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::pair< bool, Measurement1D > signedImpactParameter3D(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:71
TrackClassifier classifier_
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
TrackClassifier const & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
double z() const
y coordinate
Definition: Vertex.h:112
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool is(Category category) const
Returns track flag for a given category.
tuple tracks
Definition: testEve_cfg.py:39
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:81
histogram_data_t histogram_data_

Member Data Documentation

TrackClassifier QualityCutsAnalyzer::classifier_
private

Definition at line 214 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and LoopOverJetTracksAssociation().

histogram_data_t QualityCutsAnalyzer::histogram_data_
private

Definition at line 116 of file QualityCutsAnalyzer.cc.

Referenced by beginJob(), endJob(), and LoopOverJetTracksAssociation().

edm::InputTag QualityCutsAnalyzer::jetTracksAssociation_
private

Definition at line 57 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

double QualityCutsAnalyzer::maximumChiSquared_
private

Definition at line 62 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

int QualityCutsAnalyzer::minimumNumberOfHits_
private

Definition at line 61 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

int QualityCutsAnalyzer::minimumNumberOfPixelHits_
private

Definition at line 61 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

double QualityCutsAnalyzer::minimumTransverseMomentum_
private

Definition at line 62 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

edm::InputTag QualityCutsAnalyzer::primaryVertexProducer_
private

Definition at line 56 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

std::string QualityCutsAnalyzer::rootFile_
private

Definition at line 59 of file QualityCutsAnalyzer.cc.

Referenced by endJob(), and QualityCutsAnalyzer().

edm::InputTag QualityCutsAnalyzer::trackProducer_
private

Definition at line 55 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

reco::TrackBase::TrackQuality QualityCutsAnalyzer::trackQuality_
private

Definition at line 65 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

bool QualityCutsAnalyzer::useAllQualities_
private

Definition at line 64 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().