Added two missing includes to allow macro compilation (thanks to Laurent for remarkin...
[u/mrichter/AliRoot.git] / ITS / PlotSDDRawData.C
CommitLineData
1e40ae31 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <TH2F.h>
e5b2f7f2 3#include <TGrid.h>
1e40ae31 4#include <TCanvas.h>
5#include <TStopwatch.h>
6#include <TStyle.h>
7#include "AliRawReaderDate.h"
8#include "AliRawReaderRoot.h"
9#include "AliITSRawStreamSDD.h"
e5b2f7f2 10#include "AliITSRawStreamSDDCompressed.h"
1e40ae31 11#endif
12
13// Macro to display the SDD Raw Data for 1 DDL
14// Origin: F. Prino, prino@to.infn.it
15
e5b2f7f2 16void PlotSDDRawData(Char_t datafil[100], Int_t nDDL, Int_t firstEv=18, Int_t lastEv=20){
1e40ae31 17
1e40ae31 18 const Int_t nHybrids=24;
e5b2f7f2 19 Bool_t writtenoutput=kFALSE;
1e40ae31 20 TH2F** histo = new TH2F*[nHybrids];
21 Char_t nome[20];
22 for(Int_t i=0;i<nHybrids;i++){
23 sprintf(nome,"histo%d",i);
24 histo[i]=new TH2F(nome,"",256,-0.5,255.5,256,-0.5,255.5);
25 histo[i]->SetStats(0);
26 }
27
28 Int_t iev=firstEv;
29 AliRawReader *rd;
30 if(strstr(datafil,".root")!=0){
31 rd=new AliRawReaderRoot(datafil,iev);
32 }else{
33 rd=new AliRawReaderDate(datafil,iev);
34 }
35 TStopwatch *evtime=new TStopwatch();
36 TCanvas* c0 = new TCanvas("cd0","c0",900,900);
37 gStyle->SetPalette(1);
e5b2f7f2 38
1e40ae31 39 do{
40 c0->Clear();
41 c0->Divide(4,6,0.001,0.001);
42
43 evtime->Start();
44 printf("Event # %d\n",iev);
1e40ae31 45 rd->Reset();
46 for(Int_t i=0;i<nHybrids;i++) histo[i]->Reset();
e5b2f7f2 47 UChar_t cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rd);
48 UInt_t amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr);
49 AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rd,cdhAttr);
50 if(!writtenoutput){
51 printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq);
52 writtenoutput=kTRUE;
53 }
54
1e40ae31 55 Int_t iCountNext=0;
e5b2f7f2 56 while(s->Next()){
1e40ae31 57 iCountNext++;
e5b2f7f2 58 if(s->IsCompletedModule()==kFALSE && s->IsCompletedDDL()==kFALSE){
59 Int_t i=s->GetCarlosId()*2+s->GetChannel();
60 if(rd->GetDDLID()==nDDL) histo[i]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
1e40ae31 61 }
62 }
1e40ae31 63 evtime->Stop();
e5b2f7f2 64 printf("**** Event=%d \n",iev);
1e40ae31 65 evtime->Print("u");
66 evtime->Reset();
67 iev++;
68
69 for(Int_t i=0;i<nHybrids;i++){
70 c0->cd(i+1);
71 histo[i]->DrawCopy("colz");
72 }
73 c0->Update();
74 }while(rd->NextEvent()&&iev<=lastEv);
75
76}
77
e5b2f7f2 78void PlotSDDRawData(Int_t nrun, Int_t n2, Int_t year=2009, Char_t* dir="LHC09b_SDD",
79 Int_t nDDL=0,
80 Int_t firstEv=18,
81 Int_t lastEv=20){
82
83 TGrid::Connect("alien:",0,0,"t");
84 Char_t filnam[200];
85 sprintf(filnam,"alien:///alice/data/%d/%s/%09d/raw/%02d%09d%03d.10.root",year,dir,nrun,year-2000,nrun,n2);
86 printf("Open file %s\n",filnam);
87 PlotSDDRawData(filnam,nDDL,firstEv,lastEv);
88}
89