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 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)
 
 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::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::hlt::Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getParameterSetVector(), edm::ParameterSet::getUntrackedParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

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::LogError("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

Definition at line 35 of file VersionedIdProducer.h.

35 {}

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

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  std::auto_ptr<edm::ValueMap<bool> > outPass(new edm::ValueMap<bool>() );
143  std::auto_ptr<edm::ValueMap<float> > outPassf(new edm::ValueMap<float>() );
144  std::auto_ptr<edm::ValueMap<unsigned> > outHowFar(new edm::ValueMap<unsigned>() );
145  std::auto_ptr<edm::ValueMap<unsigned> > outBitmap(new edm::ValueMap<unsigned>() );
146  std::auto_ptr<edm::ValueMap<vid::CutFlowResult> > out_cfrs(new edm::ValueMap<vid::CutFlowResult>() );
147  std::auto_ptr<pat::UserDataCollection> out_usrd(new 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(outPass,id->name());
186  iEvent.put(outPassf,id->name());
187  iEvent.put(outHowFar,id->name());
188  iEvent.put(outBitmap,id->name()+std::string(bitmap_label));
189  iEvent.put(out_cfrs,id->name());
190  iEvent.put(std::auto_ptr<std::string>(new std::string(id->md5String())),
191  id->name());
192  auto usrd_handle = iEvent.put(out_usrd,id->name());
193  //now add the value map of ptrs to user datas
194  std::auto_ptr<edm::ValueMap<edm::Ptr<pat::UserData> > > out_usrdptrs(new 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(out_usrdptrs,id->name());
205  }
206 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::unique_ptr< SelectorType > > ids_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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:115

Member Data Documentation

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

Definition at line 44 of file VersionedIdProducer.h.

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

Definition at line 42 of file VersionedIdProducer.h.

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

Definition at line 41 of file VersionedIdProducer.h.