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

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<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 
 VersionedIdProducer (const edm::ParameterSet &)
 
 ~VersionedIdProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Attributes

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

Detailed Description

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

Definition at line 27 of file VersionedIdProducer.h.

Member Typedef Documentation

◆ Collection

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

Definition at line 31 of file VersionedIdProducer.h.

◆ PhysicsObjectType

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

Definition at line 29 of file VersionedIdProducer.h.

◆ TokenType

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

◆ VersionedIdProducer()

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

Definition at line 59 of file VersionedIdProducer.h.

References Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::ParameterSet::getParameterSetVector(), edm::ParameterSet::getUntrackedParameter(), versionedElectronIDProducer_cfi::idMD5, cutBasedElectronHLTPreselecition_Summer16_V1_cff::isPOGApproved, and AlCaHLTBitMon_QueryRunRegistry::string.

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

◆ ~VersionedIdProducer()

template<class PhysicsObjectPtr , class SelectorType = VersionedSelector<PhysicsObjectPtr>>
VersionedIdProducer< PhysicsObjectPtr, SelectorType >::~VersionedIdProducer ( )
inlineoverride

Definition at line 35 of file VersionedIdProducer.h.

35 {}

Member Function Documentation

◆ produce()

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

Definition at line 119 of file VersionedIdProducer.h.

References edm::helper::Filler< Map >::fill(), mps_fire::i, l1ctLayer2EG_cff::id, iEvent, edm::helper::Filler< Map >::insert(), pat::UserData::make(), eostools::move(), edm::View< T >::ptrAt(), edm::View< T >::size(), and AlCaHLTBitMon_QueryRunRegistry::string.

119  {
120  constexpr char bitmap_label[] = "Bitmap";
121 
122  edm::Handle<Collection> physicsObjectsHandle;
123  iEvent.getByToken(physicsObjectSrc_, physicsObjectsHandle);
124 
125  const Collection& physicsobjects = *physicsObjectsHandle;
126 
127  for (const auto& id : ids_) {
128  auto outPass = std::make_unique<edm::ValueMap<bool>>();
129  auto outPassf = std::make_unique<edm::ValueMap<float>>();
130  auto outHowFar = std::make_unique<edm::ValueMap<unsigned>>();
131  auto outBitmap = std::make_unique<edm::ValueMap<unsigned>>();
132  auto out_cfrs = std::make_unique<edm::ValueMap<vid::CutFlowResult>>();
133  auto out_usrd = std::make_unique<pat::UserDataCollection>();
134 
135  std::vector<bool> passfail;
136  std::vector<float> passfailf;
137  std::vector<unsigned> howfar;
138  std::vector<unsigned> bitmap;
139  std::vector<vid::CutFlowResult> cfrs;
140 
141  for (size_t i = 0; i < physicsobjects.size(); ++i) {
142  auto po = physicsobjects.ptrAt(i);
143  passfail.push_back((*id)(po, iEvent));
144  passfailf.push_back(passfail.back());
145  howfar.push_back(id->howFarInCutFlow());
146  bitmap.push_back(id->bitMap());
147  cfrs.push_back(id->cutFlowResult());
148  out_usrd->push_back(pat::UserData::make(cfrs.back(), false));
149  }
150 
151  edm::ValueMap<bool>::Filler fillerpassfail(*outPass);
152  fillerpassfail.insert(physicsObjectsHandle, passfail.begin(), passfail.end());
153  fillerpassfail.fill();
154 
155  edm::ValueMap<float>::Filler fillerpassfailf(*outPassf);
156  fillerpassfailf.insert(physicsObjectsHandle, passfailf.begin(), passfailf.end());
157  fillerpassfailf.fill();
158 
159  edm::ValueMap<unsigned>::Filler fillerhowfar(*outHowFar);
160  fillerhowfar.insert(physicsObjectsHandle, howfar.begin(), howfar.end());
161  fillerhowfar.fill();
162 
163  edm::ValueMap<unsigned>::Filler fillerbitmap(*outBitmap);
164  fillerbitmap.insert(physicsObjectsHandle, bitmap.begin(), bitmap.end());
165  fillerbitmap.fill();
166 
167  edm::ValueMap<vid::CutFlowResult>::Filler fillercfr(*out_cfrs);
168  fillercfr.insert(physicsObjectsHandle, cfrs.begin(), cfrs.end());
169  fillercfr.fill();
170 
171  iEvent.put(std::move(outPass), id->name());
172  iEvent.put(std::move(outPassf), id->name());
173  iEvent.put(std::move(outHowFar), id->name());
174  iEvent.put(std::move(outBitmap), id->name() + std::string(bitmap_label));
175  iEvent.put(std::move(out_cfrs), id->name());
176  iEvent.put(std::make_unique<std::string>(id->md5String()), id->name());
177  auto usrd_handle = iEvent.put(std::move(out_usrd), id->name());
178  //now add the value map of ptrs to user datas
179  auto out_usrdptrs = std::make_unique<edm::ValueMap<edm::Ptr<pat::UserData>>>();
180  std::vector<edm::Ptr<pat::UserData>> usrdptrs;
181  for (unsigned i = 0; i < usrd_handle->size(); ++i) {
182  usrdptrs.push_back(edm::Ptr<pat::UserData>(usrd_handle, i));
183  }
184 
185  edm::ValueMap<edm::Ptr<pat::UserData>>::Filler fillerusrdptrs(*out_usrdptrs);
186  fillerusrdptrs.insert(physicsObjectsHandle, usrdptrs.begin(), usrdptrs.end());
187  fillerusrdptrs.fill();
188 
189  iEvent.put(std::move(out_usrdptrs), id->name());
190  }
191 }
std::vector< std::unique_ptr< SelectorType > > ids_
edm::View< PhysicsObjectType > Collection
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ ids_

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.

◆ physicsObjectSrc_

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

Definition at line 42 of file VersionedIdProducer.h.

◆ verbose_

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

Definition at line 41 of file VersionedIdProducer.h.