CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/FWCore/Modules/src/PrintEventSetupContent.cc

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 //
00004 // Package:    PrintEventSetupContent
00005 // Class:      PrintEventSetupContent
00006 //
00014 //
00015 // Original Author:  Weng Yao
00016 //         Created:  Tue Oct  2 13:49:56 EDT 2007
00017 //
00018 //
00019 
00020 // user include files
00021 #include "FWCore/Framework/interface/ComponentDescription.h"
00022 #include "FWCore/Framework/interface/EDAnalyzer.h"
00023 #include "FWCore/Framework/interface/EventSetup.h"
00024 #include "FWCore/Framework/interface/EventSetupRecord.h"
00025 #include "FWCore/Framework/interface/IOVSyncValue.h"
00026 #include "FWCore/Framework/interface/MakerMacros.h"
00027 #include "FWCore/Framework/interface/ValidityInterval.h"
00028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00029 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00030 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00031 
00032 // system include files
00033 #include <iostream>
00034 #include <map>
00035 #include <memory>
00036 
00037 //
00038 // class decleration
00039 //
00040 
00041 namespace edm {
00042   class PrintEventSetupContent : public EDAnalyzer {
00043     public:
00044       explicit PrintEventSetupContent(ParameterSet const&);
00045       ~PrintEventSetupContent();
00046 
00047       static void fillDescriptions(ConfigurationDescriptions& descriptions);
00048 
00049     private:
00050       virtual void beginJob();
00051 
00052       virtual void analyze(Event const&, EventSetup const&);
00053       virtual void endJob() ;
00054       virtual void beginRun(Run const&, EventSetup const&);
00055       virtual void beginLuminosityBlock(LuminosityBlock const&, EventSetup const&);
00056 
00057       void print(EventSetup const&);
00058 
00059       // ----------member data ---------------------------
00060   std::map<eventsetup::EventSetupRecordKey, unsigned long long > cacheIdentifiers_;
00061 };
00062 
00063 //
00064 // constants, enums and typedefs
00065 //
00066 
00067 //
00068 // static data member definitions
00069 //
00070 
00071 //
00072 // constructors and destructor
00073 //
00074   PrintEventSetupContent::PrintEventSetupContent(ParameterSet const&) {
00075   //now do what ever initialization is neededEventSetupRecordDataGetter::EventSetupRecordDataGetter(ParameterSet const& iConfig):
00076   //  getter = new EventSetupRecordDataGetter::EventSetupRecordDataGetter(iConfig);
00077   }
00078 
00079   PrintEventSetupContent::~PrintEventSetupContent() {
00080    // do anything here that needs to be done at desctruction time
00081    // (e.g. close files, deallocate resources etc.)
00082   }
00083 
00084   //
00085   // member functions
00086   //
00087 
00088   // ------------ method called to for each event  ------------
00089   void
00090   PrintEventSetupContent::analyze(Event const&, EventSetup const& iSetup) {
00091     print(iSetup);
00092   }
00093 
00094   void
00095   PrintEventSetupContent::beginRun(Run const&, EventSetup const& iSetup){
00096     print(iSetup);
00097   }
00098 
00099   void
00100   PrintEventSetupContent::beginLuminosityBlock(LuminosityBlock const&, EventSetup const& iSetup){
00101     print(iSetup);
00102   }
00103 
00104   void
00105   PrintEventSetupContent::print (EventSetup const& iSetup) {
00106     typedef std::vector<eventsetup::EventSetupRecordKey> Records;
00107     typedef std::vector<eventsetup::DataKey> Data;
00108 
00109     Records records;
00110     Data data;
00111     iSetup.fillAvailableRecordKeys(records);
00112     int iflag=0;
00113 
00114     for(Records::iterator itrecords = records.begin(), itrecordsend = records.end();
00115        itrecords != itrecordsend; ++itrecords ) {
00116 
00117       eventsetup::EventSetupRecord const* rec = iSetup.find(*itrecords);
00118 
00119       if(0 != rec && cacheIdentifiers_[*itrecords] != rec->cacheIdentifier() ) {
00120         ++iflag;
00121         if(iflag==1) {
00122           LogSystem("ESContent") << "\n" << "Changed Record" << "\n  " << "<datatype>" << " " << "'label' provider: 'provider label' <provider module type>";
00123         }
00124         cacheIdentifiers_[*itrecords] = rec->cacheIdentifier();
00125         LogAbsolute("ESContent") << itrecords->name() << std::endl;
00126 
00127         LogAbsolute("ESContent") << " start: " << rec->validityInterval().first().eventID() << " time: " << rec->validityInterval().first().time().value() << std::endl;
00128         LogAbsolute("ESContent") << " end:   " << rec->validityInterval().last().eventID() << " time: " << rec->validityInterval().last().time().value() << std::endl;
00129         rec->fillRegisteredDataKeys(data);
00130         for(Data::iterator itdata = data.begin(), itdataend = data.end(); itdata != itdataend; ++itdata){
00131           edm::eventsetup::ComponentDescription const* cd = rec->providerDescription(*itdata);
00132           LogAbsolute("ESContent") << "  " << itdata->type().name() << " '" << itdata->name().value() << "'" << " provider:'" << cd->label_ << "' " << cd->type_ << std::endl;
00133         }
00134       }
00135     }
00136   }
00137 
00138    //#ifdef THIS_IS_AN_EVENT_EXAMPLE
00139    //   Handle<ExampleData> pIn;
00140    //   iEvent.getByLabel("example", pIn);
00141    //#endif
00142 
00143    //#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00144    //   ESHandle<SetupData> pSetup;
00145    //   iSetup.get<SetupRecord>().get(pSetup);
00146    //#endif
00147 
00148   // ------------ method called once each job just before starting event loop  ------------
00149   void
00150   PrintEventSetupContent::beginJob() {
00151   }
00152 
00153   // ------------ method called once each job just after ending the event loop  ------------
00154   void
00155   PrintEventSetupContent::endJob() {
00156   }
00157 
00158   // ------------ method called once each job for validation  ------------
00159   void
00160   PrintEventSetupContent::fillDescriptions(ConfigurationDescriptions& descriptions) {
00161     ParameterSetDescription desc;
00162     descriptions.setComment("Print what data is available in each available EventSetup Record in the job.\n"
00163                             "As part of the data is the C++ class type, label and which module makes that data.");
00164     descriptions.add("printEventSetupContent", desc);
00165   }
00166 }
00167 
00168 //define this as a plug-in
00169 using edm::PrintEventSetupContent;
00170 DEFINE_FWK_MODULE(PrintEventSetupContent);