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_;
59 template<
class PhysicsObjectPtr ,
class SelectorType >
69 const std::vector<edm::ParameterSet>&
ids =
71 for(
const auto&
id : ids ) {
79 ids_.emplace_back(
new SelectorType(the_id) );
80 calculated_md5 =
ids_.back()->md5String();
82 if(
ids_.back()->cutFlowSize() == 0 ) {
84 <<
"Post-processing cutflow size is zero! You may have configured" 85 <<
" the python incorrectly!";
88 if( idMD5 != calculated_md5 ) {
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!";
97 std::stringstream idmsg;
100 idmsg <<
"Instantiated ID: " << idname << std::endl
101 <<
"with MD5 hash: " << idMD5 << std::endl;
103 id.getUntrackedParameter<
bool>(
"isPOGApproved",
false);
104 if( isPOGApproved ) {
105 idmsg <<
"This ID is POG approved!" << std::endl;
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;
112 if( !isPOGApproved ) {
120 produces<std::string>(idname);
121 produces<edm::ValueMap<bool> >(idname);
122 produces<edm::ValueMap<float> >(idname);
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);
131 template<
class PhysicsObjectPtr ,
class SelectorType >
134 constexpr char bitmap_label[] =
"Bitmap";
139 const Collection& physicsobjects = *physicsObjectsHandle;
141 for(
const auto&
id :
ids_ ) {
142 auto outPass = std::make_unique<edm::ValueMap<bool>>();
143 auto outPassf = std::make_unique<edm::ValueMap<float>>();
144 auto outHowFar = std::make_unique<edm::ValueMap<unsigned>>();
145 auto outBitmap = std::make_unique<edm::ValueMap<unsigned>>();
146 auto out_cfrs = std::make_unique<edm::ValueMap<vid::CutFlowResult>>();
147 auto out_usrd = std::make_unique<pat::UserDataCollection>();
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;
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());
166 fillerpassfail.
insert(physicsObjectsHandle, passfail.begin(), passfail.end());
167 fillerpassfail.
fill();
170 fillerpassfailf.
insert(physicsObjectsHandle, passfailf.begin(), passfailf.end());
171 fillerpassfailf.
fill();
174 fillerhowfar.
insert(physicsObjectsHandle, howfar.begin(), howfar.end() );
178 fillerbitmap.
insert(physicsObjectsHandle, bitmap.begin(), bitmap.end() );
182 fillercfr.
insert(physicsObjectsHandle, cfrs.begin(), cfrs.end() );
190 iEvent.
put(std::make_unique<std::string>(
id->md5String()),
194 auto out_usrdptrs = std::make_unique<edm::ValueMap<edm::Ptr<pat::UserData>>>();
195 std::vector<edm::Ptr<pat::UserData> > usrdptrs;
196 for(
unsigned i = 0;
i < usrd_handle->size(); ++
i ){
201 fillerusrdptrs.insert(physicsObjectsHandle, usrdptrs.begin(), usrdptrs.end());
202 fillerusrdptrs.fill();
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
std::vector< std::unique_ptr< SelectorType > > ids_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Ptr< value_type > ptrAt(size_type i) const
void insert(const H &h, I begin, I end)
static std::unique_ptr< UserData > make(const T &value, bool transientOnly=false)
typename PhysicsObjectPtr::value_type PhysicsObjectType
Container::value_type value_type
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void produce(edm::Event &, const edm::EventSetup &) override
~VersionedIdProducer() override
isPOGApproved
for now until we have a database...
VersionedIdProducer(const edm::ParameterSet &)
TokenType physicsObjectSrc_
ParameterSet const & getParameterSet(std::string const &) const