22 #include <unordered_map> 43 typedef std::unordered_map<std::string,int>
TypeMap;
44 typedef std::vector<std::unique_ptr<IsolationConeDefinitionBase> >
IsoTypes;
74 consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcForIsolationCone"));
83 const std::vector<edm::ParameterSet>& isoDefs =
84 c.getParameterSetVector(
"isolationConeDefinitions");
85 for(
const auto& isodef : isoDefs ) {
88 const float coneSize = isodef.getParameter<
double>(
"coneSize");
90 std::sprintf(buf,
"DR%.2f",coneSize);
92 auto decimal = coneName.find(
'.');
93 if( decimal != std::string::npos ) coneName.erase(decimal,1);
98 theisolator->setConsumes(consumesCollector());
99 const auto thetype =
_typeMap.find(isotype);
102 <<
"Isolation type: " << isotype <<
" is not available in the " 103 <<
"list of allowed isolations!.";
107 std::string pname = isotype+dash+coneName+dash+theisolator->additionalCode();
109 produces<edm::ValueMap<float> >(
pname);
117 for(
const auto& isolator : isolators_for_type ) {
118 isolator->getEventSetupInfo(es);
125 typedef std::unique_ptr<edm::ValueMap<float> > product_type;
126 typedef std::vector<float> product_values;
134 std::array<std::vector<product_values>,
kNPFTypes> the_values;
138 the_values[i++].resize(isolators_for_type.size());
139 for(
const auto& isolator : isolators_for_type ) {
140 isolator->getEventInfo(ev);
145 for(
size_t c = 0;
c < to_isolate->
size(); ++
c ) {
146 auto cand_to_isolate = to_isolate->
ptrAt(
c);
147 std::array<std::vector<float>,
kNPFTypes> cand_values;
149 for(
const auto& isolators_for_type : _isolation_types ) {
150 cand_values[
k].resize(isolators_for_type.size());
151 for(
auto&
value : cand_values[k] )
value = 0.0;
154 for(
size_t ic = 0; ic < isolate_with->
size(); ++ic ) {
155 auto isocand = isolate_with->
ptrAt(ic);
158 const auto& isolations = _isolation_types[isotype];
159 for(
unsigned i = 0; i < isolations.size(); ++
i ) {
160 if( isolations[i]->isInIsolationCone(cand_to_isolate,isocand) ) {
161 double puppiWeight = 0.;
164 else puppiWeight = (*puppiValueMap)[isocand];
165 if (puppiWeight > 0.)cand_values[isotype][
i] += (isocand->pt())*puppiWeight;
171 for(
unsigned j = 0; j < cand_values[
i].size(); ++j ) {
172 the_values[
i][j].push_back(cand_values[i][j]);
178 for(
unsigned j = 0; j < the_values[
i].size(); ++j ) {
181 fillerprod.
insert(to_isolate,
182 the_values[i][j].
begin(),
183 the_values[i][j].
end());
195 iDesc.
setComment(
"PUPPI isolation sum producer");
198 iDesc.
add<
edm::InputTag>(
"srcForIsolationCone",
edm::InputTag(
"no default"))->setComment(
"collection for the isolation calculation: like particleFlow ");
199 iDesc.
add<
edm::InputTag>(
"puppiValueMap",
edm::InputTag(
"puppi"))->setComment(
"source for puppi, if left empty weight from packedCandidate is taken");
202 descIsoConeDefinitions.
add<
std::string>(
"isolationAlgo",
"no default");
203 descIsoConeDefinitions.
add<
double>(
"coneSize", 0.3);
204 descIsoConeDefinitions.
add<
std::string>(
"isolateAgainst",
"no default");
205 descIsoConeDefinitions.
add<std::vector<unsigned>>(
"miniAODVertexCodes", {2,3});
206 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeBarrel", 0.0);
207 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeEndcaps", 0.0);
208 descIsoConeDefinitions.
addOptional<
double>(
"VetoThreshold", 0.0);
209 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSize", 0.0);
210 descIsoConeDefinitions.
addOptional<
int>(
"vertexIndex",0);
216 isolationConeDefinitions.push_back(chargedHadrons);
217 isolationConeDefinitions.push_back(neutralHadrons);
218 isolationConeDefinitions.push_back(photons);
219 iDesc.
addVPSet(
"isolationConeDefinitions", descIsoConeDefinitions, isolationConeDefinitions);
220 iDesc.
add<
bool>(
"usePUPPINoLepton",
false);
222 descriptions.
add(
"CITKPFIsolationSumProducerForPUPPI", iDesc);
citk::PFIsolationSumProducerForPUPPI CITKPFIsolationSumProducerForPUPPI
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
void produce(edm::Event &, const edm::EventSetup &) final
#define DEFINE_FWK_MODULE(type)
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
void setComment(std::string const &value)
edm::View< reco::Candidate > CandView
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
ParameterDescriptionBase * add(U const &iLabel, T const &value)
PFIsolationSumProducerForPUPPI(const edm::ParameterSet &)
edm::EDGetTokenT< CandView > _to_isolate
~PFIsolationSumProducerForPUPPI() override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParticleType translatePdgIdToType(int pdgid) const
Particle reconstructed by the particle flow algorithm.
std::vector< std::unique_ptr< IsolationConeDefinitionBase > > IsoTypes
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types
T get(const Candidate &c)
static unsigned kNPFTypes