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"
34 //#include <iostream.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,7,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, 10000);
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, 1000.);
123 fMain->AddFrame(fEntries[6]);
124 fEntries[7] = new TGNumberEntry(fMain, 8000.5);
125 fMain->AddFrame(fEntries[7]);
126 fEntries[8] = new TGNumberEntry(fMain, 700);
127 fMain->AddFrame(fEntries[8]);
129 fEntries[9] = new TGNumberEntry(fMain, 2000.5);
130 fMain->AddFrame(fEntries[9]);
131 fEntries[10] = new TGNumberEntry(fMain, 3000.5);
132 fMain->AddFrame(fEntries[10]);
133 fEntries[11] = new TGNumberEntry(fMain, 1000);
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, 500);
141 fMain->AddFrame(fEntries[13]);
142 fEntries[14] = new TGNumberEntry(fMain, 500);
143 fMain->AddFrame(fEntries[14]);
145 fEntries[15] = new TGNumberEntry(fMain, 2000);
146 fMain->AddFrame(fEntries[15]);
147 fEntries[16] = new TGNumberEntry(fMain, 3000);
148 fMain->AddFrame(fEntries[16]);
149 fEntries[17] = new TGNumberEntry(fMain, 1000);
150 fMain->AddFrame(fEntries[17]);
152 fMain->AddFrame( new TGLabel(fMain, " File name") );
153 fTEntry = new TGTextEntry(fMain,"");
154 fMain->AddFrame(fTEntry);
156 for ( int i=0; i<18; i++ ) fEntries[i]->SetWidth(70);
157 fTEntry->SetWidth(80);
158 // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
160 TGTextButton *fOk = new TGTextButton(fMain, "OK");
161 fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()");
162 // fOk->SetCommand(".q");
163 fMain->AddFrame(fOk);
165 fMain->MapSubwindows();
167 fMain->SetWindowName("Dialog");
171 void AliT0CalibLaserData::DoOk()
174 fFileName = (fTEntry->GetText());
176 printf(" DoOK >> File %s\n",fFileName);
177 for( int i=0; i<18; i++ )
178 fHistLimits[i] = fEntries[i]->GetNumber();
183 void AliT0CalibLaserData::ReadData()
185 // reading RAW data from test LCS
186 // filling histograms
190 TH1F *hChannel[105]; TH1F *hQTC[24];
191 TH2F *hCFDvsQTC[24]; TH2F *hCFDvsLED[24]; TH1F *h1CFDminLED[24];
193 Int_t allData[110][5];
194 Int_t numberOfHits[105];
196 Char_t buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
198 TTree* digitsTree = new TTree("testData","Tree of test data Digits");
203 TString names[106], type;
204 AliT0LookUpKey* lookkey= new AliT0LookUpKey();
205 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
206 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
207 AliCDBManager::Instance()->SetRun(0);
208 AliT0Parameters *fParam = AliT0Parameters::Instance();
210 TMap *lookup = fParam->GetMapLookup();
211 TMapIter *iter = new TMapIter(lookup);
213 for( Int_t iline=0; iline<106; iline++)
215 lookvalue = ( AliT0LookUpValue*) iter->Next();
216 lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
218 Int_t key=lookkey->GetKey();
219 names[key]=lookkey->GetChannelName();
220 if(names[key].Contains("QT0"))
221 hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,3000,5000);
223 hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),1000,2000,3000);
225 // hitsname="xHits" + names[key];
226 // hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
227 type =names[key] + "/I";
228 b[key]=digitsTree->Branch(names[key].Data(),&channels[key], type);
231 {printf(" no such value %i \n", iline);}
234 for(Int_t ic=0; ic<24; ic++) {
236 sprintf(buf1,"QTC%i",ic+1);
237 sprintf(buf2,"CFDvsQTC%i",ic+1);
238 sprintf(buf3,"CFDvsLED%i",ic+1);
239 sprintf(buf4,"LEDminCFD%i",ic+1);
240 sprintf(buf7,"mpd%i",ic+1);
242 hQTC[ic] = new TH1F(buf1,"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]);
243 h1CFDminLED[ic] = new TH1F(buf4,"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]);
245 hCFDvsQTC[ic] = new TH2F(buf2,"CFD vs QTC",
246 (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7],
247 (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]);
248 hCFDvsLED[ic] = new TH2F(buf3,"CFD vs LED-CFD",
249 (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13],
250 (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]);
258 TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25);
259 TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25);
260 TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25);
261 TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25);
264 // Char_t filename[80];
265 // sprintf(filename,"t0%i.raw",fRunNumber);
266 AliRawReader *reader = new AliRawReaderRoot(fFileName);
267 reader->LoadEquipmentIdsMap("T0map.txt");
268 // reader->RequireHeader(kFALSE);
269 reader->RequireHeader(kTRUE);
270 AliT0RawReader *start = new AliT0RawReader(reader);
271 // start->SetNumberOfTRM(1);
272 for (Int_t i0=0; i0<105; i0++)
274 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
279 while (reader->NextEvent()) {
281 for (Int_t i=0; i<105; i++) {
282 for (Int_t iHit=0; iHit<5; iHit++)
284 allData[i][iHit]= start->GetData(i,iHit);
288 // if(event%1000 == 0)
289 printf("Event:%d\n",event);
291 // if(event > 200000) break;
293 for (Int_t it = 0; it<24; it=it+2)
295 for (Int_t iHit=0; iHit<5; iHit++)
297 if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
300 hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
301 if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]);
302 if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 )
304 hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]);
305 h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
310 for (Int_t it = 24; it<48; it=it+2)
312 for (Int_t iHit=0; iHit<5; iHit++)
314 if(allData[it+57][iHit] != 0 && allData[it+58][iHit] !=0)
316 Int_t cc=(Int_t)(it/2.0);
317 hQTC[cc]->Fill(allData[it+57][iHit]-allData[it+58][iHit]);
318 // hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
319 if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+45][iHit]-allData[0][0]);
320 if(allData[cc+57][iHit] != 0 && allData[cc+45][iHit]!=0 )
322 hCFDvsLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit],allData[cc+1][iHit]-allData[0][0]);
323 h1CFDminLED[cc]->Fill(allData[cc+57][iHit]-allData[cc+45][iHit]);
330 for (Int_t iHit=0; iHit<5; iHit++)
333 for(Int_t ik=1; ik<105; ik++)
336 if((allData[ik][iHit] - allData[0][0]) > 0 )
339 hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]);
340 channels[ik] = allData[ik][iHit] - allData[0][0];
353 printf("efficiency for %i events \n",event);
354 for (Int_t i0=1; i0<13; i0++)
356 printf("%s %f %s %f %s %f %s %f \n",
357 names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
358 names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event),
359 names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event),
360 names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event));
362 hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event));
363 hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event));
364 hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event));
365 hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event));
368 for (Int_t i0=0; i0<24; i0=i0+2)
370 hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
371 hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
372 hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) / Float_t(event));
373 hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) / Float_t(event));
375 printf("%s %f %s %f %s %f %s %f \n",
376 names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
377 names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
378 names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
379 names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
385 sprintf(filehist,"t0tree%s",fFileName);
386 // sprintf(filehist,"test.root",runNumber);
387 TFile *hist = new TFile(filehist,"RECREATE");
389 // digitsTree->Write("",TObject::kOverwrite);
396 for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write();
398 for (Int_t i=0; i<24; i++)
401 hCFDvsQTC[i]->Write();
402 hCFDvsLED[i]->Write();
403 h1CFDminLED[i]->Write();
408 void AliT0CalibLaserData::OpenFile()
411 const char *ft[]={"T0 raw files","*.root","All files","*",0,0};
413 TGFileInfo fi; fi.fFileTypes=ft; fi.fIniDir=StrDup(dir);
414 new TGFileDialog(gClient->GetRoot(), 0x0, kFDOpen, &fi);
415 if(!fi.fFilename) return;
416 // fFileName =*( fi.fFilename);
417 fFileName = fi.fFilename;
418 printf(" AliT0CalibLaserData::OpenFile %s %s\n",fi.fFilename, fFileName );
419 // if(gFile){ gFile->Close(); gFile=0;}
421 // gFile=TFile::Open(fi.fFilename);