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  assert(r != 0);
116 
117  RetrievedDataMap::iterator itRetrievedData = m_retrievedDataMap.find(*it);
118  if(itRetrievedData == m_retrievedDataMap.end()) {
119  itRetrievedData = m_retrievedDataMap.insert(std::make_pair(*it,std::pair<unsigned long long, std::map<eventsetup::DataKey,bool> >())).first;
120  itRetrievedData->second.first = r->cacheIdentifier();
121  std::vector<eventsetup::DataKey> keys;
122  r->fillRegisteredDataKeys(keys);
123  for(std::vector<eventsetup::DataKey>::const_iterator itData = keys.begin(), itDataEnd = keys.end();
124  itData != itDataEnd;
125  ++itData) {
126  itRetrievedData->second.second.insert(std::make_pair(*itData,false));
127  }
128  }
129  RetrievedDataMap::value_type& retrievedData = *itRetrievedData;
130  if(itRetrievedData->second.first != r->cacheIdentifier()) {
131  itRetrievedData->second.first = r->cacheIdentifier();
132  for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
133  itDatum != itDatumEnd;
134  ++itDatum) {
135  itDatum->second = false;
136  }
137  }
138 
139  for(std::map<eventsetup::DataKey,bool>::iterator itDatum = retrievedData.second.second.begin(), itDatumEnd = retrievedData.second.second.end();
140  itDatum != itDatumEnd;
141  ++itDatum) {
142  bool wasGotten = r->wasGotten(itDatum->first);
143  //std::cout <<" "<<itDatum->first.type().name()<<" "<<wasGotten<<std::endl;
144  if(wasGotten != itDatum->second) {
145  itDatum->second = wasGotten;
146  if(m_printProviders) {
147  const edm::eventsetup::ComponentDescription* d = r->providerDescription(itDatum->first);
148  assert(0!=d);
149  edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()
150  <<"' provider:"<<d->type_<<" '"<<d->label_<<"'";
151  } else {
152  edm::LogSystem("PrintEventSetupDataRetrieval")<<"Retrieved> Record:"<<it->name()<<" data:"<<itDatum->first.type().name()<<" '"<<itDatum->first.name().value()<<"'";
153  }
154  //std::cout <<"CHANGED"<<std::endl;
155  }
156  }
157  }
158  }
159 
160 //
161 // const member functions
162 //
163 
164 //
165 // static member functions
166 //
167 }
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)
bool wasGotten(DataKey const &aKey) const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
ComponentDescription const * providerDescription(DataKey const &aKey) const
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:101
PrintEventSetupDataRetrieval(const ParameterSet &, ActivityRegistry &)
void watchPostBeginLumi(PostBeginLumi::slot_type const &iSlot)
Container::value_type value_type
void postProcessEvent(Event const &, EventSetup const &)
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: Run.h:41