Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-16 06:12:28

0001 /****************************************************************************
0002 *
0003 * Offline analyzer for writing CTPPS Analysis Mask sqlite file 
0004 * H. Malbouisson
0005 * based on TOTEM code from  Jan Kašpar (jan.kaspar@gmail.com)
0006 *
0007 ****************************************************************************/
0008 
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "CondCore/CondDB/interface/Time.h"
0016 
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 
0019 #include "FWCore/ServiceRegistry/interface/Service.h"
0020 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
0021 
0022 #include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
0023 #include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"
0024 #include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
0025 #include "CondFormats/PPSObjects/interface/CTPPSPixelAnalysisMask.h"
0026 
0027 #include <cstdint>
0028 
0029 //----------------------------------------------------------------------------------------------------
0030 
0031 /**
0032  *\brief Prints the Analysis Mask loaded by TotemDAQMappingESSourceXML.
0033  **/
0034 class WriteCTPPSPixelAnalysisMask : public edm::one::EDAnalyzer<> {
0035 public:
0036   WriteCTPPSPixelAnalysisMask(const edm::ParameterSet &ps);
0037   ~WriteCTPPSPixelAnalysisMask() override {}
0038 
0039 private:
0040   void analyze(const edm::Event &e, const edm::EventSetup &es) override;
0041   cond::Time_t analysismaskiov_;
0042   std::string record_;
0043   std::string label_;
0044 
0045   edm::ESGetToken<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd> tokenAnalysisMask_;
0046 };
0047 
0048 using namespace std;
0049 using namespace edm;
0050 
0051 //----------------------------------------------------------------------------------------------------
0052 
0053 WriteCTPPSPixelAnalysisMask::WriteCTPPSPixelAnalysisMask(const edm::ParameterSet &ps)
0054     : analysismaskiov_(ps.getParameter<unsigned long long>("analysismaskiov")),
0055       record_(ps.getParameter<string>("record")),
0056       label_(ps.getParameter<string>("label")),
0057       tokenAnalysisMask_(esConsumes<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd>(edm::ESInputTag("", label_))) {}
0058 
0059 void WriteCTPPSPixelAnalysisMask::analyze(const edm::Event &, edm::EventSetup const &es) {
0060   /*// print analysisMask
0061   printf("* mask\n");
0062   for (const auto &p : analysisMask->analysisMask)
0063     cout << "    " << p.first
0064       << ": fullMask=" << p.second.fullMask
0065       << ", number of masked channels " << p.second.maskedPixels.size() << endl;
0066   */
0067 
0068   // Write Analysis Mask to sqlite file:
0069 
0070   const auto &analysisMask = es.getData(tokenAnalysisMask_);
0071   edm::Service<cond::service::PoolDBOutputService> poolDbService;
0072   if (poolDbService.isAvailable()) {
0073     poolDbService->writeOneIOV(analysisMask, analysismaskiov_, record_);
0074   }
0075 }
0076 
0077 //----------------------------------------------------------------------------------------------------
0078 
0079 DEFINE_FWK_MODULE(WriteCTPPSPixelAnalysisMask);