CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
citk::PFIsolationSumProducerForPUPPI Class Reference
Inheritance diagram for citk::PFIsolationSumProducerForPUPPI:
edm::stream::EDProducer<>

Public Member Functions

void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) final
 
 PFIsolationSumProducerForPUPPI (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) final
 
 ~PFIsolationSumProducerForPUPPI () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Types

typedef edm::View
< reco::Candidate
CandView
 
typedef std::vector
< std::unique_ptr
< IsolationConeDefinitionBase > > 
IsoTypes
 
typedef std::unordered_map
< std::string, int > 
TypeMap
 

Private Attributes

edm::EDGetTokenT< CandView_isolate_with
 
std::array< IsoTypes, kNPFTypes_isolation_types
 
std::array< std::vector
< std::string >, kNPFTypes
_product_names
 
edm::EDGetTokenT< CandView_to_isolate
 
const TypeMap _typeMap
 
edm::Handle< edm::ValueMap
< float > > 
puppiValueMap
 
edm::EDGetTokenT
< edm::ValueMap< float > > 
puppiValueMapToken_
 
bool usePUPPINoLepton
 
bool useValueMapForPUPPI = true
 

Static Private Attributes

static constexpr unsigned kNPFTypes = 8
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T...>
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T...>
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 26 of file CITKPFIsolationSumProducerForPUPPI.cc.

Member Typedef Documentation

Definition at line 43 of file CITKPFIsolationSumProducerForPUPPI.cc.

typedef std::vector<std::unique_ptr<IsolationConeDefinitionBase> > citk::PFIsolationSumProducerForPUPPI::IsoTypes
private

Definition at line 42 of file CITKPFIsolationSumProducerForPUPPI.cc.

typedef std::unordered_map<std::string, int> citk::PFIsolationSumProducerForPUPPI::TypeMap
private

Definition at line 41 of file CITKPFIsolationSumProducerForPUPPI.cc.

Constructor & Destructor Documentation

citk::PFIsolationSumProducerForPUPPI::PFIsolationSumProducerForPUPPI ( const edm::ParameterSet c)

Definition at line 62 of file CITKPFIsolationSumProducerForPUPPI.cc.

63  : _typeMap({{"h+", 1}, {"h0", 5}, {"gamma", 4}, {"electron", 2}, {"muon", 3}, {"HFh", 6}, {"HFgamma", 7}}) {
citk::PFIsolationSumProducerForPUPPI::~PFIsolationSumProducerForPUPPI ( )
inlineoverride

Definition at line 30 of file CITKPFIsolationSumProducerForPUPPI.cc.

30 {}

Member Function Documentation

void citk::PFIsolationSumProducerForPUPPI::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup es 
)
final

Definition at line 100 of file CITKPFIsolationSumProducerForPUPPI.cc.

References _isolation_types.

100  {
101  for (const auto& isolators_for_type : _isolation_types) {
102  for (const auto& isolator : isolators_for_type) {
103  isolator->getEventSetupInfo(es);
104  }
105  }
106  }
void citk::PFIsolationSumProducerForPUPPI::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 184 of file CITKPFIsolationSumProducerForPUPPI.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSetDescription::addVPSet(), HLT_FULL_cff::InputTag, interactiveExample::photons, edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

