CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes | Static Private Attributes
citk::PFIsolationSumProducer Class Reference
Inheritance diagram for citk::PFIsolationSumProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

void beginLuminosityBlock (const edm::LuminosityBlock &, const edm::EventSetup &) override final
 
 PFIsolationSumProducer (const edm::ParameterSet &)
 
void produce (edm::Event &, const edm::EventSetup &) override final
 
virtual ~PFIsolationSumProducer ()
 
- 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)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef edm::View< reco::CandidateCandView
 
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
 

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, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
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
 
- 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 32 of file CITKPFIsolationSumProducer.cc.

Member Typedef Documentation

Definition at line 51 of file CITKPFIsolationSumProducer.cc.

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

Definition at line 50 of file CITKPFIsolationSumProducer.cc.

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

Definition at line 49 of file CITKPFIsolationSumProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 65 of file CITKPFIsolationSumProducer.cc.

References _isolate_with, _isolation_types, _product_names, _to_isolate, _typeMap, beginLuminosityBlock(), EnergyCorrector::c, highPtTrackIsolations_cff::coneSize, edm::EDConsumerBase::consumesCollector(), Exception, reco::get(), dataset::name, BPhysicsValidation_cfi::pname, and AlCaHLTBitMon_QueryRunRegistry::string.

65  :
66  _typeMap( { {"h+",1},
67  {"h0",5},
68  {"gamma",4},
69  {"electron",2},
70  {"muon",3},
71  {"HFh",6},
72  {"HFgamma",7} } ){
73  _to_isolate =
74  consumes<CandView>(c.getParameter<edm::InputTag>("srcToIsolate"));
75  _isolate_with =
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 ) {
80  const std::string& name =
81  isodef.getParameter<std::string>("isolationAlgo");
82  const float coneSize = isodef.getParameter<double>("coneSize");
83  char buf[50];
84  sprintf(buf,"DR%.2f",coneSize);
85  std::string coneName(buf);
86  auto decimal = coneName.find('.');
87  if( decimal != std::string::npos ) coneName.erase(decimal,1);
88  const std::string& isotype =
89  isodef.getParameter<std::string>("isolateAgainst");
90  IsolationConeDefinitionBase* theisolator =
91  CITKIsolationConeDefinitionFactory::get()->create(name,isodef);
92  theisolator->setConsumes(consumesCollector());
93  const auto thetype = _typeMap.find(isotype);
94  if( thetype == _typeMap.end() ) {
95  throw cms::Exception("InvalidIsolationType")
96  << "Isolation type: " << isotype << " is not available in the "
97  << "list of allowed isolations!.";
98  }
99  _isolation_types[thetype->second].emplace_back(theisolator);
100  const std::string dash("-");
101  std::string pname = isotype+dash+coneName+dash+theisolator->additionalCode();
102  _product_names[thetype->second].emplace_back(pname);
103  produces<edm::ValueMap<float> >(pname);
104  }
105  }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
std::array< std::vector< std::string >, kNPFTypes > _product_names
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< CandView > _to_isolate
T get(const Candidate &c)
Definition: component.h:55
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types
virtual citk::PFIsolationSumProducer::~PFIsolationSumProducer ( )
inlinevirtual

Definition at line 37 of file CITKPFIsolationSumProducer.cc.

37 {}

Member Function Documentation

void citk::PFIsolationSumProducer::beginLuminosityBlock ( const edm::LuminosityBlock ,
const edm::EventSetup es 
)
finaloverride

Definition at line 108 of file CITKPFIsolationSumProducer.cc.

References _isolation_types, and produce().

Referenced by PFIsolationSumProducer().

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  }
std::array< IsoTypes, kNPFTypes > _isolation_types
void citk::PFIsolationSumProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 178 of file CITKPFIsolationSumProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addOptional(), edm::ParameterSetDescription::addVPSet(), egmElectronIsolationPUPPI_cff::isolationConeDefinitions, jetCleaner_cfi::photons, edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

