40 bool sortByMvaScore(
const std::pair<unsigned, double>&
A,
const std::pair<unsigned, double>&
B) {
41 return (
A.second >
B.second);
61 typedef std::pair<std::unique_ptr<const SeedMvaEstimator>, std::unique_ptr<const SeedMvaEstimator>>
96 tinyxml2::XMLDocument xmlDoc;
98 xmlDoc.LoadFile(weightsFileFullPath.c_str());
100 edm::LogError(
"MuonHLTSeedMVAClassifier") <<
"unsupported file extension, it should be a .xml file!";
103 tinyxml2::XMLElement*
root = xmlDoc.FirstChildElement(
"MethodSetup");
104 if (
root ==
nullptr) {
105 edm::LogError(
"MuonHLTSeedMVAClassifier") <<
"could not retrieve the MethodSetup node from XML file!";
109 const auto&
vars =
root->FirstChildElement(
"Variables");
111 if (
vars !=
nullptr) {
112 for (tinyxml2::XMLElement*
e =
vars->FirstChildElement(
"Variable");
e !=
nullptr;
113 e =
e->NextSiblingElement(
"Variable")) {
117 edm::LogError(
"MuonHLTSeedMVAClassifier") <<
"could not retrieve the Variables node from XML file!";
121 LogTrace(
"MuonHLTSeedMVAClassifier") <<
"MVA file:" << weightsFileFullPath.c_str() <<
" n Var:" <<
n;
122 bool condition = (
isFromL1 && (
n == inputIndexes::kLastL1)) || (!
isFromL1 && (
n == inputIndexes::kLastL2));
131 rejectAll_(iConfig.getParameter<
bool>(
"rejectAll")),
132 isFromL1_(iConfig.getParameter<
bool>(
"isFromL1")),
133 mvaFileB_(iConfig.getParameter<
edm::FileInPath>(
"mvaFileB")),
134 mvaFileE_(iConfig.getParameter<
edm::FileInPath>(
"mvaFileE")),
135 mvaScaleMeanB_(iConfig.getParameter<
std::
vector<double>>(
"mvaScaleMeanB")),
136 mvaScaleStdB_(iConfig.getParameter<
std::
vector<double>>(
"mvaScaleStdB")),
137 mvaScaleMeanE_(iConfig.getParameter<
std::
vector<double>>(
"mvaScaleMeanE")),
138 mvaScaleStdE_(iConfig.getParameter<
std::
vector<double>>(
"mvaScaleStdE")),
139 doSort_(iConfig.getParameter<
bool>(
"doSort")),
140 nSeedsMaxB_(iConfig.getParameter<
int>(
"nSeedsMaxB")),
141 nSeedsMaxE_(iConfig.getParameter<
int>(
"nSeedsMaxE")),
142 etaEdge_(iConfig.getParameter<double>(
"etaEdge")),
143 mvaCutB_(iConfig.getParameter<double>(
"mvaCutB")),
144 mvaCutE_(iConfig.getParameter<double>(
"mvaCutE")),
145 minL1Qual_(iConfig.getParameter<
int>(
"minL1Qual")),
146 baseScore_(iConfig.getParameter<double>(
"baseScore")) {
151 throw cms::Exception(
"ConfigurationError") <<
" MVA files appear to be not consistent with the value of isFromL1 " 152 "parameter.\n Please check your configuration.";
161 produces<TrajectorySeedCollection>();
166 auto result = std::make_unique<TrajectorySeedCollection>();
188 std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreB = {};
189 std::vector<std::pair<unsigned, double>> pairSeedIdxMvaScoreE = {};
192 trkGeom.
idToDet(
seed.startingState().detId())->surface().
toGlobal(
seed.startingState().parameters().momentum());
233 pairSeedIdxMvaScoreB.push_back(std::make_pair(&
seed - &
seeds.at(0),
score));
235 pairSeedIdxMvaScoreE.push_back(std::make_pair(&
seed - &
seeds.at(0),
score));
245 for (
auto i = 0
U;
i < pairSeedIdxMvaScoreB.size(); ++
i) {
248 const auto&
seed(
seeds.at(pairSeedIdxMvaScoreB.at(
i).first));
252 for (
auto i = 0
U;
i < pairSeedIdxMvaScoreE.size(); ++
i) {
255 const auto&
seed(
seeds.at(pairSeedIdxMvaScoreE.at(
i).first));
270 mva = pairMvaEstimator.first->computeMva(
seed, global_p, l1Muons, l2Muons);
272 mva = pairMvaEstimator.second->computeMva(
seed, global_p, l1Muons, l2Muons);
285 desc.add<
bool>(
"rejectAll",
false);
286 desc.add<
bool>(
"isFromL1",
false);
289 edm::FileInPath(
"RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_barrel.xml"));
291 edm::FileInPath(
"RecoMuon/TrackerSeedGenerator/data/xgb_Run3_Iter2FromL1Seeds_endcap.xml"));
292 desc.add<std::vector<double>>(
"mvaScaleMeanB", {0., 0., 0., 0., 0., 0., 0., 0.});
293 desc.add<std::vector<double>>(
"mvaScaleStdB", {1., 1., 1., 1., 1., 1., 1., 1.});
294 desc.add<std::vector<double>>(
"mvaScaleMeanE", {0., 0., 0., 0., 0., 0., 0., 0.});
295 desc.add<std::vector<double>>(
"mvaScaleStdE", {1., 1., 1., 1., 1., 1., 1., 1.});
297 desc.add<
bool>(
"doSort",
false);
298 desc.add<
int>(
"nSeedsMaxB", 1e6);
299 desc.add<
int>(
"nSeedsMaxE", 1e6);
301 desc.add<
double>(
"etaEdge", 1.2);
302 desc.add<
double>(
"mvaCutB", -1.);
303 desc.add<
double>(
"mvaCutE", -1.);
305 desc.add<
int>(
"minL1Qual", 7);
306 desc.add<
double>(
"baseScore", 0.5);
308 descriptions.
add(
"MuonHLTSeedMVAClassifier",
desc);
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
bool hasEnding(std::string const &fullString, std::string const &ending)
std::string fullPath() const
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_
Log< level::Error, false > LogError
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_
const edm::FileInPath mvaFileE_
const edm::EDGetTokenT< l1t::MuonBxCollection > l1MuonToken_
std::vector< TrajectorySeed > TrajectorySeedCollection
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
~MuonHLTSeedMVAClassifier() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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.
BXVector< Muon > MuonBxCollection
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
bool checkMVAFileConsistency(const std::string &weightsFileFullPath, bool isFromL1) const
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)
const std::vector< double > mvaScaleMeanE_
const std::vector< double > mvaScaleStdE_
const edm::EDGetTokenT< TrajectorySeedCollection > seedToken_
const edm::EDGetTokenT< reco::RecoChargedCandidateCollection > l2MuonToken_