CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
QualityCutsAnalyzer Class Reference
Inheritance diagram for QualityCutsAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  histogram_element_t
 
class  histogram_t
 

Public Member Functions

 QualityCutsAnalyzer (const edm::ParameterSet &)
 
 ~QualityCutsAnalyzer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
ESProxyIndex const * esGetTokenIndices (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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

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

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
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::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)
 
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<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 106 of file QualityCutsAnalyzer.cc.

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

Definition at line 48 of file QualityCutsAnalyzer.cc.

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

Definition at line 49 of file QualityCutsAnalyzer.cc.

Constructor & Destructor Documentation

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

Definition at line 204 of file QualityCutsAnalyzer.cc.

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

204  : classifier_(config, consumesCollector()) {
205  trackProducer_ = config.getUntrackedParameter<edm::InputTag>("trackProducer");
206  consumes<edm::View<reco::Track>>(trackProducer_);
207  primaryVertexProducer_ = config.getUntrackedParameter<edm::InputTag>("primaryVertexProducer");
208  consumes<reco::VertexCollection>(primaryVertexProducer_);
209  jetTracksAssociation_ = config.getUntrackedParameter<edm::InputTag>("jetTracksAssociation");
210  consumes<reco::JetTracksAssociationCollection>(jetTracksAssociation_);
211 
212  rootFile_ = config.getUntrackedParameter<std::string>("rootFile");
213 
214  minimumNumberOfHits_ = config.getUntrackedParameter<int>("minimumNumberOfHits");
215  minimumNumberOfPixelHits_ = config.getUntrackedParameter<int>("minimumNumberOfPixelHits");
216  minimumTransverseMomentum_ = config.getUntrackedParameter<double>("minimumTransverseMomentum");
217  maximumChiSquared_ = config.getUntrackedParameter<double>("maximumChiSquared");
218 
219  std::string trackQualityType = config.getUntrackedParameter<std::string>("trackQualityClass"); // used
220  trackQuality_ = reco::TrackBase::qualityByName(trackQualityType);
221  useAllQualities_ = false;
222 
224  trackQualityType.begin(), trackQualityType.end(), trackQualityType.begin(), (int (*)(int))std::tolower);
225  if (trackQualityType == "any") {
226  std::cout << "Using any" << std::endl;
227  useAllQualities_ = true;
228  }
229 }
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:126
edm::InputTag primaryVertexProducer_
edm::InputTag jetTracksAssociation_
unsigned transform(const HcalDetId &id, unsigned transformCode)
QualityCutsAnalyzer::~QualityCutsAnalyzer ( )
override

Definition at line 231 of file QualityCutsAnalyzer.cc.

231 {}

Member Function Documentation

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

Definition at line 238 of file QualityCutsAnalyzer.cc.

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

238  {
239  // Track collection
241  event.getByLabel(trackProducer_, trackCollection);
242  // Primary vertex
243  edm::Handle<reco::VertexCollection> primaryVertexCollection;
244  event.getByLabel(primaryVertexProducer_, primaryVertexCollection);
245  // Jet to tracks associator
247  event.getByLabel(jetTracksAssociation_, jetTracks);
248  // Trasient track builder
250  setup.get<TransientTrackRecord>().get("TransientTrackBuilder", TTbuilder);
251 
252  // Setting up event information for the track categories.
253  classifier_.newEvent(event, setup);
254 
255  LoopOverJetTracksAssociation(TTbuilder, primaryVertexCollection, jetTracks);
256 }
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_
T get() const
Definition: EventSetup.h:73
edm::InputTag primaryVertexProducer_
edm::InputTag jetTracksAssociation_
void QualityCutsAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 260 of file QualityCutsAnalyzer.cc.

References histogram_data_.

260 { histogram_data_.resize(6); }
histogram_data_t histogram_data_
void QualityCutsAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 264 of file QualityCutsAnalyzer.cc.

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

264  {
265  TFile file(rootFile_.c_str(), "RECREATE");
266  file.cd();
267 
268  // saving the histograms
269  for (std::size_t i = 0; i < 6; i++) {
270  std::string particle;
271  if (i == 0)
272  particle = std::string("B_tracks");
273  else if (i == 1)
274  particle = std::string("C_tracks");
275  else if (i == 2)
276  particle = std::string("nonB_tracks");
277  else if (i == 3)
278  particle = std::string("displaced_tracks");
279  else if (i == 4)
280  particle = std::string("bad_tracks");
281  else
282  particle = std::string("fake_tracks");
283 
284  histogram_t histogram(particle);
285 
286  for (std::size_t j = 0; j < histogram_data_[i].size(); j++)
287  histogram.Fill(histogram_data_[i][j]);
288 
289  histogram.Write();
290  }
291 
292  file.Flush();
293 }
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 295 of file QualityCutsAnalyzer.cc.