184  {
186  iDesc.setComment("PUPPI isolation sum producer");
187 
188  iDesc.add<edm::InputTag>("srcToIsolate", edm::InputTag("no default"))
189  ->setComment("calculate isolation for this collection");
190  iDesc.add<edm::InputTag>("srcForIsolationCone", edm::InputTag("no default"))
191  ->setComment("collection for the isolation calculation: like particleFlow ");
192  iDesc.add<edm::InputTag>("puppiValueMap", edm::InputTag("puppi"))
193  ->setComment("source for puppi, if left empty weight from packedCandidate is taken");
194 
195  edm::ParameterSetDescription descIsoConeDefinitions;
196  descIsoConeDefinitions.add<std::string>("isolationAlgo", "no default");
197  descIsoConeDefinitions.add<double>("coneSize", 0.3);
198  descIsoConeDefinitions.add<std::string>("isolateAgainst", "no default");
199  descIsoConeDefinitions.add<std::vector<unsigned>>("miniAODVertexCodes", {2, 3});
200  descIsoConeDefinitions.addOptional<double>("VetoConeSizeBarrel", 0.0);
201  descIsoConeDefinitions.addOptional<double>("VetoConeSizeEndcaps", 0.0);
202  descIsoConeDefinitions.addOptional<double>("VetoThreshold", 0.0);
203  descIsoConeDefinitions.addOptional<double>("VetoConeSize", 0.0);
204  descIsoConeDefinitions.addOptional<int>("vertexIndex", 0);
205  descIsoConeDefinitions.addOptional<edm::InputTag>("particleBasedIsolation", edm::InputTag("no default"))
206  ->setComment("map for footprint removal that is used for photons");
207 
208  std::vector<edm::ParameterSet> isolationConeDefinitions;
209  edm::ParameterSet chargedHadrons, neutralHadrons, photons;
210  isolationConeDefinitions.push_back(chargedHadrons);
211  isolationConeDefinitions.push_back(neutralHadrons);
212  isolationConeDefinitions.push_back(photons);
213  iDesc.addVPSet("isolationConeDefinitions", descIsoConeDefinitions, isolationConeDefinitions);
214  iDesc.add<bool>("usePUPPINoLepton", false);
215 
216  descriptions.add("CITKPFIsolationSumProducerForPUPPI", iDesc);
217  }
void setComment(std::string const &value)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void citk::PFIsolationSumProducerForPUPPI::produce ( edm::Event ev,
const edm::EventSetup es 
)
final

Definition at line 108 of file CITKPFIsolationSumProducerForPUPPI.cc.

References _isolate_with, _isolation_types, _product_names, _to_isolate, SplitLinear::begin, c, dataset::end, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), mps_fire::i, edm::helper::Filler< Map >::insert(), edm::Ptr< T >::isNull(), dqmiolumiharvest::j, isotrackApplyRegressor::k, kNPFTypes, eostools::move(), puppiValueMap, puppiValueMapToken_, edm::Event::put(), reco::PFCandidate::translatePdgIdToType(), usePUPPINoLepton, useValueMapForPUPPI, and relativeConstraints::value.

