CMS 3D CMS Logo

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