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
#include "CalibMuon/RPCCalibration/interface/RPCCalibSetUp.h"
#include "CalibMuon/RPCCalibration/interface/RPCFakeCalibration.h"
#include "CondFormats/DataRecord/interface/RPCStripNoisesRcd.h"
#include "CondFormats/RPCObjects/interface/RPCStripNoises.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

#include <cmath>
#include <fstream>
#include <iostream>
#include <memory>

RPCFakeCalibration::RPCFakeCalibration(const edm::ParameterSet &pset) : RPCPerformanceESSource(pset) {
  edm::LogInfo("RPCFakeCalibration::RPCFakeCalibration");
  theRPCCalibSetUp = new RPCCalibSetUp(pset);
}

RPCStripNoises *RPCFakeCalibration::makeNoise() {
  RPCStripNoises *obj = new RPCStripNoises();

  std::map<int, std::vector<double>>::iterator itc;
  for (itc = (theRPCCalibSetUp->_clsMap).begin(); itc != (theRPCCalibSetUp->_clsMap).end(); ++itc) {
    for (unsigned int n = 0; n < (itc->second).size(); ++n) {
      (obj->v_cls).push_back((itc->second)[n]);
    }
  }

  RPCStripNoises::NoiseItem tipoprova;
  for (std::map<uint32_t, std::vector<float>>::iterator it = (theRPCCalibSetUp->_mapDetIdNoise).begin();
       it != (theRPCCalibSetUp->_mapDetIdNoise).end();
       ++it) {
    tipoprova.dpid = it->first;
    tipoprova.time = theRPCCalibSetUp->getTime(it->first);

    for (unsigned int k = 0; k < 96; ++k) {
      tipoprova.noise = ((it->second))[k];
      tipoprova.eff = (theRPCCalibSetUp->getEff(it->first))[k];
      (obj->v_noises).push_back(tipoprova);
    }
  }

  return obj;
}

RPCClusterSize *RPCFakeCalibration::makeCls() {
  RPCClusterSize *obj = new RPCClusterSize();
  RPCClusterSize::ClusterSizeItem rpcClsItem;

  for (std::map<uint32_t, std::vector<double>>::iterator it = (theRPCCalibSetUp->_mapDetClsMap).begin();
       it != (theRPCCalibSetUp->_mapDetClsMap).end();
       ++it) {
    rpcClsItem.dpid = it->first;

    for (unsigned int k = 0; k < 100; k++) {
      rpcClsItem.clusterSize = (theRPCCalibSetUp->getCls(it->first))[k];
      (obj->v_cls).push_back(rpcClsItem);
    }
  }
  return obj;
}