108  {
109  typedef std::unique_ptr<edm::ValueMap<float>> product_type;
110  typedef std::vector<float> product_values;
111  edm::Handle<CandView> to_isolate;
112  edm::Handle<CandView> isolate_with;
113  ev.getByToken(_to_isolate, to_isolate);
114  ev.getByToken(_isolate_with, isolate_with);
117 
118  // the list of value vectors indexed as "to_isolate"
119  std::array<std::vector<product_values>, kNPFTypes> the_values;
120  // get extra event info and setup value cache
121  unsigned i = 0;
122  for (const auto& isolators_for_type : _isolation_types) {
123  the_values[i++].resize(isolators_for_type.size());
124  for (const auto& isolator : isolators_for_type) {
125  isolator->getEventInfo(ev);
126  }
127  }
128  reco::PFCandidate helper; // to translate pdg id to type
129  // loop over the candidates we are isolating and fill the values
130  for (size_t c = 0; c < to_isolate->size(); ++c) {
131  auto cand_to_isolate = to_isolate->ptrAt(c);
132  std::array<std::vector<float>, kNPFTypes> cand_values;
133  unsigned k = 0;
134  for (const auto& isolators_for_type : _isolation_types) {
135  cand_values[k].resize(isolators_for_type.size());
136  for (auto& value : cand_values[k])
137  value = 0.0;
138  ++k;
139  }
140  for (size_t ic = 0; ic < isolate_with->size(); ++ic) {
141  auto isocand = isolate_with->ptrAt(ic);
142  edm::Ptr<pat::PackedCandidate> aspackedCandidate;
143  auto isotype = helper.translatePdgIdToType(isocand->pdgId());
144  const auto& isolations = _isolation_types[isotype];
145  for (unsigned i = 0; i < isolations.size(); ++i) {
146  if (isolations[i]->isInIsolationCone(cand_to_isolate, isocand)) {
147  double puppiWeight = 0.;
148  if (!useValueMapForPUPPI && aspackedCandidate.isNull())
149  aspackedCandidate = edm::Ptr<pat::PackedCandidate>(isocand);
151  puppiWeight = aspackedCandidate->puppiWeight(); // if miniAOD, take puppiWeight directly from the object
153  puppiWeight =
154  aspackedCandidate->puppiWeightNoLep(); // if miniAOD, take puppiWeightNoLep directly from the object
155  else
156  puppiWeight = (*puppiValueMap)[isocand]; // if AOD, take puppiWeight from the valueMap
157  if (puppiWeight > 0.)
158  cand_values[isotype][i] +=
159  (isocand->pt()) *
160  puppiWeight; // this is basically the main change to Lindsey's code: scale pt with puppiWeight for candidates with puppiWeight > 0.
161  }
162  }
163  }
164  // add this candidate to isolation value list
165  for (unsigned i = 0; i < kNPFTypes; ++i) {
166  for (unsigned j = 0; j < cand_values[i].size(); ++j) {
167  the_values[i][j].push_back(cand_values[i][j]);
168  }
169  }
170  }
171  // fill and put all products
172  for (unsigned i = 0; i < kNPFTypes; ++i) {
173  for (unsigned j = 0; j < the_values[i].size(); ++j) {
174  product_type the_product(new edm::ValueMap<float>);
175  edm::ValueMap<float>::Filler fillerprod(*the_product);
176  fillerprod.insert(to_isolate, the_values[i][j].begin(), the_values[i][j].end());
177  fillerprod.fill();
178  ev.put(std::move(the_product), _product_names[i][j]);
179  }
180  }
181  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
edm::Handle< edm::ValueMap< float > > puppiValueMap
std::array< std::vector< std::string >, kNPFTypes > _product_names
edm::EDGetTokenT< edm::ValueMap< float > > puppiValueMapToken_
def move
Definition: eostools.py:511
bool isNull() const
Checks for null.
Definition: Ptr.h:142
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:231
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
string end
Definition: dataset.py:937

Member Data Documentation

edm::EDGetTokenT<CandView> citk::PFIsolationSumProducerForPUPPI::_isolate_with
private

Definition at line 45 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

std::array<IsoTypes, kNPFTypes> citk::PFIsolationSumProducerForPUPPI::_isolation_types
private

Definition at line 49 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by beginLuminosityBlock(), and produce().

std::array<std::vector<std::string>, kNPFTypes> citk::PFIsolationSumProducerForPUPPI::_product_names
private

Definition at line 50 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

edm::EDGetTokenT<CandView> citk::PFIsolationSumProducerForPUPPI::_to_isolate
private

Definition at line 45 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

const TypeMap citk::PFIsolationSumProducerForPUPPI::_typeMap
private

Definition at line 44 of file CITKPFIsolationSumProducerForPUPPI.cc.

constexpr unsigned citk::PFIsolationSumProducerForPUPPI::kNPFTypes = 8
staticprivate

Definition at line 40 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

edm::Handle<edm::ValueMap<float> > citk::PFIsolationSumProducerForPUPPI::puppiValueMap
private

Definition at line 47 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

edm::EDGetTokenT<edm::ValueMap<float> > citk::PFIsolationSumProducerForPUPPI::puppiValueMapToken_
private

Definition at line 46 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

bool citk::PFIsolationSumProducerForPUPPI::usePUPPINoLepton
private
Initial value:
=
false

Definition at line 52 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().

bool citk::PFIsolationSumProducerForPUPPI::useValueMapForPUPPI = true
private

Definition at line 51 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().