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