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
00116 RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
00117 if(itRetrievedData == m_retrievedDataMap.end()) {
00118 itRetrievedData = m_retrievedDataMap.insert(std::make_pair(*it,std::pair<unsigned long long, std::map<eventsetup::DataKey,bool> >())).first;
00119 itRetrievedData->second.first = r->cacheIdentifier();
00120 std::vector<eventsetup::DataKey> keys;
00121 r->fillRegisteredDataKeys(keys);
00122 for(std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
00123 itData != itDataEnd;
00124 ++itData) {
00125 itRetrievedData->second.second.insert(std::make_pair(*itData,false));
00126 }
00127 }
00128 RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
00129 if(itRetrievedData->second.first != r->cacheIdentifier()) {
00130 itRetrievedData->second.first = r->cacheIdentifier();
00131 for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
00132 itDatum != itDatumEnd;
00133 ++itDatum) {
00134 itDatum->second = false;
00135 }
00136 }
00137
00138 for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
00139 itDatum != itDatumEnd;
00140 ++itDatum) {
00141 bool wasGotten = r->wasGotten(itDatum->first);
00142
00143 if(wasGotten != itDatum->second) {
00144 itDatum->second = wasGotten;
00145 if(m_printProviders) {
00146 const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
00147 assert(0!=d);
00148 edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()
00149 <<"' provider:"<<d->type_<<" '"<<d->label_<<"'";
00150 } else {
00151 edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()<<"'";
00152 }
00153
00154 }
00155 }
00156 }
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166 }