CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

cscdqm::Detector Class Reference

Detector geometry and addressing related imformation and routines. More...

#include <CSCDQM_Detector.h>

List of all members.

Public Member Functions

const bool AddressFromString (const std::string &str_address, Address &adr) const
 Construct address from string.
const float Area (const unsigned int station) const
 Calculate station area in eta/phi space.
const float Area (const Address &adr) const
 Calculate address area in eta/phi space.
 Detector (const unsigned int p_partitions_x=0, const unsigned int p_partitions_y=0)
 Constructor.
unsigned int GlobalChamberIndex (unsigned int side, unsigned int station, unsigned int ring, unsigned int chamber) const
 Return global chamber index on his geometric location.
const bool NextAddress (unsigned int &i, const Address *&adr, const Address &mask) const
 Address iterator by mask.
const bool NextAddressBox (unsigned int &i, const AddressBox *&box, const Address &mask) const
 Address box iterator by mask.
const bool NextAddressBoxByPartition (unsigned int &i, const unsigned int px, const unsigned int py, AddressBox *&box)
 Address box iterator by partition.
const unsigned int NumberOfChamberCFEBs (const unsigned int station, const unsigned int ring) const
 Returns the number of CFEBs per Chamber on given Station/Ring.
const unsigned int NumberOfChamberHVs (const unsigned int station, const unsigned int ring) const
 Returns the number of HVs per Chamber on given Station/Ring.
const unsigned int NumberOfChambers (const unsigned int station, const unsigned int ring) const
 Returns the number of chambers for the given station and ring.
const unsigned int NumberOfRings (const unsigned int station) const
 Returns the number of rings for the given station.
void PrintAddress (const Address &adr) const
 Prints address for debugging.

Private Member Functions

const float Eta (const float r, const float z) const
const float EtaToX (const float eta) const
 Transform eta coordinate to local canvas coordinate.
const float PhiMaxCFEB (const int station, const int ring, const int chamber, const int cfeb) const
 Get Max phi boundary for particular CFEB.
const float PhiMinCFEB (const int station, const int ring, const int chamber, const int cfeb) const
 Get Min phi boundary for particular CFEB.
const float PhiToY (const float phi) const
 Transform phi coordinate to local canvas coordinate.
const float RMaxHV (const int station, const int ring, const int n_hv) const
 Get R max parameter (used in address eta/phi calculation)
const float RMinHV (const int station, const int ring, const int n_hv) const
 Get R min parameter (used in address eta/phi calculation)
const float Z (const int station, const int ring) const
 Get Z parameter (used in address eta/phi calculation)

Private Attributes

AddressBox boxes [N_ELEMENTS]
PartitionMap partitions
unsigned int partitions_x
unsigned int partitions_y
float station_area [N_STATIONS]

Detailed Description

Detector geometry and addressing related imformation and routines.

Definition at line 183 of file CSCDQM_Detector.h.


Constructor & Destructor Documentation

afs cern ch work a aaltunda public www CMSSW_6_2_5 src DQM CSCMonitorModule plugins CSCDQM_Detector cc cscdqm::Detector::Detector ( const unsigned int  p_partitions_x = 0,
const unsigned int  p_partitions_y = 0 
)

Constructor.

Parameters:
p_partition_xNumber of efficiency partitions on X axis
p_partition_yNumber of efficiency partitions on Y axis
Returns:

Creating real eta/phi boxes for available addresses

Address box calculated successfully. Now lets cache its partition elements for performace.

Cached the most frequently used areas

Definition at line 34 of file CSCDQM_Detector.cc.

