Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <iostream>
00015
00016
00017 #include "FWCore/Services/src/PrintEventSetupDataRetrieval.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "FWCore/Framework/interface/EventSetup.h"
00020 #include "FWCore/Framework/interface/EventSetupRecord.h"
00021 #include "FWCore/Framework/interface/ComponentDescription.h"
00022 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00023 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00024
00025 namespace edm {
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval(const ParameterSet& iPS,
00038 ActivityRegistry&iRegistry):
00039 m_printProviders(iPS.getUntrackedParameter<bool>("printProviders"))
00040 {
00041 if(iPS.getUntrackedParameter<bool>("checkAfterBeginRun")) {
00042 iRegistry.watchPostBeginRun(this, &PrintEventSetupDataRetrieval::postBeginRun);
00043 }
00044 if(iPS.getUntrackedParameter<bool>("checkAfterBeginLumi")) {
00045 iRegistry.watchPostBeginLumi(this, &PrintEventSetupDataRetrieval::postBeginLumi);
00046 }
00047 if(iPS.getUntrackedParameter<bool>("checkAfterEvent")) {
00048 iRegistry.watchPostProcessEvent(this, &PrintEventSetupDataRetrieval::postProcessEvent);
00049 }
00050 }
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 void PrintEventSetupDataRetrieval::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
00062 edm::ParameterSetDescription desc;
00063 desc.addUntracked<bool>("printProviders",false)->setComment(
00064 "If 'true' also print which ES module provides the data");
00065 desc.addUntracked<bool>("checkAfterBeginRun",false)->setComment(
00066 "If 'true' check for retrieved data after each begin run is processed");
00067 desc.addUntracked<bool>("checkAfterBeginLumi",false)->setComment(
00068 "If 'true' check for retrieved data after each begin lumi is processed");
00069 desc.addUntracked<bool>("checkAfterEvent",true)->setComment(
00070 "If 'true' check for retrieved data after an event is processed");
00071 descriptions.add("PrintEventSetupDataRetrieval", desc);
00072 descriptions.setComment("This service reports when EventSetup data is retrieved by a module in the job.");
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 void
00091 PrintEventSetupDataRetrieval::postProcessEvent(Event const&, EventSetup const& iES) {
00092 check(iES);
00093 }
00094
00095 void
00096 PrintEventSetupDataRetrieval::postBeginRun(Run const&, EventSetup const& iES) {
00097 check(iES);
00098 }
00099
00100 void
00101 PrintEventSetupDataRetrieval::postBeginLumi(LuminosityBlock const&, EventSetup const& iES) {
00102 check(iES);
00103 }
00104
00105 void PrintEventSetupDataRetrieval::check(EventSetup const& iES) {
00106
00107 m_recordKeys.clear();
00108 iES.fillAvailableRecordKeys(m_recordKeys);
00109
00110 for(std::vector<eventsetup::EventSetupRecordKey>::const_iterator it = m_recordKeys.begin(), itEnd = m_recordKeys.end();
00111 it != itEnd;
00112 ++it) {
00113
00114 const eventsetup::EventSetupRecord* r = iES.find(*it);
00115 assert(r != 0);
00116
00117 RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
00118 if(itRetrievedData == m_retrievedDataMap.end()) {
00119 itRetrievedData = m_retrievedDataMap.insert(std::make_pair(*it,std::pair<unsigned long long, std::map<eventsetup::DataKey,bool> >())).first;
00120 itRetrievedData->second.first = r->cacheIdentifier();
00121 std::vector<eventsetup::DataKey> keys;
00122 r->fillRegisteredDataKeys(keys);
00123 for(std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
00124 itData != itDataEnd;
00125 ++itData) {
00126 itRetrievedData->second.second.insert(std::make_pair(*itData,false));
00127 }
00128 }
00129 RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
00130 if(itRetrievedData->second.first != r->cacheIdentifier()) {
00131 itRetrievedData->second.first = r->cacheIdentifier();
00132 for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
00133 itDatum != itDatumEnd;
00134 ++itDatum) {
00135 itDatum->second = false;
00136 }
00137 }
00138
00139 for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
00140 itDatum != itDatumEnd;
00141 ++itDatum) {
00142 bool wasGotten = r->wasGotten(itDatum->first);
00143
00144 if(wasGotten != itDatum->second) {
00145 itDatum->second = wasGotten;
00146 if(m_printProviders) {
00147 const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
00148 assert(0!=d);
00149 edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()
00150 <<"' provider:"<<d->type_<<" '"<<d->label_<<"'";
00151 } else {
00152 edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()<<"'";
00153 }
00154
00155 }
00156 }
00157 }
00158 }
00159
00160
00161
00162
00163
00164
00165
00166
00167 }