References TrackCategories::Bad, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::begin(), TransientTrackBuilder::build(), TrackCategories::BWeakDecay, hltPixelTracks_cff::chi2, classifier_, TrackCategories::CWeakDecay, HLTMuonOfflineAnalyzer_cfi::d0, DEFINE_FWK_MODULE, PVValHelper::dz, MillePedeFileConverter_cfg::e, edm::AssociationVector< KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper >::end(), TrackClassifier::evaluate(), TrackCategories::Fake, histogram_data_, hfClusterShapes_cfi::hits, mps_fire::i, TrackCategories::is(), IPTools::jetTrackDistance(), HLT_2018_cff::jetTracks, maximumChiSquared_, minimumNumberOfHits_, minimumNumberOfPixelHits_, minimumTransverseMomentum_, AlCaHLTBitMon_ParallelJobs::p, TrackCategories::PrimaryVertex, edm::Handle< T >::product(), edm::ESHandle< T >::product(), DiDispStaMuonMonitor_cfi::pt, MetAnalyzer::pv(), FSQDQM_cfi::pvs, qcdUeDQM_cfi::quality, IPTools::signedDecayLength3D(), IPTools::signedImpactParameter3D(), IPTools::signedTransverseImpactParameter(), PrimaryVertexSorter< ParticlesCollection >::sortedList(), HLT_2018_cff::track, trackQuality_, PDWG_EXOHSCP_cff::tracks, useAllQualities_, HltBtagValidation_cff::Vertex, and reco::Vertex::z().

Referenced by analyze().

298  {
299  const TransientTrackBuilder *bproduct = TTbuilder.product();
300 
301  // getting the primary vertex
302  // use first pv of the collection
304 
305  if (!primaryVertexProducer_->empty()) {
307  std::vector<reco::Vertex> sortedList = pvs.sortedList(*(primaryVertexProducer_.product()));
308  pv = (sortedList.front());
309  } else { // create a dummy PV
310  // cout << "NO PV FOUND" << endl;
312  e(0, 0) = 0.0015 * 0.0015;
313  e(1, 1) = 0.0015 * 0.0015;
314  e(2, 2) = 15. * 15.;
315  reco::Vertex::Point p(0, 0, 0);
316  pv = reco::Vertex(p, e, 1, 1, 1);
317  }
318 
319  reco::JetTracksAssociationCollection::const_iterator it = jetTracksAssociation->begin();
320 
321  int i = 0;
322 
323  for (; it != jetTracksAssociation->end(); it++, i++) {
324  // get jetTracks object
325  reco::JetTracksAssociationRef jetTracks(jetTracksAssociation, i);
326 
327  double pvZ = pv.z();
328  GlobalVector direction(jetTracks->first->px(), jetTracks->first->py(), jetTracks->first->pz());
329 
330  // get the tracks associated to the jet
332  for (std::size_t index = 0; index < tracks.size(); index++) {
334 
335  double pt = tracks[index]->pt();
336  double chi2 = tracks[index]->normalizedChi2();
337  int hits = tracks[index]->hitPattern().numberOfValidHits();
338  int pixelHits = tracks[index]->hitPattern().numberOfValidPixelHits();
339 
342  continue;
343 
344  const reco::TransientTrack transientTrack = bproduct->build(&(*tracks[index]));
345  double dta = -IPTools::jetTrackDistance(transientTrack, direction, pv).second.value();
346  double sdl = IPTools::signedDecayLength3D(transientTrack, direction, pv).second.value();
347  double ips = IPTools::signedImpactParameter3D(transientTrack, direction, pv).second.value();
348  double d0 = IPTools::signedTransverseImpactParameter(transientTrack, direction, pv).second.value();
349  double dz = tracks[index]->dz() - pvZ;
350 
351  // Classify the reco track;
353 
354  // Check for the different categories
356  histogram_data_[5].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
358  histogram_data_[0].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
360  histogram_data_[4].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
362  histogram_data_[3].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
364  histogram_data_[1].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
365  else
366  histogram_data_[2].push_back(histogram_element_t(sdl, dta, d0, dz, ips, pt, chi2, hits, pixelHits));
367  }
368  }
369 }
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:57
std::pair< bool, Measurement1D > signedDecayLength3D(const TrajectoryStateOnSurface &state, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:105
reco::TransientTrack build(const reco::Track *p) const
std::vector< reco::Vertex > sortedList(const reco::VertexCollection &primaryVertex) const
const_iterator end() 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:81
TrackClassifier classifier_
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:206
TrackClassifier const & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
def pv(vc)
Definition: MetAnalyzer.py:7
double z() const
z coordinate
Definition: Vertex.h:119
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:69
const_iterator begin() const
T const * product() const
Definition: ESHandle.h:86
histogram_data_t histogram_data_

Member Data Documentation

TrackClassifier QualityCutsAnalyzer::classifier_
private

Definition at line 198 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and LoopOverJetTracksAssociation().

histogram_data_t QualityCutsAnalyzer::histogram_data_
private

Definition at line 107 of file QualityCutsAnalyzer.cc.

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

edm::InputTag QualityCutsAnalyzer::jetTracksAssociation_
private

Definition at line 53 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

double QualityCutsAnalyzer::maximumChiSquared_
private

Definition at line 58 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

int QualityCutsAnalyzer::minimumNumberOfHits_
private

Definition at line 57 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

int QualityCutsAnalyzer::minimumNumberOfPixelHits_
private

Definition at line 57 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

double QualityCutsAnalyzer::minimumTransverseMomentum_
private

Definition at line 58 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

edm::InputTag QualityCutsAnalyzer::primaryVertexProducer_
private

Definition at line 52 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

std::string QualityCutsAnalyzer::rootFile_
private

Definition at line 55 of file QualityCutsAnalyzer.cc.

Referenced by endJob(), and QualityCutsAnalyzer().

edm::InputTag QualityCutsAnalyzer::trackProducer_
private

Definition at line 51 of file QualityCutsAnalyzer.cc.

Referenced by analyze(), and QualityCutsAnalyzer().

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

Definition at line 61 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().

bool QualityCutsAnalyzer::useAllQualities_
private

Definition at line 60 of file QualityCutsAnalyzer.cc.

Referenced by LoopOverJetTracksAssociation(), and QualityCutsAnalyzer().