1 /// \file testRawReaderFastTPC.C
6 #include <TStopwatch.h>
13 #include "AliRawReader.h"
14 #include "AliRawReaderRoot.h"
16 #include "AliTPCRawStream.h"
17 #include "AliTPCRawStreamFast.h"
19 #include "AliAltroRawStream.h"
20 #include "AliAltroRawStreamFast.h"
22 #include "AliTPCCalPad.h"
23 #include "AliTPCCalROC.h"
26 .L testRawReaderFastTPC.C+
27 testRawReaderFastTPC()
31 AliTPCCalPad *testRawReaderFastTPC(const Char_t *file="/data.local/data/06000002142000.1A.root")
34 AliLog::SetGlobalDebugLevel(0) ;
35 AliLog::SetGlobalLogLevel(AliLog::kFatal);
37 //TString filename("/d/alice05/testtpc/raw/pulser/06000002142000.1A.root"); //nfs
38 //TString filename("root://lxfs35.gsi.de:1094//alice/testtpc/raw2006/06000001537001.001.root");
40 TString filename(file); //local
41 // on castor: /castor/cern.ch/alice/data/2006/09/18/15/06000002142000.1A.root
44 printf("File: %s\n", filename.Data());
46 AliRawReader *rawReader = new AliRawReaderRoot(filename);
47 if ( !rawReader ) return 0x0;
48 rawReader->RewindEvents();
50 AliTPCRawStreamFast *sf = new AliTPCRawStreamFast(rawReader);
51 AliTPCRawStream *s = new AliTPCRawStream(rawReader);
53 s->SetNoAltroMapping(kFALSE);
59 AliTPCCalPad *padOld = new AliTPCCalPad("old","old");
60 AliTPCCalPad *padNew = new AliTPCCalPad("new","new");
61 AliTPCCalPad *padSum = new AliTPCCalPad("sum","sum");
62 AliTPCCalPad *padhadd = new AliTPCCalPad("sum","sum");
64 for (Int_t sec=0; sec<72; sec++){
65 AliTPCCalROC *roc = padhadd->GetCalROC(sec);
66 for (UInt_t ch=0; ch<roc->GetNchannels(); ch++)
74 TCanvas *c1 = (TCanvas*)gROOT->FindObject("c1");
75 if ( !c1 ) c1 = new TCanvas("c1","c1");
80 while (rawReader->NextEvent()){
82 printf("\nevent: %d (%d)\n",ievent, ievent2);
86 // if ( ievent != 19 ) input=kTRUE;
88 timer1.Start();timer2.Start(kFALSE);
93 AliTPCCalROC *roc = padhadd->GetCalROC(s->GetSector());
95 //check if hwaddress gets overwritten
96 if ( roc->GetValue(s->GetRow(), s->GetPad()) == -1 )
97 roc->SetValue(s->GetRow(), s->GetPad(), s->GetHWAddress());
99 if ( roc->GetValue(s->GetRow(), s->GetPad()) != s->GetHWAddress()){
100 printf("#%.2d: %.2d.%.3d.%.2d,%.4d - old [%.4d] now[%.4d]",
101 ievent, s->GetSector(), s->GetRow(),s->GetPad(), s->GetTime(),
102 (Int_t)roc->GetValue(s->GetRow(), s->GetPad()), s->GetHWAddress());
106 Float_t val=padOld->GetCalROC(s->GetSector())->GetValue(s->GetRow(), s->GetPad());
107 padOld->GetCalROC(s->GetSector())->SetValue(s->GetRow(), s->GetPad(), s->GetSignal()+val);
109 /* if ( ievent == 19 && s->GetSector() == 25 && s->GetRow() == 00 && s->GetPad()==9 ){
110 printf("old | (%.2d.%.3d.%.2d.%.4d | %.3d ): %.3d\n",
111 s->GetSector(), s->GetRow(), s->GetPad(), s->GetTime(), s->GetHWAddress(), s->GetSignal());
112 sum1+=s->GetSignal();
119 timer1.Stop();timer2.Stop();
120 printf("old -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
125 timer1.Start();timer3.Start(kFALSE);
126 while ( sf->NextDDL() ){
127 while ( sf->NextChannel() ){
129 while ( sf->NextBunch() ){
130 for (UInt_t timebin=sf->GetStartTimeBin(); timebin<sf->GetEndTimeBin(); timebin++){
132 AliTPCCalROC *roc = padhadd->GetCalROC(sf->GetSector());
133 // if ( roc->GetValue(sf->GetRow(), sf->GetPad()) == -1 )
134 // roc->SetValue(sf->GetRow(), sf->GetPad(), sf->GetHWAddress());
136 if ( roc->GetValue(sf->GetRow(), sf->GetPad()) != sf->GetHWAddress()){
137 printf("#%.2d: %.2d.%.3d.%.2d,%.4d - old [%.4d] now[%.4d]",
138 ievent, sf->GetSector(), sf->GetRow(),sf->GetPad(), timebin+1,
139 (Int_t)roc->GetValue(sf->GetRow(), sf->GetPad()), sf->GetHWAddress());
142 Int_t sig = sf->GetSignals()[timebin-sf->GetStartTimeBin()];
143 if ( ievent == 19 && sf->GetSector() == 25 && sf->GetRow() == 00 && sf->GetPad()==9 ){
144 printf("new | (%.2d.%.3d.%.2d.%.4d | %.3d ): %.3d\n",
145 sf->GetSector(), sf->GetRow(), sf->GetPad(), timebin+1, sf->GetHWAddress(), sig );
149 signal+=sf->GetSignals()[timebin-sf->GetStartTimeBin()];
151 padNew->GetCalROC(sf->GetSector())->SetValue(sf->GetRow(),sf->GetPad(),signal);
155 timer1.Stop();timer3.Stop();
156 printf("new -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
158 printf("sum1: %d, sum2: %d, diff: %d\n",sum1,sum2,sum1-sum2);
160 AliTPCCalPad com(*padOld);
164 padOld->MakeHisto2D(1)->Draw("colz");
166 padNew->MakeHisto2D(1)->Draw("colz");
168 com.MakeHisto2D(1)->Draw("colz");
170 //loop over all sectors, rows, pads
171 for ( UInt_t iSec=0; iSec<72; iSec++ )
172 for ( UInt_t iRow=0; iRow<com.GetCalROC(iSec)->GetNrows(); iRow++ )
173 for ( UInt_t iPad=0; iPad<com.GetCalROC(iSec)->GetNPads(iRow); iPad++){
174 Float_t val = com.GetCalROC(iSec)->GetValue(iRow, iPad);
175 Float_t valo = padNew->GetCalROC(iSec)->GetValue(iRow, iPad);
176 Float_t valn = padOld->GetCalROC(iSec)->GetValue(iRow, iPad);
177 //check if values for old and new algorithm differ
179 if ( (Int_t)valo != (Int_t)valn ){
180 Float_t hadd = padhadd->GetCalROC(iSec)->GetValue(iRow,iPad);
181 printf("Event: %.2d | (%.2d.%.3d.%.2d | %f ): %.3f\n", ievent, iSec, iRow, iPad, hadd, val);
182 padSum->GetCalROC(iSec)->SetValue(iRow, iPad, padSum->GetCalROC(iSec)->GetValue(iRow, iPad)+1);
184 com.GetCalROC(iSec)->SetValue(iRow, iPad, 0);
185 padOld->GetCalROC(iSec)->SetValue(iRow, iPad, 0);
186 padNew->GetCalROC(iSec)->SetValue(iRow, iPad, 0);
191 padSum->MakeHisto2D(1)->Draw("colz");
199 TFile f("output.root","recreate");
204 printf("total old -- Time: %.4f (%.4f)\n", timer2.RealTime(), timer2.CpuTime());
205 printf("total new -- Time: %.4f (%.4f)\n", timer3.RealTime(), timer3.CpuTime());