source: JEM-EUSO/esaf_cc_at_lal/packages/simulation/detector/electronics/src/EEventTelemetryAdder.cc @ 114

Last change on this file since 114 was 114, checked in by moretto, 11 years ago

actual version of ESAF at CCin2p3

File size: 3.3 KB
Line 
1// ESAF : Euso Simulation and Analysis Framework
2// $Id: EEventTelemetryAdder.cc 1916 2005-06-04 17:37:32Z thea $
3// A.Thea created Oct, 26 2003
4
5#include "EEventTelemetryAdder.hh"
6#include "EEvent.hh"
7#include "EDetector.hh"
8#include "Telemetry.hh"
9#include "MacroCell.hh"
10#include "MacroCellHit.hh"
11
12#include "MacroCellData.hh"
13
14#include "EMacroCellHit.hh"
15
16ClassImp(EEventTelemetryAdder)
17
18//______________________________________________________________________________
19EEventTelemetryAdder::EEventTelemetryAdder( Telemetry *t)
20    : EFiller( "EDetector" ) {
21    // ctor
22
23    fTelemetry = t;
24}
25
26//______________________________________________________________________________
27EEventTelemetryAdder::~EEventTelemetryAdder() {
28    // dtor
29   
30}
31
32//______________________________________________________________________________
33void EEventTelemetryAdder::Fill( EFillable* f ) {
34    // filler
35   
36    EDetector *det = (EDetector*)f;
37   
38    Int_t nCell = fTelemetry->NumCell();
39    Int_t numgtus(0);
40    det->fNumCellHits=0;
41
42    // retridete time of the gtu 0 from macrocells
43    if (fTelemetry->NumCell() > 0 )
44        det->fElectronics.fTimeGtu0 = fTelemetry->GetData(0)->Cell()->GetGtuBegin();
45   
46    // loop on macrocell that gave data
47    for( Int_t icell=0; icell < nCell; icell++) {
48   
49        MacroCellData *pData = fTelemetry->GetData(icell);
50   
51        if ( pData ) {
52
53            // first gtu with data 
54            Int_t g_start = pData->GtuStart();
55
56            // last gtu with data
57            Int_t g_end = pData->GtuEnd();
58
59            // num gtus
60            if ( numgtus < pData->NGtus() )
61                numgtus = pData->NGtus();
62
63            // loop on GTUs for this macrocell
64            for(Int_t gtu = g_start; gtu <= g_end; gtu++) {
65
66                // for each GTU there can be more than one macrocell hit
67                // i.e. more than one valid X-Y combination with all ghosts 
68                Int_t size = (pData->Hits(gtu))->size();
69                for(Int_t iHit=0; iHit < size; iHit++) {
70                    MacroCellHit *mchit = pData->Hit(gtu,iHit);
71                    EMacroCellHit* Ehit =
72                        new ( (*(det->fMacroCellHits))[det->fNumCellHits++] )EMacroCellHit();
73                    Ehit->SetCellId( pData->Cell()->Id() );
74                    Ehit->SetGtu( mchit->Gtu() );
75                    Ehit->SetCounts( mchit->Hits() );
76                    Ehit->SetCellRow( mchit->Row() );
77                    Ehit->SetCellCol( mchit->Col() );
78                    Ehit->SetChUId( mchit->UniqueId() );
79                }
80            }
81
82
83            if (det->fElectronics.GetGtuStart() > g_start ) 
84                det->fElectronics.SetGtuStart(g_start);
85
86            if (det->fElectronics.GetGtuEnd() < g_end ) 
87                det->fElectronics.SetGtuEnd(g_end);
88
89            if (det->fElectronics.GetTimeFirstGtu() > pData->GtuTimeStart() ) 
90                det->fElectronics.SetTimeFirstGtu( pData->GtuTimeStart() ) ;
91
92            if (det->fElectronics.GetTimeLastGtu() > pData->GtuTimeEnd() ) 
93                det->fElectronics.SetTimeLastGtu( pData->GtuTimeEnd() ) ;
94
95            det->fElectronics.SetGtuLength( pData->Cell()->GetGtuLength() ); 
96        }
97    }
98    det->fElectronics.SetNumCells( nCell );
99    det->fElectronics.SetNumActiveGtus( numgtus );
100   
101    Msg(EsafMsg::Info) << "Telemetry data saved in the root event" << MsgDispatch;
102}
Note: See TracBrowser for help on using the repository browser.