CMS 3D CMS Logo

L1O2OTestAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1O2OTestAnalyzer
4 // Class: L1O2OTestAnalyzer
5 //
13 //
14 // Original Author: Werner Man-Li Sun
15 // Created: Thu Nov 6 23:00:43 CET 2008
16 //
17 //
18 
19 // system include files
20 #include <iostream>
21 #include <memory>
22 #include <sstream>
23 
24 // user include files
27 
32 
34 
39 
42 
43 //
44 // class decleration
45 //
46 
48 public:
49  explicit L1O2OTestAnalyzer(const edm::ParameterSet&);
50  ~L1O2OTestAnalyzer() override;
51 
52 private:
53  void beginJob() override;
54  void analyze(const edm::Event&, const edm::EventSetup&) override;
55  void endJob() override;
56 
57  // ----------member data ---------------------------
62  std::vector<std::string> m_recordsToPrint;
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 //
70 // static data member definitions
71 //
72 
73 //
74 // constructors and destructor
75 //
77  : m_printL1TriggerKey(iConfig.getParameter<bool>("printL1TriggerKey")),
78  m_printL1TriggerKeyList(iConfig.getParameter<bool>("printL1TriggerKeyList")),
79  m_printESRecords(iConfig.getParameter<bool>("printESRecords")),
80  m_printPayloadTokens(iConfig.getParameter<bool>("printPayloadTokens")),
81  m_recordsToPrint(iConfig.getParameter<std::vector<std::string> >("recordsToPrint")) {
82  //now do what ever initialization is needed
83 }
84 
86  // do anything here that needs to be done at desctruction time
87  // (e.g. close files, deallocate resources etc.)
88 }
89 
90 //
91 // member functions
92 //
93 
94 // ------------ method called to for each event ------------
96  using namespace edm;
97 
99  // ESHandle< L1TriggerKeyList > pList ;
100  // iSetup.get< L1TriggerKeyListRcd >().get( pList ) ;
101  L1TriggerKeyList pList;
102  l1t::DataWriter dataWriter;
103  if (!dataWriter.fillLastTriggerKeyList(pList)) {
104  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
105  }
106 
107  std::cout << "Found " << pList.tscKeyToTokenMap().size() << " TSC keys:" << std::endl;
108 
109  L1TriggerKeyList::KeyToToken::const_iterator iTSCKey = pList.tscKeyToTokenMap().begin();
110  L1TriggerKeyList::KeyToToken::const_iterator eTSCKey = pList.tscKeyToTokenMap().end();
111  for (; iTSCKey != eTSCKey; ++iTSCKey) {
112  std::cout << iTSCKey->first;
113  if (m_printPayloadTokens) {
114  std::cout << " " << iTSCKey->second;
115  }
116  std::cout << std::endl;
117  }
118  std::cout << std::endl;
119 
120  L1TriggerKeyList::RecordToKeyToToken::const_iterator iRec = pList.recordTypeToKeyToTokenMap().begin();
121  L1TriggerKeyList::RecordToKeyToToken::const_iterator eRec = pList.recordTypeToKeyToTokenMap().end();
122  for (; iRec != eRec; ++iRec) {
123  const L1TriggerKeyList::KeyToToken& keyTokenMap = iRec->second;
124  std::cout << "For record@type " << iRec->first << ", found " << keyTokenMap.size() << " keys:" << std::endl;
125 
126  L1TriggerKeyList::KeyToToken::const_iterator iKey = keyTokenMap.begin();
127  L1TriggerKeyList::KeyToToken::const_iterator eKey = keyTokenMap.end();
128  for (; iKey != eKey; ++iKey) {
129  std::cout << iKey->first;
130  if (m_printPayloadTokens) {
131  std::cout << " " << iKey->second;
132  }
133  std::cout << std::endl;
134  }
135  std::cout << std::endl;
136  }
137  }
138 
139  if (m_printL1TriggerKey) {
140  try {
142  iSetup.get<L1TriggerKeyRcd>().get(pKey);
143 
144  std::cout << std::endl;
145  std::cout << "Current TSC key = " << pKey->tscKey() << std::endl << std::endl;
146 
147  std::cout << "Current subsystem keys:" << std::endl;
148  std::cout << "CSCTF " << pKey->subsystemKey(L1TriggerKey::kCSCTF) << std::endl;
149  std::cout << "DTTF " << pKey->subsystemKey(L1TriggerKey::kDTTF) << std::endl;
150  std::cout << "RPC " << pKey->subsystemKey(L1TriggerKey::kRPC) << std::endl;
151  std::cout << "GMT " << pKey->subsystemKey(L1TriggerKey::kGMT) << std::endl;
152  std::cout << "RCT " << pKey->subsystemKey(L1TriggerKey::kRCT) << std::endl;
153  std::cout << "GCT " << pKey->subsystemKey(L1TriggerKey::kGCT) << std::endl;
154  std::cout << "GT " << pKey->subsystemKey(L1TriggerKey::kGT) << std::endl;
155  std::cout << "TSP0 " << pKey->subsystemKey(L1TriggerKey::kTSP0) << std::endl << std::endl;
156 
157  std::cout << "Object keys:" << std::endl;
158  const L1TriggerKey::RecordToKey& recKeyMap = pKey->recordToKeyMap();
159  L1TriggerKey::RecordToKey::const_iterator iRec = recKeyMap.begin();
160  L1TriggerKey::RecordToKey::const_iterator eRec = recKeyMap.end();
161  for (; iRec != eRec; ++iRec) {
162  std::cout << iRec->first << " " << iRec->second << std::endl;
163  }
164  } catch (cms::Exception& ex) {
165  std::cout << "No L1TriggerKey found." << std::endl;
166  }
167  }
168 
169  if (m_printESRecords) {
170  // ESHandle< L1TriggerKeyList > pList ;
171  // iSetup.get< L1TriggerKeyListRcd >().get( pList ) ;
172 
173  L1TriggerKeyList pList;
174  l1t::DataWriter dataWriter;
175  if (!dataWriter.fillLastTriggerKeyList(pList)) {
176  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyList";
177  }
178 
179  // Start log string, convert run number into string
180  unsigned long long run = iEvent.id().run();
181  std::stringstream ss;
182  ss << run;
183  std::string log = "runNumber=" + ss.str();
184 
186 
187  std::cout << std::endl << "Run Settings keys:" << std::endl;
188 
189  std::vector<std::string>::const_iterator iRec = m_recordsToPrint.begin();
190  std::vector<std::string>::const_iterator iEnd = m_recordsToPrint.end();
191  for (; iRec != iEnd; ++iRec) {
192  std::string payloadToken = writer.payloadToken(*iRec, iEvent.id().run());
194 
195  if (*iRec == "L1TriggerKeyRcd") {
196  key = pList.tscKey(payloadToken);
197  } else {
198  key = pList.objectKey(*iRec, payloadToken);
199  }
200 
201  std::cout << *iRec << " " << key;
202  if (m_printPayloadTokens) {
203  std::cout << " " << payloadToken;
204  }
205  std::cout << std::endl;
206 
207  // Replace spaces in key with ?s. Do reverse substitution when
208  // making L1TriggerKey.
209  replace(key.begin(), key.end(), ' ', '?');
210  log += " " + *iRec + "Key=" + key;
211  }
212 
213  std::cout << std::endl << log << std::endl;
214  }
215 }
216 
217 // ------------ method called once each job just before starting event loop ------------
219 
220 // ------------ method called once each job just after ending the event loop ------------
222 
223 //define this as a plug-in
L1O2OTestAnalyzer::~L1O2OTestAnalyzer
~L1O2OTestAnalyzer() override
Definition: L1O2OTestAnalyzer.cc:85
DataWriter.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
L1TriggerKey::kRPC
Definition: L1TriggerKey.h:27
Exception.h
L1O2OTestAnalyzer::m_printL1TriggerKey
bool m_printL1TriggerKey
Definition: L1O2OTestAnalyzer.cc:58
ESHandle.h
L1TriggerKeyRcd
Definition: L1TriggerKeyRcd.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
L1TriggerKey::kGMT
Definition: L1TriggerKey.h:27
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
EDAnalyzer.h
L1TriggerKey::RecordToKey
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKey.h:25
L1O2OTestAnalyzer::beginJob
void beginJob() override
Definition: L1O2OTestAnalyzer.cc:218
L1TriggerKeyList::recordTypeToKeyToTokenMap
const RecordToKeyToToken & recordTypeToKeyToTokenMap() const
Definition: L1TriggerKeyList.h:54
edm::EDAnalyzer
Definition: EDAnalyzer.h:29
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TriggerKey.h
L1TriggerKey::kTSP0
Definition: L1TriggerKey.h:27
edm::ESHandle
Definition: DTSurvey.h:22
L1TriggerKey::recordToKeyMap
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKey.h:76
L1O2OTestAnalyzer
Definition: L1O2OTestAnalyzer.cc:47
L1O2OTestAnalyzer::m_printESRecords
bool m_printESRecords
Definition: L1O2OTestAnalyzer.cc:60
L1TriggerKey::kRCT
Definition: L1TriggerKey.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1O2OTestAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1O2OTestAnalyzer.cc:95
L1TriggerKeyList
Definition: L1TriggerKeyList.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
L1TriggerKey::kDTTF
Definition: L1TriggerKey.h:27
edm::LogError
Definition: MessageLogger.h:183
Event.h
L1O2OTestAnalyzer::m_recordsToPrint
std::vector< std::string > m_recordsToPrint
Definition: L1O2OTestAnalyzer.cc:62
L1O2OTestAnalyzer::m_printL1TriggerKeyList
bool m_printL1TriggerKeyList
Definition: L1O2OTestAnalyzer.cc:59
L1TriggerKeyList::KeyToToken
std::map< std::string, std::string > KeyToToken
Definition: L1TriggerKeyList.h:37
iEvent
int iEvent
Definition: GenABIO.cc:224
L1TriggerKey::kGCT
Definition: L1TriggerKey.h:27
L1TriggerKeyList.h
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
L1TriggerKeyRcd.h
L1O2OTestAnalyzer::endJob
void endJob() override
Definition: L1O2OTestAnalyzer.cc:221
L1TriggerKey::tscKey
const std::string & tscKey() const
Definition: L1TriggerKey.h:69
L1TriggerKey::kGT
Definition: L1TriggerKey.h:27
l1t::DataWriter::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyList &output)
Definition: DataWriter.cc:147
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
L1O2OTestAnalyzer::L1O2OTestAnalyzer
L1O2OTestAnalyzer(const edm::ParameterSet &)
Definition: L1O2OTestAnalyzer.cc:76
Frameworkfwd.h
L1TriggerKeyList::tscKey
std::string tscKey(const std::string &triggerKeyPayloadToken) const
Definition: L1TriggerKeyList.cc:182
EventSetup.h
L1TriggerKey::kCSCTF
Definition: L1TriggerKey.h:27
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
l1t::DataWriter
Definition: DataWriter.h:35
L1TriggerKeyList::objectKey
std::string objectKey(const std::string &recordName, const std::string &payloadToken) const
Definition: L1TriggerKeyList.cc:162
cms::Exception
Definition: Exception.h:70
L1TriggerKey::subsystemKey
const std::string & subsystemKey(L1Subsystems subsystem) const
Definition: L1TriggerKey.h:71
ParameterSet.h
L1TriggerKeyList::tscKeyToTokenMap
const KeyToToken & tscKeyToTokenMap() const
Definition: L1TriggerKeyList.h:52
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
L1O2OTestAnalyzer::m_printPayloadTokens
bool m_printPayloadTokens
Definition: L1O2OTestAnalyzer.cc:61
L1TriggerKeyListRcd.h
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444