37 bool sortByMvaScore(
const std::pair<unsigned, double>&
A,
const std::pair<unsigned, double>&
B) {
38 return (A.second > B.second);
57 typedef std::pair<std::unique_ptr<const SeedMvaEstimator>, std::unique_ptr<const SeedMvaEstimator>>
96 rejectAll_(iConfig.getParameter<bool>(
"rejectAll")),
97 isFromL1_(iConfig.getParameter<bool>(
"isFromL1")),
99 mvaFileB_(iConfig.getParameter<edm::FileInPath>(isFromL1_ ?
"mvaFileBL1" :
"mvaFileBL2")),
100 mvaFileE_(iConfig.getParameter<edm::FileInPath>(isFromL1_ ?
"mvaFileEL1" :
"mvaFileEL2")),
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")),
107 doSort_(iConfig.getParameter<bool>(
"doSort")),
108 nSeedsMaxB_(iConfig.getParameter<int>(
"nSeedsMaxB")),
109 nSeedsMaxE_(iConfig.getParameter<int>(
"nSeedsMaxE")),
111 etaEdge_(iConfig.getParameter<double>(
"etaEdge")),
112 mvaCutB_(iConfig.getParameter<double>(
"mvaCutB")),
113 mvaCutE_(iConfig.getParameter<double>(
"mvaCutE")),
115 minL1Qual_(iConfig.getParameter<int>(
"minL1Qual")),
116 baseScore_(iConfig.getParameter<double>(
"baseScore")) {
123 produces<TrajectorySeedCollection>();
128 auto result = std::make_unique<TrajectorySeedCollection>();
150 std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreB = {};
151 std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreE = {};
152 for (
auto&
seed : seeds) {
154 trkGeom.
idToDet(
seed.startingState().detId())->surface().
toGlobal(
seed.startingState().parameters().momentum());
188 double score = 1. / (1. +
std::exp(-1. * mva));
195 pairSeedIdxMvaScoreB.push_back(std::make_pair(&
seed - &seeds.at(0), score));
197 pairSeedIdxMvaScoreE.push_back(std::make_pair(&
seed - &seeds.at(0), score));
204 std::sort(pairSeedIdxMvaScoreB.begin(), pairSeedIdxMvaScoreB.end(),
sortByMvaScore);
205 std::sort(pairSeedIdxMvaScoreE.begin(), pairSeedIdxMvaScoreE.end(),
sortByMvaScore);
207 for (
auto i = 0U;
i < pairSeedIdxMvaScoreB.size(); ++
i) {
210 const auto&
seed(seeds.at(pairSeedIdxMvaScoreB.at(
i).first));
214 for (
auto i = 0U;
i < pairSeedIdxMvaScoreE.size(); ++
i) {
217 const auto&
seed(seeds.at(pairSeedIdxMvaScoreE.at(
i).first));
232 mva = pairMvaEstimator.first->computeMva(seed, global_p, l1Muons, l2Muons);
234 mva = pairMvaEstimator.second->computeMva(seed, global_p, l1Muons, l2Muons);
247 desc.
add<
bool>(
"rejectAll",
false);
248 desc.
add<
bool>(
"isFromL1",
false);
251 edm::FileInPath(
"RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_barrel.xml"));
253 edm::FileInPath(
"RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_endcap.xml"));
255 edm::FileInPath(
"RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2Seeds_barrel.xml"));
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.});
267 desc.
add<
bool>(
"doSort",
false);
268 desc.
add<
int>(
"nSeedsMaxB", 1e6);
269 desc.
add<
int>(
"nSeedsMaxE", 1e6);
271 desc.
add<
double>(
"etaEdge", 1.2);
272 desc.
add<
double>(
"mvaCutB", -1.);
273 desc.
add<
double>(
"mvaCutE", -1.);
275 desc.
add<
int>(
"minL1Qual", 7);
276 desc.
add<
double>(
"baseScore", 0.5);
278 descriptions.
add(
"MuonHLTSeedMVAClassifier", desc);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
#define DEFINE_FWK_MODULE(type)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void produce(edm::Event &, const edm::EventSetup &) override
const edm::FileInPath mvaFileB_
const std::vector< double > mvaScaleStdB_
MuonHLTSeedMVAClassifier(const edm::ParameterSet &)
const std::vector< double > mvaScaleMeanB_
Exp< T >::type exp(const T &t)
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_
bool getData(T &iHolder) const
const edm::FileInPath mvaFileE_
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
std::vector< TrajectorySeed > TrajectorySeedCollection
Abs< T >::type abs(const T &t)
bool get(ProductID const &oid, Handle< PROD > &result) const
~MuonHLTSeedMVAClassifier() override=default
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const TrackerGeomDet * idToDet(DetId) const override
BXVector< Muon > MuonBxCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
PairSeedMvaEstimator mvaEstimator_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::pair< std::unique_ptr< const SeedMvaEstimator >, std::unique_ptr< const SeedMvaEstimator > > PairSeedMvaEstimator
bool sortByMvaScore(const std::pair< unsigned, double > &A, const std::pair< unsigned, double > &B)
trackerGeometryToken_(iC.esConsumes())
const std::vector< double > mvaScaleMeanE_
const std::vector< double > mvaScaleStdE_
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_