CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
TrackClassifier Class Reference

Get track history and classify it in function of their . More...

#include <TrackClassifier.h>

Inheritance diagram for TrackClassifier:
TrackCategories TrackClassifierByProxy< Collection >

Classes

struct  GeneratedPrimaryVertex
 Auxiliary class holding simulated primary vertices. More...
 

Public Types

typedef TrackCategories Categories
 Type to the associate category. More...
 
- Public Types inherited from TrackCategories
enum  Category {
  Fake = 0, Reconstructed = Fake, Bad, BadInnerHits,
  SharedInnerHits, SignalEvent, Bottom, Charm,
  Light, Muon, TrackerSimHits, BWeakDecay,
  CWeakDecay, ChargePionDecay, ChargeKaonDecay, TauDecay,
  KsDecay, LambdaDecay, JpsiDecay, XiDecay,
  OmegaDecay, SigmaPlusDecay, SigmaMinusDecay, LongLivedDecay,
  KnownProcess, UndefinedProcess, UnknownProcess, PrimaryProcess,
  HadronicProcess, DecayProcess, ComptonProcess, AnnihilationProcess,
  EIoniProcess, HIoniProcess, MuIoniProcess, PhotonProcess,
  MuPairProdProcess, ConversionsProcess, EBremProcess, SynchrotronRadiationProcess,
  MuBremProcess, MuNuclProcess, FromBWeakDecayMuon, FromCWeakDecayMuon,
  DecayOnFlightMuon, FromChargePionMuon, FromChargeKaonMuon, PrimaryVertex,
  SecondaryVertex, TertiaryVertex, TierciaryVertex = TertiaryVertex, Unknown
}
 Categories available to vertex. More...
 
typedef std::vector< bool > Flags
 Main types associated to the class. More...
 

Public Member Functions

TrackClassifier const & evaluate (reco::TrackBaseRef const &)
 Classify the RecoTrack in categories. More...
 
TrackClassifier const & evaluate (TrackingParticleRef const &)
 Classify the TrackingParticle in categories. More...
 
TrackClassifier const & evaluate (reco::TrackRef const &track)
 Classify the RecoTrack in categories. More...
 
TrackHistory const & history () const
 Returns a reference to the track history used in the classification. More...
 
void newEvent (edm::Event const &, edm::EventSetup const &)
 Pre-process event information (for accessing reconstraction information) More...
 
TrackQuality const & quality () const
 Returns a reference to the track quality used in the classification. More...
 
 TrackClassifier (edm::ParameterSet const &, edm::ConsumesCollector &&)
 Constructor by ParameterSet. More...
 
- Public Member Functions inherited from TrackCategories
const Flagsflags () const
 Returns flags with the category descriptions. More...
 
bool is (Category category) const
 Returns track flag for a given category. More...
 
 TrackCategories ()
 Void constructor. More...
 

Private Member Functions

void genPrimaryVertices ()
 
void hadronFlavor ()
 Get hadron flavor of the initial hadron. More...
 
bool isCharged (const HepMC::GenParticle *)
 
bool isFinalstateParticle (const HepMC::GenParticle *)
 
void processesAtGenerator ()
 Get all the information related to decay process. More...
 
void processesAtSimulation ()
 Get information about conversion and other interactions. More...
 
void qualityInformation (reco::TrackBaseRef const &)
 Classify all the tracks by their reconstruction quality. More...
 
void reconstructionInformation (reco::TrackBaseRef const &)
 
void simulationInformation ()
 Get all the information related to the simulation details. More...
 
void vertexInformation ()
 Get geometrical information about the vertices. More...
 

Private Attributes

double badPull_
 
edm::Handle< reco::BeamSpotbeamSpot_
 
const edm::InputTag beamSpotLabel_
 
const G4toCMSLegacyProcTypeMap g4toCMSProcMap_
 
std::vector< GeneratedPrimaryVertexgenpvs_
 
const edm::InputTag hepMCLabel_
 
double longLivedDecayLength_
 
edm::ESHandle< MagneticFieldmagneticField_
 
edm::Handle< edm::HepMCProductmcInformation_
 
unsigned int minTrackerSimHits_
 
unsigned int numberOfInnerLayers_
 
edm::ESHandle< ParticleDataTableparticleDataTable_
 
TrackQuality quality_
 
TrackHistory tracer_
 
edm::ESHandle< TransientTrackBuildertransientTrackBuilder_
 
const TrackerTopologytTopo_
 
double vertexClusteringSqDistance_
 

Additional Inherited Members

- Static Public Attributes inherited from TrackCategories
static const char *const Names []
 Name of the different categories. More...
 
- Protected Member Functions inherited from TrackCategories
void reset ()
 Reset the categories flags. More...
 
void unknownTrack ()
 
- Protected Attributes inherited from TrackCategories
Flags flags_
 Flag containers. More...
 

Detailed Description

Get track history and classify it in function of their .

Definition at line 29 of file TrackClassifier.h.

Member Typedef Documentation

Type to the associate category.

Definition at line 32 of file TrackClassifier.h.

Constructor & Destructor Documentation

TrackClassifier::TrackClassifier ( edm::ParameterSet const &  config,
edm::ConsumesCollector &&  collector 
)

Constructor by ParameterSet.

Definition at line 15 of file TrackClassifier.cc.

References badPull_, beamSpotLabel_, HistoryBase::depth(), edm::ParameterSet::getUntrackedParameter(), hepMCLabel_, longLivedDecayLength_, minTrackerSimHits_, numberOfInnerLayers_, tracer_, MuonClassifier_cff::vertexClusteringDistance, and vertexClusteringSqDistance_.

