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 "AliTRDdigitsManager.h"
95 #include "AliTRDdigitsParam.h"
96 #include "AliTRDSignalIndex.h"
97 #include "AliTRDarraySignal.h"
98 #include "AliTRDarrayADC.h"
99 #include "AliTRDfeeParam.h"
101 #include "AliTRDrawStream.h"
107 ClassImp(AliTRDCalibPadStatus) /*FOLD00*/
109 //_____________________________________________________________________
110 AliTRDCalibPadStatus::AliTRDCalibPadStatus() : /*FOLD00*/
116 fNumberOfTimeBins(0),
117 fCalRocArrayMean(540),
118 fCalRocArrayRMS(540),
119 fCalRocArrayMeand(540),
120 fCalRocArrayRMSd(540),
124 // default constructor
127 fGeo = new AliTRDgeometry();
131 //_____________________________________________________________________
132 AliTRDCalibPadStatus::AliTRDCalibPadStatus(const AliTRDCalibPadStatus &ped) : /*FOLD00*/
135 fAdcMin(ped.GetAdcMin()),
136 fAdcMax(ped.GetAdcMax()),
137 fDetector(ped.fDetector),
138 fNumberOfTimeBins(ped.fNumberOfTimeBins),
139 fCalRocArrayMean(540),
140 fCalRocArrayRMS(540),
141 fCalRocArrayMeand(540),
142 fCalRocArrayRMSd(540),
148 for (Int_t idet = 0; idet < 540; idet++){
149 const AliTRDCalROC *calRocMean = (AliTRDCalROC*)ped.fCalRocArrayMean.UncheckedAt(idet);
150 const AliTRDCalROC *calRocRMS = (AliTRDCalROC*)ped.fCalRocArrayRMS.UncheckedAt(idet);
151 const AliTRDCalROC *calRocMeand = (AliTRDCalROC*)ped.fCalRocArrayMeand.UncheckedAt(idet);
152 const AliTRDCalROC *calRocRMSd = (AliTRDCalROC*)ped.fCalRocArrayRMSd.UncheckedAt(idet);
153 const TH2F *hped = (TH2F*)ped.fHistoArray.UncheckedAt(idet);
155 if ( calRocMean != 0x0 ) fCalRocArrayMean.AddAt(new AliTRDCalROC(*calRocMean), idet);
156 if ( calRocRMS != 0x0 ) fCalRocArrayRMS.AddAt(new AliTRDCalROC(*calRocRMS), idet);
158 if ( calRocMeand != 0x0 ) fCalRocArrayMeand.AddAt(new AliTRDCalROC(*calRocMeand), idet);
159 if ( calRocRMSd != 0x0 ) fCalRocArrayRMSd.AddAt(new AliTRDCalROC(*calRocRMSd), idet);
162 TH2F *hNew = new TH2F(*hped);
163 hNew->SetDirectory(0);
164 fHistoArray.AddAt(hNew,idet);
171 fGeo = new AliTRDgeometry();
174 //_____________________________________________________________________
175 AliTRDCalibPadStatus& AliTRDCalibPadStatus::operator = (const AliTRDCalibPadStatus &source)
178 // assignment operator
180 if (&source == this) return *this;
181 new (this) AliTRDCalibPadStatus(source);
185 //_____________________________________________________________________
186 AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/
191 fCalRocArrayMean.Delete();
192 fCalRocArrayRMS.Delete();
193 fCalRocArrayMeand.Delete();
194 fCalRocArrayRMSd.Delete();
195 fHistoArray.Delete();
200 //_____________________________________________________________________
201 void AliTRDCalibPadStatus::Destroy()
206 fCalRocArrayMean.Delete();
207 fCalRocArrayRMS.Delete();
208 fCalRocArrayMeand.Delete();
209 fCalRocArrayRMSd.Delete();
210 fHistoArray.Delete();
212 //_____________________________________________________________________
213 Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/
222 // Signal filling methode
224 Int_t nbchannel = icRow+icCol*crowMax;
226 // now the case of double read channel
228 nbchannel = (((ccold-1)*8+ icMcm)*crowMax+icRow)+144*crowMax;
229 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
232 // fast filling methode.
233 // Attention: the entry counter of the histogram is not increased
234 // this means that e.g. the colz draw option gives an empty plot
238 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
239 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
241 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
243 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
247 //_____________________________________________________________________
248 Int_t AliTRDCalibPadStatus::UpdateHisto2(const Int_t icdet, /*FOLD00*/
259 // Signal filling methode
261 Int_t nbchannel = icRow+icCol*crowMax;
265 // now the case of double read channel
267 nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax;
268 //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow);
271 // fast filling methode.
272 // Attention: the entry counter of the histogram is not increased
273 // this means that e.g. the colz draw option gives an empty plot
277 if ( !(((Int_t)csignal>=fAdcMax ) || ((Int_t)csignal<fAdcMin)) )
278 bin = (nbchannel+1)*(fAdcMax-fAdcMin+2)+((Int_t)csignal-fAdcMin+1);
280 //GetHisto(icdet,kTRUE)->Fill(csignal,nbchannel);
282 GetHisto(icdet,kTRUE)->GetArray()[bin]++;
286 //_____________________________________________________________________
287 Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
290 // Event Processing loop - AliTRDRawStreamCosmic
291 // 0 time bin problem or zero suppression
297 // Raw version number:
298 // [3,31] non zero suppressed
299 // 2,4 and [32,63] zero suppressed
304 rawStream->SetSharedPadReadout(kTRUE);
308 // Check the raw version and if all have the same number of timebins.
310 while (rawStream->Next()) {
312 Int_t rawversion = rawStream->GetRawVersion(); // current raw version
313 //printf("Raw version is %d\n",rawversion);
315 // Could eventually change, have to check with time
316 if((rawversion < 3) || (rawversion > 31)) {
317 AliInfo(Form("this is not no-zero-suppressed data, the version is %d",rawversion));
320 Int_t idetector = rawStream->GetDet(); // current detector
321 Int_t iRow = rawStream->GetRow(); // current row
322 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
323 Int_t iCol = rawStream->GetCol(); // current col
324 Int_t iADC = 21-rawStream->GetADC(); // current ADC
326 // It goes in the opposite direction
328 if(iADC == 1) col = 1;
330 col = TMath::Max(0,(Int_t)(iADC-19));
333 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
334 if(col > 1) mcm -= 1;
335 if(col ==1) mcm += 1;
338 //Bool_t shared = rawStream->IsCurrentPadShared();
339 //printf("ADC %d, iCol %d, col %d, mcm %d, shared %d\n",iADC,iCol,col,mcm,(Int_t)shared);
342 Int_t *signal = rawStream->GetSignals(); // current ADC signal
343 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
345 if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) {
346 AliInfo(Form("the number of time bins is %d, is different from the previous one %d",nbtimebin,fNumberOfTimeBins));
349 fNumberOfTimeBins = nbtimebin;
350 fDetector = idetector;
352 for(Int_t k = 0; k < fNumberOfTimeBins; k++){
353 if(signal[k]>0 && iCol != -1) UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
361 while (rawStream->Next()) {
363 Int_t idetector = rawStream->GetDet(); // current detector
364 Int_t iRow = rawStream->GetRow(); // current row
365 Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax
366 Int_t iCol = rawStream->GetCol(); // current col
367 Int_t iADC = 21-rawStream->GetADC(); // current ADC
369 // It goes in the opposite direction
371 if(iADC == 1) col = 1;
373 col = TMath::Max(0,(Int_t)(iADC-19));
376 Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads
377 if(col > 1) mcm -= 1;
378 if(col ==1) mcm += 1;
381 Int_t *signal = rawStream->GetSignals(); // current ADC signal
382 Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
385 //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]);
387 for(Int_t k = 0; k < nbtimebin; k++){
388 if(signal[k]>0 && iCol != -1) {
389 UpdateHisto(idetector,iRow,iCol,signal[k],iRowMax,col,mcm);
390 //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);
400 //_____________________________________________________________________
401 Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck)
404 // Event processing loop - AliRawReader
409 rawReader->Select("TRD");
411 AliTRDrawStreamBase *pstream = AliTRDrawStreamBase::GetRawStream(rawReader);
413 result = ProcessEvent(pstream, nocheck);
420 //_________________________________________________________________________
421 Int_t AliTRDCalibPadStatus::ProcessEvent(
423 const eventHeaderStruct *event,
426 const eventHeaderStruct* /*event*/,
433 // process date event
436 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
437 Bool_t result=ProcessEvent(rawReader, nocheck);
441 Fatal("AliTRDCalibPadStatus", "this class was compiled without DATE");
447 //_____________________________________________________________________
449 Int_t AliTRDCalibPadStatus::ProcessEvent2(AliRawReader *rawReader)
452 // RawReader = AliTRDrawStream (Jochen Klein)
454 // Event Processing loop - AliTRDRawStreamCosmic
455 // 0 time bin problem or zero suppression
458 // Raw version number:
459 // [3,31] non zero suppressed
460 // 2,4 and [32,63] zero suppressed
467 AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE);
468 digitsManager->CreateArrays();
470 AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader);
471 rawStream->SetDigitsManager(digitsManager);
472 //rawStream->SetNoErrorWarning();
473 //rawStream->SetSharedPadReadout(kTRUE);
475 AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance();
478 while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector
479 if (digitsManager->GetIndexes(det)->HasEntry()) {//QA
480 // printf("there is ADC data on this chamber!\n");
482 AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod
483 if (digits->HasData()) { //array
485 AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det);
486 if (indexes->IsAllocated() == kFALSE) {
487 AliError("Indexes do not exist!");
492 indexes->ResetCounters();
494 while (indexes->NextRCIndex(iRow, iCol)) { //column,row
496 AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam();
498 Int_t mcm = 0; // MCM from AliTRDfeeParam
499 Int_t rob = 0; // ROB from AliTRDfeeParam
500 Int_t extCol = 0; // extended column from AliTRDfeeParam
501 mcm = feeParam->GetMCMfromPad(iRow,iCol);
502 rob = feeParam->GetROBfromPad(iRow,iCol);
504 Int_t idetector = det; // current detector
505 Int_t iRowMax = 16; // current rowmax
506 if(GetStack(det) == 2) iRowMax = 12;
508 Int_t adc = 20 - (iCol%18) -1; // current adc
509 Int_t col = 0; // col!=0 ->Shared Pad
510 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc);
511 //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol);
513 // Signal for regular pads
514 Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data
515 for(Int_t k = 0; k < nbtimebin; k++){
517 signal = digits->GetData(iRow,iCol,k);
520 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
526 if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) ) { //SHARED PADS
530 adc = 20; //shared Pad adc
531 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
535 adc = 1; //shared Pad adc
536 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
540 adc = 0; //shared Pad adc
541 mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm
545 rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob
548 extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc
550 //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);
551 for(Int_t k = 0; k < nbtimebin; k++){
553 signal = digits->GetDataByAdcCol(iRow,extCol,k);
556 UpdateHisto2(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob);
567 digitsManager->ClearArrays(det);
569 delete digitsManager;
576 //_____________________________________________________________________
577 Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm, Int_t ch) /*FOLD00*/
581 // fill one oroc and one iroc with random gaus
586 for (Int_t ism=sm; ism<sm+1; ism++){
587 for (Int_t ich=ch; ich < ch+1; ich++){
588 for (Int_t ipl=0; ipl < 6; ipl++){
589 for(Int_t irow = 0; irow < fGeo->GetRowMax(ipl,ich,ism); irow++){
590 for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){
591 for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){
592 Int_t signal=TMath::Nint(gRandom->Gaus(10,1.5));
593 if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism),0,0);
603 //_____________________________________________________________________
604 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/
605 Int_t nbinsY, Float_t ymin, Float_t ymax,
606 const Char_t *type, Bool_t force)
609 // return pointer to histogram
610 // if force is true create a new histogram if it doesn't exist allready
612 if ( !force || arr->UncheckedAt(det) )
613 return (TH2F*)arr->UncheckedAt(det);
615 // if we are forced and histogram doesn't yes exist create it
616 Char_t name[255], title[255];
618 snprintf(name,255,"hCalib%s%.3d",type,det);
619 snprintf(title,255,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det);
622 Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det));
624 // we will add 3*8*rowMax channels at the end for the double counted
625 nbchannels += 3*8*(fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det)));
628 // new histogram with calib information. One value for each pad!
629 TH2F* hist = new TH2F(name,title,
631 nbchannels,0,nbchannels
633 hist->SetDirectory(0);
634 arr->AddAt(hist,det);
638 //_____________________________________________________________________
639 TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/
642 // return pointer to histogram
643 // if force is true create a new histogram if it doesn't exist allready
645 TObjArray *arr = &fHistoArray;
646 return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin-0.5, fAdcMax-0.5, "Pedestal", force);
649 //_____________________________________________________________________
650 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t force) /*FOLD00*/
653 // return pointer to ROC Calibration
654 // if force is true create a new AliTRDCalROC if it doesn't exist allready
656 if ( !force || arr->UncheckedAt(det) )
657 return (AliTRDCalROC*)arr->UncheckedAt(det);
659 // if we are forced and histogram doesn't yes exist create it
661 // new AliTRDCalROC. One value for each pad!
662 AliTRDCalROC *croc = new AliTRDCalROC(GetLayer(det),GetStack(det));
663 arr->AddAt(croc,det);
666 //_____________________________________________________________________
667 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMean(Int_t det, Bool_t force) /*FOLD00*/
670 // return pointer to Carge ROC Calibration
671 // if force is true create a new histogram if it doesn't exist allready
673 TObjArray *arr = &fCalRocArrayMean;
674 return GetCalRoc(det, arr, force);
677 //_____________________________________________________________________
678 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMS(Int_t det, Bool_t force) /*FOLD00*/
681 // return pointer to Carge ROC Calibration
682 // if force is true create a new histogram if it doesn't exist allready
684 TObjArray *arr = &fCalRocArrayRMS;
685 return GetCalRoc(det, arr, force);
687 //_____________________________________________________________________
688 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocMeand(Int_t det, Bool_t force) /*FOLD00*/
691 // return pointer to Carge ROC Calibration
692 // if force is true create a new histogram if it doesn't exist allready
694 TObjArray *arr = &fCalRocArrayMeand;
695 return GetCalRoc(det, arr, force);
698 //_____________________________________________________________________
699 AliTRDCalROC* AliTRDCalibPadStatus::GetCalRocRMSd(Int_t det, Bool_t force) /*FOLD00*/
702 // return pointer to Carge ROC Calibration
703 // if force is true create a new histogram if it doesn't exist allready
705 TObjArray *arr = &fCalRocArrayRMSd;
706 return GetCalRoc(det, arr, force);
709 //_____________________________________________________________________
710 void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/
713 // Calculate calibration constants
716 Int_t nbinsAdc = fAdcMax-fAdcMin;
724 for (Int_t idet=0; idet<540; idet++){
725 TH2F *hP = GetHisto(idet);
730 //printf("Entries for %d\n",idet);
732 AliTRDCalROC *rocMean = GetCalRocMean(idet,kTRUE);
733 AliTRDCalROC *rocRMS = GetCalRocRMS(idet,kTRUE);
735 arrayHP = hP->GetArray();
736 Int_t nChannels = rocMean->GetNchannels();
738 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
739 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
740 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
741 // if the fitting failed set noise and pedestal to 0
742 if ((ret==-4) || (ret==-1) || (ret==-2)) {
746 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
747 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
748 rocMean->SetValue(iChannel,param[1]/10.0);
749 rocRMS->SetValue(iChannel,param[2]/10.0);
752 // here we analyse doubled read channels
754 AliTRDCalROC *rocMeand = GetCalRocMeand(idet,kTRUE);
755 AliTRDCalROC *rocRMSd = GetCalRocRMSd(idet,kTRUE);
757 Int_t nrows = rocMeand->GetNrows();
758 Int_t shift = 144*nrows;
759 Int_t total = shift+3*8*nrows;
761 for (Int_t iChannel=shift; iChannel<total; iChannel++){
762 Int_t offset = (nbinsAdc+2)*(iChannel+1)+1;
763 Double_t ret = AliMathBase::FitGaus(arrayHP+offset,nbinsAdc,fAdcMin-0.5,fAdcMax-0.5,¶m,&dummy);
764 // if the fitting failed set noise and pedestal to 0
765 if ((ret==-4) || (ret==-1) || (ret==-2)) {
769 if((param[1]/10.0) > 65534.0) param[1] = 0.0;
770 if((param[2]/10.0) > 65534.0) param[2] = 0.0;
772 // here we have to recalculate backward
773 Int_t nb = iChannel-shift;
774 Int_t row = nb%nrows;
775 Int_t j = (Int_t)(nb/nrows);
777 Int_t icol = (Int_t)(j/8);
779 Int_t finalcol = 18*imcm;
780 if(icol > 0) icol += 17;
784 Int_t channel = row+finalcol*nrows;
786 //printf("iChannel %d, nrows %d, finalcol %d, row %d, channel %d\n",iChannel,nrows,finalcol,row,channel);
787 if((finalcol < 0) || (finalcol >= 144)) continue;
789 rocMeand->SetValue(channel,param[1]/10.0);
790 rocRMSd->SetValue(channel,param[2]/10.0);
797 //_______________________________________________________________________________________
798 AliTRDCalPadStatus* AliTRDCalibPadStatus::CreateCalPadStatus()
801 // Create Pad Status out of Mean and RMS values
802 // The chamber without data are masked, this is the corrected in the preprocessor
805 AliTRDCalPadStatus* obj = new AliTRDCalPadStatus("padstatus", "padstatus");
807 for (Int_t idet=0; idet<540; ++idet)
809 AliTRDCalSingleChamberStatus *calROC = obj->GetCalROC(idet);
812 if ( !GetCalRocMean(idet)) {
813 for(Int_t k = 0; k < calROC->GetNchannels(); k++){
814 calROC->SetStatus(k,AliTRDCalPadStatus::kNotConnected);
821 AliTRDCalROC *calRocMean = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMean(idet)));
822 AliTRDCalROC *calRocRMS = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMS(idet)));
824 //Take the stuff second chance
825 AliTRDCalROC *calRocMeand = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMeand(idet)));
826 AliTRDCalROC *calRocRMSd = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMSd(idet)));
829 calRocRMSd->Unfold();
833 Int_t row = calROC->GetNrows();
834 Int_t col = calROC->GetNcols();
836 Double_t rmsmean = calRocMean->GetRMS()*10.0;
837 Double_t meanmean = calRocMean->GetMean()*10.0;
838 Double_t meansquares = calRocRMS->GetMean();
841 for(Int_t irow = 0; irow < row; irow++){
844 Float_t meanprevious = 0.0;
845 Float_t rmsprevious = 0.0;
849 for(Int_t icol = 0; icol < col; icol++){
851 mean = calRocMean->GetValue(icol,irow)*10.0;
852 rms = calRocRMS->GetValue(icol,irow);
855 meanprevious = calRocMean->GetValue((icol -1),irow)*10.0;
856 rmsprevious = calRocRMS->GetValue((icol - 1),irow);
860 // masked if two noisy
861 if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) {
864 // look at second chance
865 Float_t meand = calRocMeand->GetValue(icol,irow)*10.0;
866 Float_t rmsd = calRocRMSd->GetValue(icol,irow);
868 if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) {
869 if((rmsd <= 0.0001) && (rms <= 0.0001)) {
870 calROC->SetStatus(icol,irow,AliTRDCalPadStatus::kNotConnected);
873 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kMasked);
877 calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kReadSecond);
882 // bridge if previous pad found something
884 if((meanprevious == mean) && (rmsprevious == rms) && (mean > 0.0001)) {
885 //printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol);
886 calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight);
887 calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft);
905 //_______________________________________________________________________________________
906 AliTRDCalPad* AliTRDCalibPadStatus::CreateCalPad()
909 // Create Pad Noise out of RMS values
912 AliTRDCalPad* obj = new AliTRDCalPad("PadNoise", "PadNoise");
915 for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det) {
917 AliTRDCalROC *calROC22 = obj->GetCalROC(det);
919 AliTRDCalROC *calRocRMS = ((AliTRDCalROC *)GetCalRocRMS(det,kTRUE));
921 for(Int_t k = 0; k < calROC22->GetNchannels(); k++){
922 calROC22->SetValue(k,calRocRMS->GetValue(k));
931 //_______________________________________________________________________________________
932 AliTRDCalDet* AliTRDCalibPadStatus::CreateCalDet() const
935 // Create Det Noise correction factor
938 AliTRDCalDet* obj = new AliTRDCalDet("DetNoise", "DetNoise (correction factor)");
940 for(Int_t l = 0; l < 540; l++){
941 obj->SetValue(l,10.0);
948 //_____________________________________________________________________
949 void AliTRDCalibPadStatus::DumpToFile(const Char_t *filename, const Char_t *dir, Bool_t append) /*FOLD00*/
952 // Write class to file
963 TDirectory *backup = gDirectory;
964 TFile f(filename,option.Data());
966 if ( !sDir.IsNull() ){
967 f.mkdir(sDir.Data());
973 if ( backup ) backup->cd();
976 //_____________________________________________________________________
977 void AliTRDCalibPadStatus::SetCalRocMean(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
980 // Put the AliTRDCalROC in the array fCalRocArrayMean
984 AliTRDCalROC *rocMean = GetCalRocMean(det,kTRUE);
986 Int_t nChannels = rocMean->GetNchannels();
988 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
990 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
996 //_____________________________________________________________________
997 void AliTRDCalibPadStatus::SetCalRocRMS(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
1000 // Put the AliTRDCalROC in the array fCalRocArrayRMS
1004 AliTRDCalROC *rocRms = GetCalRocRMS(det,kTRUE);
1006 Int_t nChannels = rocRms->GetNchannels();
1008 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1010 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1015 //_____________________________________________________________________
1016 void AliTRDCalibPadStatus::SetCalRocMeand(AliTRDCalROC *mean, Int_t det) /*FOLD00*/
1019 // Put the AliTRDCalROC in the array fCalRocArrayMean
1023 AliTRDCalROC *rocMean = GetCalRocMeand(det,kTRUE);
1025 Int_t nChannels = rocMean->GetNchannels();
1027 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1029 rocMean->SetValue(iChannel,mean->GetValue(iChannel));
1035 //_____________________________________________________________________
1036 void AliTRDCalibPadStatus::SetCalRocRMSd(AliTRDCalROC *rms, Int_t det) /*FOLD00*/
1039 // Put the AliTRDCalROC in the array fCalRocArrayRMS
1043 AliTRDCalROC *rocRms = GetCalRocRMSd(det,kTRUE);
1045 Int_t nChannels = rocRms->GetNchannels();
1047 for (Int_t iChannel=0; iChannel<nChannels; iChannel++){
1049 rocRms->SetValue(iChannel,rms->GetValue(iChannel));
1054 //_____________________________________________________________________________
1055 Int_t AliTRDCalibPadStatus::GetLayer(Int_t d) const
1058 // Reconstruct the layer number from the detector number
1061 return ((Int_t) (d % 6));
1065 //_____________________________________________________________________________
1066 Int_t AliTRDCalibPadStatus::GetStack(Int_t d) const
1069 // Reconstruct the chamber number from the detector number
1072 return ((Int_t) (d % 30) / 6);
1076 //_____________________________________________________________________________
1077 Int_t AliTRDCalibPadStatus::GetSector(Int_t d) const
1080 // Reconstruct the sector number from the detector number
1083 return ((Int_t) (d / 30));