Skip to content

Commit

Permalink
Merge pull request #20 from gpetruc/miniAOD-from700
Browse files Browse the repository at this point in the history
Make the unpacking of names a non-const call
  • Loading branch information
arizzi committed Apr 17, 2014
2 parents 65e4b4f + 553da1a commit 250ea82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/interface/PATObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ namespace pat {
/// add a trigger match
void addTriggerObjectMatch( const TriggerObjectStandAlone & trigObj ) { triggerObjectMatchesEmbedded_.push_back( trigObj ); };
/// unpack path names of matched trigger objects (if they were packed before embedding, which is not normally the case)
void unpackTriggerObjectPathNames( const edm::TriggerNames &names ) const {
for (std::vector<TriggerObjectStandAlone>::const_iterator it = triggerObjectMatchesEmbedded_.begin(), ed = triggerObjectMatchesEmbedded_.end(); it != ed; ++it) it->unpackPathNames(names);
void unpackTriggerObjectPathNames( const edm::TriggerNames &names ) {
for (std::vector<TriggerObjectStandAlone>::iterator it = triggerObjectMatchesEmbedded_.begin(), ed = triggerObjectMatchesEmbedded_.end(); it != ed; ++it) it->unpackPathNames(names);
}

/// Returns an efficiency given its name
Expand Down
4 changes: 2 additions & 2 deletions DataFormats/PatCandidates/interface/TriggerObjectStandAlone.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ namespace pat {
virtual bool coll( const std::string & collName ) const { return hasCollection( collName ); };

/// pack trigger names into indices
void packPathNames(const edm::TriggerNames &names) const ;
void packPathNames(const edm::TriggerNames &names) ;
/// unpack trigger names into indices
void unpackPathNames(const edm::TriggerNames &names) const ;
void unpackPathNames(const edm::TriggerNames &names) ;

};

Expand Down
12 changes: 6 additions & 6 deletions DataFormats/PatCandidates/src/TriggerObjectStandAlone.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ bool TriggerObjectStandAlone::checkIfPathsAreUnpacked(bool throwIfPacked) const
return unpacked;
}

void TriggerObjectStandAlone::packPathNames(const edm::TriggerNames &names) const {
void TriggerObjectStandAlone::packPathNames(const edm::TriggerNames &names) {
if (!pathIndices_.empty()) {
if (!pathNames_.empty()) {
throw cms::Exception("RuntimeError", "Error, trying to pack a partially packed TriggerObjectStandAlone");
Expand All @@ -283,12 +283,12 @@ void TriggerObjectStandAlone::packPathNames(const edm::TriggerNames &names) cons
}
}
if (ok) {
(const_cast<std::vector<uint16_t> &>(pathIndices_)).swap(indices);
(const_cast<std::vector<std::string> &>(pathNames_)).clear();
pathIndices_.swap(indices);
pathNames_.clear();
}
}

void TriggerObjectStandAlone::unpackPathNames(const edm::TriggerNames &names) const {
void TriggerObjectStandAlone::unpackPathNames(const edm::TriggerNames &names) {
if (!pathNames_.empty()) {
if (!pathIndices_.empty()) {
throw cms::Exception("RuntimeError", "Error, trying to unpack a partially unpacked TriggerObjectStandAlone");
Expand All @@ -302,7 +302,7 @@ void TriggerObjectStandAlone::unpackPathNames(const edm::TriggerNames &names) co
if (pathIndices_[i] >= end) throw cms::Exception("RuntimeError", "Error, path index out of bounds");
paths[i] = names.triggerName(pathIndices_[i]);
}
(const_cast<std::vector<uint16_t> &>(pathIndices_)).clear();
(const_cast<std::vector<std::string> &>(pathNames_)).swap(paths);
pathIndices_.clear();
pathNames_.swap(paths);
}

0 comments on commit 250ea82

Please sign in to comment.