]>
Commit | Line | Data |
---|---|---|
170c35f1 | 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 | ||
0bc7827a | 18 | //////////////////////////////////////////////////////////////////////////// |
19 | // // | |
20 | // Example: fill pedestal with Gaussian noise // | |
21 | // // | |
22 | // AliTRDCalibPadStatus ped; // | |
23 | // ped.TestEvent(numberofevent); // | |
24 | // // | |
25 | // // Method without histo // | |
26 | // ped.Analyse(); // | |
27 | // // | |
28 | // // Create the histo of the AliTRDCalROC // | |
29 | // TH2F * histo2dm = ped.GetCalRocMean(0,kFALSE)->MakeHisto2D(); // | |
30 | // histo2dm->Scale(10.0); // | |
31 | // TH1F * histo1dm = ped.GetCalRocMean(0,kFALSE)->MakeHisto1D(); // | |
32 | // histo1dm->Scale(10.0); // | |
33 | // TH2F * histo2ds = ped.GetCalRocSquares(0,kFALSE)->MakeHisto2D(); // | |
34 | // histo2ds->Scale(10.0); // | |
35 | // TH1F * histo1ds = ped.GetCalRocSquares(0,kFALSE)->MakeHisto1D(); // | |
36 | // histo1ds->Scale(10.0) // | |
37 | // // | |
38 | // // Draw output // | |
39 | // TCanvas* c1 = new TCanvas; // | |
40 | // c1->Divide(2,2); // | |
41 | // c1->cd(1); // | |
42 | // histo2dm->Draw("colz"); // | |
43 | // c1->cd(2); // | |
44 | // histo1dm->Draw(); // | |
45 | // c1->cd(3); // | |
46 | // histo2ds->Draw("colz"); // | |
47 | // c1->cd(4); // | |
48 | // histo1ds->Draw(); // | |
49 | // // | |
50 | // // Method with histo // | |
51 | // ped.AnalyseHisto(); // | |
52 | // // | |
53 | // // Take the histo // | |
54 | // TH1F *histo = ped.GetHisto(31); // | |
55 | // histo->SetEntries(1); // | |
56 | // histo->Draw(); // | |
1785640c | 57 | // |
58 | // Authors: | |
59 | // R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de) | |
60 | // J. Book (jbook@ikf.uni-frankfurt.de) | |
61 | // // | |
0bc7827a | 62 | //////////////////////////////////////////////////////////////////////////// |
170c35f1 | 63 | |
6bbdc11a | 64 | |
170c35f1 | 65 | //Root includes |
66 | #include <TObjArray.h> | |
170c35f1 | 67 | #include <TH2F.h> |
68 | #include <TString.h> | |
69 | #include <TMath.h> | |
170c35f1 | 70 | #include <TRandom.h> |
6bbdc11a | 71 | |
72 | //#include <TRandom.h> | |
170c35f1 | 73 | #include <TDirectory.h> |
74 | #include <TFile.h> | |
f162af62 | 75 | |
170c35f1 | 76 | //AliRoot includes |
3a0f6479 | 77 | #include <AliMathBase.h> |
170c35f1 | 78 | #include "AliRawReader.h" |
79 | #include "AliRawReaderRoot.h" | |
80 | #include "AliRawReaderDate.h" | |
f162af62 | 81 | |
3a0f6479 | 82 | //header file |
e4db522f | 83 | #include "AliLog.h" |
3a0f6479 | 84 | #include "AliTRDCalibPadStatus.h" |
f162af62 | 85 | #include "AliTRDgeometry.h" |
3a0f6479 | 86 | #include "AliTRDCommonParam.h" |
170c35f1 | 87 | #include "./Cal/AliTRDCalROC.h" |
88 | #include "./Cal/AliTRDCalPadStatus.h" | |
289cc637 | 89 | #include "./Cal/AliTRDCalDet.h" |
90 | #include "./Cal/AliTRDCalPad.h" | |
170c35f1 | 91 | #include "./Cal/AliTRDCalSingleChamberStatus.h" |
170c35f1 | 92 | |
1785640c | 93 | #include "AliTRDdigitsManager.h" |
94 | #include "AliTRDdigitsParam.h" | |
95 | #include "AliTRDSignalIndex.h" | |
96 | #include "AliTRDarraySignal.h" | |
97 | #include "AliTRDarrayADC.h" | |
98 | #include "AliTRDfeeParam.h" | |
99 | ||
fd50bb14 | 100 | #include "AliTRDrawStream.h" |
101 | ||
170c35f1 | 102 | #ifdef ALI_DATE |
103 | #include "event.h" | |
104 | #endif | |
105 | ||
170c35f1 | 106 | ClassImp(AliTRDCalibPadStatus) /*FOLD00*/ |
107 | ||
108 | //_____________________________________________________________________ | |
109 | AliTRDCalibPadStatus::AliTRDCalibPadStatus() : /*FOLD00*/ | |
110 | TObject(), | |
f162af62 | 111 | fGeo(0), |
170c35f1 | 112 | fAdcMin(0), |
d95484e4 | 113 | fAdcMax(21), |
170c35f1 | 114 | fDetector(-1), |
cf46274d | 115 | fNumberOfTimeBins(0), |
170c35f1 | 116 | fCalRocArrayMean(540), |
117 | fCalRocArrayRMS(540), | |
e4db522f | 118 | fCalRocArrayMeand(540), |
119 | fCalRocArrayRMSd(540), | |
120 | fHistoArray(540) | |
170c35f1 | 121 | { |
122 | // | |
123 | // default constructor | |
124 | // | |
f162af62 | 125 | |
126 | fGeo = new AliTRDgeometry(); | |
127 | ||
170c35f1 | 128 | } |
129 | ||
130 | //_____________________________________________________________________ | |
131 | AliTRDCalibPadStatus::AliTRDCalibPadStatus(const AliTRDCalibPadStatus &ped) : /*FOLD00*/ | |
132 | TObject(ped), | |
f162af62 | 133 | fGeo(0), |
170c35f1 | 134 | fAdcMin(ped.GetAdcMin()), |
135 | fAdcMax(ped.GetAdcMax()), | |
136 | fDetector(ped.fDetector), | |
cf46274d | 137 | fNumberOfTimeBins(ped.fNumberOfTimeBins), |
170c35f1 | 138 | fCalRocArrayMean(540), |
139 | fCalRocArrayRMS(540), | |
e4db522f | 140 | fCalRocArrayMeand(540), |
141 | fCalRocArrayRMSd(540), | |
142 | fHistoArray(540) | |
170c35f1 | 143 | { |
144 | // | |
145 | // copy constructor | |
146 | // | |
147 | for (Int_t idet = 0; idet < 540; idet++){ | |
170c35f1 | 148 | const AliTRDCalROC *calRocMean = (AliTRDCalROC*)ped.fCalRocArrayMean.UncheckedAt(idet); |
149 | const AliTRDCalROC *calRocRMS = (AliTRDCalROC*)ped.fCalRocArrayRMS.UncheckedAt(idet); | |
e4db522f | 150 | const AliTRDCalROC *calRocMeand = (AliTRDCalROC*)ped.fCalRocArrayMeand.UncheckedAt(idet); |
151 | const AliTRDCalROC *calRocRMSd = (AliTRDCalROC*)ped.fCalRocArrayRMSd.UncheckedAt(idet); | |
170c35f1 | 152 | const TH2F *hped = (TH2F*)ped.fHistoArray.UncheckedAt(idet); |
153 | ||
170c35f1 | 154 | if ( calRocMean != 0x0 ) fCalRocArrayMean.AddAt(new AliTRDCalROC(*calRocMean), idet); |
155 | if ( calRocRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTRDCalROC(*calRocRMS), idet); | |
156 | ||
e4db522f | 157 | if ( calRocMeand != 0x0 ) fCalRocArrayMeand.AddAt(new AliTRDCalROC(*calRocMeand), idet); |
158 | if ( calRocRMSd != 0x0 ) fCalRocArrayRMSd.AddAt(new AliTRDCalROC(*calRocRMSd), idet); | |
159 | ||
170c35f1 | 160 | if ( hped != 0x0 ){ |
161 | TH2F *hNew = new TH2F(*hped); | |
162 | hNew->SetDirectory(0); | |
163 | fHistoArray.AddAt(hNew,idet); | |
164 | } | |
165 | ||
166 | } | |
f162af62 | 167 | if (fGeo) { |
168 | delete fGeo; | |
169 | } | |
170 | fGeo = new AliTRDgeometry(); | |
170c35f1 | 171 | } |
f162af62 | 172 | |
170c35f1 | 173 | //_____________________________________________________________________ |
174 | AliTRDCalibPadStatus& AliTRDCalibPadStatus::operator = (const AliTRDCalibPadStatus &source) | |
175 | { | |
176 | // | |
177 | // assignment operator | |
178 | // | |
179 | if (&source == this) return *this; | |
180 | new (this) AliTRDCalibPadStatus(source); | |
181 | ||
182 | return *this; | |
183 | } | |
184 | //_____________________________________________________________________ | |
185 | AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/ | |
186 | { | |
187 | // | |
188 | // destructor | |
189 | // | |
1ca79a00 | 190 | fCalRocArrayMean.Delete(); |
191 | fCalRocArrayRMS.Delete(); | |
192 | fCalRocArrayMeand.Delete(); | |
193 | fCalRocArrayRMSd.Delete(); | |
194 | fHistoArray.Delete(); | |
f162af62 | 195 | if (fGeo) { |
196 | delete fGeo; | |
197 | } | |
170c35f1 | 198 | } |
8799e123 | 199 | //_____________________________________________________________________ |
200 | void AliTRDCalibPadStatus::Destroy() | |
201 | { | |
202 | // | |
203 | // Destroy | |
204 | // | |
205 | fCalRocArrayMean.Delete(); | |
206 | fCalRocArrayRMS.Delete(); | |
207 | fCalRocArrayMeand.Delete(); | |
208 | fCalRocArrayRMSd.Delete(); | |
209 | fHistoArray.Delete(); | |
210 | } | |
170c35f1 | 211 | //_____________________________________________________________________ |
212 | Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/ | |
1785640c | 213 | const Int_t icRow, |
214 | const Int_t icCol, | |
215 | const Int_t csignal, | |
216 | const Int_t crowMax, | |
217 | const Int_t ccold, | |
218 | const Int_t icMcm, | |
219 | const Int_t icRob | |
220 | ) | |
221 | { | |
222 | // | |
223 | // Signal filling methode | |
224 | // | |
225 | Int_t nbchannel = icRow+icCol*crowMax; | |
226 | Int_t mCm = icMcm%4; | |
227 | Int_t rOb = icRob%2; | |
228 | ||
229 | // now the case of double read channel | |
230 | if(ccold > 0){ | |
231 | nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax; | |
232 | //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow); | |
233 | } | |
234 | ||
235 | // fast filling methode. | |
236 | // Attention: the entry counter of the histogram is not increased | |
237 | // this means that e.g. the colz draw option gives an empty plot | |
238 | ||
239 | Int_t bin = 0; | |
240 | ||
241 | if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) ) | |
242 | bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1); | |
243 | ||
244 | //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel); | |
245 | ||
246 | GetHisto(icdet,kTRUE)->GetArray()[bin]++; | |
247 | ||
248 | return 0; | |
249 | } | |
250 | //_____________________________________________________________________ | |
8df1f8f5 | 251 | Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader) |
fd50bb14 | 252 | { |
253 | // | |
254 | // RawReader = AliTRDrawStream (Jochen Klein) | |
255 | // | |
256 | // Event Processing loop - AliTRDRawStreamCosmic | |
257 | // 0 time bin problem or zero suppression | |
258 | // 1 no input | |
259 | // 2 input | |
260 | // Raw version number: | |
261 | // [3,31] non zero suppressed | |
262 | // 2,4 and [32,63] zero suppressed | |
263 | // | |
264 | ||
265 | ||
266 | ||
267 | Int_t withInput = 1; | |
268 | ||
269 | AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE); | |
270 | digitsManager->CreateArrays(); | |
271 | ||
272 | AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader); | |
273 | rawStream->SetDigitsManager(digitsManager); | |
274 | //rawStream->SetNoErrorWarning(); | |
275 | //rawStream->SetSharedPadReadout(kTRUE); | |
276 | ||
277 | AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance(); | |
278 | ||
279 | Int_t det = 0; | |
280 | while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector | |
281 | if (digitsManager->GetIndexes(det)->HasEntry()) {//QA | |
282 | // printf("there is ADC data on this chamber!\n"); | |
283 | ||
284 | AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod | |
285 | if (digits->HasData()) { //array | |
286 | ||
287 | AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det); | |
288 | if (indexes->IsAllocated() == kFALSE) { | |
289 | AliError("Indexes do not exist!"); | |
290 | break; | |
291 | } | |
292 | Int_t iRow = 0; | |
293 | Int_t iCol = 0; | |
294 | indexes->ResetCounters(); | |
295 | ||
296 | while (indexes->NextRCIndex(iRow, iCol)) { //column,row | |
297 | ||
298 | AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam(); | |
299 | ||
300 | Int_t mcm = 0; // MCM from AliTRDfeeParam | |
301 | Int_t rob = 0; // ROB from AliTRDfeeParam | |
302 | Int_t extCol = 0; // extended column from AliTRDfeeParam | |
303 | mcm = feeParam->GetMCMfromPad(iRow,iCol); | |
304 | rob = feeParam->GetROBfromPad(iRow,iCol); | |
305 | ||
306 | Int_t idetector = det; // current detector | |
307 | Int_t iRowMax = 16; // current rowmax | |
308 | if(GetStack(det) == 2) iRowMax = 12; | |
309 | ||
310 | Int_t adc = 20 - (iCol%18) -1; // current adc | |
311 | Int_t col = 0; // col!=0 ->Shared Pad | |
312 | extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); | |
313 | //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol); | |
314 | ||
315 | // Signal for regular pads | |
316 | Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data | |
317 | for(Int_t k = 0; k < nbtimebin; k++){ | |
318 | Short_t signal = 0; | |
319 | signal = digits->GetData(iRow,iCol,k); | |
320 | ||
321 | if(signal>0) { | |
8df1f8f5 | 322 | UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob); |
fd50bb14 | 323 | } |
324 | } | |
325 | ||
326 | ||
327 | ||
328 | if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) ) { //SHARED PADS | |
329 | ||
330 | switch(adc) { | |
331 | case 2: | |
332 | adc = 20; //shared Pad adc | |
333 | mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm | |
334 | col = 1; | |
335 | break; | |
336 | case 19: | |
337 | adc = 1; //shared Pad adc | |
338 | mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm | |
339 | col = 2; | |
340 | break; | |
341 | case 18: | |
342 | adc = 0; //shared Pad adc | |
343 | mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm | |
344 | col = 3; | |
345 | break; | |
346 | } | |
347 | rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob | |
348 | ||
349 | ||
350 | extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc | |
351 | ||
352 | //printf("SHARED PAD --- iCol %d iRow %d rob %d mcm %d adc %d extCol %d col %d\n",iCol,iRow,rob,mcm,adc,extCol,col); | |
353 | for(Int_t k = 0; k < nbtimebin; k++){ | |
354 | Short_t signal = 0; | |
355 | signal = digits->GetDataByAdcCol(iRow,extCol,k); | |
356 | ||
357 | if(signal>0) { | |
8df1f8f5 | 358 | UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob); |
fd50bb14 | 359 | } |
360 | } | |
361 | } //shared pads end | |
362 | ||
363 | ||
364 | withInput = 2; | |
365 | }//column,row | |
366 | ||
367 | }//array | |
368 | }//QA | |
369 | digitsManager->ClearArrays(det); | |
370 | }//idetector | |
371 | delete digitsManager; | |
372 | delete rawStream; | |
373 | return withInput; | |
374 | ||
375 | } | |
376 | ||
170c35f1 | 377 | //_____________________________________________________________________ |
378 | TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/ | |
379 | Int_t nbinsY, Float_t ymin, Float_t ymax, | |
a6e0ebfe | 380 | const Char_t *type, Bool_t force) |
170c35f1 | 381 | { |
382 | // | |
383 | // return pointer to histogram | |
384 | // if force is true create a new histogram if it doesn't exist allready | |
385 | // | |
386 | if ( !force || arr->UncheckedAt(det) ) | |
387 | return (TH2F*)arr->UncheckedAt(det); | |
388 | ||
389 | // if we are forced and histogram doesn't yes exist create it | |
390 | Char_t name[255], title[255]; | |
391 | ||
fdc15553 | 392 | snprintf(name,255,"hCalib%s%.3d",type,det); |
393 | snprintf(title,255,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det); | |
170c35f1 | 394 | |
3a0f6479 | 395 | |
053767a4 | 396 | Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det)); |
e4db522f | 397 | |
398 | // we will add 3*8*rowMax channels at the end for the double counted | |
053767a4 | 399 | nbchannels += 3*8*(fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))); |
e4db522f | 400 | |
170c35f1 | 401 | |
402 | // new histogram with calib information. One value for each pad! | |
403 | TH2F* hist = new TH2F(name,title, | |
404 | nbinsY, ymin, ymax, | |
405 | nbchannels,0,nbchannels | |
406 | ); | |
407 | hist->SetDirectory(0); | |
408 | arr->AddAt(hist,det); | |
409 | return hist; | |
410 | } | |
3a0f6479 | 411 | |
170c35f1 | 412 | //_____________________________________________________________________ |
413 | TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/ | |
414 | { | |
415 | // | |
416 | // return pointer to histogram | |
417 | // if force is true create a new histogram if it doesn't exist allready | |
418 | // | |
419 | TObjArray *arr = &fHistoArray; | |
d95484e4 | 420 | return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin-0.5, fAdcMax-0.5, "Pedestal", force); |
170c35f1 | 421 | } |
3a0f6479 | 422 | |
170c35f1 | 423 | //_____________________________________________________________________ |
cf46274d | 424 | AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/ |
170c35f1 | 425 | { |
426 | // | |
427 | // return pointer to ROC Calibration | |
428 | // if force is true create a new AliTRDCalROC if it doesn't exist allready | |
429 | // | |
430 | if ( !force || arr->UncheckedAt(det) ) | |
431 | return (AliTRDCalROC*)arr->UncheckedAt(det); | |
432 | ||
433 | // if we are forced and histogram doesn't yes exist create it | |
434 | ||
435 | // new AliTRDCalROC. One value for each pad! | |
053767a4 | 436 | AliTRDCalROC *croc = new AliTRDCalROC(GetLayer(det),GetStack(det)); |
170c35f1 | 437 | arr->AddAt(croc,det); |
438 | return croc; | |
439 | } | |
440 | //_____________________________________________________________________ | |
e4db522f | 441 | AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOLD00*/ |
170c35f1 | 442 | { |
443 | // | |
444 | // return pointer to Carge ROC Calibration | |
445 | // if force is true create a new histogram if it doesn't exist allready | |
446 | // | |
e4db522f | 447 | TObjArray *arr = &fCalRocArrayMean; |
448 | return GetCalRoc(det, arr, force); | |
170c35f1 | 449 | } |
3a0f6479 | 450 | |
170c35f1 | 451 | //_____________________________________________________________________ |
e4db522f | 452 | AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD00*/ |
170c35f1 | 453 | { |
454 | // | |
455 | // return pointer to Carge ROC Calibration | |
456 | // if force is true create a new histogram if it doesn't exist allready | |
457 | // | |
e4db522f | 458 | TObjArray *arr = &fCalRocArrayRMS; |
459 | return GetCalRoc(det, arr, force); | |
170c35f1 | 460 | } |
461 | //_____________________________________________________________________ | |
e4db522f | 462 | AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMeand(Int_t det, Bool_t force) /*FOLD00*/ |
170c35f1 | 463 | { |
464 | // | |
465 | // return pointer to Carge ROC Calibration | |
466 | // if force is true create a new histogram if it doesn't exist allready | |
467 | // | |
e4db522f | 468 | TObjArray *arr = &fCalRocArrayMeand; |
cf46274d | 469 | return GetCalRoc(det, arr, force); |
170c35f1 | 470 | } |
3a0f6479 | 471 | |
170c35f1 | 472 | //_____________________________________________________________________ |
e4db522f | 473 | AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMSd(Int_t det, Bool_t force) /*FOLD00*/ |
170c35f1 | 474 | { |
475 | // | |
476 | // return pointer to Carge ROC Calibration | |
477 | // if force is true create a new histogram if it doesn't exist allready | |
478 | // | |
e4db522f | 479 | TObjArray *arr = &fCalRocArrayRMSd; |
cf46274d | 480 | return GetCalRoc(det, arr, force); |
170c35f1 | 481 | } |
3a0f6479 | 482 | |
170c35f1 | 483 | //_____________________________________________________________________ |
484 | void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/ | |
485 | { | |
486 | // | |
487 | // Calculate calibration constants | |
488 | // | |
489 | ||
490 | Int_t nbinsAdc = fAdcMax-fAdcMin; | |
491 | ||
d95484e4 | 492 | TVectorD param(4); |
170c35f1 | 493 | TMatrixD dummy(3,3); |
494 | ||
0bc7827a | 495 | Float_t *arrayHP=0; |
170c35f1 | 496 | |
497 | ||
498 | for (Int_t idet=0; idet<540; idet++){ | |
499 | TH2F *hP = GetHisto(idet); | |
500 | if ( !hP ) { | |
501 | continue; | |
502 | } | |
503 | ||
d95484e4 | 504 | //printf("Entries for %d\n",idet); |
505 | ||
170c35f1 | 506 | AliTRDCalROC *rocMean = GetCalRocMean(idet,kTRUE); |
507 | AliTRDCalROC *rocRMS = GetCalRocRMS(idet,kTRUE); | |
508 | ||
0bc7827a | 509 | arrayHP = hP->GetArray(); |
170c35f1 | 510 | Int_t nChannels = rocMean->GetNchannels(); |
511 | ||
512 | for (Int_t iChannel=0; iChannel<nChannels; iChannel++){ | |
513 | Int_t offset = (nbinsAdc+2)*(iChannel+1)+1; | |
d95484e4 | 514 | Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy); |
515 | // if the fitting failed set noise and pedestal to 0 | |
6ace5fe2 | 516 | if ((ret==-4) || (ret==-1) || (ret==-2)) { |
170c35f1 | 517 | param[1]=0.0; |
518 | param[2]=0.0; | |
519 | } | |
520 | if((param[1]/10.0) > 65534.0) param[1] = 0.0; | |
521 | if((param[2]/10.0) > 65534.0) param[2] = 0.0; | |
522 | rocMean->SetValue(iChannel,param[1]/10.0); | |
523 | rocRMS->SetValue(iChannel,param[2]/10.0); | |
524 | } | |
e4db522f | 525 | |
526 | // here we analyse doubled read channels | |
527 | ||
528 | AliTRDCalROC *rocMeand = GetCalRocMeand(idet,kTRUE); | |
529 | AliTRDCalROC *rocRMSd = GetCalRocRMSd(idet,kTRUE); | |
530 | ||
531 | Int_t nrows = rocMeand->GetNrows(); | |
532 | Int_t shift = 144*nrows; | |
533 | Int_t total = shift+3*8*nrows; | |
534 | ||
535 | for (Int_t iChannel=shift; iChannel<total; iChannel++){ | |
536 | Int_t offset = (nbinsAdc+2)*(iChannel+1)+1; | |
d95484e4 | 537 | Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy); |
e4db522f | 538 | // if the fitting failed set noise and pedestal to 0 |
539 | if ((ret==-4) || (ret==-1) || (ret==-2)) { | |
540 | param[1]=0.0; | |
541 | param[2]=0.0; | |
542 | } | |
543 | if((param[1]/10.0) > 65534.0) param[1] = 0.0; | |
544 | if((param[2]/10.0) > 65534.0) param[2] = 0.0; | |
545 | ||
546 | // here we have to recalculate backward | |
547 | Int_t nb = iChannel-shift; | |
548 | Int_t row = nb%nrows; | |
549 | Int_t j = (Int_t)(nb/nrows); | |
550 | Int_t imcm = j%8; | |
551 | Int_t icol = (Int_t)(j/8); | |
552 | ||
553 | Int_t finalcol = 18*imcm; | |
554 | if(icol > 0) icol += 17; | |
555 | else icol = -1; | |
556 | finalcol += icol; | |
557 | ||
558 | Int_t channel = row+finalcol*nrows; | |
559 | ||
560 | //printf("iChannel %d, nrows %d, finalcol %d, row %d, channel %d\n",iChannel,nrows,finalcol,row,channel); | |
561 | if((finalcol < 0) || (finalcol >= 144)) continue; | |
562 | ||
563 | rocMeand->SetValue(channel,param[1]/10.0); | |
564 | rocRMSd->SetValue(channel,param[2]/10.0); | |
565 | } | |
566 | ||
170c35f1 | 567 | } |
e4db522f | 568 | |
170c35f1 | 569 | } |
3a0f6479 | 570 | |
170c35f1 | 571 | //_______________________________________________________________________________________ |
572 | AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus() | |
573 | { | |
574 | // | |
6ace5fe2 | 575 | // Create Pad Status out of Mean and RMS values |
37b0cf5e | 576 | // The chamber without data are masked, this is the corrected in the preprocessor |
170c35f1 | 577 | // |
578 | ||
579 | AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus"); | |
580 | ||
581 | for (Int_t idet=0; idet<540; ++idet) | |
582 | { | |
583 | AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet); | |
584 | ||
e4db522f | 585 | |
37b0cf5e | 586 | if ( !GetCalRocMean(idet)) { |
170c35f1 | 587 | for(Int_t k = 0; k < calROC->GetNchannels(); k++){ |
37b0cf5e | 588 | calROC->SetStatus(k,AliTRDCalPadStatus::kNotConnected); |
170c35f1 | 589 | } |
170c35f1 | 590 | continue; |
591 | } | |
6ace5fe2 | 592 | |
37b0cf5e | 593 | |
594 | //Take the stuff | |
595 | AliTRDCalROC *calRocMean = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMean(idet))); | |
596 | AliTRDCalROC *calRocRMS = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMS(idet))); | |
597 | ||
598 | //Take the stuff second chance | |
599 | AliTRDCalROC *calRocMeand = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMeand(idet))); | |
600 | AliTRDCalROC *calRocRMSd = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMSd(idet))); | |
601 | ||
602 | calRocRMS->Unfold(); | |
603 | calRocRMSd->Unfold(); | |
604 | ||
605 | ||
170c35f1 | 606 | //Range |
37b0cf5e | 607 | Int_t row = calROC->GetNrows(); |
608 | Int_t col = calROC->GetNcols(); | |
6ace5fe2 | 609 | |
610 | Double_t rmsmean = calRocMean->GetRMS()*10.0; | |
611 | Double_t meanmean = calRocMean->GetMean()*10.0; | |
37b0cf5e | 612 | Double_t meansquares = calRocRMS->GetMean(); |
170c35f1 | 613 | |
37b0cf5e | 614 | |
615 | for(Int_t irow = 0; irow < row; irow++){ | |
170c35f1 | 616 | |
37b0cf5e | 617 | // for bridged pads |
618 | Float_t meanprevious = 0.0; | |
619 | Float_t rmsprevious = 0.0; | |
620 | Float_t mean = 0.0; | |
621 | Float_t rms = 0.0; | |
6ace5fe2 | 622 | |
37b0cf5e | 623 | for(Int_t icol = 0; icol < col; icol++){ |
624 | ||
625 | mean = calRocMean->GetValue(icol,irow)*10.0; | |
626 | rms = calRocRMS->GetValue(icol,irow); | |
627 | ||
628 | if(icol > 0) { | |
629 | meanprevious = calRocMean->GetValue((icol -1),irow)*10.0; | |
630 | rmsprevious = calRocRMS->GetValue((icol - 1),irow); | |
631 | } | |
632 | ||
633 | Bool_t pb = kFALSE; | |
634 | // masked if two noisy | |
635 | if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) { | |
636 | ||
637 | pb = kTRUE; | |
638 | // look at second chance | |
639 | Float_t meand = calRocMeand->GetValue(icol,irow)*10.0; | |
640 | Float_t rmsd = calRocRMSd->GetValue(icol,irow); | |
641 | ||
642 | if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) { | |
643 | if((rmsd <= 0.0001) && (rms <= 0.0001)) { | |
644 | calROC->SetStatus(icol,irow,AliTRDCalPadStatus::kNotConnected); | |
645 | } | |
646 | else { | |
647 | calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kMasked); | |
648 | } | |
649 | } | |
650 | else { | |
651 | calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kReadSecond); | |
652 | } | |
653 | } | |
e4db522f | 654 | |
37b0cf5e | 655 | |
656 | // bridge if previous pad found something | |
657 | if(!pb) { | |
92df0132 | 658 | if((TMath::Abs(meanprevious-mean)<0.000001) && (TMath::Abs(rmsprevious-rms)<0.000001) && (mean > 0.0001)) { |
37b0cf5e | 659 | //printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol); |
660 | calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight); | |
661 | calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft); | |
662 | } | |
e4db522f | 663 | } |
37b0cf5e | 664 | |
e4db522f | 665 | } |
6ace5fe2 | 666 | } |
37b0cf5e | 667 | |
668 | delete calRocMean; | |
669 | delete calRocRMS; | |
670 | delete calRocMeand; | |
671 | delete calRocRMSd; | |
672 | ||
673 | ||
170c35f1 | 674 | } |
675 | ||
676 | return obj; | |
677 | ||
678 | } | |
289cc637 | 679 | //_______________________________________________________________________________________ |
680 | AliTRDCalPad* AliTRDCalibPadStatus::CreateCalPad() | |
681 | { | |
682 | // | |
683 | // Create Pad Noise out of RMS values | |
684 | // | |
685 | ||
686 | AliTRDCalPad* obj = new AliTRDCalPad("PadNoise", "PadNoise"); | |
687 | ||
688 | ||
689 | for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) { | |
690 | ||
691 | AliTRDCalROC *calROC22 = obj->GetCalROC(det); | |
692 | ||
693 | AliTRDCalROC *calRocRMS = ((AliTRDCalROC *)GetCalRocRMS(det,kTRUE)); | |
694 | ||
695 | for(Int_t k = 0; k < calROC22->GetNchannels(); k++){ | |
696 | calROC22->SetValue(k,calRocRMS->GetValue(k)); | |
697 | } | |
698 | ||
699 | } | |
700 | ||
701 | return obj; | |
702 | ||
703 | } | |
704 | ||
705 | //_______________________________________________________________________________________ | |
0bc7827a | 706 | AliTRDCalDet* AliTRDCalibPadStatus::CreateCalDet() const |
289cc637 | 707 | { |
708 | // | |
709 | // Create Det Noise correction factor | |
710 | // | |
711 | ||
712 | AliTRDCalDet* obj = new AliTRDCalDet("DetNoise", "DetNoise (correction factor)"); | |
713 | ||
714 | for(Int_t l = 0; l < 540; l++){ | |
715 | obj->SetValue(l,10.0); | |
716 | } | |
717 | ||
718 | return obj; | |
719 | ||
720 | } | |
721 | ||
170c35f1 | 722 | //_____________________________________________________________________ |
723 | void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/ | |
724 | { | |
725 | // | |
726 | // Write class to file | |
727 | // | |
728 | ||
729 | TString sDir(dir); | |
730 | TString option; | |
731 | ||
732 | if ( append ) | |
733 | option = "update"; | |
734 | else | |
735 | option = "recreate"; | |
736 | ||
737 | TDirectory *backup = gDirectory; | |
738 | TFile f(filename,option.Data()); | |
739 | f.cd(); | |
740 | if ( !sDir.IsNull() ){ | |
741 | f.mkdir(sDir.Data()); | |
742 | f.cd(sDir); | |
743 | } | |
744 | this->Write(); | |
745 | f.Close(); | |
746 | ||
747 | if ( backup ) backup->cd(); | |
3a0f6479 | 748 | } |
749 | ||
6ace5fe2 | 750 | //_____________________________________________________________________ |
751 | void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/ | |
752 | { | |
753 | // | |
754 | // Put the AliTRDCalROC in the array fCalRocArrayMean | |
755 | // | |
756 | ||
757 | ||
758 | AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE); | |
759 | ||
760 | Int_t nChannels = rocMean->GetNchannels(); | |
761 | ||
762 | for (Int_t iChannel=0; iChannel<nChannels; iChannel++){ | |
763 | ||
764 | rocMean->SetValue(iChannel,mean->GetValue(iChannel)); | |
765 | ||
766 | } | |
767 | ||
768 | } | |
769 | ||
770 | //_____________________________________________________________________ | |
771 | void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/ | |
772 | { | |
773 | // | |
774 | // Put the AliTRDCalROC in the array fCalRocArrayRMS | |
775 | // | |
776 | ||
777 | ||
778 | AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE); | |
779 | ||
780 | Int_t nChannels = rocRms->GetNchannels(); | |
781 | ||
782 | for (Int_t iChannel=0; iChannel<nChannels; iChannel++){ | |
783 | ||
784 | rocRms->SetValue(iChannel,rms->GetValue(iChannel)); | |
785 | ||
786 | } | |
787 | ||
788 | } | |
e4db522f | 789 | //_____________________________________________________________________ |
790 | void AliTRDCalibPadStatus::SetCalRocMeand(AliTRDCalROC *mean, Int_t det) /*FOLD00*/ | |
791 | { | |
792 | // | |
793 | // Put the AliTRDCalROC in the array fCalRocArrayMean | |
794 | // | |
6ace5fe2 | 795 | |
e4db522f | 796 | |
797 | AliTRDCalROC *rocMean = GetCalRocMeand(det,kTRUE); | |
798 | ||
799 | Int_t nChannels = rocMean->GetNchannels(); | |
800 | ||
801 | for (Int_t iChannel=0; iChannel<nChannels; iChannel++){ | |
802 | ||
803 | rocMean->SetValue(iChannel,mean->GetValue(iChannel)); | |
804 | ||
805 | } | |
806 | ||
807 | } | |
808 | ||
809 | //_____________________________________________________________________ | |
810 | void AliTRDCalibPadStatus::SetCalRocRMSd(AliTRDCalROC *rms, Int_t det) /*FOLD00*/ | |
811 | { | |
812 | // | |
813 | // Put the AliTRDCalROC in the array fCalRocArrayRMS | |
814 | // | |
815 | ||
816 | ||
817 | AliTRDCalROC *rocRms = GetCalRocRMSd(det,kTRUE); | |
818 | ||
819 | Int_t nChannels = rocRms->GetNchannels(); | |
820 | ||
821 | for (Int_t iChannel=0; iChannel<nChannels; iChannel++){ | |
822 | ||
823 | rocRms->SetValue(iChannel,rms->GetValue(iChannel)); | |
824 | ||
825 | } | |
826 | ||
827 | } | |
3a0f6479 | 828 | //_____________________________________________________________________________ |
053767a4 | 829 | Int_t AliTRDCalibPadStatus::GetLayer(Int_t d) const |
170c35f1 | 830 | { |
831 | // | |
053767a4 | 832 | // Reconstruct the layer number from the detector number |
170c35f1 | 833 | // |
834 | ||
835 | return ((Int_t) (d % 6)); | |
836 | ||
837 | } | |
838 | ||
839 | //_____________________________________________________________________________ | |
053767a4 | 840 | Int_t AliTRDCalibPadStatus::GetStack(Int_t d) const |
170c35f1 | 841 | { |
842 | // | |
843 | // Reconstruct the chamber number from the detector number | |
844 | // | |
845 | ||
846 | return ((Int_t) (d % 30) / 6); | |
847 | ||
848 | } | |
3a0f6479 | 849 | |
170c35f1 | 850 | //_____________________________________________________________________________ |
851 | Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const | |
852 | { | |
853 | // | |
854 | // Reconstruct the sector number from the detector number | |
855 | // | |
856 | ||
857 | return ((Int_t) (d / 30)); | |
858 | ||
859 | } | |
068b874f | 860 | |
861 |