]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALCalibData.cxx
Coverity 16153
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALCalibData.cxx
index 480f89f1e3adcc37914774ef31b8d63e48d5ba57..17f795eecb25dd31bcd66234d79d861e5028fd64 100644 (file)
@@ -57,10 +57,10 @@ 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)
@@ -85,10 +85,10 @@ 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)
@@ -115,8 +115,23 @@ 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.;
+        fADCchannel [supermodule][column][row]=1.;
+      }
+    }
+  } 
 }
 
 //________________________________________________________________
@@ -124,10 +139,10 @@ 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
+  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")) {
     printf("\n ----    Pedestal values ----\n\n");
     for (Int_t supermodule=0; supermodule<nSMod; supermodule++){
@@ -136,7 +151,7 @@ void  AliEMCALCalibData::Print(Option_t *option) const
       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(" %2.4f ",fADCpedestal[supermodule][column][row]);
        }
        printf("\n");
       }
@@ -152,7 +167,7 @@ void  AliEMCALCalibData::Print(Option_t *option) const
       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(" %2.4f ",fADCchannel[supermodule][column][row]);
        }
        printf("\n");
       }
@@ -191,3 +206,34 @@ void AliEMCALCalibData::SetADCpedestal(Int_t supermodule, Int_t column, Int_t ro
   // Set ADC pedestal values
   fADCpedestal[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;
+      }
+    }
+  } 
+}
+