178  {
180  iDesc.setComment("isolation sum producer");
181 
182  iDesc.add<edm::InputTag>("srcToIsolate", edm::InputTag("no default"))->setComment("calculate isolation for this collection");
183  iDesc.add<edm::InputTag>("srcForIsolationCone", edm::InputTag("no default"))->setComment("collection for the isolation calculation: like particleFlow ");
184 
185  edm::ParameterSetDescription descIsoConeDefinitions;
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);
193  descIsoConeDefinitions.addOptional<edm::InputTag>("particleBasedIsolation",edm::InputTag("no default"))->setComment("map for footprint removal that is used for photons");
194 
195 
196  std::vector<edm::ParameterSet> isolationConeDefinitions;
197  edm::ParameterSet chargedHadrons, neutralHadrons,photons;
198  isolationConeDefinitions.push_back(chargedHadrons);
199  isolationConeDefinitions.push_back(neutralHadrons);
200  isolationConeDefinitions.push_back(photons);
201  iDesc.addVPSet("isolationConeDefinitions", descIsoConeDefinitions, isolationConeDefinitions);
202 
203  descriptions.add("CITKPFIsolationSumProducer", iDesc);
204  }
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::PFIsolationSumProducer::produce ( edm::Event ev,
const edm::EventSetup es 
)
finaloverride

Definition at line 118 of file CITKPFIsolationSumProducer.cc.

References _isolate_with, _isolation_types, _product_names, _to_isolate, begin, EnergyCorrector::c, end, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), mps_fire::i, edm::helper::Filler< Map >::insert(), gen::k, kNPFTypes, eostools::move(), edm::View< T >::ptrAt(), edm::Event::put(), edm::View< T >::size(), and reco::PFCandidate::translatePdgIdToType().

Referenced by beginLuminosityBlock().

118  {
119  typedef std::unique_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);
125  // the list of value vectors indexed as "to_isolate"
126  std::array<std::vector<product_values>,kNPFTypes> the_values;
127  // get extra event info and setup value cache
128  unsigned i = 0;
129  for( const auto& isolators_for_type : _isolation_types ) {
130  the_values[i++].resize(isolators_for_type.size());
131  for( const auto& isolator : isolators_for_type ) {
132  isolator->getEventInfo(ev);
133  }
134  }
135  reco::PFCandidate helper; // to translate pdg id to type
136  // loop over the candidates we are isolating and fill the values
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;
140  unsigned k = 0;
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;
144  ++k;
145  }
146  for( size_t ic = 0; ic < isolate_with->size(); ++ic ) {
147  auto isocand = isolate_with->ptrAt(ic);
148  auto isotype = helper.translatePdgIdToType(isocand->pdgId());
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();
153  }
154  }
155  }
156  // add this candidate to isolation value list
157  for( unsigned i = 0; i < kNPFTypes; ++i ) {
158  for( unsigned j = 0; j < cand_values[i].size(); ++j ) {
159  the_values[i][j].push_back(cand_values[i][j]);
160  }
161  }
162  }
163  // fill and put all products
164  for( unsigned i = 0; i < kNPFTypes; ++ i ) {
165  for( unsigned j = 0; j < the_values[i].size(); ++j ) {
166  product_type the_product( new edm::ValueMap<float> );
167  edm::ValueMap<float>::Filler fillerprod(*the_product);
168  fillerprod.insert(to_isolate,
169  the_values[i][j].begin(),
170  the_values[i][j].end());
171  fillerprod.fill();
172  ev.put(std::move(the_product),_product_names[i][j]);
173  }
174  }
175  }
std::array< std::vector< std::string >, kNPFTypes > _product_names
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
Definition: helper.py:1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
Ptr< value_type > ptrAt(size_type i) const
size_type size() const
edm::EDGetTokenT< CandView > _to_isolate
#define end
Definition: vmac.h:37
Definition: value.py:1
int k[5][pyjets_maxn]
ParticleType translatePdgIdToType(int pdgid) const
Definition: PFCandidate.cc:229
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
#define begin
Definition: vmac.h:30
def move(src, dest)
Definition: eostools.py:510
edm::EDGetTokenT< CandView > _isolate_with
std::array< IsoTypes, kNPFTypes > _isolation_types

Member Data Documentation

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

Definition at line 53 of file CITKPFIsolationSumProducer.cc.

Referenced by PFIsolationSumProducer(), and produce().

std::array<IsoTypes,kNPFTypes> citk::PFIsolationSumProducer::_isolation_types
private
std::array<std::vector<std::string>,kNPFTypes> citk::PFIsolationSumProducer::_product_names
private

Definition at line 56 of file CITKPFIsolationSumProducer.cc.

Referenced by PFIsolationSumProducer(), and produce().

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

Definition at line 53 of file CITKPFIsolationSumProducer.cc.

Referenced by PFIsolationSumProducer(), and produce().

const TypeMap citk::PFIsolationSumProducer::_typeMap
private

Definition at line 52 of file CITKPFIsolationSumProducer.cc.

Referenced by PFIsolationSumProducer().

unsigned citk::PFIsolationSumProducer::kNPFTypes = 8
staticprivate

Definition at line 48 of file CITKPFIsolationSumProducer.cc.

Referenced by produce().