CMS 3D CMS Logo

WriteCTPPSTotemDAQMappingMask.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Offline analyzer for writing TOTEM DAQ Mapping sqlite file
4 *
5 ****************************************************************************/
6 
23 #include <cstdint>
24 
25 //----------------------------------------------------------------------------------------------------
26 
31 public:
33  ~WriteCTPPSTotemDAQMappingMask() override = default;
34 
35 private:
42 
43  void analyze(const edm::Event &e, const edm::EventSetup &es) override;
44 };
45 
46 //----------------------------------------------------------------------------------------------------
47 
49  : daqMappingIov_(ps.getParameter<unsigned long long>("daqMappingIov")),
50  recordMap_(ps.getParameter<std::string>("recordMap")),
51  recordMask_(ps.getParameter<std::string>("recordMask")),
52  label_(ps.getParameter<std::string>("label")),
53  tokenMapping_(esConsumes<TotemDAQMapping, TotemReadoutRcd>(edm::ESInputTag("", label_))),
54  tokenAnalysisMask_(esConsumes<TotemAnalysisMask, TotemReadoutRcd>(edm::ESInputTag("", label_))) {}
55 
58 
59  auto mappingHandle = es.getHandle(tokenMapping_);
60  if (!recordMap_.empty() && mappingHandle.isValid() && !mappingHandle.failedToGet()) {
61  const auto &mapping = es.getData(tokenMapping_);
62  std::stringstream output;
63  mapping.print(output, label_);
64  edm::LogInfo("WriteCTPPSTotemDAQMappingMask mapping") << output.str();
65 
66  if (poolDbService.isAvailable()) {
67  poolDbService->writeOneIOV(mapping, daqMappingIov_, recordMap_);
68  } else {
69  edm::LogError("WriteCTPPSTotemDAQMappingMask mapping")
70  << "WriteCTPPSTotemDAQMappingMask: PoolDBService not availible. Data not written.";
71  }
72 
73  } else {
74  edm::LogWarning("WriteCTPPSTotemDAQMappingMask mapping") << "WriteCTPPSTotemDAQMappingMask: No mapping found";
75  }
76 
77  auto maskHandle = es.getHandle(tokenAnalysisMask_);
78  if (!recordMask_.empty() && maskHandle.isValid() && !maskHandle.failedToGet()) {
79  const auto &analysisMask = es.getData(tokenAnalysisMask_);
80  edm::LogInfo("WriteCTPPSTotemDAQMappingMask mask") << analysisMask;
81 
82  if (poolDbService.isAvailable()) {
83  poolDbService->writeOneIOV(analysisMask, daqMappingIov_, recordMask_);
84  } else {
85  edm::LogError("WriteCTPPSTotemDAQMappingMask mask")
86  << "WriteCTPPSTotemDAQMappingMask: PoolDBService not availible. Data not written.";
87  }
88  } else {
89  edm::LogWarning("WriteCTPPSTotemDAQMappingMask mask") << "WriteCTPPSTotemDAQMappingMask: No analysis mask found";
90  }
91 }
92 
93 //----------------------------------------------------------------------------------------------------
94 
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
Channel-mask mapping.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
EventSetup record for TOTEM readout-related information.
Prints and writes to SQLite the DAQ mapping loaded by TotemDAQMappingESSourceXML. ...
Log< level::Error, false > LogError
~WriteCTPPSTotemDAQMappingMask() override=default
const edm::ESGetToken< TotemAnalysisMask, TotemReadoutRcd > tokenAnalysisMask_
unsigned long long Time_t
Definition: Time.h:14
WriteCTPPSTotemDAQMappingMask(const edm::ParameterSet &ps)
The mapping between FramePosition and VFATInfo.
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
Log< level::Info, false > LogInfo
const edm::ESGetToken< TotemDAQMapping, TotemReadoutRcd > tokenMapping_
HLT enums.
void analyze(const edm::Event &e, const edm::EventSetup &es) override
bool isAvailable() const
Definition: Service.h:40
Definition: output.py:1
Log< level::Warning, false > LogWarning