File indexing completed on 2024-04-06 11:58:35
0001
0002
0003
0004
0005
0006
0007
0008 #include "FWCore/Framework/interface/ESHandle.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 #include "FWCore/Utilities/interface/Exception.h"
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include "FWCore/Framework/interface/ESWatcher.h"
0016
0017 #include "CondFormats/AlignmentRecord/interface/RPRealAlignmentRecord.h"
0018 #include "CondFormats/AlignmentRecord/interface/RPMisalignedAlignmentRecord.h"
0019
0020 #include "CondFormats/PPSObjects/interface/CTPPSRPAlignmentCorrectionsData.h"
0021
0022
0023
0024
0025
0026
0027 class CTPPSAlignmentInfo : public edm::one::EDAnalyzer<> {
0028 public:
0029 explicit CTPPSAlignmentInfo(const edm::ParameterSet&);
0030
0031 private:
0032 std::string alignmentType_;
0033
0034 edm::ESWatcher<RPRealAlignmentRecord> watcherRealAlignments_;
0035 edm::ESWatcher<RPMisalignedAlignmentRecord> watcherMisalignedAlignments_;
0036 edm::ESGetToken<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord> alignmentToken_;
0037
0038 void analyze(const edm::Event&, const edm::EventSetup&) override;
0039
0040 void printInfo(const CTPPSRPAlignmentCorrectionsData& alignments, const edm::Event& event) const;
0041 };
0042
0043 CTPPSAlignmentInfo::CTPPSAlignmentInfo(const edm::ParameterSet& iConfig)
0044 : alignmentType_(iConfig.getUntrackedParameter<std::string>("alignmentType", "real")),
0045 alignmentToken_(esConsumes()) {}
0046
0047
0048
0049 void CTPPSAlignmentInfo::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0050 if (alignmentType_ == "real") {
0051 if (watcherRealAlignments_.check(iSetup)) {
0052 auto const& alignments = iSetup.getData(alignmentToken_);
0053 printInfo(alignments, iEvent);
0054 }
0055 return;
0056 }
0057
0058 else if (alignmentType_ == "misaligned") {
0059 if (watcherMisalignedAlignments_.check(iSetup)) {
0060 auto const& alignments = iSetup.getData(alignmentToken_);
0061 printInfo(alignments, iEvent);
0062 }
0063 return;
0064 }
0065
0066 throw cms::Exception("CTPPSAlignmentInfo") << "Unknown geometry type: `" << alignmentType_ << "'.";
0067 }
0068
0069
0070
0071 void CTPPSAlignmentInfo::printInfo(const CTPPSRPAlignmentCorrectionsData& alignments, const edm::Event& event) const {
0072 time_t unixTime = event.time().unixTime();
0073 char timeStr[50];
0074 strftime(timeStr, 50, "%F %T", localtime(&unixTime));
0075
0076 edm::LogInfo("CTPPSAlignmentInfo") << "New " << alignmentType_ << " alignments found in run=" << event.id().run()
0077 << ", event=" << event.id().event() << ", UNIX timestamp=" << unixTime << " ("
0078 << timeStr << "):\n"
0079 << alignments;
0080 }
0081
0082
0083
0084 DEFINE_FWK_MODULE(CTPPSAlignmentInfo);