forked from alisw/AliRoot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestRawReaderFastDDL.C
144 lines (115 loc) · 4.19 KB
/
testRawReaderFastDDL.C
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
132
133
134
135
136
137
138
139
140
141
142
143
/// \file testRawReaderFastDDL.C
///
/// compare old and new AltroRawStream algorithms for each pad and timebin
///
/// check if bins are filled twice (which should not be the case!!!)
#include <stdio.h>
#include <TString.h>
#include <TROOT.h>
#include <TStopwatch.h>
#include <TH2I.h>
#include <TFile.h>
#include "AliRawReader.h"
#include "AliRawReaderRoot.h"
#include "AliLog.h"
#include "AliAltroRawStreamFast.h"
#include "AliAltroRawStream.h"
void testRawReaderFastDDL(const Char_t *file="/data.local/data/06000002142000.1A.root")
{
// set minimal screen output
AliLog::SetGlobalDebugLevel(0) ;
AliLog::SetGlobalLogLevel(AliLog::kFatal);
// TString filename("/d/alice05/testtpc/raw/pulser/06000002142000.1A.root");
TString filename(file);
printf("File: %s\n", filename.Data());
AliRawReader *rawReader = new AliRawReaderRoot(filename);
if ( !rawReader ) return;
rawReader->RewindEvents();
AliAltroRawStreamFast *sf = new AliAltroRawStreamFast(rawReader);
AliAltroRawStream *s = new AliAltroRawStream(rawReader);
s->SetNoAltroMapping(kFALSE);
s->SelectRawData("TPC");
Int_t ievent = 0;
Int_t count=0;
TH2I *h2ddlT1[216];
TH2I *h2ddlT2[216];
for ( Int_t i=0; i<216; i++ ){
h2ddlT1[i] = 0x0;
h2ddlT2[i] = 0x0;
}
TStopwatch timer1;
TStopwatch timer2;
TStopwatch timer3;
while (rawReader->NextEvent()){
printf("\nevent: %d\n",ievent);
Bool_t input=kFALSE;
//old algorithm
timer1.Start();timer2.Start(kFALSE);
while ( s->Next() ){
if ( !h2ddlT1[s->GetDDLNumber()] ) h2ddlT1[s->GetDDLNumber()] = new TH2I(Form("hddl1_%d",s->GetDDLNumber()),"h2c1",3584,0,3584,1024,0,1024);
TH2I *hist = h2ddlT1[s->GetDDLNumber()];
//fast filling, TH1::Fill takes awfully long
Int_t bin=(s->GetTime()+1)*(3584+2)+s->GetHWAddress()+1;
// check if this bin was allready filled
if ( hist->GetArray()[bin] > 0 )
printf(" not 0: | %.3d : %.3d (%.3d)\n",
s->GetHWAddress(), s->GetSignal(), hist->GetArray()[bin]);
else
hist->GetArray()[bin]=s->GetSignal();
input=kTRUE;
count++;
}
timer1.Stop();timer2.Stop();
printf("old -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
// END OLD
rawReader->Reset();
//new algorithm
timer1.Start();timer3.Start(kFALSE);
while ( sf->NextDDL() ){
if ( !h2ddlT2[sf->GetDDLNumber()] ) h2ddlT2[sf->GetDDLNumber()] = new TH2I(Form("hddl2_%d",s->GetDDLNumber()),"h2c1",3584,0,3584,1024,0,1024);
TH2I *hist = h2ddlT2[sf->GetDDLNumber()];
while ( sf->NextChannel() ){
UInt_t signal=0;
while ( sf->NextBunch() ){
for (UInt_t timebin=sf->GetStartTimeBin(); timebin<sf->GetEndTimeBin(); timebin++){
signal=sf->GetSignals()[timebin-sf->GetStartTimeBin()];
//fast filling, TH1::Fill takes awfully long
Int_t bin=(timebin+1+1)*(3584+2)+sf->GetHWAddress()+1; // timebins of old and new algorithm differ by 1!!!
// check if this bin was allready filled
if ( hist->GetArray()[bin] > 0 )
printf(" not 0: | %.3d : %.3d (%.3d)\n",
sf->GetHWAddress(), signal, hist->GetArray()[bin]);
else
hist->GetArray()[bin]=signal;
}
}
}
}
timer1.Stop();timer3.Stop();
printf("new -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
// END NEW
//check if all data are the same for both algorithms
for ( Int_t ddl=0; ddl<216; ddl++ ){
TH2I *hist = h2ddlT1[ddl];
if ( !hist ) continue;
TH2I *hist2 = h2ddlT2[ddl];
for ( Int_t hadd=0; hadd<3584; hadd++ )
for ( Int_t time=0; time<1024; time++ ){
Int_t bin=(time+1)*(3584+2)+hadd+1;
Int_t val1 = hist->GetArray()[bin];
Int_t val2 = hist2->GetArray()[bin];
if ( val1 != val2 )
printf("%.2d. %.3d %.4d %.4d: %d - %d = %d\n", ievent, ddl, hadd, time, val1, val2, val1-val2);
//reset for the next event
hist->GetArray()[bin]=0;
hist2->GetArray()[bin]=0;
}
}
if (input) ievent++;
}
printf("total old -- Time: %.4f (%.4f)\n", timer2.RealTime(), timer2.CpuTime());
printf("total new -- Time: %.4f (%.4f)\n", timer3.RealTime(), timer3.CpuTime());
delete rawReader;
delete [] h2ddlT1;
delete [] h2ddlT2;
}