CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
VersionedIdProducer< PhysicsObjectPtr, SelectorType > Class Template Reference

#include <VersionedIdProducer.h>

Inheritance diagram for VersionedIdProducer< PhysicsObjectPtr, SelectorType >:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

using Collection = edm::View< PhysicsObjectType >
 
using PhysicsObjectType = typename PhysicsObjectPtr::value_type
 
using TokenType = edm::EDGetTokenT< Collection >
 
- 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
 

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &) override
 
 VersionedIdProducer (const edm::ParameterSet &)
 
 ~VersionedIdProducer ()
 
- 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
 
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)
 

Private Attributes

std::vector< std::unique_ptr< SelectorType > > ids_
 
TokenType physicsObjectSrc_
 
bool verbose_
 

Additional Inherited Members

- 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

template<class PhysicsObjectPtr, class SelectorType = VersionedSelector<PhysicsObjectPtr>>
class VersionedIdProducer< PhysicsObjectPtr, SelectorType >

Definition at line 27 of file VersionedIdProducer.h.

Member Typedef Documentation

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
using VersionedIdProducer< PhysicsObjectPtr, SelectorType >::Collection = edm::View<PhysicsObjectType>

Definition at line 31 of file VersionedIdProducer.h.

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
using VersionedIdProducer< PhysicsObjectPtr, SelectorType >::PhysicsObjectType = typename PhysicsObjectPtr::value_type

Definition at line 29 of file VersionedIdProducer.h.

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
using VersionedIdProducer< PhysicsObjectPtr, SelectorType >::TokenType = edm::EDGetTokenT<Collection>

Definition at line 32 of file VersionedIdProducer.h.

Constructor & Destructor Documentation

template<class PhysicsObjectPtr , class SelectorType >
VersionedIdProducer< PhysicsObjectPtr, SelectorType >::VersionedIdProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 61 of file VersionedIdProducer.h.

References constexpr, edm::EDConsumerBase::consumesCollector(), Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getParameterSetVector(), edm::ParameterSet::getUntrackedParameter(), egmPatElectronIDs_cfi::idMD5, VersionedIdProducer< PhysicsObjectPtr, SelectorType >::ids_, cutBasedElectronHLTPreselecition_Summer16_V1_cff::isPOGApproved, VersionedIdProducer< PhysicsObjectPtr, SelectorType >::physicsObjectSrc_, VersionedIdProducer< PhysicsObjectPtr, SelectorType >::produce(), AlCaHLTBitMon_QueryRunRegistry::string, and VersionedIdProducer< PhysicsObjectPtr, SelectorType >::verbose_.

61  {
62  constexpr char bitmap_label[] = "Bitmap";
63 
64  verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
65 
67  consumes<Collection>(iConfig.getParameter<edm::InputTag>("physicsObjectSrc"));
68 
69  const std::vector<edm::ParameterSet>& ids =
70  iConfig.getParameterSetVector("physicsObjectIDs");
71  for(const auto& id : ids ) {
72  const std::string& idMD5 =
73  id.getParameter<std::string>("idMD5");
74  const edm::ParameterSet& the_id =
75  id.getParameterSet("idDefinition");
76  const std::string& idname =
77  the_id.getParameter<std::string>("idName");
78  std::string calculated_md5;
79  ids_.emplace_back( new SelectorType(the_id) );
80  calculated_md5 = ids_.back()->md5String();
81  ids_.back()->setConsumes(consumesCollector());
82  if( ids_.back()->cutFlowSize() == 0 ) {
83  throw cms::Exception("InvalidCutFlow")
84  << "Post-processing cutflow size is zero! You may have configured"
85  << " the python incorrectly!";
86  }
87 
88  if( idMD5 != calculated_md5 ) {
89  edm::LogInfo("IdConfigurationNotValidated")
90  << "ID: " << ids_.back()->name() << "\n"
91  << "The expected md5: " << idMD5 << " does not match the md5\n"
92  << "calculated by the ID: " << calculated_md5 << " please\n"
93  << "update your python configuration or determine the source\n"
94  << "of transcription error!";
95  }
96 
97  std::stringstream idmsg;
98 
99  // dump whatever information about the ID we have
100  idmsg << "Instantiated ID: " << idname << std::endl
101  << "with MD5 hash: " << idMD5 << std::endl;
102  const bool isPOGApproved =
103  id.getUntrackedParameter<bool>("isPOGApproved",false);
104  if( isPOGApproved ) {
105  idmsg << "This ID is POG approved!" << std::endl;
106  } else {
107  idmsg << "This ID is not POG approved and likely under development!!!\n"
108  << "Please make sure to report your progress with this ID "
109  << "at the next relevant POG meeting." << std::endl;
110  }
111 
112  if( !isPOGApproved ) {
113  edm::LogWarning("IdInformation")
114  << idmsg.str();
115  } else {
116  edm::LogInfo("IdInformation")
117  << idmsg.str();
118  }
119 
120  produces<std::string>(idname);
121  produces<edm::ValueMap<bool> >(idname);
122  produces<edm::ValueMap<float> >(idname); // for PAT
123  produces<edm::ValueMap<unsigned> >(idname);
124  produces<edm::ValueMap<unsigned> >(idname+std::string(bitmap_label));
125  produces<edm::ValueMap<vid::CutFlowResult> >(idname);
126  produces<pat::UserDataCollection>(idname);
127  produces<edm::ValueMap<edm::Ptr<pat::UserData> > >(idname);
128  }
129 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
std::vector< std::unique_ptr< SelectorType > > ids_
#define constexpr
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ParameterSet const & getParameterSet(std::string const &) const
template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
VersionedIdProducer< PhysicsObjectPtr, SelectorType >::~VersionedIdProducer ( )
inline

Member Function Documentation

template<class PhysicsObjectPtr , class SelectorType >
void VersionedIdProducer< PhysicsObjectPtr, SelectorType >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Definition at line 133 of file VersionedIdProducer.h.

References constexpr, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), mps_fire::i, hcalTTPDigis_cfi::id, VersionedIdProducer< PhysicsObjectPtr, SelectorType >::ids_, edm::helper::Filler< Map >::insert(), pat::UserData::make(), eostools::move(), VersionedIdProducer< PhysicsObjectPtr, SelectorType >::physicsObjectSrc_, edm::View< T >::ptrAt(), edm::Event::put(), edm::View< T >::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by VersionedIdProducer< PhysicsObjectPtr, SelectorType >::VersionedIdProducer(), and VersionedIdProducer< PhysicsObjectPtr, SelectorType >::~VersionedIdProducer().

