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