1 #ifndef PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H 2 #define PhysicsTools_IsolationAlgos_CITKIsolationSumProducer_H 26 #include <unordered_map> 49 typedef std::unordered_map<std::string, int>
TypeMap;
50 typedef std::vector<std::unique_ptr<IsolationConeDefinitionBase>>
IsoTypes;
66 : _typeMap({{
"h+", 1}, {
"h0", 5}, {
"gamma", 4}, {
"electron", 2}, {
"muon", 3}, {
"HFh", 6}, {
"HFgamma", 7}}) {
67 _to_isolate = consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcToIsolate"));
68 _isolate_with = consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcForIsolationCone"));
69 const std::vector<edm::ParameterSet>& isoDefs =
c.getParameterSetVector(
"isolationConeDefinitions");
70 for (
const auto& isodef : isoDefs) {
72 const float coneSize = isodef.getParameter<
double>(
"coneSize");
76 auto decimal = coneName.find(
'.');
77 if (decimal != std::string::npos)
78 coneName.erase(decimal, 1);
81 theisolator->setConsumes(consumesCollector());
82 const auto thetype = _typeMap.find(isotype);
83 if (thetype == _typeMap.end()) {
84 throw cms::Exception(
"InvalidIsolationType") <<
"Isolation type: " << isotype <<
" is not available in the " 85 <<
"list of allowed isolations!.";
88 std::string pname = isotype + dash + coneName + dash + theisolator->additionalCode();
89 _product_names[thetype->second].emplace_back(
pname);
90 produces<edm::ValueMap<float>>(
pname);
91 _isolation_types[thetype->second].emplace_back(
std::move(theisolator));
97 for (
const auto& isolator : isolators_for_type) {
98 isolator->getEventSetupInfo(es);
104 typedef std::unique_ptr<edm::ValueMap<float>> product_type;
105 typedef std::vector<float> product_values;
111 std::array<std::vector<product_values>,
kNPFTypes> the_values;
115 the_values[
i++].resize(isolators_for_type.size());
116 for (
const auto& isolator : isolators_for_type) {
117 isolator->getEventInfo(
ev);
122 for (
size_t c = 0;
c < to_isolate->
size(); ++
c) {
123 auto cand_to_isolate = to_isolate->
ptrAt(
c);
124 std::array<std::vector<float>,
kNPFTypes> cand_values;
127 cand_values[
k].resize(isolators_for_type.size());
128 for (
auto&
value : cand_values[
k])
132 for (
size_t ic = 0; ic < isolate_with->
size(); ++ic) {
133 auto isocand = isolate_with->
ptrAt(ic);
134 auto isotype =
helper.translatePdgIdToType(isocand->pdgId());
136 for (
unsigned i = 0;
i < isolations.size(); ++
i) {
137 if (isolations[
i]->isInIsolationCone(cand_to_isolate, isocand)) {
138 cand_values[isotype][
i] += isocand->pt();
144 for (
unsigned j = 0;
j < cand_values[
i].size(); ++
j) {
145 the_values[
i][
j].push_back(cand_values[
i][
j]);
151 for (
unsigned j = 0;
j < the_values[
i].size(); ++
j) {
154 fillerprod.
insert(to_isolate, the_values[
i][
j].begin(), the_values[
i][
j].end());
167 ->setComment(
"calculate isolation for this collection");
169 ->setComment(
"collection for the isolation calculation: like particleFlow ");
172 descIsoConeDefinitions.
add<
std::string>(
"isolationAlgo",
"no default");
173 descIsoConeDefinitions.
add<
double>(
"coneSize", 0.3);
174 descIsoConeDefinitions.
add<
std::string>(
"isolateAgainst",
"no default");
175 descIsoConeDefinitions.
add<std::vector<unsigned>>(
"miniAODVertexCodes", {2, 3});
176 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeBarrel", 0.0);
177 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeEndcaps", 0.0);
178 descIsoConeDefinitions.
addOptional<
int>(
"vertexIndex", 0);
180 ->setComment(
"map for footprint removal that is used for photons");
189 descriptions.
add(
"CITKPFIsolationSumProducer", iDesc);
PFIsolationSumProducer(const edm::ParameterSet &)
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
Ptr< value_type > ptrAt(size_type i) const
std::vector< std::unique_ptr< IsolationConeDefinitionBase > > IsoTypes
citk::PFIsolationSumProducer CITKPFIsolationSumProducer
void insert(const H &h, I begin, I end)
std::unordered_map< std::string, int > TypeMap
std::array< IsoTypes, kNPFTypes > _isolation_types
void setComment(std::string const &value)
edm::View< reco::Candidate > CandView
void produce(edm::Event &, const edm::EventSetup &) final
edm::EDGetTokenT< CandView > _to_isolate
#define DEFINE_FWK_MODULE(type)
std::array< std::vector< std::string >, kNPFTypes > _product_names
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
TracksUtilities< TrackerTraits > helper
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static constexpr unsigned kNPFTypes
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Particle reconstructed by the particle flow algorithm.
edm::EDGetTokenT< CandView > _isolate_with