#ifndef ROOT_THaDetMap
#define ROOT_THaDetMap
#include "Rtypes.h"
#include <vector>
class THaDetMap {
protected:
static const UInt_t kADCBit = BIT(31);
static const UInt_t kTDCBit = BIT(30);
static const UInt_t kModelMask = 0x00ffffff;
public:
struct Module {
UShort_t crate;
UShort_t slot;
UShort_t lo;
UShort_t hi;
UInt_t first;
UInt_t model;
Int_t refchan;
Int_t refindex;
Double_t resolution;
Bool_t reverse;
bool operator==( const Module& rhs ) const
{ return crate == rhs.crate && slot == rhs.slot; }
bool operator!=( const Module& rhs ) const
{ return !(*this==rhs); }
Int_t GetNchan() const { return hi-lo+1; }
UInt_t GetModel() const { return model & kModelMask; }
Bool_t IsTDC() const { return model & kTDCBit; }
Bool_t IsADC() const { return model & kADCBit; }
void SetModel( UInt_t model );
void SetResolution( Double_t resolution );
void MakeTDC() { model |= kTDCBit; }
void MakeADC() { model |= kADCBit; }
};
enum ECountMode {
kLogicalChan = 0,
kRefIndex = 1
};
enum EFillFlags {
kDoNotClear = BIT(0),
kFillLogicalChannel = BIT(10),
kFillModel = BIT(11),
kFillRefIndex = BIT(12),
kFillRefChan = BIT(13)
};
THaDetMap();
THaDetMap( const THaDetMap& );
THaDetMap& operator=( const THaDetMap& );
virtual ~THaDetMap();
virtual Int_t AddModule( UShort_t crate, UShort_t slot,
UShort_t chan_lo, UShort_t chan_hi,
UInt_t first=0, UInt_t model=0,
Int_t refindex=-1, Int_t refchan = -1 );
void Clear() { fNmodules = 0; }
virtual Module* Find( UShort_t crate, UShort_t slot, UShort_t chan );
virtual Int_t Fill( const std::vector<Int_t>& values, UInt_t flags = 0 );
void GetMinMaxChan( Int_t& min, Int_t& max,
ECountMode mode = kLogicalChan ) const;
Module* GetModule( UShort_t i ) const ;
Int_t GetNchan( UShort_t i ) const;
Int_t GetTotNumChan() const;
Int_t GetSize() const { return static_cast<Int_t>(fNmodules); }
UInt_t GetModel( UShort_t i ) const;
Bool_t IsADC( UShort_t i ) const;
Bool_t IsTDC( UShort_t i ) const;
static UInt_t GetModel( Module* d );
static Bool_t IsADC( Module* d );
static Bool_t IsTDC( Module* d );
virtual void Print( Option_t* opt="" ) const;
virtual void Reset();
virtual void Sort();
static const int kDetMapSize = (1<<16)-1;
protected:
UShort_t fNmodules;
Module* fMap;
Int_t fMaplength;
Module* uGetModule( UShort_t i ) const { return fMap+i; }
ClassDef(THaDetMap,0)
};
inline THaDetMap::Module* THaDetMap::GetModule( UShort_t i ) const {
return i<fNmodules ? uGetModule(i) : NULL;
}
inline Bool_t THaDetMap::IsADC(Module* d) {
if( !d ) return kFALSE;
return d->IsADC();
}
inline Bool_t THaDetMap::IsTDC(Module* d) {
if( !d ) return kFALSE;
return d->IsTDC();
}
inline UInt_t THaDetMap::GetModel(Module* d) {
if( !d ) return 0;
return d->GetModel();
}
inline Bool_t THaDetMap::IsADC( UShort_t i ) const {
if( i >= fNmodules ) return kFALSE;
return uGetModule(i)->IsADC();
}
inline Bool_t THaDetMap::IsTDC( UShort_t i ) const {
if( i >= fNmodules ) return kFALSE;
return uGetModule(i)->IsTDC();
}
inline UInt_t THaDetMap::GetModel( UShort_t i ) const {
if( i >= fNmodules ) return 0;
return uGetModule(i)->GetModel();
}
inline Int_t THaDetMap::GetNchan( UShort_t i ) const {
if( i >= fNmodules ) return 0;
return uGetModule(i)->GetNchan();
}
#endif
Last change: Sat Nov 7 21:26:45 2009
Last generated: 2009-11-07 21:26
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.