Line data Source code
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 "TGFileDialog.h"
34 : #include <iostream>
35 :
36 : #include "AliT0CalibLaserData.h"
37 :
38 : #include "AliCDBManager.h"
39 : #include "AliRawReader.h"
40 : #include "AliRawReaderRoot.h"
41 : #include "AliT0LookUpValue.h"
42 : #include "AliT0LookUpKey.h"
43 : #include "AliT0Parameters.h"
44 : #include "AliT0RawReader.h"
45 :
46 20 : ClassImp(AliT0CalibLaserData)
47 : //const char *fFileName;
48 0 : AliT0CalibLaserData::AliT0CalibLaserData() : TObject(),
49 0 : fTEntry(0),
50 0 : fFileName(" ")
51 :
52 0 : {
53 : //
54 0 : for ( int i=0; i<30; i++ ) { fEntries[i] = NULL; fHistLimits[i] = 0.0;}
55 0 : }
56 : /*
57 : //________________________________________________________________
58 :
59 : AliT0CalibLaserData::AliT0CalibLaserData(const AliT0CalibLaserData& calibda) : TObject(),
60 : fRunNumber(905)
61 : {
62 : //copy constructor
63 :
64 : }
65 : //________________________________________________________________
66 :
67 : AliT0CalibLaserData &AliT0CalibLaserData::operator =(const AliT0CalibLaserData& calibda)
68 : {
69 : // assignment operator
70 :
71 : return *this;
72 : }
73 : //________________________________________________________________
74 : AliT0CalibLaserData::~AliT0CalibLaserData()
75 : {
76 : //
77 : }
78 : */
79 : //________________________________________________________________
80 :
81 : void AliT0CalibLaserData::ReadHistSize()
82 : {
83 : //build GUI frame for reading:
84 : // - run number
85 : // - histograms rates
86 :
87 :
88 0 : TGMainFrame* fMain = new TGMainFrame(0,1500,1500);
89 0 : fMain->SetLayoutManager( new TGMatrixLayout(fMain,10,7) );
90 :
91 0 : fMain->AddFrame( new TGLabel(fMain, " Histogram") );
92 0 : fMain->AddFrame( new TGLabel(fMain, "X min") );
93 0 : fMain->AddFrame( new TGLabel(fMain, "X max") );
94 0 : fMain->AddFrame( new TGLabel(fMain, "X N# channels") );
95 :
96 0 : fMain->AddFrame( new TGLabel(fMain, "Y min") );
97 0 : fMain->AddFrame( new TGLabel(fMain, "Y max") );
98 0 : fMain->AddFrame( new TGLabel(fMain, "Y N# channels") );
99 :
100 0 : fMain->AddFrame( new TGLabel(fMain, "QTC" ) );
101 0 : fEntries[0] = new TGNumberEntry(fMain, 0);
102 0 : fMain->AddFrame(fEntries[0]);
103 0 : fEntries[1] = new TGNumberEntry(fMain, 10000);
104 0 : fMain->AddFrame(fEntries[1]);
105 0 : fEntries[2] = new TGNumberEntry(fMain, 2500);
106 0 : fMain->AddFrame(fEntries[2]);
107 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
108 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
109 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
110 :
111 0 : fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) );
112 0 : fEntries[3] = new TGNumberEntry(fMain, 0);
113 0 : fMain->AddFrame(fEntries[3]);
114 0 : fEntries[4] = new TGNumberEntry(fMain, 1000);
115 0 : fMain->AddFrame(fEntries[4]);
116 0 : fEntries[5] = new TGNumberEntry(fMain, 1000);
117 0 : fMain->AddFrame(fEntries[5]);
118 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
119 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
120 0 : fMain->AddFrame( new TGLabel(fMain, " ") );
121 0 : fMain->AddFrame( new TGLabel(fMain, "CFD vs QTC " ) );
122 : // QTC axis X
123 0 : fEntries[6] = new TGNumberEntry(fMain, 0.);
124 0 : fMain->AddFrame(fEntries[6]);
125 0 : fEntries[7] = new TGNumberEntry(fMain, 8000);
126 0 : fMain->AddFrame(fEntries[7]);
127 0 : fEntries[8] = new TGNumberEntry(fMain, 800);
128 0 : fMain->AddFrame(fEntries[8]);
129 : // CFD axis Y
130 0 : fEntries[9] = new TGNumberEntry(fMain, 0);
131 0 : fMain->AddFrame(fEntries[9]);
132 0 : fEntries[10] = new TGNumberEntry(fMain, 5000);
133 0 : fMain->AddFrame(fEntries[10]);
134 0 : fEntries[11] = new TGNumberEntry(fMain, 5000);
135 0 : fMain->AddFrame(fEntries[11]);
136 : //
137 0 : fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) );
138 : //LED-CFD axis X
139 0 : fEntries[12] = new TGNumberEntry(fMain, 0);
140 0 : fMain->AddFrame(fEntries[12]);
141 0 : fEntries[13] = new TGNumberEntry(fMain, 1000);
142 0 : fMain->AddFrame(fEntries[13]);
143 0 : fEntries[14] = new TGNumberEntry(fMain, 1000);
144 0 : fMain->AddFrame(fEntries[14]);
145 : // CFD axis Y
146 0 : fEntries[15] = new TGNumberEntry(fMain, 1000);
147 0 : fMain->AddFrame(fEntries[15]);
148 0 : fEntries[16] = new TGNumberEntry(fMain, 5000);
149 0 : fMain->AddFrame(fEntries[16]);
150 0 : fEntries[17] = new TGNumberEntry(fMain, 4000);
151 0 : fMain->AddFrame(fEntries[17]);
152 :
153 0 : fMain->AddFrame( new TGLabel(fMain, "CFD C " ) );
154 : //CFD side C
155 0 : fEntries[18] = new TGNumberEntry(fMain, 0);
156 0 : fMain->AddFrame(fEntries[18]);
157 0 : fEntries[19] = new TGNumberEntry(fMain, 5000);
158 0 : fMain->AddFrame(fEntries[19]);
159 0 : fEntries[20] = new TGNumberEntry(fMain, 5000);
160 0 : fMain->AddFrame(fEntries[20]);
161 :
162 0 : fMain->AddFrame( new TGLabel(fMain, "") );
163 0 : fMain->AddFrame( new TGLabel(fMain, "") );
164 0 : fMain->AddFrame( new TGLabel(fMain, "") );
165 :
166 0 : fMain->AddFrame( new TGLabel(fMain, "CFD A " ) );
167 : //CFD side A
168 0 : fEntries[21] = new TGNumberEntry(fMain,0);
169 0 : fMain->AddFrame(fEntries[21]);
170 0 : fEntries[22] = new TGNumberEntry(fMain, 5000);
171 0 : fMain->AddFrame(fEntries[22]);
172 0 : fEntries[23] = new TGNumberEntry(fMain, 5000);
173 0 : fMain->AddFrame(fEntries[23]);
174 :
175 0 : fMain->AddFrame( new TGLabel(fMain, "") );
176 0 : fMain->AddFrame( new TGLabel(fMain, "") );
177 0 : fMain->AddFrame( new TGLabel(fMain, "") );
178 :
179 :
180 0 : fMain->AddFrame( new TGLabel(fMain, "LED C " ) );
181 : //LED axis X
182 0 : fEntries[24] = new TGNumberEntry(fMain, 0);
183 0 : fMain->AddFrame(fEntries[24]);
184 0 : fEntries[25] = new TGNumberEntry(fMain, 5000);
185 0 : fMain->AddFrame(fEntries[25]);
186 0 : fEntries[26] = new TGNumberEntry(fMain, 5000);
187 0 : fMain->AddFrame(fEntries[26]);
188 :
189 :
190 0 : for ( int i=0; i<27; i++ ) fEntries[i]->SetWidth(70);
191 0 : fMain->AddFrame( new TGLabel(fMain, " File name") );
192 0 : fTEntry = new TGTextEntry(fMain,"");
193 0 : fMain->AddFrame(fTEntry);
194 0 : fTEntry->SetWidth(80);
195 : // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
196 :
197 0 : TGTextButton *fOk = new TGTextButton(fMain, "OK");
198 0 : fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()");
199 : // fOk->SetCommand(".q");
200 0 : fMain->AddFrame(fOk);
201 :
202 0 : fMain->MapSubwindows();
203 0 : fMain->Resize();
204 0 : fMain->SetWindowName("Dialog");
205 0 : fMain->MapWindow();
206 0 : }
207 :
208 : void AliT0CalibLaserData::DoOk()
209 : {
210 :
211 0 : fFileName = (fTEntry->GetText());
212 : //OpenFile();
213 0 : printf(" DoOK >> File %s\n",fFileName);
214 0 : for( int i=0; i<27; i++ )
215 0 : fHistLimits[i] = fEntries[i]->GetNumber();
216 :
217 0 : ReadData();
218 0 : }
219 :
220 : void AliT0CalibLaserData::ReadData()
221 : {
222 : // reading RAW data from test LCS
223 : // filling histograms
224 : // fillinf tree
225 :
226 :
227 0 : TH1I *hChannel[105]; TH1I *hQTC[24];
228 0 : TH2F *hCFDvsQTC[24]; TH2F *hCFDvsLED[24]; TH1I *h1CFDminLED[24];
229 :
230 0 : Int_t allData[110][50];
231 0 : Int_t numberOfHits[105];
232 :
233 0 : Int_t channels[106];
234 :
235 0 : TString names[106], type;
236 : AliT0LookUpKey* lookkey;//= new AliT0LookUpKey();
237 : AliT0LookUpValue* lookvalue;//= new AliT0LookUpValue();
238 0 : AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
239 0 : AliCDBManager::Instance()->SetRun(0);
240 0 : AliT0Parameters *fParam = AliT0Parameters::Instance();
241 0 : fParam->Init();
242 0 : TMap *lookup = fParam->GetMapLookup();
243 0 : TMapIter *iter = new TMapIter(lookup);
244 :
245 0 : for( Int_t iline=0; iline<106; iline++)
246 : {
247 0 : lookvalue = ( AliT0LookUpValue*) iter->Next();
248 0 : lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
249 0 : if(lookkey){
250 0 : Int_t key=lookkey->GetKey();
251 0 : names[key]=lookkey->GetChannelName();
252 : // if(names[key].Contains("QT0"))
253 : // hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,3000,5000);
254 : // else
255 0 : hChannel[key] = new TH1I(names[key].Data(),names[key].Data(),Int_t(fHistLimits[20]),fHistLimits[18],fHistLimits[19]);
256 0 : if(key >0 && key<13)
257 0 : hChannel[key] = new TH1I(names[key].Data(),names[key].Data(),Int_t(fHistLimits[20]),fHistLimits[18],fHistLimits[19]);
258 0 : if(key >13 && key<25)
259 0 : hChannel[key] = new TH1I(names[key].Data(),names[key].Data(),Int_t(fHistLimits[26]),fHistLimits[24],fHistLimits[25]);
260 :
261 0 : if(key >57 && key<69)
262 0 : hChannel[key] = new TH1I(names[key].Data(),names[key].Data(),Int_t (fHistLimits[23]),fHistLimits[21],fHistLimits[22]);
263 : // hitsname="xHits" + names[key];
264 : // hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
265 0 : }
266 : else
267 0 : {printf(" no such value %i \n", iline);}
268 :
269 : }
270 0 : for(Int_t ic=0; ic<24; ic++) {
271 : {
272 :
273 0 : hQTC[ic] = new TH1I(Form("QTC%i",ic+1),"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]);
274 0 : h1CFDminLED[ic] = new TH1I(Form("LEDminCFD%i",ic+1),"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]);
275 :
276 0 : hCFDvsQTC[ic] = new TH2F(Form("CFDvsQTC%i",ic+1),"CFD vs QTC",
277 0 : (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7],
278 0 : (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]);
279 0 : hCFDvsLED[ic] = new TH2F(Form("CFDvsLED%i",ic+1),"CFD vs LED-CFD",
280 0 : (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13],
281 0 : (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]);
282 :
283 :
284 : }
285 :
286 :
287 : }
288 :
289 0 : TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25);
290 0 : TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25);
291 0 : TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25);
292 0 : TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25);
293 :
294 :
295 : // Char_t filename[80];
296 : // sprintf(filename,"t0%i.raw",fRunNumber);
297 0 : AliRawReader *reader = new AliRawReaderRoot(fFileName);
298 0 : reader->LoadEquipmentIdsMap("T0map.txt");
299 : // reader->RequireHeader(kFALSE);
300 0 : reader->RequireHeader(kTRUE);
301 0 : AliT0RawReader *start = new AliT0RawReader(reader);
302 : // start->SetNumberOfTRM(1);
303 0 : for (Int_t i0=0; i0<105; i0++)
304 : {
305 0 : for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
306 0 : numberOfHits[i0]=0;
307 : }
308 : Int_t event=0;
309 :
310 0 : while (reader->NextEvent()) {
311 0 : start->Next();
312 0 : for (Int_t i=0; i<105; i++) {
313 0 : for (Int_t iHit=0; iHit<5; iHit++)
314 : {
315 0 : allData[i][iHit]= start->GetData(i,iHit);
316 : // if( allData[i][iHit]>0) cout<<i<<" "<<iHit<<" "<<allData[i][iHit]<<endl;
317 : }
318 : }
319 :
320 0 : if(event%1000 == 0)
321 0 : printf("Event:%d\n",event);
322 :
323 : // if(event > 100000) break;
324 :
325 0 : for (Int_t it = 0; it<24; it=it+2)
326 : {
327 0 : Int_t cc=it/2;
328 0 : for (Int_t iHit=0; iHit<5; iHit++)
329 : {
330 0 : if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
331 : {
332 0 : hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
333 0 : if(allData[cc+1][iHit] != 0 )
334 0 : hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],
335 0 : allData[cc+1][iHit]-allData[0][0]+5000.);
336 : }
337 0 : if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 )
338 : {
339 0 : hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],
340 0 : allData[cc+1][iHit]-allData[0][0]+5000.);
341 0 : h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
342 : }
343 :
344 : }
345 : }
346 0 : for (Int_t it = 24; it<48; it=it+2)
347 : {
348 0 : Int_t cc=(Int_t)(it/2);
349 0 : for (Int_t iHit=0; iHit<5; iHit++)
350 : {
351 0 : if(allData[it+57][iHit] != 0 && allData[it+58][iHit] !=0)
352 : {
353 0 : hQTC[cc]->Fill(allData[it+57][iHit]-allData[it+58][iHit]);
354 : // hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
355 0 : if(allData[cc+1][iHit] != 0 )
356 0 : hCFDvsQTC[cc]->Fill(allData[it+57][iHit]-allData[it+58][iHit],
357 0 : allData[cc+45][iHit]-allData[0][0]+5000);
358 : }
359 0 : if(allData[cc+57][iHit] != 0 && allData[cc+45][iHit]!=0 )
360 : {
361 0 : hCFDvsLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit],
362 0 : allData[cc+1][iHit]-allData[0][0]+5000);
363 0 : h1CFDminLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit]);
364 : }
365 :
366 : }
367 : }
368 :
369 :
370 0 : for (Int_t iHit=0; iHit<5; iHit++)
371 : {
372 :
373 0 : for(Int_t ik=1; ik<105; ik++)
374 : {
375 0 : channels[ik] = -100;
376 0 : if((allData[ik][iHit] - allData[0][0] +5000) != 0 && //!!!!! Uncomment it !!!!! and comment next line
377 : // if((allData[ik][iHit] - allData[1][0] ) != 0 &&
378 0 : allData[ik][iHit] >0 )
379 : {
380 0 : numberOfHits[ik]++;
381 : // hChannel[ik] -> Fill(allData[ik][iHit] - allData[1][0]); //Comment this line !!!
382 0 : hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]+5000);
383 : // cout<<" zpis'>> "<<iHit<<" "<<ik<<" "<<allData[ik][iHit] - allData[0][0]<<endl;
384 : // hChannel[ik] -> Fill(allData[0][0]-allData[ik][iHit] );
385 : // channels[ik] = allData[ik][iHit] - allData[0][0];
386 : }
387 : }
388 : // digitsTree->Fill();
389 : }
390 :
391 0 : event++;
392 :
393 : } //event
394 :
395 :
396 0 : if (event>1)
397 : {
398 0 : printf("efficiency for %i events \n",event);
399 0 : for (Int_t i0=1; i0<13; i0++)
400 : {
401 0 : printf("%s %f %s %f %s %f %s %f \n ",
402 0 : names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
403 0 : names[i0+12].Data(),Float_t(numberOfHits[i0+12])/Float_t(event),
404 0 : names[i0+56].Data(),Float_t(numberOfHits[i0+56])/Float_t(event),
405 0 : names[i0+68].Data(),Float_t(numberOfHits[i0+68])/Float_t(event));
406 :
407 0 : hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event));
408 0 : hEffLED->Fill(i0,Float_t(numberOfHits[i0+12]) / Float_t(event));
409 0 : hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+56]) /Float_t(event));
410 0 : hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+68]) /Float_t(event));
411 : }
412 0 : printf("\n");
413 0 : for (Int_t i0=0; i0<24; i0=i0+2)
414 : {
415 0 : hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
416 0 : hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
417 0 : hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) / Float_t(event));
418 0 : hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) / Float_t(event));
419 :
420 0 : printf("%s %f %s %f %s %f %s %f \n",
421 0 : names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
422 0 : names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
423 0 : names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
424 0 : names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
425 : }
426 0 : }
427 :
428 :
429 0 : TString filehist = Form("t0tree%s",fFileName);;
430 : // sprintf(filehist,"t0treeDA%s",fFileName);
431 : // sprintf(filehist,"t0tree%s",fFileName);
432 0 : printf("\n Wrote data in %s !!\n",filehist.Data());
433 0 : TFile *hist = new TFile(filehist.Data(),"RECREATE");
434 0 : hist->cd();
435 : // digitsTree->Write("",TObject::kOverwrite);
436 :
437 0 : hEffCFD->Write();
438 0 : hEffLED->Write();
439 0 : hEffQT0->Write();
440 0 : hEffQT1->Write();
441 :
442 0 : for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write();
443 :
444 0 : for (Int_t i=0; i<24; i++)
445 : {
446 0 : hQTC[i]->Write();
447 0 : hCFDvsQTC[i]->Write();
448 0 : hCFDvsLED[i]->Write();
449 0 : h1CFDminLED[i]->Write();
450 : }
451 :
452 0 : }
453 :
454 : void AliT0CalibLaserData::OpenFile()
455 : {
456 :
457 0 : const char *ft[]={"T0 raw files","*.root","All files","*",0,0};
458 0 : TString dir(".");
459 0 : TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir);
460 0 : new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi);
461 0 : if(!fi.fFilename) return;
462 : // fFileName =*( fi.fFilename);
463 0 : fFileName = fi.fFilename;
464 0 : printf(" AliT0CalibLaserData::OpenFile %s %s\n",fi.fFilename, fFileName );
465 : // if(gFile){ gFile->Close(); gFile=0;}
466 :
467 : // gFile=TFile::Open(fi.fFilename);
468 :
469 0 : }
470 :
|