]>
Commit | Line | Data |
---|---|---|
91282711 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TH2F.h> | |
3 | #include <TCanvas.h> | |
4 | #include <TStopwatch.h> | |
5 | #include <TStyle.h> | |
6 | #include <TLatex.h> | |
7 | #include <TFile.h> | |
8 | #include <TGrid.h> | |
9 | #include "AliRawReader.h" | |
10 | #include "AliRawReaderDate.h" | |
11 | #include "AliRawReaderRoot.h" | |
12 | #include "AliITSOnlineSDDBase.h" | |
13 | #include "AliITSOnlineSDDCMN.h" | |
14 | #include "AliITSOnlineSDDTP.h" | |
15 | #include "AliITSRawStreamSDD.h" | |
16 | #endif | |
17 | ||
18 | // Macro for the analysis of PULSER runs (equivalent to ITSSDDGAINda.cxx) | |
19 | // Two functions named AnalyzeSDDGainAllModules: | |
20 | // The first is for analyzing a local raw data file and takes as agrument the file name. | |
21 | // The second is for running on ALIEN | |
22 | // All DDLs are analyzed, the argument nDDL selects the DDL to be plotted | |
23 | // Origin: F. Prino (prino@to.infn.it) | |
24 | ||
25 | ||
b255f56d | 26 | void AnalyzeSDDGainAllMod(Char_t *datafil, Int_t adcfreq=20, Int_t nDDL=0, Int_t firstEv=10, Int_t lastEv=16, Float_t pascalDAC=100){ |
91282711 | 27 | |
91282711 | 28 | const Int_t kTotDDL=24; |
29 | const Int_t kModPerDDL=12; | |
30 | const Int_t kSides=2; | |
31 | ||
32 | ||
33 | TH2F** histo = new TH2F*[kTotDDL*kModPerDDL*kSides]; | |
34 | AliITSOnlineSDDTP **anal=new AliITSOnlineSDDTP*[kTotDDL*kModPerDDL*kSides]; | |
35 | Bool_t isFilled[kTotDDL*kModPerDDL*kSides]; | |
36 | ||
37 | Char_t hisnam[20]; | |
38 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
39 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
40 | for(Int_t isid=0;isid<kSides;isid++){ | |
41 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
42 | anal[index]=new AliITSOnlineSDDTP(iddl,imod,isid,pascalDAC); | |
b255f56d | 43 | if(adcfreq==40) anal[index]->SetLastGoodTB(254); |
44 | else anal[index]->SetLastGoodTB(126); | |
91282711 | 45 | sprintf(hisnam,"h%02dc%02ds%d",iddl,imod,isid); |
46 | histo[index]=new TH2F(hisnam,"",256,-0.5,255.5,256,-0.5,255.5); | |
47 | isFilled[index]=0; | |
48 | } | |
49 | } | |
50 | } | |
51 | ||
52 | TCanvas* c0 = new TCanvas("c0","Ev Display",900,900); | |
53 | gStyle->SetPalette(1); | |
54 | Char_t text[50]; | |
55 | ||
56 | Int_t iev=firstEv; | |
57 | AliRawReader *rd; | |
58 | if(strstr(datafil,".root")!=0){ | |
59 | rd=new AliRawReaderRoot(datafil,iev); | |
60 | }else{ | |
61 | rd=new AliRawReaderDate(datafil,iev); | |
62 | } | |
63 | TLatex *t0=new TLatex(); | |
64 | t0->SetNDC(); | |
65 | t0->SetTextSize(0.06); | |
66 | t0->SetTextColor(4); | |
67 | ||
68 | do{ | |
69 | c0->Clear(); | |
70 | c0->Divide(4,6,0.001,0.001); | |
71 | printf("Event # %d\n",iev); | |
91282711 | 72 | rd->Reset(); |
73 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
74 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
75 | for(Int_t isid=0;isid<kSides;isid++){ | |
76 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
77 | histo[index]->Reset(); | |
78 | } | |
79 | } | |
80 | } | |
81 | AliITSRawStreamSDD s(rd); | |
91282711 | 82 | while(s.Next()){ |
83 | Int_t iDDL=rd->GetDDLID(); | |
84 | Int_t iCarlos=s.GetCarlosId(); | |
de075dae | 85 | if(s.IsCompletedModule()) continue; |
86 | if(s.IsCompletedDDL()) continue; | |
87 | if(iDDL>=0 && iDDL<kTotDDL){ | |
91282711 | 88 | Int_t index=kSides*(kModPerDDL*iDDL+iCarlos)+s.GetChannel(); |
89 | histo[index]->Fill(s.GetCoord2(),s.GetCoord1(),s.GetSignal()); | |
90 | isFilled[index]=1; | |
91 | } | |
92 | } | |
93 | iev++; | |
94 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
95 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
96 | for(Int_t isid=0;isid<kSides;isid++){ | |
97 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
98 | anal[index]->AddEvent(histo[index]); | |
99 | if(iddl==nDDL){ | |
100 | Int_t index2=kSides*imod+isid; | |
101 | c0->cd(index2+1); | |
102 | histo[index]->DrawCopy("colz"); | |
103 | sprintf(text,"DDL %d channel %d Side %d",nDDL,imod,isid); | |
104 | t0->DrawLatex(0.15,0.92,text); | |
105 | c0->Update(); | |
106 | } | |
107 | } | |
108 | } | |
109 | } | |
110 | printf(" --- OK\n"); | |
111 | }while(rd->NextEvent()&&iev<=lastEv); | |
112 | ||
de075dae | 113 | TH1F *htotgain=new TH1F("htotgain","",100,0.2,4.2); |
91282711 | 114 | TH1F *htotpeakpos=new TH1F("htotpeakpos","",256,-0.5,255.5); |
115 | TH1F *hstatus=new TH1F("hstatus","",2,-0.5,1.5); | |
116 | ||
117 | TFile *outfil=new TFile("SDDgain-results.root","recreate"); | |
118 | for(Int_t iddl=0; iddl<kTotDDL;iddl++){ | |
119 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
120 | for(Int_t isid=0;isid<kSides;isid++){ | |
121 | Int_t index=kSides*(kModPerDDL*iddl+imod)+isid; | |
122 | if(isFilled[index]){ | |
123 | anal[index]->ValidateAnodes(); | |
124 | anal[index]->WriteToASCII(); | |
125 | anal[index]->WriteToROOT(outfil); | |
126 | for(Int_t ian=0; ian<256;ian++){ | |
127 | Float_t gain=anal[index]->GetChannelGain(ian); | |
128 | Float_t ppos=anal[index]->GetTimeBinTPPeak(ian); | |
129 | Int_t anstatus=anal[index]->IsAnodeGood(ian); | |
130 | hstatus->Fill(anstatus); | |
131 | htotgain->Fill(gain); | |
132 | htotpeakpos->Fill(ppos); | |
133 | } | |
134 | } | |
135 | } | |
136 | } | |
137 | } | |
138 | outfil->Close(); | |
139 | ||
140 | // Draw Statistics of baselines and noise | |
141 | TCanvas *call=new TCanvas("call","General stats",700,700); | |
142 | call->Divide(2,2); | |
143 | call->cd(1); | |
144 | htotpeakpos->Draw(); | |
145 | htotpeakpos->GetXaxis()->SetTitle("TP peak position (Time Bin)"); | |
146 | htotpeakpos->GetXaxis()->SetTitleSize(0.07); | |
147 | htotpeakpos->GetXaxis()->SetTitleOffset(0.6); | |
148 | call->cd(2); | |
149 | htotgain->Draw(); | |
150 | htotgain->GetXaxis()->SetTitle("Gain (ADC/DAC)"); | |
151 | htotgain->GetXaxis()->SetTitleSize(0.07); | |
152 | htotgain->GetXaxis()->SetTitleOffset(0.6); | |
153 | call->cd(3); | |
154 | hstatus->Draw(); | |
155 | hstatus->GetXaxis()->SetTitle("Anode Status (0=bad 1=good)"); | |
156 | hstatus->GetXaxis()->SetTitleSize(0.07); | |
157 | hstatus->GetXaxis()->SetTitleOffset(0.6); | |
158 | call->Update(); | |
159 | call->SaveAs("GenStatsPulser.gif"); | |
160 | ||
161 | // Draw baselines and noisegain and TestPulse time bin for all modules | |
162 | ||
163 | TH1F** hgain = new TH1F*[kModPerDDL*kSides]; | |
164 | TH1F** htptb = new TH1F*[kModPerDDL*kSides]; | |
165 | ||
166 | TCanvas *c1=new TCanvas("c1","DDL: TP position",900,900); | |
167 | c1->SetBottomMargin(0.14); | |
168 | c1->Divide(4,6,0.001,0.001); | |
169 | TCanvas *c2=new TCanvas("c2","DDL: gain",900,900); | |
170 | c2->SetBottomMargin(0.14); | |
171 | c2->Divide(4,6,0.001,0.001); | |
172 | ||
173 | for(Int_t imod=0; imod<kModPerDDL;imod++){ | |
174 | for(Int_t isid=0;isid<kSides;isid++){ | |
175 | Int_t index1=kSides*(kModPerDDL*nDDL+imod)+isid; | |
176 | Int_t index2=kSides*imod+isid; | |
177 | sprintf(text,"DDL %d channel %d Side %d",nDDL,imod,isid); | |
178 | ||
179 | TLatex *t3=new TLatex(0.15,0.92,text); | |
180 | t3->SetNDC(); | |
181 | t3->SetTextSize(0.06); | |
182 | t3->SetTextColor(4); | |
183 | sprintf(hisnam,"hgain%ds%d",imod,isid); | |
184 | hgain[index2]=new TH1F(hisnam,"",256,-0.5,255.5); | |
185 | sprintf(hisnam,"htptb%ds%d",imod,isid); | |
186 | htptb[index2]=new TH1F(hisnam,"",256,-0.5,255.5); | |
187 | for(Int_t ian=0;ian<256;ian++){ | |
188 | hgain[index2]->SetBinContent(ian+1,anal[index1]->GetChannelGain(ian)); | |
189 | htptb[index2]->SetBinContent(ian+1,anal[index1]->GetTimeBinTPPeak(ian)); | |
190 | } | |
191 | ||
192 | c1->cd(index2+1); | |
193 | htptb[index2]->Draw(); | |
194 | // htptb[imod]->SetMinimum(0); | |
195 | // htptb[imod]->SetMaximum(75); | |
196 | htptb[index2]->GetXaxis()->SetTitle("Anode"); | |
197 | htptb[index2]->GetYaxis()->SetTitle("TP position (Time Bin)"); | |
198 | htptb[index2]->GetXaxis()->SetTitleSize(0.07); | |
199 | htptb[index2]->GetYaxis()->SetTitleSize(0.07); | |
200 | htptb[index2]->GetXaxis()->SetTitleOffset(0.6); | |
201 | htptb[index2]->GetYaxis()->SetTitleOffset(0.7); | |
202 | t3->Draw(); | |
203 | c1->Update(); | |
204 | ||
205 | ||
206 | c2->cd(index2+1); | |
207 | hgain[index2]->SetMinimum(0.); | |
208 | hgain[index2]->SetMaximum(4.); | |
209 | hgain[index2]->Draw(); | |
210 | hgain[index2]->GetXaxis()->SetTitle("Anode"); | |
211 | hgain[index2]->GetYaxis()->SetTitle("Gain"); | |
212 | hgain[index2]->GetXaxis()->SetTitleSize(0.07); | |
213 | hgain[index2]->GetYaxis()->SetTitleSize(0.07); | |
214 | hgain[index2]->GetXaxis()->SetTitleOffset(0.6); | |
215 | hgain[index2]->GetYaxis()->SetTitleOffset(0.7); | |
216 | hgain[index2]->SetStats(0); | |
217 | t3->Draw(); | |
218 | c2->Update(); | |
219 | } | |
220 | } | |
221 | ||
222 | c1->SaveAs("TPtimebin.gif"); | |
223 | c2->SaveAs("Gain.gif"); | |
224 | ||
225 | } | |
226 | ||
b255f56d | 227 | void AnalyzeSDDGainAllMod(Int_t nrun, Int_t n2, Char_t* dir="LHC08d_SDD",Int_t adcfreq=20, Int_t nDDL=0, Int_t firstEv=15, Int_t lastEv=20, Float_t pascalDAC=100){ |
91282711 | 228 | TGrid::Connect("alien:",0,0,"t"); |
229 | Char_t filnam[200]; | |
a7996467 | 230 | sprintf(filnam,"alien:///alice/data/2008/%s/%09d/raw/08%09d%03d.10.root",dir,nrun,nrun,n2); |
91282711 | 231 | printf("Open file %s\n",filnam); |
b255f56d | 232 | AnalyzeSDDGainAllMod(filnam,adcfreq,nDDL,firstEv,lastEv,pascalDAC); |
91282711 | 233 | } |