53 const std::vector<std::string>
names_;
57 std::vector<std::unique_ptr<const GBRForest> >
models_;
76 thresholds_(conf.getParameter<
std::vector<double> >(
"ModelThresholds")),
92 <<
"'ModelNames' size (" <<
names_.size() <<
") != 'ModelWeights' size (" <<
models_.size() <<
").\n";
96 <<
"'ModelWeights' size (" <<
models_.size() <<
") != 'ModelThresholds' size (" <<
thresholds_.size() <<
").\n";
102 produces<edm::ValueMap<float> >(
name);
116 event.getByToken(
rho_, rho);
117 if (!rho.isValid()) {
118 std::ostringstream os;
119 os <<
"Problem accessing rho collection for low-pT electrons" << std::endl;
126 event.getByToken(
gsf2trk_, gsf2trk);
145 std::vector<std::vector<float> >
output;
147 for (
unsigned int iname = 0; iname <
names_.size(); ++iname) {
148 output.emplace_back(nElectrons, -999.);
152 for (
unsigned int iele = 0; iele <
nElectrons; iele++) {
162 const PackedPtr* ptr1 = ele->
userData<PackedPtr>(
"ele2packed");
163 const PackedPtr* ptr2 = ele->
userData<PackedPtr>(
"ele2lost");
164 auto hasBestTrack = [](
const PackedPtr* ptr) {
165 return ptr !=
nullptr && ptr->isNonnull() && ptr->isAvailable() && ptr->get() !=
nullptr &&
166 ptr->get()->bestTrack() !=
nullptr;
168 if (hasBestTrack(ptr1)) {
169 trk = ptr1->get()->bestTrack();
170 }
else if (hasBestTrack(ptr2)) {
171 trk = ptr2->get()->bestTrack();
180 for (
unsigned int iname = 0; iname <
names_.size(); ++iname) {
181 output[iname][iele] =
eval(
names_[iname], ele, *rho, ele->
electronID(
"unbiased"), zfield.z(), trk);
185 for (
unsigned int iele = 0; iele <
nElectrons; iele++) {
190 const auto&
gsf = ele->
core()->gsfTrack();
198 if (
gsf.isAvailable()) {
199 auto const& ref = (*gsf2trk)[
gsf];
200 if (ref.isNonnull() && ref.isAvailable()) {
212 for (
unsigned int iname = 0; iname <
names_.size(); ++iname) {
213 output[iname][iele] =
eval(
names_[iname], ele, *rho, unbiased, zfield.z(), trk);
219 for (
unsigned int iname = 0; iname <
names_.size(); ++iname) {
223 filler.
insert(patElectrons, output[iname].
begin(), output[iname].
end());
225 filler.
insert(electrons, output[iname].
begin(), output[iname].
end());
241 if (iter !=
names_.end()) {
243 std::vector<float>
inputs;
246 features.
set(*ele, rho);
247 inputs = features.
get();
253 return models_.at(index)->GetResponse(inputs.data());
255 throw cms::Exception(
"Unknown model name") <<
"'Name given: '" << name <<
"'. Check against configuration file.\n";
264 desc.
add<
bool>(
"useGsfToTrack",
false);
265 desc.
add<
bool>(
"usePAT",
false);
270 desc.
add<std::vector<std::string> >(
"ModelNames", std::vector<std::string>());
271 desc.
add<std::vector<std::string> >(
"ModelWeights", std::vector<std::string>());
272 desc.
add<std::vector<double> >(
"ModelThresholds", std::vector<double>());
273 desc.
add<
bool>(
"PassThrough",
false);
274 desc.
add<
double>(
"MinPtThreshold", 0.5);
275 desc.
add<
double>(
"MaxPtThreshold", 15.);
277 descriptions.
add(
"defaultLowPtGsfElectronID", desc);
const bool useGsfToTrack_
const double minPtThreshold_
T getParameter(std::string const &) const
bool isElectronIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Electron.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
virtual TrackRef closestCtfTrackRef() const
bool isNonnull() const
Checks for non-null.
static void fillDescriptions(edm::ConfigurationDescriptions &)
const std::string version_
void insert(const H &h, I begin, I end)
edm::EDGetTokenT< reco::GsfElectronCollection > electrons_
def setup(process, global_tag, zero_tesla=False)
std::vector< float > get()
const std::vector< double > thresholds_
const std::vector< std::string > names_
std::vector< std::unique_ptr< const GBRForest > > models_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::vector< float > features_V1(reco::GsfElectron const &ele, float rho, float unbiased, float field_z, const reco::Track *trk=0)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
double eval(const std::string &name, const edm::Ptr< reco::GsfElectron > &, double rho, float unbiased, float field_z, const reco::Track *trk=0) const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
LowPtGsfElectronIDProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
const double maxPtThreshold_
edm::EDGetTokenT< pat::ElectronCollection > patElectrons_
float electronID(const std::string &name) const
Returns a specific electron ID associated to the pat::Electron given its name.
const T * userData(const std::string &key) const
Returns user-defined data. Returns NULL if the data is not present, or not of type T...
T const * get() const
Returns C++ pointer to the item.
std::vector< float > features_V0(reco::GsfElectron const &ele, float rho, float unbiased)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isNull() const
Checks for null.
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
const edm::EDGetTokenT< double > rho_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::EDGetTokenT< edm::ValueMap< float > > unbiased_
reco::TrackRef closestCtfTrackRef() const override
override the reco::GsfElectron::closestCtfTrackRef method, to access the internal storage of the trac...
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::Association< reco::TrackCollection > > gsf2trk_
virtual GsfElectronCoreRef core() const
bool isUninitialized() const
void set(const reco::GsfElectronRef &ele, double rho)