45 template <
typename EL,
typename FID,
typename FTRK>
56 const std::vector<std::string>
names_;
57 std::vector<edm::EDPutTokenT<edm::ValueMap<float>>>
putTokens_;
61 std::vector<std::unique_ptr<const GBRForest>>
models_;
71 : useGsfToTrack_(conf.getParameter<
bool>(
"useGsfToTrack")),
72 usePAT_(conf.getParameter<
bool>(
"usePAT")),
75 rho_(consumes<double>(conf.getParameter<
edm::
InputTag>(
"rho"))),
80 passThrough_(conf.getParameter<
bool>(
"PassThrough")),
81 minPtThreshold_(conf.getParameter<double>(
"MinPtThreshold")),
82 maxPtThreshold_(conf.getParameter<double>(
"MaxPtThreshold")),
83 thresholds_(conf.getParameter<
std::
vector<double>>(
"ModelThresholds")),
84 versionName_(conf.getParameter<
std::
string>(
"Version")) {
99 <<
"'ModelNames' size (" <<
names_.size() <<
") != 'ModelWeights' size (" <<
models_.size() <<
").\n";
103 <<
"'ModelWeights' size (" <<
models_.size() <<
") != 'ModelThresholds' size (" <<
thresholds_.size() <<
").\n";
126 event.getByToken(
rho_, hRho);
127 if (!hRho.isValid()) {
128 std::ostringstream
os;
129 os <<
"Problem accessing rho collection for low-pT electrons" << std::endl;
136 event.getByToken(
gsf2trk_, gsf2trk);
151 [&](
auto const& ele) {
152 if (!ele.isElectronIDAvailable(kUnbiased)) {
155 return ele.electronID(kUnbiased);
157 [&](
auto const& ele) {
160 const PackedPtr* ptr1 = ele.template userData<PackedPtr>(
"ele2packed");
161 const PackedPtr* ptr2 = ele.template userData<PackedPtr>(
"ele2lost");
162 auto hasBestTrack = [](
const PackedPtr* ptr) {
163 return ptr !=
nullptr && ptr->
isNonnull() && ptr->isAvailable() && ptr->get() !=
nullptr &&
164 ptr->get()->bestTrack() !=
nullptr;
166 if (hasBestTrack(ptr1)) {
167 return ptr1->get()->bestTrack();
168 }
else if (hasBestTrack(ptr2)) {
169 return ptr2->get()->bestTrack();
188 [&](
auto const& ele) {
189 if (ele.core().isNull()) {
192 const auto&
gsf = ele.core()->gsfTrack();
196 return unbiasedH[
gsf];
198 [&](
auto const& ele) {
200 const auto&
gsf = ele.core()->gsfTrack();
201 if (
gsf.isNonnull() &&
gsf.isAvailable()) {
202 auto const& ref = (*gsf2trk)[
gsf];
203 if (ref.isNonnull() && ref.isAvailable()) {
219 template <
typename EL,
typename FID,
typename FTRK>
223 std::vector<float> ids;
226 std::vector<const reco::Track*>
trks;
233 for (
unsigned int iele = 0; iele <
nElectrons; iele++) {
234 auto const& ele = (*electrons)[iele];
257 std::vector<float>
inputs;
270 desc.add<
bool>(
"useGsfToTrack",
false);
271 desc.add<
bool>(
"usePAT",
false);
276 desc.add<std::vector<std::string>>(
"ModelNames", {
""});
277 desc.add<std::vector<std::string>>(
278 "ModelWeights", {
"RecoEgamma/ElectronIdentification/data/LowPtElectrons/LowPtElectrons_ID_2020Nov28.root"});
279 desc.add<std::vector<double>>(
"ModelThresholds", {-99.});
280 desc.add<
bool>(
"PassThrough",
false);
281 desc.add<
double>(
"MinPtThreshold", 0.5);
282 desc.add<
double>(
"MaxPtThreshold", 15.);
284 descriptions.
add(
"defaultLowPtGsfElectronID",
desc);
double eval(const GBRForest &model, const reco::GsfElectron &, double rho, float unbiased, float field_z, const reco::Track *trk=nullptr) const
const bool useGsfToTrack_
const double minPtThreshold_
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &)
const_reference_type get(ProductID id, size_t idx) const
Global3DPoint GlobalPoint
edm::EDGetTokenT< reco::GsfElectronCollection > electrons_
bool isNonnull() const
Checks for non-null.
const std::vector< double > thresholds_
const std::vector< std::string > names_
std::vector< std::unique_ptr< const GBRForest > > models_
LowPtGsfElectronIDProducer(const edm::ParameterSet &)
void doWork(double rho, float bz, EL const &electrons, FID &&idFunctor, FTRK &&trkFunctor, edm::Event &) const
bool isNonnull() const
Checks for non-null.
const double maxPtThreshold_
edm::EDGetTokenT< pat::ElectronCollection > patElectrons_
#define DEFINE_FWK_MODULE(type)
std::vector< float > features_V0(reco::GsfElectron const &ele, float rho, float unbiased)
std::vector< float > features_V1(reco::GsfElectron const &ele, float rho, float unbiased, float field_z, const reco::Track *trk=nullptr)
const edm::EDGetTokenT< double > rho_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const std::string versionName_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > fieldToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
T const * get() const
Returns C++ pointer to the item.
std::vector< edm::EDPutTokenT< edm::ValueMap< float > > > putTokens_