]>
Commit | Line | Data |
---|---|---|
a0918fa7 | 1 | #include <stdio.h> |
2 | #include <TString.h> | |
3 | #include <TROOT.h> | |
4 | #include <TStopwatch.h> | |
5 | #include <TH2I.h> | |
6 | #include <TFile.h> | |
7 | ||
8 | #include "AliRawReader.h" | |
9 | #include "AliRawReaderRoot.h" | |
10 | #include "AliLog.h" | |
11 | ||
12 | #include "AliAltroRawStreamFast.h" | |
13 | #include "AliAltroRawStream.h" | |
14 | ||
15 | /* | |
16 | compare old and new AltroRawStream algorithms for each pad and timebin | |
17 | ||
18 | check if bins are filled twice (which should not be the case!!!) | |
19 | */ | |
20 | ||
21 | void testRawReaderFastDDL(const Char_t *file="/data.local/data/06000002142000.1A.root") | |
22 | { | |
23 | // set minimal screen output | |
24 | AliLog::SetGlobalDebugLevel(0) ; | |
25 | AliLog::SetGlobalLogLevel(AliLog::kFatal); | |
26 | ||
27 | // TString filename("/d/alice05/testtpc/raw/pulser/06000002142000.1A.root"); | |
28 | TString filename(file); | |
29 | ||
30 | printf("File: %s\n", filename.Data()); | |
31 | ||
32 | AliRawReader *rawReader = new AliRawReaderRoot(filename); | |
33 | if ( !rawReader ) return; | |
34 | rawReader->RewindEvents(); | |
35 | ||
36 | AliAltroRawStreamFast *sf = new AliAltroRawStreamFast(rawReader); | |
37 | AliAltroRawStream *s = new AliAltroRawStream(rawReader); | |
38 | ||
a0918fa7 | 39 | s->SetNoAltroMapping(kFALSE); |
40 | s->SelectRawData("TPC"); | |
41 | ||
42 | Int_t ievent = 0; | |
43 | Int_t count=0; | |
44 | ||
45 | TH2I *h2ddlT1[216]; | |
46 | TH2I *h2ddlT2[216]; | |
47 | ||
48 | for ( Int_t i=0; i<216; i++ ){ | |
49 | h2ddlT1[i] = 0x0; | |
50 | h2ddlT2[i] = 0x0; | |
51 | } | |
52 | ||
53 | TStopwatch timer1; | |
54 | TStopwatch timer2; | |
55 | TStopwatch timer3; | |
56 | ||
57 | while (rawReader->NextEvent()){ | |
58 | printf("\nevent: %d\n",ievent); | |
59 | Bool_t input=kFALSE; | |
60 | ||
61 | ||
62 | //old algorithm | |
63 | timer1.Start();timer2.Start(kFALSE); | |
64 | while ( s->Next() ){ | |
65 | if ( !h2ddlT1[s->GetDDLNumber()] ) h2ddlT1[s->GetDDLNumber()] = new TH2I(Form("hddl1_%d",s->GetDDLNumber()),"h2c1",3584,0,3584,1024,0,1024); | |
66 | TH2I *hist = h2ddlT1[s->GetDDLNumber()]; | |
67 | ||
68 | //fast filling, TH1::Fill takes awfully long | |
69 | Int_t bin=(s->GetTime()+1)*(3584+2)+s->GetHWAddress()+1; | |
70 | // check if this bin was allready filled | |
71 | if ( hist->GetArray()[bin] > 0 ) | |
72 | printf(" not 0: | %.3d : %.3d (%.3d)\n", | |
73 | s->GetHWAddress(), s->GetSignal(), hist->GetArray()[bin]); | |
74 | else | |
75 | hist->GetArray()[bin]=s->GetSignal(); | |
76 | ||
77 | ||
78 | input=kTRUE; | |
79 | count++; | |
80 | } | |
81 | timer1.Stop();timer2.Stop(); | |
82 | printf("old -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime()); | |
83 | // END OLD | |
84 | ||
85 | rawReader->Reset(); | |
86 | ||
87 | //new algorithm | |
88 | timer1.Start();timer3.Start(kFALSE); | |
89 | while ( sf->NextDDL() ){ | |
90 | if ( !h2ddlT2[sf->GetDDLNumber()] ) h2ddlT2[sf->GetDDLNumber()] = new TH2I(Form("hddl2_%d",s->GetDDLNumber()),"h2c1",3584,0,3584,1024,0,1024); | |
91 | TH2I *hist = h2ddlT2[sf->GetDDLNumber()]; | |
92 | while ( sf->NextChannel() ){ | |
93 | UInt_t signal=0; | |
94 | while ( sf->NextBunch() ){ | |
95 | for (UInt_t timebin=sf->GetStartTimeBin(); timebin<sf->GetEndTimeBin(); timebin++){ | |
96 | signal=sf->GetSignals()[timebin-sf->GetStartTimeBin()]; | |
97 | ||
98 | //fast filling, TH1::Fill takes awfully long | |
99 | Int_t bin=(timebin+1+1)*(3584+2)+sf->GetHWAddress()+1; // timebins of old and new algorithm differ by 1!!! | |
100 | // check if this bin was allready filled | |
101 | if ( hist->GetArray()[bin] > 0 ) | |
102 | printf(" not 0: | %.3d : %.3d (%.3d)\n", | |
103 | sf->GetHWAddress(), signal, hist->GetArray()[bin]); | |
104 | else | |
105 | hist->GetArray()[bin]=signal; | |
106 | } | |
107 | } | |
108 | } | |
109 | } | |
110 | timer1.Stop();timer3.Stop(); | |
111 | printf("new -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime()); | |
112 | // END NEW | |
113 | ||
114 | //check if all data are the same for both algorithms | |
115 | for ( Int_t ddl=0; ddl<216; ddl++ ){ | |
116 | TH2I *hist = h2ddlT1[ddl]; | |
117 | if ( !hist ) continue; | |
118 | TH2I *hist2 = h2ddlT2[ddl]; | |
119 | for ( Int_t hadd=0; hadd<3584; hadd++ ) | |
120 | for ( Int_t time=0; time<1024; time++ ){ | |
121 | Int_t bin=(time+1)*(3584+2)+hadd+1; | |
122 | Int_t val1 = hist->GetArray()[bin]; | |
123 | Int_t val2 = hist2->GetArray()[bin]; | |
124 | if ( val1 != val2 ) | |
125 | printf("%.2d. %.3d %.4d %.4d: %d - %d = %d\n", ievent, ddl, hadd, time, val1, val2, val1-val2); | |
126 | ||
127 | //reset for the next event | |
128 | hist->GetArray()[bin]=0; | |
129 | hist2->GetArray()[bin]=0; | |
130 | } | |
131 | } | |
132 | ||
133 | if (input) ievent++; | |
134 | } | |
135 | ||
136 | printf("total old -- Time: %.4f (%.4f)\n", timer2.RealTime(), timer2.CpuTime()); | |
137 | printf("total new -- Time: %.4f (%.4f)\n", timer3.RealTime(), timer3.CpuTime()); | |
138 | ||
139 | delete rawReader; | |
140 | delete [] h2ddlT1; | |
141 | delete [] h2ddlT2; | |
142 | } | |
143 |