CMS 3D CMS Logo

CTPPSRPAlignmentInfoAnalyzer.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Authors:
4  * Jan Kaspar
5  * Adapted by:
6  * Helena Malbouisson
7  * Clemencia Mora Herrera
8  ****************************************************************************/
9 
22 
26 
28 #include <string>
29 
30 //----------------------------------------------------------------------------------------------------
31 
36 public:
39 
40 private:
41  void analyze(const edm::Event& e, const edm::EventSetup& es) override;
42 
43  void printInfo(const CTPPSRPAlignmentCorrectionsData& alignments, const edm::Event& event) const;
44 
48 
51 };
52 
53 //----------------------------------------------------------------------------------------------------
54 //----------------------------------------------------------------------------------------------------
55 
56 using namespace std;
57 using namespace edm;
58 
59 //----------------------------------------------------------------------------------------------------
60 
62  : record_(iConfig.getParameter<string>("record")), iov_(iConfig.getParameter<unsigned long long>("iov")) {
63  if (strcmp(record_.c_str(), "CTPPSRPAlignmentCorrectionsDataRcd") == 0) {
64  tokenAlignmentIdeal_ = esConsumes<CTPPSRPAlignmentCorrectionsData, CTPPSRPAlignmentCorrectionsDataRcd>();
65  } else if (strcmp(record_.c_str(), "RPRealAlignmentRecord") == 0) {
66  tokenAlignmentReal_ = esConsumes<CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord>();
67  } else {
68  tokenAlignmentMisaligned_ = esConsumes<CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord>();
69  }
70 }
71 
72 //----------------------------------------------------------------------------------------------------
73 
75  const auto alignments = [&r = record_,
76  &eS = iSetup,
77  &tAI = tokenAlignmentIdeal_,
78  &tAR = tokenAlignmentReal_,
80  if (r == "CTPPSRPAlignmentCorrectionsDataRcd") {
81  return eS.getData(tAI);
82  } else if (r == "RPRealAlignmentRecord") {
83  return eS.getData(tAR);
84  } else {
85  return eS.getData(tAM);
86  }
87  }();
88 
90  if (!poolDbService.isAvailable()) {
91  edm::LogError("CTPPSAlignmentInfoAnalyzer") << " DbService not available ";
92  } else {
93  poolDbService->writeOneIOV(alignments, iov_, record_);
94  }
95 }
96 
97 //----------------------------------------------------------------------------------------------------
98 
100  const edm::Event& event) const {
101  time_t unixTime = event.time().unixTime();
102  char timeStr[50];
103  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
104 
105  edm::LogInfo("CTPPSRPAlignmentInfoAnalyzer")
106  << "New alignments found in run=" << event.id().run() << ", event=" << event.id().event()
107  << ", UNIX timestamp=" << unixTime << " (" << timeStr << "):\n"
108  << alignments;
109 }
110 
111 //----------------------------------------------------------------------------------------------------
112 
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord > tokenAlignmentReal_
Class to print out information on current geometry.
Log< level::Error, false > LogError
void printInfo(const CTPPSRPAlignmentCorrectionsData &alignments, const edm::Event &event) const
int iEvent
Definition: GenABIO.cc:224
unsigned long long Time_t
Definition: Time.h:14
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Log< level::Info, false > LogInfo
void analyze(const edm::Event &e, const edm::EventSetup &es) override
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, CTPPSRPAlignmentCorrectionsDataRcd > tokenAlignmentIdeal_
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPMisalignedAlignmentRecord > tokenAlignmentMisaligned_
Container for CTPPS RP alignment corrections. The corrections are stored on two levels - RP and senso...
HLT enums.
CTPPSRPAlignmentInfoAnalyzer(const edm::ParameterSet &ps)
bool isAvailable() const
Definition: Service.h:40
Definition: event.py:1