CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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, 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 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
 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 (const std::string &iProcessName, std::vector< const char * > &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 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::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 25 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 29 of file VersionedIdProducer.h.

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

Definition at line 27 of file VersionedIdProducer.h.

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

Definition at line 30 of file VersionedIdProducer.h.

Constructor & Destructor Documentation

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

Definition at line 59 of file VersionedIdProducer.h.

References constexpr, edm::hlt::Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getParameterSetVector(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 33 of file VersionedIdProducer.h.

33 {}

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 131 of file VersionedIdProducer.h.

References constexpr, edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), i, edm::helper::Filler< Map >::insert(), pat::UserData::make(), edm::View< T >::ptrAt(), edm::Event::put(), edm::View< T >::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

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

Definition at line 42 of file VersionedIdProducer.h.

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
TokenType VersionedIdProducer< PhysicsObjectPtr, SelectorType >::physicsObjectSrc_
private

Definition at line 40 of file VersionedIdProducer.h.

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
bool VersionedIdProducer< PhysicsObjectPtr, SelectorType >::verbose_
private

Definition at line 39 of file VersionedIdProducer.h.