CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
MuonHLTSeedMVAClassifier Class Reference
Inheritance diagram for MuonHLTSeedMVAClassifier:
edm::stream::EDProducer<>

Public Member Functions

 MuonHLTSeedMVAClassifier (const edm::ParameterSet &)
 
 ~MuonHLTSeedMVAClassifier () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::pair< std::unique_ptr< const SeedMvaEstimator >, std::unique_ptr< const SeedMvaEstimator > > PairSeedMvaEstimator
 

Private Member Functions

double getSeedMva (const PairSeedMvaEstimator &pairMvaEstimator, const TrajectorySeed &seed, const GlobalVector &global_p, const l1t::MuonBxCollection &l1Muons, const reco::RecoChargedCandidateCollection &l2Muons)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

const double baseScore_
 
const bool doSort_
 
const double etaEdge_
 
const bool isFromL1_
 
const edm::EDGetTokenT< l1t::MuonBxCollectionl1MuonToken_
 
const edm::EDGetTokenT< reco::RecoChargedCandidateCollectionl2MuonToken_
 
const int minL1Qual_
 
const double mvaCutB_
 
const double mvaCutE_
 
PairSeedMvaEstimator mvaEstimator_
 
const edm::FileInPath mvaFileB_
 
const edm::FileInPath mvaFileE_
 
const std::vector< double > mvaScaleMeanB_
 
const std::vector< double > mvaScaleMeanE_
 
const std::vector< double > mvaScaleStdB_
 
const std::vector< double > mvaScaleStdE_
 
const int nSeedsMaxB_
 
const int nSeedsMaxE_
 
const bool rejectAll_
 
const edm::EDGetTokenT< TrajectorySeedCollectionseedToken_
 
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecordtrackerGeometryToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 41 of file MuonHLTSeedMVAClassifier.cc.

Member Typedef Documentation

◆ PairSeedMvaEstimator

typedef std::pair<std::unique_ptr<const SeedMvaEstimator>, std::unique_ptr<const SeedMvaEstimator> > MuonHLTSeedMVAClassifier::PairSeedMvaEstimator
private

Definition at line 58 of file MuonHLTSeedMVAClassifier.cc.

Constructor & Destructor Documentation

◆ MuonHLTSeedMVAClassifier()

MuonHLTSeedMVAClassifier::MuonHLTSeedMVAClassifier ( const edm::ParameterSet iConfig)
explicit

Definition at line 90 of file MuonHLTSeedMVAClassifier.cc.

References isFromL1_, minL1Qual_, mvaEstimator_, mvaFileB_, mvaFileE_, mvaScaleMeanB_, mvaScaleMeanE_, mvaScaleStdB_, mvaScaleStdE_, and rejectAll_.

