]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/macrosSDD/PlotSDDRawData.C
Package for fast semi-analitical MC with realistic geometry
[u/mrichter/AliRoot.git] / ITS / macrosSDD / PlotSDDRawData.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TH2F.h>
3 #include <TGrid.h>
4 #include <TCanvas.h>
5 #include <TStopwatch.h>
6 #include <TStyle.h>
7 #include "AliRawReaderDate.h"
8 #include "AliRawReaderRoot.h"
9 #include "AliITSRawStreamSDD.h"
10 #include "AliITSRawStreamSDDCompressed.h"
11 #endif
12
13 // Macro to display the SDD Raw Data for 1 DDL
14 // Origin: F. Prino,   prino@to.infn.it
15
16 void PlotSDDRawData(Char_t datafil[100], 
17                     Int_t nDDL, 
18                     Int_t firstEv=18, 
19                     Int_t lastEv=20){
20
21   // Main function
22
23   const Int_t nHybrids=24;
24   Bool_t writtenoutput=kFALSE;
25   TH2F** histo = new TH2F*[nHybrids];
26   for(Int_t i=0;i<nHybrids;i++){
27     histo[i]=new TH2F(Form("histo%d",i),"",256,-0.5,255.5,256,-0.5,255.5);
28     histo[i]->SetStats(0);
29   }
30
31   Bool_t isSingleMod=kFALSE;
32   Int_t npx=4;
33   Int_t npy=6;
34   Int_t xsiz=700;
35   Int_t ysiz=700;
36   Int_t nHybrToPlot=24;
37   Int_t iMod=-1;
38   Int_t nCarlos;
39   if(nDDL>=240 && nDDL<500){
40     iMod=nDDL;
41     AliITSDDLModuleMapSDD* dmap=new AliITSDDLModuleMapSDD();
42     dmap->SetJun09Map();
43     dmap->FindInDDLMap(iMod,nDDL,nCarlos);
44     histo[nCarlos*2]->SetTitle(Form("Module %d Side 0",iMod));
45     histo[nCarlos*2+1]->SetTitle(Form("Module %d Side 1",iMod));
46     isSingleMod=kTRUE;
47     npx=2;
48     npy=1;
49     xsiz=900;
50     ysiz=450;
51     nHybrToPlot=2;
52   }
53
54   Int_t iev=firstEv;
55   AliRawReader *rd; 
56   if(strstr(datafil,".root")!=0){
57     rd=new AliRawReaderRoot(datafil,iev);
58   }else{
59     rd=new AliRawReaderDate(datafil,iev);
60   }
61   TStopwatch *evtime=new TStopwatch();
62   TCanvas* c0 = new TCanvas("cd0","c0",xsiz,ysiz);
63   gStyle->SetPalette(1);
64
65   do{
66     c0->Clear();                                
67     c0->Divide(npx,npy,0.001,0.001);
68
69     evtime->Start();
70     printf("Event # %d\n",iev);
71     rd->Reset();
72     for(Int_t i=0;i<nHybrids;i++) histo[i]->Reset();
73     UChar_t cdhAttr=AliITSRawStreamSDD::ReadBlockAttributes(rd);
74     UInt_t amSamplFreq=AliITSRawStreamSDD::ReadAMSamplFreqFromCDH(cdhAttr);
75     AliITSRawStream* s=AliITSRawStreamSDD::CreateRawStreamSDD(rd,cdhAttr);
76     if(!writtenoutput){
77       printf("Use %s raw stream, sampling frequency %d MHz\n",s->ClassName(),amSamplFreq);
78       writtenoutput=kTRUE;
79     }
80
81     Int_t iCountNext=0;    
82     while(s->Next()){
83       iCountNext++;
84       if(s->IsCompletedModule()==kFALSE && s->IsCompletedDDL()==kFALSE){
85         Int_t i=s->GetCarlosId()*2+s->GetChannel();
86         if(rd->GetDDLID()==nDDL) histo[i]->Fill(s->GetCoord2(),s->GetCoord1(),s->GetSignal());
87       }
88     }
89     evtime->Stop();
90     printf("**** Event=%d  \n",iev);
91     evtime->Print("u");
92     evtime->Reset();
93     iev++;
94     
95     for(Int_t i=0;i<nHybrToPlot;i++){
96       c0->cd(i+1);
97       if(isSingleMod){
98         histo[nCarlos*2+i]->DrawCopy("colz");
99       }else{
100         histo[i]->DrawCopy("colz");
101       }
102     }
103     c0->Update();
104     //    if(histo[nCarlos*2]->GetMaximum()>1) getchar();
105   }while(rd->NextEvent()&&iev<=lastEv);
106
107 }
108
109 void PlotSDDRawData(Int_t nrun, 
110                     Int_t n2, 
111                     Int_t year=2011, 
112                     Char_t* dir="LHC11d_SDD",
113                     Int_t nDDL=0, 
114                     Int_t firstEv=18, 
115                     Int_t lastEv=20){
116
117   // Get file directly from alien
118
119   TGrid::Connect("alien:",0,0,"t");
120   Char_t filnam[200];
121   sprintf(filnam,"alien:///alice/data/%d/%s/%09d/raw/%02d%09d%03d.10.root",year,dir,nrun,year-2000,nrun,n2);
122   printf("Open file %s\n",filnam);
123   PlotSDDRawData(filnam,nDDL,firstEv,lastEv);
124 }
125
126 void PlotSDDRawData(Char_t datafil[100], 
127                     Int_t nLay, 
128                     Int_t nLad, 
129                     Int_t nDet,
130                     Int_t firstEv, 
131                     Int_t lastEv){
132
133   // plot raw data for single module starting from 
134   // Layer, Ladder and detector numbers (counted from 1)
135   Int_t modIndex=AliITSgeomTGeo::GetModuleIndex(nLay,nLad,nDet);
136   PlotSDDRawData(datafil,modIndex,firstEv,lastEv);
137
138 }