CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
76 
77  if (strcmp(record_.c_str(), "CTPPSRPAlignmentCorrectionsDataRcd") == 0) {
78  alignments = iSetup.getHandle(tokenAlignmentIdeal_);
79  } else if (strcmp(record_.c_str(), "RPRealAlignmentRecord") == 0) {
80  alignments = iSetup.getHandle(tokenAlignmentReal_);
81  } else {
82  alignments = iSetup.getHandle(tokenAlignmentMisaligned_);
83  }
84 
85  const CTPPSRPAlignmentCorrectionsData* pCTPPSRPAlignmentCorrectionsData = alignments.product();
87  if (poolDbService.isAvailable()) {
88  poolDbService->writeOneIOV(*pCTPPSRPAlignmentCorrectionsData, iov_, record_);
89  }
90 }
91 
92 //----------------------------------------------------------------------------------------------------
93 
95  const edm::Event& event) const {
96  time_t unixTime = event.time().unixTime();
97  char timeStr[50];
98  strftime(timeStr, 50, "%F %T", localtime(&unixTime));
99 
100  edm::LogInfo("CTPPSRPAlignmentInfoAnalyzer")
101  << "New alignments found in run=" << event.id().run() << ", event=" << event.id().event()
102  << ", UNIX timestamp=" << unixTime << " (" << timeStr << "):\n"
103  << alignments;
104 }
105 
106 //----------------------------------------------------------------------------------------------------
107 
edm::ESGetToken< CTPPSRPAlignmentCorrectionsData, RPRealAlignmentRecord > tokenAlignmentReal_
void printInfo(const CTPPSRPAlignmentCorrectionsData &alignments, const edm::Event &event) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Class to print out information on current geometry.
int iEvent
Definition: GenABIO.cc:224
unsigned long long Time_t
Definition: Time.h:14
bool isAvailable() const
Definition: Service.h:40
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo
void analyze(const edm::Event &e, const edm::EventSetup &es) override
T const * product() const
Definition: ESHandle.h:86
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...
CTPPSRPAlignmentInfoAnalyzer(const edm::ParameterSet &ps)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:157