CMS 3D CMS Logo

WriteTotemDAQMapping.cc
Go to the documentation of this file.
11 #include <fstream>
12 #include <iostream>
13 
14 //----------------------------------------------------------------------------------------------------
15 
20 public:
22  ~WriteTotemDAQMapping() override = default;
23 
24 private:
27  std::ofstream outStream_;
28  const bool readMap_;
29  const bool readMask_;
32  void analyze(const edm::Event &e, const edm::EventSetup &es) override;
33 };
34 
36  : subSystemName_(ps.getUntrackedParameter<std::string>("subSystem")),
37  outStream_(ps.getUntrackedParameter<std::string>("fileName"), std::ios_base::app),
38  readMap_(ps.getUntrackedParameter<bool>("readMap")),
39  readMask_(ps.getUntrackedParameter<bool>("readMask")) {
40  if (readMap_ == true) {
42  }
43  if (readMask_ == true) {
45  }
46 }
47 
48 //----------------------------------------------------------------------------------------------------
49 
51  // get mapping
52  if (readMap_ == true) {
53  auto mappingHandle = es.getHandle(mappingToken_);
54  if (mappingHandle.isValid() && !mappingHandle.failedToGet()) {
55  auto const &mapping = *mappingHandle;
57  } else {
58  edm::LogError("WriteTotemDAQMapping mapping") << "WriteTotemDAQMapping: No mapping found";
59  }
60  }
61 
62  // get analysis mask to mask channels
63  if (readMask_ == true) {
64  auto analysisMaskHandle = es.getHandle(maskToken_);
65  if (analysisMaskHandle.isValid() && !analysisMaskHandle.failedToGet()) {
66  auto const &analysisMask = *analysisMaskHandle;
67  outStream_ << analysisMask;
68  } else {
69  edm::LogError("WriteTotemDAQMapping mask") << "WriteTotemDAQMapping: No analysis mask found";
70  }
71  }
72 
73  outStream_.close();
74 }
75 
76 //----------------------------------------------------------------------------------------------------
77 
const std::string subSystemName_
label of the CTPPS sub-system
WriteTotemDAQMapping(const edm::ParameterSet &ps)
Log< level::Error, false > LogError
Writes to file the DAQ mapping loaded by TotemDAQMappingESSourceXML.
edm::ESGetToken< TotemAnalysisMask, TotemAnalysisMaskRcd > maskToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
void analyze(const edm::Event &e, const edm::EventSetup &es) override
~WriteTotemDAQMapping() override=default
edm::ESGetToken< TotemDAQMapping, TotemReadoutRcd > mappingToken_