References cscdqm::AddressBox::adr, boxes, cscdqm::Address::cfeb, cscdqm::Address::chamber, Eta(), EtaToX(), cscdqm::Address::hv, i, getHLTprescales::index, N_STATIONS, NumberOfChamberCFEBs(), NumberOfChamberHVs(), NumberOfChambers(), NumberOfRings(), PARTITION_INDEX, PARTITION_STEP_X, PARTITION_STEP_Y, partitions, partitions_x, PhiMaxCFEB(), PhiMinCFEB(), PhiToY(), cscdqm::Address::ring, RMaxHV(), RMinHV(), cscdqm::Address::side, cscdqm::Address::station, findQualityFiles::v, x, cscdqm::AddressBox::xmax, cscdqm::AddressBox::xmin, detailsBasic3DVector::y, cscdqm::AddressBox::ymax, cscdqm::AddressBox::ymin, Z(), and z.

                                                        { 
      float sign = +1.0;
      if(adr.side == 2) sign = -1.0;
      for (adr.station = 1; adr.station <= N_STATIONS; adr.station++) {
        for (adr.ring = 1; adr.ring <= NumberOfRings(adr.station); adr.ring++) { 
          for (adr.chamber = 1; adr.chamber <= NumberOfChambers(adr.station, adr.ring); adr.chamber++) {
            for (adr.cfeb = 1; adr.cfeb <= NumberOfChamberCFEBs(adr.station, adr.ring); adr.cfeb++) {
              for (adr.hv = 1; adr.hv <= NumberOfChamberHVs(adr.station, adr.ring); adr.hv++) {
  
                float z = Z(adr.station, adr.ring);
                float r_min = RMinHV(adr.station, adr.ring, adr.hv);
                float r_max = RMaxHV(adr.station, adr.ring, adr.hv);
                float eta_min = sign * Eta(r_min, z);
                float eta_max = sign * Eta(r_max, z);
                float x_min = EtaToX(eta_min);
                float x_max = EtaToX(eta_max);
                float phi_min = 0;
                float phi_max = 0;
  
                if(adr.station == 1 && adr.ring == 1 && adr.hv == 1) {
                  phi_min = PhiMinCFEB(adr.station, adr.ring, adr.chamber, 1);
                  phi_max = PhiMaxCFEB(adr.station, adr.ring, adr.chamber, NumberOfChamberCFEBs(adr.station, adr.ring));
                } else {
                  phi_min = PhiMinCFEB(adr.station, adr.ring, adr.chamber, adr.cfeb);
                  phi_max = PhiMaxCFEB(adr.station, adr.ring, adr.chamber, adr.cfeb);
                }
  
                float y_min = PhiToY(phi_min);
                float y_max = PhiToY(phi_max);
                  
                boxes[i].adr = adr;
  
                float xboxmin = (x_min < x_max ? x_min : x_max);
                float xboxmax = (x_max > x_min ? x_max : x_min);
                float yboxmin = (y_min < y_max ? y_min : y_max);
                float yboxmax = (y_max > y_min ? y_max : y_min);
  
                boxes[i].xmin = xboxmin;
                boxes[i].xmax = xboxmax;
                boxes[i].ymin = yboxmin;
                boxes[i].ymax = yboxmax;
  
                unsigned int x1 = int(floor(xboxmin / PARTITION_STEP_X)) + int(partitions_x / 2);
                unsigned int x2 = int( ceil(xboxmax / PARTITION_STEP_X)) + int(partitions_x / 2);
                unsigned int y1 = int(floor(yboxmin / PARTITION_STEP_Y));
                unsigned int y2 = int( ceil(yboxmax / PARTITION_STEP_Y));
  
                for (unsigned int x = x1; x < x2; x++) {
                  for (unsigned int y = y1; y < y2; y++) {
                    
                    unsigned int index = PARTITION_INDEX(x, y);
                    PartitionMapIterator iter = partitions.find(index);
                    if (iter == partitions.end()) {
                      std::vector<unsigned int> v;
                      partitions.insert(std::make_pair(index, v));
                    }
                    partitions[index].push_back(i);
  
                  }
                }
  
                i++;
  
              }
            }
          }
        }
      }
  
    }
  
    adr.mask.side = adr.mask.ring = adr.mask.chamber = adr.mask.layer = adr.mask.cfeb = adr.mask.hv = false;
    adr.mask.station = true;
    adr.station = 1;
    station_area[0] = Area(adr);
    adr.station = 2;
    station_area[1] = Area(adr);
    adr.station = 3;
    station_area[2] = Area(adr);
    adr.station = 4;
    station_area[3] = Area(adr);
  
  }
  

