CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes
edm::EventSetupRecordDataGetter Class Reference
Inheritance diagram for edm::EventSetupRecordDataGetter:
edm::stream::EDAnalyzer<> edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (Event const &, EventSetup const &) override
 
void beginLuminosityBlock (LuminosityBlock const &, EventSetup const &) override
 
void beginRun (Run const &, EventSetup const &) override
 
 EventSetupRecordDataGetter (ParameterSet const &)
 
 ~EventSetupRecordDataGetter () override
 
- Public Member Functions inherited from edm::stream::EDAnalyzer<>
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Types

typedef std::map< eventsetup::EventSetupRecordKey, std::vector< eventsetup::DataKey > > RecordToDataKeys
 

Private Member Functions

void doGet (EventSetup const &)
 

Private Attributes

const ParameterSet pSet_
 
std::map< eventsetup::EventSetupRecordKey, unsigned long long > recordToCacheIdentifier_
 
RecordToDataKeys recordToDataKeys_
 
const bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 40 of file EventSetupRecordDataGetter.cc.

Member Typedef Documentation

Definition at line 56 of file EventSetupRecordDataGetter.cc.

Constructor & Destructor Documentation

EventSetupRecordDataGetter::EventSetupRecordDataGetter ( ParameterSet const &  iConfig)
explicit

Definition at line 65 of file EventSetupRecordDataGetter.cc.

66  : pSet_(iConfig),
69  verbose_(iConfig.getUntrackedParameter<bool>("verbose")) {}
std::map< eventsetup::EventSetupRecordKey, unsigned long long > recordToCacheIdentifier_
EventSetupRecordDataGetter::~EventSetupRecordDataGetter ( )
override

Definition at line 71 of file EventSetupRecordDataGetter.cc.

71  {
72  // do anything here that needs to be done at desctruction time
73  // (e.g. close files, deallocate resources etc.)
74  }

Member Function Documentation

void EventSetupRecordDataGetter::analyze ( edm::Event const &  ,
edm::EventSetup const &  iSetup 
)
overridevirtual

Implements edm::stream::EDAnalyzerBase.

Definition at line 119 of file EventSetupRecordDataGetter.cc.

References doGet().

119  {
120  doGet(iSetup);
121  }
void EventSetupRecordDataGetter::beginLuminosityBlock ( LuminosityBlock const &  ,
EventSetup const &  iSetup 
)
overridevirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 115 of file EventSetupRecordDataGetter.cc.

References doGet().

115  {
116  doGet(iSetup);
117  }
void EventSetupRecordDataGetter::beginRun ( Run const &  ,
EventSetup const &  iSetup 
)
overridevirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 113 of file EventSetupRecordDataGetter.cc.

References doGet().

113 { doGet(iSetup); }
void EventSetupRecordDataGetter::doGet ( EventSetup const &  iSetup)
private

Definition at line 123 of file EventSetupRecordDataGetter.cc.

References DEFINE_FWK_MODULE, edm::EventSetup::fillAvailableRecordKeys(), edm::EventSetup::find(), edm::eventsetup::heterocontainer::HCTypeTag::findType(), edm::ParameterSet::getParameterSetVector(), relativeConstraints::keys, pSet_, record, align_cfg::recordName, recordToCacheIdentifier_, recordToDataKeys_, AlCaHLTBitMon_QueryRunRegistry::string, DBConfiguration_cff::toGet, and verbose_.

Referenced by analyze(), beginLuminosityBlock(), and beginRun().

