// access and set functions for binary calorimeter tags
// Version 1.0 21 Oct 1998 Richard creation

#include "towerID.h"

ClassImp(towerID)

///////////////////////////////////////////////////////////////////////////
//                                                                        
// towerID                                                                
//                                                                        
// The towerID class contains a tower ID number (encoding of detector
// element position) as well as functions to obtain the location of
// tower in question. TowerID is used in the CalHit class.
//                                                                        
///////////////////////////////////////////////////////////////////////////
///________________________________________________________________________
 towerID::towerID(){
  m_tag = 0;
}
///________________________________________________________________________
 towerID::towerID(UInt_t tag=0) : m_tag(tag) {
  // Create a towerID object with number tag
  }
///________________________________________________________________________
 UInt_t towerID::tag() const { 
  // Returns the tower number
  return m_tag;
}
///________________________________________________________________________
 void towerID::setTag(UInt_t tagVal) { 
  // Sets the m_tag to tagVal
   m_tag = tagVal;
}
///________________________________________________________________________
 Int_t towerID::theta() const {
  // theta bin in bits 3-11. Extract those bits, return them shifted down
    Int_t  theta = (towerID::thetaOn & m_tag) >> 3;
    return theta;
}
///_______________________________________________________________________
 void towerID::setTheta(Int_t tag) {
// setTheta sets tag theta bits in appropriate place.
    Int_t thetaShift = (tag << 3) & towerID::thetaOn;
    Int_t  theta = (towerID::thetaOff & m_tag) | thetaShift;
    m_tag = theta;
}
///________________________________________________________________________
 Int_t towerID::phi() const {
  // phi bin in bits 12-20. Extract those bits, shift to "bottom", return
    Int_t  phi = (towerID::phiOn & m_tag) >> 12;
    return phi;
}
///________________________________________________________________________
 void towerID::setPhi(Int_t tag) {
  // setPhi sets tag phi bits in appropriate place
  Int_t phiShift = (tag << 12) & towerID::phiOn;
  Int_t  phi = (towerID::phiOff & m_tag) | phiShift;
  m_tag = phi;
}
///________________________________________________________________________
 Int_t towerID::phiBinWidth() const {
  // phi bin width in bits 0-2. phiBinWidth extracts those bits.
  Int_t  phiBinWidth = (towerID::phiBinWidthOn & m_tag);
  return phiBinWidth;
}
///________________________________________________________________________
 void towerID::setPhiBinWidth(Int_t tag) {
  // setPhiBinWidth sets tag phi bin width bits in appropriate place
    Int_t  phiBinWidth = (towerID::phiBinWidthOff & m_tag) | 
      (tag & towerID::phiBinWidthOn);
    m_tag = phiBinWidth;
}
///________________________________________________________________________
 Int_t towerID::layer() const {
  // layer bin in bits 21-26. Extracts those bits, shift to bottom, return
    Int_t  layer = (towerID::layerOn & m_tag) >> 21;
    return layer;
}
///________________________________________________________________________
 void towerID::setLayer(Int_t tag) {
  // setLayer sets tag phi bits in appropriate place
    Int_t layerShift = (tag << 21) & towerID::layerOn;
    Int_t  layer = (towerID::layerOff & m_tag) | layerShift;
    m_tag = layer;
}
///________________________________________________________________________
 Int_t towerID::barrelEndcap() const {
  // barrelEndcap in bit 30. Extract, shift to bottom and return.
    Int_t  barrelEndcap = (towerID::barrelEndcapOn & m_tag) >> 31;
    return barrelEndcap;
}
///________________________________________________________________________
 void towerID::setBarrelEndcap(Int_t tag) {
  // setBarrelEndcap sets tag barrelEndcap bit in appropriate place
    Int_t barrelEndcapShift = (tag << 31) & towerID::barrelEndcapOn;
    Int_t  barrelEndcap = (towerID::barrelEndcapOff & m_tag)
      | barrelEndcapShift;
    m_tag = barrelEndcap;
}
///________________________________________________________________________
 Int_t towerID::system() const {
  // system in bits 28-29. Extract those bits, shift to bottom and return.
    Int_t  system = (towerID::systemOn & m_tag) >> 28;
    return system;
}
///________________________________________________________________________
 void towerID::setSystem(Int_t tag) {
  // setsystem sets tag system bits in appropriate place.
    Int_t systemShift = (tag << 28) & towerID::systemOn;
    Int_t  system = (towerID::systemOff & m_tag) | systemShift;
    m_tag = system;
}
///________________________________________________________________________
 Int_t towerID::northSouth() const {
  // north/south in bit 30. Extract, shift to bottom and return.
    Int_t  northSouth = (towerID::northSouthOn & m_tag) >> 30;
    return northSouth;
}
///________________________________________________________________________
 void towerID::setNorthSouth(Int_t tag) {
  // setNorthSouth sets N/S bit in appropriate place.
  Int_t northSouthShift = (tag << 30) & towerID::northSouthOn;
  Int_t  northSouth = (towerID::northSouthOff & m_tag) | northSouthShift;
  m_tag = northSouth;
}
///________________________________________________________________________

const Int_t  towerID::phiBinWidthOn =  0x00000007;
const Int_t  towerID::phiBinWidthOff = ~towerID::phiBinWidthOn;

const Int_t  towerID::thetaOn =	 0x00000FF8;
const Int_t  towerID::thetaOff =       ~towerID::thetaOn;

const Int_t  towerID::phiOn =	         0x001FF000;
const Int_t  towerID::phiOff =         ~towerID::phiOn;

const Int_t  towerID::layerOn =        0x0FE00000;
const Int_t  towerID::layerOff =       ~towerID::layerOn;

const Int_t  towerID::systemOn =       0x30000000;
const Int_t  towerID::systemOff =      ~towerID::systemOn;

const Int_t  towerID::northSouthOn =   0x40000000;
const Int_t  towerID::northSouthOff =  ~towerID::northSouthOn;

const Int_t  towerID::barrelEndcapOn = 0x80000000;
const Int_t  towerID::barrelEndcapOff = ~towerID::barrelEndcapOn;


ROOT page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.