1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/****************************************************************************
*
* Offline analyzer for writing TOTEM DAQ Mapping sqlite file
*
****************************************************************************/
#include "CondCore/CondDB/interface/Time.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondFormats/DataRecord/interface/TotemAnalysisMaskRcd.h"
#include "CondFormats/DataRecord/interface/TotemReadoutRcd.h"
#include "CondFormats/PPSObjects/interface/TotemAnalysisMask.h"
#include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/Utilities/interface/ESInputTag.h"
#include <cstdint>
//----------------------------------------------------------------------------------------------------
/**
*\brief Prints and writes to SQLite the DAQ mapping loaded by TotemDAQMappingESSourceXML.
**/
class WriteCTPPSTotemDAQMappingMask : public edm::one::EDAnalyzer<> {
public:
WriteCTPPSTotemDAQMappingMask(const edm::ParameterSet &ps);
~WriteCTPPSTotemDAQMappingMask() override = default;
private:
const cond::Time_t daqMappingIov_;
const std::string recordMap_;
const std::string recordMask_;
const std::string label_;
const edm::ESGetToken<TotemDAQMapping, TotemReadoutRcd> tokenMapping_;
const edm::ESGetToken<TotemAnalysisMask, TotemReadoutRcd> tokenAnalysisMask_;
void analyze(const edm::Event &e, const edm::EventSetup &es) override;
};
//----------------------------------------------------------------------------------------------------
WriteCTPPSTotemDAQMappingMask::WriteCTPPSTotemDAQMappingMask(const edm::ParameterSet &ps)
: daqMappingIov_(ps.getParameter<unsigned long long>("daqMappingIov")),
recordMap_(ps.getParameter<std::string>("recordMap")),
recordMask_(ps.getParameter<std::string>("recordMask")),
label_(ps.getParameter<std::string>("label")),
tokenMapping_(esConsumes<TotemDAQMapping, TotemReadoutRcd>(edm::ESInputTag("", label_))),
tokenAnalysisMask_(esConsumes<TotemAnalysisMask, TotemReadoutRcd>(edm::ESInputTag("", label_))) {}
void WriteCTPPSTotemDAQMappingMask::analyze(const edm::Event &, edm::EventSetup const &es) {
edm::Service<cond::service::PoolDBOutputService> poolDbService;
auto mappingHandle = es.getHandle(tokenMapping_);
if (!recordMap_.empty() && mappingHandle.isValid() && !mappingHandle.failedToGet()) {
const auto &mapping = es.getData(tokenMapping_);
std::stringstream output;
mapping.print(output, label_);
edm::LogInfo("WriteCTPPSTotemDAQMappingMask mapping") << output.str();
if (poolDbService.isAvailable()) {
poolDbService->writeOneIOV(mapping, daqMappingIov_, recordMap_);
} else {
edm::LogError("WriteCTPPSTotemDAQMappingMask mapping")
<< "WriteCTPPSTotemDAQMappingMask: PoolDBService not availible. Data not written.";
}
} else {
edm::LogWarning("WriteCTPPSTotemDAQMappingMask mapping") << "WriteCTPPSTotemDAQMappingMask: No mapping found";
}
auto maskHandle = es.getHandle(tokenAnalysisMask_);
if (!recordMask_.empty() && maskHandle.isValid() && !maskHandle.failedToGet()) {
const auto &analysisMask = es.getData(tokenAnalysisMask_);
edm::LogInfo("WriteCTPPSTotemDAQMappingMask mask") << analysisMask;
if (poolDbService.isAvailable()) {
poolDbService->writeOneIOV(analysisMask, daqMappingIov_, recordMask_);
} else {
edm::LogError("WriteCTPPSTotemDAQMappingMask mask")
<< "WriteCTPPSTotemDAQMappingMask: PoolDBService not availible. Data not written.";
}
} else {
edm::LogWarning("WriteCTPPSTotemDAQMappingMask mask") << "WriteCTPPSTotemDAQMappingMask: No analysis mask found";
}
}
//----------------------------------------------------------------------------------------------------
DEFINE_FWK_MODULE(WriteCTPPSTotemDAQMappingMask);
|