CMS 3D CMS Logo

L1O2OTestAnalyzerExt.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <memory>
3 #include <sstream>
4 
7 
12 
14 
21 
24 
25 //
26 // class decleration
27 //
28 
30 public:
31  explicit L1O2OTestAnalyzerExt(const edm::ParameterSet&);
32  ~L1O2OTestAnalyzerExt() override;
33 
34 private:
35  void beginJob() override;
36  void analyze(const edm::Event&, const edm::EventSetup&) override;
37  void endJob() override;
38 
39  // ----------member data ---------------------------
44  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
54 }
55 
57  // do anything here that needs to be done at desctruction time
58  // (e.g. close files, deallocate resources etc.)
59 }
60 
61 // ------------ method called to for each event ------------
63  using namespace edm;
64 
66  // ESHandle< L1TriggerKeyListExt > pList ;
67  // iSetup.get< L1TriggerKeyListExtRcd >().get( pList ) ;
68  L1TriggerKeyListExt pList;
69  l1t::DataWriterExt dataWriter;
70  if (!dataWriter.fillLastTriggerKeyList(pList)) {
71  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
72  }
73 
74  std::cout << "Found " << pList.tscKeyToTokenMap().size() << " TSC keys:" << std::endl;
75 
76  L1TriggerKeyListExt::KeyToToken::const_iterator iTSCKey = pList.tscKeyToTokenMap().begin();
77  L1TriggerKeyListExt::KeyToToken::const_iterator eTSCKey = pList.tscKeyToTokenMap().end();
78  for (; iTSCKey != eTSCKey; ++iTSCKey) {
79  std::cout << iTSCKey->first;
81  std::cout << " " << iTSCKey->second;
82  }
83  std::cout << std::endl;
84  }
85  std::cout << std::endl;
86 
87  L1TriggerKeyListExt::RecordToKeyToToken::const_iterator iRec = pList.recordTypeToKeyToTokenMap().begin();
88  L1TriggerKeyListExt::RecordToKeyToToken::const_iterator eRec = pList.recordTypeToKeyToTokenMap().end();
89  for (; iRec != eRec; ++iRec) {
90  const L1TriggerKeyListExt::KeyToToken& keyTokenMap = iRec->second;
91  std::cout << "For record@type " << iRec->first << ", found " << keyTokenMap.size() << " keys:" << std::endl;
92 
93  L1TriggerKeyListExt::KeyToToken::const_iterator iKey = keyTokenMap.begin();
94  L1TriggerKeyListExt::KeyToToken::const_iterator eKey = keyTokenMap.end();
95  for (; iKey != eKey; ++iKey) {
96  std::cout << iKey->first;
98  std::cout << " " << iKey->second;
99  }
100  std::cout << std::endl;
101  }
102  std::cout << std::endl;
103  }
104  }
105 
107  try {
109  iSetup.get<L1TriggerKeyExtRcd>().get(pKey);
110 
111  std::cout << std::endl;
112  std::cout << "Current TSC key = " << pKey->tscKey() << std::endl << std::endl;
113 
114  std::cout << "Current subsystem keys:" << std::endl;
115  std::cout << "TSP0 " << pKey->subsystemKey(L1TriggerKeyExt::kuGT) << std::endl << std::endl;
116 
117  std::cout << "Object keys:" << std::endl;
118  const L1TriggerKeyExt::RecordToKey& recKeyMap = pKey->recordToKeyMap();
119  L1TriggerKeyExt::RecordToKey::const_iterator iRec = recKeyMap.begin();
120  L1TriggerKeyExt::RecordToKey::const_iterator eRec = recKeyMap.end();
121  for (; iRec != eRec; ++iRec) {
122  std::cout << iRec->first << " " << iRec->second << std::endl;
123  }
124  } catch (cms::Exception& ex) {
125  std::cout << "No L1TriggerKeyExt found." << std::endl;
126  }
127  }
128 
129  if (m_printESRecords) {
130  // ESHandle< L1TriggerKeyListExt > pList ;
131  // iSetup.get< L1TriggerKeyListExtRcd >().get( pList ) ;
132 
133  L1TriggerKeyListExt pList;
134  l1t::DataWriterExt dataWriter;
135  if (!dataWriter.fillLastTriggerKeyList(pList)) {
136  edm::LogError("L1-O2O") << "Problem getting last L1TriggerKeyListExt";
137  }
138 
139  // Start log string, convert run number into string
140  unsigned long long run = iEvent.id().run();
141  std::stringstream ss;
142  ss << run;
143  std::string log = "runNumber=" + ss.str();
144 
146 
147  std::cout << std::endl << "Run Settings keys:" << std::endl;
148 
149  std::vector<std::string>::const_iterator iRec = m_recordsToPrint.begin();
150  std::vector<std::string>::const_iterator iEnd = m_recordsToPrint.end();
151  for (; iRec != iEnd; ++iRec) {
152  std::string payloadToken = writer.payloadToken(*iRec, iEvent.id().run());
154 
155  if (*iRec == "L1TriggerKeyExtRcd") {
156  key = pList.tscKey(payloadToken);
157  } else {
158  key = pList.objectKey(*iRec, payloadToken);
159  }
160 
161  std::cout << *iRec << " " << key;
162  if (m_printPayloadTokens) {
163  std::cout << " " << payloadToken;
164  }
165  std::cout << std::endl;
166 
167  // Replace spaces in key with ?s. Do reverse substitution when
168  // making L1TriggerKeyExt.
169  replace(key.begin(), key.end(), ' ', '?');
170  log += " " + *iRec + "Key=" + key;
171  }
172 
173  std::cout << std::endl << log << std::endl;
174  }
175 }
176 
177 // ------------ method called once each job just before starting event loop ------------
179 
180 // ------------ method called once each job just after ending the event loop ------------
182 
183 //define this as a plug-in
DataWriterExt.h
electrons_cff.bool
bool
Definition: electrons_cff.py:366
L1TriggerKeyListExt
Definition: L1TriggerKeyListExt.h:10
L1TriggerKeyListExt::tscKeyToTokenMap
const KeyToToken & tscKeyToTokenMap() const
Definition: L1TriggerKeyListExt.h:30
Exception.h
ESHandle.h
L1TriggerKeyListExt::tscKey
std::string tscKey(const std::string &triggerKeyPayloadToken) const
Definition: L1TriggerKeyListExt.cc:155
edm
HLT enums.
Definition: AlignableModifier.h:19
L1O2OTestAnalyzerExt
Definition: L1O2OTestAnalyzerExt.cc:29
L1TriggerKeyExt::subsystemKey
const std::string & subsystemKey(L1Subsystems subsystem) const
Definition: L1TriggerKeyExt.h:71
gather_cfg.cout
cout
Definition: gather_cfg.py:144
L1TriggerKeyExtRcd
Definition: L1TriggerKeyExtRcd.h:8
L1O2OTestAnalyzerExt::endJob
void endJob() override
Definition: L1O2OTestAnalyzerExt.cc:181
cscNeutronWriter_cfi.writer
writer
Definition: cscNeutronWriter_cfi.py:6
EDAnalyzer.h
L1TriggerKeyExt::RecordToKey
std::map< std::string, std::string > RecordToKey
Definition: L1TriggerKeyExt.h:25
L1TriggerKeyExt::recordToKeyMap
const RecordToKey & recordToKeyMap() const
Definition: L1TriggerKeyExt.h:77
L1O2OTestAnalyzerExt::m_printESRecords
bool m_printESRecords
Definition: L1O2OTestAnalyzerExt.cc:42
L1TriggerKeyListExt::objectKey
std::string objectKey(const std::string &recordName, const std::string &payloadToken) const
Definition: L1TriggerKeyListExt.cc:135
L1O2OTestAnalyzerExt::m_recordsToPrint
std::vector< std::string > m_recordsToPrint
Definition: L1O2OTestAnalyzerExt.cc:44
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
L1TriggerKeyExtRcd.h
L1TriggerKeyExt.h
L1TriggerKeyListExtRcd.h
L1TriggerKeyExt::tscKey
const std::string & tscKey() const
Definition: L1TriggerKeyExt.h:69
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
L1TriggerKey.h
L1O2OTestAnalyzerExt::~L1O2OTestAnalyzerExt
~L1O2OTestAnalyzerExt() override
Definition: L1O2OTestAnalyzerExt.cc:56
L1O2OTestAnalyzerExt::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1O2OTestAnalyzerExt.cc:62
edm::ESHandle
Definition: DTSurvey.h:22
l1t::DataWriterExt::fillLastTriggerKeyList
bool fillLastTriggerKeyList(L1TriggerKeyListExt &output)
Definition: DataWriterExt.cc:148
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1O2OTestAnalyzerExt::L1O2OTestAnalyzerExt
L1O2OTestAnalyzerExt(const edm::ParameterSet &)
Definition: L1O2OTestAnalyzerExt.cc:47
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::EventSetup
Definition: EventSetup.h:58
L1O2OTestAnalyzerExt::beginJob
void beginJob() override
Definition: L1O2OTestAnalyzerExt.cc:178
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
L1O2OTestAnalyzerExt::m_printL1TriggerKeyListExt
bool m_printL1TriggerKeyListExt
Definition: L1O2OTestAnalyzerExt.cc:41
get
#define get
L1TriggerKeyRcd.h
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
Frameworkfwd.h
L1O2OTestAnalyzerExt::m_printPayloadTokens
bool m_printPayloadTokens
Definition: L1O2OTestAnalyzerExt.cc:43
EventSetup.h
L1TriggerKeyListExt.h
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
L1TriggerKeyExt::kuGT
Definition: L1TriggerKeyExt.h:27
cms::Exception
Definition: Exception.h:70
L1O2OTestAnalyzerExt::m_printL1TriggerKeyExt
bool m_printL1TriggerKeyExt
Definition: L1O2OTestAnalyzerExt.cc:40
L1TriggerKeyListExt::KeyToToken
std::map< std::string, std::string > KeyToToken
Definition: L1TriggerKeyListExt.h:15
ParameterSet.h
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444
l1t::DataWriterExt
Definition: DataWriterExt.h:35
L1TriggerKeyListExt::recordTypeToKeyToTokenMap
const RecordToKeyToToken & recordTypeToKeyToTokenMap() const
Definition: L1TriggerKeyListExt.h:32