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
/** \file CSCRangeMapAccessor.cc
 *
 *  \author Matteo Sani
 */

#include "DataFormats/CSCRecHit/interface/CSCRangeMapAccessor.h"
#include <cstdlib>

CSCRangeMapAccessor::CSCRangeMapAccessor() {}

CSCRangeMapAccessor::~CSCRangeMapAccessor() {}

std::pair<CSCDetId, CSCDetIdSameChamberComparator> CSCRangeMapAccessor::cscChamber(CSCDetId id) {
  return std::make_pair(id, CSCDetIdSameChamberComparator());
}

std::pair<CSCDetId, CSCDetIdSameDetLayerComparator> CSCRangeMapAccessor::cscDetLayer(CSCDetId id) {
  return std::make_pair(id, CSCDetIdSameDetLayerComparator());
}

bool CSCDetIdSameChamberComparator::operator()(CSCDetId i1, CSCDetId i2) const {
  if (i1.chamberId() == i2.chamberId())
    return false;

  return (i1 < i2);
}

bool CSCDetIdSameDetLayerComparator::operator()(CSCDetId i1, CSCDetId i2) const {
  bool station = false;
  if (i1.endcap() == i2.endcap() && i1.station() == i2.station())
    station = true;

  // Same DetLayer for station 2,3 and 4
  if ((station) && (i1.station() != 1))
    return false;

  // Same DetLayer for station 1
  if ((station) && (i1.station() == 1)) {
    int delta = abs(i1.ring() - i2.ring());
    int sum = i1.ring() + i2.ring();

    // Same DetLayer: rings 1,4 or rings 2,3
    if ((delta == 0) || (sum == 5))
      return false;
  }

  return (i1 < i2);
}