// ESAF : Euso Simulation and Analysis Framework
// $Id: EEventFrontEndDataAdder.cc,v 1.3 2005/02/19 20:00:05 thea Exp $
// A.Thea created Oct, 26 2003
#include "EEventFrontEndDataAdder.hh"
#include "EEvent.hh"
#include "Photomultiplier.hh"
#include "ChipGtuData.hh"
#include "FrontEndChip.hh"
#include "MacroCell.hh"
#include "EFee.hh"
#include "EAFee.hh"
ClassImp(EEventFrontEndDataAdder)
//______________________________________________________________________________
EEventFrontEndDataAdder::EEventFrontEndDataAdder( ChipGtuData* chip)
: EFiller("EDetector") {
// ctor
fChip = chip;
}
//______________________________________________________________________________
EEventFrontEndDataAdder::~EEventFrontEndDataAdder() {
// dtor
}
//______________________________________________________________________________
void EEventFrontEndDataAdder::Fill( EFillable* f) {
// filler
// copy data related to Front End chip into root file
// both DFEE and AFEE data are copied
// there are two objects: EFee and EAFee
// EFee contains both digital electronics data (counts for each channel
// and for each GTU) and FULL AFEE (charge per channel and per GTU)
// AFee contains the minimal analog info (dynode charge) and
// possibly the Cerenkov trigger signals simulation
EDetector *det = (EDetector*)f;
if (!fChip) {
throw runtime_error("Invalid ChipGtuData. Null pointer! n");
return;
}
if ( fChip->IsEmpty() && !det->IsNightGlowFillable() ) return;
if ( fChip->GetTotalCounts() == 0) return;
FrontEndChip *fe = fChip->FrontEnd();
if (!fe) {
throw runtime_error("Invalid ChipGtuData. No Front End attached!n");
return;
}
// FIXME! to be changed to take into account many pmts mapping...
// right now not dangerous
Photomultiplier *pmt = fe->Pmt();
if (!pmt) {
throw runtime_error("Invalid ChipGtuData. No Pmt attached!n");
return;
}
// for each channel one EFee object is created
for( int nch=0; nch<fe->Channels(); nch++) {
// creates a new EFee object and store it into the TClonesArray
new ( (*(det->fFee))[det->fNumFee] ) EFee();
EFee *pFee = (EFee*) (*(det->fFee))[det->fNumFee];
// fill data
pFee->fGtu = fChip->Gtu(); // gtu id
pFee->fFEId = fe->Id(); // front end chip id
pFee->fChUId = fe->UniqueChanId(nch); // pixel identifier
pFee->fNumSignals = fChip->GetPureSignal(nch); // number of signal photons
pFee->fNumHits = fChip->GetCounter(nch); // number of detected photons
pFee->fHasTriggered = fChip->CheckCounter(nch); // above threshold ?
if ( pFee->fHasTriggered )
pFee->fChCharge = fChip->Charge(nch); // full AFEE charge for this channel/gtu
else
pFee->fChCharge = -1.;
det->fNumFee++;
}
// analog front end data (gtu related, dynode charge and trigger if any)
// this is minimal AFEE
// FULL AFEE is in the EFee object above
new ( (*(det->fAFee))[det->fNumAFee] ) EAFee();
EAFee *pa = (EAFee*) (*(det->fAFee))[det->fNumAFee];
pa->fMCId = pmt->Cell()->Id(); // macrocell id
pa->fGtu = fChip->Gtu(); // gtu id
pa->fFEId = fe->Id(); // front end fChip id
pa->fDyCharge = fChip->DynodeCharge(); // dynode charge
pa->fCherTrigg = kFALSE; // Cerenkov trigger to be done
det->fNumAFee++;
}