Member Function Documentation

const bool cscdqm::Detector::AddressFromString ( const std::string &  str_address,
Address adr 
) const

Construct address from string.

Parameters:
str_addressAddress in string
adrAddress to return
Returns:
true if address was successfully created, false - otherwise

Definition at line 573 of file CSCDQM_Detector.cc.

Referenced by cscdqm::Summary::setMaskedHWElements().

                                                 {
  
      std::string token = tokens.at(r);
      Utility::trimString(token);
      bool mask = false;
      unsigned int num  = 0;
  
      if (token.compare("*") != 0) {
        if(stringToNumber<unsigned int>(num, token, std::dec)) {
          mask = true;
        } else {
          return false;
        }
      }
  
      switch (r) {
        case 0:
          adr.mask.side = mask;
          adr.side = num;
          break;
        case 1:
          adr.mask.station = mask;
          adr.station = num;
          break;
        case 2:
          adr.mask.ring = mask;
          adr.ring = num;
          break;
        case 3:
          adr.mask.chamber = mask;
          adr.chamber = num;
          break;
        case 4:
          adr.mask.layer = mask;
          adr.layer = num;
          break;
        case 5:
          adr.mask.cfeb = mask;
          adr.cfeb = num;
          break;
        case 6:
          adr.mask.hv = mask;
          adr.hv = num;
      }
  
    } 
  
    return true;
  
  }

const float cscdqm::Detector::Area ( const Address adr) const

Calculate address area in eta/phi space.

Parameters:
adrAddress
Returns:
Area that is being covered by address

Definition at line 185 of file CSCDQM_Detector.cc.

References boxes, SiStripMonitorClusterAlca_cfi::xmax, SiStripMonitorClusterAlca_cfi::xmin, SiStripMonitorClusterAlca_cfi::ymax, and SiStripMonitorClusterAlca_cfi::ymin.

                                                  {
      if (boxes[i].adr == adr) {
        a += fabs((boxes[i].xmax - boxes[i].xmin) * (boxes[i].ymax - boxes[i].ymin));
      }
    }
    return a;
  }
  
const float cscdqm::Detector::Area ( const unsigned int  station) const

Calculate station area in eta/phi space.

Parameters:
stationStation number
Returns:
Area that is being covered by station

Definition at line 139 of file CSCDQM_Detector.cc.

References station_area.

Referenced by cscdqm::Summary::GetEfficiencyArea(), and cscdqm::Summary::GetReportingArea().

                                              {
      return station_area[station - 1];
    }
    return 0;
  }
  
const float cscdqm::Detector::Eta ( const float  r,
const float  z 
) const [private]

Definition at line 357 of file CSCDQM_Detector.cc.

References create_public_lumi_plots::log, and mathSSE::sqrt().

Referenced by Detector().

                           {
      float sin_theta = r / sqrt(r * r + z * z);
      float cos_theta = z / sqrt(r * r + z * z);
      return - log(sin_theta / (cos_theta + 1));
    }
    if(r == 0.0) return FLT_MAX;
    return 0.0;
  }
  
const float cscdqm::Detector::EtaToX ( const float  eta) const [private]

Transform eta coordinate to local canvas coordinate.

Parameters:
etaEta coordinate
Returns:
local canvas coordinate

Definition at line 373 of file CSCDQM_Detector.cc.

Referenced by Detector().

unsigned int cscdqm::Detector::GlobalChamberIndex ( unsigned int  side,
unsigned int  station,
unsigned int  ring,
unsigned int  chamber 
) const

Return global chamber index on his geometric location.

Parameters:
sideSide (1,2)
stationStation
ringRing\
chamberChamber position
Returns:
Global chamber index starting 1. If chamber is not existing - returns 0

