// class ChipGtuData
// describe the digital data coming out of the Front End Chip
// (counters, internal memories, logical signals)
// used by the MacroCell
// M. Pallavicini - created 19/11/01
#include <iostream>
#include "utils.hh"
#include "ChipGtuData.hh"
#include "FrontEndChip.hh"
#include "Etypes.hh"
ClassImp(ChipGtuData)
//______________________________________________________________________________
ChipGtuData::ChipGtuData(FrontEndChip* fe, Int_t g) : pFrontEnd( fe ), fGtu(g) {
//
// Constructor
//
fThresh = 0;
Reset();
}
//______________________________________________________________________________
ChipGtuData::ChipGtuData() {
//
// Empty private ctor
//
pFrontEnd = 0;
fGtu = 0;
fThresh = 0;
fEmpty = kTRUE;
fTime = -kHuge;
fRow = -1;
fCol = -1;
fDynode = 0;
}
//______________________________________________________________________________
ChipGtuData::~ChipGtuData() {
//
// Destructor
//
}
//______________________________________________________________________________
Int_t ChipGtuData::GetTotalCounts() {
//
// Returns the total number of detected counts
//
Int_t tot=0;
for(Int_t index=0; index < FrontEnd()->Channels(); index++) {
tot += GetCounter(index);
}
return tot;
}
//______________________________________________________________________________
Int_t ChipGtuData::GetTotalPureSignal() {
//
// Returns the total number of detected signal counts
//
Int_t tot=0;
for(Int_t index=0; index < FrontEnd()->Channels(); index++) {
tot += GetPureSignal(index);
}
return tot;
}
//______________________________________________________________________________
Int_t ChipGtuData::GetNumActivePixels() {
//
// Returns the number of pixels with at least one hit
//
Int_t tot=0;
for(Int_t index=0; index < FrontEnd()->Channels(); index++) {
if ( GetCounter(index) > 0 )
tot++;
}
return tot;
}
//______________________________________________________________________________
void ChipGtuData::Reset() {
//
// Reset data (counters, memory)
//
fCounts.clear();
fPureSignal.clear();
fCharge.clear();
fPureSignal.resize( FrontEnd()->Channels() );
fCounts.resize( FrontEnd()->Channels() );
fCharge.resize( FrontEnd()->Channels() );
for(Int_t index=0; index < FrontEnd()->Channels(); index++) {
fCounts[index] = 0;
fCharge[index] = 0;
}
fRowList.clear();
fColList.clear();
fRowList.resize( FrontEnd()->NumSide() );
fColList.resize( FrontEnd()->NumSide() );
for(Int_t index=0; index < FrontEnd()->NumSide(); index++) {
fRowList[index] = -1;
fColList[index] = -1.;
}
fTime = kHuge;
fRow = fCol = 0;
fDynode=0.;
SetEmpty();
}
//______________________________________________________________________________
void ChipGtuData::SetRowCol( Int_t r, Int_t c, Double_t t ) {
//
// Set the logical signals for rows and columns
// remember the time at which they go on
// if already set, do not change the time
// negative time means NOT activated in this GTU
//
if ( fRowList[r] < 0. ) {
fRowList[r] = t;
}
if ( fColList[c] < 0. ) {
fColList[c] = t;
}
if ( t < fTime ) {
fTime = t;
fRow = r;
fCol = c;
}
SetEmpty( kFALSE );
}
//______________________________________________________________________________
Bool_t ChipGtuData::GetXYLogic(Int_t& x, Int_t& y, Double_t& t) {
//
// Returns coordinates and time of the first XY logic hic
// returns false if no active counter in this gtu
//
if ( IsEmpty() )
return kFALSE;
x = fRow;
y = fCol;
t = fTime;
return kTRUE;
}
//______________________________________________________________________________
void ChipGtuData::AddCharge(Int_t ch, Double_t crg, Int_t g) {
//
// Analog front end function
// add charge for a channel
//
if ( Gtu() != g ) {
Msg(EsafMsg::Warning) << "GTU=" << Gtu() << " " << g << MsgDispatch;
FatalError("GTU Id mismatch in ChipGtuData::AddCharge");
}
fCharge[ch] = crg;
}
//______________________________________________________________________________
void ChipGtuData::AddDynodeCharge(Double_t crg, Int_t g) {
//
// Add dynode charge for the whole chip in gtu
//
if ( Gtu() != g ) {
Msg(EsafMsg::Warning) << "GTU=" << Gtu() << " " << g << MsgDispatch;
FatalError("GTU Id mismatch in ChipGtuData::AddDynodeCharge");
}
fDynode = crg;
}