]> git.uio.no Git - u/mrichter/AliRoot.git/blame - 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
CommitLineData
6de2bc40 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"
6de2bc40 13#include "AliHLTTPCCAMerger.h"
14#include "AliHLTTPCCAClusterData.h"
b22af1bf 15#include "AliHLTTPCCATrackerFramework.h"
6de2bc40 16#include <iostream>
7be9b0d7 17#include <fstream>
b22af1bf 18#include "TStopwatch.h"
6de2bc40 19
20/**
21 * @class AliHLTTPCCAStandaloneFramework
22 *
23 * The class to run the HLT TPC reconstruction (36 CA slice trackers + CA merger )
b8139972 24 * in a stand-alone mode.
6de2bc40 25 * Used by AliTPCtrackerCA, the CA event display, CA performance.
26 *
27 */
28class AliHLTTPCCAStandaloneFramework
29{
30
31 public:
32
33 AliHLTTPCCAStandaloneFramework();
34 ~AliHLTTPCCAStandaloneFramework();
35
36 static AliHLTTPCCAStandaloneFramework &Instance();
37
b22af1bf 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)); }
98512261 40 const AliHLTTPCCASliceOutput &Output( int iSlice ) const { return *fSliceOutput[iSlice]; }
b8139972 41 AliHLTTPCCAMerger &Merger() { return fMerger; }
42 AliHLTTPCCAClusterData &ClusterData( int iSlice ) { return fClusterData[iSlice]; }
6de2bc40 43
44 /**
45 * prepare for reading of the event
46 */
47 void StartDataReading( int guessForNumberOfClusters = 256 );
48
49 /**
50 * read next cluster
51 */
b8139972 52 void ReadCluster( int id, int iSlice, int iRow, float X, float Y, float Z, float Amp ) {
6de2bc40 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 */
b22af1bf 64 void ProcessEvent(int forceSingleSlice = -1);
6de2bc40 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; }
b8139972 72
6de2bc40 73 void WriteSettings( std::ostream &out ) const;
74 void WriteEvent( std::ostream &out ) const;
75 void WriteTracks( std::ostream &out ) const;
b8139972 76
6de2bc40 77 void ReadSettings( std::istream &in );
7be9b0d7 78 void ReadEvent( std::istream &in );
6de2bc40 79 void ReadTracks( std::istream &in );
80
b22af1bf 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)); }
d4594e7d 86 int GetGPUStatus() const { return(fTracker.GetGPUStatus()); }
87 int GetGPUMaxSliceCount() const { return(fTracker.MaxSliceCount()); }
b22af1bf 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);
31649d4b 94#endif //HLTCA_STANDALONE
7be9b0d7 95
6de2bc40 96 private:
97
98 static const int fgkNSlices = 36; //* N slices
99
100 AliHLTTPCCAStandaloneFramework( const AliHLTTPCCAStandaloneFramework& );
101 const AliHLTTPCCAStandaloneFramework &operator=( const AliHLTTPCCAStandaloneFramework& ) const;
102
6de2bc40 103 AliHLTTPCCAMerger fMerger; //* global merger
104 AliHLTTPCCAClusterData fClusterData[fgkNSlices];
98512261 105 AliHLTTPCCASliceOutput* fSliceOutput[fgkNSlices];
d4594e7d 106 AliHLTTPCCASliceOutput::outputControlStruct fOutputControl;
6de2bc40 107
b22af1bf 108 AliHLTTPCCATrackerFramework fTracker;
7be9b0d7 109
6de2bc40 110 double fLastTime[20]; //* timers
111 double fStatTime[20]; //* timers
112 int fStatNEvents; //* n events proceed
7be9b0d7 113
b22af1bf 114 int fDebugLevel;
6de2bc40 115};
116
b22af1bf 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;
31649d4b 126 #endif //R__WIN32
b22af1bf 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;
31649d4b 135 #endif //R__WIN32
b22af1bf 136 }
31649d4b 137#endif //HLTCA_STANDALONE
b22af1bf 138
31649d4b 139#endif //ALIHLTTPCCASTANDALONEFRAMEWORK_H