Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

access per event per product parameter sets #580

Merged
merged 1 commit into from Aug 21, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.cc
Expand Up @@ -3,7 +3,7 @@
// user include files

#include "Calibration/HcalAlCaRecoProducers/src/ProducerAnalyzer.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "FWCore/Common/interface/Provenance.h"
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
Expand Down Expand Up @@ -88,7 +88,7 @@ ProducerAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetu
for( std::vector<Provenance const*>::const_iterator ip = theProvenance.begin();
ip != theProvenance.end(); ip++)
{
cout<<" Print all module/label names "<<(**ip).moduleName()<<" "<<(**ip).moduleLabel()<<
cout<<" Print all module/label names "<<moduleName(**ip)<<" "<<(**ip).moduleLabel()<<
" "<<(**ip).productInstanceName()<<endl;
}

Expand Down
27 changes: 1 addition & 26 deletions DataFormats/Provenance/interface/BranchDescription.h
Expand Up @@ -104,20 +104,6 @@ namespace edm {
ParameterSetID const& parameterSetID() const {return transient_.parameterSetID_;}
std::string const& moduleName() const {return transient_.moduleName_;}

std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {
return transient_.parameterSetIDs_;
}
void insertParameterSetID(std::pair<ProcessConfigurationID, ParameterSetID> const& entry) {
transient_.parameterSetIDs_.insert(entry);
}
std::map<ProcessConfigurationID, std::string> const& moduleNames() const {
return transient_.moduleNames_;
}
void insertModuleName(std::pair<ProcessConfigurationID, std::string> const& entry) {
transient_.moduleNames_.insert(entry);
}
ParameterSetID const& psetID() const;
bool isPsetIDUnique() const {return parameterSetIDs().size() == 1;}
std::set<std::string> const& branchAliases() const {return branchAliases_;}
void insertBranchAlias(std::string const& alias) {
branchAliases_.insert(alias);
Expand Down Expand Up @@ -165,16 +151,6 @@ namespace edm {
// This item is set only in the framework, not by FWLite.
bool dropped_;

// ID's of process configurations for products on this branch
// with corresponding parameter set IDs,
// This is initialized if and only if produced_ is false.
std::map<ProcessConfigurationID, ParameterSetID> parameterSetIDs_;

// ID's of process configurations for products on this branch
// with corresponding module names
// This is initialized if and only if produced_ is false.
std::map<ProcessConfigurationID, std::string> moduleNames_;

// Is the class of the branch marked as transient
// in the data dictionary
bool transient_;
Expand Down Expand Up @@ -249,7 +225,6 @@ namespace edm {

std::string match(BranchDescription const& a,
BranchDescription const& b,
std::string const& fileName,
BranchDescription::MatchMode m);
std::string const& fileName);
}
#endif
2 changes: 1 addition & 1 deletion DataFormats/Provenance/interface/ModuleDescription.h
Expand Up @@ -54,7 +54,7 @@ namespace edm {
///If the id is invalid, will return the max unsigned int value.
unsigned int id() const {return id_;}
ProcessConfiguration const& processConfiguration() const;
ProcessConfigurationID processConfigurationID() const;

std::string const& processName() const;
std::string const& releaseVersion() const;
std::string const& passID() const;
Expand Down
1 change: 0 additions & 1 deletion DataFormats/Provenance/interface/ProductRegistry.h
Expand Up @@ -51,7 +51,6 @@ namespace edm {

std::string merge(ProductRegistry const& other,
std::string const& fileName,
BranchDescription::MatchMode parametersMustMatch = BranchDescription::Permissive,
BranchDescription::MatchMode branchesMustMatch = BranchDescription::Permissive);

void updateFromInput(ProductList const& other);
Expand Down
9 changes: 0 additions & 9 deletions DataFormats/Provenance/interface/Provenance.h
Expand Up @@ -65,16 +65,7 @@ namespace edm {
boost::shared_ptr<BranchMapper> const& store() const {return store_;}
ProcessHistoryID const& processHistoryID() const {return *processHistoryID_;}
bool getProcessConfiguration(ProcessConfiguration& pc) const;
ProcessConfigurationID processConfigurationID() const;
ParameterSetID psetID() const;
std::string moduleName() const;
ReleaseVersion releaseVersion() const;
std::map<ProcessConfigurationID, ParameterSetID> const& parameterSetIDs() const {
return product().parameterSetIDs();
}
std::map<ProcessConfigurationID, std::string> const& moduleNames() const {
return product().moduleNames();
}
std::set<std::string> const& branchAliases() const {return product().branchAliases();}

std::vector<BranchID> const& parents() const {return parentage().parents();}
Expand Down
35 changes: 1 addition & 34 deletions DataFormats/Provenance/src/BranchDescription.cc
Expand Up @@ -25,8 +25,6 @@ namespace edm {
produced_(false),
onDemand_(false),
dropped_(false),
parameterSetIDs_(),
moduleNames_(),
transient_(false),
wrappedType_(),
unwrappedType_(),
Expand Down Expand Up @@ -211,22 +209,8 @@ namespace edm {
}
}

ParameterSetID const&
BranchDescription::psetID() const {
assert(!parameterSetIDs().empty());
if(parameterSetIDs().size() != 1) {
throw cms::Exception("Ambiguous")
<< "Your application requires all events on Branch '" << branchName()
<< "'\n to have the same provenance. This file has events with mixed provenance\n"
<< "on this branch. Use a different input file.\n";
}
return parameterSetIDs().begin()->second;
}

void
BranchDescription::merge(BranchDescription const& other) {
transient_.parameterSetIDs_.insert(other.parameterSetIDs().begin(), other.parameterSetIDs().end());
transient_.moduleNames_.insert(other.moduleNames().begin(), other.moduleNames().end());
branchAliases_.insert(other.branchAliases().begin(), other.branchAliases().end());
if(splitLevel() == invalidSplitLevel) setSplitLevel(other.splitLevel());
if(basketSize() == invalidBasketSize) setBasketSize(other.basketSize());
Expand Down Expand Up @@ -295,10 +279,6 @@ namespace edm {
if(b.branchType() < a.branchType()) return false;
if(a.branchID() < b.branchID()) return true;
if(b.branchID() < a.branchID()) return false;
if(a.parameterSetIDs() < b.parameterSetIDs()) return true;
if(b.parameterSetIDs() < a.parameterSetIDs()) return false;
if(a.moduleNames() < b.moduleNames()) return true;
if(b.moduleNames() < a.moduleNames()) return false;
if(a.branchAliases() < b.branchAliases()) return true;
if(b.branchAliases() < a.branchAliases()) return false;
if(a.present() < b.present()) return true;
Expand All @@ -322,15 +302,12 @@ namespace edm {
operator==(BranchDescription const& a, BranchDescription const& b) {
return combinable(a, b) &&
(a.dropped() == b.dropped()) &&
(a.moduleNames() == b.moduleNames()) &&
(a.parameterSetIDs() == b.parameterSetIDs()) &&
(a.branchAliases() == b.branchAliases());
}

std::string
match(BranchDescription const& a, BranchDescription const& b,
std::string const& fileName,
BranchDescription::MatchMode m) {
std::string const& fileName) {
std::ostringstream differences;
if(a.branchName() != b.branchName()) {
differences << "Branch name '" << b.branchName() << "' does not match '" << a.branchName() << "'.\n";
Expand All @@ -355,16 +332,6 @@ namespace edm {
if(!b.dropped() && a.dropped()) {
differences << "Branch '" << a.branchName() << "' was dropped in the first input file but is present in '" << fileName << "'.\n";
}
if(m == BranchDescription::Strict) {
if(b.parameterSetIDs().size() > 1) {
differences << "Branch '" << b.branchName() << "' uses more than one parameter set in file '" << fileName << "'.\n";
} else if(a.parameterSetIDs().size() > 1) {
differences << "Branch '" << a.branchName() << "' uses more than one parameter set in previous files.\n";
} else if(a.parameterSetIDs() != b.parameterSetIDs()) {
differences << "Branch '" << b.branchName() << "' uses different parameter sets in file '" << fileName << "'.\n";
differences << " than in previous files.\n";
}
}
return differences.str();
}

Expand Down
5 changes: 0 additions & 5 deletions DataFormats/Provenance/src/ModuleDescription.cc
Expand Up @@ -54,11 +54,6 @@ namespace edm {
return *processConfigurationPtr_;
}

ProcessConfigurationID
ModuleDescription::processConfigurationID() const {
return processConfiguration().id();
}

std::string const&
ModuleDescription::processName() const {
return processConfiguration().processName();
Expand Down
5 changes: 2 additions & 3 deletions DataFormats/Provenance/src/ProductRegistry.cc
Expand Up @@ -214,7 +214,6 @@ namespace edm {
std::string
ProductRegistry::merge(ProductRegistry const& other,
std::string const& fileName,
BranchDescription::MatchMode parametersMustMatch,
BranchDescription::MatchMode branchesMustMatch) {
std::ostringstream differences;

Expand Down Expand Up @@ -245,9 +244,9 @@ namespace edm {
}
++j;
} else {
std::string difs = match(j->second, i->second, fileName, parametersMustMatch);
std::string difs = match(j->second, i->second, fileName);
if(difs.empty()) {
if(parametersMustMatch == BranchDescription::Permissive) j->second.merge(i->second);
j->second.merge(i->second);
} else {
differences << difs;
}
Expand Down
60 changes: 4 additions & 56 deletions DataFormats/Provenance/src/Provenance.cc
Expand Up @@ -3,6 +3,8 @@
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Provenance/interface/ProcessHistoryRegistry.h"
#include "DataFormats/Provenance/interface/ProductProvenance.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/Registry.h"

#include <algorithm>

Expand All @@ -27,7 +29,7 @@ namespace edm {
ProductProvenance*
Provenance::resolve() const {
if(!store_) {
return 0;
return nullptr;
}
if (!productProvenanceValid_) {
ProductProvenance const* prov = store_->branchIDToProvenance(branchDescription_->branchID());
Expand All @@ -39,28 +41,6 @@ namespace edm {
return productProvenancePtr_.get();
}

ProcessConfigurationID
Provenance::processConfigurationID() const {
if (parameterSetIDs().size() == 1) {
return parameterSetIDs().begin()->first;
}
if (moduleNames().size() == 1) {
return moduleNames().begin()->first;
}
// Get the ProcessHistory for this event.
ProcessHistoryRegistry* phr = ProcessHistoryRegistry::instance();
ProcessHistory ph;
if (!phr->getMapped(processHistoryID(), ph)) {
return ProcessConfigurationID();
}

ProcessConfiguration config;
if (!ph.getConfigurationForProcess(processName(), config)) {
return ProcessConfigurationID();
}
return config.id();
}

bool
Provenance::getProcessConfiguration(ProcessConfiguration& pc) const {
// Get the ProcessHistory for this event.
Expand All @@ -79,45 +59,13 @@ namespace edm {
return pc.releaseVersion();
}

ParameterSetID
Provenance::psetID() const {
if (product().parameterSetID().isValid()) {
return product().parameterSetID();
}
if (parameterSetIDs().size() == 1) {
return parameterSetIDs().begin()->second;
}
std::map<ProcessConfigurationID, ParameterSetID>::const_iterator it =
parameterSetIDs().find(processConfigurationID());
if (it == parameterSetIDs().end()) {
return ParameterSetID();
}
return it->second;
}

std::string
Provenance::moduleName() const {
if (!product().moduleName().empty()) {
return product().moduleName();
}
if (moduleNames().size() == 1) {
return moduleNames().begin()->second;
}
std::map<ProcessConfigurationID, std::string>::const_iterator it =
moduleNames().find(processConfigurationID());
if (it == moduleNames().end()) {
return std::string();
}
return it->second;
}

void
Provenance::write(std::ostream& os) const {
// This is grossly inadequate, but it is not critical for the
// first pass.
product().write(os);
ProductProvenance* pp = productProvenance();
if (pp != 0) {
if (pp != nullptr) {
pp->write(os);
}
}
Expand Down
3 changes: 0 additions & 3 deletions DataFormats/Streamer/interface/StreamedProducts.h
Expand Up @@ -110,18 +110,15 @@ namespace edm {
SendDescs const& descs() const {return descs_;}
ParameterSetMap const& processParameterSet() const {return processParameterSet_;}
BranchIDLists const& branchIDLists() const {return branchIDLists_;}
std::vector<ProcessConfiguration> const& processConfigurations() const {return processConfigurations_;}
void push_back(BranchDescription const& bd) {descs_.push_back(bd);}
void setParameterSetMap(ParameterSetMap const& psetMap) {processParameterSet_ = psetMap;}
void setBranchIDLists(BranchIDLists const& bidlists) {branchIDLists_ = bidlists;}
void setProcessConfigurations(std::vector<ProcessConfiguration> const& pcs) {processConfigurations_ = pcs;}
void initializeTransients();

private:
SendDescs descs_;
ParameterSetMap processParameterSet_;
BranchIDLists branchIDLists_;
std::vector<ProcessConfiguration> processConfigurations_;
// trigger bit descriptions will be added here and permanent
// provenance values
};
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Streamer/src/classes_def.xml
Expand Up @@ -10,7 +10,7 @@
<version ClassVersion="10" checksum="747121728"/>
</class>
<class name="edm::SendJobHeader" ClassVersion="10">
<version ClassVersion="10" checksum="442578358"/>
<version ClassVersion="10" checksum="1238072397"/>
</class>
<class name="std::vector<edm::BranchDescription>"/>
</lcgdict>
Expand Down
1 change: 1 addition & 0 deletions FWCore/Common/BuildFile.xml
@@ -1,3 +1,4 @@
<use name="DataFormats/Provenance"/>
<use name="FWCore/ParameterSet"/>
<use name="FWCore/Utilities"/>
<export>
Expand Down
12 changes: 12 additions & 0 deletions FWCore/Common/interface/Provenance.h
@@ -0,0 +1,12 @@
#ifndef FWCore_Common_Provenance_h
#define FWCore_Common_Provenance_h

#include <string>
#include "DataFormats/Provenance/interface/Provenance.h"

namespace edm {
class ParameterSet;
std::string moduleName(Provenance const& provenance);
ParameterSet const& parameterSet(Provenance const& provenance);
}
#endif
34 changes: 34 additions & 0 deletions FWCore/Common/src/Provenance.cc
@@ -0,0 +1,34 @@
#include "FWCore/Common/interface/Provenance.h"
#include "DataFormats/Provenance/interface/ProcessConfiguration.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/Registry.h"

namespace edm {
static std::string const triggerResults("TriggerResults");
static std::string const source("source");
static std::string const triggerResultsInserter("TriggerResultsInserter");

ParameterSet const& parameterSet(Provenance const& provenance) {
ProcessConfiguration pc;
provenance.getProcessConfiguration(pc);
ParameterSet const& processParameterSet = *pset::Registry::instance()->getMapped(pc.parameterSetID());
std::string const& label = provenance.moduleLabel();
if (!processParameterSet.existsAs<ParameterSet>(label)) {
// Trigger results and input sources are special cases
if(label == triggerResults) {
return processParameterSet.getParameterSet("@trigger_paths");
} else if(label == source) {
return processParameterSet.getParameterSet("@main_input");
}
}
return processParameterSet.getParameterSet(label);
}

std::string moduleName(Provenance const& provenance) {
// Trigger results ia a special case
if(provenance.moduleLabel() == triggerResults) {
return triggerResultsInserter;
}
return parameterSet(provenance).getParameter<std::string>("@module_type");
}
}
2 changes: 1 addition & 1 deletion FWCore/Framework/interface/ProductHolder.h
Expand Up @@ -13,7 +13,7 @@ a set of related EDProducts. This is the storage unit of such information.
#include "DataFormats/Common/interface/WrapperOwningHolder.h"
#include "DataFormats/Provenance/interface/BranchDescription.h"
#include "DataFormats/Provenance/interface/BranchID.h"
#include "DataFormats/Provenance/interface/Provenance.h"
#include "FWCore/Common/interface/Provenance.h"
#include "FWCore/Utilities/interface/ProductHolderIndex.h"
#include "FWCore/Utilities/interface/TypeID.h"

Expand Down