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
#include "CondFormats/RPCObjects/interface/DBSpecToDetUnit.h"
#include "DataFormats/MuonDetId/interface/RPCDetId.h"
#include "CondFormats/RPCObjects/interface/ChamberLocationSpec.h"
#include "CondFormats/RPCObjects/interface/FebLocationSpec.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"
#include <iostream>
#include <string>

using namespace std;
using namespace edm;

uint32_t DBSpecToDetUnit::operator()(const ChamberLocationSpec& ch, const FebLocationSpec& feb) {
  // REGION
  int region = -2;
  bool barrel = (ch.barrelOrEndcap == 1);
  if (barrel)
    region = 0;
  else if (ch.diskOrWheel < 0)
    region = -1;
  else if (ch.diskOrWheel > 0)
    region = 1;

  //ROLL
  string localEtaPartVal[6] = {"Forward", "Central", "Backward", "A", "B", "C"};
  string nroll = localEtaPartVal[feb.localEtaPartition - 1];

  //SUBSECTOR
  string subsecVal[5] = {"--", "-", "0", "+", "++"};
  string subsec = subsecVal[ch.subsector + 2];

  // build RPCdetId
  try {
    RPCDetId dn;
    dn.buildfromDB(region, ch.diskOrWheel, ch.layer, ch.sector, subsec, nroll, " ");
    return dn.rawId();
  } catch (cms::Exception& e) {
    LogDebug("CondFormas/DBSpecToDetInit") << " Problem with RPCDetId, got exception!! "
                                           << "DB Chamber " << ch.chamberLocationName() << " roll " << nroll << e;
    return 0;
  }
}