]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: */ | |
17 | ||
18 | //____________________________________________________________________ | |
19 | // | |
20 | // T0 - T0. | |
21 | // | |
22 | // This class privides GIU service for reading RAW data from Laser | |
23 | // during electronics test | |
24 | // | |
25 | #include "TH1F.h" | |
26 | #include "TH2F.h" | |
27 | #include "TMap.h" | |
28 | #include "TFile.h" | |
29 | #include "TTree.h" | |
30 | #include "TBranch.h" | |
31 | #include "AliT0RawReader.h" | |
32 | #include "TGLabel.h" | |
33 | //#include <iostream.h> | |
34 | ||
35 | #include "AliT0CalibLaserData.h" | |
36 | ||
37 | #include "AliCDBManager.h" | |
38 | #include "AliRawReader.h" | |
39 | #include "AliRawReaderRoot.h" | |
40 | #include "AliT0LookUpValue.h" | |
41 | #include "AliT0LookUpKey.h" | |
42 | #include "AliT0Parameters.h" | |
43 | #include "AliT0RawReader.h" | |
44 | ||
45 | ClassImp(AliT0CalibLaserData) | |
46 | ||
47 | AliT0CalibLaserData::AliT0CalibLaserData() : TObject(), | |
48 | fRunNumber(905) | |
49 | { | |
50 | // | |
51 | } | |
52 | /* | |
53 | //________________________________________________________________ | |
54 | ||
55 | AliT0CalibLaserData::AliT0CalibLaserData(const AliT0CalibLaserData& calibda) : TObject(), | |
56 | fRunNumber(905) | |
57 | { | |
58 | //copy constructor | |
59 | ||
60 | } | |
61 | //________________________________________________________________ | |
62 | ||
63 | AliT0CalibLaserData &AliT0CalibLaserData::operator =(const AliT0CalibLaserData& calibda) | |
64 | { | |
65 | // assignment operator | |
66 | ||
67 | return *this; | |
68 | } | |
69 | //________________________________________________________________ | |
70 | AliT0CalibLaserData::~AliT0CalibLaserData() | |
71 | { | |
72 | // | |
73 | } | |
74 | */ | |
75 | //________________________________________________________________ | |
76 | ||
77 | void AliT0CalibLaserData::ReadHistSize(Int_t rNumber) | |
78 | { | |
79 | //build GUI frame for reading: | |
80 | // - run number | |
81 | // - histograms rates | |
82 | ||
83 | fRunNumber = rNumber; | |
84 | ||
85 | TGMainFrame* fMain = new TGMainFrame(0,1500,1500); | |
86 | fMain->SetLayoutManager( new TGMatrixLayout(fMain,7,7) ); | |
87 | ||
88 | fMain->AddFrame( new TGLabel(fMain, " Histogram") ); | |
89 | fMain->AddFrame( new TGLabel(fMain, "X min") ); | |
90 | fMain->AddFrame( new TGLabel(fMain, "X max") ); | |
91 | fMain->AddFrame( new TGLabel(fMain, "X N# channels") ); | |
92 | ||
93 | fMain->AddFrame( new TGLabel(fMain, "Y min") ); | |
94 | fMain->AddFrame( new TGLabel(fMain, "Y max") ); | |
95 | fMain->AddFrame( new TGLabel(fMain, "Y N# channels") ); | |
96 | ||
97 | fMain->AddFrame( new TGLabel(fMain, "QTC" ) ); | |
98 | fEntries[0] = new TGNumberEntry(fMain, 0); | |
99 | fMain->AddFrame(fEntries[0]); | |
100 | fEntries[1] = new TGNumberEntry(fMain, 10000); | |
101 | fMain->AddFrame(fEntries[1]); | |
102 | fEntries[2] = new TGNumberEntry(fMain, 10000); | |
103 | fMain->AddFrame(fEntries[2]); | |
104 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
105 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
106 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
107 | ||
108 | fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) ); | |
109 | fEntries[3] = new TGNumberEntry(fMain, 0); | |
110 | fMain->AddFrame(fEntries[3]); | |
111 | fEntries[4] = new TGNumberEntry(fMain, 10000); | |
112 | fMain->AddFrame(fEntries[4]); | |
113 | fEntries[5] = new TGNumberEntry(fMain, 10000); | |
114 | fMain->AddFrame(fEntries[5]); | |
115 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
116 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
117 | fMain->AddFrame( new TGLabel(fMain, " ") ); | |
118 | fMain->AddFrame( new TGLabel(fMain, "CFD vs QTC " ) ); | |
119 | // QTC axis X | |
120 | fEntries[6] = new TGNumberEntry(fMain, 1000.); | |
121 | fMain->AddFrame(fEntries[6]); | |
122 | fEntries[7] = new TGNumberEntry(fMain, 8000.5); | |
123 | fMain->AddFrame(fEntries[7]); | |
124 | fEntries[8] = new TGNumberEntry(fMain, 700); | |
125 | fMain->AddFrame(fEntries[8]); | |
126 | // CFD axis Y | |
127 | fEntries[9] = new TGNumberEntry(fMain, 12000.5); | |
128 | fMain->AddFrame(fEntries[9]); | |
129 | fEntries[10] = new TGNumberEntry(fMain, 18000.5); | |
130 | fMain->AddFrame(fEntries[10]); | |
131 | fEntries[11] = new TGNumberEntry(fMain, 2000); | |
132 | fMain->AddFrame(fEntries[11]); | |
133 | // | |
134 | fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) ); | |
135 | //LED-CFD axis X | |
136 | fEntries[12] = new TGNumberEntry(fMain, 0); | |
137 | fMain->AddFrame(fEntries[12]); | |
138 | fEntries[13] = new TGNumberEntry(fMain, 500); | |
139 | fMain->AddFrame(fEntries[13]); | |
140 | fEntries[14] = new TGNumberEntry(fMain, 500); | |
141 | fMain->AddFrame(fEntries[14]); | |
142 | // CFD axis Y | |
143 | fEntries[15] = new TGNumberEntry(fMain, 14600); | |
144 | fMain->AddFrame(fEntries[15]); | |
145 | fEntries[16] = new TGNumberEntry(fMain, 14700); | |
146 | fMain->AddFrame(fEntries[16]); | |
147 | fEntries[17] = new TGNumberEntry(fMain, 100); | |
148 | fMain->AddFrame(fEntries[17]); | |
149 | ||
150 | fMain->AddFrame( new TGLabel(fMain, " Number of run") ); | |
151 | fEntries[18] = new TGNumberEntry(fMain, 905); | |
152 | fMain->AddFrame(fEntries[18]); | |
153 | ||
154 | for ( int i=0; i<19; i++ ) fEntries[i]->SetWidth(70); | |
155 | // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() ); | |
156 | ||
157 | TGTextButton *fOk = new TGTextButton(fMain, "OK"); | |
158 | fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()"); | |
159 | // fOk->SetCommand(".q"); | |
160 | fMain->AddFrame(fOk); | |
161 | ||
162 | fMain->MapSubwindows(); | |
163 | fMain->Resize(); | |
164 | fMain->SetWindowName("Dialog"); | |
165 | fMain->MapWindow(); | |
166 | } | |
167 | ||
168 | void AliT0CalibLaserData::DoOk() | |
169 | { | |
170 | ||
171 | // delete fMain; | |
172 | fRunNumber = Int_t (fEntries[18]->GetNumber()); | |
173 | printf(" RUN NUMBER %i\n",fRunNumber); | |
174 | for( int i=0; i<18; i++ ) | |
175 | fHistLimits[i] = fEntries[i]->GetNumber(); | |
176 | ||
177 | ReadData(); | |
178 | } | |
179 | ||
180 | void AliT0CalibLaserData::ReadData() | |
181 | { | |
182 | // reading RAW data from test LCS | |
183 | // filling histograms | |
184 | // fillinf tree | |
185 | ||
186 | ||
187 | TH1F *hChannel[105]; TH1F *hQTC[12]; | |
188 | TH2F *hCFDvsQTC[12]; TH2F *hCFDvsLED[12]; TH1F *h1CFDminLED[12]; | |
189 | TH1F *hmpd[12]; | |
190 | Int_t allData[110][5]; | |
191 | Int_t numberOfHits[105]; | |
192 | ||
193 | Char_t buf1[20], buf2[20], buf3[20], buf4[20], buf7[20]; | |
194 | ||
195 | TTree* digitsTree = new TTree("testData","Tree of test data Digits"); | |
196 | TBranch *b[106]; | |
197 | ||
198 | Int_t channels[106]; | |
199 | ||
200 | TString names[106], type; | |
201 | AliT0LookUpKey* lookkey= new AliT0LookUpKey(); | |
202 | AliT0LookUpValue* lookvalue= new AliT0LookUpValue(); | |
203 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
204 | AliCDBManager::Instance()->SetRun(0); | |
205 | AliT0Parameters *fParam = AliT0Parameters::Instance(); | |
206 | fParam->Init(); | |
207 | TMap *lookup = fParam->GetMapLookup(); | |
208 | TMapIter *iter = new TMapIter(lookup); | |
209 | ||
210 | for( Int_t iline=0; iline<106; iline++) | |
211 | { | |
212 | lookvalue = ( AliT0LookUpValue*) iter->Next(); | |
213 | lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue); | |
214 | if(lookkey){ | |
215 | Int_t key=lookkey->GetKey(); | |
216 | names[key]=lookkey->GetChannelName(); | |
217 | hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),30000,0,30000); | |
218 | // hitsname="xHits" + names[key]; | |
219 | // hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25); | |
220 | type =names[key] + "/I"; | |
221 | b[key]=digitsTree->Branch(names[key].Data(),&channels[key], type); | |
222 | } | |
223 | else | |
224 | {printf(" no such value %i \n", iline);} | |
225 | ||
226 | } | |
227 | for(Int_t ic=0; ic<12; ic++) { | |
228 | { | |
229 | sprintf(buf1,"QTC%i",ic+1); | |
230 | sprintf(buf2,"CFDvsQTC%i",ic+1); | |
231 | sprintf(buf3,"CFDvsLED%i",ic+1); | |
232 | sprintf(buf4,"LEDminCFD%i",ic+1); | |
233 | sprintf(buf7,"mpd%i",ic+1); | |
234 | ||
235 | hQTC[ic] = new TH1F(buf1,"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]); | |
236 | h1CFDminLED[ic] = new TH1F(buf4,"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]); | |
237 | ||
238 | hmpd[ic] = new TH1F(buf7,"mpd",20000,-10000.0,10000.0); | |
239 | hCFDvsQTC[ic] = new TH2F(buf2,"CFD vs QTC", | |
240 | (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7], | |
241 | (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]); | |
242 | hCFDvsLED[ic] = new TH2F(buf3,"CFD vs LED-CFD", | |
243 | (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13], | |
244 | (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]); | |
245 | ||
246 | ||
247 | } | |
248 | ||
249 | ||
250 | } | |
251 | ||
252 | TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25); | |
253 | TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25); | |
254 | TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25); | |
255 | TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25); | |
256 | ||
257 | ||
258 | Char_t filename[13]; | |
259 | sprintf(filename,"t0%i.raw",fRunNumber); | |
260 | AliRawReader *reader = new AliRawReaderRoot(filename); | |
261 | // // AliRawReader *reader = new AliRawReaderFile(); | |
262 | // AliRawReader *reader = new AliRawReaderFile(); | |
263 | reader->LoadEquipmentIdsMap("T0map.txt"); | |
264 | // reader->RequireHeader(kFALSE); | |
265 | reader->RequireHeader(kTRUE); | |
266 | AliT0RawReader *start = new AliT0RawReader(reader); | |
267 | // start->SetNumberOfTRM(1); | |
268 | for (Int_t i0=0; i0<105; i0++) | |
269 | { | |
270 | for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0; | |
271 | numberOfHits[i0]=0; | |
272 | } | |
273 | Int_t event=0; | |
274 | ||
275 | while (reader->NextEvent()) { | |
276 | start->Next(); | |
277 | for (Int_t i=0; i<105; i++) { | |
278 | for (Int_t iHit=0; iHit<5; iHit++) | |
279 | { | |
280 | allData[i][iHit]= start->GetData(i,iHit); | |
281 | } | |
282 | } | |
283 | ||
284 | if(event%1000 == 0) printf("Event:%d\n",event); | |
285 | ||
286 | // if(event > 200000) break; | |
287 | ||
288 | for (Int_t it = 0; it<24; it=it+2) | |
289 | { | |
290 | for (Int_t iHit=0; iHit<5; iHit++) | |
291 | { | |
292 | if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0) | |
293 | { | |
294 | Int_t cc=it/2; | |
295 | hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]); | |
296 | hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]); | |
297 | if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]); | |
298 | if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 ) | |
299 | { | |
300 | hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]); | |
301 | h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]); | |
302 | } | |
303 | } | |
304 | } | |
305 | } | |
306 | ||
307 | for (Int_t iHit=0; iHit<5; iHit++) | |
308 | { | |
309 | ||
310 | for(Int_t ik=1; ik<105; ik++) | |
311 | { | |
312 | channels[ik] = -100; | |
313 | if((allData[ik][iHit] - allData[0][0]) > 0 ) | |
314 | { | |
315 | numberOfHits[ik]++; | |
316 | hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]); | |
317 | channels[ik] = allData[ik][iHit] - allData[0][0]; | |
318 | } | |
319 | } | |
320 | digitsTree->Fill(); | |
321 | } | |
322 | ||
323 | event++; | |
324 | ||
325 | } //event | |
326 | ||
327 | ||
328 | if (event>1) | |
329 | { | |
330 | printf("efficiency for %i events \n",event); | |
331 | for (Int_t i0=1; i0<13; i0++) | |
332 | { | |
333 | printf("%s %f %s %f %s %f %s %f \n", | |
334 | names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event), | |
335 | names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event), | |
336 | names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event), | |
337 | names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event)); | |
338 | ||
339 | hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event)); | |
340 | hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event)); | |
341 | hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event)); | |
342 | hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event)); | |
343 | } | |
344 | ||
345 | for (Int_t i0=0; i0<24; i0=i0+2) | |
346 | { | |
347 | hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event)); | |
348 | hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event)); | |
349 | hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) / Float_t(event)); | |
350 | hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) / Float_t(event)); | |
351 | ||
352 | printf("%s %f %s %f %s %f %s %f \n", | |
353 | names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event), | |
354 | names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event), | |
355 | names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event), | |
356 | names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event)); | |
357 | } | |
358 | } | |
359 | ||
360 | ||
361 | Char_t filehist[40]; | |
362 | sprintf(filehist,"t0tree%i.root",fRunNumber); | |
363 | // sprintf(filehist,"test.root",runNumber); | |
364 | TFile *hist = new TFile(filehist,"RECREATE"); | |
365 | hist->cd(); | |
366 | // digitsTree->Write("",TObject::kOverwrite); | |
367 | ||
368 | hEffCFD->Write(); | |
369 | hEffLED->Write(); | |
370 | hEffQT0->Write(); | |
371 | hEffQT1->Write(); | |
372 | ||
373 | for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write(); | |
374 | ||
375 | for (Int_t i=0; i<12; i++) | |
376 | { | |
377 | hQTC[i]->Write(); | |
378 | hmpd[i]->Write(); | |
379 | hCFDvsQTC[i]->Write(); | |
380 | hCFDvsLED[i]->Write(); | |
381 | h1CFDminLED[i]->Write(); | |
382 | } | |
383 | ||
384 | } |