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 ////////////////////////////////////////////////////////////////////////////
20 // Example: fill pedestal with Gaussian noise //
22 // AliTRDCalibPadStatus ped; //
23 // ped.TestEvent(numberofevent); //
25 // // Method without histo //
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) //
39 // TCanvas* c1 = new TCanvas; //
40 // c1->Divide(2,2); //
42 // histo2dm->Draw("colz"); //
44 // histo1dm->Draw(); //
46 // histo2ds->Draw("colz"); //
48 // histo1ds->Draw(); //
50 // // Method with histo //
51 // ped.AnalyseHisto(); //
53 // // Take the histo //
54 // TH1F *histo = ped.GetHisto(31); //
55 // histo->SetEntries(1); //
59 // R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de)
60 // J. Book (jbook@ikf.uni-frankfurt.de)
62 ////////////////////////////////////////////////////////////////////////////
66 #include <TObjArray.h>
72 //#include <TRandom.h>
73 #include <TDirectory.h>
77 #include <AliMathBase.h>
78 #include "AliRawReader.h"
79 #include "AliRawReaderRoot.h"
80 #include "AliRawReaderDate.h"
84 #include "AliTRDCalibPadStatus.h"
85 #include "AliTRDrawStreamBase.h"
86 #include "AliTRDgeometry.h"
87 #include "AliTRDCommonParam.h"
88 #include "./Cal/AliTRDCalROC.h"
89 #include "./Cal/AliTRDCalPadStatus.h"
90 #include "./Cal/AliTRDCalDet.h"
91 #include "./Cal/AliTRDCalPad.h"
92 #include "./Cal/AliTRDCalSingleChamberStatus.h"
94 #include "AliTRDrawFastStream.h"
95 #include "AliTRDdigitsManager.h"
96 #include "AliTRDdigitsParam.h"
97 #include "AliTRDSignalIndex.h"
98 #include "AliTRDarraySignal.h"
99 #include "AliTRDarrayADC.h"
100 #include "AliTRDfeeParam.h"
102 #include "AliTRDrawStream.h"
108 ClassImp(AliTRDCalibPadStatus) /*FOLD00*/
110 //_____________________________________________________________________
111 AliTRDCalibPadStatus::AliTRDCalibPadStatus() : /*FOLD00*/
117 fNumberOfTimeBins(0),
118 fCalRocArrayMean(540),
119 fCalRocArrayRMS(540),
120 fCalRocArrayMeand(540),
121 fCalRocArrayRMSd(540),
125 // default constructor
128 fGeo = new AliTRDgeometry();
132 //_____________________________________________________________________
133 AliTRDCalibPadStatus::AliTRDCalibPadStatus(const AliTRDCalibPadStatus &ped) : /*FOLD00*/
136 fAdcMin(ped.GetAdcMin()),
137 fAdcMax(ped.GetAdcMax()),
138 fDetector(ped.fDetector),
139 fNumberOfTimeBins(ped.fNumberOfTimeBins),
140 fCalRocArrayMean(540),
141 fCalRocArrayRMS(540),
142 fCalRocArrayMeand(540),
143 fCalRocArrayRMSd(540),
149 for (Int_t idet = 0; idet < 540; idet++){
150 const AliTRDCalROC *calRocMean = (AliTRDCalROC*)ped.fCalRocArrayMean.UncheckedAt(idet);
151 const AliTRDCalROC *calRocRMS = (AliTRDCalROC*)ped.fCalRocArrayRMS.UncheckedAt(idet);
152 const AliTRDCalROC *calRocMeand = (AliTRDCalROC*)ped.fCalRocArrayMeand.UncheckedAt(idet);
153 const AliTRDCalROC *calRocRMSd = (AliTRDCalROC*)ped.fCalRocArrayRMSd.UncheckedAt(idet);
154 const TH2F *hped = (TH2F*)ped.fHistoArray.UncheckedAt(idet);
156 if ( calRocMean != 0x0 ) fCalRocArrayMean.AddAt(new AliTRDCalROC(*calRocMean), idet);
157 if ( calRocRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTRDCalROC(*calRocRMS), idet);
159 if ( calRocMeand != 0x0 ) fCalRocArrayMeand.AddAt(new AliTRDCalROC(*calRocMeand), idet);
160 if ( calRocRMSd != 0x0 ) fCalRocArrayRMSd.AddAt(new AliTRDCalROC(*calRocRMSd), idet);
163 TH2F *hNew = new TH2F(*hped);
164 hNew->SetDirectory(0);
165 fHistoArray.AddAt(hNew,idet);
172 fGeo = new AliTRDgeometry();
175 //_____________________________________________________________________
176 AliTRDCalibPadStatus& AliTRDCalibPadStatus::operator = (const AliTRDCalibPadStatus &source)
179 // assignment operator
181 if (&source == this) return *this;
182 new (this) AliTRDCalibPadStatus(source);
186 //_____________________________________________________________________
187 AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/
192 fCalRocArrayMean.Delete();
193 fCalRocArrayRMS.Delete();
194 fCalRocArrayMeand.Delete();
195 fCalRocArrayRMSd.Delete();
196 fHistoArray.Delete();
201 //_____________________________________________________________________
202 void AliTRDCalibPadStatus::Destroy()
207 fCalRocArrayMean.Delete();
208 fCalRocArrayRMS.Delete();
209 fCalRocArrayMeand.Delete();
210 fCalRocArrayRMSd.Delete();
211 fHistoArray.Delete();
213 //_____________________________________________________________________
214 Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
223 // Signal filling methode
225 Int_t nbchannel = icRow+icCol*crowMax;
227 // now the case of double read channel
229 nbchannel = (((ccold-1)*8+ icMcm)*crowMax+icRow)+144*crowMax;
230 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
233 // fast filling methode.
234 // Attention: the entry counter of the histogram is not increased
235 // this means that e.g. the colz draw option gives an empty plot
239 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
240 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
242 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
244 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
248 //_____________________________________________________________________
249 Int_t AliTRDCalibPadStatus::UpdateHisto2(const Int_t icdet, /*FOLD00*/
260 // Signal filling methode
262 Int_t nbchannel = icRow+icCol*crowMax;
266 // now the case of double read channel
268 nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax;
269 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
272 // fast filling methode.
273 // Attention: the entry counter of the histogram is not increased
274 // this means that e.g. the colz draw option gives an empty plot
278 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
279 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
281 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
283 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
287 //_____________________________________________________________________
288 Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
291 // Event Processing loop - AliTRDRawStreamCosmic
292 // 0 time bin problem or zero suppression
298 // Raw version number:
299 // [3,31] non zero suppressed
300 // 2,4 and [32,63] zero suppressed
305 rawStream->SetSharedPadReadout(kTRUE);
309 // Check the raw version and if all have the same number of timebins.
311 while (rawStream->Next()) {
313 Int_t rawversion = rawStream->GetRawVersion(); // current raw version
314 //printf("Raw version is %d\n",rawversion);
316 // Could eventually change, have to check with time
317 if((rawversion < 3) || (rawversion > 31)) {
318 AliInfo(Form("this is not no-zero-suppressed data, the version is %d",rawversion));
321 Int_t idetector = rawStream->GetDet(); // current detector
322 Int_t iRow = rawStream->GetRow(); // current row
323 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
324 Int_t iCol = rawStream->GetCol(); // current col
325 Int_t iADC = 21-rawStream->GetADC(); // current ADC
327 // It goes in the opposite direction
329 if(iADC == 1) col = 1;
331 col = TMath::Max(0,(Int_t)(iADC-19));
334 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
335 if(col > 1) mcm -= 1;
336 if(col ==1) mcm += 1;
339 //Bool_t shared = rawStream->IsCurrentPadShared();
340 //printf("ADC %d, iCol %d, col %d, mcm %d, shared %d\n",iADC,iCol,col,mcm,(Int_t)shared);
343 Int_t *signal = rawStream->GetSignals(); // current ADC signal
344 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
346 if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) {
347 AliInfo(Form("the number of time bins is %d, is different from the previous one %d",nbtimebin,fNumberOfTimeBins));
350 fNumberOfTimeBins = nbtimebin;
351 fDetector = idetector;
353 for(Int_t k = 0; k < fNumberOfTimeBins; k++){
354 if(signal[k]>0 && iCol != -1) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
362 while (rawStream->Next()) {
364 Int_t idetector = rawStream->GetDet(); // current detector
365 Int_t iRow = rawStream->GetRow(); // current row
366 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
367 Int_t iCol = rawStream->GetCol(); // current col
368 Int_t iADC = 21-rawStream->GetADC(); // current ADC
370 // It goes in the opposite direction
372 if(iADC == 1) col = 1;
374 col = TMath::Max(0,(Int_t)(iADC-19));
377 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
378 if(col > 1) mcm -= 1;
379 if(col ==1) mcm += 1;
382 Int_t *signal = rawStream->GetSignals(); // current ADC signal
383 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
386 //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]);
388 for(Int_t k = 0; k < nbtimebin; k++){
389 if(signal[k]>0 && iCol != -1) {
390 UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
391 //printf("Update with det %d, row %d, col %d, signal %d, rowmax %d, col %d, mcm %d\n",idetector,iRow,iCol,signal[n],iRowMax,col,mcm);
401 //_____________________________________________________________________
402 Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
405 // Event processing loop - AliRawReader
410 rawReader->Select("TRD");
412 AliTRDrawStreamBase *pstream = AliTRDrawStreamBase::GetRawStream(rawReader);
414 result = ProcessEvent(pstream, nocheck);
421 //_________________________________________________________________________
422 Int_t AliTRDCalibPadStatus::ProcessEvent(
424 const eventHeaderStruct *event,
427 const eventHeaderStruct* /*event*/,
434 // process date event
437 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
438 Bool_t result=ProcessEvent(rawReader, nocheck);
442 Fatal("AliTRDCalibPadStatus", "this class was compiled without DATE");
448 //_____________________________________________________________________
449 Int_t AliTRDCalibPadStatus::ProcessEvent2(AliRawReader *rawReader)
452 // Event Processing loop - AliTRDRawStreamCosmic
453 // 0 time bin problem or zero suppression
456 // Raw version number:
457 // [3,31] non zero suppressed
458 // 2,4 and [32,63] zero suppressed
463 AliTRDrawFastStream *rawStream = new AliTRDrawFastStream(rawReader);
464 rawStream->SetNoErrorWarning();
465 rawStream->SetSharedPadReadout(kTRUE);
467 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
468 digitsManager->CreateArrays();
470 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
473 while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
474 if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
475 // printf("there is ADC data on this chamber!\n");
477 AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
478 if (digits->HasData()) { //array
480 AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
481 if (indexes->IsAllocated() == kFALSE) {
482 AliError("Indexes do not exist!");
487 indexes->ResetCounters();
489 while (indexes->NextRCIndex(iRow, iCol)) { //column,row
492 AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
494 Int_t mcm = 0; // MCM from AliTRDfeeParam
495 Int_t rob = 0; // ROB from AliTRDfeeParam
496 Int_t extCol = 0; // extended column from AliTRDfeeParam
497 mcm = feeParam->GetMCMfromPad(iRow,iCol);
498 rob = feeParam->GetROBfromPad(iRow,iCol);
500 Int_t idetector = det; // current detector
501 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
503 Int_t adc = 20 - (iCol%18) -1; // current adc
504 Int_t col = 0; // col!=0 ->Shared Pad
505 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
506 //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);
508 // Signal for regular pads
509 Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data
510 for(Int_t k = 0; k < nbtimebin; k++){
512 signal = digits->GetData(iRow,iCol,k);
515 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
521 if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) /* && fSharedPadsOn*/ ) { //SHARED PADS
525 adc = 20; //shared Pad adc
526 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
530 adc = 1; //shared Pad adc
531 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
535 adc = 0; //shared Pad adc
536 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
540 rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob
543 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc
545 //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);
546 for(Int_t k = 0; k < nbtimebin; k++){
548 signal = digits->GetDataByAdcCol(iRow,extCol,k);
551 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
562 digitsManager->ClearArrays(det);
564 delete digitsManager;
569 //_____________________________________________________________________
571 Int_t AliTRDCalibPadStatus::ProcessEvent3(AliRawReader *rawReader)
574 // RawReader = AliTRDrawStream (Jochen Klein)
576 // Event Processing loop - AliTRDRawStreamCosmic
577 // 0 time bin problem or zero suppression
580 // Raw version number:
581 // [3,31] non zero suppressed
582 // 2,4 and [32,63] zero suppressed
589 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
590 digitsManager->CreateArrays();
592 AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader);
593 rawStream->SetDigitsManager(digitsManager);
594 //rawStream->SetNoErrorWarning();
595 //rawStream->SetSharedPadReadout(kTRUE);
597 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
600 while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
601 if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
602 // printf("there is ADC data on this chamber!\n");
604 AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
605 if (digits->HasData()) { //array
607 AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
608 if (indexes->IsAllocated() == kFALSE) {
609 AliError("Indexes do not exist!");
614 indexes->ResetCounters();
616 while (indexes->NextRCIndex(iRow, iCol)) { //column,row
618 AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
620 Int_t mcm = 0; // MCM from AliTRDfeeParam
621 Int_t rob = 0; // ROB from AliTRDfeeParam
622 Int_t extCol = 0; // extended column from AliTRDfeeParam
623 mcm = feeParam->GetMCMfromPad(iRow,iCol);
624 rob = feeParam->GetROBfromPad(iRow,iCol);
626 Int_t idetector = det; // current detector
627 Int_t iRowMax = 16; // current rowmax
628 if(GetStack(det) == 2) iRowMax = 12;
630 Int_t adc = 20 - (iCol%18) -1; // current adc
631 Int_t col = 0; // col!=0 ->Shared Pad
632 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
633 //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);
635 // Signal for regular pads
636 Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data
637 for(Int_t k = 0; k < nbtimebin; k++){
639 signal = digits->GetData(iRow,iCol,k);
642 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
648 if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) ) { //SHARED PADS
652 adc = 20; //shared Pad adc
653 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
657 adc = 1; //shared Pad adc
658 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
662 adc = 0; //shared Pad adc
663 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
667 rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob
670 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc
672 //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);
673 for(Int_t k = 0; k < nbtimebin; k++){
675 signal = digits->GetDataByAdcCol(iRow,extCol,k);
678 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
689 digitsManager->ClearArrays(det);
691 delete digitsManager;
698 //_____________________________________________________________________
699 Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm, Int_t ch) /*FOLD00*/
703 // fill one oroc and one iroc with random gaus
708 for (Int_t ism=sm; ism<sm+1; ism++){
709 for (Int_t ich=ch; ich < ch+1; ich++){
710 for (Int_t ipl=0; ipl < 6; ipl++){
711 for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
712 for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
713 for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
714 Int_t signal=TMath::Nint(gRandom->Gaus(10,1.5));
715 if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism),0,0);
725 //_____________________________________________________________________
726 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
727 Int_t nbinsY, Float_t ymin, Float_t ymax,
728 const Char_t *type, Bool_t force)
731 // return pointer to histogram
732 // if force is true create a new histogram if it doesn't exist allready
734 if ( !force || arr->UncheckedAt(det) )
735 return (TH2F*)arr->UncheckedAt(det);
737 // if we are forced and histogram doesn't yes exist create it
738 Char_t name[255], title[255];
740 sprintf(name,"hCalib%s%.3d",type,det);
741 sprintf(title,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
744 Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det));
746 // we will add 3*8*rowMax channels at the end for the double counted
747 nbchannels += 3*8*(fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det)));
750 // new histogram with calib information. One value for each pad!
751 TH2F* hist = new TH2F(name,title,
753 nbchannels,0,nbchannels
755 hist->SetDirectory(0);
756 arr->AddAt(hist,det);
760 //_____________________________________________________________________
761 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/
764 // return pointer to histogram
765 // if force is true create a new histogram if it doesn't exist allready
767 TObjArray *arr = &fHistoArray;
768 return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin-0.5, fAdcMax-0.5, "Pedestal", force);
771 //_____________________________________________________________________
772 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/
775 // return pointer to ROC Calibration
776 // if force is true create a new AliTRDCalROC if it doesn't exist allready
778 if ( !force || arr->UncheckedAt(det) )
779 return (AliTRDCalROC*)arr->UncheckedAt(det);
781 // if we are forced and histogram doesn't yes exist create it
783 // new AliTRDCalROC. One value for each pad!
784 AliTRDCalROC *croc = new AliTRDCalROC(GetLayer(det),GetStack(det));
785 arr->AddAt(croc,det);
788 //_____________________________________________________________________
789 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOLD00*/
792 // return pointer to Carge ROC Calibration
793 // if force is true create a new histogram if it doesn't exist allready
795 TObjArray *arr = &fCalRocArrayMean;
796 return GetCalRoc(det, arr, force);
799 //_____________________________________________________________________
800 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD00*/
803 // return pointer to Carge ROC Calibration
804 // if force is true create a new histogram if it doesn't exist allready
806 TObjArray *arr = &fCalRocArrayRMS;
807 return GetCalRoc(det, arr, force);
809 //_____________________________________________________________________
810 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMeand(Int_t det, Bool_t force) /*FOLD00*/
813 // return pointer to Carge ROC Calibration
814 // if force is true create a new histogram if it doesn't exist allready
816 TObjArray *arr = &fCalRocArrayMeand;
817 return GetCalRoc(det, arr, force);
820 //_____________________________________________________________________
821 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMSd(Int_t det, Bool_t force) /*FOLD00*/
824 // return pointer to Carge ROC Calibration
825 // if force is true create a new histogram if it doesn't exist allready
827 TObjArray *arr = &fCalRocArrayRMSd;
828 return GetCalRoc(det, arr, force);
831 //_____________________________________________________________________
832 void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
835 // Calculate calibration constants
838 Int_t nbinsAdc = fAdcMax-fAdcMin;
846 for (Int_t idet=0; idet<540; idet++){
847 TH2F *hP = GetHisto(idet);
852 //printf("Entries for %d\n",idet);
854 AliTRDCalROC *rocMean = GetCalRocMean(idet,kTRUE);
855 AliTRDCalROC *rocRMS = GetCalRocRMS(idet,kTRUE);
857 arrayHP = hP->GetArray();
858 Int_t nChannels = rocMean->GetNchannels();
860 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
861 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
862 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
863 // if the fitting failed set noise and pedestal to 0
864 if ((ret==-4) || (ret==-1) || (ret==-2)) {
868 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
869 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
870 rocMean->SetValue(iChannel,param[1]/10.0);
871 rocRMS->SetValue(iChannel,param[2]/10.0);
874 // here we analyse doubled read channels
876 AliTRDCalROC *rocMeand = GetCalRocMeand(idet,kTRUE);
877 AliTRDCalROC *rocRMSd = GetCalRocRMSd(idet,kTRUE);
879 Int_t nrows = rocMeand->GetNrows();
880 Int_t shift = 144*nrows;
881 Int_t total = shift+3*8*nrows;
883 for (Int_t iChannel=shift; iChannel<total; iChannel++){
884 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
885 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
886 // if the fitting failed set noise and pedestal to 0
887 if ((ret==-4) || (ret==-1) || (ret==-2)) {
891 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
892 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
894 // here we have to recalculate backward
895 Int_t nb = iChannel-shift;
896 Int_t row = nb%nrows;
897 Int_t j = (Int_t)(nb/nrows);
899 Int_t icol = (Int_t)(j/8);
901 Int_t finalcol = 18*imcm;
902 if(icol > 0) icol += 17;
906 Int_t channel = row+finalcol*nrows;
908 //printf("iChannel %d, nrows %d, finalcol %d, row %d, channel %d\n",iChannel,nrows,finalcol,row,channel);
909 if((finalcol < 0) || (finalcol >= 144)) continue;
911 rocMeand->SetValue(channel,param[1]/10.0);
912 rocRMSd->SetValue(channel,param[2]/10.0);
919 //_______________________________________________________________________________________
920 AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
923 // Create Pad Status out of Mean and RMS values
924 // The chamber without data are masked, this is the corrected in the preprocessor
927 AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus");
929 for (Int_t idet=0; idet<540; ++idet)
931 AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet);
934 if ( !GetCalRocMean(idet)) {
935 for(Int_t k = 0; k < calROC->GetNchannels(); k++){
936 calROC->SetStatus(k,AliTRDCalPadStatus::kNotConnected);
943 AliTRDCalROC *calRocMean = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMean(idet)));
944 AliTRDCalROC *calRocRMS = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMS(idet)));
946 //Take the stuff second chance
947 AliTRDCalROC *calRocMeand = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMeand(idet)));
948 AliTRDCalROC *calRocRMSd = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMSd(idet)));
951 calRocRMSd->Unfold();
955 Int_t row = calROC->GetNrows();
956 Int_t col = calROC->GetNcols();
958 Double_t rmsmean = calRocMean->GetRMS()*10.0;
959 Double_t meanmean = calRocMean->GetMean()*10.0;
960 Double_t meansquares = calRocRMS->GetMean();
963 for(Int_t irow = 0; irow < row; irow++){
966 Float_t meanprevious = 0.0;
967 Float_t rmsprevious = 0.0;
971 for(Int_t icol = 0; icol < col; icol++){
973 mean = calRocMean->GetValue(icol,irow)*10.0;
974 rms = calRocRMS->GetValue(icol,irow);
977 meanprevious = calRocMean->GetValue((icol -1),irow)*10.0;
978 rmsprevious = calRocRMS->GetValue((icol - 1),irow);
982 // masked if two noisy
983 if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) {
986 // look at second chance
987 Float_t meand = calRocMeand->GetValue(icol,irow)*10.0;
988 Float_t rmsd = calRocRMSd->GetValue(icol,irow);
990 if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) {
991 if((rmsd <= 0.0001) && (rms <= 0.0001)) {
992 calROC->SetStatus(icol,irow,AliTRDCalPadStatus::kNotConnected);
995 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kMasked);
999 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kReadSecond);
1004 // bridge if previous pad found something
1006 if((meanprevious == mean) && (rmsprevious == rms) && (mean > 0.0001)) {
1007 //printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol);
1008 calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight);
1009 calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft);
1027 //_______________________________________________________________________________________
1028 AliTRDCalPad* AliTRDCalibPadStatus::CreateCalPad()
1031 // Create Pad Noise out of RMS values
1034 AliTRDCalPad* obj = new AliTRDCalPad("PadNoise", "PadNoise");
1037 for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) {
1039 AliTRDCalROC *calROC22 = obj->GetCalROC(det);
1041 AliTRDCalROC *calRocRMS = ((AliTRDCalROC *)GetCalRocRMS(det,kTRUE));
1043 for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
1044 calROC22->SetValue(k,calRocRMS->GetValue(k));
1053 //_______________________________________________________________________________________
1054 AliTRDCalDet* AliTRDCalibPadStatus::CreateCalDet() const
1057 // Create Det Noise correction factor
1060 AliTRDCalDet* obj = new AliTRDCalDet("DetNoise", "DetNoise (correction factor)");
1062 for(Int_t l = 0; l < 540; l++){
1063 obj->SetValue(l,10.0);
1070 //_____________________________________________________________________
1071 void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
1074 // Write class to file
1083 option = "recreate";
1085 TDirectory *backup = gDirectory;
1086 TFile f(filename,option.Data());
1088 if ( !sDir.IsNull() ){
1089 f.mkdir(sDir.Data());
1095 if ( backup ) backup->cd();
1098 //_____________________________________________________________________
1099 void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
1102 // Put the AliTRDCalROC in the array fCalRocArrayMean
1106 AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE);
1108 Int_t nChannels = rocMean->GetNchannels();
1110 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1112 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
1118 //_____________________________________________________________________
1119 void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
1122 // Put the AliTRDCalROC in the array fCalRocArrayRMS
1126 AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE);
1128 Int_t nChannels = rocRms->GetNchannels();
1130 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1132 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1137 //_____________________________________________________________________
1138 void AliTRDCalibPadStatus::SetCalRocMeand(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
1141 // Put the AliTRDCalROC in the array fCalRocArrayMean
1145 AliTRDCalROC *rocMean = GetCalRocMeand(det,kTRUE);
1147 Int_t nChannels = rocMean->GetNchannels();
1149 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1151 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
1157 //_____________________________________________________________________
1158 void AliTRDCalibPadStatus::SetCalRocRMSd(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
1161 // Put the AliTRDCalROC in the array fCalRocArrayRMS
1165 AliTRDCalROC *rocRms = GetCalRocRMSd(det,kTRUE);
1167 Int_t nChannels = rocRms->GetNchannels();
1169 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1171 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1176 //_____________________________________________________________________________
1177 Int_t AliTRDCalibPadStatus::GetLayer(Int_t d) const
1180 // Reconstruct the layer number from the detector number
1183 return ((Int_t) (d % 6));
1187 //_____________________________________________________________________________
1188 Int_t AliTRDCalibPadStatus::GetStack(Int_t d) const
1191 // Reconstruct the chamber number from the detector number
1194 return ((Int_t) (d % 30) / 6);
1198 //_____________________________________________________________________________
1199 Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const
1202 // Reconstruct the sector number from the detector number
1205 return ((Int_t) (d / 30));