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 <iostream.h>
35 #include "AliT0CalibLaserData.h"
37 #include "AliCDBManager.h"
38 #include "AliRawReader.h"
39 #include "AliRawReaderRoot.h"
40 #include "AliT0LookUpValue.h"
41 #include "AliT0LookUpKey.h"
42 #include "AliT0Parameters.h"
43 #include "AliT0RawReader.h"
45 ClassImp(AliT0CalibLaserData)
47 AliT0CalibLaserData::AliT0CalibLaserData() : TObject(),
53 //________________________________________________________________
55 AliT0CalibLaserData::AliT0CalibLaserData(const AliT0CalibLaserData& calibda) : TObject(),
61 //________________________________________________________________
63 AliT0CalibLaserData &AliT0CalibLaserData::operator =(const AliT0CalibLaserData& calibda)
65 // assignment operator
69 //________________________________________________________________
70 AliT0CalibLaserData::~AliT0CalibLaserData()
75 //________________________________________________________________
77 void AliT0CalibLaserData::ReadHistSize(Int_t rNumber)
79 //build GUI frame for reading:
85 TGMainFrame* fMain = new TGMainFrame(0,1500,1500);
86 fMain->SetLayoutManager( new TGMatrixLayout(fMain,7,7) );
88 fMain->AddFrame( new TGLabel(fMain, " Histogram") );
89 fMain->AddFrame( new TGLabel(fMain, "X min") );
90 fMain->AddFrame( new TGLabel(fMain, "X max") );
91 fMain->AddFrame( new TGLabel(fMain, "X N# channels") );
93 fMain->AddFrame( new TGLabel(fMain, "Y min") );
94 fMain->AddFrame( new TGLabel(fMain, "Y max") );
95 fMain->AddFrame( new TGLabel(fMain, "Y N# channels") );
97 fMain->AddFrame( new TGLabel(fMain, "QTC" ) );
98 fEntries[0] = new TGNumberEntry(fMain, 0);
99 fMain->AddFrame(fEntries[0]);
100 fEntries[1] = new TGNumberEntry(fMain, 10000);
101 fMain->AddFrame(fEntries[1]);
102 fEntries[2] = new TGNumberEntry(fMain, 10000);
103 fMain->AddFrame(fEntries[2]);
104 fMain->AddFrame( new TGLabel(fMain, " ") );
105 fMain->AddFrame( new TGLabel(fMain, " ") );
106 fMain->AddFrame( new TGLabel(fMain, " ") );
108 fMain->AddFrame( new TGLabel(fMain, "LED - CFD" ) );
109 fEntries[3] = new TGNumberEntry(fMain, 0);
110 fMain->AddFrame(fEntries[3]);
111 fEntries[4] = new TGNumberEntry(fMain, 10000);
112 fMain->AddFrame(fEntries[4]);
113 fEntries[5] = new TGNumberEntry(fMain, 10000);
114 fMain->AddFrame(fEntries[5]);
115 fMain->AddFrame( new TGLabel(fMain, " ") );
116 fMain->AddFrame( new TGLabel(fMain, " ") );
117 fMain->AddFrame( new TGLabel(fMain, " ") );
118 fMain->AddFrame( new TGLabel(fMain, "CFD vs QTC " ) );
120 fEntries[6] = new TGNumberEntry(fMain, 1000.);
121 fMain->AddFrame(fEntries[6]);
122 fEntries[7] = new TGNumberEntry(fMain, 8000.5);
123 fMain->AddFrame(fEntries[7]);
124 fEntries[8] = new TGNumberEntry(fMain, 700);
125 fMain->AddFrame(fEntries[8]);
127 fEntries[9] = new TGNumberEntry(fMain, 12000.5);
128 fMain->AddFrame(fEntries[9]);
129 fEntries[10] = new TGNumberEntry(fMain, 18000.5);
130 fMain->AddFrame(fEntries[10]);
131 fEntries[11] = new TGNumberEntry(fMain, 2000);
132 fMain->AddFrame(fEntries[11]);
134 fMain->AddFrame( new TGLabel(fMain, "CFD vs LED-CFD " ) );
136 fEntries[12] = new TGNumberEntry(fMain, 0);
137 fMain->AddFrame(fEntries[12]);
138 fEntries[13] = new TGNumberEntry(fMain, 500);
139 fMain->AddFrame(fEntries[13]);
140 fEntries[14] = new TGNumberEntry(fMain, 500);
141 fMain->AddFrame(fEntries[14]);
143 fEntries[15] = new TGNumberEntry(fMain, 14600);
144 fMain->AddFrame(fEntries[15]);
145 fEntries[16] = new TGNumberEntry(fMain, 14700);
146 fMain->AddFrame(fEntries[16]);
147 fEntries[17] = new TGNumberEntry(fMain, 100);
148 fMain->AddFrame(fEntries[17]);
150 fMain->AddFrame( new TGLabel(fMain, " Number of run") );
151 fEntries[18] = new TGNumberEntry(fMain, 905);
152 fMain->AddFrame(fEntries[18]);
154 for ( int i=0; i<19; i++ ) fEntries[i]->SetWidth(70);
155 // printf( "Max Length %d\n", fEntries[0]->GetMaxWidth() );
157 TGTextButton *fOk = new TGTextButton(fMain, "OK");
158 fOk->Connect("Clicked()","AliT0CalibLaserData",this,"DoOk()");
159 // fOk->SetCommand(".q");
160 fMain->AddFrame(fOk);
162 fMain->MapSubwindows();
164 fMain->SetWindowName("Dialog");
168 void AliT0CalibLaserData::DoOk()
172 fRunNumber = Int_t (fEntries[18]->GetNumber());
173 printf(" RUN NUMBER %i\n",fRunNumber);
174 for( int i=0; i<18; i++ )
175 fHistLimits[i] = fEntries[i]->GetNumber();
180 void AliT0CalibLaserData::ReadData()
182 // reading RAW data from test LCS
183 // filling histograms
187 TH1F *hChannel[105]; TH1F *hQTC[12];
188 TH2F *hCFDvsQTC[12]; TH2F *hCFDvsLED[12]; TH1F *h1CFDminLED[12];
190 Int_t allData[110][5];
191 Int_t numberOfHits[105];
193 Char_t buf1[20], buf2[20], buf3[20], buf4[20], buf7[20];
195 TTree* digitsTree = new TTree("testData","Tree of test data Digits");
200 TString names[106], type;
201 AliT0LookUpKey* lookkey= new AliT0LookUpKey();
202 AliT0LookUpValue* lookvalue= new AliT0LookUpValue();
203 AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
204 AliCDBManager::Instance()->SetRun(0);
205 AliT0Parameters *fParam = AliT0Parameters::Instance();
207 TMap *lookup = fParam->GetMapLookup();
208 TMapIter *iter = new TMapIter(lookup);
210 for( Int_t iline=0; iline<106; iline++)
212 lookvalue = ( AliT0LookUpValue*) iter->Next();
213 lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
215 Int_t key=lookkey->GetKey();
216 names[key]=lookkey->GetChannelName();
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 AliRawReaderRoot(filename);
261 // // AliRawReader *reader = new AliRawReaderFile();
262 // AliRawReader *reader = new AliRawReaderFile();
263 reader->LoadEquipmentIdsMap("T0map.txt");
264 // reader->RequireHeader(kFALSE);
265 reader->RequireHeader(kTRUE);
266 AliT0RawReader *start = new AliT0RawReader(reader);
267 // start->SetNumberOfTRM(1);
268 for (Int_t i0=0; i0<105; i0++)
270 for (Int_t j0=0; j0<5; j0++) allData[i0][j0]=0;
275 while (reader->NextEvent()) {
277 for (Int_t i=0; i<105; i++) {
278 for (Int_t iHit=0; iHit<5; iHit++)
280 allData[i][iHit]= start->GetData(i,iHit);
284 if(event%1000 == 0) printf("Event:%d\n",event);
286 // if(event > 200000) break;
288 for (Int_t it = 0; it<24; it=it+2)
290 for (Int_t iHit=0; iHit<5; iHit++)
292 if(allData[it+25][iHit] != 0 && allData[it+26][iHit] !=0)
295 hQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit]);
296 hmpd[cc]->Fill(allData[it+26][iHit]-allData[it+25][iHit]);
297 if(allData[cc+1][iHit] != 0 ) hCFDvsQTC[cc]->Fill(allData[it+25][iHit]-allData[it+26][iHit],allData[cc+1][iHit]-allData[0][0]);
298 if(allData[cc+1][iHit] != 0 && allData[cc+13][iHit]!=0 )
300 hCFDvsLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit],allData[cc+1][iHit]-allData[0][0]);
301 h1CFDminLED[cc]->Fill(allData[cc+13][iHit]-allData[cc+1][iHit]);
307 for (Int_t iHit=0; iHit<5; iHit++)
310 for(Int_t ik=1; ik<105; ik++)
313 if((allData[ik][iHit] - allData[0][0]) > 0 )
316 hChannel[ik] -> Fill(allData[ik][iHit] - allData[0][0]);
317 channels[ik] = allData[ik][iHit] - allData[0][0];
330 printf("efficiency for %i events \n",event);
331 for (Int_t i0=1; i0<13; i0++)
333 printf("%s %f %s %f %s %f %s %f \n",
334 names[i0].Data(), Float_t(numberOfHits[i0])/Float_t(event),
335 names[i0+13].Data(),Float_t(numberOfHits[i0+13])/Float_t(event),
336 names[i0+57].Data(),Float_t(numberOfHits[i0+57])/Float_t(event),
337 names[i0+69].Data(),Float_t(numberOfHits[i0+69])/Float_t(event));
339 hEffCFD->Fill(i0,Float_t(numberOfHits[i0]) / Float_t(event));
340 hEffLED->Fill(i0,Float_t(numberOfHits[i0+13]) / Float_t(event));
341 hEffCFD->Fill(i0+12,Float_t(numberOfHits[i0+57]) /Float_t(event));
342 hEffLED->Fill(i0+12,Float_t(numberOfHits[i0+69]) /Float_t(event));
345 for (Int_t i0=0; i0<24; i0=i0+2)
347 hEffQT1->Fill(i0, Float_t (numberOfHits[i0+25]) / Float_t(event));
348 hEffQT0->Fill(i0, Float_t (numberOfHits[i0]+26) / Float_t(event));
349 hEffQT1->Fill((i0+12), Float_t (numberOfHits[i0]+81) / Float_t(event));
350 hEffQT0->Fill((i0+12), Float_t (numberOfHits[i0]+82) / Float_t(event));
352 printf("%s %f %s %f %s %f %s %f \n",
353 names[i0+25].Data(), Float_t(numberOfHits[i0+25])/Float_t(event),
354 names[i0+26].Data(),Float_t(numberOfHits[i0+26])/Float_t(event),
355 names[i0+81].Data(),Float_t(numberOfHits[i0+81])/Float_t(event),
356 names[i0+82].Data(),Float_t(numberOfHits[i0+82])/Float_t(event));
362 sprintf(filehist,"t0tree%i.root",fRunNumber);
363 // sprintf(filehist,"test.root",runNumber);
364 TFile *hist = new TFile(filehist,"RECREATE");
366 // digitsTree->Write("",TObject::kOverwrite);
373 for(Int_t ik=0; ik<105; ik++) hChannel[ik] ->Write();
375 for (Int_t i=0; i<12; i++)
379 hCFDvsQTC[i]->Write();
380 hCFDvsLED[i]->Write();
381 h1CFDminLED[i]->Write();