123  {
124  if (recordToDataKeys_.empty()) {
125  typedef std::vector<ParameterSet> Parameters;
126  Parameters const& toGet = pSet_.getParameterSetVector("toGet");
127 
128  for (Parameters::const_iterator itToGet = toGet.begin(), itToGetEnd = toGet.end(); itToGet != itToGetEnd;
129  ++itToGet) {
130  std::string recordName = itToGet->getParameter<std::string>("record");
131 
132  eventsetup::EventSetupRecordKey recordKey(eventsetup::EventSetupRecordKey::TypeTag::findType(recordName));
133  if (recordKey.type() == eventsetup::EventSetupRecordKey::TypeTag()) {
134  //record not found
135  edm::LogWarning("DataGetter") << "Record \"" << recordName << "\" does not exist " << std::endl;
136 
137  continue;
138  }
139  typedef std::vector<std::string> Strings;
140  Strings dataNames = itToGet->getParameter<Strings>("data");
141  std::vector<eventsetup::DataKey> dataKeys;
142  for (Strings::iterator itDatum = dataNames.begin(), itDatumEnd = dataNames.end(); itDatum != itDatumEnd;
143  ++itDatum) {
144  std::string datumName(*itDatum, 0, itDatum->find_first_of("/"));
145  std::string labelName;
146  if (itDatum->size() != datumName.size()) {
147  labelName = std::string(*itDatum, datumName.size() + 1);
148  }
149  eventsetup::TypeTag datumType = eventsetup::TypeTag::findType(datumName);
150  if (datumType == eventsetup::TypeTag()) {
151  //not found
152  edm::LogWarning("DataGetter") << "data item of type \"" << datumName << "\" does not exist" << std::endl;
153 
154  continue;
155  }
156  eventsetup::DataKey datumKey(datumType, labelName.c_str());
157  dataKeys.push_back(datumKey);
158  }
159  recordToDataKeys_.insert(std::make_pair(recordKey, dataKeys));
160  recordToCacheIdentifier_.insert(std::make_pair(recordKey, 0));
161  }
162  if (toGet.empty()) {
163  //This means we should get everything in the EventSetup
164  std::vector<eventsetup::EventSetupRecordKey> recordKeys;
165  iSetup.fillAvailableRecordKeys(recordKeys);
166  std::vector<eventsetup::DataKey> dataKeys;
167 
168  for (std::vector<eventsetup::EventSetupRecordKey>::iterator itRKey = recordKeys.begin(),
169  itRKeyEnd = recordKeys.end();
170  itRKey != itRKeyEnd;
171  ++itRKey) {
172  auto record = iSetup.find(*itRKey);
173  assert(record);
174  dataKeys.clear();
175  record->fillRegisteredDataKeys(dataKeys);
176  recordToDataKeys_.insert(std::make_pair(*itRKey, dataKeys));
177  recordToCacheIdentifier_.insert(std::make_pair(*itRKey, 0));
178  }
179  }
180  }
181 
182  using namespace edm::eventsetup;
183 
184  //For each requested Record get the requested data only if the Record is in a new IOV
185 
186  for (RecordToDataKeys::iterator itRecord = recordToDataKeys_.begin(), itRecordEnd = recordToDataKeys_.end();
187  itRecord != itRecordEnd;
188  ++itRecord) {
189  auto pRecord = iSetup.find(itRecord->first);
190  if (not pRecord) {
191  edm::LogWarning("RecordNotInIOV")
192  << "The EventSetup Record '" << itRecord->first.name() << "' is not available for this IOV.";
193  }
194  if (pRecord.has_value() && pRecord->cacheIdentifier() != recordToCacheIdentifier_[itRecord->first]) {
195  recordToCacheIdentifier_[itRecord->first] = pRecord->cacheIdentifier();
196  typedef std::vector<DataKey> Keys;
197  Keys const& keys = itRecord->second;
198  for (Keys::const_iterator itKey = keys.begin(), itKeyEnd = keys.end(); itKey != itKeyEnd; ++itKey) {
199  if (!pRecord->doGet(*itKey)) {
200  edm::LogWarning("DataGetter")
201  << "No data of type \"" << itKey->type().name() << "\" with name \"" << itKey->name().value()
202  << "\" in record " << itRecord->first.type().name() << " found " << std::endl;
203  } else {
204  if (verbose_) {
205  edm::LogSystem("DataGetter")
206  << "got data of type \"" << itKey->type().name() << "\" with name \"" << itKey->name().value()
207  << "\" in record " << itRecord->first.type().name() << std::endl;
208  }
209  }
210  }
211  }
212  }
213  }
VParameterSet const & getParameterSetVector(std::string const &name) const
JetCorrectorParameters::Record record
Definition: classes.h:7
EventSelector::Strings Strings
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
vector< ParameterSet > Parameters
heterocontainer::HCTypeTag TypeTag
Definition: DataKeyTags.h:30
std::map< eventsetup::EventSetupRecordKey, unsigned long long > recordToCacheIdentifier_
std::vector< size_type > Keys
heterocontainer::HCTypeTag TypeTag
void EventSetupRecordDataGetter::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 81 of file EventSetupRecordDataGetter.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::addVPSet(), edm::ConfigurationDescriptions::setComment(), edm::ParameterDescriptionNode::setComment(), AlCaHLTBitMon_QueryRunRegistry::string, and DBConfiguration_cff::toGet.

81  {
82  descriptions.setComment("Retrieves specified data from the EventSetup sytem whenever that data changes.");
83 
85  desc.addUntracked<bool>("verbose", false)
86  ->setComment("Print a message to the logger each time a data item is gotten.");
87 
89  toGet.add<std::string>("record")->setComment(
90  "The name of an EventSetup record holding the data you want obtained.");
91  toGet.add<std::vector<std::string> >("data")->setComment(
92  "The identifier for the data you wish to retrieve. "
93  "The identifier is in two parts separated by a backslash '/'. "
94  "The first part is the C++ class name of the data and the "
95  "second part is the label used when getting the data (blank is acceptable). "
96  "If there is no label, the backslash may be omitted.");
97 
98  std::vector<edm::ParameterSet> emptyVect;
99  desc.addVPSet("toGet", toGet, emptyVect)
100  ->setComment(
101  "The contained PSets must have the following structure.\n"
102  "A 'string' named 'record' that holds the name of an EventSetup record holding the data you want to "
103  "obtain.\n"
104  "a 'vstring' named 'data' that holds identifiers for the data you wish to retrieve. "
105  "The identifier is in two parts separated by a backslash '/'. "
106  "The first part is the C++ class name of the data and the "
107  "second part is the label used when getting the data (blank is acceptable). "
108  "If there is no label, the backslash may be omitted.\n"
109  "If the VPSet is empty it means all data in the EventSetup should be retrieved.");
110  descriptions.add("getEventSetupData", desc);
111  }

Member Data Documentation

const ParameterSet edm::EventSetupRecordDataGetter::pSet_
private

Definition at line 54 of file EventSetupRecordDataGetter.cc.

Referenced by doGet().

std::map<eventsetup::EventSetupRecordKey, unsigned long long> edm::EventSetupRecordDataGetter::recordToCacheIdentifier_
private

Definition at line 58 of file EventSetupRecordDataGetter.cc.

Referenced by doGet().

RecordToDataKeys edm::EventSetupRecordDataGetter::recordToDataKeys_
private

Definition at line 57 of file EventSetupRecordDataGetter.cc.

Referenced by doGet().

const bool edm::EventSetupRecordDataGetter::verbose_
private

Definition at line 59 of file EventSetupRecordDataGetter.cc.

Referenced by doGet().