CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
L1TrackQuality Class Reference

#include <L1TrackQuality.h>

Public Member Functions

std::vector< float > featureTransform (TTTrack< Ref_Phase2TrackerDigi_ > &aTrack, std::vector< std::string > const &featureNames)
 
 L1TrackQuality ()
 
 L1TrackQuality (const edm::ParameterSet &qualityParams)
 
float runEmulatedTQ (std::vector< ap_fixed< 10, 5 >> inputFeatures)
 
void setBonusFeatures (std::vector< float > bonusFeatures)
 
void setL1TrackQuality (TTTrack< Ref_Phase2TrackerDigi_ > &aTrack)
 
void setModel (edm::FileInPath const &model, std::vector< std::string > const &featureNames)
 
 ~L1TrackQuality ()=default
 

Static Public Member Functions

static constexpr std::array< double, 1<< TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize > getTqMVAPreSigBins ()
 
static constexpr double invSigmoid (double value)
 

Private Attributes

std::vector< float > bonusFeatures_
 
std::vector< std::string > featureNames_
 
edm::FileInPath model_
 
bool useHPH_
 

Detailed Description

Definition at line 28 of file L1TrackQuality.h.

Constructor & Destructor Documentation

◆ L1TrackQuality() [1/2]

L1TrackQuality::L1TrackQuality ( )

Definition at line 10 of file L1TrackQuality.cc.

10 {}

◆ L1TrackQuality() [2/2]

L1TrackQuality::L1TrackQuality ( const edm::ParameterSet qualityParams)

Definition at line 12 of file L1TrackQuality.cc.

References edm::ParameterSet::getParameter(), and setModel().

