1 #ifndef PhysicsTools_SelectorUtils_VersionedIdProducer_h 2 #define PhysicsTools_SelectorUtils_VersionedIdProducer_h 26 template <
class PhysicsObjectPtr,
class SelectorType = VersionedSelector<PhysicsObjectPtr>>
44 std::vector<std::unique_ptr<SelectorType>>
ids_;
58 template <
class PhysicsObjectPtr,
class SelectorType>
67 for (
const auto&
id : ids) {
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!";
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!";
88 std::stringstream idmsg;
91 idmsg <<
"Instantiated ID: " << idname << std::endl <<
"with MD5 hash: " <<
idMD5 << std::endl;
92 const bool isPOGApproved =
id.getUntrackedParameter<
bool>(
"isPOGApproved",
false);
94 idmsg <<
"This ID is POG approved!" << std::endl;
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;
107 produces<std::string>(idname);
108 produces<edm::ValueMap<bool>>(idname);
109 produces<edm::ValueMap<float>>(idname);
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);
118 template <
class PhysicsObjectPtr,
class SelectorType>
120 constexpr char bitmap_label[] =
"Bitmap";
123 iEvent.getByToken(physicsObjectSrc_, physicsObjectsHandle);
125 const Collection& physicsobjects = *physicsObjectsHandle;
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>();
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;
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());
152 fillerpassfail.
insert(physicsObjectsHandle, passfail.begin(), passfail.end());
153 fillerpassfail.
fill();
156 fillerpassfailf.
insert(physicsObjectsHandle, passfailf.begin(), passfailf.end());
157 fillerpassfailf.
fill();
160 fillerhowfar.
insert(physicsObjectsHandle, howfar.begin(), howfar.end());
164 fillerbitmap.
insert(physicsObjectsHandle, bitmap.begin(), bitmap.end());
168 fillercfr.
insert(physicsObjectsHandle, cfrs.begin(), cfrs.end());
176 iEvent.put(std::make_unique<std::string>(
id->md5String()),
id->name());
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) {
186 fillerusrdptrs.insert(physicsObjectsHandle, usrdptrs.begin(), usrdptrs.end());
187 fillerusrdptrs.fill();
T getParameter(std::string const &) const
Ptr< value_type > ptrAt(size_type i) const
std::vector< std::unique_ptr< SelectorType > > ids_
ParameterSet const & getParameterSet(std::string const &) const
void insert(const H &h, I begin, I end)
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
T getUntrackedParameter(std::string const &, T const &) const
typename PhysicsObjectPtr::value_type PhysicsObjectType
Container::value_type value_type
void produce(edm::Event &, const edm::EventSetup &) override
~VersionedIdProducer() override
isPOGApproved
for now until we have a database...
VersionedIdProducer(const edm::ParameterSet &)
Log< level::Info, false > LogInfo
TokenType physicsObjectSrc_
VParameterSet const & getParameterSetVector(std::string const &name) const
Log< level::Warning, false > LogWarning