CTPPSPixelDAQMappingAnalyzer

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
// system include files
#include <memory>

#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "CondCore/CondDB/interface/Time.h"

#include "CondFormats/PPSObjects/interface/CTPPSPixelDAQMapping.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelDAQMappingRcd.h"
#include "CondFormats/PPSObjects/interface/CTPPSPixelAnalysisMask.h"
#include "CondFormats/DataRecord/interface/CTPPSPixelAnalysisMaskRcd.h"

using namespace std;

class CTPPSPixelDAQMappingAnalyzer : public edm::one::EDAnalyzer<> {
public:
  string label_;
  cond::Time_t daqmappingiov_;
  cond::Time_t analysismaskiov_;

  edm::ESGetToken<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd> tokenMapping_;
  edm::ESGetToken<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd> tokenMask_;

  explicit CTPPSPixelDAQMappingAnalyzer(edm::ParameterSet const& iConfig)
      : label_(iConfig.getUntrackedParameter<string>("label", "RPix")),
        daqmappingiov_(iConfig.getParameter<unsigned long long>("daqmappingiov")),
        analysismaskiov_(iConfig.getParameter<unsigned long long>("analysismaskiov")),
        tokenMapping_(esConsumes<CTPPSPixelDAQMapping, CTPPSPixelDAQMappingRcd>(edm::ESInputTag("", label_))),
        tokenMask_(esConsumes<CTPPSPixelAnalysisMask, CTPPSPixelAnalysisMaskRcd>(edm::ESInputTag("", label_))) {}
  explicit CTPPSPixelDAQMappingAnalyzer(int i) {}
  ~CTPPSPixelDAQMappingAnalyzer() override {}
  void analyze(const edm::Event& e, const edm::EventSetup& c) override;
};

void CTPPSPixelDAQMappingAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
  using namespace edm;

  /*edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelDAQMappingRcd"));
    if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
      //record not found
      std::cout <<"Record \"CTPPSPixelDAQMappingRcd"<<"\" does not exist "<<std::endl;
    }*/

  //this part gets the handle of the event source and the record (i.e. the Database)
  if (e.id().run() == daqmappingiov_) {
    ESHandle<CTPPSPixelDAQMapping> mapping = context.getHandle(tokenMapping_);

    // print mapping
    /*printf("* DAQ mapping\n");
      for (const auto &p : mapping->ROCMapping)
      std::cout << "    " << p.first << " -> " << p.second << std::endl;*/
  }

  //edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("CTPPSPixelAnalysisMaskRcd"));
  //if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
  //record not found
  //std::cout <<"Record \"CTPPSPixelAnalysisMaskRcd"<<"\" does not exist "<<std::endl;
  //}

  if (e.id().run() == analysismaskiov_) {
    // get analysis mask to mask channels
    ESHandle<CTPPSPixelAnalysisMask> analysisMask = context.getHandle(tokenMask_);

    // print mask
    /*printf("* mask\n");
      for (const auto &p : analysisMask->analysisMask)
        cout << "    " << p.first
        << ": fullMask=" << p.second.fullMask
        << ", number of masked channels " << p.second.maskedPixels.size() << endl;
      */
  }
}
DEFINE_FWK_MODULE(CTPPSPixelDAQMappingAnalyzer);