12  : useHPH_(false), bonusFeatures_() {
13  // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers
14  setModel(qualityParams.getParameter<edm::FileInPath>("model"),
15  qualityParams.getParameter<std::vector<std::string>>("featureNames"));
16 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void setModel(edm::FileInPath const &model, std::vector< std::string > const &featureNames)
std::vector< float > bonusFeatures_

◆ ~L1TrackQuality()

L1TrackQuality::~L1TrackQuality ( )
default

Member Function Documentation

◆ featureTransform()

std::vector< float > L1TrackQuality::featureTransform ( TTTrack< Ref_Phase2TrackerDigi_ > &  aTrack,
std::vector< std::string > const &  featureNames 
)

Definition at line 18 of file L1TrackQuality.cc.

References funct::abs(), TTTrack< T >::eta(), TrackQualityParams_cfi::featureNames, nano_mu_digi_cff::float, TTTrack_TrackWord::getBendChi2Bits(), TTTrack_TrackWord::getChi2RPhiBits(), TTTrack_TrackWord::getChi2RZBits(), TTTrack< T >::getStubRefs(), TTTrack< T >::hitPattern(), mps_fire::i, TTTrack_TrackWord::minZ0, TTTrack< T >::phi(), cmsswSequenceInfo::seq, AlCaHLTBitMon_QueryRunRegistry::string, TTTrack< T >::tanL(), and TTTrack< T >::z0().

Referenced by setL1TrackQuality().

19  {
20  // List input features for MVA in proper order below, the current features options are
21  // {"phi", "eta", "z0", "bendchi2_bin", "nstub", "nlaymiss_interior", "chi2rphi_bin",
22  // "chi2rz_bin"}
23  //
24  // To use more features, they must be created here and added to feature_map below
25 
26  std::vector<float> transformedFeatures;
27 
28  // Define feature map, filled as features are generated
29  std::map<std::string, float> feature_map;
30 
31  // -------- calculate feature variables --------
32 
33  // calculate number of missed interior layers from hitpattern
34  int tmp_trk_hitpattern = aTrack.hitPattern();
35  int nbits = floor(log2(tmp_trk_hitpattern)) + 1;
36  int lay_i = 0;
37  int tmp_trk_nlaymiss_interior = 0;
38  bool seq = false;
39  for (int i = 0; i < nbits; i++) {
40  lay_i = ((1 << i) & tmp_trk_hitpattern) >> i; //0 or 1 in ith bit (right to left)
41 
42  if (lay_i && !seq)
43  seq = true; //sequence starts when first 1 found
44  if (!lay_i && seq)
45  tmp_trk_nlaymiss_interior++;
46  }
47 
48  // binned chi2 variables
49  int tmp_trk_bendchi2_bin = aTrack.getBendChi2Bits();
50  int tmp_trk_chi2rphi_bin = aTrack.getChi2RPhiBits();
51  int tmp_trk_chi2rz_bin = aTrack.getChi2RZBits();
52 
53  // get the nstub
54  std::vector<edm::Ref<edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>>, TTStub<Ref_Phase2TrackerDigi_>>> stubRefs =
55  aTrack.getStubRefs();
56  int tmp_trk_nstub = stubRefs.size();
57 
58  // get other variables directly from TTTrack
59  float tmp_trk_z0 = aTrack.z0();
60  float tmp_trk_z0_scaled = tmp_trk_z0 / abs(aTrack.minZ0);
61  float tmp_trk_phi = aTrack.phi();
62  float tmp_trk_eta = aTrack.eta();
63  float tmp_trk_tanl = aTrack.tanL();
64 
65  // -------- fill the feature map ---------
66 
67  feature_map["nstub"] = float(tmp_trk_nstub);
68  feature_map["z0"] = tmp_trk_z0;
69  feature_map["z0_scaled"] = tmp_trk_z0_scaled;
70  feature_map["phi"] = tmp_trk_phi;
71  feature_map["eta"] = tmp_trk_eta;
72  feature_map["nlaymiss_interior"] = float(tmp_trk_nlaymiss_interior);
73  feature_map["bendchi2_bin"] = tmp_trk_bendchi2_bin;
74  feature_map["chi2rphi_bin"] = tmp_trk_chi2rphi_bin;
75  feature_map["chi2rz_bin"] = tmp_trk_chi2rz_bin;
76  feature_map["tanl"] = tmp_trk_tanl;
77 
78  // fill tensor with track params
79  transformedFeatures.reserve(featureNames.size());
80  for (const std::string& feature : featureNames)
81  transformedFeatures.push_back(feature_map[feature]);
82 
83  return transformedFeatures;
84 }
double eta() const
Track eta.
Definition: TTTrack.h:310
unsigned int getChi2RZBits() const
static constexpr double minZ0
unsigned int getChi2RPhiBits() const
double phi() const
Track phi.
Definition: TTTrack.h:315
double tanL() const
Track tanL.
Definition: TTTrack.h:305
unsigned int hitPattern() const
Hit Pattern.
Definition: TTTrack.h:424
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Class to store the L1 Track Trigger stubs.
Definition: TTStub.h:22
std::vector< edm::Ref< edmNew::DetSetVector< TTStub< T > >, TTStub< T > > > getStubRefs() const
Track components.
Definition: TTTrack.h:93
unsigned int getBendChi2Bits() const
double z0() const
Track z0.
Definition: TTTrack.h:330

◆ getTqMVAPreSigBins()

static constexpr std::array<double, 1 << TTTrack_TrackWord::TrackBitWidths::kMVAQualitySize> L1TrackQuality::getTqMVAPreSigBins ( )
inlinestatic

Definition at line 55 of file L1TrackQuality.h.

References invSigmoid(), and TTTrack_TrackWord::tqMVABins.

Referenced by trklet::ProducerKFout::produce().

55  {
56  return {{-16.,
64  }
static constexpr double invSigmoid(double value)
static constexpr std::array< double, 1<< TrackBitWidths::kMVAQualitySize > tqMVABins

◆ invSigmoid()

static constexpr double L1TrackQuality::invSigmoid ( double  value)
inlinestatic

Definition at line 54 of file L1TrackQuality.h.

References dqm-mbProfile::log.

Referenced by getTqMVAPreSigBins().

54 { return -log(1. / value - 1.); }
Definition: value.py:1

◆ runEmulatedTQ()

float L1TrackQuality::runEmulatedTQ ( std::vector< ap_fixed< 10, 5 >>  inputFeatures)

Definition at line 96 of file L1TrackQuality.cc.

References edm::FileInPath::fullPath(), and model_.

96  {
97  // load in bdt
98 
99  conifer::BDT<ap_fixed<10, 5>, ap_fixed<10, 5>> bdt(this->model_.fullPath());
100 
101  // collect features and classify using bdt
102  std::vector<ap_fixed<10, 5>> output = bdt.decision_function(inputFeatures);
103  return output.at(0).to_float(); // need logistic sigmoid fcn applied to xgb output
104 }
std::string fullPath() const
Definition: FileInPath.cc:161
edm::FileInPath model_
Definition: output.py:1

◆ setBonusFeatures()

void L1TrackQuality::setBonusFeatures ( std::vector< float >  bonusFeatures)

Definition at line 112 of file L1TrackQuality.cc.

References bonusFeatures_, and useHPH_.

112  {
113  bonusFeatures_ = bonusFeatures;
114  useHPH_ = true;
115 }
std::vector< float > bonusFeatures_

◆ setL1TrackQuality()

void L1TrackQuality::setL1TrackQuality ( TTTrack< Ref_Phase2TrackerDigi_ > &  aTrack)

Definition at line 86 of file L1TrackQuality.cc.

References JetChargeProducer_cfi::exp, featureNames_, featureTransform(), edm::FileInPath::fullPath(), PixelMapPlotter::inputs, model_, and TTTrack< T >::settrkMVA1().

86  {
87  // load in bdt
88  conifer::BDT<float, float> bdt(this->model_.fullPath());
89 
90  // collect features and classify using bdt
91  std::vector<float> inputs = featureTransform(aTrack, this->featureNames_);
92  std::vector<float> output = bdt.decision_function(inputs);
93  aTrack.settrkMVA1(1. / (1. + exp(-output.at(0))));
94 }
std::string fullPath() const
Definition: FileInPath.cc:161
edm::FileInPath model_
void settrkMVA1(double atrkMVA1)
Definition: TTTrack.h:382
std::vector< float > featureTransform(TTTrack< Ref_Phase2TrackerDigi_ > &aTrack, std::vector< std::string > const &featureNames)
std::vector< std::string > featureNames_
Definition: output.py:1

◆ setModel()

void L1TrackQuality::setModel ( edm::FileInPath const &  model,
std::vector< std::string > const &  featureNames 
)

Definition at line 106 of file L1TrackQuality.cc.

References TrackQualityParams_cfi::featureNames, featureNames_, ReggeGribovPartonMC_EposLHC_2760GeV_PbPb_cfi::model, and model_.

Referenced by L1TrackQuality().

106  {
107  //Convert algorithm string to Enum class for track by track comparison
108  model_ = model;
110 }
edm::FileInPath model_
std::vector< std::string > featureNames_

Member Data Documentation

◆ bonusFeatures_

std::vector<float> L1TrackQuality::bonusFeatures_
private

Definition at line 71 of file L1TrackQuality.h.

Referenced by setBonusFeatures().

◆ featureNames_

std::vector<std::string> L1TrackQuality::featureNames_
private

Definition at line 69 of file L1TrackQuality.h.

Referenced by setL1TrackQuality(), and setModel().

◆ model_

edm::FileInPath L1TrackQuality::model_
private

Definition at line 68 of file L1TrackQuality.h.

Referenced by runEmulatedTQ(), setL1TrackQuality(), and setModel().

◆ useHPH_

bool L1TrackQuality::useHPH_
private

Definition at line 70 of file L1TrackQuality.h.

Referenced by setBonusFeatures().