ALIROOT-5769: Better handling of the error (R. Preghenella)
[u/mrichter/AliRoot.git] / RAW / readCaloV3.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2   #include <TStopwatch.h>
3   #include <TStyle.h>
4   #include <TH1F.h>
5   #include <TH2F.h>
6   #include <TString.h>
7   #include <TCanvas.h>
8   #include "AliRawReader.h"
9   #include "AliCaloRawStreamV3.h"
10   #include "AliLog.h"
11 #endif
12
13
14 void readCaloV3(const char *fileName = "./", const TString calo="PHOS")
15 {
16   TH1D *hAmplHG  = new TH1D("hAmplHG" ,"HG amplitude" ,1024,-0.5,1023.5);
17   TH1D *hAmplLG  = new TH1D("hAmplLG" ,"LG amplitude" ,1024,-0.5,1023.5);
18   TH1D *hAmplTRU = new TH1D("hAmplTRU","TRU amplitude",1024,-0.5,1023.5);
19   TH1F *hModule  = new TH1F("hModule" ,"Module number",10,-0.5,9.5);
20   TH2F *hXZHG    = new TH2F("hXZHG"   ,"XZ HG cells",64,-0.5,63.5,64,-0.5,63.5);
21   TH2F *hXZLG    = new TH2F("hXZLG"   ,"XZ LG cells",64,-0.5,63.5,64,-0.5,63.5);
22   TH2F *hHWaddr  = new TH2F("hHWaddr","DDL is vs HW addr",216,-0.5,215.5,4096,-0.5,4095.5);
23
24   //  AliLog::SetGlobalLogLevel(AliLog::kFatal);
25   //  AliLog::SetPrintRepetitions(kFALSE);
26
27   AliRawReader *reader = AliRawReader::Create(fileName);
28   reader->Reset();
29
30   TStopwatch timer;
31   timer.Start();
32
33   AliCaloRawStreamV3 *stream = new AliCaloRawStreamV3(reader,calo);
34
35   Int_t iev = 0;
36
37   while (reader->NextEvent()) {
38     AliInfoGeneral("",Form("Reading event %d\n",iev++));
39     while (stream->NextDDL()) {
40       while (stream->NextChannel()) {
41 //      AliInfoGeneral("",Form("New channel: HW=%d, module=%d, row=%d, col=%d, caloflag=%d",
42 //                          stream->GetHWAddress(),
43 //                          stream->GetModule(),
44 //                          stream->GetRow(),
45 //                          stream->GetColumn(),
46 //                          stream->GetCaloFlag()));
47         hHWaddr->Fill(stream->GetDDLNumber(),stream->GetHWAddress());
48         hModule->Fill(stream->GetModule());
49         if (stream->IsHighGain())
50           hXZHG->Fill(stream->GetRow(),stream->GetColumn());
51         if (stream->IsLowGain())
52           hXZLG->Fill(stream->GetRow(),stream->GetColumn());
53
54         while (stream->NextBunch()) {
55           const UShort_t *sig = stream->GetSignals();
56           Int_t startBin = stream->GetStartTimeBin();
57           for (Int_t i = 0; i < stream->GetBunchLength(); i++) {
58             if (stream->IsHighGain())
59               hAmplHG->Fill(sig[i]);
60             if (stream->IsLowGain())
61               hAmplLG->Fill(sig[i]);
62             if (stream->IsTRUData())
63               hAmplTRU->Fill(sig[i]);
64           }
65         }
66       }
67     }
68     stream->Reset();
69   }
70
71   timer.Stop();
72   timer.Print();
73
74   gStyle->SetPalette(1);
75   TCanvas *c1 = new TCanvas("c1","",0,0,900,600);
76   c1->Divide(3,1);
77   c1->cd(1);
78   hAmplHG->Draw();
79   c1->cd(2);
80   hAmplLG->Draw();
81   c1->cd(3);
82   hAmplTRU->Draw();
83
84   TCanvas *c2 = new TCanvas("c2","",0,0,900,600);
85   c2->Divide(2,1);
86   c2->cd(1);
87   hModule->Draw();
88   c2->cd(2);
89   hHWaddr->Draw("colz");
90
91   TCanvas *c3 = new TCanvas("c3","",0,0,900,600);
92   c3->Divide(2,1);
93   c3->cd(1);
94   hXZHG->Draw("colz");
95   c3->cd(2);
96   hXZLG->Draw("colz");
97 }