CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
L1O2OTestAnalyzerExt.cc
Go to the documentation of this file.
1 #include <memory>
2 #include <sstream>
3 
6 
11 
13 
20 
23 
24 //
25 // class decleration
26 //
27 
29 public:
30  explicit L1O2OTestAnalyzerExt(const edm::ParameterSet&);
31  ~L1O2OTestAnalyzerExt() override;
32 
33 private:
34  void beginJob() override;
35  void analyze(const edm::Event&, const edm::EventSetup&) override;
36  void endJob() override;
37 
38  // ----------member data ---------------------------
43  std::vector<std::string> m_recordsToPrint;
45 };
46 
48  : m_printL1TriggerKeyExt(iConfig.getParameter<bool>("printL1TriggerKeyExt")),
49  m_printL1TriggerKeyListExt(iConfig.getParameter<bool>("printL1TriggerKeyListExt")),
50  m_printESRecords(iConfig.getParameter<bool>("printESRecords")),
51  m_printPayloadTokens(iConfig.getParameter<bool>("printPayloadTokens")),
52  m_recordsToPrint(iConfig.getParameter<std::vector<std::string> >("recordsToPrint")) {
53  //now do what ever initialization is needed
55 }
56 
58  // do anything here that needs to be done at desctruction time
59  // (e.g. close files, deallocate resources etc.)
60 }
61 
62 // ------------ method called to for each event ------------
64  using namespace edm;
65 
67  // ESHandle< L1TriggerKeyListExt > pList ;
68  // iSetup.get< L1TriggerKeyListExtRcd >().get( pList ) ;
69  L1TriggerKeyListExt pList;
70  l1t::DataWriterExt dataWriter;
71  if (!dataWriter.fillLastTriggerKeyList(pList)) {
72  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
73  }
74 
75  edm::LogInfo("L1-O2O") << "Found " << pList.tscKeyToTokenMap().size() << " TSC keys:";
76 
77  L1TriggerKeyListExt::KeyToToken::const_iterator iTSCKey = pList.tscKeyToTokenMap().begin();
78  L1TriggerKeyListExt::KeyToToken::const_iterator eTSCKey = pList.tscKeyToTokenMap().end();
79  for (; iTSCKey != eTSCKey; ++iTSCKey) {
80  edm::LogInfo("L1-O2O") << iTSCKey->first;
82  edm::LogInfo("L1-O2O") << " " << iTSCKey->second;
83  }
84  }
85 
86  L1TriggerKeyListExt::RecordToKeyToToken::const_iterator iRec = pList.recordTypeToKeyToTokenMap().begin();
87  L1TriggerKeyListExt::RecordToKeyToToken::const_iterator eRec = pList.recordTypeToKeyToTokenMap().end();
88  for (; iRec != eRec; ++iRec) {
89  const L1TriggerKeyListExt::KeyToToken& keyTokenMap = iRec->second;
90  edm::LogInfo("L1-O2O") << "For record@type " << iRec->first << ", found " << keyTokenMap.size() << " keys:";
91 
92  L1TriggerKeyListExt::KeyToToken::const_iterator iKey = keyTokenMap.begin();
93  L1TriggerKeyListExt::KeyToToken::const_iterator eKey = keyTokenMap.end();
94  for (; iKey != eKey; ++iKey) {
95  edm::LogInfo("L1-O2O") << iKey->first;
97  edm::LogInfo("L1-O2O") << " " << iKey->second;
98  }
99  }
100  }
101  }
102 
104  try {
106 
107  edm::LogInfo("L1-O2O") << "Current TSC key = " << pKey->tscKey();
108 
109  edm::LogInfo("L1-O2O") << "Current subsystem keys:";
110  edm::LogInfo("L1-O2O") << "TSP0 " << pKey->subsystemKey(L1TriggerKeyExt::kuGT);
111 
112  edm::LogInfo("L1-O2O") << "Object keys:";
113  const L1TriggerKeyExt::RecordToKey& recKeyMap = pKey->recordToKeyMap();
114  L1TriggerKeyExt::RecordToKey::const_iterator iRec = recKeyMap.begin();
115  L1TriggerKeyExt::RecordToKey::const_iterator eRec = recKeyMap.end();
116  for (; iRec != eRec; ++iRec) {
117  edm::LogInfo("L1-O2O") << iRec->first << " " << iRec->second;
118  }
119  } catch (cms::Exception& ex) {
120  edm::LogInfo("L1-O2O") << "No L1TriggerKeyExt found.";
121  }
122  }
123 
124  if (m_printESRecords) {
125  L1TriggerKeyListExt pList;
126  l1t::DataWriterExt dataWriter;
127  if (!dataWriter.fillLastTriggerKeyList(pList)) {
128  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
129  }
130 
131  // Start log string, convert run number into string
132  unsigned long long run = iEvent.id().run();
133  std::stringstream ss;
134  ss << run;
135  std::string log = "runNumber=" + ss.str();
136 
137  l1t::DataWriterExt writer;
138 
139  edm::LogInfo("L1-O2O") << "Run Settings keys:";
140 
141  std::vector<std::string>::const_iterator iRec = m_recordsToPrint.begin();
142  std::vector<std::string>::const_iterator iEnd = m_recordsToPrint.end();
143  for (; iRec != iEnd; ++iRec) {
144  std::string payloadToken = writer.payloadToken(*iRec, iEvent.id().run());
146 
147  if (*iRec == "L1TriggerKeyExtRcd") {
148  key = pList.tscKey(payloadToken);
149  } else {
150  key = pList.objectKey(*iRec, payloadToken);
151  }
152 
153  edm::LogInfo("L1-O2O") << *iRec << " " << key;
154  if (m_printPayloadTokens) {
155  edm::LogInfo("L1-O2O") << " " << payloadToken;
156  }
157 
158  // Replace spaces in key with ?s. Do reverse substitution when
159  // making L1TriggerKeyExt.
160  replace(key.begin(), key.end(), ' ', '?');
161  log += " " + *iRec + "Key=" + key;
162  }
163 
164  edm::LogInfo("L1-O2O") << log;
165  }
166 }
167 
168 // ------------ method called once each job just before starting event loop ------------
170 
171 // ------------ method called once each job just after ending the event loop ------------
173 
174 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:38
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
void analyze(const edm::Event &, const edm::EventSetup &) override
static std::vector< std::string > checklist log
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< std::string > m_recordsToPrint
const KeyToToken & tscKeyToTokenMap() const
L1O2OTestAnalyzerExt(const edm::ParameterSet &)
Log< level::Error, false > LogError
int iEvent
Definition: GenABIO.cc:224
std::string payloadToken(const std::string &recordName, edm::RunNumber_t runNumber)
tuple key
prepare the HTCondor submission files and eventually submit them
std::string tscKey(const std::string &triggerKeyPayloadToken) const
std::map< std::string, std::string > RecordToKey
Log< level::Info, false > LogInfo
std::string objectKey(const std::string &recordName, const std::string &payloadToken) const
edm::EventID id() const
Definition: EventBase.h:59
const RecordToKeyToToken & recordTypeToKeyToTokenMap() const
std::map< std::string, std::string > KeyToToken
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
edm::ESGetToken< L1TriggerKeyExt, L1TriggerKeyExtRcd > l1TriggerKeyExtToken_