AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
testRawReaderFastTPC.C
Go to the documentation of this file.
1 
3 #include <stdio.h>
4 #include <TString.h>
5 #include <TROOT.h>
6 #include <TStopwatch.h>
7 #include <TCanvas.h>
8 #include <TFile.h>
9 #include <TH2F.h>
10 
11 #include "AliLog.h"
12 
13 #include "AliRawReader.h"
14 #include "AliRawReaderRoot.h"
15 
16 #include "AliTPCRawStream.h"
17 #include "AliTPCRawStreamFast.h"
18 
19 #include "AliAltroRawStream.h"
20 #include "AliAltroRawStreamFast.h"
21 
22 #include "AliTPCCalPad.h"
23 #include "AliTPCCalROC.h"
24 
25 /*
26  .L testRawReaderFastTPC.C+
27  testRawReaderFastTPC()
28 */
29 
30 
31 AliTPCCalPad *testRawReaderFastTPC(const Char_t *file="/data.local/data/06000002142000.1A.root")
32 {
33 
34  AliLog::SetGlobalDebugLevel(0) ;
35  AliLog::SetGlobalLogLevel(AliLog::kFatal);
36 
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");
39 
40  TString filename(file); //local
41  // on castor: /castor/cern.ch/alice/data/2006/09/18/15/06000002142000.1A.root
42 
43 
44  printf("File: %s\n", filename.Data());
45 
46  AliRawReader *rawReader = new AliRawReaderRoot(filename);
47  if ( !rawReader ) return 0x0;
48  rawReader->RewindEvents();
49 
50  AliTPCRawStreamFast *sf = new AliTPCRawStreamFast(rawReader);
51  AliTPCRawStream *s = new AliTPCRawStream(rawReader);
52 
53  s->SetNoAltroMapping(kFALSE);
54 
55  Int_t ievent = 0;
56  Int_t ievent2 = 0;
57  Int_t count=0;
58 
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");
63 
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++)
67  roc->SetValue(ch,-1);
68  }
69 
70  TStopwatch timer1;
71  TStopwatch timer2;
72  TStopwatch timer3;
73 
74  TCanvas *c1 = (TCanvas*)gROOT->FindObject("c1");
75  if ( !c1 ) c1 = new TCanvas("c1","c1");
76  c1->Clear();
77  c1->Divide(2,2);
78 
79 
80  while (rawReader->NextEvent()){
81  //old algorithm
82  printf("\nevent: %d (%d)\n",ievent, ievent2);
83 
84  Bool_t input=kFALSE;
85 
86 // if ( ievent != 19 ) input=kTRUE;
87 // else{
88  timer1.Start();timer2.Start(kFALSE);
89 
90  Int_t sum1 = 0;
91  Int_t sum2 = 0;
92  while ( s->Next() ){
93  AliTPCCalROC *roc = padhadd->GetCalROC(s->GetSector());
94 
95  //check if hwaddress gets overwritten
96  if ( roc->GetValue(s->GetRow(), s->GetPad()) == -1 )
97  roc->SetValue(s->GetRow(), s->GetPad(), s->GetHWAddress());
98  else
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());
103  }
104 
105 
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);
108 
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();
113  }
114 */
115 
116  input=kTRUE;
117  count++;
118  }
119  timer1.Stop();timer2.Stop();
120  printf("old -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
121 
122  rawReader->Reset();
123 
124  //new algorithm
125  timer1.Start();timer3.Start(kFALSE);
126  while ( sf->NextDDL() ){
127  while ( sf->NextChannel() ){
128  UInt_t signal=0;
129  while ( sf->NextBunch() ){
130  for (UInt_t timebin=sf->GetStartTimeBin(); timebin<sf->GetEndTimeBin(); timebin++){
131 
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());
135 // else
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());
140  }
141  /*
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 );
146  sum2+=sig;
147  }
148  */
149  signal+=sf->GetSignals()[timebin-sf->GetStartTimeBin()];
150  }
151  padNew->GetCalROC(sf->GetSector())->SetValue(sf->GetRow(),sf->GetPad(),signal);
152  }
153  }
154  }
155  timer1.Stop();timer3.Stop();
156  printf("new -- Time: %.4f (%.4f)\n", timer1.RealTime(), timer1.CpuTime());
157 
158  printf("sum1: %d, sum2: %d, diff: %d\n",sum1,sum2,sum1-sum2);
159 
160  AliTPCCalPad com(*padOld);
161  com.Add(padNew, -1);
162 
163  c1->cd(1);
164  padOld->MakeHisto2D(1)->Draw("colz");
165  c1->cd(2);
166  padNew->MakeHisto2D(1)->Draw("colz");
167  c1->cd(3);
168  com.MakeHisto2D(1)->Draw("colz");
169 
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
178 // if ( val != 0 ){
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);
183  }
184  com.GetCalROC(iSec)->SetValue(iRow, iPad, 0);
185  padOld->GetCalROC(iSec)->SetValue(iRow, iPad, 0);
186  padNew->GetCalROC(iSec)->SetValue(iRow, iPad, 0);
187  }
188 
189 
190  c1->cd(4);
191  padSum->MakeHisto2D(1)->Draw("colz");
192 
193  c1->Modified();
194  c1->Update();
195  // }// end event sel
196  if (input) ievent++;
197  ievent2++;
198  }
199  TFile f("output.root","recreate");
200  padSum->Write();
201  f.Save();
202  f.Close();
203 
204  printf("total old -- Time: %.4f (%.4f)\n", timer2.RealTime(), timer2.CpuTime());
205  printf("total new -- Time: %.4f (%.4f)\n", timer3.RealTime(), timer3.CpuTime());
206 
207  delete rawReader;
208  return padSum;
209 }
210 
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
AliTPCCalROC * GetCalROC(Int_t sector) const
Definition: AliTPCCalPad.h:42
TFile f("CalibObjects.root")
Float_t GetValue(UInt_t row, UInt_t pad) const
Definition: AliTPCCalROC.h:33
TROOT * gROOT
UInt_t GetNPads(UInt_t row) const
Definition: AliTPCCalROC.h:32
void SetValue(UInt_t row, UInt_t pad, Float_t vd)
Definition: AliTPCCalROC.h:35
void Add(Float_t c1)
AliTPCCalPad * testRawReaderFastTPC(const Char_t *file="/data.local/data/06000002142000.1A.root")
TPC calibration base class for one ROC.
Definition: AliTPCCalROC.h:19
TH2F * MakeHisto2D(Int_t side=0)
UInt_t GetNchannels() const
Definition: AliTPCCalROC.h:30
UInt_t GetNrows() const
Definition: AliTPCCalROC.h:29