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!.";
97 _isolation_types[thetype->second].emplace_back(theisolator);
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(
size_t c = 0;
c < to_isolate->size(); ++
c ) {
136 auto cand_to_isolate = to_isolate->ptrAt(
c);
137 std::array<std::vector<float>,
kNPFTypes> cand_values;
139 for(
const auto& isolators_for_type : _isolation_types ) {
140 cand_values[
k].resize(isolators_for_type.size());
141 for(
auto&
value : cand_values[k] )
value = 0.0;
144 for(
size_t ic = 0; ic < isolate_with->size(); ++ic ) {
145 auto isocand = isolate_with->ptrAt(ic);
147 const auto& isolations = _isolation_types[isotype];
148 for(
unsigned i = 0; i < isolations.size(); ++
i ) {
149 if( isolations[i]->isInIsolationCone(cand_to_isolate,isocand) ) {
150 cand_values[isotype][
i] += isocand->pt();
156 for(
unsigned j = 0;
j < cand_values[
i].size(); ++
j ) {
157 the_values[
i][
j].push_back(cand_values[i][
j]);
163 for(
unsigned j = 0;
j < the_values[
i].size(); ++
j ) {
166 fillerprod.
insert(to_isolate,
168 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)
const std::vector< edm::ParameterSet > & isoDefs
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.
T get(const Candidate &c)
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types