Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:17

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // File: HcalTestNumbering.cc
0003 // Description: Numbering scheme packing for test beam hadron calorimeter
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #include "DataFormats/HcalDetId/interface/HcalTestNumbering.h"
0006 
0007 uint32_t HcalTestNumbering::packHcalIndex(int det, int z, int depth, int eta, int phi, int lay) {
0008   uint32_t idx = (det & 15) << 28;  //bits 28-31
0009   idx += ((depth - 1) & 3) << 26;   //bits 26-27
0010   idx += ((lay - 1) & 31) << 21;    //bits 21-25
0011   idx += (z & 1) << 20;             //bits 20
0012   idx += (eta & 1023) << 10;        //bits 10-19
0013   idx += (phi & 1023);              //bits  0-9
0014 
0015   return idx;
0016 }
0017 
0018 void HcalTestNumbering::unpackHcalIndex(
0019     const uint32_t& idx, int& det, int& z, int& depth, int& eta, int& phi, int& lay) {
0020   det = (idx >> 28) & 15;
0021   depth = (idx >> 26) & 3;
0022   depth += 1;
0023   lay = (idx >> 21) & 31;
0024   lay += 1;
0025   z = (idx >> 20) & 1;
0026   eta = (idx >> 10) & 1023;
0027   phi = (idx & 1023);
0028 }