CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrintEventSetupDataRetrieval.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Services
4 // Class : PrintEventSetupDataRetrieval
5 //
6 // Implementation:
7 // A service which prints which data from the EventSetup have been retrieved since the last time it checked
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Jul 9 14:30:13 CDT 2009
11 //
12 
13 // system include files
14 #include <iostream>
15 
16 // user include files
24 
25 namespace edm {
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  ActivityRegistry&iRegistry):
39  m_printProviders(iPS.getUntrackedParameter<bool>("printProviders"))
40  {
41  if(iPS.getUntrackedParameter<bool>("checkAfterBeginRun")) {
43  }
44  if(iPS.getUntrackedParameter<bool>("checkAfterBeginLumi")) {
46  }
47  if(iPS.getUntrackedParameter<bool>("checkAfterEvent")) {
49  }
50  }
51 
52 // PrintEventSetupDataRetrieval::PrintEventSetupDataRetrieval(const PrintEventSetupDataRetrieval& rhs)
53 // {
54 // // do actual copying here;
55 // }
56 
57  //PrintEventSetupDataRetrieval::~PrintEventSetupDataRetrieval()
58  //{
59  //}
60 
63  desc.addUntracked<bool>("printProviders",false)->setComment(
64  "If 'true' also print which ES module provides the data");
65  desc.addUntracked<bool>("checkAfterBeginRun",false)->setComment(
66  "If 'true' check for retrieved data after each begin run is processed");
67  desc.addUntracked<bool>("checkAfterBeginLumi",false)->setComment(
68  "If 'true' check for retrieved data after each begin lumi is processed");
69  desc.addUntracked<bool>("checkAfterEvent",true)->setComment(
70  "If 'true' check for retrieved data after an event is processed");
71  descriptions.add("PrintEventSetupDataRetrieval", desc);
72  descriptions.setComment("This service reports when EventSetup data is retrieved by a module in the job.");
73  }
74 
75 //
76 // assignment operators
77 //
78 // const PrintEventSetupDataRetrieval& PrintEventSetupDataRetrieval::operator=(const PrintEventSetupDataRetrieval& rhs)
79 // {
80 // //An exception safe implementation is
81 // PrintEventSetupDataRetrieval temp(rhs);
82 // swap(rhs);
83 //
84 // return *this;
85 // }
86 
87 //
88 // member functions
89 //
90  void
92  check(iES);
93  }
94 
95  void
97  check(iES);
98  }
99 
100  void
102  check(iES);
103  }
104 
106  //std::cout <<"postProcessEvent"<<std::endl;
107  m_recordKeys.clear();
109 
110  for(std::vector<eventsetup::EventSetupRecordKey>::const_iterator it = m_recordKeys.begin(), itEnd = m_recordKeys.end();
111  it != itEnd;
112  ++it) {
113  //std::cout <<" "<<it->name()<<std::endl;
114  const eventsetup::EventSetupRecord* r = iES.find(*it);
115 
116  RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
117  if(itRetrievedData == m_retrievedDataMap.end()) {
118  itRetrievedData = m_retrievedDataMap.insert(std::make_pair(*it,std::pair<unsigned long long, std::map<eventsetup::DataKey,bool> >())).first;
119  itRetrievedData->second.first = r->cacheIdentifier();
120  std::vector<eventsetup::DataKey> keys;
121  r->fillRegisteredDataKeys(keys);
122  for(std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
123  itData != itDataEnd;
124  ++itData) {
125  itRetrievedData->second.second.insert(std::make_pair(*itData,false));
126  }
127  }
128  RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
129  if(itRetrievedData->second.first != r->cacheIdentifier()) {
130  itRetrievedData->second.first = r->cacheIdentifier();
131  for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
132  itDatum != itDatumEnd;
133  ++itDatum) {
134  itDatum->second = false;
135  }
136  }
137 
138  for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
139  itDatum != itDatumEnd;
140  ++itDatum) {
141  bool wasGotten = r->wasGotten(itDatum->first);
142  //std::cout <<" "<<itDatum->first.type().name()<<" "<<wasGotten<<std::endl;
143  if(wasGotten != itDatum->second) {
144  itDatum->second = wasGotten;
145  if(m_printProviders) {
146  const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
147  assert(0!=d);
148  edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()
149  <<"' provider:"<<d->type_<<" '"<<d->label_<<"'";
150  } else {
151  edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()<<"'";
152  }
153  //std::cout <<"CHANGED"<<std::endl;
154  }
155  }
156  }
157  }
158 
159 //
160 // const member functions
161 //
162 
163 //
164 // static member functions
165 //
166 }
void watchPostBeginRun(PostBeginRun::slot_type const &iSlot)
unsigned long long cacheIdentifier() const
T getUntrackedParameter(std::string const &, T const &) const
void fillRegisteredDataKeys(std::vector< DataKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all registered data keys ...
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Container::value_type value_type
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:82
void watchPostProcessEvent(PostProcessEvent::slot_type const &iSlot)
std::vector< eventsetup::EventSetupRecordKey > m_recordKeys
void postBeginLumi(LuminosityBlock const &, EventSetup const &)
void postBeginRun(Run const &, EventSetup const &)
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records ...
Definition: EventSetup.cc:93
PrintEventSetupDataRetrieval(const ParameterSet &, ActivityRegistry &)
void watchPostBeginLumi(PostBeginLumi::slot_type const &iSlot)
void postProcessEvent(Event const &, EventSetup const &)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
ComponentDescription const * providerDescription(const DataKey &aKey) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool wasGotten(const DataKey &aKey) const
Definition: Run.h:31