// ESAF : Euso Simulation and Analysis Framework
// $Id: EEventTelemetryAdder.cc,v 1.4 2005/05/08 21:02:44 thea Exp $
// A.Thea created Oct, 26 2003
#include "EEventTelemetryAdder.hh"
#include "EEvent.hh"
#include "Telemetry.hh"
#include "MacroCell.hh"
#include "MacroCellHit.hh"
#include "MacroCellData.hh"
#include "EMacroCellHit.hh"
ClassImp(EEventTelemetryAdder)
//______________________________________________________________________________
EEventTelemetryAdder::EEventTelemetryAdder( Telemetry *t)
: EFiller( "EDetector" ) {
// ctor
fTelemetry = t;
}
//______________________________________________________________________________
EEventTelemetryAdder::~EEventTelemetryAdder() {
// dtor
}
//______________________________________________________________________________
void EEventTelemetryAdder::Fill( EFillable* f ) {
// filler
EDetector *det = (EDetector*)f;
Int_t nCell = fTelemetry->NumCell();
Int_t numgtus(0);
det->fNumCellHits=0;
// retridete time of the gtu 0 from macrocells
if (fTelemetry->NumCell() > 0 )
det->fElectronics.fTimeGtu0 = fTelemetry->GetData(0)->Cell()->GetGtuBegin();
// loop on macrocell that gave data
for( Int_t icell=0; icell < nCell; icell++) {
MacroCellData *pData = fTelemetry->GetData(icell);
if ( pData ) {
// first gtu with data
Int_t g_start = pData->GtuStart();
// last gtu with data
Int_t g_end = pData->GtuEnd();
// num gtus
if ( numgtus < pData->NGtus() )
numgtus = pData->NGtus();
// loop on GTUs for this macrocell
for(Int_t gtu = g_start; gtu <= g_end; gtu++) {
// for each GTU there can be more than one macrocell hit
// i.e. more than one valid X-Y combination with all ghosts
Int_t size = (pData->Hits(gtu))->size();
for(Int_t iHit=0; iHit < size; iHit++) {
MacroCellHit *mchit = pData->Hit(gtu,iHit);
EMacroCellHit* Ehit =
new ( (*(det->fMacroCellHits))[det->fNumCellHits++] )EMacroCellHit();
Ehit->SetCellId( pData->Cell()->Id() );
Ehit->SetGtu( mchit->Gtu() );
Ehit->SetCounts( mchit->Hits() );
Ehit->SetCellRow( mchit->Row() );
Ehit->SetCellCol( mchit->Col() );
Ehit->SetChUId( mchit->UniqueId() );
}
}
if (det->fElectronics.GetGtuStart() > g_start )
det->fElectronics.SetGtuStart(g_start);
if (det->fElectronics.GetGtuEnd() < g_end )
det->fElectronics.SetGtuEnd(g_end);
if (det->fElectronics.GetTimeFirstGtu() > pData->GtuTimeStart() )
det->fElectronics.SetTimeFirstGtu( pData->GtuTimeStart() ) ;
if (det->fElectronics.GetTimeLastGtu() > pData->GtuTimeEnd() )
det->fElectronics.SetTimeLastGtu( pData->GtuTimeEnd() ) ;
det->fElectronics.SetGtuLength( pData->Cell()->GetGtuLength() );
}
}
det->fElectronics.SetNumCells( nCell );
det->fElectronics.SetNumActiveGtus( numgtus );
Msg(EsafMsg::Info) << "Telemetry data saved in the root event" << MsgDispatch;
}