// ESAF : Euso Simulation and Analysis Framework
// $Id: FullAnalogFrontEnd.cc,v 1.7 2004/06/16 10:46:48 thea Exp $
// M. Pallavicini created Jul, 2 2002
// Very basic implementation of full analog front end
// Charge is measured per each channel and GTU
#include <stdio.h>
#include "FullAnalogFrontEnd.hh"
#include "ChipGtuData.hh"
#include "PmtSignal.hh"
ClassImp(FullAnalogFrontEnd)
//______________________________________________________________________________
FullAnalogFrontEnd::FullAnalogFrontEnd(FrontEndChip* p, Int_t size) :
// ctor
AnalogFrontEnd( p ), fSize(size) {
fCharge = (Double_t*)new Double_t[ size ];
if (!fCharge ) {
char s[100];
sprintf(s,"Error new in FullAnalogFrontEnd Id=%d",Id());
throw runtime_error( s );
}
}
//______________________________________________________________________________
FullAnalogFrontEnd::~FullAnalogFrontEnd() {
// dtor
}
//______________________________________________________________________________
void FullAnalogFrontEnd::Reset(Int_t g) {
// reset (clear internal variables and status)
fGtu = g;
fDynode = 0.;
for(Int_t ch = 0; ch < fSize; ch++)
fCharge[ch] = 0.;
}
//______________________________________________________________________________
void FullAnalogFrontEnd::Add( const PmtSignal& s, Int_t ch, Int_t g) {
// add a photon for one specific channel and GTU
// last bool is true if DFEE has triggered on this channel and GTU
if ( ch < 0 || ch >= fSize) {
char msg[200];
sprintf(msg,"Invalid channel (%d) in FullAnalogFrontEnd::Add()",ch);
throw runtime_error( msg );
}
if ( fGtu != g )
throw runtime_error("GTU Id mismatch in FullAnalogFrontEnd::Add");
fCharge[ch] += s.Charge();
fDynode += s.Charge();
}
//______________________________________________________________________________
void FullAnalogFrontEnd::Simulate( ChipGtuData* data) {
// simulate gtu response
//
// need to do nothing in this implementation
// total fCharges already computed in Add()
// this method is foreseen to allow more sophisticated simulations
// in different implementations
// just copy infos to ChipGtuData
for(Int_t ch=0; ch < fSize; ch++)
data->AddCharge(ch,fCharge[ch],fGtu);
data->AddDynodeCharge(fDynode,fGtu);
}