CMS 3D CMS Logo

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

Public Member Functions

virtual void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) overridefinal
 
 PFIsolationSumProducerForPUPPI (const edm::ParameterSet &)
 
virtual void produce (edm::Event &, const edm::EventSetup &) overridefinal
 
virtual ~PFIsolationSumProducerForPUPPI ()
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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 useValueMapForPUPPI = true
 

Static Private Attributes

static unsigned kNPFTypes = 8
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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 60 of file CITKPFIsolationSumProducerForPUPPI.cc.

60  :
61  _typeMap( { {"h+",1},
62  {"h0",5},
63  {"gamma",4},
64  {"electron",2},
65  {"muon",3},
66  {"HFh",6},
67  {"HFgamma",7} } ){
virtual citk::PFIsolationSumProducerForPUPPI::~PFIsolationSumProducerForPUPPI ( )
inlinevirtual

Definition at line 31 of file CITKPFIsolationSumProducerForPUPPI.cc.

31 {}

Member Function Documentation

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

Reimplemented from edm::stream::EDProducerBase.

Definition at line 108 of file CITKPFIsolationSumProducerForPUPPI.cc.

References _isolation_types.

109  {
110  for( const auto& isolators_for_type : _isolation_types ) {
111  for( const auto& isolator : isolators_for_type ) {
112  isolator->getEventSetupInfo(es);
113  }
114  }
115  }
void citk::PFIsolationSumProducerForPUPPI::produce ( edm::Event ev,
const edm::EventSetup es 
)
finaloverridevirtual

Implements edm::stream::EDProducerBase.

Definition at line 118 of file CITKPFIsolationSumProducerForPUPPI.cc.

References _isolate_with, _isolation_types, _product_names, _to_isolate, begin, EnergyCorrector::c, end, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), i, edm::helper::Filler< Map >::insert(), j, relval_2017::k, kNPFTypes, puppiValueMap, puppiValueMapToken_, edm::Event::put(), reco::PFCandidate::translatePdgIdToType(), useValueMapForPUPPI, and relativeConstraints::value.

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

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.

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::useValueMapForPUPPI = true
private

Definition at line 51 of file CITKPFIsolationSumProducerForPUPPI.cc.

Referenced by produce().