133  {
134  constexpr char bitmap_label[] = "Bitmap";
135 
136  edm::Handle<Collection> physicsObjectsHandle;
137  iEvent.getByToken(physicsObjectSrc_,physicsObjectsHandle);
138 
139  const Collection& physicsobjects = *physicsObjectsHandle;
140 
141  for( const auto& id : ids_ ) {
142  auto outPass = std::make_unique<edm::ValueMap<bool>>();
143  auto outPassf = std::make_unique<edm::ValueMap<float>>();
144  auto outHowFar = std::make_unique<edm::ValueMap<unsigned>>();
145  auto outBitmap = std::make_unique<edm::ValueMap<unsigned>>();
146  auto out_cfrs = std::make_unique<edm::ValueMap<vid::CutFlowResult>>();
147  auto out_usrd = std::make_unique<pat::UserDataCollection>();
148 
149  std::vector<bool> passfail;
150  std::vector<float> passfailf;
151  std::vector<unsigned> howfar;
152  std::vector<unsigned> bitmap;
153  std::vector<vid::CutFlowResult> cfrs;
154 
155  for(size_t i = 0; i < physicsobjects.size(); ++i) {
156  auto po = physicsobjects.ptrAt(i);
157  passfail.push_back((*id)(po,iEvent));
158  passfailf.push_back(passfail.back());
159  howfar.push_back(id->howFarInCutFlow());
160  bitmap.push_back(id->bitMap());
161  cfrs.push_back(id->cutFlowResult());
162  out_usrd->push_back(pat::UserData::make(cfrs.back(),false));
163  }
164 
165  edm::ValueMap<bool>::Filler fillerpassfail(*outPass);
166  fillerpassfail.insert(physicsObjectsHandle, passfail.begin(), passfail.end());
167  fillerpassfail.fill();
168 
169  edm::ValueMap<float>::Filler fillerpassfailf(*outPassf);
170  fillerpassfailf.insert(physicsObjectsHandle, passfailf.begin(), passfailf.end());
171  fillerpassfailf.fill();
172 
173  edm::ValueMap<unsigned>::Filler fillerhowfar(*outHowFar);
174  fillerhowfar.insert(physicsObjectsHandle, howfar.begin(), howfar.end() );
175  fillerhowfar.fill();
176 
177  edm::ValueMap<unsigned>::Filler fillerbitmap(*outBitmap);
178  fillerbitmap.insert(physicsObjectsHandle, bitmap.begin(), bitmap.end() );
179  fillerbitmap.fill();
180 
181  edm::ValueMap<vid::CutFlowResult>::Filler fillercfr(*out_cfrs);
182  fillercfr.insert(physicsObjectsHandle, cfrs.begin(), cfrs.end() );
183  fillercfr.fill();
184 
185  iEvent.put(std::move(outPass),id->name());
186  iEvent.put(std::move(outPassf),id->name());
187  iEvent.put(std::move(outHowFar),id->name());
188  iEvent.put(std::move(outBitmap),id->name()+std::string(bitmap_label));
189  iEvent.put(std::move(out_cfrs),id->name());
190  iEvent.put(std::make_unique<std::string>(id->md5String()),
191  id->name());
192  auto usrd_handle = iEvent.put(std::move(out_usrd),id->name());
193  //now add the value map of ptrs to user datas
194  auto out_usrdptrs = std::make_unique<edm::ValueMap<edm::Ptr<pat::UserData>>>();
195  std::vector<edm::Ptr<pat::UserData> > usrdptrs;
196  for( unsigned i = 0; i < usrd_handle->size(); ++i ){
197  usrdptrs.push_back(edm::Ptr<pat::UserData>(usrd_handle,i));
198  }
199 
200  edm::ValueMap<edm::Ptr<pat::UserData> >::Filler fillerusrdptrs(*out_usrdptrs);
201  fillerusrdptrs.insert(physicsObjectsHandle, usrdptrs.begin(), usrdptrs.end());
202  fillerusrdptrs.fill();
203 
204  iEvent.put(std::move(out_usrdptrs),id->name());
205  }
206 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
std::vector< std::unique_ptr< SelectorType > > ids_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::View< PhysicsObjectType > Collection
#define constexpr
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
std::vector<std::unique_ptr<SelectorType> > VersionedIdProducer< PhysicsObjectPtr, SelectorType >::ids_
private
template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
TokenType VersionedIdProducer< PhysicsObjectPtr, SelectorType >::physicsObjectSrc_
private
template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
bool VersionedIdProducer< PhysicsObjectPtr, SelectorType >::verbose_
private