CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::MuonBxCollection
l1MuonToken_
 
const edm::EDGetTokenT
< reco::RecoChargedCandidateCollection
l2MuonToken_
 
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
< TrajectorySeedCollection
seedToken_
 
const edm::ESGetToken
< TrackerGeometry,
TrackerDigiGeometryRecord
trackerGeometryToken_
 

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

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 ( 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 }
const std::vector< double > mvaScaleStdB_
const std::vector< double > mvaScaleMeanB_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
PairSeedMvaEstimator mvaEstimator_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const std::vector< double > mvaScaleMeanE_
const std::vector< double > mvaScaleStdE_
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_
MuonHLTSeedMVAClassifier::~MuonHLTSeedMVAClassifier ( )
overridedefault

Member Function Documentation

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

Definition at line 241 of file MuonHLTSeedMVAClassifier.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, and HLT_FULL_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 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
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_, and beam_dqm_sourceclient-live_cfg::mva.

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 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T eta() const
Definition: PV3DBase.h:73
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_, funct::exp(), edm::Event::get(), edm::EventSetup::getData(), getSeedMva(), mps_fire::i, TrackerGeometry::idToDet(), l1MuonToken_, l2MuonToken_, eostools::move(), beam_dqm_sourceclient-live_cfg::mva, mvaCutB_, mvaCutE_, mvaEstimator_, nSeedsMaxB_, nSeedsMaxE_, edm::Event::put(), rejectAll_, mps_fire::result, fileCollector::seed, DetachedQuadStep_cff::seeds, seedToken_, sortByMvaScore(), GeomDet::toGlobal(), and trackerGeometryToken_.

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 
145  const TrajectorySeedCollection& seeds = iEvent.get(seedToken_);
146  const l1t::MuonBxCollection& l1Muons = iEvent.get(l1MuonToken_);
147  const reco::RecoChargedCandidateCollection& l2Muons = iEvent.get(l2MuonToken_);
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 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
double getSeedMva(const PairSeedMvaEstimator &pairMvaEstimator, const TrajectorySeed &seed, const GlobalVector &global_p, const l1t::MuonBxCollection &l1Muons, const reco::RecoChargedCandidateCollection &l2Muons)
tuple result
Definition: mps_fire.py:311
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerGeometryToken_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
std::vector< TrajectorySeed > TrajectorySeedCollection
def move
Definition: eostools.py:511
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
const TrackerGeomDet * idToDet(DetId) const override
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
PairSeedMvaEstimator mvaEstimator_
T eta() const
Definition: PV3DBase.h:73
bool sortByMvaScore(const std::pair< unsigned, double > &A, const std::pair< unsigned, double > &B)
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_

Member Data Documentation

const double MuonHLTSeedMVAClassifier::baseScore_
private

Definition at line 81 of file MuonHLTSeedMVAClassifier.cc.

Referenced by getSeedMva().

const bool MuonHLTSeedMVAClassifier::doSort_
private

Definition at line 72 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

const double MuonHLTSeedMVAClassifier::etaEdge_
private

Definition at line 76 of file MuonHLTSeedMVAClassifier.cc.

Referenced by getSeedMva(), and produce().

const bool MuonHLTSeedMVAClassifier::isFromL1_
private

Definition at line 62 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

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

Definition at line 53 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

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

Definition at line 54 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

const int MuonHLTSeedMVAClassifier::minL1Qual_
private

Definition at line 80 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

const double MuonHLTSeedMVAClassifier::mvaCutB_
private

Definition at line 77 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

const double MuonHLTSeedMVAClassifier::mvaCutE_
private

Definition at line 78 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

PairSeedMvaEstimator MuonHLTSeedMVAClassifier::mvaEstimator_
private

Definition at line 59 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier(), and produce().

const edm::FileInPath MuonHLTSeedMVAClassifier::mvaFileB_
private

Definition at line 64 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

const edm::FileInPath MuonHLTSeedMVAClassifier::mvaFileE_
private

Definition at line 65 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

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

Definition at line 67 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

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

Definition at line 69 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

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

Definition at line 68 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

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

Definition at line 70 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier().

const int MuonHLTSeedMVAClassifier::nSeedsMaxB_
private

Definition at line 73 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

const int MuonHLTSeedMVAClassifier::nSeedsMaxE_
private

Definition at line 74 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

const bool MuonHLTSeedMVAClassifier::rejectAll_
private

Definition at line 61 of file MuonHLTSeedMVAClassifier.cc.

Referenced by MuonHLTSeedMVAClassifier(), and produce().

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

Definition at line 52 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().

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

Definition at line 55 of file MuonHLTSeedMVAClassifier.cc.

Referenced by produce().