Definition at line 154 of file CSCDQM_Detector.cc.

References cscdqm::Address::chamber, i, N_STATIONS, NumberOfChambers(), NumberOfRings(), cscdqm::Address::ring, and cscdqm::Address::station.

Referenced by cscdqm::EventProcessor::processCSC().

                                                           { 
      for (iadr.station = 1; iadr.station <= N_STATIONS; iadr.station++) {
        for (iadr.ring = 1; iadr.ring <= NumberOfRings(iadr.station); iadr.ring++) { 
          for (iadr.chamber = 1; iadr.chamber <= NumberOfChambers(iadr.station, iadr.ring); iadr.chamber++) {
            if (iadr == adr) {
              return i;
            }
            i += 1;
          }
        }
      }
    }
    return 0;
  }

const bool cscdqm::Detector::NextAddress ( unsigned int &  i,
const Address *&  adr,
const Address mask 
) const

Address iterator by mask.

Parameters:
iIterator
adrAddress to return
maskfor addresses
Returns:
true if address was found and filled in, false - otherwise

Definition at line 303 of file CSCDQM_Detector.cc.

References cscdqm::AddressBox::adr, boxes, and i.

                                {
      if (boxes[i].adr == mask) {
          adr = &boxes[i].adr;
          i++;
          return true; 
      }
    }
    return false;
  }
  
const bool cscdqm::Detector::NextAddressBox ( unsigned int &  i,
const AddressBox *&  box,
const Address mask 
) const

Address box iterator by mask.

Parameters:
iIterator
adrAddressBox to return
maskfor addresses
Returns:
true if address box was found and filled in, false - otherwise

Definition at line 321 of file CSCDQM_Detector.cc.

References boxes, and i.

Referenced by cscdqm::Summary::Write().

                                {
      if (boxes[i].adr == mask) {
          box = &boxes[i];
          i++;
          return true; 
        }
    }
    return false;
  }
  
const bool cscdqm::Detector::NextAddressBoxByPartition ( unsigned int &  i,
const unsigned int  px,
const unsigned int  py,
AddressBox *&  box 
)

Address box iterator by partition.

Parameters:
iIterator
pxPartition x index
pyPartition y index
boxAddressBox to return
Returns:
true if address box was found and filled in, false - otherwise

Definition at line 341 of file CSCDQM_Detector.cc.

Referenced by cscdqm::Summary::IsPhysicsReady().

                                  {
      if (i < partitions[index].size()) {
        box = &boxes[partitions[index].at(i)];
        i++;
        return true; 
      }
    }
    return false;
  
  }
  
const unsigned int cscdqm::Detector::NumberOfChamberCFEBs ( const unsigned int  station,
const unsigned int  ring 
) const

Returns the number of CFEBs per Chamber on given Station/Ring.

Parameters:
stationStation number (1...4)
ringRing number (1...3)
Returns:
Number of CFEBs per Chamber

Definition at line 233 of file CSCDQM_Detector.cc.

Referenced by Detector(), cscdqm::Summary::GetEfficiencyHW(), cscdqm::Summary::GetReportingArea(), cscdqm::Summary::GetValue(), and cscdqm::Summary::SetValue().

const unsigned int cscdqm::Detector::NumberOfChamberHVs ( const unsigned int  station,
const unsigned int  ring 
) const

Returns the number of HVs per Chamber on given Station/Ring.

Parameters:
stationStation number (1...4)
ringRing number (1...3)
Returns:
Number of HVs per Chamber

Definition at line 252 of file CSCDQM_Detector.cc.

Referenced by Detector(), cscdqm::Summary::GetEfficiencyHW(), cscdqm::Summary::GetReportingArea(), cscdqm::Summary::GetValue(), and cscdqm::Summary::SetValue().

const unsigned int cscdqm::Detector::NumberOfChambers ( const unsigned int  station,
const unsigned int  ring 
) const

Returns the number of chambers for the given station and ring.

Parameters:
stationStation number (1...4)
ringRing number (1...3)
Returns:
number of chambers

