23 #include <unordered_map>
30 static const std::vector<std::string> float_var_names( { } );
32 static const std::vector<std::string> integer_var_names( { } );
35 std::unordered_map<std::string,float>&
map) {
39 std::unordered_map<std::string,int>&
map) {
44 inline void check_map(
const std::unordered_map<std::string,T>&
map,
unsigned exp_size) {
45 if( map.size() != exp_size ) {
47 <<
"variable map size: " << map.size()
48 <<
" not equal to expected size: " << exp_size <<
" !"
49 <<
" The regression variable calculation code definitely has a bug, fix it!";
53 template<
typename LazyTools>
57 std::unordered_map<std::string,float>& float_vars,
58 std::unordered_map<std::string,int>& int_vars ) {
78 const std::vector<T> &
values,
81 std::unique_ptr<EcalClusterLazyToolsBase>
lazyTools;
99 use_full5x5_(iConfig.getParameter<bool>(
"useFull5x5")) {
105 (
"ebReducedRecHitCollection"));
107 (
"ebReducedRecHitCollectionMiniAOD"));
110 (
"eeReducedRecHitCollection"));
112 (
"eeReducedRecHitCollectionMiniAOD"));
115 (
"esReducedRecHitCollection"));
117 (
"esReducedRecHitCollectionMiniAOD"));
123 produces<edm::ValueMap<float> >(
name);
127 produces<edm::ValueMap<int> >(
name);
146 if( !
src.isValid() ) {
165 lazyTools = std::make_unique<noZS::EcalClusterLazyTools>(
iEvent, iSetup,
172 std::vector<std::vector<float> > float_vars(k_NFloatVars);
173 std::vector<std::vector<int> > int_vars(k_NIntVars);
175 std::unordered_map<std::string,float> float_vars_map;
176 std::unordered_map<std::string,int> int_vars_map;
179 for (
size_t i = 0;
i <
src->size(); ++
i){
180 auto iEle =
src->ptrAt(
i);
183 calculateValues<noZS::EcalClusterLazyTools>(
lazyTools.get(),
189 calculateValues<EcalClusterLazyTools>(
lazyTools.get(),
196 check_map(float_vars_map, k_NFloatVars);
197 check_map(int_vars_map, k_NIntVars);
199 for(
unsigned i = 0;
i < float_vars.size(); ++
i ) {
200 float_vars[
i].emplace_back(float_vars_map.at(float_var_names[
i]));
203 for(
unsigned i = 0;
i < int_vars.size(); ++
i ) {
204 int_vars[
i].emplace_back(int_vars_map.at(integer_var_names[
i]));
208 for(
unsigned i = 0;
i < float_vars.size(); ++
i ) {
212 for(
unsigned i = 0;
i < int_vars.size(); ++
i ) {
222 const std::vector<T> &
values,
229 auto_ptr<TValueMap> valMap(
new TValueMap());
230 typename TValueMap::Filler filler(*valMap);
231 filler.insert(
handle, values.begin(), values.end());
233 iEvent.
put(valMap, label);
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::GsfElectron > > &handle, const std::vector< T > &values, const std::string &label) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~ElectronRegressionValueMapProducer()
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
void addDefault(ParameterSetDescription const &psetDescription)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionMiniAOD_
std::unique_ptr< EcalClusterLazyToolsBase > lazyTools
edm::EDGetToken srcMiniAOD_
ElectronRegressionValueMapProducer(const edm::ParameterSet &)
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
virtual void produce(edm::Event &, const edm::EventSetup &) override