-/************************************************************************* \r
-* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. * \r
-* * \r
-* Author: The ALICE Off-line Project. * \r
-* Contributors are mentioned in the code where appropriate. * \r
-* * \r
-* Permission to use, copy, modify and distribute this software and its * \r
-* documentation strictly for non-commercial purposes is hereby granted * \r
-* without fee, provided that the above copyright notice appears in all * \r
-* copies and that both the copyright notice and this permission notice * \r
-* appear in the supporting documentation. The authors make no claims * \r
-* about the suitability of this software for any purpose. It is * \r
-* provided "as is" without express or implied warranty. *\r
-**************************************************************************/\r
-\r
-/* $Id: AliTRDarrayADC.cxx 25392 2008-04-23 19:40:29Z cblume $ */\r
-\r
-////////////////////////////////////////////////////////\r
-// //\r
-// Container class for ADC values //\r
-// //\r
-// Author: //\r
-// Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //\r
-// // \r
-////////////////////////////////////////////////////////\r
-\r
-#include "AliTRDarrayADC.h"\r
-#include "Cal/AliTRDCalPadStatus.h"\r
-#include "AliTRDfeeParam.h"\r
-\r
-ClassImp(AliTRDarrayADC)\r
-\r
-Short_t *AliTRDarrayADC::fgLutPadNumbering = 0x0;\r
-\r
-//____________________________________________________________________________________\r
-AliTRDarrayADC::AliTRDarrayADC()\r
- :TObject()\r
- ,fNdet(0)\r
- ,fNrow(0)\r
- ,fNcol(0)\r
- ,fNumberOfChannels(0)\r
- ,fNtime(0) \r
- ,fNAdim(0)\r
- ,fADC(0)\r
-{\r
- //\r
- // AliTRDarrayADC default constructor\r
- //\r
-\r
- CreateLut();\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-AliTRDarrayADC::AliTRDarrayADC(Int_t nrow, Int_t ncol, Int_t ntime)\r
- :TObject()\r
- ,fNdet(0) \r
- ,fNrow(0)\r
- ,fNcol(0)\r
- ,fNumberOfChannels(0)\r
- ,fNtime(0) \r
- ,fNAdim(0)\r
- ,fADC(0)\r
-{\r
- //\r
- // AliTRDarrayADC constructor\r
- //\r
-\r
- CreateLut();\r
- Allocate(nrow,ncol,ntime);\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-AliTRDarrayADC::AliTRDarrayADC(const AliTRDarrayADC &b)\r
- :TObject()\r
- ,fNdet(b.fNdet)\r
- ,fNrow(b.fNrow)\r
- ,fNcol(b.fNcol)\r
- ,fNumberOfChannels(b.fNumberOfChannels)\r
- ,fNtime(b.fNtime) \r
- ,fNAdim(b.fNAdim)\r
- ,fADC(0) \r
-{\r
- //\r
- // AliTRDarrayADC copy constructor\r
- //\r
-\r
- fADC = new Short_t[fNAdim];\r
- memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t)); \r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-AliTRDarrayADC::~AliTRDarrayADC()\r
-{\r
- //\r
- // AliTRDarrayADC destructor\r
- //\r
-\r
- if(fADC)\r
- {\r
- delete [] fADC;\r
- fADC=0;\r
- }\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-AliTRDarrayADC &AliTRDarrayADC::operator=(const AliTRDarrayADC &b)\r
-{\r
- //\r
- // Assignment operator\r
- //\r
-\r
- if(this==&b)\r
- {\r
- return *this;\r
- }\r
- if(fADC)\r
- {\r
- delete [] fADC;\r
- }\r
- fNdet=b.fNdet;\r
- fNrow=b.fNrow;\r
- fNcol=b.fNcol;\r
- fNumberOfChannels = b.fNumberOfChannels;\r
- fNtime=b.fNtime;\r
- fNAdim=b.fNAdim;\r
- fADC = new Short_t[fNAdim];\r
- memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t));\r
-\r
- return *this;\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-void AliTRDarrayADC::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)\r
-{\r
- //\r
- // Allocate memory for an AliTRDarrayADC array with dimensions\r
- // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time\r
- //\r
- \r
- fNrow=nrow;\r
- fNcol=ncol;\r
- fNtime=ntime;\r
- Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm(); \r
- Int_t padspermcm = AliTRDfeeParam::GetNcolMcm(); \r
- Int_t numberofmcms = fNcol/padspermcm; \r
- fNumberOfChannels = numberofmcms*adcchannelspermcm; \r
- fNAdim=nrow*fNumberOfChannels*ntime;\r
-\r
- if(fADC)\r
- {\r
- delete [] fADC;\r
- }\r
- \r
- fADC = new Short_t[fNAdim];\r
- memset(fADC,0,sizeof(Short_t)*fNAdim);\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-Short_t AliTRDarrayADC::GetDataBits(Int_t row, Int_t col, Int_t time) const\r
-{\r
- //\r
- // Get the ADC value for a given position: row, col, time\r
- // Taking bit masking into account\r
- //\r
- // Adapted from code of the class AliTRDdataArrayDigits \r
- //\r
-\r
- Short_t tempval = GetData(row,col,time);\r
- // Be aware of manipulations introduced by pad masking in the RawReader\r
- // Only output the manipulated Value\r
- CLRBIT(tempval, 10);\r
- CLRBIT(tempval, 11);\r
- CLRBIT(tempval, 12);\r
- return tempval;\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-UChar_t AliTRDarrayADC::GetPadStatus(Int_t row, Int_t col, Int_t time) const\r
-{\r
- // \r
- // Returns the pad status stored in the pad signal\r
- //\r
- // Output is a UChar_t value\r
- // Status Codes:\r
- // Noisy Masking: 2\r
- // Bridged Left Masking 8\r
- // Bridged Right Masking 8\r
- // Not Connected Masking Digits\r
- //\r
- // Adapted from code of the class AliTRDdataArrayDigits\r
- //\r
-\r
- UChar_t padstatus = 0;\r
- Short_t signal = GetData(row,col,time);\r
- if(signal > 0 && TESTBIT(signal, 10)){\r
- if(TESTBIT(signal, 11))\r
- if(TESTBIT(signal, 12))\r
- padstatus = AliTRDCalPadStatus::kPadBridgedRight;\r
- else\r
- padstatus = AliTRDCalPadStatus::kNotConnected;\r
- else\r
- if(TESTBIT(signal, 12))\r
- padstatus = AliTRDCalPadStatus::kPadBridgedLeft;\r
- else\r
- padstatus = AliTRDCalPadStatus::kMasked;\r
- }\r
-\r
- return padstatus;\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t status)\r
-{\r
- //\r
- // Setting the pad status into the signal using the Bits 10 to 14 \r
- // (currently used: 10 to 12)\r
- //\r
- // Input codes (Unsigned char):\r
- // Noisy Masking: 2\r
- // Bridged Left Masking 8\r
- // Bridged Right Masking 8\r
- // Not Connected Masking 32\r
- //\r
- // Status codes: Any masking: Bit 10(1)\r
- // Noisy masking: Bit 11(0), Bit 12(0)\r
- // No Connection masking: Bit 11(1), Bit 12(0)\r
- // Bridged Left masking: Bit 11(0), Bit 12(1)\r
- // Bridged Right masking: Bit 11(1), Bit 12(1)\r
- // \r
- // Adapted from code of the class AliTRDdataArrayDigits\r
- //\r
-\r
- Short_t signal = GetData(row,col,time);\r
-\r
- // Only set the Pad Status if the signal is > 0\r
- if(signal > 0)\r
- {\r
- switch(status)\r
- {\r
- case AliTRDCalPadStatus::kMasked:\r
- SETBIT(signal, 10);\r
- CLRBIT(signal, 11);\r
- CLRBIT(signal, 12);\r
- break;\r
- case AliTRDCalPadStatus::kNotConnected:\r
- SETBIT(signal, 10);\r
- SETBIT(signal, 11);\r
- CLRBIT(signal, 12);\r
- break;\r
- case AliTRDCalPadStatus::kPadBridgedLeft:\r
- SETBIT(signal, 10);\r
- CLRBIT(signal, 11);\r
- SETBIT(signal, 12);\r
- break;\r
- case AliTRDCalPadStatus::kPadBridgedRight:\r
- SETBIT(signal, 10);\r
- SETBIT(signal, 11);\r
- SETBIT(signal, 12);\r
- default:\r
- CLRBIT(signal, 10);\r
- CLRBIT(signal, 11);\r
- CLRBIT(signal, 12);\r
- }\r
- SetData(row, col, time, signal);\r
- }\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-Bool_t AliTRDarrayADC::IsPadCorrupted(Int_t row, Int_t col, Int_t time)\r
-{\r
- // \r
- // Checks if the pad has any masking as corrupted (Bit 10 in signal set)\r
- // \r
- // Adapted from code of the class AliTRDdataArrayDigits\r
- //\r
-\r
- Short_t signal = GetData(row,col,time);\r
- return (signal > 0 && TESTBIT(signal, 10)) ? kTRUE : kFALSE;\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-void AliTRDarrayADC::Compress()\r
-{\r
- //\r
- // Compress the array\r
- //\r
-\r
- Int_t counter=0;\r
- Int_t newDim=0;\r
- Int_t j; \r
- Int_t l; \r
- Int_t r=0; \r
- Int_t s=0; \r
- Int_t *longm; \r
- longm = new Int_t[fNAdim]; \r
- Int_t *longz; \r
- longz = new Int_t[fNAdim];\r
- Int_t k=0;\r
- memset(longz,0,sizeof(Int_t)*fNAdim);\r
- memset(longm,0,sizeof(Int_t)*fNAdim);\r
-\r
- for(Int_t i=0;i<fNAdim; i++)\r
- {\r
- j=0;\r
- if(fADC[i]==-1)\r
- {\r
- for(k=i;k<fNAdim;k++)\r
- {\r
- if((fADC[k]==-1)&&(j<16000)) \r
- {\r
- j=j+1;\r
- longm[r]=j; \r
- }\r
- else\r
- {\r
- break;\r
- }\r
- }\r
- r=r+1; \r
- }\r
- l=16001;\r
- if(fADC[i]==0)\r
- {\r
- for(k=i;k<fNAdim;k++)\r
- {\r
- if((fADC[k]==0)&&(l<32767)) \r
- { \r
- l=l+1;\r
- longz[s]=l; \r
- }\r
- else\r
- {\r
- break;\r
- }\r
- }\r
- s=s+1; \r
- }\r
- if(fADC[i]>0)\r
- {\r
- i=i+1;\r
- }\r
- i=i+j+(l-16001-1); \r
- }\r
-\r
- //Calculate the size of the compressed array\r
- for(Int_t i=0; i<fNAdim;i++)\r
- {\r
- if(longm[i]!=0) \r
- {\r
- counter=counter+longm[i]-1;\r
- }\r
- if(longz[i]!=0) \r
- {\r
- counter=counter+(longz[i]-16001)-1;\r
- }\r
- }\r
- newDim = fNAdim-counter; //Dimension of the compressed array\r
- Short_t* buffer;\r
- buffer = new Short_t[newDim];\r
- Int_t counterTwo=0;\r
-\r
- //Fill the buffer of the compressed array\r
- Int_t g=0;\r
- Int_t h=0; \r
- for(Int_t i=0; i<newDim; i++)\r
- {\r
- if(counterTwo<fNAdim)\r
- {\r
- if(fADC[counterTwo]>0)\r
- {\r
- buffer[i]=fADC[counterTwo];\r
- }\r
- if(fADC[counterTwo]==-1)\r
- {\r
- buffer[i]=-(longm[g]);\r
- counterTwo=counterTwo+longm[g]-1;\r
- g++;\r
- } \r
- if(fADC[counterTwo]==0)\r
- {\r
- buffer[i]=-(longz[h]); \r
- counterTwo=counterTwo+(longz[h]-16001)-1;\r
- h++;\r
- } \r
- counterTwo++;\r
- }\r
- }\r
-\r
- //Copy the buffer\r
- if(fADC)\r
- {\r
- delete [] fADC;\r
- fADC=0;\r
- }\r
- fADC = new Short_t[newDim];\r
- fNAdim = newDim;\r
- for(Int_t i=0; i<newDim; i++)\r
- {\r
- fADC[i] = buffer[i]; \r
- }\r
-\r
- //Delete auxiliary arrays\r
- if(buffer)\r
- {\r
- delete [] buffer;\r
- buffer=0;\r
- } \r
- if(longz) \r
- {\r
- delete [] longz;\r
- longz=0;\r
- }\r
- if(longm) \r
- {\r
- delete [] longm;\r
- longm=0;\r
- }\r
-\r
-}\r
-\r
-//____________________________________________________________________________________\r
-void AliTRDarrayADC::Expand()\r
-{\r
- //\r
- // Expand the array\r
- //\r
-\r
- //Check if the array has not been already expanded\r
- Int_t verif=0;\r
- for(Int_t i=0; i<fNAdim; i++)\r
- {\r
- if(fADC[i]<-1)\r
- {\r
- verif++;\r
- }\r
- }\r
- \r
- if(verif==0)\r
- {\r
- // AliDebug(1,"Nothing to expand");\r
- return;\r
- }\r
-\r
- Int_t *longz;\r
- longz = new Int_t[fNAdim];\r
- Int_t *longm;\r
- longm = new Int_t[fNAdim];\r
- Int_t dimexp=0;\r
- //Initialize arrays\r
- memset(longz,0,sizeof(Int_t)*fNAdim);\r
- memset(longm,0,sizeof(Int_t)*fNAdim);\r
- Int_t r2=0; \r
- Int_t r3=0; \r
- for(Int_t i=0; i<fNAdim;i++)\r
- {\r
- if((fADC[i]<0)&&(fADC[i]>=-16000)) \r
- {\r
- longm[r2]=-fADC[i];\r
- r2++;\r
- }\r
- if(fADC[i]<-16000) \r
- {\r
- longz[r3]=-fADC[i]-16001; \r
- r3++;\r
- }\r
- }\r
- //Calculate the new dimensions of the array\r
- for(Int_t i=0; i<fNAdim;i++)\r
- {\r
- if(longm[i]!=0) \r
- {\r
- dimexp=dimexp+longm[i]-1;\r
- }\r
- if(longz[i]!=0) \r
- {\r
- dimexp=dimexp+longz[i]-1;\r
- }\r
- }\r
- dimexp=dimexp+fNAdim; \r
-\r
- //Write in the buffer the new array\r
- Short_t* bufferE;\r
- bufferE = new Short_t[dimexp];\r
- Int_t contaexp =0; \r
- Int_t h=0;\r
- Int_t l=0; \r
- for(Int_t i=0; i<dimexp; i++)\r
- {\r
- if(fADC[contaexp]>0) \r
- {\r
- bufferE[i]=fADC[contaexp];\r
- }\r
-\r
- if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000)) \r
- {\r
- for(Int_t j=0; j<longm[h];j++)\r
- {\r
- bufferE[i+j]=-1;\r
- }\r
- i=i+longm[h]-1;\r
- h++;\r
- }\r
- if(fADC[contaexp]<-16000) \r
- {\r
- for(Int_t j=0; j<longz[l];j++)\r
- {\r
- bufferE[i+j]=0; \r
- }\r
- i=i+longz[l]-1;\r
- l++;\r
- }\r
- contaexp++;\r
- }\r
- //Copy the buffer\r
- if(fADC)\r
- {\r
- delete [] fADC;\r
- fADC=0;\r
- }\r
-\r
- fADC = new Short_t[dimexp];\r
- fNAdim = dimexp;\r
- for(Int_t i=0; i<dimexp; i++)\r
- {\r
- fADC[i] = bufferE[i]; \r
- }\r
-\r
- //Delete auxiliary arrays\r
- if(bufferE) delete [] bufferE;\r
- if(longm) delete [] longm;\r
- if(longz) delete [] longz;\r
-\r
-}\r
-//____________________________________________________________________________________\r
-void AliTRDarrayADC::DeleteNegatives()\r
-{\r
-\r
- //\r
- //This method modifies the digits array, changing the negative values (-1)\r
- //Produced during digitization into zero.\r
- //\r
-\r
- for(Int_t a=0; a<fNAdim; a++)\r
- {\r
- if(fADC[a]==-1)\r
- {\r
- fADC[a]=0;\r
- }\r
- }\r
-}\r
-//________________________________________________________________________________\r
-void AliTRDarrayADC::Reset()\r
-{\r
- //\r
- // Reset the array, the old contents are deleted\r
- // The array keeps the same dimensions as before\r
- //\r
- \r
- memset(fADC,0,sizeof(Short_t)*fNAdim);\r
-\r
-}\r
-//________________________________________________________________________________\r
-Short_t AliTRDarrayADC::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const\r
-{\r
- //\r
- // Get the data using the pad numbering.\r
- // To access data using the mcm scheme use instead\r
- // the method GetDataByAdcCol\r
- //\r
-\r
- Int_t corrcolumn = fgLutPadNumbering[ncol];\r
-\r
- return fADC[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];\r
-\r
-}\r
-//________________________________________________________________________________\r
-void AliTRDarrayADC::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Short_t value)\r
-{\r
- //\r
- // Set the data using the pad numbering.\r
- // To write data using the mcm scheme use instead\r
- // the method SetDataByAdcCol\r
- //\r
-\r
- Int_t colnumb = fgLutPadNumbering[ncol];\r
-\r
- fADC[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;\r
-\r
-}\r
-\r
-//________________________________________________________________________________\r
-void AliTRDarrayADC::CreateLut()\r
-{\r
- //\r
- // Initializes the Look Up Table to relate\r
- // pad numbering and mcm channel numbering\r
- //\r
-\r
- if(fgLutPadNumbering) return;\r
- \r
- fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];\r
- memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());\r
-\r
- for(Int_t mcm=0; mcm<8; mcm++)\r
- {\r
- Int_t lowerlimit=0+mcm*18;\r
- Int_t upperlimit=18+mcm*18;\r
- Int_t shiftposition = 1+3*mcm;\r
- for(Int_t index=lowerlimit;index<upperlimit;index++)\r
- {\r
- fgLutPadNumbering[index]=index+shiftposition;\r
- }\r
- }\r
-}\r
-//________________________________________________________________________________\r
-void AliTRDarrayADC::SubtractBaseline(Short_t baseline)\r
-{\r
- //\r
- // Subtracts the baseline to all the adc array\r
- // if the value is equal or greater than baseline\r
- //\r
-\r
- for(Int_t b=0; b<fNAdim; b++)\r
- {\r
- //if(fADC[b]>=baseline)\r
- //{\r
- fADC[b]=fADC[b]-baseline;\r
- //}\r
- }\r
-}\r
+/*************************************************************************
+* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
+* *
+* Author: The ALICE Off-line Project. *
+* Contributors are mentioned in the code where appropriate. *
+* *
+* Permission to use, copy, modify and distribute this software and its *
+* documentation strictly for non-commercial purposes is hereby granted *
+* without fee, provided that the above copyright notice appears in all *
+* copies and that both the copyright notice and this permission notice *
+* appear in the supporting documentation. The authors make no claims *
+* about the suitability of this software for any purpose. It is *
+* provided "as is" without express or implied warranty. *
+**************************************************************************/
+
+/* $Id: AliTRDarrayADC.cxx 25392 2008-04-23 19:40:29Z cblume $ */
+
+////////////////////////////////////////////////////////
+// //
+// Container class for ADC values //
+// //
+// Author: //
+// Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //
+// //
+////////////////////////////////////////////////////////
+
+#include "AliTRDarrayADC.h"
+#include "Cal/AliTRDCalPadStatus.h"
+#include "AliTRDfeeParam.h"
+#include "AliTRDSignalIndex.h"
+ClassImp(AliTRDarrayADC)
+
+Short_t *AliTRDarrayADC::fgLutPadNumbering = 0x0;
+
+//____________________________________________________________________________________
+AliTRDarrayADC::AliTRDarrayADC()
+ :TObject()
+ ,fNdet(0)
+ ,fNrow(0)
+ ,fNcol(0)
+ ,fNumberOfChannels(0)
+ ,fNtime(0)
+ ,fNAdim(0)
+ ,fADC(0)
+{
+ //
+ // AliTRDarrayADC default constructor
+ //
+
+ CreateLut();
+
+}
+
+//____________________________________________________________________________________
+AliTRDarrayADC::AliTRDarrayADC(Int_t nrow, Int_t ncol, Int_t ntime)
+ :TObject()
+ ,fNdet(0)
+ ,fNrow(0)
+ ,fNcol(0)
+ ,fNumberOfChannels(0)
+ ,fNtime(0)
+ ,fNAdim(0)
+ ,fADC(0)
+{
+ //
+ // AliTRDarrayADC constructor
+ //
+
+ CreateLut();
+ Allocate(nrow,ncol,ntime);
+
+}
+
+//____________________________________________________________________________________
+AliTRDarrayADC::AliTRDarrayADC(const AliTRDarrayADC &b)
+ :TObject()
+ ,fNdet(b.fNdet)
+ ,fNrow(b.fNrow)
+ ,fNcol(b.fNcol)
+ ,fNumberOfChannels(b.fNumberOfChannels)
+ ,fNtime(b.fNtime)
+ ,fNAdim(b.fNAdim)
+ ,fADC(0)
+{
+ //
+ // AliTRDarrayADC copy constructor
+ //
+
+ fADC = new Short_t[fNAdim];
+ memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t));
+
+}
+
+//____________________________________________________________________________________
+AliTRDarrayADC::~AliTRDarrayADC()
+{
+ //
+ // AliTRDarrayADC destructor
+ //
+
+ if(fADC)
+ {
+ delete [] fADC;
+ fADC=0;
+ }
+
+}
+
+//____________________________________________________________________________________
+AliTRDarrayADC &AliTRDarrayADC::operator=(const AliTRDarrayADC &b)
+{
+ //
+ // Assignment operator
+ //
+
+ if(this==&b)
+ {
+ return *this;
+ }
+ if(fADC)
+ {
+ delete [] fADC;
+ }
+ fNdet=b.fNdet;
+ fNrow=b.fNrow;
+ fNcol=b.fNcol;
+ fNumberOfChannels = b.fNumberOfChannels;
+ fNtime=b.fNtime;
+ fNAdim=b.fNAdim;
+ fADC = new Short_t[fNAdim];
+ memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t));
+
+ return *this;
+
+}
+
+//____________________________________________________________________________________
+void AliTRDarrayADC::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
+{
+ //
+ // Allocate memory for an AliTRDarrayADC array with dimensions
+ // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
+ //
+
+ fNrow=nrow;
+ fNcol=ncol;
+ fNtime=ntime;
+ Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm();
+ Int_t padspermcm = AliTRDfeeParam::GetNcolMcm();
+ Int_t numberofmcms = fNcol/padspermcm;
+ fNumberOfChannels = numberofmcms*adcchannelspermcm;
+ fNAdim=nrow*fNumberOfChannels*ntime;
+
+ if(fADC)
+ {
+ delete [] fADC;
+ }
+
+ fADC = new Short_t[fNAdim];
+ memset(fADC,0,sizeof(Short_t)*fNAdim);
+
+}
+
+//____________________________________________________________________________________
+Short_t AliTRDarrayADC::GetDataBits(Int_t row, Int_t col, Int_t time) const
+{
+ //
+ // Get the ADC value for a given position: row, col, time
+ // Taking bit masking into account
+ //
+ // Adapted from code of the class AliTRDdataArrayDigits
+ //
+
+ Short_t tempval = GetData(row,col,time);
+ // Be aware of manipulations introduced by pad masking in the RawReader
+ // Only output the manipulated Value
+ CLRBIT(tempval, 10);
+ CLRBIT(tempval, 11);
+ CLRBIT(tempval, 12);
+ return tempval;
+
+}
+
+//____________________________________________________________________________________
+UChar_t AliTRDarrayADC::GetPadStatus(Int_t row, Int_t col, Int_t time) const
+{
+ //
+ // Returns the pad status stored in the pad signal
+ //
+ // Output is a UChar_t value
+ // Status Codes:
+ // Noisy Masking: 2
+ // Bridged Left Masking 8
+ // Bridged Right Masking 8
+ // Not Connected Masking Digits
+ //
+ // Adapted from code of the class AliTRDdataArrayDigits
+ //
+
+ UChar_t padstatus = 0;
+ Short_t signal = GetData(row,col,time);
+ if(signal > 0 && TESTBIT(signal, 10)){
+ if(TESTBIT(signal, 11))
+ if(TESTBIT(signal, 12))
+ padstatus = AliTRDCalPadStatus::kPadBridgedRight;
+ else
+ padstatus = AliTRDCalPadStatus::kNotConnected;
+ else
+ if(TESTBIT(signal, 12))
+ padstatus = AliTRDCalPadStatus::kPadBridgedLeft;
+ else
+ padstatus = AliTRDCalPadStatus::kMasked;
+ }
+
+ return padstatus;
+
+}
+
+//____________________________________________________________________________________
+void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t status)
+{
+ //
+ // Setting the pad status into the signal using the Bits 10 to 14
+ // (currently used: 10 to 12)
+ //
+ // Input codes (Unsigned char):
+ // Noisy Masking: 2
+ // Bridged Left Masking 8
+ // Bridged Right Masking 8
+ // Not Connected Masking 32
+ //
+ // Status codes: Any masking: Bit 10(1)
+ // Noisy masking: Bit 11(0), Bit 12(0)
+ // No Connection masking: Bit 11(1), Bit 12(0)
+ // Bridged Left masking: Bit 11(0), Bit 12(1)
+ // Bridged Right masking: Bit 11(1), Bit 12(1)
+ //
+ // Adapted from code of the class AliTRDdataArrayDigits
+ //
+
+ Short_t signal = GetData(row,col,time);
+
+ // Only set the Pad Status if the signal is > 0
+ if(signal > 0)
+ {
+ switch(status)
+ {
+ case AliTRDCalPadStatus::kMasked:
+ SETBIT(signal, 10);
+ CLRBIT(signal, 11);
+ CLRBIT(signal, 12);
+ break;
+ case AliTRDCalPadStatus::kNotConnected:
+ SETBIT(signal, 10);
+ SETBIT(signal, 11);
+ CLRBIT(signal, 12);
+ break;
+ case AliTRDCalPadStatus::kPadBridgedLeft:
+ SETBIT(signal, 10);
+ CLRBIT(signal, 11);
+ SETBIT(signal, 12);
+ break;
+ case AliTRDCalPadStatus::kPadBridgedRight:
+ SETBIT(signal, 10);
+ SETBIT(signal, 11);
+ SETBIT(signal, 12);
+ break;
+ default:
+ CLRBIT(signal, 10);
+ CLRBIT(signal, 11);
+ CLRBIT(signal, 12);
+ }
+ SetData(row, col, time, signal);
+ }
+
+}
+
+//____________________________________________________________________________________
+Bool_t AliTRDarrayADC::IsPadCorrupted(Int_t row, Int_t col, Int_t time)
+{
+ //
+ // Checks if the pad has any masking as corrupted (Bit 10 in signal set)
+ //
+ // Adapted from code of the class AliTRDdataArrayDigits
+ //
+
+ Short_t signal = GetData(row,col,time);
+ return (signal > 0 && TESTBIT(signal, 10)) ? kTRUE : kFALSE;
+
+}
+
+//____________________________________________________________________________________
+void AliTRDarrayADC::Compress()
+{
+ //
+ // Compress the array
+ //
+
+ Int_t counter=0;
+ Int_t newDim=0;
+ Int_t j;
+ Int_t l;
+ Int_t r=0;
+ Int_t s=0;
+ Int_t k=0;
+
+ Int_t *longm = new Int_t[fNAdim];
+ Int_t *longz = new Int_t[fNAdim];
+
+ if(longz && longm && fADC)
+ {
+
+ memset(longz,0,sizeof(Int_t)*fNAdim);
+ memset(longm,0,sizeof(Int_t)*fNAdim);
+
+ for(Int_t i=0;i<fNAdim; i++)
+ {
+ j=0;
+ if(fADC[i]==-1)
+ {
+ for(k=i;k<fNAdim;k++)
+ {
+ if((fADC[k]==-1)&&(j<16000))
+ {
+ j=j+1;
+ longm[r]=j;
+ }
+ else
+ {
+ break;
+ }
+ }
+ r=r+1;
+ }
+ l=16001;
+ if(fADC[i]==0)
+ {
+ for(k=i;k<fNAdim;k++)
+ {
+ if((fADC[k]==0)&&(l<32767))
+ {
+ l=l+1;
+ longz[s]=l;
+ }
+ else
+ {
+ break;
+ }
+ }
+ s=s+1;
+ }
+ if(fADC[i]>0)
+ {
+ i=i+1;
+ }
+ i=i+j+(l-16001-1);
+ }
+
+ //Calculate the size of the compressed array
+ for(Int_t i=0; i<fNAdim;i++)
+ {
+ if(longm[i]!=0)
+ {
+ counter=counter+longm[i]-1;
+ }
+ if(longz[i]!=0)
+ {
+ counter=counter+(longz[i]-16001)-1;
+ }
+ }
+
+ Int_t counterTwo=0;
+ newDim = fNAdim-counter; //Dimension of the compressed array
+ Short_t* buffer = new Short_t[newDim];
+
+ if(buffer)
+ {
+
+ //Fill the buffer of the compressed array
+ Int_t g=0;
+ Int_t h=0;
+ for(Int_t i=0; i<newDim; i++)
+ {
+ if(counterTwo<fNAdim)
+ {
+ if(fADC[counterTwo]>0)
+ {
+ buffer[i]=fADC[counterTwo];
+ }
+ if(fADC[counterTwo]==-1)
+ {
+ buffer[i]=-(longm[g]);
+ counterTwo=counterTwo+longm[g]-1;
+ g++;
+ }
+ if(fADC[counterTwo]==0)
+ {
+ buffer[i]=-(longz[h]);
+ counterTwo=counterTwo+(longz[h]-16001)-1;
+ h++;
+ }
+ counterTwo++;
+ }
+ }
+
+ //Copy the buffer
+ delete [] fADC;
+ fADC=0;
+ fADC = new Short_t[newDim];
+ fNAdim = newDim;
+ for(Int_t i=0; i<newDim; i++)
+ {
+ fADC[i] = buffer[i];
+ }
+
+ //Delete auxiliary arrays
+ delete [] buffer;
+ buffer=0;
+ }
+
+ }
+
+ if (longz)
+ {
+ delete [] longz;
+ longz=0;
+ }
+ if (longm)
+ {
+ delete [] longm;
+ longm=0;
+
+ }
+
+}
+
+//____________________________________________________________________________________
+void AliTRDarrayADC::Expand()
+{
+ //
+ // Expand the array
+ //
+
+ if (fADC)
+ {
+
+ //Check if the array has not been already expanded
+ Int_t verif=0;
+ for(Int_t i=0; i<fNAdim; i++)
+ {
+ if(fADC[i]<-1)
+ {
+ verif++;
+ }
+ }
+
+ if(verif==0)
+ {
+ //AliDebug(1,"Nothing to expand");
+ return;
+ }
+
+ Int_t dimexp=0;
+ Int_t *longz = new Int_t[fNAdim];
+ Int_t *longm = new Int_t[fNAdim];
+
+ if (longz && longm)
+ {
+
+ //Initialize arrays
+ memset(longz,0,sizeof(Int_t)*fNAdim);
+ memset(longm,0,sizeof(Int_t)*fNAdim);
+ Int_t r2=0;
+ Int_t r3=0;
+ for(Int_t i=0; i<fNAdim;i++)
+ {
+ if((fADC[i]<0)&&(fADC[i]>=-16000))
+ {
+ longm[r2]=-fADC[i];
+ r2++;
+ }
+ if(fADC[i]<-16000)
+ {
+ longz[r3]=-fADC[i]-16001;
+ r3++;
+ }
+ }
+
+ //Calculate the new dimensions of the array
+ for(Int_t i=0; i<fNAdim;i++)
+ {
+ if(longm[i]!=0)
+ {
+ dimexp=dimexp+longm[i]-1;
+ }
+ if(longz[i]!=0)
+ {
+ dimexp=dimexp+longz[i]-1;
+ }
+ }
+ dimexp=dimexp+fNAdim;
+
+ //Write in the buffer the new array
+ Int_t contaexp =0;
+ Int_t h=0;
+ Int_t l=0;
+ Short_t* bufferE = new Short_t[dimexp];
+ if(bufferE)
+ {
+ for(Int_t i=0; i<dimexp; i++)
+ {
+ if(fADC[contaexp]>0)
+ {
+ bufferE[i]=fADC[contaexp];
+ }
+ if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000))
+ {
+ for(Int_t j=0; j<longm[h];j++)
+ {
+ bufferE[i+j]=-1;
+ }
+ i=i+longm[h]-1;
+ h++;
+ }
+ if(fADC[contaexp]<-16000)
+ {
+ for(Int_t j=0; j<longz[l];j++)
+ {
+ bufferE[i+j]=0;
+ }
+ i=i+longz[l]-1;
+ l++;
+ }
+ contaexp++;
+ }
+ //Copy the buffer
+ delete [] fADC;
+ fADC = new Short_t[dimexp];
+ fNAdim = dimexp;
+ for(Int_t i=0; i<dimexp; i++)
+ {
+ fADC[i] = bufferE[i];
+ }
+
+ delete [] bufferE;
+
+ }
+
+ //Delete auxiliary arrays
+ delete [] longm;
+ delete [] longz;
+
+ }
+
+ }
+
+}
+//____________________________________________________________________________________
+void AliTRDarrayADC::DeleteNegatives()
+{
+
+ //
+ //This method modifies the digits array, changing the negative values (-1)
+ //Produced during digitization into zero.
+ //
+
+ for(Int_t a=0; a<fNAdim; a++)
+ {
+ if(fADC[a]==-1)
+ {
+ fADC[a]=0;
+ }
+ }
+}
+//________________________________________________________________________________
+void AliTRDarrayADC::Reset()
+{
+ //
+ // Reset the array, the old contents are deleted
+ // The array keeps the same dimensions as before
+ //
+
+ memset(fADC,0,sizeof(Short_t)*fNAdim);
+}
+//________________________________________________________________________________
+void AliTRDarrayADC::ConditionalReset(AliTRDSignalIndex* idx)
+{
+ //
+ // Reset the array, the old contents are deleted
+ // The array keeps the same dimensions as before
+ //
+
+ if(idx->GetNoOfIndexes()>25)
+ memset(fADC,0,sizeof(Short_t)*fNAdim);
+ else
+ {
+ Int_t row, col;
+ while(idx->NextRCIndex(row, col)){
+ Int_t colnumb = fgLutPadNumbering[col];
+ memset(&fADC[(row*fNumberOfChannels+colnumb)*fNtime],0,fNtime);
+ }
+ }
+
+}
+
+//________________________________________________________________________________
+void AliTRDarrayADC::CreateLut()
+{
+ //
+ // Initializes the Look Up Table to relate
+ // pad numbering and mcm channel numbering
+ //
+
+ if(fgLutPadNumbering) return;
+
+ fgLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
+ memset(fgLutPadNumbering,0,sizeof(Short_t)*AliTRDfeeParam::GetNcol());
+
+ for(Int_t mcm=0; mcm<8; mcm++)
+ {
+ Int_t lowerlimit=0+mcm*18;
+ Int_t upperlimit=18+mcm*18;
+ Int_t shiftposition = 1+3*mcm;
+ for(Int_t index=lowerlimit;index<upperlimit;index++)
+ {
+ fgLutPadNumbering[index]=index+shiftposition;
+ }
+ }
+}