1 /*************************************************************************
2 * Copyright(c) 1998-2008, 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 **************************************************************************/
16 /* $Id: AliTRDarrayADC.cxx 25392 2008-04-23 19:40:29Z cblume $ */
18 ////////////////////////////////////////////////////////
20 // Container class for ADC values //
23 // Hermes Leon Vargas (hleon@ikf.uni-frankfurt.de) //
25 ////////////////////////////////////////////////////////
27 #include "AliTRDarrayADC.h"
28 #include "Cal/AliTRDCalPadStatus.h"
30 ClassImp(AliTRDarrayADC)
32 //____________________________________________________________________________________
33 AliTRDarrayADC::AliTRDarrayADC()
43 // AliTRDarrayADC default constructor
48 //____________________________________________________________________________________
49 AliTRDarrayADC::AliTRDarrayADC(Int_t nrow, Int_t ncol, Int_t ntime)
59 // AliTRDarrayADC constructor
62 Allocate(nrow,ncol,ntime);
66 //____________________________________________________________________________________
67 AliTRDarrayADC::AliTRDarrayADC(const AliTRDarrayADC &b)
77 // AliTRDarrayADC copy constructor
80 fADC = new Short_t[fNAdim];
81 memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t));
85 //____________________________________________________________________________________
86 AliTRDarrayADC::~AliTRDarrayADC()
89 // AliTRDarrayADC destructor
100 //____________________________________________________________________________________
101 AliTRDarrayADC &AliTRDarrayADC::operator=(const AliTRDarrayADC &b)
104 // Assignment operator
121 fADC = new Short_t[fNAdim];
122 memcpy(fADC,b.fADC, fNAdim*sizeof(Short_t));
128 //____________________________________________________________________________________
129 void AliTRDarrayADC::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
132 // Allocate memory for an AliTRDarrayADC array with dimensions
139 fNAdim=nrow*ncol*ntime;
146 fADC = new Short_t[fNAdim];
147 memset(fADC,0,sizeof(Short_t)*fNAdim);
151 //____________________________________________________________________________________
152 Short_t AliTRDarrayADC::GetDataB(Int_t row, Int_t col, Int_t time) const
155 // Get the ADC value for a given position: row, col, time
156 // Taking bit masking into account
158 // Adapted from code of the class AliTRDdataArrayDigits
161 Short_t tempval = fADC[(row*fNcol+col)*fNtime+time];
162 // Be aware of manipulations introduced by pad masking in the RawReader
163 // Only output the manipulated Value
171 //____________________________________________________________________________________
172 UChar_t AliTRDarrayADC::GetPadStatus(Int_t row, Int_t col, Int_t time) const
175 // Returns the pad status stored in the pad signal
177 // Output is a UChar_t value
180 // Bridged Left Masking 8
181 // Bridged Right Masking 8
182 // Not Connected Masking Digits
184 // Adapted from code of the class AliTRDdataArrayDigits
187 UChar_t padstatus = 0;
188 Short_t signal = GetData(row,col,time);
189 if(signal > 0 && TESTBIT(signal, 10)){
190 if(TESTBIT(signal, 11))
191 if(TESTBIT(signal, 12))
192 padstatus = AliTRDCalPadStatus::kPadBridgedRight;
194 padstatus = AliTRDCalPadStatus::kNotConnected;
196 if(TESTBIT(signal, 12))
197 padstatus = AliTRDCalPadStatus::kPadBridgedLeft;
199 padstatus = AliTRDCalPadStatus::kMasked;
206 //____________________________________________________________________________________
207 void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t status)
210 // Setting the pad status into the signal using the Bits 10 to 14
211 // (currently used: 10 to 12)
213 // Input codes (Unsigned char):
215 // Bridged Left Masking 8
216 // Bridged Right Masking 8
217 // Not Connected Masking 32
219 // Status codes: Any masking: Bit 10(1)
220 // Noisy masking: Bit 11(0), Bit 12(0)
221 // No Connection masking: Bit 11(1), Bit 12(0)
222 // Bridged Left masking: Bit 11(0), Bit 12(1)
223 // Bridged Right masking: Bit 11(1), Bit 12(1)
225 // Adapted from code of the class AliTRDdataArrayDigits
228 Short_t signal = GetData(row,col,time);
230 // Only set the Pad Status if the signal is > 0
235 case AliTRDCalPadStatus::kMasked:
240 case AliTRDCalPadStatus::kNotConnected:
245 case AliTRDCalPadStatus::kPadBridgedLeft:
250 case AliTRDCalPadStatus::kPadBridgedRight:
259 SetData(row, col, time, signal);
264 //____________________________________________________________________________________
265 Bool_t AliTRDarrayADC::IsPadCorrupted(Int_t row, Int_t col, Int_t time)
268 // Checks if the pad has any masking as corrupted (Bit 10 in signal set)
270 // Adapted from code of the class AliTRDdataArrayDigits
273 Short_t signal = GetData(row,col,time);
274 return (signal > 0 && TESTBIT(signal, 10)) ? kTRUE : kFALSE;
278 //____________________________________________________________________________________
279 void AliTRDarrayADC::Compress()
282 // Compress the array
292 longm = new Int_t[fNAdim];
294 longz = new Int_t[fNAdim];
296 memset(longz,0,sizeof(Int_t)*fNAdim);
297 memset(longm,0,sizeof(Int_t)*fNAdim);
299 for(Int_t i=0;i<fNAdim; i++)
304 for(k=i;k<fNAdim;k++)
306 if((fADC[k]==-1)&&(j<16000))
321 for(k=i;k<fNAdim;k++)
323 if((fADC[k]==0)&&(l<32767))
342 //Calculate the size of the compressed array
343 for(Int_t i=0; i<fNAdim;i++)
347 counter=counter+longm[i]-1;
351 counter=counter+(longz[i]-16001)-1;
354 newDim = fNAdim-counter; //Dimension of the compressed array
356 buffer = new Short_t[newDim];
359 //Fill the buffer of the compressed array
362 for(Int_t i=0; i<newDim; i++)
364 if(counterTwo<fNAdim)
366 if(fADC[counterTwo]>0)
368 buffer[i]=fADC[counterTwo];
370 if(fADC[counterTwo]==-1)
372 buffer[i]=-(longm[g]);
373 counterTwo=counterTwo+longm[g]-1;
376 if(fADC[counterTwo]==0)
378 buffer[i]=-(longz[h]);
379 counterTwo=counterTwo+(longz[h]-16001)-1;
392 fADC = new Short_t[newDim];
394 for(Int_t i=0; i<newDim; i++)
399 //Delete auxiliary arrays
418 //____________________________________________________________________________________
419 void AliTRDarrayADC::Expand()
425 //Check if the array has not been already expanded
427 for(Int_t i=0; i<fNAdim; i++)
437 // AliDebug(1,"Nothing to expand");
442 longz = new Int_t[fNAdim];
444 longm = new Int_t[fNAdim];
447 memset(longz,0,sizeof(Int_t)*fNAdim);
448 memset(longm,0,sizeof(Int_t)*fNAdim);
451 for(Int_t i=0; i<fNAdim;i++)
453 if((fADC[i]<0)&&(fADC[i]>=-16000))
460 longz[r3]=-fADC[i]-16001;
464 //Calculate the new dimensions of the array
465 for(Int_t i=0; i<fNAdim;i++)
469 dimexp=dimexp+longm[i]-1;
473 dimexp=dimexp+longz[i]-1;
476 dimexp=dimexp+fNAdim;
478 //Write in the buffer the new array
480 bufferE = new Short_t[dimexp];
484 for(Int_t i=0; i<dimexp; i++)
488 bufferE[i]=fADC[contaexp];
491 if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000))
493 for(Int_t j=0; j<longm[h];j++)
500 if(fADC[contaexp]<-16000)
502 for(Int_t j=0; j<longz[l];j++)
518 fADC = new Short_t[dimexp];
520 for(Int_t i=0; i<dimexp; i++)
522 fADC[i] = bufferE[i];
525 //Delete auxiliary arrays
526 if(bufferE) delete [] bufferE;
527 if(longm) delete [] longm;
528 if(longz) delete [] longz;
531 //____________________________________________________________________________________
532 void AliTRDarrayADC::DeleteNegatives()
536 //This method modifies the digits array, changing the negative values (-1)
537 //Produced during digitization into zero.
540 for(Int_t a=0; a<fNAdim; a++)
548 //________________________________________________________________________________
549 void AliTRDarrayADC::Reset()
552 // Reset the array, the old contents are deleted
553 // The array keeps the same dimensions as before
556 memset(fADC,0,sizeof(Short_t)*fNAdim);