91  : seedToken_(consumes<TrajectorySeedCollection>(iConfig.getParameter<edm::InputTag>("src"))),
92  l1MuonToken_(consumes<l1t::MuonBxCollection>(iConfig.getParameter<edm::InputTag>("L1Muon"))),
93  l2MuonToken_(consumes<reco::RecoChargedCandidateCollection>(iConfig.getParameter<edm::InputTag>("L2Muon"))),
94  trackerGeometryToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>()),
95 
96  rejectAll_(iConfig.getParameter<bool>("rejectAll")),
97  isFromL1_(iConfig.getParameter<bool>("isFromL1")),
98 
99  mvaFileB_(iConfig.getParameter<edm::FileInPath>(isFromL1_ ? "mvaFileBL1" : "mvaFileBL2")),
100  mvaFileE_(iConfig.getParameter<edm::FileInPath>(isFromL1_ ? "mvaFileEL1" : "mvaFileEL2")),
101 
102  mvaScaleMeanB_(iConfig.getParameter<std::vector<double>>(isFromL1_ ? "mvaScaleMeanBL1" : "mvaScaleMeanBL2")),
103  mvaScaleStdB_(iConfig.getParameter<std::vector<double>>(isFromL1_ ? "mvaScaleStdBL1" : "mvaScaleStdBL2")),
104  mvaScaleMeanE_(iConfig.getParameter<std::vector<double>>(isFromL1_ ? "mvaScaleMeanEL1" : "mvaScaleMeanEL2")),
105  mvaScaleStdE_(iConfig.getParameter<std::vector<double>>(isFromL1_ ? "mvaScaleStdEL1" : "mvaScaleStdEL2")),
106 
107  doSort_(iConfig.getParameter<bool>("doSort")),
108  nSeedsMaxB_(iConfig.getParameter<int>("nSeedsMaxB")),
109  nSeedsMaxE_(iConfig.getParameter<int>("nSeedsMaxE")),
110 
111  etaEdge_(iConfig.getParameter<double>("etaEdge")),
112  mvaCutB_(iConfig.getParameter<double>("mvaCutB")),
113  mvaCutE_(iConfig.getParameter<double>("mvaCutE")),
114 
115  minL1Qual_(iConfig.getParameter<int>("minL1Qual")),
116  baseScore_(iConfig.getParameter<double>("baseScore")) {
117  if (!rejectAll_) {
118  mvaEstimator_ = std::make_pair(
119  std::make_unique<SeedMvaEstimator>(mvaFileB_, mvaScaleMeanB_, mvaScaleStdB_, isFromL1_, minL1Qual_),
120  std::make_unique<SeedMvaEstimator>(mvaFileE_, mvaScaleMeanE_, mvaScaleStdE_, isFromL1_, minL1Qual_));
121  }
122 
123  produces<TrajectorySeedCollection>();
124 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::vector< double > mvaScaleStdB_
const std::vector< double > mvaScaleMeanB_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
PairSeedMvaEstimator mvaEstimator_
const std::vector< double > mvaScaleMeanE_
const std::vector< double > mvaScaleStdE_
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_

◆ ~MuonHLTSeedMVAClassifier()

MuonHLTSeedMVAClassifier::~MuonHLTSeedMVAClassifier ( )
overridedefault

Member Function Documentation

◆ fillDescriptions()

void MuonHLTSeedMVAClassifier::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 241 of file MuonHLTSeedMVAClassifier.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_2022v15_cff::InputTag.

241  {
243  desc.add<edm::InputTag>("src", edm::InputTag("hltIter2IterL3MuonPixelSeeds", ""));
244  desc.add<edm::InputTag>("L1Muon", edm::InputTag("hltGtStage2Digis", "Muon"));
245  desc.add<edm::InputTag>("L2Muon", edm::InputTag("hltL2MuonCandidates", ""));
246 
247  desc.add<bool>("rejectAll", false);
248  desc.add<bool>("isFromL1", false);
249 
250  desc.add<edm::FileInPath>("mvaFileBL1",
251  edm::FileInPath("RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_barrel.xml"));
252  desc.add<edm::FileInPath>("mvaFileEL1",
253  edm::FileInPath("RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_endcap.xml"));
254  desc.add<edm::FileInPath>("mvaFileBL2",
255  edm::FileInPath("RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2Seeds_barrel.xml"));
256  desc.add<edm::FileInPath>("mvaFileEL2",
257  edm::FileInPath("RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2Seeds_endcap.xml"));
258  desc.add<std::vector<double>>("mvaScaleMeanBL1", {0., 0., 0., 0., 0., 0., 0., 0.});
259  desc.add<std::vector<double>>("mvaScaleStdBL1", {1., 1., 1., 1., 1., 1., 1., 1.});
260  desc.add<std::vector<double>>("mvaScaleMeanEL1", {0., 0., 0., 0., 0., 0., 0., 0.});
261  desc.add<std::vector<double>>("mvaScaleStdEL1", {1., 1., 1., 1., 1., 1., 1., 1.});
262  desc.add<std::vector<double>>("mvaScaleMeanBL2", {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.});
263  desc.add<std::vector<double>>("mvaScaleStdBL2", {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.});
264  desc.add<std::vector<double>>("mvaScaleMeanEL2", {0., 0., 0., 0., 0., 0., 0., 0., 0., 0.});
265  desc.add<std::vector<double>>("mvaScaleStdEL2", {1., 1., 1., 1., 1., 1., 1., 1., 1., 1.});
266 
267  desc.add<bool>("doSort", false);
268  desc.add<int>("nSeedsMaxB", 1e6);
269  desc.add<int>("nSeedsMaxE", 1e6);
270 
271  desc.add<double>("etaEdge", 1.2);
272  desc.add<double>("mvaCutB", -1.);
273  desc.add<double>("mvaCutE", -1.);
274 
275  desc.add<int>("minL1Qual", 7);
276  desc.add<double>("baseScore", 0.5);
277 
278  descriptions.add("MuonHLTSeedMVAClassifier", desc);
279 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ getSeedMva()

double MuonHLTSeedMVAClassifier::getSeedMva ( const PairSeedMvaEstimator pairMvaEstimator,
const TrajectorySeed seed,
const GlobalVector global_p,
const l1t::MuonBxCollection l1Muons,
const reco::RecoChargedCandidateCollection l2Muons 
)
private

Definition at line 225 of file MuonHLTSeedMVAClassifier.cc.

References funct::abs(), baseScore_, PV3DBase< T, PVType, FrameType >::eta(), etaEdge_, beam_dqm_sourceclient-live_cfg::mva, and fileCollector::seed.

Referenced by produce().

229  {
230  double mva = 0.;
231  if (std::abs(global_p.eta()) < etaEdge_) {
232  mva = pairMvaEstimator.first->computeMva(seed, global_p, l1Muons, l2Muons);
233  } else {
234  mva = pairMvaEstimator.second->computeMva(seed, global_p, l1Muons, l2Muons);
235  }
236 
237  return (mva + baseScore_);
238 }
T eta() const
Definition: PV3DBase.h:73
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ produce()

void MuonHLTSeedMVAClassifier::produce ( edm::Event iEvent,
const edm::EventSetup iEventSetup 
)
overrideprivate

Definition at line 127 of file MuonHLTSeedMVAClassifier.cc.

References funct::abs(), doSort_, PV3DBase< T, PVType, FrameType >::eta(), etaEdge_, JetChargeProducer_cfi::exp, edm::EventSetup::getData(), getSeedMva(), mps_fire::i, TrackerGeometry::idToDet(), iEvent, l1MuonToken_, l2MuonToken_, eostools::move(), beam_dqm_sourceclient-live_cfg::mva, mvaCutB_, mvaCutE_, mvaEstimator_, nSeedsMaxB_, nSeedsMaxE_, rejectAll_, mps_fire::result, offlineSlimmedPrimaryVertices_cfi::score, fileCollector::seed, DetachedQuadStep_cff::seeds, seedToken_, jetUpdater_cfi::sort, sortByMvaScore(), GeomDet::toGlobal(), trackerGeometryToken_, and mitigatedMETSequence_cff::U.

127  {
128  auto result = std::make_unique<TrajectorySeedCollection>();
129 
130  if (rejectAll_) {
131  iEvent.put(std::move(result));
132  return;
133  }
134 
135  if (doSort_ && nSeedsMaxB_ <= 0 && nSeedsMaxE_ <= 0) {
136  iEvent.put(std::move(result));
137  return;
138  }
139 
140  if (!doSort_ && mvaCutB_ > 1. && mvaCutE_ > 1.) {
141  iEvent.put(std::move(result));
142  return;
143  }
144 
146  const l1t::MuonBxCollection& l1Muons = iEvent.get(l1MuonToken_);
148  const TrackerGeometry& trkGeom = iEventSetup.getData(trackerGeometryToken_);
149 
150  std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreB = {};
151  std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreE = {};
152  for (auto& seed : seeds) {
153  const GlobalVector global_p =
154  trkGeom.idToDet(seed.startingState().detId())->surface().toGlobal(seed.startingState().parameters().momentum());
155 
156  bool isB = (std::abs(global_p.eta()) < etaEdge_);
157 
158  if (doSort_) {
159  if (isB) {
160  if (nSeedsMaxB_ <= 0) {
161  continue;
162  }
163  } else {
164  if (nSeedsMaxE_ <= 0) {
165  continue;
166  }
167  }
168  } else {
169  if (isB) {
170  if (mvaCutB_ > 1.0) {
171  continue;
172  } else if (mvaCutB_ <= 0.) {
173  result->emplace_back(seed);
174  continue;
175  }
176  } else {
177  if (mvaCutE_ > 1.0) {
178  continue;
179  } else if (mvaCutE_ <= 0.) {
180  result->emplace_back(seed);
181  continue;
182  }
183  }
184  }
185 
186  double mva = getSeedMva(mvaEstimator_, seed, global_p, l1Muons, l2Muons);
187 
188  double score = 1. / (1. + std::exp(-1. * mva));
189  bool passMva = isB ? score > mvaCutB_ : score > mvaCutE_;
190  if (!passMva)
191  continue;
192 
193  if (doSort_) {
194  if (isB)
195  pairSeedIdxMvaScoreB.push_back(std::make_pair(&seed - &seeds.at(0), score));
196  else
197  pairSeedIdxMvaScoreE.push_back(std::make_pair(&seed - &seeds.at(0), score));
198  } else {
199  result->emplace_back(seed);
200  }
201  }
202 
203  if (doSort_) {
204  std::sort(pairSeedIdxMvaScoreB.begin(), pairSeedIdxMvaScoreB.end(), sortByMvaScore);
205  std::sort(pairSeedIdxMvaScoreE.begin(), pairSeedIdxMvaScoreE.end(), sortByMvaScore);
206 
207  for (auto i = 0U; i < pairSeedIdxMvaScoreB.size(); ++i) {
208  if ((int)i == nSeedsMaxB_)
209  break;
210  const auto& seed(seeds.at(pairSeedIdxMvaScoreB.at(i).first));
211  result->emplace_back(seed);
212  }
213 
214  for (auto i = 0U; i < pairSeedIdxMvaScoreE.size(); ++i) {
215  if ((int)i == nSeedsMaxE_)
216  break;
217  const auto& seed(seeds.at(pairSeedIdxMvaScoreE.at(i).first));
218  result->emplace_back(seed);
219  }
220  }
221 
222  iEvent.put(std::move(result));
223 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
T eta() const
Definition: PV3DBase.h:73
double getSeedMva(const PairSeedMvaEstimator &pairMvaEstimator, const TrajectorySeed &seed, const GlobalVector &global_p, const l1t::MuonBxCollection &l1Muons, const reco::RecoChargedCandidateCollection &l2Muons)
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
int iEvent
Definition: GenABIO.cc:224
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
std::vector< TrajectorySeed > TrajectorySeedCollection
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
PairSeedMvaEstimator mvaEstimator_
bool sortByMvaScore(const std::pair< unsigned, double > &A, const std::pair< unsigned, double > &B)
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_

Member Data Documentation

◆ baseScore_

const double MuonHLTSeedMVAClassifier::baseScore_
private

Definition at line 81 of file MuonHLTSeedMVAClassifier.cc.

Referenced by getSeedMva().

◆ doSort_

const bool MuonHLTSeedMVAClassifier::doSort_
private

Definition at line 72 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ etaEdge_

const double MuonHLTSeedMVAClassifier::etaEdge_
private

Definition at line 76 of file MuonHLTSeedMVAClassifier.cc.

Referenced by getSeedMva(), and produce().

◆ isFromL1_

const bool MuonHLTSeedMVAClassifier::isFromL1_
private

Definition at line 62 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ l1MuonToken_

const edm::EDGetTokenT<l1t::MuonBxCollection> MuonHLTSeedMVAClassifier::l1MuonToken_
private

Definition at line 53 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ l2MuonToken_

const edm::EDGetTokenT<reco::RecoChargedCandidateCollection> MuonHLTSeedMVAClassifier::l2MuonToken_
private

Definition at line 54 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ minL1Qual_

const int MuonHLTSeedMVAClassifier::minL1Qual_
private

Definition at line 80 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaCutB_

const double MuonHLTSeedMVAClassifier::mvaCutB_
private

Definition at line 77 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ mvaCutE_

const double MuonHLTSeedMVAClassifier::mvaCutE_
private

Definition at line 78 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ mvaEstimator_

PairSeedMvaEstimator MuonHLTSeedMVAClassifier::mvaEstimator_
private

Definition at line 59 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier(), and produce().

◆ mvaFileB_

const edm::FileInPath MuonHLTSeedMVAClassifier::mvaFileB_
private

Definition at line 64 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaFileE_

const edm::FileInPath MuonHLTSeedMVAClassifier::mvaFileE_
private

Definition at line 65 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaScaleMeanB_

const std::vector<double> MuonHLTSeedMVAClassifier::mvaScaleMeanB_
private

Definition at line 67 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaScaleMeanE_

const std::vector<double> MuonHLTSeedMVAClassifier::mvaScaleMeanE_
private

Definition at line 69 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaScaleStdB_

const std::vector<double> MuonHLTSeedMVAClassifier::mvaScaleStdB_
private

Definition at line 68 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ mvaScaleStdE_

const std::vector<double> MuonHLTSeedMVAClassifier::mvaScaleStdE_
private

Definition at line 70 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

◆ nSeedsMaxB_

const int MuonHLTSeedMVAClassifier::nSeedsMaxB_
private

Definition at line 73 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ nSeedsMaxE_

const int MuonHLTSeedMVAClassifier::nSeedsMaxE_
private

Definition at line 74 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ rejectAll_

const bool MuonHLTSeedMVAClassifier::rejectAll_
private

Definition at line 61 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier(), and produce().

◆ seedToken_

const edm::EDGetTokenT<TrajectorySeedCollection> MuonHLTSeedMVAClassifier::seedToken_
private

Definition at line 52 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

◆ trackerGeometryToken_

const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> MuonHLTSeedMVAClassifier::trackerGeometryToken_
private

Definition at line 55 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().