CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
CondHDF5ESSource Class Reference
Inheritance diagram for CondHDF5ESSource:
edm::EventSetupRecordIntervalFinder edm::eventsetup::ESProductResolverProvider

Public Types

using EventSetupRecordKey = edm::eventsetup::EventSetupRecordKey
 

Public Member Functions

 CondHDF5ESSource (edm::ParameterSet const &)
 
- Public Member Functions inherited from edm::EventSetupRecordIntervalFinder
bool concurrentFinder () const
 
const eventsetup::ComponentDescriptiondescriptionForFinder () const
 
 EventSetupRecordIntervalFinder ()
 
 EventSetupRecordIntervalFinder (const EventSetupRecordIntervalFinder &)=delete
 
std::set< eventsetup::EventSetupRecordKeyfindingForRecords () const
 
const ValidityIntervalfindIntervalFor (const eventsetup::EventSetupRecordKey &, const IOVSyncValue &)
 
bool nonconcurrentAndIOVNeedsUpdate (const eventsetup::EventSetupRecordKey &key, const IOVSyncValue &syncValue) const
 
const EventSetupRecordIntervalFinderoperator= (const EventSetupRecordIntervalFinder &)=delete
 
void resetInterval (const eventsetup::EventSetupRecordKey &)
 
void setDescriptionForFinder (const eventsetup::ComponentDescription &iDescription)
 
virtual ~EventSetupRecordIntervalFinder () noexcept(false)
 
- Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
void createKeyedResolvers (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
const ComponentDescriptiondescription () const
 
 ESProductResolverProvider ()
 
 ESProductResolverProvider (const ESProductResolverProvider &)=delete
 
void fillRecordsNotAllowingConcurrentIOVs (std::set< EventSetupRecordKey > &recordsNotAllowingConcurrentIOVs) const
 
virtual void initConcurrentIOVs (EventSetupRecordKey const &key, unsigned int nConcurrentIOVs)
 
bool isUsingRecord (const EventSetupRecordKey &key) const
 
KeyedResolverskeyedResolvers (const EventSetupRecordKey &iRecordKey, unsigned int iovIndex=0)
 
const ESProductResolverProvideroperator= (const ESProductResolverProvider &)=delete
 
void setAppendToDataLabel (const edm::ParameterSet &)
 
void setDescription (const ComponentDescription &iDescription)
 
virtual void updateLookup (ESRecordsToProductResolverIndices const &)
 
std::set< EventSetupRecordKeyusingRecords () const
 
virtual ~ESProductResolverProvider () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::eventsetup::ESProductResolverProvider
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

bool isConcurrentFinder () const final
 
KeyedResolversVector registerResolvers (EventSetupRecordKey const &, unsigned int iovIndex) final
 
void setIntervalFor (EventSetupRecordKey const &, edm::IOVSyncValue const &, edm::ValidityInterval &) final
 

Private Attributes

Compression compression_ = Compression::kNone
 
cms::h5::File file_
 
std::string filename_
 
std::mutex mutex_
 
edm::SerialTaskQueue queue_
 
std::vector< Recordrecords_
 

Additional Inherited Members

- Protected Types inherited from edm::eventsetup::ESProductResolverProvider
using KeyedResolversVector = std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >>
 
- Protected Member Functions inherited from edm::EventSetupRecordIntervalFinder
template<class T >
void findingRecord ()
 
void findingRecordWithKey (const eventsetup::EventSetupRecordKey &)
 
- Protected Member Functions inherited from edm::eventsetup::ESProductResolverProvider
template<class T >
void usingRecord ()
 
void usingRecordWithKey (const EventSetupRecordKey &key)
 

Detailed Description

Definition at line 44 of file CondHDF5ESSource.cc.

Member Typedef Documentation

◆ EventSetupRecordKey

Definition at line 46 of file CondHDF5ESSource.cc.

Constructor & Destructor Documentation

◆ CondHDF5ESSource()

CondHDF5ESSource::CondHDF5ESSource ( edm::ParameterSet const &  iPSet)
explicit

Definition at line 89 of file CondHDF5ESSource.cc.

References cms::cuda::assert(), cms::h5::File::derefGroup(), file_, cms::h5::File::findGroup(), edm::EventSetupRecordIntervalFinder::findingRecordWithKey(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), get, edm::ParameterSet::getParameter(), mps_fire::i, submitPVResolutionJobs::key, MainPageGenerator::l, eostools::move(), Skims_PA_cff::name, alignCSCRings::r, AlCaHarvesting_cff::record, records_, jetUpdater_cfi::sort, AlCaHLTBitMon_QueryRunRegistry::string, submitPVValidationJobs::t, triggerMatcherToHLTDebug_cfi::tags, dqmiodumpindices::typeName, and edm::eventsetup::ESProductResolverProvider::usingRecordWithKey().

90  : filename_(iPSet.getUntrackedParameter<std::string>("filename")),
92  compression_(nameToEnum(file_.findAttribute("default_payload_compressor")->readString())) {
93  const auto globalTagsGroup = file_.findGroup("GlobalTags");
94  const auto chosenTag = globalTagsGroup->findGroup(iPSet.getParameter<std::string>("globalTag"));
95  const auto tagsDataSet = chosenTag->findDataSet("Tags");
96  const auto recordsGroup = file_.findGroup("Records");
97 
98  std::vector<hobj_ref_t> tags = tagsDataSet->readRefs();
99 
100  std::set<std::string> recordsToExclude;
101  {
102  auto exclude = iPSet.getParameter<std::vector<std::string>>("excludeRecords");
103  recordsToExclude = std::set(exclude.begin(), exclude.end());
104  }
105 
106  for (auto t : tags) {
107  auto tagGroup = file_.derefGroup(t);
108  Record record;
109  record.name_ = tagGroup->findAttribute("record")->readString();
110  //std::cout << record.name_ << std::endl;
111 
112  if (recordsToExclude.end() != recordsToExclude.find(record.name_)) {
113  //std::cout << "excluding " << record.name_ << std::endl;
114  continue;
115  }
116 
117  auto recordGroup = recordsGroup->findGroup(record.name_);
118  //std::cout << "found record group" << std::endl;
119  auto dataProductsGroup = recordGroup->findGroup("DataProducts");
120  //std::cout << "found DataProducts group" << std::endl;
121 
122  for (size_t i = 0; i < dataProductsGroup->getNumObjs(); ++i) {
123  std::string productGroupName = dataProductsGroup->getObjnameByIdx(i);
124  //std::cout << "looking for " << productGroupName << std::endl;
125  auto dataProductGroup = dataProductsGroup->findGroup(productGroupName);
126 
127  auto const typeAttr = dataProductGroup->findAttribute("type");
128  std::string typeName = typeAttr->readString();
129  //loading the factory should also trigger registering the Record and DataProduct keys
131  std::string name = productGroupName.substr(typeName.size() + 1, productGroupName.size());
132  if (name.size() == 1 and name[0] == '-') {
133  name = std::string();
134  }
135  record.dataProducts_.emplace_back(std::move(name), std::move(typeName));
136  }
137 
138  {
139  auto const typeAttr = tagGroup->findAttribute("time_type");
140  std::string typeName = typeAttr->readString();
141  record.iovIsRunLumi_ = (typeName == "run_lumi");
142  }
143 
144  std::vector<hobj_ref_t> payloadRefForIOVs;
145  {
146  auto const firstDataSet = tagGroup->findDataSet("first");
147  auto const lastDataSet = tagGroup->findDataSet("last");
148 
149  record.iovFirsts_ = firstDataSet->readSyncValues();
150  record.iovLasts_ = lastDataSet->readSyncValues();
151 
152  {
153  auto const payloadDataSet = tagGroup->findDataSet("payload");
154  payloadRefForIOVs = payloadDataSet->readRefs();
155  assert(payloadRefForIOVs.size() == record.iovFirsts_.size() * record.dataProducts_.size());
156  }
157  }
158  size_t dataProductIndex = 0;
159  for (auto r : payloadRefForIOVs) {
160  record.dataProducts_[dataProductIndex].payloadForIOVs_.push_back(r);
161  ++dataProductIndex;
162  if (dataProductIndex >= record.dataProducts_.size()) {
163  dataProductIndex = 0;
164  }
165  }
166 
167  //now that we've loaded a plugin that is associated to the record, the record should be registered
168  auto key =
171  //tell system we retrieve this Record
174 
175  records_.emplace_back(std::move(record));
176  }
177  std::sort(records_.begin(), records_.end(), [](auto const& l, auto const& r) { return l.name_ < r.name_; });
178 }
std::string filename_
std::shared_ptr< Group > derefGroup(hobj_ref_t iRef) const
Definition: h5_File.cc:75
std::vector< Record > records_
void usingRecordWithKey(const EventSetupRecordKey &key)
assert(be >=bs)
std::shared_ptr< Group > findGroup(std::string const &iName) const
Definition: h5_File.cc:66
key
prepare the HTCondor submission files and eventually submit them
std::shared_ptr< Attribute > findAttribute(std::string const &iName) const
Definition: h5_File.cc:71
cms::h5::File file_
#define get
Compression compression_
def move(src, dest)
Definition: eostools.py:511
void findingRecordWithKey(const eventsetup::EventSetupRecordKey &)
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121

Member Function Documentation

◆ fillDescriptions()

void CondHDF5ESSource::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 180 of file CondHDF5ESSource.cc.

References edm::ConfigurationDescriptions::addDefault(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

180  {
182  desc.addUntracked<std::string>("filename")->setComment("HDF5 file containing the conditions");
183  desc.add<std::string>("globalTag")->setComment("Which global tag to use from the file");
184  desc.add<std::vector<std::string>>("excludeRecords", std::vector<std::string>())
185  ->setComment("List of Records that should not be read from the file");
186 
187  descriptions.addDefault(desc);
188 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ isConcurrentFinder()

bool CondHDF5ESSource::isConcurrentFinder ( ) const
inlinefinalprivatevirtual

Reimplemented from edm::EventSetupRecordIntervalFinder.

Definition at line 52 of file CondHDF5ESSource.cc.

52 { return true; }

◆ registerResolvers()

CondHDF5ESSource::KeyedResolversVector CondHDF5ESSource::registerResolvers ( EventSetupRecordKey const &  iRecordKey,
unsigned int  iovIndex 
)
finalprivatevirtual

Implements edm::eventsetup::ESProductResolverProvider.

Definition at line 214 of file CondHDF5ESSource.cc.

References cms::cuda::assert(), compression_, file_, filename_, edm::eventsetup::heterocontainer::HCTypeTag::findType(), get, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, eostools::move(), edm::eventsetup::EventSetupRecordKey::name(), queue_, AlCaHarvesting_cff::record, and records_.

215  {
217 
218  //std::cout << "Register proxies called " << iRecordKey.name() << std::endl;
219  auto const itRecord =
220  std::lower_bound(records_.begin(), records_.end(), iRecordKey.name(), [](auto const& iE, auto const& iV) {
221  return iE.name_ < iV;
222  });
223  assert(itRecord != records_.end());
224  auto const& record = *itRecord;
225  assert(record.name_ == iRecordKey.name());
226  for (auto const& dataProduct : record.dataProducts_) {
227  //std::cout << "Making DataProduct " << dataProduct.type_ << " '" << dataProduct.name_ << "' for Record "
228  // << record.name_ << std::endl;
229  auto helper = cond::serialization::SerializationHelperFactory::get()->create(dataProduct.type_);
230  returnValue.emplace_back(
232  dataProduct.name_.c_str()),
233  std::make_shared<HDF5ProductResolver>(
234  &queue_, std::move(helper), &file_, filename_, compression_, &record, &dataProduct));
235  }
236  return returnValue;
237 }
std::string filename_
Definition: helper.py:1
std::vector< Record > records_
assert(be >=bs)
edm::SerialTaskQueue queue_
cms::h5::File file_
std::vector< std::pair< DataKey, std::shared_ptr< ESProductResolver > >> KeyedResolversVector
#define get
Compression compression_
def move(src, dest)
Definition: eostools.py:511
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
Definition: HCTypeTag.cc:121

◆ setIntervalFor()

void CondHDF5ESSource::setIntervalFor ( EventSetupRecordKey const &  iRecordKey,
edm::IOVSyncValue const &  iSync,
edm::ValidityInterval iIOV 
)
finalprivatevirtual

Implements edm::EventSetupRecordIntervalFinder.

Definition at line 190 of file CondHDF5ESSource.cc.

References cms::cuda::assert(), cond::hdf5::convertSyncValue(), cond::hdf5::findMatchingFirst(), edm::ValidityInterval::invalidInterval(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, edm::eventsetup::EventSetupRecordKey::name(), AlCaHarvesting_cff::record, and records_.

192  {
193  using namespace cond::hdf5;
194 
195  auto const itRecord =
196  std::lower_bound(records_.begin(), records_.end(), iRecordKey.name(), [](auto const& iE, auto const& iV) {
197  return iE.name_ < iV;
198  });
199  assert(itRecord != records_.end());
200  auto const& record = *itRecord;
201  assert(record.name_ == iRecordKey.name());
202  auto sync = convertSyncValue(iSync, record.iovIsRunLumi_);
203  auto itFound = findMatchingFirst(record.iovFirsts_, sync);
204  if (itFound == record.iovFirsts_.end()) {
205  //std::cout << "BAD SYNC for record " << iRecordKey.name() << std::endl;
207  return;
208  }
209  iIOV = edm::ValidityInterval{
210  convertSyncValue(*itFound, record.iovIsRunLumi_),
211  convertSyncValue(record.iovLasts_[itFound - record.iovFirsts_.begin()], record.iovIsRunLumi_)};
212 }
std::vector< Record > records_
assert(be >=bs)
std::vector< IOVSyncValue >::const_iterator findMatchingFirst(std::vector< IOVSyncValue > const &iIOVs, IOVSyncValue iMatch)
Definition: IOVSyncValue.cc:19
static const ValidityInterval & invalidInterval()
IOVSyncValue convertSyncValue(edm::IOVSyncValue const &iFrom, bool iIsRunLumi)

Member Data Documentation

◆ compression_

Compression CondHDF5ESSource::compression_ = Compression::kNone
private

Definition at line 61 of file CondHDF5ESSource.cc.

Referenced by registerResolvers().

◆ file_

cms::h5::File CondHDF5ESSource::file_
private

Definition at line 60 of file CondHDF5ESSource.cc.

Referenced by CondHDF5ESSource(), and registerResolvers().

◆ filename_

std::string CondHDF5ESSource::filename_
private

Definition at line 59 of file CondHDF5ESSource.cc.

Referenced by registerResolvers().

◆ mutex_

std::mutex CondHDF5ESSource::mutex_
private

Definition at line 57 of file CondHDF5ESSource.cc.

◆ queue_

edm::SerialTaskQueue CondHDF5ESSource::queue_
private

Definition at line 56 of file CondHDF5ESSource.cc.

Referenced by registerResolvers().

◆ records_

std::vector<Record> CondHDF5ESSource::records_
private

Definition at line 58 of file CondHDF5ESSource.cc.

Referenced by CondHDF5ESSource(), registerResolvers(), and setIntervalFor().