Skip to content

Commit aeedb8a

Browse files
committed
Merge pull request #8 from lgray/pyVID_and_newIDs_74X
add bitmap to VID output - the order of bits is the order of the cuts…
2 parents f827d53 + 3d36778 commit aeedb8a

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

PhysicsTools/SelectorUtils/interface/VersionedIdProducer.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class VersionedIdProducer : public edm::stream::EDProducer<> {
3535
bool verbose_;
3636
TokenType physicsObjectSrc_;
3737

38-
std::vector<std::unique_ptr<SelectorType> > ids_;
38+
std::vector<std::unique_ptr<SelectorType> > ids_;
39+
3940
};
4041

4142
//
@@ -52,6 +53,8 @@ class VersionedIdProducer : public edm::stream::EDProducer<> {
5253
template< class PhysicsObjectPtr , class SelectorType >
5354
VersionedIdProducer<PhysicsObjectPtr,SelectorType>::
5455
VersionedIdProducer(const edm::ParameterSet& iConfig) {
56+
constexpr char bitmap_label[] = "_bitmap";
57+
5558
verbose_ = iConfig.getUntrackedParameter<bool>("verbose", false);
5659

5760
physicsObjectSrc_ =
@@ -102,16 +105,21 @@ VersionedIdProducer(const edm::ParameterSet& iConfig) {
102105
edm::LogWarning("IdInformation")
103106
<< idmsg.str();
104107

108+
109+
105110
produces<std::string>(idname);
106111
produces<edm::ValueMap<bool> >(idname);
107112
produces<edm::ValueMap<float> >(idname); // for PAT
108-
produces<edm::ValueMap<unsigned> >(idname);
113+
produces<edm::ValueMap<unsigned> >(idname);
114+
produces<edm::ValueMap<unsigned> >(idname+std::string(bitmap_label));
109115
}
110116
}
111117

112118
template< class PhysicsObjectPtr , class SelectorType >
113119
void VersionedIdProducer<PhysicsObjectPtr,SelectorType>::
114120
produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
121+
constexpr char bitmap_label[] = "_bitmap";
122+
115123
edm::Handle<Collection> physicsObjectsHandle;
116124
iEvent.getByToken(physicsObjectSrc_,physicsObjectsHandle);
117125

@@ -121,14 +129,17 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
121129
std::auto_ptr<edm::ValueMap<bool> > outPass(new edm::ValueMap<bool>() );
122130
std::auto_ptr<edm::ValueMap<float> > outPassf(new edm::ValueMap<float>() );
123131
std::auto_ptr<edm::ValueMap<unsigned> > outHowFar(new edm::ValueMap<unsigned>() );
132+
std::auto_ptr<edm::ValueMap<unsigned> > outBitmap(new edm::ValueMap<unsigned>() );
124133
std::vector<bool> passfail;
125134
std::vector<float> passfailf;
126135
std::vector<unsigned> howfar;
136+
std::vector<unsigned> bitmap;
127137
for(size_t i = 0; i < physicsobjects.size(); ++i) {
128138
auto po = physicsobjects.ptrAt(i);
129139
passfail.push_back((*id)(po,iEvent));
130140
passfailf.push_back(passfail.back());
131141
howfar.push_back(id->howFarInCutFlow());
142+
bitmap.push_back(id->bitMap());
132143
}
133144

134145
edm::ValueMap<bool>::Filler fillerpassfail(*outPass);
@@ -143,11 +154,17 @@ produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
143154
fillerhowfar.insert(physicsObjectsHandle, howfar.begin(), howfar.end() );
144155
fillerhowfar.fill();
145156

157+
edm::ValueMap<unsigned>::Filler fillerbitmap(*outBitmap);
158+
fillerbitmap.insert(physicsObjectsHandle, bitmap.begin(), bitmap.end() );
159+
fillerbitmap.fill();
160+
146161
iEvent.put(outPass,id->name());
147162
iEvent.put(outPassf,id->name());
148163
iEvent.put(outHowFar,id->name());
164+
iEvent.put(outBitmap,id->name()+std::string(bitmap_label));
149165
iEvent.put(std::auto_ptr<std::string>(new std::string(id->md5String())),
150166
id->name());
167+
151168
}
152169
}
153170

PhysicsTools/SelectorUtils/interface/VersionedSelector.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class VersionedSelector : public Selector<T> {
5959

6060
virtual bool operator()( const T& ref, pat::strbitset& ret ) override final {
6161
howfar_ = 0;
62+
bitmap_ = 0;
6263
bool failed = false;
6364
if( !initialized_ ) {
6465
throw cms::Exception("CutNotInitialized")
@@ -69,6 +70,7 @@ class VersionedSelector : public Selector<T> {
6970
const bool result = (*cuts_[i])(temp);
7071
if( result || this->ignoreCut(cut_indices_[i]) ) {
7172
this->passCut(ret,cut_indices_[i]);
73+
bitmap_ |= 1<<i;
7274
if( !failed ) ++howfar_;
7375
} else {
7476
failed = true;
@@ -117,6 +119,8 @@ class VersionedSelector : public Selector<T> {
117119
const std::string& name() const { return name_; }
118120

119121
const unsigned howFarInCutFlow() const { return howfar_; }
122+
123+
const unsigned bitMap() const { return bitmap_; }
120124

121125
const size_t cutFlowSize() const { return cuts_.size(); }
122126

@@ -129,7 +133,7 @@ class VersionedSelector : public Selector<T> {
129133
std::vector<std::shared_ptr<candf::CandidateCut> > cuts_;
130134
std::vector<bool> needs_event_content_;
131135
std::vector<typename Selector<T>::index_type> cut_indices_;
132-
unsigned howfar_;
136+
unsigned howfar_, bitmap_;
133137

134138
private:
135139
unsigned char id_md5_[MD5_DIGEST_LENGTH];

0 commit comments

Comments
 (0)