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"
106 ClassImp(AliTRDCalibPadStatus) /*FOLD00*/
108 //_____________________________________________________________________
109 AliTRDCalibPadStatus::AliTRDCalibPadStatus() : /*FOLD00*/
115 fNumberOfTimeBins(0),
116 fCalRocArrayMean(540),
117 fCalRocArrayRMS(540),
118 fCalRocArrayMeand(540),
119 fCalRocArrayRMSd(540),
123 // default constructor
126 fGeo = new AliTRDgeometry();
130 //_____________________________________________________________________
131 AliTRDCalibPadStatus::AliTRDCalibPadStatus(const AliTRDCalibPadStatus &ped) : /*FOLD00*/
134 fAdcMin(ped.GetAdcMin()),
135 fAdcMax(ped.GetAdcMax()),
136 fDetector(ped.fDetector),
137 fNumberOfTimeBins(ped.fNumberOfTimeBins),
138 fCalRocArrayMean(540),
139 fCalRocArrayRMS(540),
140 fCalRocArrayMeand(540),
141 fCalRocArrayRMSd(540),
147 for (Int_t idet = 0; idet < 540; idet++){
148 const AliTRDCalROC *calRocMean = (AliTRDCalROC*)ped.fCalRocArrayMean.UncheckedAt(idet);
149 const AliTRDCalROC *calRocRMS = (AliTRDCalROC*)ped.fCalRocArrayRMS.UncheckedAt(idet);
150 const AliTRDCalROC *calRocMeand = (AliTRDCalROC*)ped.fCalRocArrayMeand.UncheckedAt(idet);
151 const AliTRDCalROC *calRocRMSd = (AliTRDCalROC*)ped.fCalRocArrayRMSd.UncheckedAt(idet);
152 const TH2F *hped = (TH2F*)ped.fHistoArray.UncheckedAt(idet);
154 if ( calRocMean != 0x0 ) fCalRocArrayMean.AddAt(new AliTRDCalROC(*calRocMean), idet);
155 if ( calRocRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTRDCalROC(*calRocRMS), idet);
157 if ( calRocMeand != 0x0 ) fCalRocArrayMeand.AddAt(new AliTRDCalROC(*calRocMeand), idet);
158 if ( calRocRMSd != 0x0 ) fCalRocArrayRMSd.AddAt(new AliTRDCalROC(*calRocRMSd), idet);
161 TH2F *hNew = new TH2F(*hped);
162 hNew->SetDirectory(0);
163 fHistoArray.AddAt(hNew,idet);
170 fGeo = new AliTRDgeometry();
173 //_____________________________________________________________________
174 AliTRDCalibPadStatus& AliTRDCalibPadStatus::operator = (const AliTRDCalibPadStatus &source)
177 // assignment operator
179 if (&source == this) return *this;
180 new (this) AliTRDCalibPadStatus(source);
184 //_____________________________________________________________________
185 AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/
190 fCalRocArrayMean.Delete();
191 fCalRocArrayRMS.Delete();
192 fCalRocArrayMeand.Delete();
193 fCalRocArrayRMSd.Delete();
194 fHistoArray.Delete();
199 //_____________________________________________________________________
200 void AliTRDCalibPadStatus::Destroy()
205 fCalRocArrayMean.Delete();
206 fCalRocArrayRMS.Delete();
207 fCalRocArrayMeand.Delete();
208 fCalRocArrayRMSd.Delete();
209 fHistoArray.Delete();
211 //_____________________________________________________________________
212 Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
221 // Signal filling methode
223 Int_t nbchannel = icRow+icCol*crowMax;
225 // now the case of double read channel
227 nbchannel = (((ccold-1)*8+ icMcm)*crowMax+icRow)+144*crowMax;
228 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
231 // fast filling methode.
232 // Attention: the entry counter of the histogram is not increased
233 // this means that e.g. the colz draw option gives an empty plot
237 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
238 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
240 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
242 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
246 //_____________________________________________________________________
247 Int_t AliTRDCalibPadStatus::UpdateHisto2(const Int_t icdet, /*FOLD00*/
258 // Signal filling methode
260 Int_t nbchannel = icRow+icCol*crowMax;
264 // now the case of double read channel
266 nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax;
267 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
270 // fast filling methode.
271 // Attention: the entry counter of the histogram is not increased
272 // this means that e.g. the colz draw option gives an empty plot
276 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
277 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
279 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
281 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
285 //_____________________________________________________________________
286 Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
289 // Event Processing loop - AliTRDRawStreamCosmic
290 // 0 time bin problem or zero suppression
296 // Raw version number:
297 // [3,31] non zero suppressed
298 // 2,4 and [32,63] zero suppressed
303 rawStream->SetSharedPadReadout(kTRUE);
307 // Check the raw version and if all have the same number of timebins.
309 while (rawStream->Next()) {
311 Int_t rawversion = rawStream->GetRawVersion(); // current raw version
312 //printf("Raw version is %d\n",rawversion);
314 // Could eventually change, have to check with time
315 if((rawversion < 3) || (rawversion > 31)) {
316 AliInfo(Form("this is not no-zero-suppressed data, the version is %d",rawversion));
319 Int_t idetector = rawStream->GetDet(); // current detector
320 Int_t iRow = rawStream->GetRow(); // current row
321 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
322 Int_t iCol = rawStream->GetCol(); // current col
323 Int_t iADC = 21-rawStream->GetADC(); // current ADC
325 // It goes in the opposite direction
327 if(iADC == 1) col = 1;
329 col = TMath::Max(0,(Int_t)(iADC-19));
332 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
333 if(col > 1) mcm -= 1;
334 if(col ==1) mcm += 1;
337 //Bool_t shared = rawStream->IsCurrentPadShared();
338 //printf("ADC %d, iCol %d, col %d, mcm %d, shared %d\n",iADC,iCol,col,mcm,(Int_t)shared);
341 Int_t *signal = rawStream->GetSignals(); // current ADC signal
342 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
344 if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) {
345 AliInfo(Form("the number of time bins is %d, is different from the previous one %d",nbtimebin,fNumberOfTimeBins));
348 fNumberOfTimeBins = nbtimebin;
349 fDetector = idetector;
351 for(Int_t k = 0; k < fNumberOfTimeBins; k++){
352 if(signal[k]>0 && iCol != -1) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
360 while (rawStream->Next()) {
362 Int_t idetector = rawStream->GetDet(); // current detector
363 Int_t iRow = rawStream->GetRow(); // current row
364 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
365 Int_t iCol = rawStream->GetCol(); // current col
366 Int_t iADC = 21-rawStream->GetADC(); // current ADC
368 // It goes in the opposite direction
370 if(iADC == 1) col = 1;
372 col = TMath::Max(0,(Int_t)(iADC-19));
375 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
376 if(col > 1) mcm -= 1;
377 if(col ==1) mcm += 1;
380 Int_t *signal = rawStream->GetSignals(); // current ADC signal
381 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
384 //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]);
386 for(Int_t k = 0; k < nbtimebin; k++){
387 if(signal[k]>0 && iCol != -1) {
388 UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
389 //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);
399 //_____________________________________________________________________
400 Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
403 // Event processing loop - AliRawReader
408 rawReader->Select("TRD");
410 AliTRDrawStreamBase *pstream = AliTRDrawStreamBase::GetRawStream(rawReader);
412 result = ProcessEvent(pstream, nocheck);
419 //_________________________________________________________________________
420 Int_t AliTRDCalibPadStatus::ProcessEvent(
422 const eventHeaderStruct *event,
425 const eventHeaderStruct* /*event*/,
432 // process date event
435 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
436 Bool_t result=ProcessEvent(rawReader, nocheck);
440 Fatal("AliTRDCalibPadStatus", "this class was compiled without DATE");
446 //_____________________________________________________________________
447 Int_t AliTRDCalibPadStatus::ProcessEvent2(AliRawReader *rawReader)
450 // Event Processing loop - AliTRDRawStreamCosmic
451 // 0 time bin problem or zero suppression
454 // Raw version number:
455 // [3,31] non zero suppressed
456 // 2,4 and [32,63] zero suppressed
461 AliTRDrawFastStream *rawStream = new AliTRDrawFastStream(rawReader);
462 rawStream->SetNoErrorWarning();
463 rawStream->SetSharedPadReadout(kTRUE);
465 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
466 digitsManager->CreateArrays();
468 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
471 while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
472 if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
473 // printf("there is ADC data on this chamber!\n");
475 AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
476 if (digits->HasData()) { //array
478 AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
479 if (indexes->IsAllocated() == kFALSE) {
480 AliError("Indexes do not exist!");
485 indexes->ResetCounters();
487 while (indexes->NextRCIndex(iRow, iCol)) { //column,row
490 AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
492 Int_t mcm = 0; // MCM from AliTRDfeeParam
493 Int_t rob = 0; // ROB from AliTRDfeeParam
494 Int_t extCol = 0; // extended column from AliTRDfeeParam
495 mcm = feeParam->GetMCMfromPad(iRow,iCol);
496 rob = feeParam->GetROBfromPad(iRow,iCol);
498 Int_t idetector = det; // current detector
499 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
501 Int_t adc = 20 - (iCol%18) -1; // current adc
502 Int_t col = 0; // col!=0 ->Shared Pad
503 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
504 //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);
506 // Signal for regular pads
507 Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data
508 for(Int_t k = 0; k < nbtimebin; k++){
510 signal = digits->GetData(iRow,iCol,k);
513 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
519 if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) /* && fSharedPadsOn*/ ) { //SHARED PADS
523 adc = 20; //shared Pad adc
524 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
528 adc = 1; //shared Pad adc
529 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
533 adc = 0; //shared Pad adc
534 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
538 rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob
541 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc
543 //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);
544 for(Int_t k = 0; k < nbtimebin; k++){
546 signal = digits->GetDataByAdcCol(iRow,extCol,k);
549 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
560 digitsManager->ClearArrays(det);
562 delete digitsManager;
567 //_____________________________________________________________________
568 Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm, Int_t ch) /*FOLD00*/
572 // fill one oroc and one iroc with random gaus
577 for (Int_t ism=sm; ism<sm+1; ism++){
578 for (Int_t ich=ch; ich < ch+1; ich++){
579 for (Int_t ipl=0; ipl < 6; ipl++){
580 for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
581 for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
582 for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
583 Int_t signal=TMath::Nint(gRandom->Gaus(10,1.5));
584 if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism),0,0);
594 //_____________________________________________________________________
595 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
596 Int_t nbinsY, Float_t ymin, Float_t ymax,
597 const Char_t *type, Bool_t force)
600 // return pointer to histogram
601 // if force is true create a new histogram if it doesn't exist allready
603 if ( !force || arr->UncheckedAt(det) )
604 return (TH2F*)arr->UncheckedAt(det);
606 // if we are forced and histogram doesn't yes exist create it
607 Char_t name[255], title[255];
609 sprintf(name,"hCalib%s%.3d",type,det);
610 sprintf(title,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
613 Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det));
615 // we will add 3*8*rowMax channels at the end for the double counted
616 nbchannels += 3*8*(fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det)));
619 // new histogram with calib information. One value for each pad!
620 TH2F* hist = new TH2F(name,title,
622 nbchannels,0,nbchannels
624 hist->SetDirectory(0);
625 arr->AddAt(hist,det);
629 //_____________________________________________________________________
630 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/
633 // return pointer to histogram
634 // if force is true create a new histogram if it doesn't exist allready
636 TObjArray *arr = &fHistoArray;
637 return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin-0.5, fAdcMax-0.5, "Pedestal", force);
640 //_____________________________________________________________________
641 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/
644 // return pointer to ROC Calibration
645 // if force is true create a new AliTRDCalROC if it doesn't exist allready
647 if ( !force || arr->UncheckedAt(det) )
648 return (AliTRDCalROC*)arr->UncheckedAt(det);
650 // if we are forced and histogram doesn't yes exist create it
652 // new AliTRDCalROC. One value for each pad!
653 AliTRDCalROC *croc = new AliTRDCalROC(GetLayer(det),GetStack(det));
654 arr->AddAt(croc,det);
657 //_____________________________________________________________________
658 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOLD00*/
661 // return pointer to Carge ROC Calibration
662 // if force is true create a new histogram if it doesn't exist allready
664 TObjArray *arr = &fCalRocArrayMean;
665 return GetCalRoc(det, arr, force);
668 //_____________________________________________________________________
669 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD00*/
672 // return pointer to Carge ROC Calibration
673 // if force is true create a new histogram if it doesn't exist allready
675 TObjArray *arr = &fCalRocArrayRMS;
676 return GetCalRoc(det, arr, force);
678 //_____________________________________________________________________
679 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMeand(Int_t det, Bool_t force) /*FOLD00*/
682 // return pointer to Carge ROC Calibration
683 // if force is true create a new histogram if it doesn't exist allready
685 TObjArray *arr = &fCalRocArrayMeand;
686 return GetCalRoc(det, arr, force);
689 //_____________________________________________________________________
690 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMSd(Int_t det, Bool_t force) /*FOLD00*/
693 // return pointer to Carge ROC Calibration
694 // if force is true create a new histogram if it doesn't exist allready
696 TObjArray *arr = &fCalRocArrayRMSd;
697 return GetCalRoc(det, arr, force);
700 //_____________________________________________________________________
701 void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
704 // Calculate calibration constants
707 Int_t nbinsAdc = fAdcMax-fAdcMin;
715 for (Int_t idet=0; idet<540; idet++){
716 TH2F *hP = GetHisto(idet);
721 //printf("Entries for %d\n",idet);
723 AliTRDCalROC *rocMean = GetCalRocMean(idet,kTRUE);
724 AliTRDCalROC *rocRMS = GetCalRocRMS(idet,kTRUE);
726 arrayHP = hP->GetArray();
727 Int_t nChannels = rocMean->GetNchannels();
729 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
730 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
731 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
732 // if the fitting failed set noise and pedestal to 0
733 if ((ret==-4) || (ret==-1) || (ret==-2)) {
737 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
738 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
739 rocMean->SetValue(iChannel,param[1]/10.0);
740 rocRMS->SetValue(iChannel,param[2]/10.0);
743 // here we analyse doubled read channels
745 AliTRDCalROC *rocMeand = GetCalRocMeand(idet,kTRUE);
746 AliTRDCalROC *rocRMSd = GetCalRocRMSd(idet,kTRUE);
748 Int_t nrows = rocMeand->GetNrows();
749 Int_t shift = 144*nrows;
750 Int_t total = shift+3*8*nrows;
752 for (Int_t iChannel=shift; iChannel<total; iChannel++){
753 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
754 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
755 // if the fitting failed set noise and pedestal to 0
756 if ((ret==-4) || (ret==-1) || (ret==-2)) {
760 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
761 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
763 // here we have to recalculate backward
764 Int_t nb = iChannel-shift;
765 Int_t row = nb%nrows;
766 Int_t j = (Int_t)(nb/nrows);
768 Int_t icol = (Int_t)(j/8);
770 Int_t finalcol = 18*imcm;
771 if(icol > 0) icol += 17;
775 Int_t channel = row+finalcol*nrows;
777 //printf("iChannel %d, nrows %d, finalcol %d, row %d, channel %d\n",iChannel,nrows,finalcol,row,channel);
778 if((finalcol < 0) || (finalcol >= 144)) continue;
780 rocMeand->SetValue(channel,param[1]/10.0);
781 rocRMSd->SetValue(channel,param[2]/10.0);
788 //_______________________________________________________________________________________
789 AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
792 // Create Pad Status out of Mean and RMS values
793 // The chamber without data are masked, this is the corrected in the preprocessor
796 AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus");
798 for (Int_t idet=0; idet<540; ++idet)
800 AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet);
803 if ( !GetCalRocMean(idet)) {
804 for(Int_t k = 0; k < calROC->GetNchannels(); k++){
805 calROC->SetStatus(k,AliTRDCalPadStatus::kNotConnected);
812 AliTRDCalROC *calRocMean = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMean(idet)));
813 AliTRDCalROC *calRocRMS = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMS(idet)));
815 //Take the stuff second chance
816 AliTRDCalROC *calRocMeand = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMeand(idet)));
817 AliTRDCalROC *calRocRMSd = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMSd(idet)));
820 calRocRMSd->Unfold();
824 Int_t row = calROC->GetNrows();
825 Int_t col = calROC->GetNcols();
827 Double_t rmsmean = calRocMean->GetRMS()*10.0;
828 Double_t meanmean = calRocMean->GetMean()*10.0;
829 Double_t meansquares = calRocRMS->GetMean();
832 for(Int_t irow = 0; irow < row; irow++){
835 Float_t meanprevious = 0.0;
836 Float_t rmsprevious = 0.0;
840 for(Int_t icol = 0; icol < col; icol++){
842 mean = calRocMean->GetValue(icol,irow)*10.0;
843 rms = calRocRMS->GetValue(icol,irow);
846 meanprevious = calRocMean->GetValue((icol -1),irow)*10.0;
847 rmsprevious = calRocRMS->GetValue((icol - 1),irow);
851 // masked if two noisy
852 if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) {
855 // look at second chance
856 Float_t meand = calRocMeand->GetValue(icol,irow)*10.0;
857 Float_t rmsd = calRocRMSd->GetValue(icol,irow);
859 if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) {
860 if((rmsd <= 0.0001) && (rms <= 0.0001)) {
861 calROC->SetStatus(icol,irow,AliTRDCalPadStatus::kNotConnected);
864 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kMasked);
868 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kReadSecond);
873 // bridge if previous pad found something
875 if((meanprevious == mean) && (rmsprevious == rms) && (mean > 0.0001)) {
876 //printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol);
877 calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight);
878 calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft);
896 //_______________________________________________________________________________________
897 AliTRDCalPad* AliTRDCalibPadStatus::CreateCalPad()
900 // Create Pad Noise out of RMS values
903 AliTRDCalPad* obj = new AliTRDCalPad("PadNoise", "PadNoise");
906 for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) {
908 AliTRDCalROC *calROC22 = obj->GetCalROC(det);
910 AliTRDCalROC *calRocRMS = ((AliTRDCalROC *)GetCalRocRMS(det,kTRUE));
912 for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
913 calROC22->SetValue(k,calRocRMS->GetValue(k));
922 //_______________________________________________________________________________________
923 AliTRDCalDet* AliTRDCalibPadStatus::CreateCalDet() const
926 // Create Det Noise correction factor
929 AliTRDCalDet* obj = new AliTRDCalDet("DetNoise", "DetNoise (correction factor)");
931 for(Int_t l = 0; l < 540; l++){
932 obj->SetValue(l,10.0);
939 //_____________________________________________________________________
940 void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
943 // Write class to file
954 TDirectory *backup = gDirectory;
955 TFile f(filename,option.Data());
957 if ( !sDir.IsNull() ){
958 f.mkdir(sDir.Data());
964 if ( backup ) backup->cd();
967 //_____________________________________________________________________
968 void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
971 // Put the AliTRDCalROC in the array fCalRocArrayMean
975 AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE);
977 Int_t nChannels = rocMean->GetNchannels();
979 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
981 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
987 //_____________________________________________________________________
988 void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
991 // Put the AliTRDCalROC in the array fCalRocArrayRMS
995 AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE);
997 Int_t nChannels = rocRms->GetNchannels();
999 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1001 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1006 //_____________________________________________________________________
1007 void AliTRDCalibPadStatus::SetCalRocMeand(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
1010 // Put the AliTRDCalROC in the array fCalRocArrayMean
1014 AliTRDCalROC *rocMean = GetCalRocMeand(det,kTRUE);
1016 Int_t nChannels = rocMean->GetNchannels();
1018 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1020 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
1026 //_____________________________________________________________________
1027 void AliTRDCalibPadStatus::SetCalRocRMSd(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
1030 // Put the AliTRDCalROC in the array fCalRocArrayRMS
1034 AliTRDCalROC *rocRms = GetCalRocRMSd(det,kTRUE);
1036 Int_t nChannels = rocRms->GetNchannels();
1038 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1040 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1045 //_____________________________________________________________________________
1046 Int_t AliTRDCalibPadStatus::GetLayer(Int_t d) const
1049 // Reconstruct the layer number from the detector number
1052 return ((Int_t) (d % 6));
1056 //_____________________________________________________________________________
1057 Int_t AliTRDCalibPadStatus::GetStack(Int_t d) const
1060 // Reconstruct the chamber number from the detector number
1063 return ((Int_t) (d % 30) / 6);
1067 //_____________________________________________________________________________
1068 Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const
1071 // Reconstruct the sector number from the detector number
1074 return ((Int_t) (d / 30));