Definition at line 214 of file CSCDQM_Detector.cc.

Referenced by Detector(), cscdqm::Summary::GetEfficiencyHW(), cscdqm::Summary::GetReportingArea(), cscdqm::Summary::GetValue(), GlobalChamberIndex(), cscdqm::Summary::SetValue(), cscdqm::EventProcessor::updateEfficiencyHistos(), and cscdqm::Summary::WriteChamberState().

const unsigned int cscdqm::Detector::NumberOfRings ( const unsigned int  station) const

Returns the number of rings for the given station.

Parameters:
stationStation number (1, 2, 3, 4)
Returns:
number of rings for the given station

Definition at line 200 of file CSCDQM_Detector.cc.

Referenced by Detector(), cscdqm::Summary::GetEfficiencyHW(), cscdqm::Summary::GetReportingArea(), cscdqm::Summary::GetValue(), GlobalChamberIndex(), cscdqm::Summary::SetValue(), cscdqm::EventProcessor::updateEfficiencyHistos(), and cscdqm::Summary::WriteChamberState().

const float cscdqm::Detector::PhiMaxCFEB ( const int  station,
const int  ring,
const int  chamber,
const int  cfeb 
) const [private]

Get Max phi boundary for particular CFEB.

Parameters:
stationStation number
ringRing number
chamberChamber number
cfebCFEB number
Returns:
Max phi CFEB boundary

Definition at line 556 of file CSCDQM_Detector.cc.

Referenced by Detector().

const float cscdqm::Detector::PhiMinCFEB ( const int  station,
const int  ring,
const int  chamber,
const int  cfeb 
) const [private]

Get Min phi boundary for particular CFEB.

Parameters:
stationStation number
ringRing number
chamberChamber number
cfebCFEB number
Returns:
Min phi CFEB boundary

Definition at line 537 of file CSCDQM_Detector.cc.

Referenced by Detector().

const float cscdqm::Detector::PhiToY ( const float  phi) const [private]

Transform phi coordinate to local canvas coordinate.

Parameters:
phiPhi coordinate
Returns:
local canvas coordinate

Definition at line 388 of file CSCDQM_Detector.cc.

Referenced by Detector().

void cscdqm::Detector::PrintAddress ( const Address adr) const

Prints address for debugging.

Parameters:
adrAddress to print
Returns:

Definition at line 270 of file CSCDQM_Detector.cc.

const float cscdqm::Detector::RMaxHV ( const int  station,
const int  ring,
const int  n_hv 
) const [private]

Get R max parameter (used in address eta/phi calculation)

Parameters:
stationStation Id
ringRing Id
n_hvHV number
Returns:
R max value

Definition at line 480 of file CSCDQM_Detector.cc.

Referenced by Detector().

                                  {
      if(n_hv == 1) r_max_hv = 1500.0;
      if(n_hv == 2) r_max_hv = 2565.0;
    }
    
    if(station == 1 && ring == 2) {
      if(n_hv == 1) r_max_hv = 3368.2;
      if(n_hv == 2) r_max_hv = 4025.7;
      if(n_hv == 3) r_max_hv = 4559.9;
    }
    
    if(station == 1 && ring == 3) {
      if(n_hv == 1) r_max_hv = 5724.1;
      if(n_hv == 2) r_max_hv = 6230.2;
      if(n_hv == 3) r_max_hv = 6761.5;
    }
    
    if(station == 2 && ring == 1) {
      if(n_hv == 1) r_max_hv = 2152.3;
      if(n_hv == 2) r_max_hv = 2763.7;
      if(n_hv == 3) r_max_hv = 3365.8;
    }
    
    if(station == 3 && ring == 1) {
      if(n_hv == 1) r_max_hv = 2164.9;
      if(n_hv == 2) r_max_hv = 2763.8;
      if(n_hv == 3) r_max_hv = 3365.8;
    }
    
    if(station == 4 && ring == 1) {
      if(n_hv == 1) r_max_hv = 2365.9;
      if(n_hv == 2) r_max_hv = 2865.0;
      if(n_hv == 3) r_max_hv = 3356.3;
    }
    
    if((station == 2 || station == 3 || station == 4) && ring == 2) {
      if(n_hv == 1) r_max_hv = 4446.3;
      if(n_hv == 2) r_max_hv = 5053.2;
      if(n_hv == 3) r_max_hv = 5660.1;
      if(n_hv == 4) r_max_hv = 6267.0;
      if(n_hv == 5) r_max_hv = 6870.8;
    }
    
    return r_max_hv;
  }
  
