22 #include <unordered_map>
41 typedef std::unordered_map<std::
string,
int>
TypeMap;
71 consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcForIsolationCone"));
73 puppiValueMapToken_ = mayConsume<edm::ValueMap<float>>(
c.getParameter<
edm::InputTag>(
"puppiValueMap"));
77 const std::vector<edm::ParameterSet>&
isoDefs =
78 c.getParameterSetVector(
"isolationConeDefinitions");
79 for(
const auto& isodef : isoDefs ) {
82 const float coneSize = isodef.getParameter<
double>(
"coneSize");
84 std::sprintf(buf,
"DR%.2f",coneSize);
86 auto decimal = coneName.find(
'.');
87 if( decimal != std::string::npos ) coneName.erase(decimal,1);
92 theisolator->setConsumes(consumesCollector());
93 const auto thetype = _typeMap.find(isotype);
94 if( thetype == _typeMap.end() ) {
96 <<
"Isolation type: " << isotype <<
" is not available in the "
97 <<
"list of allowed isolations!.";
99 _isolation_types[thetype->second].emplace_back(theisolator);
101 std::string pname = isotype+dash+coneName+dash+theisolator->additionalCode();
102 _product_names[thetype->second].emplace_back(pname);
103 produces<edm::ValueMap<float> >(
pname);
111 for(
const auto& isolator : isolators_for_type ) {
112 isolator->getEventSetupInfo(es);
119 typedef std::auto_ptr<edm::ValueMap<float> > product_type;
120 typedef std::vector<float> product_values;
128 std::array<std::vector<product_values>,
kNPFTypes> the_values;
132 the_values[i++].resize(isolators_for_type.size());
133 for(
const auto& isolator : isolators_for_type ) {
134 isolator->getEventInfo(ev);
139 for(
size_t c = 0;
c < to_isolate->size(); ++
c ) {
140 auto cand_to_isolate = to_isolate->ptrAt(
c);
141 std::array<std::vector<float>,
kNPFTypes> cand_values;
143 for(
const auto& isolators_for_type : _isolation_types ) {
144 cand_values[
k].resize(isolators_for_type.size());
145 for(
auto&
value : cand_values[k] )
value = 0.0;
148 for(
size_t ic = 0; ic < isolate_with->size(); ++ic ) {
149 auto isocand = isolate_with->ptrAt(ic);
152 const auto& isolations = _isolation_types[isotype];
153 for(
unsigned i = 0; i < isolations.size(); ++
i ) {
154 if( isolations[i]->isInIsolationCone(cand_to_isolate,isocand) ) {
155 double puppiWeight = 0.;
157 else puppiWeight = (*puppiValueMap)[isocand];
158 if (puppiWeight > 0.)cand_values[isotype][
i] += (isocand->pt())*puppiWeight;
164 for(
unsigned j = 0;
j < cand_values[
i].size(); ++
j ) {
165 the_values[
i][
j].push_back(cand_values[i][
j]);
171 for(
unsigned j = 0;
j < the_values[
i].size(); ++
j ) {
174 fillerprod.
insert(to_isolate,
176 the_values[i][
j].
end());
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
const std::vector< edm::ParameterSet > & isoDefs
edm::Handle< edm::ValueMap< float > > puppiValueMap
std::array< std::vector< std::string >, kNPFTypes > _product_names
void insert(const H &h, I begin, I end)
edm::EDGetTokenT< edm::ValueMap< float > > puppiValueMapToken_
std::unordered_map< std::string, int > TypeMap
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
PFIsolationSumProducerForPUPPI(const edm::ParameterSet &)
virtual ~PFIsolationSumProducerForPUPPI()
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
edm::EDGetTokenT< CandView > _to_isolate
ParticleType translatePdgIdToType(int pdgid) const
Particle reconstructed by the particle flow algorithm.
std::vector< std::unique_ptr< IsolationConeDefinitionBase > > IsoTypes
virtual void produce(edm::Event &, const edm::EventSetup &) overridefinal
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types
T get(const Candidate &c)
static unsigned kNPFTypes