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;
76 consumes<CandView>(
c.getParameter<
edm::InputTag>(
"srcForIsolationCone"));
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 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);
96 <<
"Isolation type: " << isotype <<
" is not available in the " 97 <<
"list of allowed isolations!.";
101 std::string pname = isotype+dash+coneName+dash+theisolator->additionalCode();
103 produces<edm::ValueMap<float> >(
pname);
111 for(
const auto& isolator : isolators_for_type ) {
112 isolator->getEventSetupInfo(es);
119 typedef std::unique_ptr<edm::ValueMap<float> > product_type;
120 typedef std::vector<float> product_values;
126 std::array<std::vector<product_values>,
kNPFTypes> the_values;
130 the_values[i++].resize(isolators_for_type.size());
131 for(
const auto& isolator : isolators_for_type ) {
132 isolator->getEventInfo(ev);
137 for(
size_t c = 0;
c < to_isolate->
size(); ++
c ) {
138 auto cand_to_isolate = to_isolate->
ptrAt(
c);
139 std::array<std::vector<float>,
kNPFTypes> cand_values;
141 for(
const auto& isolators_for_type : _isolation_types ) {
142 cand_values[
k].resize(isolators_for_type.size());
143 for(
auto&
value : cand_values[k] )
value = 0.0;
146 for(
size_t ic = 0; ic < isolate_with->
size(); ++ic ) {
147 auto isocand = isolate_with->
ptrAt(ic);
149 const auto& isolations = _isolation_types[isotype];
150 for(
unsigned i = 0; i < isolations.size(); ++
i ) {
151 if( isolations[i]->isInIsolationCone(cand_to_isolate,isocand) ) {
152 cand_values[isotype][
i] += isocand->pt();
158 for(
unsigned j = 0; j < cand_values[
i].size(); ++j ) {
159 the_values[
i][j].push_back(cand_values[i][j]);
165 for(
unsigned j = 0; j < the_values[
i].size(); ++j ) {
168 fillerprod.
insert(to_isolate,
169 the_values[i][j].
begin(),
170 the_values[i][j].
end());
183 iDesc.
add<
edm::InputTag>(
"srcForIsolationCone",
edm::InputTag(
"no default"))->setComment(
"collection for the isolation calculation: like particleFlow ");
186 descIsoConeDefinitions.
add<
std::string>(
"isolationAlgo",
"no default");
187 descIsoConeDefinitions.
add<
double>(
"coneSize", 0.3);
188 descIsoConeDefinitions.
add<
std::string>(
"isolateAgainst",
"no default");
189 descIsoConeDefinitions.
add<std::vector<unsigned>>(
"miniAODVertexCodes", {2,3});
190 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeBarrel", 0.0);
191 descIsoConeDefinitions.
addOptional<
double>(
"VetoConeSizeEndcaps", 0.0);
192 descIsoConeDefinitions.
addOptional<
int>(
"vertexIndex",0);
198 isolationConeDefinitions.push_back(chargedHadrons);
199 isolationConeDefinitions.push_back(neutralHadrons);
200 isolationConeDefinitions.push_back(photons);
201 iDesc.
addVPSet(
"isolationConeDefinitions", descIsoConeDefinitions, isolationConeDefinitions);
203 descriptions.
add(
"CITKPFIsolationSumProducer", iDesc);
std::array< std::vector< std::string >, kNPFTypes > _product_names
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
static unsigned kNPFTypes
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
~PFIsolationSumProducer() override
std::vector< std::unique_ptr< IsolationConeDefinitionBase > > IsoTypes
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
#define DEFINE_FWK_MODULE(type)
citk::PFIsolationSumProducer CITKPFIsolationSumProducer
void insert(const H &h, I begin, I end)
void setComment(std::string const &value)
edm::View< reco::Candidate > CandView
void produce(edm::Event &, const edm::EventSetup &) final
edm::EDGetTokenT< CandView > _to_isolate
std::unordered_map< std::string, int > TypeMap
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ParticleType translatePdgIdToType(int pdgid) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Particle reconstructed by the particle flow algorithm.
T get(const Candidate &c)
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types