1 #ifndef PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H
2 #define PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H
26 #include <unordered_map>
28 namespace edm {
class Event; }
47 typedef std::unordered_map<std::
string,
int>
TypeMap;
74 consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcForIsolationCone"));
75 const std::vector<edm::ParameterSet>&
isoDefs =
76 c.getParameterSetVector(
"isolationConeDefinitions");
77 for(
const auto& isodef : isoDefs ) {
80 const float coneSize = isodef.getParameter<
double>(
"coneSize");
82 sprintf(buf,
"DR%.2f",coneSize);
84 auto decimal = coneName.find(
'.');
85 if( decimal != std::string::npos ) coneName.erase(decimal,1);
90 theisolator->setConsumes(consumesCollector());
91 const auto thetype = _typeMap.find(isotype);
92 if( thetype == _typeMap.end() ) {
94 <<
"Isolation type: " << isotype <<
" is not available in the "
95 <<
"list of allowed isolations!.";
99 std::string pname = isotype+dash+coneName+dash+theisolator->additionalCode();
100 _product_names[thetype->second].emplace_back(pname);
101 produces<edm::ValueMap<float> >(pname);
109 for(
const auto& isolator : isolators_for_type ) {
110 isolator->getEventSetupInfo(es);
117 typedef std::auto_ptr<edm::ValueMap<float> > product_type;
118 typedef std::vector<float> product_values;
124 std::array<std::vector<product_values>,
kNPFTypes> the_values;
128 the_values[i++].resize(isolators_for_type.size());
129 for(
const auto& isolator : isolators_for_type ) {
130 isolator->getEventInfo(ev);
135 for(
const auto& cand_to_isolate : to_isolate->ptrVector() ) {
136 std::array<std::vector<float>,
kNPFTypes> cand_values;
138 for(
const auto& isolators_for_type : _isolation_types ) {
139 cand_values[
k].resize(isolators_for_type.size());
140 for(
auto&
value : cand_values[k] )
value = 0.0;
143 for(
const auto& isocand : isolate_with->ptrVector() ) {
145 const auto& isolations = _isolation_types[isotype];
146 for(
unsigned i = 0; i < isolations.size(); ++
i ) {
147 if( isolations[i]->isInIsolationCone(cand_to_isolate,isocand) ) {
148 cand_values[isotype][
i] += isocand->pt();
154 for(
unsigned j = 0;
j < cand_values[
i].size(); ++
j ) {
155 the_values[
i][
j].push_back(cand_values[i][
j]);
161 for(
unsigned j = 0;
j < the_values[
i].size(); ++
j ) {
164 fillerprod.
insert(to_isolate,
166 the_values[i][
j].
end());
std::array< std::vector< std::string >, kNPFTypes > _product_names
PFIsolationSumProducer(const edm::ParameterSet &)
static unsigned kNPFTypes
std::vector< std::unique_ptr< IsolationConeDefinitionBase > > IsoTypes
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
void insert(const H &h, I begin, I end)
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
virtual ~PFIsolationSumProducer()
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< CandView > _to_isolate
std::unordered_map< std::string, int > TypeMap
void produce(edm::Event &, const edm::EventSetup &) overridefinal
ParticleType translatePdgIdToType(int pdgid) const
Particle reconstructed by the particle flow algorithm.
const std::vector< edm::ParameterSet > & isoDefs
T get(const Candidate &c)
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types