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"
35 #include "AliT0CalibLaserData.h"
37 #include "AliCDBManager.h"
38 #include "AliRawReader.h"
39 #include "AliRawReaderDate.h"
40 #include "AliT0LookUpValue.h"
41 #include "AliT0Parameters.h"
42 #include "AliT0RawReader.h"
44 ClassImp(AliT0CalibLaserData)
46 AliT0CalibLaserData::AliT0CalibLaserData() : TObject(),
52 //________________________________________________________________
54 AliT0CalibLaserData::AliT0CalibLaserData(const AliT0CalibLaserData& calibda) : TObject(),
60 //________________________________________________________________
62 AliT0CalibLaserData &AliT0CalibLaserData::operator =(const AliT0CalibLaserData& calibda)
64 // assignment operator
68 //________________________________________________________________
69 AliT0CalibLaserData::~AliT0CalibLaserData()
74 //________________________________________________________________
76 void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
78 //build GUI frame for reading:
84 TGMainFrame* fMain = new TGMainFrame(0,1500,1500);
85 fMain->SetLayoutManager( new TGMatrixLayout(fMain,7,7) );
87 fMain->AddFrame( new TGLabel(fMain, " Histogram") );
88 fMain->AddFrame( new TGLabel(fMain, "X min") );
89 fMain->AddFrame( new TGLabel(fMain, "X max") );
90 fMain->AddFrame( new TGLabel(fMain, "X N# channels") );
92 fMain->AddFrame( new TGLabel(fMain, "Y min") );
93 fMain->AddFrame( new TGLabel(fMain, "Y max") );
94 fMain->AddFrame( new TGLabel(fMain, "Y N# channels") );
96 fMain->AddFrame( new TGLabel(fMain, "QTC" ) );
97 fEntries[0] = new TGNumberEntry(fMain, 0);
98 fMain->AddFrame(fEntries[0]);
99 fEntries[1] = new TGNumberEntry(fMain, 10000);
100 fMain->AddFrame(fEntries[1]);
101 fEntries[2] = new TGNumberEntry(fMain, 10000);
102 fMain->AddFrame(fEntries[2]);
103 fMain->AddFrame( new TGLabel(fMain, " ") );
104 fMain->AddFrame( new TGLabel(fMain, " ") );
105 fMain->AddFrame( new TGLabel(fMain, " ") );
107 fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) );
108 fEntries[3] = new TGNumberEntry(fMain, 0);
109 fMain->AddFrame(fEntries[3]);
110 fEntries[4] = new TGNumberEntry(fMain, 10000);
111 fMain->AddFrame(fEntries[4]);
112 fEntries[5] = new TGNumberEntry(fMain, 10000);
113 fMain->AddFrame(fEntries[5]);
114 fMain->AddFrame( new TGLabel(fMain, " ") );
115 fMain->AddFrame( new TGLabel(fMain, " ") );
116 fMain->AddFrame( new TGLabel(fMain, " ") );
117 fMain->AddFrame( new TGLabel(fMain, "CFD vs QTC " ) );
119 fEntries[6] = new TGNumberEntry(fMain, 1000.);
120 fMain->AddFrame(fEntries[6]);
121 fEntries[7] = new TGNumberEntry(fMain, 8000.5);
122 fMain->AddFrame(fEntries[7]);
123 fEntries[8] = new TGNumberEntry(fMain, 700);
124 fMain->AddFrame(fEntries[8]);
126 fEntries[9] = new TGNumberEntry(fMain, 12000.5);
127 fMain->AddFrame(fEntries[9]);
128 fEntries[10] = new TGNumberEntry(fMain, 18000.5);
129 fMain->AddFrame(fEntries[10]);
130 fEntries[11] = new TGNumberEntry(fMain, 2000);
131 fMain->AddFrame(fEntries[11]);
133 fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) );
135 fEntries[12] = new TGNumberEntry(fMain, 0);
136 fMain->AddFrame(fEntries[12]);
137 fEntries[13] = new TGNumberEntry(fMain, 500);
138 fMain->AddFrame(fEntries[13]);
139 fEntries[14] = new TGNumberEntry(fMain, 500);
140 fMain->AddFrame(fEntries[14]);
142 fEntries[15] = new TGNumberEntry(fMain, 14600);
143 fMain->AddFrame(fEntries[15]);
144 fEntries[16] = new TGNumberEntry(fMain, 14700);
145 fMain->AddFrame(fEntries[16]);
146 fEntries[17] = new TGNumberEntry(fMain, 100);
147 fMain->AddFrame(fEntries[17]);
149 fMain->AddFrame( new TGLabel(fMain, " Number of run") );
150 fEntries[18] = new TGNumberEntry(fMain, 905);
151 fMain->AddFrame(fEntries[18]);
153 for ( int i=0; i<19; i++ ) fEntries[i]->SetWidth(70);
154 // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
156 TGTextButton *fOk = new TGTextButton(fMain, "OK");
157 fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()");
158 // fOk->SetCommand(".q");
159 fMain->AddFrame(fOk);
161 fMain->MapSubwindows();
163 fMain->SetWindowName("Dialog");
167 void AliT0CalibLaserData::DoOk()
171 fRunNumber = Int_t (fEntries[18]->GetNumber());
172 printf(" RUN NUMBER %i\n",fRunNumber);
173 for( int i=0; i<18; i++ )
174 fHistLimits[i] = fEntries[i]->GetNumber();
179 void AliT0CalibLaserData::ReadData()
181 // reading RAW data from test LCS
182 // filling histograms
186 TH1F *hChannel[105]; TH1F *hQTC[12];
187 TH2F *hCFDvsQTC[12]; TH2F *hCFDvsLED[12]; TH1F *h1CFDminLED[12];
189 Int_t allData[110][5];
190 Int_t numberOfHits[105];
192 Char_t buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
194 TTree* digitsTree = new TTree("testData","Tree of test data Digits");
199 TString names[106], type;
200 AliT0LookUpKey* lookkey= new AliT0LookUpKey();
201 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
202 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
203 AliCDBManager::Instance()->SetRun(0);
204 AliT0Parameters *fParam = AliT0Parameters::Instance();
206 TMap *lookup = fParam->GetMapLookup();
207 TMapIter *iter = new TMapIter(lookup);
209 for( Int_t iline=0; iline<106; iline++)
211 lookvalue = ( AliT0LookUpValue*) iter->Next();
212 lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
214 Int_t key=lookkey->GetKey();
215 names[key]=lookkey->GetChannelName();
216 // cout<<lookkey->GetKey()<<" "<<lookkey->GetChannelName()<<" trm "<<lookvalue->GetTRM()<<" tdc "<<lookvalue->GetTDC()<<" chain "<<lookvalue->GetChain()<<" channel "<<lookvalue->GetChannel()<<endl;
217 hChannel[key] = new TH1F(names[key].Data(),names[key].Data(),30000,0,30000);
218 // hitsname="xHits" + names[key];
219 // hNumHits[key] = new TH1F(hitsname.Data(),hitsname.Data(),50,-0.25,24.25);
220 type =names[key] + "/I";
221 b[key]=digitsTree->Branch(names[key].Data(),&channels[key], type);
224 {printf(" no such value %i \n", iline);}
227 for(Int_t ic=0; ic<12; ic++) {
229 sprintf(buf1,"QTC%i",ic+1);
230 sprintf(buf2,"CFDvsQTC%i",ic+1);
231 sprintf(buf3,"CFDvsLED%i",ic+1);
232 sprintf(buf4,"LEDminCFD%i",ic+1);
233 sprintf(buf7,"mpd%i",ic+1);
235 hQTC[ic] = new TH1F(buf1,"QTC",(Int_t)fHistLimits[2],fHistLimits[0],fHistLimits[1]);
236 h1CFDminLED[ic] = new TH1F(buf4,"LED - CFD",(Int_t)fHistLimits[5],fHistLimits[3],fHistLimits[4]);
238 hmpd[ic] = new TH1F(buf7,"mpd",20000,-10000.0,10000.0);
239 hCFDvsQTC[ic] = new TH2F(buf2,"CFD vs QTC",
240 (Int_t)fHistLimits[8],fHistLimits[6],fHistLimits[7],
241 (Int_t)fHistLimits[11],fHistLimits[9],fHistLimits[10]);
242 hCFDvsLED[ic] = new TH2F(buf3,"CFD vs LED-CFD",
243 (Int_t)fHistLimits[14],fHistLimits[12],fHistLimits[13],
244 (Int_t)fHistLimits[17],fHistLimits[15],fHistLimits[16]);
252 TH1F*hEffCFD= new TH1F("hEffCFD","Effeciency",50,-0.25,24.25);
253 TH1F*hEffLED= new TH1F("hEffLED","Effeciency",50,-0.25,24.25);
254 TH1F*hEffQT0= new TH1F("hEffQT0","Effeciency",50,-0.25,24.25);
255 TH1F*hEffQT1= new TH1F("hEffQT1","Effeciency",50,-0.25,24.25);
259 sprintf(filename,"t0%i.raw",fRunNumber);
260 AliRawReader *reader = new AliRawReaderDate(filename);
261 // AliRawReader *reader = new AliRawReaderFile();
262 reader->LoadEquipmentIdsMap("T0map.txt");
263 // reader->RequireHeader(kFALSE);
264 reader->RequireHeader(kTRUE);
265 AliT0RawReader *start = new AliT0RawReader(reader);
266 // start->SetNumberOfTRM(1);
267 for (Int_t i0=0; i0<105; i0++)
269 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
274 while (reader->NextEvent()) {
276 for (Int_t i=0; i<105; i++) {
277 for (Int_t iHit=0; iHit<5; iHit++)
279 allData[i][iHit]= start->GetData(i,iHit);
283 if(event%1000 == 0) printf("Event:%d\n",event);
285 // if(event > 200000) break;
287 for (Int_t it = 0; it<24; it=it+2)
289 for (Int_t iHit=0; iHit<5; iHit++)
291 if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
294 hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
295 hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
296 if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]);
297 if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 )
299 hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]);
300 h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
306 for (Int_t iHit=0; iHit<5; iHit++)
309 for(Int_t ik=1; ik<105; ik++)
312 if((allData[ik][iHit] - allData[0][0]) > 0 )
315 hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]);
316 channels[ik] = allData[ik][iHit] - allData[0][0];
329 printf("efficiency for %i events \n",event);
330 for (Int_t i0=1; i0<13; i0++)
332 printf("%s %f %s %f %s %f %s %f \n",
333 names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
334 names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event),
335 names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event),
336 names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event));
338 hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event));
339 hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event));
340 hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event));
341 hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event));
344 for (Int_t i0=0; i0<24; i0=i0+2)
346 hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
347 hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
348 hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) / Float_t(event));
349 hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) / Float_t(event));
351 printf("%s %f %s %f %s %f %s %f \n",
352 names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
353 names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
354 names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
355 names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
361 sprintf(filehist,"t0tree%i.root",fRunNumber);
362 // sprintf(filehist,"test.root",runNumber);
363 TFile *hist = new TFile(filehist,"RECREATE");
365 // digitsTree->Write("",TObject::kOverwrite);
372 for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write();
374 for (Int_t i=0; i<12; i++)
378 hCFDvsQTC[i]->Write();
379 hCFDvsLED[i]->Write();
380 h1CFDminLED[i]->Write();