X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDCalibPadStatus.cxx;h=832e64009c89d3197f5a3407b5931d7f8860c327;hb=2ecad9b5a9c135d633647dae32104f82b3f6f771;hp=4e7a7fee6a976b977b8b5bc3f8414a61c598e934;hpb=162a3e73367bd8ff7a75b99280f294e684c763e8;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDCalibPadStatus.cxx b/TRD/AliTRDCalibPadStatus.cxx index 4e7a7fee6a9..832e64009c8 100644 --- a/TRD/AliTRDCalibPadStatus.cxx +++ b/TRD/AliTRDCalibPadStatus.cxx @@ -54,15 +54,22 @@ // TH1F *histo = ped.GetHisto(31); // // histo->SetEntries(1); // // histo->Draw(); // -// // +// +// Authors: +// R. Bailhache (R.Bailhache@gsi.de, rbailhache@ikf.uni-frankfurt.de) +// J. Book (jbook@ikf.uni-frankfurt.de) +// // //////////////////////////////////////////////////////////////////////////// + //Root includes #include #include #include #include #include + +//#include #include #include @@ -75,7 +82,6 @@ //header file #include "AliLog.h" #include "AliTRDCalibPadStatus.h" -#include "AliTRDrawStreamTB.h" #include "AliTRDgeometry.h" #include "AliTRDCommonParam.h" #include "./Cal/AliTRDCalROC.h" @@ -84,6 +90,15 @@ #include "./Cal/AliTRDCalPad.h" #include "./Cal/AliTRDCalSingleChamberStatus.h" +#include "AliTRDdigitsManager.h" +#include "AliTRDdigitsParam.h" +#include "AliTRDSignalIndex.h" +#include "AliTRDarraySignal.h" +#include "AliTRDarrayADC.h" +#include "AliTRDfeeParam.h" + +#include "AliTRDrawStream.h" + #ifdef ALI_DATE #include "event.h" #endif @@ -95,7 +110,7 @@ AliTRDCalibPadStatus::AliTRDCalibPadStatus() : /*FOLD00*/ TObject(), fGeo(0), fAdcMin(0), - fAdcMax(20), + fAdcMax(21), fDetector(-1), fNumberOfTimeBins(0), fCalRocArrayMean(540), @@ -166,228 +181,203 @@ AliTRDCalibPadStatus& AliTRDCalibPadStatus::operator = (const AliTRDCalibPadSta return *this; } - //_____________________________________________________________________ AliTRDCalibPadStatus::~AliTRDCalibPadStatus() /*FOLD00*/ { // // destructor // + fCalRocArrayMean.Delete(); + fCalRocArrayRMS.Delete(); + fCalRocArrayMeand.Delete(); + fCalRocArrayRMSd.Delete(); + fHistoArray.Delete(); if (fGeo) { delete fGeo; } } - +//_____________________________________________________________________ +void AliTRDCalibPadStatus::Destroy() +{ + // + // Destroy + // + fCalRocArrayMean.Delete(); + fCalRocArrayRMS.Delete(); + fCalRocArrayMeand.Delete(); + fCalRocArrayRMSd.Delete(); + fHistoArray.Delete(); +} //_____________________________________________________________________ Int_t AliTRDCalibPadStatus::UpdateHisto(const Int_t icdet, /*FOLD00*/ - const Int_t icRow, - const Int_t icCol, - const Int_t csignal, - const Int_t crowMax, - const Int_t ccold, - const Int_t icMcm) + const Int_t icRow, + const Int_t icCol, + const Int_t csignal, + const Int_t crowMax, + const Int_t ccold, + const Int_t icMcm, + const Int_t icRob + ) { // // Signal filling methode // Int_t nbchannel = icRow+icCol*crowMax; + Int_t mCm = icMcm%4; + Int_t rOb = icRob%2; // now the case of double read channel if(ccold > 0){ - nbchannel = (((ccold-1)*8+ icMcm)*crowMax+icRow)+144*crowMax; + nbchannel = (((ccold-1)*8+ (mCm+rOb*4))*crowMax+icRow)+144*crowMax; //printf("nbchannel %d, ccold %d, icMcm %d, crowMax %d, icRow %d\n",nbchannel,ccold,icMcm,crowMax,icRow); } // fast filling methode. // Attention: the entry counter of the histogram is not increased // this means that e.g. the colz draw option gives an empty plot + Int_t bin = 0; - if ( !(((Int_t)csignal>fAdcMax ) || ((Int_t)csignal=fAdcMax ) || ((Int_t)csignalFill(csignal,nbchannel); + GetHisto(icdet,kTRUE)->GetArray()[bin]++; return 0; } //_____________________________________________________________________ -Int_t AliTRDCalibPadStatus::ProcessEvent(AliTRDrawStreamTB *rawStream, Bool_t nocheck) +Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader) { + // + // RawReader = AliTRDrawStream (Jochen Klein) // // Event Processing loop - AliTRDRawStreamCosmic // 0 time bin problem or zero suppression // 1 no input // 2 input - // + // Raw version number: + // [3,31] non zero suppressed + // 2,4 and [32,63] zero suppressed + // + + Int_t withInput = 1; - //rawStream->SetSharedPadReadout(kTRUE); - - if(!nocheck) { - while (rawStream->Next()) { - Int_t rawversion = rawStream->GetRawVersion(); // current raw version - //if(!rawStream->IsDataZeroSuppressed()) { - if(rawversion > 2) { - AliInfo(Form("this is not no-zero-suppressed data, the version is %d",rawversion)); - return 0; - } - Int_t idetector = rawStream->GetDet(); // current detector - Int_t iRow = rawStream->GetRow(); // current row - Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax - Int_t iCol = rawStream->GetCol(); // current col - - - Int_t iADC = 21-rawStream->GetADC(); // current ADC - Int_t col = 0; - if(iADC == 1) col = 1; - else { - col = TMath::Max(0,(Int_t)(iADC-19)); - if(col > 0) col++; - } - Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads - if(col > 1) mcm -= 1; - if(col ==1) mcm += 1; - - //Bool_t shared = rawStream->IsCurrentPadShared(); - //printf("ADC %d, iCol %d, col %d, mcm %d, shared %d\n",iADC,iCol,col,mcm,(Int_t)shared); - - Int_t iTimeBin = rawStream->GetTimeBin(); // current time bin - Int_t *signal = rawStream->GetSignals(); // current ADC signal - Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data + AliTRDdigitsManager *digitsManager = new AliTRDdigitsManager(kTRUE); + digitsManager->CreateArrays(); - if((fDetector != -1) && (nbtimebin != fNumberOfTimeBins)) { - AliInfo(Form("the number of time bins is %d, is different from the previous one %d",nbtimebin,fNumberOfTimeBins)); - return 0; - } - fNumberOfTimeBins = nbtimebin; - - Int_t fin = TMath::Min(nbtimebin,(iTimeBin+3)); - Int_t n = 0; - - for(Int_t k = iTimeBin; k < fin; k++){ - if(signal[n]>0) UpdateHisto(idetector,iRow,iCol,signal[n],iRowMax,col,mcm); - n++; - } - - withInput = 2; - } - } - else { - while (rawStream->Next()) { - Int_t idetector = rawStream->GetDet(); // current detector - Int_t iRow = rawStream->GetRow(); // current row - Int_t iRowMax = rawStream->GetMaxRow(); // current rowmax - Int_t iCol = rawStream->GetCol(); // current col - - - Int_t iADC = 21-rawStream->GetADC(); // current ADC - Int_t col = 0; - if(iADC == 1) col = 1; - else { - col = TMath::Max(0,(Int_t)(iADC-19)); - if(col > 0) col++; - } - Int_t mcm = (Int_t)(iCol/18); // current group of 18 col pads - if(col > 1) mcm -= 1; - if(col ==1) mcm += 1; + AliTRDrawStream *rawStream = new AliTRDrawStream(rawReader); + rawStream->SetDigitsManager(digitsManager); + //rawStream->SetNoErrorWarning(); + //rawStream->SetSharedPadReadout(kTRUE); + + AliTRDfeeParam *feeParam = AliTRDfeeParam::Instance(); - Int_t iTimeBin = rawStream->GetTimeBin(); // current time bin - Int_t *signal = rawStream->GetSignals(); // current ADC signal - Int_t nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data + Int_t det = 0; + while ((det = rawStream->NextChamber(digitsManager, NULL, NULL)) >= 0) { //idetector + if (digitsManager->GetIndexes(det)->HasEntry()) {//QA + // printf("there is ADC data on this chamber!\n"); - Int_t fin = TMath::Min(nbtimebin,(iTimeBin+3)); - Int_t n = 0; - - //printf("det %d, row %d, signal[0] %d, signal[1] %d, signal [2] %d\n", idetector, iRow, signal[0], signal[1], signal[2]); - - for(Int_t k = iTimeBin; k < fin; k++){ - if(signal[n]>0) { - UpdateHisto(idetector,iRow,iCol,signal[n],iRowMax,col,mcm); - //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); + AliTRDarrayADC *digits = (AliTRDarrayADC *) digitsManager->GetDigits(det); //mod + if (digits->HasData()) { //array + + AliTRDSignalIndex *indexes = digitsManager->GetIndexes(det); + if (indexes->IsAllocated() == kFALSE) { + AliError("Indexes do not exist!"); + break; } - n++; - } - - withInput = 2; - } - } - - return withInput; -} - -//_____________________________________________________________________ -Int_t AliTRDCalibPadStatus::ProcessEvent(AliRawReader *rawReader, Bool_t nocheck) -{ - // - // Event processing loop - AliRawReader - // - - - AliTRDrawStreamTB rawStream(rawReader); - - rawReader->Select("TRD"); - - return ProcessEvent(&rawStream, nocheck); -} - -//_________________________________________________________________________ -Int_t AliTRDCalibPadStatus::ProcessEvent( -#ifdef ALI_DATE - eventHeaderStruct *event, - Bool_t nocheck -#else - eventHeaderStruct* /*event*/, - Bool_t /*nocheck*/ + Int_t iRow = 0; + Int_t iCol = 0; + indexes->ResetCounters(); + + while (indexes->NextRCIndex(iRow, iCol)) { //column,row + + AliTRDdigitsParam *digitParam = (AliTRDdigitsParam *)digitsManager->GetDigitsParam(); + + Int_t mcm = 0; // MCM from AliTRDfeeParam + Int_t rob = 0; // ROB from AliTRDfeeParam + Int_t extCol = 0; // extended column from AliTRDfeeParam + mcm = feeParam->GetMCMfromPad(iRow,iCol); + rob = feeParam->GetROBfromPad(iRow,iCol); + + Int_t idetector = det; // current detector + Int_t iRowMax = 16; // current rowmax + if(GetStack(det) == 2) iRowMax = 12; + + Int_t adc = 20 - (iCol%18) -1; // current adc + Int_t col = 0; // col!=0 ->Shared Pad + extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); + //printf(" iCol %d iRow %d iRowMax %d rob %d mcm %d adc %d extCol %d\n",iCol,iRow,iRowMax,rob,mcm,adc,extCol); + + // Signal for regular pads + Int_t nbtimebin = digitParam->GetNTimeBins(idetector); // number of time bins read from data + for(Int_t k = 0; k < nbtimebin; k++){ + Short_t signal = 0; + signal = digits->GetData(iRow,iCol,k); + + if(signal>0) { + UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob); + } + } + + + + if((adc==3-1 || adc==20-1 || adc==19-1) && (iCol > 1 && iCol <142) ) { //SHARED PADS -#endif - ) -{ - // - // process date event - // -#ifdef ALI_DATE - AliRawReader *rawReader = new AliRawReaderDate((void*)event); - Bool_t result=ProcessEvent(rawReader, nocheck); - delete rawReader; - return result; -#else - Fatal("AliTRDCalibPadStatus", "this class was compiled without DATE"); - return 0; -#endif - -} - -//_____________________________________________________________________ -Bool_t AliTRDCalibPadStatus::TestEventHisto(Int_t nevent, Int_t sm) /*FOLD00*/ -{ - // - // Test event loop - // fill one oroc and one iroc with random gaus - // - - gRandom->SetSeed(0); - - for (Int_t ism=sm; ismGetRowMax(ipl,ich,ism); irow++){ - for(Int_t icol = 0; icol < fGeo->GetColMax(ipl); icol++){ - for (Int_t iTimeBin=0; iTimeBin<(30*nevent); iTimeBin++){ - Int_t signal=(Int_t)(gRandom->Gaus(10.0,1.2)); - if ( signal>0 )UpdateHisto((ipl+ich*6+ism*6*5),irow,icol,signal,fGeo->GetRowMax(ipl,ich,ism),0,0); - } - } + switch(adc) { + case 2: + adc = 20; //shared Pad adc + mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm + col = 1; + break; + case 19: + adc = 1; //shared Pad adc + mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm + col = 2; + break; + case 18: + adc = 0; //shared Pad adc + mcm = feeParam->GetMCMfromSharedPad(iRow,iCol); //shared Pad mcm + col = 3; + break; + } + rob = feeParam->GetROBfromSharedPad(iRow,iCol); //shared Pad rob + + + extCol = feeParam->GetExtendedPadColFromADC(rob,mcm,adc); //extended pad col via the shared pad rob,mcm and adc + + //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); + for(Int_t k = 0; k < nbtimebin; k++){ + Short_t signal = 0; + signal = digits->GetDataByAdcCol(iRow,extCol,k); + + if(signal>0) { + UpdateHisto(idetector,iRow,iCol,signal,iRowMax,col,mcm,rob); } } - } - } - return kTRUE; + } //shared pads end + + + withInput = 2; + }//column,row + + }//array + }//QA + digitsManager->ClearArrays(det); + }//idetector + delete digitsManager; + delete rawStream; + return withInput; + } //_____________________________________________________________________ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/ Int_t nbinsY, Float_t ymin, Float_t ymax, - Char_t *type, Bool_t force) + const Char_t *type, Bool_t force) { // // return pointer to histogram @@ -399,14 +389,14 @@ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, TObjArray *arr, /*FOLD00*/ // if we are forced and histogram doesn't yes exist create it Char_t name[255], title[255]; - sprintf(name,"hCalib%s%.2d",type,det); - sprintf(title,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det); + snprintf(name,255,"hCalib%s%.3d",type,det); + snprintf(title,255,"%s calibration histogram detector %.2d;ADC channel;Channel (pad)",type,det); - Int_t nbchannels = fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))*fGeo->GetColMax(GetPlane(det)); + Int_t nbchannels = fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))*fGeo->GetColMax(GetLayer(det)); // we will add 3*8*rowMax channels at the end for the double counted - nbchannels += 3*8*(fGeo->GetRowMax(GetPlane(det),GetChamber(det),GetSector(det))); + nbchannels += 3*8*(fGeo->GetRowMax(GetLayer(det),GetStack(det),GetSector(det))); // new histogram with calib information. One value for each pad! @@ -427,7 +417,7 @@ TH2F* AliTRDCalibPadStatus::GetHisto(Int_t det, Bool_t force) /*FOLD00*/ // if force is true create a new histogram if it doesn't exist allready // TObjArray *arr = &fHistoArray; - return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin, fAdcMax, "Pedestal", force); + return GetHisto(det, arr, fAdcMax-fAdcMin, fAdcMin-0.5, fAdcMax-0.5, "Pedestal", force); } //_____________________________________________________________________ @@ -443,7 +433,7 @@ AliTRDCalROC* AliTRDCalibPadStatus::GetCalRoc(Int_t det, TObjArray* arr, Bool_t // if we are forced and histogram doesn't yes exist create it // new AliTRDCalROC. One value for each pad! - AliTRDCalROC *croc = new AliTRDCalROC(GetPlane(det),GetChamber(det)); + AliTRDCalROC *croc = new AliTRDCalROC(GetLayer(det),GetStack(det)); arr->AddAt(croc,det); return croc; } @@ -499,7 +489,7 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/ Int_t nbinsAdc = fAdcMax-fAdcMin; - TVectorD param(3); + TVectorD param(4); TMatrixD dummy(3,3); Float_t *arrayHP=0; @@ -511,6 +501,8 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/ continue; } + //printf("Entries for %d\n",idet); + AliTRDCalROC *rocMean = GetCalRocMean(idet,kTRUE); AliTRDCalROC *rocRMS = GetCalRocRMS(idet,kTRUE); @@ -519,8 +511,8 @@ void AliTRDCalibPadStatus::AnalyseHisto() /*FOLD00*/ for (Int_t iChannel=0; iChannelGetCalROC(idet); - //Take the stuff - AliTRDCalROC *calRocMean = ((AliTRDCalROC *)GetCalRocMean(idet)); - AliTRDCalROC *calRocRMS = ((AliTRDCalROC *)GetCalRocRMS(idet)); - //Take the stuff second chance - AliTRDCalROC *calRocMeand = ((AliTRDCalROC *)GetCalRocMeand(idet)); - AliTRDCalROC *calRocRMSd = ((AliTRDCalROC *)GetCalRocRMSd(idet)); - - if ( !calRocMean ) { + if ( !GetCalRocMean(idet)) { for(Int_t k = 0; k < calROC->GetNchannels(); k++){ - calROC->SetStatus(k,AliTRDCalPadStatus::kMasked); + calROC->SetStatus(k,AliTRDCalPadStatus::kNotConnected); } continue; } + + //Take the stuff + AliTRDCalROC *calRocMean = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMean(idet))); + AliTRDCalROC *calRocRMS = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMS(idet))); + + //Take the stuff second chance + AliTRDCalROC *calRocMeand = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocMeand(idet))); + AliTRDCalROC *calRocRMSd = new AliTRDCalROC(*( (AliTRDCalROC *) GetCalRocRMSd(idet))); + + calRocRMS->Unfold(); + calRocRMSd->Unfold(); + + //Range - Int_t channels = calROC->GetNchannels(); + Int_t row = calROC->GetNrows(); + Int_t col = calROC->GetNcols(); Double_t rmsmean = calRocMean->GetRMS()*10.0; Double_t meanmean = calRocMean->GetMean()*10.0; - Double_t meansquares = calRocRMS->GetMean()*10.0; + Double_t meansquares = calRocRMS->GetMean(); - for(Int_t ich = 0; ich < channels; ich++){ + + for(Int_t irow = 0; irow < row; irow++){ - Float_t mean = calRocMean->GetValue(ich)*10.0; - Float_t rms = calRocRMS->GetValue(ich)*10.0; + // for bridged pads + Float_t meanprevious = 0.0; + Float_t rmsprevious = 0.0; + Float_t mean = 0.0; + Float_t rms = 0.0; - if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) { - // look at second chance - Float_t meand = calRocMeand->GetValue(ich)*10.0; - Float_t rmsd = calRocRMSd->GetValue(ich)*10.0; + for(Int_t icol = 0; icol < col; icol++){ + + mean = calRocMean->GetValue(icol,irow)*10.0; + rms = calRocRMS->GetValue(icol,irow); + + if(icol > 0) { + meanprevious = calRocMean->GetValue((icol -1),irow)*10.0; + rmsprevious = calRocRMS->GetValue((icol - 1),irow); + } + + Bool_t pb = kFALSE; + // masked if two noisy + if((rms <= 0.0001) || (TMath::Abs(mean-meanmean)>(5*rmsmean)) || (TMath::Abs(rms)>(5.0*TMath::Abs(meansquares)))) { + + pb = kTRUE; + // look at second chance + Float_t meand = calRocMeand->GetValue(icol,irow)*10.0; + Float_t rmsd = calRocRMSd->GetValue(icol,irow); + + if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) { + if((rmsd <= 0.0001) && (rms <= 0.0001)) { + calROC->SetStatus(icol,irow,AliTRDCalPadStatus::kNotConnected); + } + else { + calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kMasked); + } + } + else { + calROC->SetStatus(icol, irow, AliTRDCalPadStatus::kReadSecond); + } + } + - if((rmsd <= 0.0001) || (TMath::Abs(meand-meanmean)>(5*rmsmean)) || (TMath::Abs(rmsd)>(5.0*TMath::Abs(meansquares)))) { - calROC->SetStatus(ich, AliTRDCalPadStatus::kMasked); + // bridge if previous pad found something + if(!pb) { + if((meanprevious == mean) && (rmsprevious == rms) && (mean > 0.0001)) { + //printf("mean previous %f, mean %f, rms %f, rmsprevious %f, col %d\n",meanprevious,mean,rms,rmsprevious,icol); + calROC->SetStatus(icol -1 ,irow, AliTRDCalPadStatus::kPadBridgedRight); + calROC->SetStatus(icol ,irow, AliTRDCalPadStatus::kPadBridgedLeft); + } } - else calROC->SetStatus(ich, AliTRDCalPadStatus::kReadSecond); + } - } + + delete calRocMean; + delete calRocRMS; + delete calRocMeand; + delete calRocRMSd; + + } return obj; @@ -783,10 +826,10 @@ void AliTRDCalibPadStatus::SetCalRocRMSd(AliTRDCalROC *rms, Int_t det) /*FOLD00* } //_____________________________________________________________________________ -Int_t AliTRDCalibPadStatus::GetPlane(Int_t d) const +Int_t AliTRDCalibPadStatus::GetLayer(Int_t d) const { // - // Reconstruct the plane number from the detector number + // Reconstruct the layer number from the detector number // return ((Int_t) (d % 6)); @@ -794,7 +837,7 @@ Int_t AliTRDCalibPadStatus::GetPlane(Int_t d) const } //_____________________________________________________________________________ -Int_t AliTRDCalibPadStatus::GetChamber(Int_t d) const +Int_t AliTRDCalibPadStatus::GetStack(Int_t d) const { // // Reconstruct the chamber number from the detector number