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
/** \file
 *  See header file for a description of this class.
 *
 *  \author G. Cerminara - INFN Torino
 */

#include <iostream>
#include <DataFormats/MuonDetId/interface/DTSuperLayerId.h>
#include <FWCore/Utilities/interface/Exception.h>

DTSuperLayerId::DTSuperLayerId() : DTChamberId() {}

DTSuperLayerId::DTSuperLayerId(uint32_t id) {
  id_ = id & slIdMask_;  // Mask the bits outside DTSuperLayerId fields
  checkMuonId();         // Check this is a valid id for muon DTs.
}

DTSuperLayerId::DTSuperLayerId(int wheel, int station, int sector, int superlayer)
    : DTChamberId(wheel, station, sector) {
  if (superlayer < minSuperLayerId || superlayer > maxSuperLayerId) {
    throw cms::Exception("InvalidDetId") << "DTSuperLayerId ctor:"
                                         << " Invalid parameters: "
                                         << " Wh:" << wheel << " St:" << station << " Se:" << sector
                                         << " Sl:" << superlayer << std::endl;
  }
  id_ |= (superlayer & slMask_) << slayerStartBit_;
}

// Copy Constructor.
DTSuperLayerId::DTSuperLayerId(const DTSuperLayerId& slId) : DTChamberId() {
  // The mask is required for proper slicing, i.e. if slId is
  // actually a derived class.
  id_ = (slId.rawId() & slIdMask_);
}

// Constructor from a camberId and SL number
DTSuperLayerId::DTSuperLayerId(const DTChamberId& chId, int superlayer) : DTChamberId(chId) {
  if (superlayer < minSuperLayerId || superlayer > maxSuperLayerId) {
    throw cms::Exception("InvalidDetId") << "DTSuperLayerId ctor:"
                                         << " Invalid parameter: "
                                         << " Sl:" << superlayer << std::endl;
  }
  id_ |= (superlayer & slMask_) << slayerStartBit_;
}

std::ostream& operator<<(std::ostream& os, const DTSuperLayerId& id) {
  os << " Wh:" << id.wheel() << " St:" << id.station() << " Se:" << id.sector() << " Sl:" << id.superlayer() << " ";

  return os;
}