CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
VIDNestedWPBitmapProducer< T > Class Template Reference

#include <PhysicsTools/NanoAOD/plugins/VIDNestedWPBitmapProducer.cc>

Inheritance diagram for VIDNestedWPBitmapProducer< T >:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 VIDNestedWPBitmapProducer (const edm::ParameterSet &iConfig)
 
 ~VIDNestedWPBitmapProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 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 Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void initNCuts (unsigned int)
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

bool isInit_
 
unsigned int nBits
 
unsigned int nCuts
 
unsigned int nWP
 
std::vector< unsigned int > res_
 
edm::EDGetTokenT< edm::View< T > > src_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
 
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
 

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
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

template<typename T>
class VIDNestedWPBitmapProducer< T >

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 43 of file VIDNestedWPBitmapProducer.cc.

Constructor & Destructor Documentation

template<typename T >
VIDNestedWPBitmapProducer< T >::VIDNestedWPBitmapProducer ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 45 of file VIDNestedWPBitmapProducer.cc.

References edm::EDConsumerBase::consumes(), edm::ParameterSet::getParameter(), VIDNestedWPBitmapProducer< T >::nWP, VIDNestedWPBitmapProducer< T >::src_bitmaps_, VIDNestedWPBitmapProducer< T >::src_cutflows_, and AlCaHLTBitMon_QueryRunRegistry::string.

45  :
47  isInit_(false)
48  {
49  auto vwp = iConfig.getParameter<std::vector<std::string>>("WorkingPoints");
50  for (auto wp : vwp) {
53  }
54  nWP = src_bitmaps_.size();
55  produces<edm::ValueMap<int>>();
56  }
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< T > > src_
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
template<typename T >
VIDNestedWPBitmapProducer< T >::~VIDNestedWPBitmapProducer ( )
inlineoverride

Member Function Documentation

template<typename T >
void VIDNestedWPBitmapProducer< T >::beginStream ( edm::StreamID  )
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 62 of file VIDNestedWPBitmapProducer.cc.

References VIDNestedWPBitmapProducer< T >::produce().

62 {};
template<typename T >
void VIDNestedWPBitmapProducer< T >::endStream ( )
inlineoverrideprivatevirtual

Reimplemented from edm::stream::EDProducerBase.

Definition at line 64 of file VIDNestedWPBitmapProducer.cc.

64 {};
template<typename T >
void VIDNestedWPBitmapProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 155 of file VIDNestedWPBitmapProducer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by VIDNestedWPBitmapProducer< T >::~VIDNestedWPBitmapProducer().

155  {
157  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
158  desc.add<std::vector<std::string>>("WorkingPoints")->setComment("working points to be saved in the bitmask");
159  std::string modname;
160  if (typeid(T) == typeid(pat::Electron)) modname+="Ele";
161  else if (typeid(T) == typeid(pat::Photon)) modname+="Pho";
162  modname+="VIDNestedWPBitmapProducer";
163  descriptions.add(modname,desc);
164 }
Analysis-level Photon class.
Definition: Photon.h:47
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Analysis-level electron class.
Definition: Electron.h:52
void add(std::string const &label, ParameterSetDescription const &psetDescription)
long double T
template<typename T >
void VIDNestedWPBitmapProducer< T >::initNCuts ( unsigned int  n)
private

Definition at line 144 of file VIDNestedWPBitmapProducer.cc.

References Exception, VIDNestedWPBitmapProducer< T >::isInit_, gen::n, VIDNestedWPBitmapProducer< T >::nBits, VIDNestedWPBitmapProducer< T >::nCuts, VIDNestedWPBitmapProducer< T >::nWP, and VIDNestedWPBitmapProducer< T >::res_.

Referenced by VIDNestedWPBitmapProducer< T >::produce().

144  {
145  nCuts = n;
146  nBits = ceil(log2(nWP+1));
147  if (nBits*nCuts>sizeof(int)*8) throw cms::Exception("Configuration","Integer cannot contain the compressed VID bitmap information");
148  res_.resize(nCuts,0);
149  isInit_ = true;
150 }
std::vector< unsigned int > res_
template<typename T >
void VIDNestedWPBitmapProducer< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 98 of file VIDNestedWPBitmapProducer.cc.

