-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdisplay.cpp
More file actions
131 lines (108 loc) · 3.33 KB
/
display.cpp
File metadata and controls
131 lines (108 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
Copyright (C) 2009 Matthias Kretz <kretz@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) version 3.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "AliHLTTPCCAGBTracker.h"
#include "AliHLTTPCCATracker.h"
#include "AliHLTTPCCAPerformance.h"
#include "AliHLTTPCCADisplay.h"
#include "TApplication.h"
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#ifdef DRAW
#error "Do not -DDRAW"
#endif
static void readMcEvent( Int_t eventIndex, AliHLTTPCCAPerformance *perf )
{
char name[32];
sprintf( name, "Events/%i.mcevent.dat", eventIndex );
std::fstream mcevent;
mcevent.open(name, std::ios::in);
if( !mcevent.is_open() ) {
std::exit( 1 );
}
perf->ReadMCEvent(mcevent);
mcevent.close();
}
static bool readBinaryStore( Int_t eventIndex, AliHLTTPCCAGBTracker *tracker )
{
char name[32];
sprintf( name, "%i.dat", eventIndex );
FILE *f = std::fopen( name, "rb" );
if ( f == NULL ) {
return false;
}
tracker->RestoreFromFile( f );
std::fclose( f );
return true;
}
static void drawSlice( AliHLTTPCCADisplay &display, AliHLTTPCCATracker &slice )
{
display.ClearView();
display.SetCurrentSlice( &slice );
display.DrawSlice( &slice );
display.DrawSliceHits();
display.Ask();
for ( int trackIndex = 0; trackIndex < *slice.NOutTracks(); ++trackIndex ) {
display.DrawSliceOutTrack( trackIndex );
}
display.Ask();
}
int main( int argc, char **argv )
{
int eventNumber = 0;
int sliceNumber = -1;
TApplication app( "CA Display", 0, 0 ); //, &argc, argv );
//app.Run();
if ( argc > 1 ) {
eventNumber = atoi( argv[1] );
if ( argc > 2 ) {
sliceNumber = atoi( argv[2] );
}
}
AliHLTTPCCAGBTracker tracker;
if ( !readBinaryStore( eventNumber, &tracker ) ) {
std::cerr << eventNumber << ".dat does not exist. Run CA first." << std::endl;
return 1;
}
AliHLTTPCCAPerformance &perf = AliHLTTPCCAPerformance::Instance();
perf.SetTracker( &tracker );
readMcEvent( eventNumber, &perf );
AliHLTTPCCADisplay display;
display.Init();
//display.SetPerformance( &perf );
display.SetGB( &tracker );
if ( sliceNumber < 0 ) {
display.SetTPCView();
display.DrawTPC();
display.DrawGBHits( tracker );
display.Ask();
for ( int trackIndex = 0; trackIndex < tracker.NTracks(); ++trackIndex ) {
display.DrawGBTrack( trackIndex );
}
display.Ask();
display.SetSliceView();
for ( int i = 0; i < tracker.NSlices(); ++i ) {
if ( tracker.Slice( i ).Data().NumberOfHits() > 0 ) {
drawSlice( display, tracker.Slices()[i] );
}
}
} else {
display.SetSliceView();
drawSlice( display, tracker.Slices()[sliceNumber] );
}
return 0;
}