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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
/*
 *  See header file for a description of this class.
 *
 *  \author Paolo Ronchese INFN Padova
 *
 */

//----------------------
// This Class' Header --
//----------------------
#include "CondFormats/DTObjects/interface/DTT0.h"

//-------------------------------
// Collaborating Class Headers --
//-------------------------------
#include "CondFormats/DTObjects/interface/DTSequentialCellNumber.h"

//---------------
// C++ Headers --
//---------------
#include <iostream>
#include <sstream>

//-------------------
// Initializations --
//-------------------

//----------------
// Constructors --
//----------------
DTT0::DTT0() : dataVersion(" "), nsPerCount(25.0 / 32.0), dataList(DTSequentialCellNumber::max() + 10) {}

DTT0::DTT0(const std::string& version)
    : dataVersion(version), nsPerCount(25.0 / 32.0), dataList(DTSequentialCellNumber::max() + 10) {}

DTT0Data::DTT0Data() : channelId(0), t0mean(0.0), t0rms(0.0) {}

//--------------
// Destructor --
//--------------
DTT0::~DTT0() {}

DTT0Data::~DTT0Data() {}

//--------------
// Operations --
//--------------
int DTT0::get(int wheelId,
              int stationId,
              int sectorId,
              int slId,
              int layerId,
              int cellId,
              float& t0mean,
              float& t0rms,
              DTTimeUnits::type unit) const {
  t0mean = t0rms = 0.0;

  int seqNum = DTSequentialCellNumber::id(wheelId, stationId, sectorId, slId, layerId, cellId);
  if (seqNum < 0)
    return seqNum;

  const DTT0Data& data = dataList[seqNum];
  if (data.channelId == 0)
    return -999999999;

  t0mean = data.t0mean;
  t0rms = data.t0rms;
  if (unit == DTTimeUnits::ns) {
    t0mean *= nsPerCount;
    t0rms *= nsPerCount;
  }
  return 0;
}

int DTT0::get(const DTWireId& id, float& t0mean, float& t0rms, DTTimeUnits::type unit) const {
  return get(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), t0mean, t0rms, unit);
}

float DTT0::unit() const { return nsPerCount; }

const std::string& DTT0::version() const { return dataVersion; }

std::string& DTT0::version() { return dataVersion; }

void DTT0::clear() {
  int i;
  int n = dataList.size();
  for (i = 0; i < n; ++i) {
    DTT0Data& data = dataList[i];
    data.channelId = 0;
    data.t0mean = data.t0rms;
  }
  return;
}

int DTT0::set(int wheelId,
              int stationId,
              int sectorId,
              int slId,
              int layerId,
              int cellId,
              float t0mean,
              float t0rms,
              DTTimeUnits::type unit) {
  if (unit == DTTimeUnits::ns) {
    t0mean /= nsPerCount;
    t0rms /= nsPerCount;
  }

  int seqNum = DTSequentialCellNumber::id(wheelId, stationId, sectorId, slId, layerId, cellId);
  if (seqNum < 0)
    return seqNum;

  DTWireId id(wheelId, stationId, sectorId, slId, layerId, cellId);
  DTT0Data& data = dataList[seqNum];
  data.channelId = id.rawId();
  data.t0mean = t0mean;
  data.t0rms = t0rms;

  return 0;
}

int DTT0::set(const DTWireId& id, float t0mean, float t0rms, DTTimeUnits::type unit) {
  if (unit == DTTimeUnits::ns) {
    t0mean /= nsPerCount;
    t0rms /= nsPerCount;
  }

  int seqNum =
      DTSequentialCellNumber::id(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
  if (seqNum < 0)
    return seqNum;

  DTT0Data& data = dataList[seqNum];
  data.channelId = id.rawId();
  data.t0mean = t0mean;
  data.t0rms = t0rms;

  return 0;
}

void DTT0::setUnit(float unit) { nsPerCount = unit; }

DTT0::const_iterator DTT0::begin() const { return dataList.begin(); }

DTT0::const_iterator DTT0::end() const { return dataList.end(); }