Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:39

0001 #include <stdexcept>
0002 #include <string>
0003 #include <iostream>
0004 #include <map>
0005 #include <typeinfo>
0006 
0007 #include "CondCore/IOVService/interface/KeyList.h"
0008 
0009 #include "CondFormats/Calibration/interface/Conf.h"
0010 #include "CondFormats/DataRecord/interface/ExEfficiency.h"
0011 
0012 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0013 #include "FWCore/Framework/interface/Event.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/MakerMacros.h"
0016 
0017 using namespace std;
0018 
0019 namespace {
0020 
0021   template <typename Conf>
0022   void print(Conf const& c) {
0023     edm::LogPrint("KeyListAnalyzer") << c.v << " " << c.key << " ; ";
0024   }
0025 
0026 }  // namespace
0027 
0028 namespace edmtest {
0029   class KeyListAnalyzer : public edm::one::EDAnalyzer<> {
0030   public:
0031     explicit KeyListAnalyzer(edm::ParameterSet const& p) : theKeyListToken_(esConsumes()) {
0032       edm::LogPrint("KeyListAnalyzer") << "KeyListAnalyzer";
0033     }
0034     explicit KeyListAnalyzer(int i) { edm::LogPrint("KeyListAnalyzer") << "KeyListAnalyzer " << i; }
0035     virtual ~KeyListAnalyzer() { edm::LogPrint("KeyListAnalyzer") << "~KeyListAnalyzer "; }
0036     virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
0037 
0038   private:
0039     const edm::ESGetToken<cond::KeyList, ExDwarfListRcd> theKeyListToken_;
0040   };
0041 
0042   void KeyListAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0043     using namespace edm::eventsetup;
0044     // Context is not used.
0045     edm::LogPrint("KeyListAnalyzer") << " I AM IN RUN NUMBER " << e.id().run();
0046     edm::LogPrint("KeyListAnalyzer") << " ---EVENT NUMBER " << e.id().event();
0047     edm::eventsetup::EventSetupRecordKey recordKey(
0048         edm::eventsetup::EventSetupRecordKey::TypeTag::findType("ExDwarfListRcd"));
0049     if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0050       //record not found
0051       edm::LogPrint("KeyListAnalyzer") << "Record \"ExDwarfListRcd\" does not exist";
0052     }
0053     edm::LogPrint("KeyListAnalyzer") << "got context";
0054     cond::KeyList const& kl = context.getData(theKeyListToken_);
0055     int n = 0;
0056     for (int i = 0; i < kl.size(); i++)
0057       if (kl.elem(i)) {
0058         n++;
0059         if (0 == i % 2)
0060           print(*kl.get<condex::ConfI>(i));
0061         else
0062           print(*kl.get<condex::ConfF>(i));
0063       }
0064     edm::LogPrint("KeyListAnalyzer") << "found " << n << " valid keyed confs" << std::endl;
0065   }
0066 
0067   DEFINE_FWK_MODULE(KeyListAnalyzer);
0068 }  // namespace edmtest