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 for(Int_t i=0; i<fNAdim; i++)
88 //____________________________________________________________________________________
89 AliTRDarrayADC::~AliTRDarrayADC()
92 // AliTRDarrayADC destructor
103 //____________________________________________________________________________________
104 AliTRDarrayADC &AliTRDarrayADC::operator=(const AliTRDarrayADC &b)
107 // Assignment operator
124 fADC = new Short_t[fNAdim];
125 for(Int_t i=0;i<fNAdim;i++)
133 //____________________________________________________________________________________
134 void AliTRDarrayADC::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
137 // Allocate memory for an AliTRDarrayADC array with dimensions
144 fNAdim=nrow*ncol*ntime;
151 fADC = new Short_t[fNAdim];
152 for(Int_t a=0; a<fNAdim; a++)
159 //____________________________________________________________________________________
160 Short_t AliTRDarrayADC::GetDataB(Int_t row, Int_t col, Int_t time) const
163 // Get the ADC value for a given position: row, col, time
164 // Taking bit masking into account
166 // Adapted from code of the class AliTRDdataArrayDigits
169 Short_t tempval = fADC[(row*fNcol+col)*fNtime+time];
170 // Be aware of manipulations introduced by pad masking in the RawReader
171 // Only output the manipulated Value
179 //____________________________________________________________________________________
180 UChar_t AliTRDarrayADC::GetPadStatus(Int_t row, Int_t col, Int_t time) const
183 // Returns the pad status stored in the pad signal
185 // Output is a UChar_t value
188 // Bridged Left Masking 8
189 // Bridged Right Masking 8
190 // Not Connected Masking Digits
192 // Adapted from code of the class AliTRDdataArrayDigits
195 UChar_t padstatus = 0;
196 Short_t signal = GetData(row,col,time);
197 if(signal > 0 && TESTBIT(signal, 10)){
198 if(TESTBIT(signal, 11))
199 if(TESTBIT(signal, 12))
200 padstatus = AliTRDCalPadStatus::kPadBridgedRight;
202 padstatus = AliTRDCalPadStatus::kNotConnected;
204 if(TESTBIT(signal, 12))
205 padstatus = AliTRDCalPadStatus::kPadBridgedLeft;
207 padstatus = AliTRDCalPadStatus::kMasked;
214 //____________________________________________________________________________________
215 void AliTRDarrayADC::SetPadStatus(Int_t row, Int_t col, Int_t time, UChar_t status)
218 // Setting the pad status into the signal using the Bits 10 to 14
219 // (currently used: 10 to 12)
221 // Input codes (Unsigned char):
223 // Bridged Left Masking 8
224 // Bridged Right Masking 8
225 // Not Connected Masking 32
227 // Status codes: Any masking: Bit 10(1)
228 // Noisy masking: Bit 11(0), Bit 12(0)
229 // No Connection masking: Bit 11(1), Bit 12(0)
230 // Bridged Left masking: Bit 11(0), Bit 12(1)
231 // Bridged Right masking: Bit 11(1), Bit 12(1)
233 // Adapted from code of the class AliTRDdataArrayDigits
236 Short_t signal = GetData(row,col,time);
238 // Only set the Pad Status if the signal is > 0
243 case AliTRDCalPadStatus::kMasked:
248 case AliTRDCalPadStatus::kNotConnected:
253 case AliTRDCalPadStatus::kPadBridgedLeft:
258 case AliTRDCalPadStatus::kPadBridgedRight:
267 SetData(row, col, time, signal);
272 //____________________________________________________________________________________
273 Bool_t AliTRDarrayADC::IsPadCorrupted(Int_t row, Int_t col, Int_t time)
276 // Checks if the pad has any masking as corrupted (Bit 10 in signal set)
278 // Adapted from code of the class AliTRDdataArrayDigits
281 Short_t signal = GetData(row,col,time);
282 return (signal > 0 && TESTBIT(signal, 10)) ? kTRUE : kFALSE;
286 //____________________________________________________________________________________
287 void AliTRDarrayADC::Compress()
290 // Compress the array
300 longm = new Int_t[fNAdim];
302 longz = new Int_t[fNAdim];
304 for(Int_t i=0; i<fNAdim;i++)
310 for(Int_t i=0;i<fNAdim; i++)
315 for(k=i;k<fNAdim;k++)
317 if((fADC[k]==-1)&&(j<16000))
332 for(k=i;k<fNAdim;k++)
334 if((fADC[k]==0)&&(l<32767))
353 //Calculate the size of the compressed array
354 for(Int_t i=0; i<fNAdim;i++)
358 counter=counter+longm[i]-1;
362 counter=counter+(longz[i]-16001)-1;
365 newDim = fNAdim-counter; //Dimension of the compressed array
367 buffer = new Short_t[newDim];
370 //Fill the buffer of the compressed array
373 for(Int_t i=0; i<newDim; i++)
375 if(counterTwo<fNAdim)
377 if(fADC[counterTwo]>0)
379 buffer[i]=fADC[counterTwo];
381 if(fADC[counterTwo]==-1)
383 buffer[i]=-(longm[g]);
384 counterTwo=counterTwo+longm[g]-1;
387 if(fADC[counterTwo]==0)
389 buffer[i]=-(longz[h]);
390 counterTwo=counterTwo+(longz[h]-16001)-1;
403 fADC = new Short_t[newDim];
405 for(Int_t i=0; i<newDim; i++)
410 //Delete auxiliary arrays
429 //____________________________________________________________________________________
430 void AliTRDarrayADC::Expand()
436 //Check if the array has not been already expanded
438 for(Int_t i=0; i<fNAdim; i++)
448 // AliDebug(1,"Nothing to expand");
453 longz = new Int_t[fNAdim];
455 longm = new Int_t[fNAdim];
458 for(Int_t i=0; i<fNAdim;i++)
465 for(Int_t i=0; i<fNAdim;i++)
467 if((fADC[i]<0)&&(fADC[i]>=-16000))
474 longz[r3]=-fADC[i]-16001;
478 //Calculate the new dimensions of the array
479 for(Int_t i=0; i<fNAdim;i++)
483 dimexp=dimexp+longm[i]-1;
487 dimexp=dimexp+longz[i]-1;
490 dimexp=dimexp+fNAdim;
492 //Write in the buffer the new array
494 bufferE = new Short_t[dimexp];
498 for(Int_t i=0; i<dimexp; i++)
502 bufferE[i]=fADC[contaexp];
505 if((fADC[contaexp]<0)&&(fADC[contaexp]>=-16000))
507 for(Int_t j=0; j<longm[h];j++)
514 if(fADC[contaexp]<-16000)
516 for(Int_t j=0; j<longz[l];j++)
532 fADC = new Short_t[dimexp];
534 for(Int_t i=0; i<dimexp; i++)
536 fADC[i] = bufferE[i];
539 //Delete auxiliary arrays
540 if(bufferE) delete [] bufferE;
541 if(longm) delete [] longm;
542 if(longz) delete [] longz;
545 //____________________________________________________________________________________
546 void AliTRDarrayADC::DeleteNegatives()
550 //This method modifies the digits array, changing the negative values (-1)
551 //Produced during digitization into zero.
554 for(Int_t a=0; a<fNAdim; a++)