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<>

Public Member Functions

 VIDNestedWPBitmapProducer (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

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

Private Attributes

bool isInit_
 
unsigned int nBits
 
unsigned int nCuts = 0
 
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
 

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 47 of file VIDNestedWPBitmapProducer.cc.

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

47  :
48  src_(consumes<edm::View<T>>(iConfig.getParameter<edm::InputTag>("src"))),
49  isInit_(false)
50  {
51  auto const& vwp = iConfig.getParameter<std::vector<std::string>>("WorkingPoints");
52  for (auto const& wp : vwp) {
53  src_bitmaps_.push_back(consumes<edm::ValueMap<unsigned int> >(edm::InputTag(wp+std::string("Bitmap"))));
55  }
56  nWP = src_bitmaps_.size();
57  produces<edm::ValueMap<int>>();
58  }
T getParameter(std::string const &) const
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
edm::EDGetTokenT< edm::View< T > > src_
std::vector< edm::EDGetTokenT< edm::ValueMap< unsigned int > > > src_bitmaps_

Member Function Documentation

template<typename T >
void VIDNestedWPBitmapProducer< T >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 139 of file VIDNestedWPBitmapProducer.cc.

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

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

139  {
141  desc.add<edm::InputTag>("src")->setComment("input physics object collection");
142  desc.add<std::vector<std::string>>("WorkingPoints")->setComment("working points to be saved in the bitmask");
143  std::string modname;
144  if (typeid(T) == typeid(pat::Electron)) modname+="Ele";
145  else if (typeid(T) == typeid(pat::Photon)) modname+="Pho";
146  modname+="VIDNestedWPBitmapProducer";
147  descriptions.add(modname,desc);
148 }
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 128 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().

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

Definition at line 85 of file VIDNestedWPBitmapProducer.cc.

References Exception, objects.autophobj::filler, edm::Event::getByToken(), mps_fire::i, VIDNestedWPBitmapProducer< T >::initNCuts(), VIDNestedWPBitmapProducer< T >::isInit_, gen::k, eostools::move(), VIDNestedWPBitmapProducer< T >::nBits, VIDNestedWPBitmapProducer< T >::nCuts, VIDNestedWPBitmapProducer< T >::nWP, GetRecoTauVFromDQM_MC_cff::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 >::VIDNestedWPBitmapProducer().

86 {
87 
89  iEvent.getByToken(src_, src);
90  std::vector<edm::Handle<edm::ValueMap<unsigned int>>> src_bitmaps(nWP);
91  for (unsigned int i=0; i<nWP; i++) iEvent.getByToken(src_bitmaps_[i], src_bitmaps[i]);
92  std::vector<edm::Handle<edm::ValueMap<vid::CutFlowResult>>> src_cutflows(nWP);
93  for (unsigned int i=0; i<nWP; i++) iEvent.getByToken(src_cutflows_[i], src_cutflows[i]);
94 
95  std::vector<unsigned int> res;
96 
97  for (auto const& obj : src->ptrs()) {
98  for (unsigned int j=0; j<nWP; j++){
99  auto cutflow = (*(src_cutflows[j]))[obj];
100  if (!isInit_) initNCuts(cutflow.cutFlowSize());
101  if (cutflow.cutFlowSize()!=nCuts) throw cms::Exception("Configuration","Trying to compress VID bitmaps for cutflows of different size");
102  auto bitmap = (*(src_bitmaps[j]))[obj];
103  for (unsigned int k=0; k<nCuts; k++){
104  if (j==0) res_[k] = 0;
105  if (bitmap>>k & 1) {
106  if (res_[k]!=j) throw cms::Exception("Configuration","Trying to compress VID bitmaps which are not nested in the correct order for all cuts");
107  res_[k]++;
108  }
109  }
110  }
111 
112  int out = 0;
113  for (unsigned int k=0; k<nCuts; k++) out |= (res_[k] << (nBits*k));
114  res.push_back(out);
115  }
116 
117  auto resV = std::make_unique<edm::ValueMap<int>>();
119  filler.insert(src,res.begin(),res.end());
120  filler.fill();
121 
122  iEvent.put(std::move(resV));
123 
124 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
std::vector< edm::EDGetTokenT< edm::ValueMap< vid::CutFlowResult > > > src_cutflows_
Definition: Electron.h:6
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 = 0
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