16  : TrackCategories(),
17  hepMCLabel_(config.getUntrackedParameter<edm::InputTag>("hepMC")),
18  beamSpotLabel_(config.getUntrackedParameter<edm::InputTag>("beamSpot")),
19  tracer_(config, std::move(collector)),
20  quality_(config, collector) {
23 
24  // Set the history depth after hadronization
25  tracer_.depth(-2);
26 
27  // Set the maximum d0pull for the bad category
28  badPull_ = config.getUntrackedParameter<double>("badPull");
29 
30  // Set the minimum decay length for detecting long decays
31  longLivedDecayLength_ = config.getUntrackedParameter<double>("longLivedDecayLength");
32 
33  // Set the distance for clustering vertices
34  float vertexClusteringDistance = config.getUntrackedParameter<double>("vertexClusteringDistance");
35  vertexClusteringSqDistance_ = vertexClusteringDistance * vertexClusteringDistance;
36 
37  // Set the number of innermost layers to check for bad hits
38  numberOfInnerLayers_ = config.getUntrackedParameter<unsigned int>("numberOfInnerLayers");
39 
40  // Set the minimum number of simhits in the tracker
41  minTrackerSimHits_ = config.getUntrackedParameter<unsigned int>("minTrackerSimHits");
42 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::InputTag beamSpotLabel_
const edm::InputTag hepMCLabel_
unsigned int numberOfInnerLayers_
Definition: config.py:1
unsigned int minTrackerSimHits_
TrackQuality quality_
TrackCategories()
Void constructor.
void depth(int d)
Set the depth of the history.
Definition: HistoryBase.h:49
double longLivedDecayLength_
double vertexClusteringSqDistance_
def move(src, dest)
Definition: eostools.py:511
TrackHistory tracer_

Member Function Documentation

TrackClassifier const & TrackClassifier::evaluate ( reco::TrackBaseRef const &  track)

Classify the RecoTrack in categories.

Definition at line 75 of file TrackClassifier.cc.

References TrackHistory::evaluate(), TrackCategories::Fake, TrackCategories::flags_, hadronFlavor(), processesAtGenerator(), processesAtSimulation(), qualityInformation(), reconstructionInformation(), TrackCategories::reset(), simulationInformation(), tracer_, TrackCategories::unknownTrack(), and vertexInformation().

Referenced by TrackCategoriesAnalyzer::analyze(), TrackingParticleCategoriesAnalyzer::analyze(), TrackHistoryAnalyzer::analyze(), BDHadronTrackMonitoringAnalyzer::analyze(), TrackClassifierByProxy< Collection >::evaluate(), QualityCutsAnalyzer::LoopOverJetTracksAssociation(), and JetVetoedTracksAssociationDRVertex::produce().

75  {
76  // Initializing the category vector
77  reset();
78 
79  // Associate and evaluate the track history (check for fakes)
80  if (tracer_.evaluate(track)) {
81  // Classify all the tracks by their association and reconstruction
82  // information
84 
85  // Get all the information related to the simulation details
87 
88  // Analyse the track reconstruction quality
90 
91  // Get hadron flavor of the initial hadron
92  hadronFlavor();
93 
94  // Get all the information related to decay process
96 
97  // Get information about conversion and other interactions
99 
100  // Get geometrical information about the vertices
102 
103  // Check for unkown classification
104  unknownTrack();
105  } else
106  flags_[Fake] = true;
107 
108  return *this;
109 }
void processesAtSimulation()
Get information about conversion and other interactions.
void simulationInformation()
Get all the information related to the simulation details.
void qualityInformation(reco::TrackBaseRef const &)
Classify all the tracks by their reconstruction quality.
void reconstructionInformation(reco::TrackBaseRef const &)
void hadronFlavor()
Get hadron flavor of the initial hadron.
void vertexInformation()
Get geometrical information about the vertices.
void processesAtGenerator()
Get all the information related to decay process.
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:37
Flags flags_
Flag containers.
void reset()
Reset the categories flags.
TrackHistory tracer_
TrackClassifier const & TrackClassifier::evaluate ( TrackingParticleRef const &  track)

Classify the TrackingParticle in categories.

Definition at line 111 of file TrackClassifier.cc.

References TrackHistory::evaluate(), TrackCategories::flags_, hadronFlavor(), edm::RefToBase< T >::isNonnull(), processesAtGenerator(), processesAtSimulation(), qualityInformation(), TrackCategories::Reconstructed, reconstructionInformation(), TrackHistory::recoTrack(), TrackCategories::reset(), simulationInformation(), tracer_, TrackCategories::unknownTrack(), and vertexInformation().

111  {
112  // Initializing the category vector
113  reset();
114 
115  // Trace the history for the given TP
117 
118  // Collect the associated reco track
119  const reco::TrackBaseRef &recotrack = tracer_.recoTrack();
120 
121  // If there is a reco truck then evaluate the simulated history
122  if (recotrack.isNonnull()) {
123  flags_[Reconstructed] = true;
124  // Classify all the tracks by their association and reconstruction
125  // information
126  reconstructionInformation(recotrack);
127  // Analyse the track reconstruction quality
128  qualityInformation(recotrack);
129  } else
130  flags_[Reconstructed] = false;
131 
132  // Get all the information related to the simulation details
134 
135  // Get hadron flavor of the initial hadron
136  hadronFlavor();
137 
138  // Get all the information related to decay process
140 
141  // Get information about conversion and other interactions
143 
144  // Get geometrical information about the vertices
146 
147  // Check for unkown classification
148  unknownTrack();
149 
150  return *this;
151 }
bool isNonnull() const
Checks for non-null.
Definition: RefToBase.h:340
void processesAtSimulation()
Get information about conversion and other interactions.
void simulationInformation()
Get all the information related to the simulation details.
void qualityInformation(reco::TrackBaseRef const &)
Classify all the tracks by their reconstruction quality.
void reconstructionInformation(reco::TrackBaseRef const &)
void hadronFlavor()
Get hadron flavor of the initial hadron.
void vertexInformation()
Get geometrical information about the vertices.
void processesAtGenerator()
Get all the information related to decay process.
bool evaluate(TrackingParticleRef tpr)
Evaluate track history using a TrackingParticleRef.
Definition: TrackHistory.h:37
Flags flags_
Flag containers.
const reco::TrackBaseRef & recoTrack() const
Return a reference to the reconstructed track.
Definition: TrackHistory.h:55
void reset()
Reset the categories flags.
TrackHistory tracer_
TrackClassifier const& TrackClassifier::evaluate ( reco::TrackRef const &  track)
inline

Classify the RecoTrack in categories.

Definition at line 47 of file TrackClassifier.h.

References evaluate().

Referenced by evaluate().

47 { return evaluate(reco::TrackBaseRef(track)); }
TrackClassifier const & evaluate(reco::TrackBaseRef const &)
Classify the RecoTrack in categories.
void TrackClassifier::genPrimaryVertices ( )
private

Definition at line 501 of file TrackClassifier.cc.

References funct::abs(), spr::find(), genpvs_, edm::HepMCProduct::GetEvent(), training_settings::idx, isCharged(), isFinalstateParticle(), funct::m, mcInformation_, parents, funct::pow(), MetAnalyzer::pv(), and vertexClusteringSqDistance_.

Referenced by newEvent().

501  {
502  genpvs_.clear();
503 
504  const HepMC::GenEvent *event = mcInformation_->GetEvent();
505 
506  if (event) {
507  int idx = 0;
508 
509  // Loop over the different GenVertex
510  for (HepMC::GenEvent::vertex_const_iterator ivertex = event->vertices_begin(); ivertex != event->vertices_end();
511  ++ivertex) {
512  bool hasParentVertex = false;
513 
514  // Loop over the parents looking to see if they are coming from a
515  // production vertex
516  for (HepMC::GenVertex::particle_iterator iparent = (*ivertex)->particles_begin(HepMC::parents);
517  iparent != (*ivertex)->particles_end(HepMC::parents);
518  ++iparent)
519  if ((*iparent)->production_vertex()) {
520  hasParentVertex = true;
521  break;
522  }
523 
524  // Reject those vertices with parent vertices
525  if (hasParentVertex)
526  continue;
527 
528  // Get the position of the vertex
529  HepMC::FourVector pos = (*ivertex)->position();
530 
531  double const mm = 0.1;
532 
533  GeneratedPrimaryVertex pv(pos.x() * mm, pos.y() * mm, pos.z() * mm);
534 
535  std::vector<GeneratedPrimaryVertex>::iterator ientry = genpvs_.begin();
536 
537  // Search for a VERY close vertex in the list
538  for (; ientry != genpvs_.end(); ++ientry) {
539  double distance2 = pow(pv.x - ientry->x, 2) + pow(pv.y - ientry->y, 2) + pow(pv.z - ientry->z, 2);
540  if (distance2 < vertexClusteringSqDistance_)
541  break;
542  }
543 
544  // Check if there is not a VERY close vertex and added to the list
545  if (ientry == genpvs_.end())
546  ientry = genpvs_.insert(ientry, pv);
547 
548  // Add the vertex barcodes to the new or existent vertices
549  ientry->genVertex.push_back((*ivertex)->barcode());
550 
551  // Collect final state descendants
552  for (HepMC::GenVertex::particle_iterator idecendants = (*ivertex)->particles_begin(HepMC::descendants);
553  idecendants != (*ivertex)->particles_end(HepMC::descendants);
554  ++idecendants) {
555  if (isFinalstateParticle(*idecendants))
556  if (find(ientry->finalstateParticles.begin(), ientry->finalstateParticles.end(), (*idecendants)->barcode()) ==
557  ientry->finalstateParticles.end()) {
558  ientry->finalstateParticles.push_back((*idecendants)->barcode());
559  HepMC::FourVector m = (*idecendants)->momentum();
560 
561  ientry->ptot.setPx(ientry->ptot.px() + m.px());
562  ientry->ptot.setPy(ientry->ptot.py() + m.py());
563  ientry->ptot.setPz(ientry->ptot.pz() + m.pz());
564  ientry->ptot.setE(ientry->ptot.e() + m.e());
565  ientry->ptsq += m.perp() * m.perp();
566 
567  if (m.perp() > 0.8 && std::abs(m.pseudoRapidity()) < 2.5 && isCharged(*idecendants))
568  ientry->nGenTrk++;
569  }
570  }
571  idx++;
572  }
573  }
574 
575  std::sort(genpvs_.begin(), genpvs_.end());
576 }
TPRegexp parents
Definition: eve_filter.cc:21
edm::Handle< edm::HepMCProduct > mcInformation_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
std::vector< GeneratedPrimaryVertex > genpvs_
bool isCharged(const HepMC::GenParticle *)
def pv(vc)
Definition: MetAnalyzer.py:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
bool isFinalstateParticle(const HepMC::GenParticle *)
double vertexClusteringSqDistance_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: event.py:1
void TrackClassifier::hadronFlavor ( )
private

Get hadron flavor of the initial hadron.

Definition at line 234 of file TrackClassifier.cc.

References TrackCategories::Bottom, TrackCategories::Charm, TrackCategories::flags_, TrackCategories::Light, source_particleGun_cfi::ParticleID, reco::LeafCandidate::pdgId(), sysUtil::pid, HistoryBase::recoGenParticle(), and tracer_.

Referenced by evaluate().

234  {
235  // Get the initial hadron from the recoGenParticleTrail
236  const reco::GenParticle *particle = tracer_.recoGenParticle();
237 
238  // Check for the initial hadron
239  if (particle) {
240  HepPDT::ParticleID pid(particle->pdgId());
241  flags_[Bottom] = pid.hasBottom();
242  flags_[Charm] = pid.hasCharm();
243  flags_[Light] = !pid.hasCharm() && !pid.hasBottom();
244  }
245 }
int pdgId() const final
PDG identifier.
const reco::GenParticle * recoGenParticle() const
Definition: HistoryBase.h:82
Flags flags_
Flag containers.
TrackHistory tracer_
TrackHistory const& TrackClassifier::history ( ) const
inline

Returns a reference to the track history used in the classification.

Definition at line 50 of file TrackClassifier.h.

References tracer_.

Referenced by TrackHistoryAnalyzer::analyze(), and BDHadronTrackMonitoringAnalyzer::analyze().

50 { return tracer_; }
TrackHistory tracer_
bool TrackClassifier::isCharged ( const HepMC::GenParticle *  p)
private

Definition at line 491 of file TrackClassifier.cc.

References particleDataTable_.

Referenced by genPrimaryVertices().

491  {
492  const ParticleData *part = particleDataTable_->particle(p->pdg_id());
493  if (part)
494  return part->charge() != 0;
495  else {
496  // the new/improved particle table doesn't know anti-particles
497  return particleDataTable_->particle(-p->pdg_id()) != nullptr;
498  }
499 }
HepPDT::ParticleData ParticleData
part
Definition: HCALResponse.h:20
edm::ESHandle< ParticleDataTable > particleDataTable_
bool TrackClassifier::isFinalstateParticle ( const HepMC::GenParticle *  p)
private

Definition at line 489 of file TrackClassifier.cc.

Referenced by genPrimaryVertices().

489 { return !p->end_vertex() && p->status() == 1; }
void TrackClassifier::newEvent ( edm::Event const &  event,
edm::EventSetup const &  setup 
)

Pre-process event information (for accessing reconstraction information)

Definition at line 44 of file TrackClassifier.cc.

References beamSpot_, beamSpotLabel_, genPrimaryVertices(), edm::EventSetup::get(), edm::EventSetup::getData(), hepMCLabel_, magneticField_, mcInformation_, TrackHistory::newEvent(), TrackQuality::newEvent(), particleDataTable_, edm::ESHandle< T >::product(), quality_, tracer_, transientTrackBuilder_, and tTopo_.

Referenced by TrackCategoriesAnalyzer::analyze(), TrackingParticleCategoriesAnalyzer::analyze(), QualityCutsAnalyzer::analyze(), TrackHistoryAnalyzer::analyze(), BDHadronTrackMonitoringAnalyzer::analyze(), TrackClassifierByProxy< Collection >::newEvent(), and JetVetoedTracksAssociatorAtVertex::produce().

44  {
45  // Get the new event information for the tracer
47 
48  // Get the new event information for the track quality analyser
50 
51  // Get hepmc of the event
52  event.getByLabel(hepMCLabel_, mcInformation_);
53 
54  // Magnetic field
56 
57  // Get the partivle data table
58  setup.getData(particleDataTable_);
59 
60  // get the beam spot
61  event.getByLabel(beamSpotLabel_, beamSpot_);
62 
63  // Transient track builder
64  setup.get<TransientTrackRecord>().get("TransientTrackBuilder", transientTrackBuilder_);
65 
66  // Create the list of primary vertices associated to the event
68 
69  // Retrieve tracker topology from geometry
71  setup.get<TrackerTopologyRcd>().get(tTopoHand);
72  tTopo_ = tTopoHand.product();
73 }
const edm::InputTag beamSpotLabel_
const edm::InputTag hepMCLabel_
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
Definition: TrackHistory.cc:33
edm::Handle< edm::HepMCProduct > mcInformation_
const TrackerTopology * tTopo_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
edm::ESHandle< TransientTrackBuilder > transientTrackBuilder_
edm::Handle< reco::BeamSpot > beamSpot_
TrackQuality quality_
edm::ESHandle< MagneticField > magneticField_
void newEvent(const edm::Event &, const edm::EventSetup &)
Pre-process event information (for accessing reconstruction information)
edm::ESHandle< ParticleDataTable > particleDataTable_
T const * product() const
Definition: ESHandle.h:86
TrackHistory tracer_
Definition: event.py:1
void TrackClassifier::processesAtGenerator ( )
private

Get all the information related to decay process.

Definition at line 247 of file TrackClassifier.cc.

References funct::abs(), TrackCategories::BWeakDecay, TrackCategories::ChargeKaonDecay, TrackCategories::ChargePionDecay, TrackCategories::CWeakDecay, TrackCategories::DecayOnFlightMuon, TrackCategories::flags_, TrackCategories::FromBWeakDecayMuon, TrackCategories::FromChargeKaonMuon, TrackCategories::FromChargePionMuon, TrackCategories::FromCWeakDecayMuon, mps_fire::i, TrackCategories::JpsiDecay, TrackCategories::KsDecay, TrackCategories::LambdaDecay, TrackCategories::LongLivedDecay, longLivedDecayLength_, particleDataTable_, EgammaObjectsElectrons_cfi::particleID, source_particleGun_cfi::ParticleID, BPhysicsValidation_cfi::pdgid, HistoryBase::recoGenParticleTrail(), TrackCategories::SigmaMinusDecay, TrackCategories::SigmaPlusDecay, tracer_, update, and TrackCategories::XiDecay.

Referenced by evaluate().

247  {
248  // pdgid of the "in" particle to the production vertex
249  int pdgid = 0;
250 
251  // Get the generated particles from track history (reco::GenParticle in the
252  // recoGenParticleTrail)
253  TrackHistory::RecoGenParticleTrail const &recoGenParticleTrail = tracer_.recoGenParticleTrail();
254 
255  // Loop over the generated particles (reco::GenParticle in the
256  // recoGenParticleTrail)
257  for (TrackHistory::RecoGenParticleTrail::const_iterator iparticle = recoGenParticleTrail.begin();
258  iparticle != recoGenParticleTrail.end();
259  ++iparticle) {
260  pdgid = std::abs((*iparticle)->pdgId());
261  // Get particle type
263 
264  // Check if the particle type is valid one
265  if (particleID.isValid()) {
266  // Get particle data
267  ParticleData const *particleData = particleDataTable_->particle(particleID);
268  // Check if the particle exist in the table
269  if (particleData) {
270  // Check if their life time is bigger than longLivedDecayLength_
271  if (particleData->lifetime() > longLivedDecayLength_)
272  update(flags_[LongLivedDecay], true);
273  // Check for B and C weak decays
274  update(flags_[BWeakDecay], particleID.hasBottom());
275  update(flags_[CWeakDecay], particleID.hasCharm());
276  // Check for B and C pure leptonic decay
277  std::set<int> daughterIds;
278  size_t ndau = (*iparticle)->numberOfDaughters();
279  for (size_t i = 0; i < ndau; ++i) {
280  daughterIds.insert((*iparticle)->daughter(i)->pdgId());
281  }
282  update(flags_[FromBWeakDecayMuon], particleID.hasBottom() && (daughterIds.find(13) != daughterIds.end()));
283  update(flags_[FromCWeakDecayMuon], particleID.hasCharm() && (daughterIds.find(13) != daughterIds.end()));
284  }
285  // Check Tau, Ks and Lambda decay
286  update(flags_[ChargePionDecay], pdgid == 211);
287  update(flags_[ChargeKaonDecay], pdgid == 321);
288  update(flags_[TauDecay], pdgid == 15);
289  update(flags_[KsDecay], pdgid == 310);
290  update(flags_[LambdaDecay], pdgid == 3122);
291  update(flags_[JpsiDecay], pdgid == 443);
292  update(flags_[XiDecay], pdgid == 3312);
293  update(flags_[SigmaPlusDecay], pdgid == 3222);
294  update(flags_[SigmaMinusDecay], pdgid == 3112);
295  }
296  }
297  // Decays in flight
301 }
std::vector< const reco::GenParticle * > RecoGenParticleTrail
reco::GenParticle trail type.
Definition: HistoryBase.h:18
Definition: Muon.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HepPDT::ParticleData ParticleData
#define update(a, b)
Flags flags_
Flag containers.
double longLivedDecayLength_
RecoGenParticleTrail const & recoGenParticleTrail() const
Return all reco::GenParticle in the history.
Definition: HistoryBase.h:64
edm::ESHandle< ParticleDataTable > particleDataTable_
TrackHistory tracer_
void TrackClassifier::processesAtSimulation ( )
private

Get information about conversion and other interactions.

Definition at line 303 of file TrackClassifier.cc.

References funct::abs(), CMS::Annihilation, TrackCategories::AnnihilationProcess, TrackCategories::BWeakDecay, TrackCategories::ChargeKaonDecay, TrackCategories::ChargePionDecay, CMS::Compton, TrackCategories::ComptonProcess, CMS::Conversions, TrackCategories::ConversionsProcess, TrackCategories::CWeakDecay, CMS::Decay, TrackCategories::DecayOnFlightMuon, TrackCategories::DecayProcess, CMS::EBrem, TrackCategories::EBremProcess, CMS::EIoni, TrackCategories::EIoniProcess, RemoveAddSevLevel::flag, TrackCategories::flags_, TrackCategories::FromBWeakDecayMuon, TrackCategories::FromChargeKaonMuon, TrackCategories::FromChargePionMuon, TrackCategories::FromCWeakDecayMuon, g4toCMSProcMap_, CMS::Hadronic, TrackCategories::HadronicProcess, CMS::HIoni, TrackCategories::HIoniProcess, edm::Ref< C, T, F >::isNonnull(), TrackCategories::JpsiDecay, TrackCategories::KnownProcess, TrackCategories::KsDecay, TrackCategories::LambdaDecay, TrackCategories::LongLivedDecay, longLivedDecayLength_, CMS::MuBrem, TrackCategories::MuBremProcess, CMS::MuIoni, TrackCategories::MuIoniProcess, CMS::MuNucl, TrackCategories::MuNuclProcess, CMS::MuPairProd, TrackCategories::MuPairProdProcess, TrackCategories::OmegaDecay, particleDataTable_, EgammaObjectsElectrons_cfi::particleID, source_particleGun_cfi::ParticleID, BPhysicsValidation_cfi::pdgid, CMS::Photon, TrackCategories::PhotonProcess, CMS::Primary, TrackCategories::PrimaryProcess, LaserDQM_cfg::process, G4toCMSLegacyProcTypeMap::processId(), TrackCategories::SigmaMinusDecay, TrackCategories::SigmaPlusDecay, HistoryBase::simParticleTrail(), CMS::SynchrotronRadiation, TrackCategories::SynchrotronRadiationProcess, tracer_, CMS::Undefined, TrackCategories::UndefinedProcess, CMS::Unknown, TrackCategories::UnknownProcess, update, and TrackCategories::XiDecay.

Referenced by evaluate().

303  {
304  TrackHistory::SimParticleTrail const &simParticleTrail = tracer_.simParticleTrail();
305 
306  // Loop over the simulated particles
307  for (TrackHistory::SimParticleTrail::const_iterator iparticle = simParticleTrail.begin();
308  iparticle != simParticleTrail.end();
309  ++iparticle) {
310  // pdgid of the real source parent vertex
311  int pdgid = 0;
312 
313  // Get a reference to the TP's parent vertex
314  TrackingVertexRef const &parentVertex = (*iparticle)->parentVertex();
315 
316  // Look for the original source track
317  if (parentVertex.isNonnull()) {
318  // select the original source in case of combined vertices
319  bool flag = false;
321 
322  for (its = parentVertex->sourceTracks_begin(); its != parentVertex->sourceTracks_end(); ++its) {
323  for (itd = parentVertex->daughterTracks_begin(); itd != parentVertex->daughterTracks_end(); ++itd)
324  if (itd != its) {
325  flag = true;
326  break;
327  }
328  if (flag)
329  break;
330  }
331 
332  // Collect the pdgid of the original source track
333  if (its != parentVertex->sourceTracks_end())
334  pdgid = std::abs((*its)->pdgId());
335  else
336  pdgid = 0;
337  }
338 
339  unsigned int processG4 = 0;
340 
341  // Check existence of SimVerteces assigned
342  if (parentVertex->nG4Vertices() > 0) {
343  processG4 = (*(parentVertex->g4Vertices_begin())).processType();
344  }
345 
346  unsigned int process = g4toCMSProcMap_.processId(processG4);
347 
348  // Flagging all the different processes
349  update(flags_[KnownProcess], process != CMS::Undefined && process != CMS::Unknown && process != CMS::Primary);
350 
355  update(flags_[DecayProcess], process == CMS::Decay);
358  update(flags_[EIoniProcess], process == CMS::EIoni);
359  update(flags_[HIoniProcess], process == CMS::HIoni);
360  update(flags_[MuIoniProcess], process == CMS::MuIoni);
361  update(flags_[PhotonProcess], process == CMS::Photon);
364  update(flags_[EBremProcess], process == CMS::EBrem);
366  update(flags_[MuBremProcess], process == CMS::MuBrem);
367  update(flags_[MuNuclProcess], process == CMS::MuNucl);
368 
369  // Get particle type
371 
372  // Check if the particle type is valid one
373  if (particleID.isValid()) {
374  // Get particle data
375  ParticleData const *particleData = particleDataTable_->particle(particleID);
376  // Special treatment for decays
377  if (process == CMS::Decay) {
378  // Check if the particle exist in the table
379  if (particleData) {
380  // Check if their life time is bigger than 1e-14
381  if (particleDataTable_->particle(particleID)->lifetime() > longLivedDecayLength_)
382  update(flags_[LongLivedDecay], true);
383 
384  // Check for B and C weak decays
385  update(flags_[BWeakDecay], particleID.hasBottom());
386  update(flags_[CWeakDecay], particleID.hasCharm());
387 
388  // Check for B or C pure leptonic decays
389  int daughtId = abs((*iparticle)->pdgId());
390  update(flags_[FromBWeakDecayMuon], particleID.hasBottom() && daughtId == 13);
391  update(flags_[FromCWeakDecayMuon], particleID.hasCharm() && daughtId == 13);
392  }
393  // Check decays
394  update(flags_[ChargePionDecay], pdgid == 211);
395  update(flags_[ChargeKaonDecay], pdgid == 321);
396  update(flags_[TauDecay], pdgid == 15);
397  update(flags_[KsDecay], pdgid == 310);
398  update(flags_[LambdaDecay], pdgid == 3122);
399  update(flags_[JpsiDecay], pdgid == 443);
400  update(flags_[XiDecay], pdgid == 3312);
401  update(flags_[OmegaDecay], pdgid == 3334);
402  update(flags_[SigmaPlusDecay], pdgid == 3222);
403  update(flags_[SigmaMinusDecay], pdgid == 3112);
404  }
405  }
406  }
407  // Decays in flight
411 }
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:251
const G4toCMSLegacyProcTypeMap g4toCMSProcMap_
Definition: Muon.py:1
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const unsigned int processId(unsigned int g4ProcessId) const
Definition: Utils.cc:59
HepPDT::ParticleData ParticleData
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
#define update(a, b)
Flags flags_
Flag containers.
double longLivedDecayLength_
edm::ESHandle< ParticleDataTable > particleDataTable_
TrackHistory tracer_
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30
TrackQuality const& TrackClassifier::quality ( void  ) const
inline

Returns a reference to the track quality used in the classification.

Definition at line 53 of file TrackClassifier.h.

References quality_.

53 { return quality_; }
TrackQuality quality_
void TrackClassifier::qualityInformation ( reco::TrackBaseRef const &  track)
private

Classify all the tracks by their reconstruction quality.

Definition at line 211 of file TrackClassifier.cc.

References TrackCategories::BadInnerHits, TrackQuality::evaluate(), TrackCategories::flags_, TrackQuality::Layer::hits, mps_fire::i, TrackQuality::layer(), histoParameters_cff::maxLayers, min(), TrackQuality::Layer::Misassoc, TrackQuality::Layer::Noise, numberOfInnerLayers_, TrackQuality::numberOfLayers(), quality_, TrackQuality::Layer::Shared, TrackCategories::SharedInnerHits, HistoryBase::simParticleTrail(), TrackQuality::Layer::Hit::state, tracer_, HiIsolationCommonParameters_cff::track, and tTopo_.

Referenced by evaluate().

211  {
212  // run the hit-by-hit reconstruction quality analysis
214 
216 
217  // check the innermost layers for bad hits
218  for (unsigned int i = 0; i < maxLayers; i++) {
219  const TrackQuality::Layer &layer = quality_.layer(i);
220 
221  // check all hits in that layer
222  for (unsigned int j = 0; j < layer.hits.size(); j++) {
223  const TrackQuality::Layer::Hit &hit = layer.hits[j];
224 
225  // In those cases the bad hit was used by track reconstruction
227  flags_[BadInnerHits] = true;
228  else if (hit.state == TrackQuality::Layer::Shared)
229  flags_[SharedInnerHits] = true;
230  }
231  }
232 }
unsigned int numberOfLayers() const
Return the number of layers with simulated and/or reconstructed hits.
Definition: TrackQuality.h:74
const TrackerTopology * tTopo_
unsigned int numberOfInnerLayers_
void evaluate(SimParticleTrail const &, reco::TrackBaseRef const &, const TrackerTopology *tTopo)
Compute information about the track reconstruction quality.
T min(T a, T b)
Definition: MathUtil.h:58
const Layer & layer(unsigned int index) const
Return information about the given layer by index.
Definition: TrackQuality.h:77
TrackQuality quality_
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
std::vector< Hit > hits
Definition: TrackQuality.h:56
Flags flags_
Flag containers.
TrackHistory tracer_
void TrackClassifier::reconstructionInformation ( reco::TrackBaseRef const &  track)
private

Classify all the tracks by their association and reconstruction information

Definition at line 153 of file TrackClassifier.cc.

References funct::abs(), TrackCategories::Bad, badPull_, beamSpot_, reco::TrackBase::charge(), funct::cos(), reco::TrackBase::dxy(), reco::TrackBase::dxyError(), reco::TrackBase::dz(), reco::TrackBase::dzError(), TrackCategories::flags_, magneticField_, CoreSimTrack::momentum(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, FreeTrajectoryState::position(), edm::ESHandle< T >::product(), HistoryBase::simParticle(), funct::sin(), TrajectoryStateClosestToPoint::theState(), tracer_, findQualityFiles::v, PV3DBase< T, PVType, FrameType >::x(), reco::BeamSpot::x0(), PV3DBase< T, PVType, FrameType >::y(), reco::BeamSpot::y0(), PV3DBase< T, PVType, FrameType >::z(), and reco::BeamSpot::z0().

Referenced by evaluate().

153  {
155 
156  // Compute tracking particle parameters at point of closest approach to the
157  // beamline
158 
159  const SimTrack *assocTrack = &(*tpr->g4Track_begin());
160 
161  FreeTrajectoryState ftsAtProduction(
162  GlobalPoint(tpr->vertex().x(), tpr->vertex().y(), tpr->vertex().z()),
163  GlobalVector(assocTrack->momentum().x(), assocTrack->momentum().y(), assocTrack->momentum().z()),
164  TrackCharge(track->charge()),
166 
167  try {
168  TSCPBuilderNoMaterial tscpBuilder;
169  TrajectoryStateClosestToPoint tsAtClosestApproach =
170  tscpBuilder(ftsAtProduction, GlobalPoint(beamSpot_->x0(), beamSpot_->y0(), beamSpot_->z0()));
171 
172  GlobalVector v =
173  tsAtClosestApproach.theState().position() - GlobalPoint(beamSpot_->x0(), beamSpot_->y0(), beamSpot_->z0());
174  GlobalVector p = tsAtClosestApproach.theState().momentum();
175 
176  // Simulated dxy
177  double dxySim = -v.x() * sin(p.phi()) + v.y() * cos(p.phi());
178 
179  // Simulated dz
180  double dzSim = v.z() - (v.x() * p.x() + v.y() * p.y()) * p.z() / p.perp2();
181 
182  // Calculate the dxy pull
183  double dxyPull =
185  track->dxyError();
186 
187  // Calculate the dx pull
188  double dzPull =
190  track->dzError();
191 
192  // Return true if d0Pull > badD0Pull sigmas
193  flags_[Bad] = (dxyPull > badPull_ || dzPull > badPull_);
194 
195  } catch (cms::Exception const &) {
196  flags_[Bad] = true;
197  }
198 }
double z0() const
z coordinate
Definition: BeamSpot.h:68
const FreeTrajectoryState & theState() const
const TrackingParticleRef & simParticle() const
Return the initial tracking particle from the history.
Definition: HistoryBase.h:67
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
int TrackCharge
Definition: TrackCharge.h:4
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
math::XYZPoint Point
point in the space
Definition: TrackBase.h:83
edm::Handle< reco::BeamSpot > beamSpot_
GlobalVector momentum() const
GlobalPoint position() const
edm::ESHandle< MagneticField > magneticField_
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
double y0() const
y coordinate
Definition: BeamSpot.h:66
Flags flags_
Flag containers.
T x() const
Definition: PV3DBase.h:62
T const * product() const
Definition: ESHandle.h:86
TrackHistory tracer_
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double x0() const
x coordinate
Definition: BeamSpot.h:64
void TrackClassifier::simulationInformation ( )
private

Get all the information related to the simulation details.

Definition at line 200 of file TrackClassifier.cc.

References funct::abs(), EncodedEventId::bunchCrossing(), EncodedEventId::event(), TrackCategories::flags_, createfilelist::int, minTrackerSimHits_, TrackCategories::Muon, TrackCategories::SignalEvent, HistoryBase::simParticle(), tracer_, and TrackCategories::TrackerSimHits.

Referenced by evaluate().

200  {
201  // Get the event id for the initial TP.
202  EncodedEventId eventId = tracer_.simParticle()->eventId();
203  // Check for signal events
204  flags_[SignalEvent] = !eventId.bunchCrossing() && !eventId.event();
205  // Check for muons
206  flags_[Muon] = (abs(tracer_.simParticle()->pdgId()) == 13);
207  // Check for the number of psimhit in tracker
208  flags_[TrackerSimHits] = tracer_.simParticle()->numberOfTrackerLayers() >= (int)minTrackerSimHits_;
209 }
int event() const
get the contents of the subdetector field (should be protected?)
const TrackingParticleRef & simParticle() const
Return the initial tracking particle from the history.
Definition: HistoryBase.h:67
unsigned int minTrackerSimHits_
int bunchCrossing() const
get the detector field from this detid
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Flags flags_
Flag containers.
TrackHistory tracer_
void TrackClassifier::vertexInformation ( )
private

Get geometrical information about the vertices.

Definition at line 413 of file TrackClassifier.cc.

References TrackCategories::flags_, HistoryBase::genParticleTrail(), genpvs_, AlCaHLTBitMon_ParallelJobs::p, class-composition::parent, funct::pow(), TrackCategories::PrimaryVertex, TrackCategories::SecondaryVertex, HistoryBase::simParticleTrail(), TrackCategories::TertiaryVertex, tracer_, vertexClusteringSqDistance_, TrackClassifier::GeneratedPrimaryVertex::x, TrackClassifier::GeneratedPrimaryVertex::y, and TrackClassifier::GeneratedPrimaryVertex::z.

Referenced by evaluate().

413  {
414  // Get the main primary vertex from the list
415  GeneratedPrimaryVertex const &genpv = genpvs_.back();
416 
417  // Get the generated history of the tracks
418  const TrackHistory::GenParticleTrail &genParticleTrail = tracer_.genParticleTrail();
419 
420  // Vertex counter
421  int counter = 0;
422 
423  // Unit transformation from mm to cm
424  double const mm = 0.1;
425 
426  double oldX = genpv.x;
427  double oldY = genpv.y;
428  double oldZ = genpv.z;
429 
430  // Loop over the generated particles
431  for (TrackHistory::GenParticleTrail::const_reverse_iterator iparticle = genParticleTrail.rbegin();
432  iparticle != genParticleTrail.rend();
433  ++iparticle) {
434  // Look for those with production vertex
435  HepMC::GenVertex *parent = (*iparticle)->production_vertex();
436  if (parent) {
437  HepMC::ThreeVector p = parent->point3d();
438 
439  double distance2 = pow(p.x() * mm - genpv.x, 2) + pow(p.y() * mm - genpv.y, 2) + pow(p.z() * mm - genpv.z, 2);
440  double difference2 = pow(p.x() * mm - oldX, 2) + pow(p.y() * mm - oldY, 2) + pow(p.z() * mm - oldZ, 2);
441 
442  // std::cout << "Distance2 : " << distance2 << " (" << p.x() * mm << ","
443  // << p.y() * mm << "," << p.z() * mm << ")" << std::endl; std::cout <<
444  // "Difference2 : " << difference2 << std::endl;
445 
446  if (difference2 > vertexClusteringSqDistance_) {
447  if (distance2 > vertexClusteringSqDistance_)
448  counter++;
449  oldX = p.x() * mm;
450  oldY = p.y() * mm;
451  oldZ = p.z() * mm;
452  }
453  }
454  }
455 
456  const TrackHistory::SimParticleTrail &simParticleTrail = tracer_.simParticleTrail();
457 
458  // Loop over the generated particles
459  for (TrackHistory::SimParticleTrail::const_reverse_iterator iparticle = simParticleTrail.rbegin();
460  iparticle != simParticleTrail.rend();
461  ++iparticle) {
462  // Look for those with production vertex
463  TrackingParticle::Point p = (*iparticle)->vertex();
464 
465  double distance2 = pow(p.x() - genpv.x, 2) + pow(p.y() - genpv.y, 2) + pow(p.z() - genpv.z, 2);
466  double difference2 = pow(p.x() - oldX, 2) + pow(p.y() - oldY, 2) + pow(p.z() - oldZ, 2);
467 
468  // std::cout << "Distance2 : " << distance2 << " (" << p.x() << "," << p.y()
469  // << "," << p.z() << ")" << std::endl; std::cout << "Difference2 : " <<
470  // difference2 << std::endl;
471 
472  if (difference2 > vertexClusteringSqDistance_) {
473  if (distance2 > vertexClusteringSqDistance_)
474  counter++;
475  oldX = p.x();
476  oldY = p.y();
477  oldZ = p.z();
478  }
479  }
480 
481  if (!counter)
482  flags_[PrimaryVertex] = true;
483  else if (counter == 1)
484  flags_[SecondaryVertex] = true;
485  else
486  flags_[TertiaryVertex] = true;
487 }
std::vector< GeneratedPrimaryVertex > genpvs_
std::vector< const HepMC::GenParticle * > GenParticleTrail
HepMC::GenParticle trail type.
Definition: HistoryBase.h:15
math::XYZPointD Point
point in the space
SimParticleTrail const & simParticleTrail() const
Return all the simulated particle in the history.
Definition: HistoryBase.h:55
Flags flags_
Flag containers.
double vertexClusteringSqDistance_
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
GenParticleTrail const & genParticleTrail() const
Return all generated particle (HepMC::GenParticle) in the history.
Definition: HistoryBase.h:61
TrackHistory tracer_
std::vector< TrackingParticleRef > SimParticleTrail
SimParticle trail type.
Definition: HistoryBase.h:30

Member Data Documentation

double TrackClassifier::badPull_
private

Definition at line 59 of file TrackClassifier.h.

Referenced by reconstructionInformation(), and TrackClassifier().

edm::Handle<reco::BeamSpot> TrackClassifier::beamSpot_
private

Definition at line 79 of file TrackClassifier.h.

Referenced by newEvent(), and reconstructionInformation().

const edm::InputTag TrackClassifier::beamSpotLabel_
private

Definition at line 57 of file TrackClassifier.h.

Referenced by newEvent(), and TrackClassifier().

const G4toCMSLegacyProcTypeMap TrackClassifier::g4toCMSProcMap_
private

Definition at line 69 of file TrackClassifier.h.

Referenced by processesAtSimulation().

std::vector<GeneratedPrimaryVertex> TrackClassifier::genpvs_
private

Definition at line 122 of file TrackClassifier.h.

Referenced by genPrimaryVertices(), and vertexInformation().

const edm::InputTag TrackClassifier::hepMCLabel_
private

Definition at line 56 of file TrackClassifier.h.

Referenced by newEvent(), and TrackClassifier().

double TrackClassifier::longLivedDecayLength_
private

Definition at line 60 of file TrackClassifier.h.

Referenced by processesAtGenerator(), processesAtSimulation(), and TrackClassifier().

edm::ESHandle<MagneticField> TrackClassifier::magneticField_
private

Definition at line 71 of file TrackClassifier.h.

Referenced by newEvent(), and reconstructionInformation().

edm::Handle<edm::HepMCProduct> TrackClassifier::mcInformation_
private

Definition at line 73 of file TrackClassifier.h.

Referenced by genPrimaryVertices(), and newEvent().

unsigned int TrackClassifier::minTrackerSimHits_
private

Definition at line 63 of file TrackClassifier.h.

Referenced by simulationInformation(), and TrackClassifier().

unsigned int TrackClassifier::numberOfInnerLayers_
private

Definition at line 62 of file TrackClassifier.h.

Referenced by qualityInformation(), and TrackClassifier().

edm::ESHandle<ParticleDataTable> TrackClassifier::particleDataTable_
private

Definition at line 75 of file TrackClassifier.h.

Referenced by isCharged(), newEvent(), processesAtGenerator(), and processesAtSimulation().

TrackQuality TrackClassifier::quality_
private

Definition at line 67 of file TrackClassifier.h.

Referenced by newEvent(), quality(), and qualityInformation().

TrackHistory TrackClassifier::tracer_
private
edm::ESHandle<TransientTrackBuilder> TrackClassifier::transientTrackBuilder_
private

Definition at line 77 of file TrackClassifier.h.

Referenced by newEvent().

const TrackerTopology* TrackClassifier::tTopo_
private

Definition at line 81 of file TrackClassifier.h.

Referenced by newEvent(), and qualityInformation().

double TrackClassifier::vertexClusteringSqDistance_
private

Definition at line 61 of file TrackClassifier.h.

Referenced by genPrimaryVertices(), TrackClassifier(), and vertexInformation().