1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //____________________________________________________________________
22 // This class privides GIU service for reading RAW data from Laser
23 // during electronics test
31 #include "AliT0RawReader.h"
33 #include "TGFileDialog.h"
36 #include "AliT0CalibLaserData.h"
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"
46 ClassImp(AliT0CalibLaserData)
47 //const char *fFileName;
48 AliT0CalibLaserData::AliT0CalibLaserData() : TObject(),
56 //________________________________________________________________
58 AliT0CalibLaserData::AliT0CalibLaserData(const AliT0CalibLaserData& calibda) : TObject(),
64 //________________________________________________________________
66 AliT0CalibLaserData &AliT0CalibLaserData::operator =(const AliT0CalibLaserData& calibda)
68 // assignment operator
72 //________________________________________________________________
73 AliT0CalibLaserData::~AliT0CalibLaserData()
78 //________________________________________________________________
80 void AliT0CalibLaserData::ReadHistSize()
82 //build GUI frame for reading:
87 TGMainFrame* fMain = new TGMainFrame(0,1500,1500);
88 fMain->SetLayoutManager( new TGMatrixLayout(fMain,10,7) );
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") );
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") );
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]);
104 fEntries[2] = new TGNumberEntry(fMain, 2500);
105 fMain->AddFrame(fEntries[2]);
106 fMain->AddFrame( new TGLabel(fMain, " ") );
107 fMain->AddFrame( new TGLabel(fMain, " ") );
108 fMain->AddFrame( new TGLabel(fMain, " ") );
110 fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) );
111 fEntries[3] = new TGNumberEntry(fMain, 0);
112 fMain->AddFrame(fEntries[3]);
113 fEntries[4] = new TGNumberEntry(fMain, 1000);
114 fMain->AddFrame(fEntries[4]);
115 fEntries[5] = new TGNumberEntry(fMain, 1000);
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 " ) );
122 fEntries[6] = new TGNumberEntry(fMain, 0.);
123 fMain->AddFrame(fEntries[6]);
124 fEntries[7] = new TGNumberEntry(fMain, 8000);
125 fMain->AddFrame(fEntries[7]);
126 fEntries[8] = new TGNumberEntry(fMain, 800);
127 fMain->AddFrame(fEntries[8]);
129 fEntries[9] = new TGNumberEntry(fMain, 0);
130 fMain->AddFrame(fEntries[9]);
131 fEntries[10] = new TGNumberEntry(fMain, 5000);
132 fMain->AddFrame(fEntries[10]);
133 fEntries[11] = new TGNumberEntry(fMain, 5000);
134 fMain->AddFrame(fEntries[11]);
136 fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) );
138 fEntries[12] = new TGNumberEntry(fMain, 0);
139 fMain->AddFrame(fEntries[12]);
140 fEntries[13] = new TGNumberEntry(fMain, 1000);
141 fMain->AddFrame(fEntries[13]);
142 fEntries[14] = new TGNumberEntry(fMain, 1000);
143 fMain->AddFrame(fEntries[14]);
145 fEntries[15] = new TGNumberEntry(fMain, 1000);
146 fMain->AddFrame(fEntries[15]);
147 fEntries[16] = new TGNumberEntry(fMain, 5000);
148 fMain->AddFrame(fEntries[16]);
149 fEntries[17] = new TGNumberEntry(fMain, 4000);
150 fMain->AddFrame(fEntries[17]);
152 fMain->AddFrame( new TGLabel(fMain, "CFD 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]);
161 fMain->AddFrame( new TGLabel(fMain, "") );
162 fMain->AddFrame( new TGLabel(fMain, "") );
163 fMain->AddFrame( new TGLabel(fMain, "") );
165 fMain->AddFrame( new TGLabel(fMain, "CFD 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]);
174 fMain->AddFrame( new TGLabel(fMain, "") );
175 fMain->AddFrame( new TGLabel(fMain, "") );
176 fMain->AddFrame( new TGLabel(fMain, "") );
179 fMain->AddFrame( new TGLabel(fMain, "LED C " ) );
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]);
189 for ( int i=0; i<27; i++ ) fEntries[i]->SetWidth(70);
190 fMain->AddFrame( new TGLabel(fMain, " File name") );
191 fTEntry = new TGTextEntry(fMain,"");
192 fMain->AddFrame(fTEntry);
193 fTEntry->SetWidth(80);
194 // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
196 TGTextButton *fOk = new TGTextButton(fMain, "OK");
197 fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()");
198 // fOk->SetCommand(".q");
199 fMain->AddFrame(fOk);
201 fMain->MapSubwindows();
203 fMain->SetWindowName("Dialog");
207 void AliT0CalibLaserData::DoOk()
210 fFileName = (fTEntry->GetText());
212 printf(" DoOK >> File %s\n",fFileName);
213 for( int i=0; i<27; i++ )
214 fHistLimits[i] = fEntries[i]->GetNumber();
219 void AliT0CalibLaserData::ReadData()
221 // reading RAW data from test LCS
222 // filling histograms
226 TH1I *hChannel[105]; TH1I *hQTC[24];
227 TH2F *hCFDvsQTC[24]; TH2F *hCFDvsLED[24]; TH1I *h1CFDminLED[24];
229 Int_t allData[110][50];
230 Int_t numberOfHits[105];
232 Char_t buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
236 TString names[106], type;
237 AliT0LookUpKey* lookkey= new AliT0LookUpKey();
238 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
239 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
240 AliCDBManager::Instance()->SetRun(0);
241 AliT0Parameters *fParam = AliT0Parameters::Instance();
243 TMap *lookup = fParam->GetMapLookup();
244 TMapIter *iter = new TMapIter(lookup);
246 for( Int_t iline=0; iline<106; iline++)
248 lookvalue = ( AliT0LookUpValue*) iter->Next();
249 lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
251 Int_t key=lookkey->GetKey();
252 names[key]=lookkey->GetChannelName();
253 // if(names[key].Contains("QT0"))
254 // hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,3000,5000);
256 hChannel[key] = new TH1I(names[key].Data(),names[key].Data(),Int_t(fHistLimits[20]),fHistLimits[18],fHistLimits[19]);
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]);
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]);
264 // hitsname="xHits" + names[key];
265 // hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
268 {printf(" no such value %i \n", iline);}
271 for(Int_t ic=0; ic<24; ic++) {
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);
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]);
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]);
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);
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++)
311 for (Int_t j0=0; j0<50; j0++) allData[i0][j0]=0;
316 while (reader->NextEvent()) {
318 for (Int_t i=0; i<105; i++) {
319 for (Int_t iHit=0; iHit<50; iHit++)
321 allData[i][iHit]= start->GetData(i,iHit);
322 // if( allData[i][iHit]>0) cout<<i<<" "<<iHit<<" "<<allData[i][iHit]<<endl;
327 printf("Event:%d\n",event);
329 // if(event > 100000) break;
331 for (Int_t it = 0; it<24; it=it+2)
334 for (Int_t iHit=0; iHit<5; iHit++)
336 if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
338 hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
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.);
343 if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 )
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]);
352 for (Int_t it = 24; it<48; it=it+2)
354 Int_t cc=(Int_t)(it/2);
355 for (Int_t iHit=0; iHit<5; iHit++)
357 if(allData[it+57][iHit] != 0 && allData[it+58][iHit] !=0)
359 hQTC[cc]->Fill(allData[it+57][iHit]-allData[it+58][iHit]);
360 // hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
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);
365 if(allData[cc+57][iHit] != 0 && allData[cc+45][iHit]!=0 )
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]);
376 for (Int_t iHit=0; iHit<5; iHit++)
379 for(Int_t ik=1; ik<105; ik++)
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 )
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];
394 // digitsTree->Fill();
404 printf("efficiency for %i events \n",event);
405 for (Int_t i0=1; i0<13; i0++)
407 printf("%s %f %s %f %s %f %s %f \n ",
408 names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
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));
413 hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event));
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));
419 for (Int_t i0=0; i0<24; i0=i0+2)
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));
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));
436 // sprintf(filehist,"t0treeDA%s",fFileName);
437 sprintf(filehist,"t0tree%s",fFileName);
438 printf("\n Wrote data in %s !!\n",filehist);
439 TFile *hist = new TFile(filehist,"RECREATE");
441 // digitsTree->Write("",TObject::kOverwrite);
448 for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write();
450 for (Int_t i=0; i<24; i++)
453 hCFDvsQTC[i]->Write();
454 hCFDvsLED[i]->Write();
455 h1CFDminLED[i]->Write();
460 void AliT0CalibLaserData::OpenFile()
463 const char *ft[]={"T0 raw files","*.root","All files","*",0,0};
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;}
473 // gFile=TFile::Open(fi.fFilename);