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
std::vector< ConsumesInfoconsumesInfo () const
 
 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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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
 
- 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 &)
 
- 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,consumesCollector())
223 {
224  trackProducer_ = config.getUntrackedParameter<edm::InputTag> ( "trackProducer" );
225  consumes<edm::View<reco::Track>>(trackProducer_);
226  primaryVertexProducer_ = config.getUntrackedParameter<edm::InputTag> ( "primaryVertexProducer" );
227  consumes<reco::VertexCollection>(primaryVertexProducer_);
228  jetTracksAssociation_ = config.getUntrackedParameter<edm::InputTag> ( "jetTracksAssociation" );
229  consumes<reco::JetTracksAssociationCollection>(jetTracksAssociation_);
230 
231  rootFile_ = config.getUntrackedParameter<std::string> ( "rootFile" );
232 
233  minimumNumberOfHits_ = config.getUntrackedParameter<int> ( "minimumNumberOfHits" );
234  minimumNumberOfPixelHits_ = config.getUntrackedParameter<int> ( "minimumNumberOfPixelHits" );
235  minimumTransverseMomentum_ = config.getUntrackedParameter<double> ( "minimumTransverseMomentum" );
236  maximumChiSquared_ = config.getUntrackedParameter<double> ( "maximumChiSquared" );
237 
238  std::string trackQualityType = config.getUntrackedParameter<std::string>("trackQualityClass"); //used
239  trackQuality_ = reco::TrackBase::qualityByName(trackQualityType);
240  useAllQualities_ = false;
241 
242  std::transform(trackQualityType.begin(), trackQualityType.end(), trackQualityType.begin(), (int(*)(int)) std::tolower);
243  if (trackQualityType == "any")
244  {
245  std::cout << "Using any" << std::endl;
246  useAllQualities_ = true;
247  }
248 }
T getUntrackedParameter(std::string const &, T const &) const
reco::TrackBase::TrackQuality trackQuality_
TrackClassifier classifier_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::InputTag trackProducer_
static TrackQuality qualityByName(const std::string &name)
Definition: TrackBase.cc:125
edm::InputTag primaryVertexProducer_
tuple cout
Definition: gather_cfg.py:145
edm::InputTag jetTracksAssociation_
QualityCutsAnalyzer::~QualityCutsAnalyzer ( )

Definition at line 250 of file QualityCutsAnalyzer.cc.

250 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 258 of file QualityCutsAnalyzer.cc.

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

259 {
260  // Track collection
262  event.getByLabel(trackProducer_,trackCollection);
263  // Primary vertex
264  edm::Handle<reco::VertexCollection> primaryVertexCollection;
265  event.getByLabel(primaryVertexProducer_, primaryVertexCollection);
266  // Jet to tracks associator
268  event.getByLabel(jetTracksAssociation_, jetTracks);
269  // Trasient track builder
271  setup.get<TransientTrackRecord>().get("TransientTrackBuilder", TTbuilder);
272 
273  // Setting up event information for the track categories.
274  classifier_.newEvent(event, setup);
275 
277  TTbuilder,
278  primaryVertexCollection,
279  jetTracks
280  );
281 }
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:56
edm::InputTag primaryVertexProducer_
edm::InputTag jetTracksAssociation_
void QualityCutsAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 286 of file QualityCutsAnalyzer.cc.

References histogram_data_.

287 {
288  histogram_data_.resize(6);
289 }
histogram_data_t histogram_data_
void QualityCutsAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 294 of file QualityCutsAnalyzer.cc.

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

295 {
296  TFile file(rootFile_.c_str(), "RECREATE");
297  file.cd();
298 
299  // saving the histograms
300  for (std::size_t i=0; i<6; i++)
301  {
302  std::string particle;
303  if (i == 0)
304  particle = std::string("B_tracks");
305  else if (i == 1)
306  particle = std::string("C_tracks");
307  else if (i == 2)
308  particle = std::string("nonB_tracks");
309  else if (i == 3)
310  particle = std::string("displaced_tracks");
311  else if (i == 4)
312  particle = std::string("bad_tracks");
313  else
314  particle = std::string("fake_tracks");
315 
316  histogram_t histogram(particle);
317 
318  for (std::size_t j=0; j<histogram_data_[i].size(); j++)
319  histogram.Fill(histogram_data_[i][j]);
320 
321  histogram.Write();
322  }
323 
324  file.Flush();
325 }
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 329 of file QualityCutsAnalyzer.cc.

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

Referenced by analyze().

334 {
335  const TransientTrackBuilder * bproduct = TTbuilder.product();
336 
337  // getting the primary vertex
338  // use first pv of the collection
340 
341  if (primaryVertexProducer_->size() != 0)
342  {
344  std::vector<reco::Vertex> sortedList = pvs.sortedList(*(primaryVertexProducer_.product()));
345  pv = (sortedList.front());
346  }
347  else
348  { // create a dummy PV
349  // cout << "NO PV FOUND" << endl;
351  e(0,0)=0.0015*0.0015;
352  e(1,1)=0.0015*0.0015;
353  e(2,2)=15.*15.;
354  reco::Vertex::Point p(0,0,0);
355  pv = reco::Vertex(p,e,1,1,1);
356  }
357 
358  reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
359 
360  int i=0;
361 
362  for (; it != jetTracksAssociation->end(); it++, i++)
363  {
364  // get jetTracks object
365  reco::JetTracksAssociationRef jetTracks(jetTracksAssociation, i);
366 
367  double pvZ = pv.z();
368  GlobalVector direction(jetTracks->first->px(), jetTracks->first->py(), jetTracks->first->pz());
369 
370  // get the tracks associated to the jet
372  for (std::size_t index = 0; index < tracks.size(); index++)
373  {
374  edm::RefToBase<reco::Track> track(tracks[index]);
375 
376  double pt = tracks[index]->pt();
377  double chi2 = tracks[index]->normalizedChi2();
378  int hits = tracks[index]->hitPattern().numberOfValidHits();
379  int pixelHits = tracks[index]->hitPattern().numberOfValidPixelHits();
380 
381  if (
382  hits < minimumNumberOfHits_ ||
383  pixelHits < minimumNumberOfPixelHits_ ||
385  chi2 > maximumChiSquared_ ||
387  ) continue;
388 
389  const reco::TransientTrack transientTrack = bproduct->build(&(*tracks[index]));
390  double dta = - IPTools::jetTrackDistance(transientTrack, direction, pv).second.value();
391  double sdl = IPTools::signedDecayLength3D(transientTrack, direction, pv).second.value();
392  double ips = IPTools::signedImpactParameter3D(transientTrack, direction, pv).second.value();
393  double d0 = IPTools::signedTransverseImpactParameter(transientTrack, direction, pv).second.value();
394  double dz = tracks[index]->dz() - pvZ;
395 
396  // Classify the reco track;
398 
399  // Check for the different categories
401  histogram_data_[5].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
403  histogram_data_[0].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
404  else if ( classifier_.is(TrackClassifier::Bad) )
405  histogram_data_[4].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
406  else if (
409  )
410  histogram_data_[3].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
412  histogram_data_[1].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
413  else
414  histogram_data_[2].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
415 
416  }
417  }
418 }
int i
Definition: DBlmapReader.cc:9
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
std::vector< reco::Vertex > sortedList(const reco::VertexCollection &primaryVertex) 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:105
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool is(Category category) const
Returns track flag for a given category.
T const * product() const
Definition: Handle.h:81
tuple tracks
Definition: testEve_cfg.py:39
T const * product() const
Definition: ESHandle.h:86
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().