#ifndef HMDCCELLGROUP_H
#define HMDCCELLGROUP_H
#include "TObject.h"
#include <string.h>
class HMdcCellGroup : public TObject {
protected:
static UChar_t nCellsLookUp[256];
static UChar_t cellPosLookUp[4][256];
static Bool_t lookUpsInitialized;
UShort_t *pLayer;
void initLookups(void);
HMdcCellGroup(UShort_t *layerBuffer) {
if (!lookUpsInitialized) initLookups();
pLayer=layerBuffer;
}
public:
~HMdcCellGroup(void) { }
inline Int_t getNCells(Int_t layer);
inline Int_t getCell(Int_t layer,Int_t idx);
inline Int_t getSignId(Int_t layer,Int_t idx);
inline void setSignId(Int_t layer,Int_t cell,
Int_t t1,Int_t t2=0,Int_t t3=0,Int_t t4=0);
ClassDef(HMdcCellGroup,1)
};
class HMdcCellGroup6 : public HMdcCellGroup {
protected:
UShort_t iLayer[6];
public:
HMdcCellGroup6(void) : HMdcCellGroup(iLayer)
{ memset(iLayer,0,6*sizeof(UShort_t)); }
~HMdcCellGroup6(void) {}
void clear(void) { memset(iLayer,0,6*sizeof(UShort_t)); }
Int_t getSumWires()
{
Int_t sum=0;
for(Int_t i=0;i<6;i++){sum+=getNCells(i);}
return sum;
}
Int_t getNLayers()
{
Int_t sum=0;
for(Int_t i=0;i<6;i++){if(getNCells(i)>0)sum++;}
return sum;
}
ClassDef(HMdcCellGroup6,1)
};
class HMdcCellGroup12 : public HMdcCellGroup {
protected:
UShort_t iLayer[12];
public:
HMdcCellGroup12(void) : HMdcCellGroup(iLayer)
{ memset(iLayer,0,12*sizeof(UShort_t));}
~HMdcCellGroup12(void) {}
void clear(void) { memset(iLayer,0,12*sizeof(UShort_t)); }
Int_t getSumWires()
{
Int_t sum=0;
for(Int_t i=0;i<12;i++){sum+=getNCells(i);}
return sum;
}
Int_t getSumWires(UInt_t mod)
{
Int_t sum=0;
if(mod==0)for(Int_t i=0;i<6;i++) {sum+=getNCells(i);}
if(mod==1)for(Int_t i=6;i<12;i++){sum+=getNCells(i);}
return sum;
}
Int_t getNLayers()
{
Int_t sum=0;
for(Int_t i=0;i<12;i++){if(getNCells(i)>0)sum++;}
return sum;
}
Int_t getNLayers(UInt_t mod)
{
Int_t sum=0;
if(mod==0)for(Int_t i=0;i<6;i++){if(getNCells(i)>0)sum++;}
if(mod==1)for(Int_t i=6;i<12;i++){if(getNCells(i)>0)sum++;}
return sum;
}
ClassDef(HMdcCellGroup12,1)
};
inline Int_t HMdcCellGroup::getNCells(Int_t layer) {
return nCellsLookUp[pLayer[layer] & 0xFF];
}
inline Int_t HMdcCellGroup::getCell(Int_t layer,Int_t idx) {
return ((pLayer[layer]>>8) & 0xFF)+cellPosLookUp[idx][pLayer[layer] & 0xFF];
}
inline Int_t HMdcCellGroup::getSignId(Int_t layer,Int_t idx) {
if (idx < getNCells(layer) ) {
Int_t shift=cellPosLookUp[idx][pLayer[layer] & 0xFF]*2;
return (pLayer[layer] >> shift) & 0x3;
}
return 0;
}
inline void HMdcCellGroup::setSignId(Int_t layer,Int_t cell,
Int_t t1,Int_t t2,Int_t t3,Int_t t4) {
pLayer[layer]=((cell & 0xFF) << 8) | ((t4 & 0x3)<<6) |
((t3 & 0x3)<<4) | ((t2 & 0x3)<<2) | ((t1 & 0x3));
}
#endif
Last change: Sat May 22 13:00:43 2010
Last generated: 2010-05-22 13:00
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.