21 #include <unordered_map> 29 static const std::vector<std::string> float_var_names( { } );
31 static const std::vector<std::string> integer_var_names( { } );
34 std::unordered_map<std::string,float>&
map) {
37 inline void set_map_val(
const reg_int_vars index,
const int value,
38 std::unordered_map<std::string,int>& map) {
43 inline void check_map(
const std::unordered_map<std::string,T>& map,
unsigned exp_size) {
44 if( map.size() != exp_size ) {
46 <<
"variable map size: " << map.size()
47 <<
" not equal to expected size: " << exp_size <<
" !" 48 <<
" The regression variable calculation code definitely has a bug, fix it!";
52 template<
typename LazyTools,
typename SeedType>
55 std::unordered_map<std::string,float>& float_vars,
56 std::unordered_map<std::string,int>& int_vars ) {
76 const std::vector<T> &
values,
80 std::unique_ptr<EcalClusterLazyToolsBase>
lazyTools;
104 (
"ebReducedRecHitCollection"));
106 (
"ebReducedRecHitCollectionMiniAOD"));
109 (
"eeReducedRecHitCollection"));
111 (
"eeReducedRecHitCollectionMiniAOD"));
114 (
"esReducedRecHitCollection"));
116 (
"esReducedRecHitCollectionMiniAOD"));
127 produces<edm::ValueMap<float> >(
name);
131 produces<edm::ValueMap<int> >(
name);
153 <<
"DataFormat does not contain a photon source!";
170 lazyTools = std::make_unique<noZS::EcalClusterLazyTools>(
iEvent, iSetup,
177 if( !isAOD && src->size() ) {
179 if(
test.isNull() || !
test.isAvailable() ) {
181 <<
"DataFormat is detected as miniAOD but cannot cast to pat::Photon!";
185 std::vector<std::vector<float> > float_vars(k_NFloatVars);
186 std::vector<std::vector<int> > int_vars(k_NIntVars);
188 std::unordered_map<std::string,float> float_vars_map;
189 std::unordered_map<std::string,int> int_vars_map;
192 for (
unsigned idxpho = 0; idxpho < src->size(); ++idxpho) {
193 const auto& iPho = src->ptrAt(idxpho);
198 const auto& theseed = *(iPho->superCluster()->seed());
201 calculateValues<noZS::EcalClusterLazyTools>(
lazyTools.get(),
206 calculateValues<EcalClusterLazyTools>(
lazyTools.get(),
212 check_map(float_vars_map, k_NFloatVars);
213 check_map(int_vars_map, k_NIntVars);
215 for(
unsigned i = 0;
i < float_vars.size(); ++
i ) {
216 float_vars[
i].emplace_back(float_vars_map.at(float_var_names[
i]));
220 for(
unsigned i = 0;
i < int_vars.size(); ++
i ) {
221 int_vars[
i].emplace_back(int_vars_map.at(integer_var_names[
i]));
226 for(
unsigned i = 0;
i < float_vars.size(); ++
i ) {
230 for(
unsigned i = 0;
i < int_vars.size(); ++
i ) {
240 const std::vector<T> &
values,
247 auto valMap = std::make_unique<TValueMap>();
248 typename TValueMap::Filler
filler(*valMap);
249 filler.insert(
handle, values.begin(), values.end());
edm::EDGetToken srcMiniAOD_
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::unique_ptr< EcalClusterLazyToolsBase > lazyTools
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollectionMiniAOD_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollectionMiniAOD_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > ebReducedRecHitCollection_
void addDefault(ParameterSetDescription const &psetDescription)
PhotonRegressionValueMapProducer(const edm::ParameterSet &)
void writeValueMap(edm::Event &iEvent, const edm::Handle< edm::View< reco::Photon > > &handle, const std::vector< T > &values, const std::string &label) const
~PhotonRegressionValueMapProducer()
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< EcalRecHitCollection > esReducedRecHitCollection_
edm::EDGetTokenT< EcalRecHitCollection > eeReducedRecHitCollectionMiniAOD_
virtual void produce(edm::Event &, const edm::EventSetup &) override