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

typedef edm::View
< PhysicsObjectType
Collection
 
typedef
PhysicsObjectPtr::value_type 
PhysicsObjectType
 
typedef edm::EDGetTokenT
< Collection
TokenType
 
- 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 &)
 
 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
 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
 
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 21 of file VersionedIdProducer.h.

Member Typedef Documentation

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

Definition at line 25 of file VersionedIdProducer.h.

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

Definition at line 23 of file VersionedIdProducer.h.

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

Definition at line 26 of file VersionedIdProducer.h.

Constructor & Destructor Documentation

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

Definition at line 54 of file VersionedIdProducer.h.

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

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

29 {}

Member Function Documentation

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

Implements edm::stream::EDProducerBase.

Definition at line 114 of file VersionedIdProducer.h.

References edm::helper::Filler< Map >::fill(), edm::Event::getByToken(), edm::helper::Filler< Map >::insert(), edm::View< T >::ptrVector(), edm::Event::put(), and AlCaHLTBitMon_QueryRunRegistry::string.

114  {
115  edm::Handle<Collection> physicsObjectsHandle;
116  iEvent.getByToken(physicsObjectSrc_,physicsObjectsHandle);
117 
118  const Collection& physicsobjects = *physicsObjectsHandle;
119 
120  for( const auto& id : ids_ ) {
121  std::auto_ptr<edm::ValueMap<bool> > outPass(new edm::ValueMap<bool>() );
122  std::auto_ptr<edm::ValueMap<float> > outPassf(new edm::ValueMap<float>() );
123  std::auto_ptr<edm::ValueMap<unsigned> > outHowFar(new edm::ValueMap<unsigned>() );
124  std::vector<bool> passfail;
125  std::vector<float> passfailf;
126  std::vector<unsigned> howfar;
127  for(const auto& po : physicsobjects.ptrVector()) {
128  passfail.push_back((*id)(po,iEvent));
129  passfailf.push_back(passfail.back());
130  howfar.push_back(id->howFarInCutFlow());
131  }
132 
133  edm::ValueMap<bool>::Filler fillerpassfail(*outPass);
134  fillerpassfail.insert(physicsObjectsHandle, passfail.begin(), passfail.end());
135  fillerpassfail.fill();
136 
137  edm::ValueMap<float>::Filler fillerpassfailf(*outPassf);
138  fillerpassfailf.insert(physicsObjectsHandle, passfailf.begin(), passfailf.end());
139  fillerpassfailf.fill();
140 
141  edm::ValueMap<unsigned>::Filler fillerhowfar(*outHowFar);
142  fillerhowfar.insert(physicsObjectsHandle, howfar.begin(), howfar.end() );
143  fillerhowfar.fill();
144 
145  iEvent.put(outPass,id->name());
146  iEvent.put(outPassf,id->name());
147  iEvent.put(outHowFar,id->name());
148  iEvent.put(std::auto_ptr<std::string>(new std::string(id->md5String())),
149  id->name());
150  }
151 }
std::vector< std::unique_ptr< SelectorType > > ids_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
edm::View< PhysicsObjectType > Collection

Member Data Documentation

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

Definition at line 38 of file VersionedIdProducer.h.

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

Definition at line 36 of file VersionedIdProducer.h.

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

Definition at line 35 of file VersionedIdProducer.h.