Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:36

0001 /****************************************************************************
0002  *
0003  * This is a part of TOTEM offline software.
0004  * Authors: 
0005  *  Jan Kašpar (jan.kaspar@gmail.com) 
0006  *
0007  ****************************************************************************/
0008 
0009 #include "CondFormats/DataRecord/interface/TotemAnalysisMaskRcd.h"
0010 #include "CondFormats/DataRecord/interface/TotemReadoutRcd.h"
0011 #include "CondFormats/PPSObjects/interface/TotemAnalysisMask.h"
0012 #include "CondFormats/PPSObjects/interface/TotemDAQMapping.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 
0020 //----------------------------------------------------------------------------------------------------
0021 
0022 /**
0023  *\brief Prints the DAQ mapping loaded by TotemDAQMappingESSourceXML.
0024  **/
0025 class PrintTotemDAQMapping : public edm::one::EDAnalyzer<> {
0026 public:
0027   PrintTotemDAQMapping(const edm::ParameterSet &ps);
0028   ~PrintTotemDAQMapping() override {}
0029 
0030 private:
0031   /// label of the CTPPS sub-system
0032   const std::string subSystemName_;
0033   const edm::ESGetToken<TotemDAQMapping, TotemReadoutRcd> mappingToken_;
0034   const edm::ESGetToken<TotemAnalysisMask, TotemAnalysisMaskRcd> maskToken_;
0035   void analyze(const edm::Event &e, const edm::EventSetup &es) override;
0036 };
0037 
0038 PrintTotemDAQMapping::PrintTotemDAQMapping(const edm::ParameterSet &ps)
0039     : subSystemName_(ps.getUntrackedParameter<std::string>("subSystem")),
0040       mappingToken_(esConsumes(edm::ESInputTag("", subSystemName_))),
0041       maskToken_(esConsumes(edm::ESInputTag("", subSystemName_))) {}
0042 
0043 //----------------------------------------------------------------------------------------------------
0044 
0045 void PrintTotemDAQMapping::analyze(const edm::Event &, edm::EventSetup const &es) {
0046   // get mapping
0047   if (auto mappingHandle = es.getHandle(mappingToken_)) {
0048     auto const &mapping = *mappingHandle;
0049     edm::LogInfo("PrintTotemDAQMapping mapping");
0050     mapping.print(std::cout, subSystemName_);
0051   } else {
0052     edm::LogError("PrintTotemDAQMapping mapping") << "PrintTotemDAQMapping: No mapping found";
0053   }
0054 
0055   // get analysis mask to mask channels
0056   if (auto analysisMaskHandle = es.getHandle(maskToken_)) {
0057     auto const &analysisMask = *analysisMaskHandle;
0058     edm::LogPrint("PrintTotemDAQMapping") << analysisMask;
0059   } else {
0060     edm::LogError("PrintTotemDAQMapping mask") << "PrintTotemDAQMapping: No analysis mask found";
0061   }
0062 }
0063 
0064 //----------------------------------------------------------------------------------------------------
0065 
0066 DEFINE_FWK_MODULE(PrintTotemDAQMapping);