Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:43

0001 // system include files
0002 #include <memory>
0003 
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 #include "FWCore/Framework/interface/MakerMacros.h"
0009 #include "CondCore/CondDB/interface/Time.h"
0010 
0011 #include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
0012 #include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
0013 #include "CondFormats/PPSObjects/interface/CTPPSPixelAnalysisMask.h"
0014 #include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"
0015 
0016 using namespace std;
0017 
0018 class CTPPSPixelDAQMappingAnalyzer : public edm::one::EDAnalyzer<> {
0019 public:
0020   string label_;
0021   cond::Time_t daqmappingiov_;
0022   cond::Time_t analysismaskiov_;
0023 
0024   edm::ESGetToken<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd> tokenMapping_;
0025   edm::ESGetToken<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd> tokenMask_;
0026 
0027   explicit CTPPSPixelDAQMappingAnalyzer(edm::ParameterSet const& iConfig)
0028       : label_(iConfig.getUntrackedParameter<string>("label", "RPix")),
0029         daqmappingiov_(iConfig.getParameter<unsigned long long>("daqmappingiov")),
0030         analysismaskiov_(iConfig.getParameter<unsigned long long>("analysismaskiov")),
0031         tokenMapping_(esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>(edm::ESInputTag("", label_))),
0032         tokenMask_(esConsumes<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd>(edm::ESInputTag("", label_))) {}
0033   explicit CTPPSPixelDAQMappingAnalyzer(int i) {}
0034   ~CTPPSPixelDAQMappingAnalyzer() override {}
0035   void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0036 };
0037 
0038 void CTPPSPixelDAQMappingAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0039   using namespace edm;
0040 
0041   /*edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelDAQMappingRcd"));
0042     if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0043       //record not found
0044       std::cout <<"Record \"CTPPSPixelDAQMappingRcd"<<"\" does not exist "<<std::endl;
0045     }*/
0046 
0047   //this part gets the handle of the event source and the record (i.e. the Database)
0048   if (e.id().run() == daqmappingiov_) {
0049     ESHandle<CTPPSPixelDAQMapping> mapping = context.getHandle(tokenMapping_);
0050 
0051     // print mapping
0052     /*printf("* DAQ mapping\n");
0053       for (const auto &p : mapping->ROCMapping)
0054       std::cout << "    " << p.first << " -> " << p.second << std::endl;*/
0055   }
0056 
0057   //edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelAnalysisMaskRcd"));
0058   //if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0059   //record not found
0060   //std::cout <<"Record \"CTPPSPixelAnalysisMaskRcd"<<"\" does not exist "<<std::endl;
0061   //}
0062 
0063   if (e.id().run() == analysismaskiov_) {
0064     // get analysis mask to mask channels
0065     ESHandle<CTPPSPixelAnalysisMask> analysisMask = context.getHandle(tokenMask_);
0066 
0067     // print mask
0068     /*printf("* mask\n");
0069       for (const auto &p : analysisMask->analysisMask)
0070         cout << "    " << p.first
0071         << ": fullMask=" << p.second.fullMask
0072         << ", number of masked channels " << p.second.maskedPixels.size() << endl;
0073       */
0074   }
0075 }
0076 DEFINE_FWK_MODULE(CTPPSPixelDAQMappingAnalyzer);