Skip to content

Commit

Permalink
pack algo and originalAlgo to a uint16_t, original saved in the upper…
Browse files Browse the repository at this point in the history
… 8 bits only if algo!=original
  • Loading branch information
slava77devel committed Mar 27, 2023
1 parent da0cb6d commit 1e3b629
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 21 deletions.
26 changes: 12 additions & 14 deletions DataFormats/PatCandidates/interface/PackedCandidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ namespace pat {
covarianceVersion_(iOther.covarianceVersion_),
covarianceSchema_(iOther.covarianceSchema_),
firstHit_(iOther.firstHit_),
trkAlgo_(iOther.trkAlgo_),
trkOriginalAlgo_(iOther.trkOriginalAlgo_) {}
trkAlgoPacked_(iOther.trkAlgoPacked_) {}

PackedCandidate(PackedCandidate &&iOther)
: packedPt_(iOther.packedPt_),
Expand Down Expand Up @@ -265,8 +264,7 @@ namespace pat {
covarianceVersion_(iOther.covarianceVersion_),
covarianceSchema_(iOther.covarianceSchema_),
firstHit_(iOther.firstHit_),
trkAlgo_(iOther.trkAlgo_),
trkOriginalAlgo_(iOther.trkOriginalAlgo_) {}
trkAlgoPacked_(iOther.trkAlgoPacked_) {}

PackedCandidate &operator=(const PackedCandidate &iOther) {
if (this == &iOther) {
Expand Down Expand Up @@ -343,8 +341,7 @@ namespace pat {
covarianceVersion_ = iOther.covarianceVersion_;
covarianceSchema_ = iOther.covarianceSchema_;
firstHit_ = iOther.firstHit_;
trkAlgo_ = iOther.trkAlgo_;
trkOriginalAlgo_ = iOther.trkOriginalAlgo_;
trkAlgoPacked_ = iOther.trkAlgoPacked_;
return *this;
}

Expand Down Expand Up @@ -391,8 +388,7 @@ namespace pat {
covarianceVersion_ = iOther.covarianceVersion_;
covarianceSchema_ = iOther.covarianceSchema_;
firstHit_ = iOther.firstHit_;
trkAlgo_ = iOther.trkAlgo_;
trkOriginalAlgo_ = iOther.trkOriginalAlgo_;
trkAlgoPacked_ = iOther.trkAlgoPacked_;
return *this;
}

Expand Down Expand Up @@ -846,10 +842,13 @@ namespace pat {
uint16_t firstHit() const { return firstHit_; }

/// Set/get track algo
void setTrkAlgo(uint8_t algo) { trkAlgo_ = algo; }
void setTrkOriginalAlgo(uint8_t algo) { trkOriginalAlgo_ = algo; }
uint8_t trkAlgo() const { return trkAlgo_; }
uint8_t trkOriginalAlgo() const { return trkOriginalAlgo_; }
void setTrkAlgo(uint8_t algo, uint8_t original) {
trkAlgoPacked_ = algo | ((algo == original ? 0 : original) << 8);
}
uint8_t trkAlgo() const { return trkAlgoPacked_ & 0xff; }
uint8_t trkOriginalAlgo() const {
return (trkAlgoPacked_ & 0xff00) == 0 ? trkAlgo() : ((trkAlgoPacked_ >> 8) & 0xff);
}

void setMuonID(bool isStandAlone, bool isGlobal) {
int16_t muonFlags = isStandAlone | (2 * isGlobal);
Expand Down Expand Up @@ -1126,8 +1125,7 @@ namespace pat {
uint16_t firstHit_;

/// track algorithm details
uint8_t trkAlgo_ = 0;
uint8_t trkOriginalAlgo_ = 0;
uint16_t trkAlgoPacked_ = 0;

/// check overlap with another Candidate
bool overlap(const reco::Candidate &) const override;
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/PatCandidates/src/classes_def_objects.xml
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@
<version ClassVersion="3" checksum="3320406063"/>
</class>
<class name="pat::PackedCandidate" ClassVersion="35">
<version ClassVersion="35" checksum="3383258297"/>
<version ClassVersion="35" checksum="2065846728"/>
<version ClassVersion="34" checksum="3953181632"/>
<version ClassVersion="33" checksum="1092680546"/>
<version ClassVersion="32" checksum="926869123"/>
Expand Down
3 changes: 1 addition & 2 deletions PhysicsTools/PatAlgos/plugins/PATLostTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ void pat::PATLostTracks::addPackedCandidate(std::vector<pat::PackedCandidate>& c
cands.back().setCovarianceVersion(covarianceVersion_);
cands.back().setLostInnerHits(lostHits);
if (trk->pt() > minPtToStoreProps_ || trkStatus == TrkStatus::VTX) {
cands.back().setTrkAlgo(static_cast<uint8_t>(trk->algo()));
cands.back().setTrkOriginalAlgo(static_cast<uint8_t>(trk->originalAlgo()));
cands.back().setTrkAlgo(static_cast<uint8_t>(trk->algo()), static_cast<uint8_t>(trk->originalAlgo()));
if (useLegacySetup_ || std::abs(id) == 11 || trkStatus == TrkStatus::VTX) {
cands.back().setTrackProperties(*trk, covariancePackingSchemas_[4], covarianceVersion_);
} else {
Expand Down
3 changes: 1 addition & 2 deletions PhysicsTools/PatAlgos/plugins/PATPackedCandidateProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ void pat::PATPackedCandidateProducer::produce(edm::StreamID, edm::Event &iEvent,
if (outPtrP->back().pt() > minPtForTrackProperties_ || outPtrP->back().ptTrk() > minPtForTrackProperties_ ||
whiteList.find(ic) != whiteList.end() ||
(cand.trackRef().isNonnull() && whiteListTk.find(cand.trackRef()) != whiteListTk.end())) {
outPtrP->back().setTrkAlgo(static_cast<uint8_t>(ctrack->algo()));
outPtrP->back().setTrkOriginalAlgo(static_cast<uint8_t>(ctrack->originalAlgo()));
outPtrP->back().setTrkAlgo(static_cast<uint8_t>(ctrack->algo()), static_cast<uint8_t>(ctrack->originalAlgo()));
outPtrP->back().setFirstHit(ctrack->hitPattern().getHitPattern(reco::HitPattern::TRACK_HITS, 0));
if (abs(outPtrP->back().pdgId()) == 22) {
outPtrP->back().setTrackProperties(*ctrack, covariancePackingSchemas_[4], covarianceVersion_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,7 @@ void DeepBoostedJetTagInfoProducer::fillParticleFeatures(DeepBoostedJetFeatures
} else
lostHits = (nlost == 1 ? pat::PackedCandidate::oneLostInnerHit : pat::PackedCandidate::moreLostInnerHits);
candidate.setLostInnerHits(lostHits);
candidate.setTrkAlgo(static_cast<uint8_t>(track->algo()));
candidate.setTrkOriginalAlgo(static_cast<uint8_t>(track->originalAlgo()));
candidate.setTrkAlgo(static_cast<uint8_t>(track->algo()), static_cast<uint8_t>(track->originalAlgo()));

if (useTrackProperties(reco_cand) or
std::find(whiteListSV.begin(), whiteListSV.end(), icand) != whiteListSV.end() or
Expand Down

0 comments on commit 1e3b629

Please sign in to comment.