1- #include " FWCore/Framework /interface/Frameworkfwd .h"
2- #include " FWCore/Framework/interface/one/EDAnalyzer .h"
1+ #include " CondFormats/Common /interface/Time .h"
2+ #include " FWCore/Framework/interface/ESWatcher .h"
33#include " FWCore/Framework/interface/Event.h"
44#include " FWCore/Framework/interface/EventSetup.h"
5- #include " FWCore/Framework/interface/ESWatcher .h"
5+ #include " FWCore/Framework/interface/Frameworkfwd .h"
66#include " FWCore/Framework/interface/MakerMacros.h"
7+ #include " FWCore/Framework/interface/one/EDAnalyzer.h"
8+ #include " FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
9+ #include " FWCore/ParameterSet/interface/ParameterSetDescription.h"
710
811#include " CondFormats/RunInfo/interface/LHCInfoPerLS.h"
912#include " CondFormats/DataRecord/interface/LHCInfoPerLSRcd.h"
1417
1518class LHCInfoPerLSAnalyzer : public edm ::one::EDAnalyzer<> {
1619public:
17- explicit LHCInfoPerLSAnalyzer (const edm::ParameterSet&)
18- : tokenInfoPerLS_(esConsumes<LHCInfoPerLS, LHCInfoPerLSRcd>()) {}
20+ explicit LHCInfoPerLSAnalyzer (const edm::ParameterSet& pset)
21+ : tokenInfoPerLS_(esConsumes<LHCInfoPerLS, LHCInfoPerLSRcd>()),
22+ csvFormat_(pset.getUntrackedParameter<bool >(" csvFormat" )),
23+ header_(pset.getUntrackedParameter<bool >(" header" )),
24+ iov_(pset.getUntrackedParameter<cond::Time_t>(" iov" )),
25+ separator_(pset.getUntrackedParameter<std::string>(" separator" )) {}
26+
27+ static void fillDescriptions (edm::ConfigurationDescriptions& descriptions);
1928
2029private:
2130 void beginJob () override {}
@@ -24,22 +33,39 @@ class LHCInfoPerLSAnalyzer : public edm::one::EDAnalyzer<> {
2433
2534 edm::ESWatcher<LHCInfoPerLSRcd> infoPerLSWatcher_;
2635
27- edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> tokenInfoPerLS_;
36+ const edm::ESGetToken<LHCInfoPerLS, LHCInfoPerLSRcd> tokenInfoPerLS_;
37+ const bool csvFormat_;
38+ const bool header_;
39+ const cond::Time_t iov_;
40+ const std::string separator_;
2841};
2942
43+ void LHCInfoPerLSAnalyzer::fillDescriptions (edm::ConfigurationDescriptions& descriptions) {
44+ edm::ParameterSetDescription desc;
45+ desc.addUntracked <bool >(" csvFormat" , false );
46+ desc.addUntracked <bool >(" header" , false );
47+ desc.addUntracked <std::string>(" separator" , " ," );
48+ desc.addUntracked <cond::Time_t>(" iov" , 0 );
49+ descriptions.add (" LHCInfoPerLSAnalyzer" , desc);
50+ }
51+
3052void LHCInfoPerLSAnalyzer::analyze (const edm::Event& iEvent, const edm::EventSetup& iSetup) {
3153 // get InfoPerLS
3254 assert (infoPerLSWatcher_.check (iSetup));
3355 const LHCInfoPerLS& infoPerLS = iSetup.getData (tokenInfoPerLS_);
3456
35- assert (infoPerLS.fillNumber () == 7066 );
36- assert (infoPerLS.lumiSection () == 1 );
37- assert (infoPerLS.crossingAngleX () == 170 );
38- assert (infoPerLS.crossingAngleY () == 170 );
39- assert (infoPerLS.betaStarX () == 11 );
40- assert (infoPerLS.betaStarY () == 11 );
41- assert (infoPerLS.runNumber () == 301765 );
42- edm::LogInfo (" LHCInfoPerLSAnalyzer" ) << " LHCInfoPerLS retrieved:\n " << infoPerLS;
57+ if (csvFormat_) {
58+ auto s = separator_;
59+ if (header_) {
60+ std::cout << " IOV" << s << " class" << s << " timestamp" << s << " runNumber" << s << " LS" << s << " xangleX" << s
61+ << " xangleY" << s << " beta*X" << s << " beta*Y" << s << std::endl;
62+ }
63+ std::cout << iov_ << s << " LHCInfoPerLS" << s << iEvent.time ().unixTime () << s << infoPerLS.runNumber () << s
64+ << infoPerLS.lumiSection () << s << infoPerLS.crossingAngleX () << s << infoPerLS.crossingAngleY () << s
65+ << infoPerLS.betaStarX () << s << infoPerLS.betaStarY () << s << std::endl;
66+ } else {
67+ std::cout << infoPerLS << std::endl;
68+ }
4369}
4470
4571DEFINE_FWK_MODULE (LHCInfoPerLSAnalyzer);
0 commit comments