Add shared pads also to dictionary and signal array
[u/mrichter/AliRoot.git] / TRD / AliTRDarrayDictionary.cxx
index 335e212..94c98ea 100644 (file)
 
 #include "AliTRDarrayDictionary.h"
 #include "TArray.h"
+#include "AliTRDfeeParam.h"
 
 ClassImp(AliTRDarrayDictionary)
 
+Short_t *AliTRDarrayDictionary::fLutPadNumbering = 0x0;
+
 //________________________________________________________________________________
 AliTRDarrayDictionary::AliTRDarrayDictionary()
                       :TObject()
                       ,fNdet(0)
                       ,fNrow(0)
                       ,fNcol(0)
+                     ,fNumberOfChannels(0)
                       ,fNtime(0)
                       ,fNDdim(0)
                       ,fDictionary(0)
@@ -43,6 +47,8 @@ AliTRDarrayDictionary::AliTRDarrayDictionary()
   // AliTRDarrayDictionary default contructor
   //
 
+  CreateLut();
+
 }
 
 //________________________________________________________________________________
@@ -51,6 +57,7 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime
                      ,fNdet(0)
                       ,fNrow(0)
                       ,fNcol(0)
+                     ,fNumberOfChannels(0)
                       ,fNtime(0)
                      ,fNDdim(0)
                      ,fDictionary(0)
@@ -60,6 +67,7 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(Int_t nrow, Int_t ncol, Int_t ntime
   // AliTRDarrayDictionary contructor
   //
 
+  CreateLut();
   Allocate(nrow,ncol,ntime);
 
 }
@@ -70,6 +78,7 @@ AliTRDarrayDictionary::AliTRDarrayDictionary(const AliTRDarrayDictionary &a)
                      ,fNdet(a.fNdet)
                       ,fNrow(a.fNrow)
                       ,fNcol(a.fNcol)
+                     ,fNumberOfChannels(a.fNumberOfChannels)
                       ,fNtime(a.fNtime)
                      ,fNDdim(a.fNDdim)
                      ,fDictionary(0)
@@ -121,6 +130,7 @@ AliTRDarrayDictionary &AliTRDarrayDictionary::operator=(const AliTRDarrayDiction
   fNDdim=a.fNDdim;
   fNrow=a.fNrow;
   fNcol=a.fNcol;
+  fNumberOfChannels = a.fNumberOfChannels;
   fNtime=a.fNtime;
   fDictionary = new Int_t[fNDdim];
   for(Int_t i=0; i<fNDdim; i++)
@@ -136,14 +146,19 @@ void AliTRDarrayDictionary::Allocate(Int_t nrow, Int_t ncol, Int_t ntime)
 {
   //
   // Allocates memory for the dictionary array with dimensions
-  // Row*Col*Time
+  // Row*NumberOfNecessaryMCMs*ADCchannelsInMCM*Time
+  // To be consistent with AliTRDarrayADC
   // Object initialized to -1
   //
 
   fNrow=nrow;
   fNcol=ncol;
   fNtime=ntime;
-  fNDdim=nrow*ncol*ntime;
+  Int_t adcchannelspermcm = AliTRDfeeParam::GetNadcMcm(); 
+  Int_t padspermcm = AliTRDfeeParam::GetNcolMcm(); 
+  Int_t numberofmcms = fNcol/padspermcm;
+  fNumberOfChannels = numberofmcms*adcchannelspermcm;
+  fNDdim=nrow*fNumberOfChannels*ntime;
   if(fDictionary)
     {
       delete [] fDictionary;
@@ -340,3 +355,56 @@ void AliTRDarrayDictionary::Reset()
   memset(fDictionary,0,sizeof(Int_t)*fNDdim);
 
 }
+//________________________________________________________________________________
+Int_t AliTRDarrayDictionary::GetData(Int_t nrow, Int_t ncol, Int_t ntime) const
+{
+  //
+  // Get the data using the pad numbering.
+  // To access data using the mcm scheme use instead
+  // the method GetDataByAdcCol
+  //
+
+  Int_t corrcolumn = fLutPadNumbering[ncol];
+
+  return fDictionary[(nrow*fNumberOfChannels+corrcolumn)*fNtime+ntime];
+
+}
+//________________________________________________________________________________
+void AliTRDarrayDictionary::SetData(Int_t nrow, Int_t ncol, Int_t ntime, Int_t value)
+{
+  //
+  // Set the data using the pad numbering.
+  // To write data using the mcm scheme use instead
+  // the method SetDataByAdcCol
+  //
+
+  Int_t colnumb = fLutPadNumbering[ncol];
+
+  fDictionary[(nrow*fNumberOfChannels+colnumb)*fNtime+ntime]=value;
+
+}
+
+//________________________________________________________________________________
+void AliTRDarrayDictionary::CreateLut()
+{
+  //
+  // Initializes the Look Up Table to relate
+  // pad numbering and mcm channel numbering
+  //
+
+  if(fLutPadNumbering)  return;
+  
+   fLutPadNumbering = new Short_t[AliTRDfeeParam::GetNcol()];
+   memset(fLutPadNumbering,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++)
+       {
+         fLutPadNumbering[index]=index+shiftposition;
+       }
+    }
+}