const float cscdqm::Detector::RMinHV ( const int  station,
const int  ring,
const int  n_hv 
) const [private]

Get R min parameter (used in address eta/phi calculation)

Parameters:
stationStation Id
ringRing Id
n_hvHV number
Returns:
R min value

Definition at line 424 of file CSCDQM_Detector.cc.

Referenced by Detector().

                                  {
      if(n_hv == 1) r_min_hv = 1060.0;
      if(n_hv == 2) r_min_hv = 1500.0;
    }
    
    if(station == 1 && ring == 2) {
      if(n_hv == 1) r_min_hv = 2815.0;
      if(n_hv == 2) r_min_hv = 3368.2;
      if(n_hv == 3) r_min_hv = 4025.7;
    }
    
    if(station == 1 && ring == 3) {
      if(n_hv == 1) r_min_hv = 5120.0;
      if(n_hv == 2) r_min_hv = 5724.1;
      if(n_hv == 3) r_min_hv = 6230.2;
    }
    
    if(station == 2 && ring == 1) {
      if(n_hv == 1) r_min_hv = 1469.2;
      if(n_hv == 2) r_min_hv = 2152.3;
      if(n_hv == 3) r_min_hv = 2763.7;
    }
    
    if(station == 3 && ring == 1) {
      if(n_hv == 1) r_min_hv = 1668.9;
      if(n_hv == 2) r_min_hv = 2164.9;
      if(n_hv == 3) r_min_hv = 2763.8;
    }
    
    if(station == 4 && ring == 1) {
      if(n_hv == 1) r_min_hv = 1876.1;
      if(n_hv == 2) r_min_hv = 2365.9;
      if(n_hv == 3) r_min_hv = 2865.0;
    }
    
    if((station == 2 || station == 3 || station == 4) && ring == 2) {
      if(n_hv == 1) r_min_hv = 3640.2;
      if(n_hv == 2) r_min_hv = 4446.3;
      if(n_hv == 3) r_min_hv = 5053.2;
      if(n_hv == 4) r_min_hv = 5660.1;
      if(n_hv == 5) r_min_hv = 6267.0;
    }
    
    return r_min_hv;
  }
  
const float cscdqm::Detector::Z ( const int  station,
const int  ring 
) const [private]

Get Z parameter (used in address eta/phi calculation)

Parameters:
stationStation Id
ringRing Id
Returns:
Z value

Definition at line 404 of file CSCDQM_Detector.cc.

Referenced by Detector().


Member Data Documentation

AddressBox cscdqm::Detector::boxes[N_ELEMENTS] [private]

Address boxes in epa/phi space

Definition at line 218 of file CSCDQM_Detector.h.

Referenced by Area(), Detector(), NextAddress(), and NextAddressBox().

Map of partitions and list of it covering addresses indexes

Definition at line 230 of file CSCDQM_Detector.h.

Referenced by Detector().

unsigned int cscdqm::Detector::partitions_x [private]

Number of partitions in X axis

Definition at line 224 of file CSCDQM_Detector.h.

Referenced by Detector().

unsigned int cscdqm::Detector::partitions_y [private]

Number of partitions in Y axis

Definition at line 227 of file CSCDQM_Detector.h.

float cscdqm::Detector::station_area[N_STATIONS] [private]

Station areas precalculated

Definition at line 221 of file CSCDQM_Detector.h.

Referenced by Area().