]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALCalibData.cxx
remove exec
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibData.cxx
index 7c2fcecbd0307289e5924b81c7c68584133d308d..36bb21479456769cee7a5123962d23a72cce26e5 100644 (file)
 
 /* $Id$ */
 
+//_________________________________________________________________________
+///*-- Author: Yves Schutz (SUBATECH)
+//           : Aleksei Pavlinov (WSU); Jun 30, 2006 - ALICE numbering scheme
+//           : Add decalibration and time calibration arrays: Jul 21, 2011 (GCB)
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 // class for EMCAL calibration                                               //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TMath.h>
+
 #include "AliEMCALCalibData.h"
 
 ClassImp(AliEMCALCalibData)
@@ -52,20 +58,36 @@ AliEMCALCalibData::AliEMCALCalibData(const AliEMCALCalibData& calibda) :
   SetTitle(calibda.GetName());
   Reset();
 
-  Int_t nSMod = 12;
-  Int_t nCol  = 48;
-  Int_t nRow  = 24;
-  Int_t nRow2 = 12; //Modules 11 and 12 are half modules
+  Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
+  Int_t nCol  = AliEMCALGeoParams::fgkEMCALCols;    //48
+  Int_t nRow  = AliEMCALGeoParams::fgkEMCALRows;    //24
+  Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows;    //12 - Modules 11 and 12 are half modules
 
