]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/tracking-ca/AliHLTTPCCAStandaloneFramework.h
bug fix: reconstruction crash when the output buffer size exceed
[u/mrichter/AliRoot.git] / HLT / TPCLib / tracking-ca / AliHLTTPCCAStandaloneFramework.h
1 //-*- Mode: C++ -*-
2 // ************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project        *
4 // ALICE Experiment at CERN, All rights reserved.                         *
5 // See cxx source for full Copyright notice                               *
6 //                                                                        *
7 //*************************************************************************
8
9 #ifndef ALIHLTTPCCASTANDALONEFRAMEWORK_H
10 #define ALIHLTTPCCASTANDALONEFRAMEWORK_H
11
12 #include "AliHLTTPCCADef.h"
13 #include "AliHLTTPCCAMerger.h"
14 #include "AliHLTTPCCAClusterData.h"
15 #include "AliHLTTPCCATrackerFramework.h"
16 #include <iostream>
17 #include <fstream>
18 #include "TStopwatch.h"
19
20 /**
21  * @class AliHLTTPCCAStandaloneFramework
22  *
23  * The class to run the HLT TPC reconstruction (36 CA slice trackers + CA merger )
24  * in a stand-alone mode.
25  * Used by AliTPCtrackerCA, the CA event display, CA performance.
26  *
27  */
28 class AliHLTTPCCAStandaloneFramework
29 {
30
31   public:
32
33     AliHLTTPCCAStandaloneFramework();
34     ~AliHLTTPCCAStandaloneFramework();
35
36     static AliHLTTPCCAStandaloneFramework &Instance();
37
38         const AliHLTTPCCAParam &Param ( int iSlice ) const { return(fTracker.Param(iSlice)); }
39         const AliHLTTPCCARow &Row ( int iSlice, int iRow ) const { return(fTracker.Row(iSlice, iRow)); }
40     const AliHLTTPCCASliceOutput &Output( int iSlice ) const { return *fSliceOutput[iSlice]; }
41     AliHLTTPCCAMerger  &Merger()  { return fMerger; }
42     AliHLTTPCCAClusterData &ClusterData( int iSlice ) { return fClusterData[iSlice]; }
43
44     /**
45      * prepare for reading of the event
46      */
47     void StartDataReading( int guessForNumberOfClusters = 256 );
48
49     /**
50      *  read next cluster
51      */
52     void ReadCluster( int id, int iSlice, int iRow, float X, float Y, float Z, float Amp ) {
53       fClusterData[iSlice].ReadCluster( id, iRow, X, Y, Z, Amp );
54     }
55
56     /**
57      * finish reading of the event
58      */
59     void FinishDataReading();
60
61     /**
62      *  perform event reconstruction
63      */
64     void ProcessEvent(int forceSingleSlice = -1);
65
66
67     int NSlices() const { return fgkNSlices; }
68
69     double LastTime( int iTimer ) const { return fLastTime[iTimer]; }
70     double StatTime( int iTimer ) const { return fStatTime[iTimer]; }
71     int StatNEvents() const { return fStatNEvents; }
72
73     void WriteSettings( std::ostream &out ) const;
74     void WriteEvent( std::ostream &out ) const;
75     void WriteTracks( std::ostream &out ) const;
76
77     void ReadSettings( std::istream &in );
78     void ReadEvent( std::istream &in );
79     void ReadTracks( std::istream &in );
80
81         int InitGPU(int sliceCount = 1, int forceDeviceID = -1) { return(fTracker.InitGPU(sliceCount, forceDeviceID)); }
82         int ExitGPU() { return(fTracker.ExitGPU()); }
83         void SetGPUDebugLevel(int Level, std::ostream *OutFile = NULL, std::ostream *GPUOutFile = NULL) { fDebugLevel = Level; fTracker.SetGPUDebugLevel(Level, OutFile, GPUOutFile); }
84         int SetGPUTrackerOption(char* OptionName, int OptionValue) {return(fTracker.SetGPUTrackerOption(OptionName, OptionValue));}
85         int SetGPUTracker(bool enable) { return(fTracker.SetGPUTracker(enable)); }
86         int GetGPUStatus() const { return(fTracker.GetGPUStatus()); }
87         int GetGPUMaxSliceCount() const { return(fTracker.MaxSliceCount()); }
88
89         int InitializeSliceParam(int iSlice, AliHLTTPCCAParam& param) { return(fTracker.InitializeSliceParam(iSlice, param)); }
90
91 #ifdef HLTCA_STANDALONE
92         static inline void StandaloneQueryTime(unsigned long long int *i);
93         static inline void StandaloneQueryFreq(unsigned long long int *i);
94 #endif //HLTCA_STANDALONE
95
96   private:
97
98     static const int fgkNSlices = 36;       //* N slices
99
100     AliHLTTPCCAStandaloneFramework( const AliHLTTPCCAStandaloneFramework& );
101     const AliHLTTPCCAStandaloneFramework &operator=( const AliHLTTPCCAStandaloneFramework& ) const;
102
103     AliHLTTPCCAMerger fMerger;  //* global merger
104     AliHLTTPCCAClusterData fClusterData[fgkNSlices];
105         AliHLTTPCCASliceOutput* fSliceOutput[fgkNSlices];
106         AliHLTTPCCASliceOutput::outputControlStruct fOutputControl;
107
108         AliHLTTPCCATrackerFramework fTracker;
109
110     double fLastTime[20]; //* timers
111     double fStatTime[20]; //* timers
112     int fStatNEvents;    //* n events proceed
113
114         int fDebugLevel;
115 };
116
117 #ifdef HLTCA_STANDALONE
118         void AliHLTTPCCAStandaloneFramework::StandaloneQueryTime(unsigned long long int *i)
119         {
120         #ifdef R__WIN32
121                   QueryPerformanceCounter((LARGE_INTEGER*) i);
122         #else
123                   timespec t;
124                   clock_gettime(CLOCK_REALTIME, &t);
125                   *i = (unsigned long long int) t.tv_sec * (unsigned long long int) 1000000000 + (unsigned long long int) t.tv_nsec;
126         #endif //R__WIN32
127         }
128
129         void AliHLTTPCCAStandaloneFramework::StandaloneQueryFreq(unsigned long long int *i)
130         {
131         #ifdef R__WIN32
132                   QueryPerformanceFrequency((LARGE_INTEGER*) i);
133         #else
134                 *i = 1000000000;
135         #endif //R__WIN32
136         }
137 #endif //HLTCA_STANDALONE
138
139 #endif //ALIHLTTPCCASTANDALONEFRAMEWORK_H