#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"
/*
compare old and new AltroRawStream algorithms for each pad and timebin
check if bins are filled twice (which should not be the case!!!)
*/
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;
}
testRawReaderFastDDL.C:10 testRawReaderFastDDL.C:11 testRawReaderFastDDL.C:12 testRawReaderFastDDL.C:13 testRawReaderFastDDL.C:14 testRawReaderFastDDL.C:15 testRawReaderFastDDL.C:16 testRawReaderFastDDL.C:17 testRawReaderFastDDL.C:18 testRawReaderFastDDL.C:19 testRawReaderFastDDL.C:20 testRawReaderFastDDL.C:21 testRawReaderFastDDL.C:22 testRawReaderFastDDL.C:23 testRawReaderFastDDL.C:24 testRawReaderFastDDL.C:25 testRawReaderFastDDL.C:26 testRawReaderFastDDL.C:27 testRawReaderFastDDL.C:28 testRawReaderFastDDL.C:29 testRawReaderFastDDL.C:30 testRawReaderFastDDL.C:31 testRawReaderFastDDL.C:32 testRawReaderFastDDL.C:33 testRawReaderFastDDL.C:34 testRawReaderFastDDL.C:35 testRawReaderFastDDL.C:36 testRawReaderFastDDL.C:37 testRawReaderFastDDL.C:38 testRawReaderFastDDL.C:39 testRawReaderFastDDL.C:40 testRawReaderFastDDL.C:41 testRawReaderFastDDL.C:42 testRawReaderFastDDL.C:43 testRawReaderFastDDL.C:44 testRawReaderFastDDL.C:45 testRawReaderFastDDL.C:46 testRawReaderFastDDL.C:47 testRawReaderFastDDL.C:48 testRawReaderFastDDL.C:49 testRawReaderFastDDL.C:50 testRawReaderFastDDL.C:51 testRawReaderFastDDL.C:52 testRawReaderFastDDL.C:53 testRawReaderFastDDL.C:54 testRawReaderFastDDL.C:55 testRawReaderFastDDL.C:56 testRawReaderFastDDL.C:57 testRawReaderFastDDL.C:58 testRawReaderFastDDL.C:59 testRawReaderFastDDL.C:60 testRawReaderFastDDL.C:61 testRawReaderFastDDL.C:62 testRawReaderFastDDL.C:63 testRawReaderFastDDL.C:64 testRawReaderFastDDL.C:65 testRawReaderFastDDL.C:66 testRawReaderFastDDL.C:67 testRawReaderFastDDL.C:68 testRawReaderFastDDL.C:69 testRawReaderFastDDL.C:70 testRawReaderFastDDL.C:71 testRawReaderFastDDL.C:72 testRawReaderFastDDL.C:73 testRawReaderFastDDL.C:74 testRawReaderFastDDL.C:75 testRawReaderFastDDL.C:76 testRawReaderFastDDL.C:77 testRawReaderFastDDL.C:78 testRawReaderFastDDL.C:79 testRawReaderFastDDL.C:80 testRawReaderFastDDL.C:81 testRawReaderFastDDL.C:82 testRawReaderFastDDL.C:83 testRawReaderFastDDL.C:84 testRawReaderFastDDL.C:85 testRawReaderFastDDL.C:86 testRawReaderFastDDL.C:87 testRawReaderFastDDL.C:88 testRawReaderFastDDL.C:89 testRawReaderFastDDL.C:90 testRawReaderFastDDL.C:91 testRawReaderFastDDL.C:92 testRawReaderFastDDL.C:93 testRawReaderFastDDL.C:94 testRawReaderFastDDL.C:95 testRawReaderFastDDL.C:96 testRawReaderFastDDL.C:97 testRawReaderFastDDL.C:98 testRawReaderFastDDL.C:99 testRawReaderFastDDL.C:100 testRawReaderFastDDL.C:101 testRawReaderFastDDL.C:102 testRawReaderFastDDL.C:103 testRawReaderFastDDL.C:104 testRawReaderFastDDL.C:105 testRawReaderFastDDL.C:106 testRawReaderFastDDL.C:107 testRawReaderFastDDL.C:108 testRawReaderFastDDL.C:109 testRawReaderFastDDL.C:110 testRawReaderFastDDL.C:111 testRawReaderFastDDL.C:112 testRawReaderFastDDL.C:113 testRawReaderFastDDL.C:114 testRawReaderFastDDL.C:115 testRawReaderFastDDL.C:116 testRawReaderFastDDL.C:117 testRawReaderFastDDL.C:118 testRawReaderFastDDL.C:119 testRawReaderFastDDL.C:120 testRawReaderFastDDL.C:121 testRawReaderFastDDL.C:122 testRawReaderFastDDL.C:123 testRawReaderFastDDL.C:124 testRawReaderFastDDL.C:125 testRawReaderFastDDL.C:126 testRawReaderFastDDL.C:127 testRawReaderFastDDL.C:128 testRawReaderFastDDL.C:129 testRawReaderFastDDL.C:130 testRawReaderFastDDL.C:131 testRawReaderFastDDL.C:132 testRawReaderFastDDL.C:133 testRawReaderFastDDL.C:134 testRawReaderFastDDL.C:135 testRawReaderFastDDL.C:136 testRawReaderFastDDL.C:137 testRawReaderFastDDL.C:138 testRawReaderFastDDL.C:139 testRawReaderFastDDL.C:140 testRawReaderFastDDL.C:141 testRawReaderFastDDL.C:142 testRawReaderFastDDL.C:143 testRawReaderFastDDL.C:144