-  for(Int_t supermodule=0; supermodule<nSMod; supermodule++) {
-    if(supermodule > 10)
+  for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
+    
+    if(supermodule >= 10)
       nRow = nRow2;
-    for(Int_t column=0; column<nCol; column++) {
-      for(Int_t row=0; row<nRow; row++) {
-       fADCchannel[supermodule][column][row] = 
-         calibda.GetADCchannel(supermodule,column,row);
-       fADCpedestal[supermodule][column][row] = 
-         calibda.GetADCpedestal(supermodule,column,row);
+    
+    for(Int_t column = 0; column<nCol; column++) {
+      
+      for(Int_t row = 0; row<nRow; row++) {
+        
+        fADCchannel[supermodule][column][row] = 
+        calibda.GetADCchannel(supermodule,column,row);
+        
+        fADCchannelDecal[supermodule][column][row] = 
+        calibda.GetADCchannelDecal(supermodule,column,row);
+        
+        fADCpedestal[supermodule][column][row] = 
+        calibda.GetADCpedestal(supermodule,column,row);
+        
+        fTimeChannel[supermodule][column][row] = 
+        calibda.GetTimeChannel(supermodule,column,row);
+        
+        fTimeChannelDecal[supermodule][column][row] = 
+        calibda.GetTimeChannelDecal(supermodule,column,row);
+        
+        
       }
     }
   }
@@ -80,20 +102,35 @@ AliEMCALCalibData &AliEMCALCalibData::operator =(const AliEMCALCalibData& calibd
   SetTitle(calibda.GetName());
   Reset();
 
-  Int_t nSMod = 12;
-  Int_t nCol  = 48;
-  Int_t nRow  = 24;
-  Int_t nRow2 = 12; //Modules 11 and 12 are half modules
+  Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
+  Int_t nCol  = AliEMCALGeoParams::fgkEMCALCols;    //48
+  Int_t nRow  = AliEMCALGeoParams::fgkEMCALRows;    //24
+  Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2;  //12 - Modules 11 and 12 are half modules
 
-  for(Int_t supermodule=0; supermodule<nSMod; supermodule++) {
-    if(supermodule > 10)
+  for(Int_t supermodule = 0; supermodule < nSMod; supermodule++) {
+    
+    if(supermodule >= 10)
       nRow = nRow2;
-    for(Int_t column=0; column<nCol; column++) {
-      for(Int_t row=0; row<nRow; row++) {
-       fADCchannel[supermodule][column][row] = 
-         calibda.GetADCchannel(supermodule,column,row);
-       fADCpedestal[supermodule][column][row] = 
-         calibda.GetADCpedestal(supermodule,column,row);
+    
+    for(Int_t column = 0; column<nCol; column++) {
+      
+      for(Int_t row = 0; row<nRow; row++) {
+        
+        fADCchannel[supermodule][column][row] = 
+        calibda.GetADCchannel(supermodule,column,row);
+        
+        fADCchannelDecal[supermodule][column][row] = 
+        calibda.GetADCchannelDecal(supermodule,column,row);
+        
+        fADCpedestal[supermodule][column][row] = 
+        calibda.GetADCpedestal(supermodule,column,row);
+        
+        fTimeChannel[supermodule][column][row] = 
+        calibda.GetTimeChannel(supermodule,column,row);
+
+        fTimeChannelDecal[supermodule][column][row] = 
+        calibda.GetTimeChannelDecal(supermodule,column,row);
+        
       }
     }
   }
@@ -110,78 +147,228 @@ AliEMCALCalibData::~AliEMCALCalibData()
 void AliEMCALCalibData::Reset()
 {
   // Set all pedestals to 0 and all ADC channels widths to 1
-  memset(fADCchannel ,1,12*48*24*sizeof(Float_t));
-  memset(fADCpedestal,0,12*48*24*sizeof(Float_t));
+  //memset(fADCchannel ,1,12*48*24*sizeof(Float_t));
+  //memset(fADCpedestal,0,12*48*24*sizeof(Float_t));
+
+  Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
+  Int_t nCol  = AliEMCALGeoParams::fgkEMCALCols;    //48
+  Int_t nRow  = AliEMCALGeoParams::fgkEMCALRows;    //24
+  Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2;  //12 - Modules 11 and 12 are half modules
+  for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
+    if(supermodule >= 10)
+      nRow = nRow2;
+    for (Int_t column=0; column < nCol; column++){
+      
+      for (Int_t row = 0; row < nRow; row++){
+        
+        fADCpedestal     [supermodule][column][row]=0.;
+        
+        fADCchannelDecal [supermodule][column][row]=1.;
+        fADCchannel      [supermodule][column][row]=1.;
+        
+        fTimeChannel     [supermodule][column][row]=0.;
+        fTimeChannelDecal[supermodule][column][row]=0.;
+
+      }
+    }
+  } 
 }
 
 //________________________________________________________________
 void  AliEMCALCalibData::Print(Option_t *option) const
 {
   // Print tables of pedestals and ADC channels widths
-
-  Int_t nSMod = 12;
-  Int_t nCol  = 48;
-  Int_t nRow  = 24;
-  Int_t nRow2 = 12; //Modules 11 and 12 are half modules
-  if (strstr(option,"ped")) {
+  // options are: "gain", "ped", "decal", "time", "all"
+  
+  Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
+  Int_t nCol  = AliEMCALGeoParams::fgkEMCALCols;    //48
+  Int_t nRow  = AliEMCALGeoParams::fgkEMCALRows;    //24
+  Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2;  //12 - Modules 11 and 12 are half modules
+  if (strstr(option,"ped") || strstr(option,"all")) {
     printf("\n ----    Pedestal values ----\n\n");
     for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
-      if(supermodule > 10)
-       nRow = nRow2;
+      if(supermodule >= 10)
+        nRow = nRow2;
       printf("============== Supermodule %d\n",supermodule+1);
       for (Int_t column=0; column<nCol; column++){
-       for (Int_t row=0; row<nRow; row++){
-         printf("%4.1f",fADCpedestal[supermodule][column][row]);
-       }
-       printf("\n");
+        for (Int_t row=0; row<nRow; row++){
+          printf(" %2.4f ",fADCpedestal[supermodule][column][row]);
+        }
+        printf("\n");
       }
     } 
   }
-
-
-  if (strstr(option,"gain")) {
+  
+  if (strstr(option,"gain") || strstr(option,"all")) {
     printf("\n ----    ADC channel values      ----\n\n");
     for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
-      if(supermodule > 10) 
-       nRow = nRow2;
+      if(supermodule >= 10) 
+        nRow = nRow2;
+      printf("============== Supermodule %d\n",supermodule+1);
+      for (Int_t column=0; column<nCol; column++){
+        for (Int_t row=0; row<nRow; row++){
+          printf(" %2.4f ",fADCchannel[supermodule][column][row]);
+        }
+        printf("\n");
+      }
+    }   
+  }
+  
+  if (strstr(option,"adcdecal") || strstr(option,"all")) {
+    printf("\n ----    ADC decalibration channel values        ----\n\n");
+    for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
+      if(supermodule >= 10) 
+        nRow = nRow2;
       printf("============== Supermodule %d\n",supermodule+1);
       for (Int_t column=0; column<nCol; column++){
-       for (Int_t row=0; row<nRow; row++){
-         printf("%4.1f",fADCchannel[supermodule][column][row]);
-       }
-       printf("\n");
+        for (Int_t row=0; row<nRow; row++){
+          printf(" %2.4f ",fADCchannelDecal[supermodule][column][row]);
+        }
+        printf("\n");
       }
     }   
   }
+  
+  if (strstr(option,"time") || strstr(option,"all")) {
+    printf("\n ----    time channel values     ----\n\n");
+    for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
+      if(supermodule >= 10) 
+        nRow = nRow2;
+      printf("============== Supermodule %d\n",supermodule+1);
+      for (Int_t column=0; column<nCol; column++){
+        for (Int_t row=0; row<nRow; row++){
+          printf(" %2.4f ",fTimeChannel[supermodule][column][row]);
+        }
+        printf("\n");
+      }
+    }   
+  }
+  
+  
+  if (strstr(option,"time") || strstr(option,"all")) {
+    printf("\n ----    time decalibration channel values       ----\n\n");
+    for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
+      if(supermodule >= 10) 
+        nRow = nRow2;
+      printf("============== Supermodule %d\n",supermodule+1);
+      for (Int_t column=0; column<nCol; column++){
+        for (Int_t row=0; row<nRow; row++){
+          printf(" %2.4f ",fTimeChannelDecal[supermodule][column][row]);
+        }
+        printf("\n");
+      }
+    }   
+  }
+  
+  
 }
 
 //________________________________________________________________
 Float_t AliEMCALCalibData::GetADCchannel(Int_t supermodule, Int_t column, Int_t row) const
 {
   // Set ADC channel witdth values
-  //supermodule, column,raw should follow the internal EMCAL convention:
-  //supermodule 1:12, column 1:48, row 1:24
+  // All indexes start from 0!
+  // Supermodule, column,raw should follow the ALICE convention:
+  // supermodule 0:11, column 0:47, row 0:23
+
+  return fADCchannel[supermodule][column][row];
+}
 
-  return fADCchannel[supermodule-1][column-1][row-1];
+//________________________________________________________________
+Float_t AliEMCALCalibData::GetADCchannelDecal(Int_t supermodule, Int_t column, Int_t row) const
+{
+  // Set ADC channel decalibration witdth values
+  // All indexes start from 0!
+  // Supermodule, column,raw should follow the ALICE convention:
+  // supermodule 0:11, column 0:47, row 0:23
+  
+  return fADCchannelDecal[supermodule][column][row];
 }
 
 //________________________________________________________________
 Float_t AliEMCALCalibData::GetADCpedestal(Int_t supermodule, Int_t column, Int_t row) const
 {
   // Get ADC pedestal values
- return fADCpedestal[supermodule-1][column-1][row-1];
+ return fADCpedestal[supermodule][column][row];
+}
+
+//________________________________________________________________
+Float_t AliEMCALCalibData::GetTimeChannel(Int_t supermodule, Int_t column, Int_t row) const
+{
+  // Set channel time witdth values
+  return fTimeChannel[supermodule][column][row];
+}
+
+//________________________________________________________________
+Float_t AliEMCALCalibData::GetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row) const
+{
+  // Set channel time witdth values
+  return fTimeChannelDecal[supermodule][column][row];
 }
 
 //________________________________________________________________
 void AliEMCALCalibData::SetADCchannel(Int_t supermodule, Int_t column, Int_t row, Float_t value)
 { 
   // Set ADC channel width values
-  fADCchannel[supermodule-1][column-1][row-1] = value;
+  fADCchannel[supermodule][column][row] = value;
+}
+
+//________________________________________________________________
+void AliEMCALCalibData::SetADCchannelDecal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
+{ 
+  // Set ADC channel width values
+  fADCchannelDecal[supermodule][column][row] = value;
 }
 
 //________________________________________________________________
 void AliEMCALCalibData::SetADCpedestal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
 {
   // Set ADC pedestal values
-  fADCpedestal[supermodule-1][column-1][row-1] = value;
+  fADCpedestal[supermodule][column][row] = value;
+}
+
+//________________________________________________________________
+void AliEMCALCalibData::SetTimeChannel(Int_t supermodule, Int_t column, Int_t row, Float_t value)
+{
+  // Set ADC pedestal values
+  fTimeChannel[supermodule][column][row] = value;
+}
+
+//________________________________________________________________
+void AliEMCALCalibData::SetTimeChannelDecal(Int_t supermodule, Int_t column, Int_t row, Float_t value)
+{
+  // Set ADC pedestal values
+  fTimeChannelDecal[supermodule][column][row] = value;
+}
+
+
+//________________________________________________________________
+void AliEMCALCalibData::Fill(const AliEMCALCalibData *cd1, const AliEMCALCalibData *cd2, Bool_t print)
+{
+  // Fill for (relative) recalibration to undo calibration 
+  // from 1 and apply calibration from 2.
+
+  Int_t nSMod = AliEMCALGeoParams::fgkEMCALModules; //12
+  Int_t nCol  = AliEMCALGeoParams::fgkEMCALCols;    //48
+  Int_t nRow  = AliEMCALGeoParams::fgkEMCALRows;    //24
+  Int_t nRow2 = AliEMCALGeoParams::fgkEMCALRows/2;  //12 - Modules 11 and 12 are half modules
+  for (Int_t supermodule=0; supermodule<nSMod; supermodule++) {
+    if(supermodule >= 10)
+      nRow = nRow2;
+    for (Int_t column=0; column<nCol; column++) {
+      for (Int_t row=0; row<nRow; row++){
+        Double_t adc1 = cd1->GetADCchannel(supermodule, column, row);
+        Double_t ped1 = cd1->GetADCpedestal(supermodule, column, row);
+        Double_t adc2 = cd2->GetADCchannel(supermodule, column, row);
+        Double_t ped2 = cd2->GetADCpedestal(supermodule, column, row);
+        Double_t adc = adc2/adc1;
+        Double_t ped = ped2-adc*ped1;
+        if (print)
+          printf("%d %d %d: %f %f %f %f -> %f %f\n",supermodule,column,row,adc1,ped1,adc2,ped2,adc,ped);
+        fADCchannel [supermodule][column][row]=adc;
+        fADCpedestal[supermodule][column][row]=ped;
+      }
+    }
+  } 
 }
+