References Exception, edm::helper::Filler< Map >::fill(), objects.autophobj::filler, edm::Event::getByToken(), mps_fire::i, VIDNestedWPBitmapProducer< T >::initNCuts(), edm::helper::Filler< Map >::insert(), VIDNestedWPBitmapProducer< T >::isInit_, gen::k, eostools::move(), VIDNestedWPBitmapProducer< T >::nBits, VIDNestedWPBitmapProducer< T >::nCuts, VIDNestedWPBitmapProducer< T >::nWP, NewMuonAssociatorByHits_cfi::obj, MillePedeFileConverter_cfg::out, edm::Event::put(), VIDNestedWPBitmapProducer< T >::res_, TrackRefitter_38T_cff::src, VIDNestedWPBitmapProducer< T >::src_, VIDNestedWPBitmapProducer< T >::src_bitmaps_, and VIDNestedWPBitmapProducer< T >::src_cutflows_.

Referenced by VIDNestedWPBitmapProducer< T >::beginStream().

99 {
100 
102  iEvent.getByToken(src_, src);
103  std::vector<edm::Handle<edm::ValueMap<unsigned int>>> src_bitmaps(nWP);
104  for (unsigned int i=0; i<nWP; i++) iEvent.getByToken(src_bitmaps_[i], src_bitmaps[i]);
105  std::vector<edm::Handle<edm::ValueMap<vid::CutFlowResult>>> src_cutflows(nWP);
106  for (unsigned int i=0; i<nWP; i++) iEvent.getByToken(src_cutflows_[i], src_cutflows[i]);
107 
108  std::vector<unsigned int> res;
109 
110  auto npho = src->size();
111  for (unsigned int i=0; i<npho; i++){
112  auto obj = src->ptrAt(i);
113  for (unsigned int j=0; j<nWP; j++){
114  auto cutflow = (*(src_cutflows[j]))[obj];
115  if (!isInit_) initNCuts(cutflow.cutFlowSize());
116  if (cutflow.cutFlowSize()!=nCuts) throw cms::Exception("Configuration","Trying to compress VID bitmaps for cutflows of different size");
117  auto bitmap = (*(src_bitmaps[j]))[obj];
118  for (unsigned int k=0; k<nCuts; k++){
119  if (j==0) res_[k] = 0;
120  if (bitmap>>k & 1) {
121  if (res_[k]!=j) throw cms::Exception("Configuration","Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
122  res_[k]++;
123  }
124  }
125  }
126 
127  int out = 0;
128  for (unsigned int k=0; k<nCuts; k++) out |= (res_[k] << (nBits*k));
129  res.push_back(out);
130  }
131 
132 
133  std::unique_ptr<edm::ValueMap<int>> resV(new edm::ValueMap<int>());
135  filler.insert(src,res.begin(),res.end());
136  filler.fill();
137 
138  iEvent.put(std::move(resV));
139 
140 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:127
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
Definition: Electron.h:4
std::vector< unsigned int > res_
int k[5][pyjets_maxn]
edm::EDGetTokenT< edm::View< T > > src_
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<typename T >
bool VIDNestedWPBitmapProducer< T >::isInit_
private
template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nBits
private
template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nCuts
private
template<typename T >
unsigned int VIDNestedWPBitmapProducer< T >::nWP
private
template<typename T >
std::vector<unsigned int> VIDNestedWPBitmapProducer< T >::res_
private
template<typename T >
edm::EDGetTokenT<edm::View<T> > VIDNestedWPBitmapProducer< T >::src_
private
template<typename T >
std::vector<edm::EDGetTokenT<edm::ValueMap<unsigned int> > > VIDNestedWPBitmapProducer< T >::src_bitmaps_
private
template<typename T >
std::vector<edm::EDGetTokenT<edm::ValueMap<vid::CutFlowResult> > > VIDNestedWPBitmapProducer< T >::src_cutflows_
private