]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSModuleDaSSD.cxx
Update for the value of the density of the foam inside the support cylinder between...
[u/mrichter/AliRoot.git] / ITS / AliITSModuleDaSSD.cxx
index 95773b5aba3600a8e20c6425849f242cb758653a..2b3efb489bf77690d0e391d22d78ac4ee6ff10b9 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id:$  */
+/* $Id$  */
 
 ///////////////////////////////////////////////////////////////////////////////
 ///
 /// This class provides storage container ITS SSD module callibration data
 /// used by DA. 
-///
+/// 
+/// Date: 09/07/2009
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliITSNoiseSSD.h"
@@ -55,6 +56,7 @@ AliITSModuleDaSSD::AliITSModuleDaSSD() :
   fStrips(NULL),
   fNumberOfChips(0),
   fCm(NULL),
+  fCmFerom(NULL),
   fEventsNumber(0)
 {
 // Default constructor
@@ -73,6 +75,7 @@ AliITSModuleDaSSD::AliITSModuleDaSSD(const UChar_t ddlID, const UChar_t ad, cons
   fStrips(NULL),
   fNumberOfChips(0),
   fCm(NULL),
+  fCmFerom(NULL),
   fEventsNumber(0)
 {
 // Constructor, set module id data
@@ -92,9 +95,10 @@ AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips) :
   fStrips(NULL),
   fNumberOfChips(0),
   fCm(NULL),
+  fCmFerom(NULL),
   fEventsNumber(0)
 {
-// Constructor, allocates memory for AliITSChannelDaSSD*
+// Constructor, allocates memory for AliITSChannelDaSSD* and TArrayS* array for CM calculated in FEROM
   if (numberofstrips != fgkStripsPerModule) 
     AliWarning(Form("AliITSModuleDaSSD: ALICE ITS SSD Module contains %i strips", fgkStripsPerModule));
   fStrips = new (nothrow) AliITSChannelDaSSD* [numberofstrips];
@@ -121,6 +125,7 @@ AliITSModuleDaSSD::AliITSModuleDaSSD(const Int_t numberofstrips, const Long_t ev
   fStrips(NULL),
   fNumberOfChips(0),
   fCm(NULL),
+  fCmFerom(NULL),
   fEventsNumber(0)
 {
 // Constructor, allocates memory for AliITSChannelDaSSD* and events data
@@ -156,6 +161,7 @@ AliITSModuleDaSSD::AliITSModuleDaSSD(const AliITSModuleDaSSD& module) :
   fStrips(NULL),
   fNumberOfChips(module.fNumberOfChips),
   fCm(NULL),
+  fCmFerom(NULL),
   fEventsNumber(module.fEventsNumber)
 {
 // copy constructor
@@ -189,7 +195,17 @@ AliITSModuleDaSSD::AliITSModuleDaSSD(const AliITSModuleDaSSD& module) :
        fNumberOfChips = 0;
        fCm = NULL;
     }  
-  }  
+  }
+  
+  if (module.fCmFerom) {
+    fCmFerom = new (nothrow) TArrayS [fgkChipsPerModule];
+    if (fCmFerom) {
+      for (Int_t chind = 0; chind < fgkChipsPerModule; chind++) fCmFerom[chind] = module.fCmFerom[chind]; 
+    } else {
+       AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayS objects!", fgkChipsPerModule));
+       fCmFerom = NULL;
+    }  
+  }
 }
 
 
@@ -199,9 +215,11 @@ AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& modul
 {
 // assignment operator
   if (this == &module)  return *this;  
+  TObject::operator=(module);
   if (fStrips) {
     for (Long_t i = 0; i < fNumberOfStrips; i++) if (fStrips[i]) delete fStrips[i];
     delete [] fStrips;
+    fStrips = NULL;
   } 
   fEquipId = module.fEquipId;
   fEquipType = module.fEquipType;
@@ -209,7 +227,6 @@ AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& modul
   fAd = module.fAd;
   fAdc = module.fAdc;
   fModuleId = module.fModuleId;
-  fNumberOfStrips = module.fNumberOfStrips;
   fStrips = NULL;
   fNumberOfChips = module.fNumberOfChips;
   fCm = NULL;
@@ -217,18 +234,21 @@ AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& modul
   if ((module.fNumberOfStrips > 0) && (module.fStrips)) {
     fStrips = new (nothrow) AliITSChannelDaSSD* [module.fNumberOfStrips];
     if (fStrips) {
+      memset(fStrips, 0, (sizeof(AliITSChannelDaSSD*) * module.fNumberOfStrips));
       for (Int_t strind = 0; strind < module.fNumberOfStrips; strind++) {
         if (module.fStrips[strind]) {
-         fStrips[strind] = new AliITSChannelDaSSD(*(module.fStrips[strind]));
-         if (!fStrips[strind]) { 
-           AliError("AliITSModuleDaSSD: Error copy constructor");
+          fStrips[strind] = new AliITSChannelDaSSD(*(module.fStrips[strind]));
+          if (!fStrips[strind]) { 
+            AliError("AliITSModuleDaSSD: Error copy constructor");
             for (Int_t i = (strind - 1); i >= 0; i--) delete fStrips[strind];
-           delete [] fStrips;
-           fStrips = NULL;
-           break;
-         }
-       } else fStrips[strind] = NULL; 
-      }          
+            delete [] fStrips;
+            fStrips = NULL;
+            fNumberOfStrips = 0;
+            break;
+          }
+        } else fStrips[strind] = NULL; 
+      }
+      fNumberOfStrips = module.fNumberOfStrips;
     } else {
        AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i AliITSChannelDaSSD* objects!", module.fNumberOfStrips));
        fNumberOfStrips = 0;
@@ -246,6 +266,16 @@ AliITSModuleDaSSD& AliITSModuleDaSSD::operator = (const AliITSModuleDaSSD& modul
        fCm = NULL;
     }  
   }  
+  if (fCmFerom) { delete [] fCmFerom; fCmFerom = NULL; }
+  if (module.fCmFerom) {
+    fCmFerom = new (nothrow) TArrayS [module.fNumberOfChips];
+    if (fCmFerom) {
+      for (Int_t chind = 0; chind < fgkChipsPerModule; chind++) fCmFerom[chind] = module.fCmFerom[chind]; 
+    } else {
+       AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayS objects!", fgkChipsPerModule));
+       fCmFerom = NULL;
+    }  
+  }  
   return *this;
 }
     
@@ -264,6 +294,7 @@ AliITSModuleDaSSD::~AliITSModuleDaSSD()
     delete [] fStrips;
   } 
   if (fCm) delete [] fCm;
+  if (fCmFerom) delete [] fCmFerom;
 }
 
 
@@ -361,14 +392,14 @@ Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber)
   Int_t i;
   if (!fStrips) return kFALSE;
   for (i = 0; i < fNumberOfStrips; i++) {
-    if (fStrips[i])  
+    if (fStrips[i]) { 
       if (!fStrips[i]->SetEvenetsNumber(eventsnumber)) {
         for (Int_t j = 0; j < i; j++) fStrips[j]->DeleteSignal();
-        AliError(Form("AliITSModuleDaSSD: Error allocating memory for i% events for module %i, strip %i", 
-                                   eventsnumber, (Int_t)fModuleId, i));
+        AliError(Form("AliITSModuleDaSSD: Error allocating memory for %ld event for module %d, strip %d",eventsnumber, (Int_t)fModuleId, i));
         return kFALSE;
       }
-    else 
+    }
+    else { 
       if (!(fStrips[i] = new AliITSChannelDaSSD(i, eventsnumber))) {
         for (Int_t j = 0; j < i; j++) delete fStrips[j];
         delete [] fStrips;
@@ -377,7 +408,9 @@ Bool_t AliITSModuleDaSSD::SetEventsNumber(const Long_t eventsnumber)
         AliError(Form("AliITSModuleDaSSD: Error allocating memory for strip %i of module %i!", (Int_t)fModuleId, i));
         return kFALSE;
       }
-  } 
+    }
+  }
+  fEventsNumber = eventsnumber;
   return kTRUE;
 }
 
@@ -405,74 +438,60 @@ Float_t  AliITSModuleDaSSD::GetCM(const Int_t chipn, const Long_t evn)   const
 }
 
 
-
 //______________________________________________________________________________
-AliITSNoiseSSD* AliITSModuleDaSSD::GetCalibrationNoise() const
+Bool_t  AliITSModuleDaSSD::AllocateCMFeromArray(void)
 {
-// Creates the AliITSNoiseSSD objects with callibration data
-  AliITSNoiseSSD  *mc;
-  Float_t          noise;
-  if (!fStrips) return NULL;
-  mc = new AliITSNoiseSSD();
-  mc->SetMod(fModuleId);
-  mc->SetNNoiseP(fgkPNStripsPerModule);
-  mc->SetNNoiseN(fgkPNStripsPerModule);
-  for (Int_t i = 0; i < fNumberOfStrips; i++) {
-    if (!fStrips[i]) noise = AliITSChannelDaSSD::GetUndefinedValue();
-    else  noise = fStrips[i]->GetNoiseCM();
-    if (i < fgkPNStripsPerModule)
-          mc->AddNoiseP(i, noise);
-    else  mc->AddNoiseN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), noise);                     
+// Allocates memory for the channels which contains CM calculated in Ferom
+ if (!fCmFerom) { 
+    fCmFerom = new (nothrow) TArrayS [fgkChipsPerModule];
+    if (!fCmFerom) {
+       AliError(Form("AliITSModuleDaSSD: Error allocating memory for %i TArrayS objects!", fgkChipsPerModule));
+       fCmFerom = NULL;
+       return kFALSE;
+    }
   }
-  return mc;
+  return kTRUE;
 }
 
 
-
 //______________________________________________________________________________
-AliITSPedestalSSD* AliITSModuleDaSSD::GetCalibrationPedestal() const
+Bool_t  AliITSModuleDaSSD::SetCMFeromEventsNumber(const Long_t eventsnumber)
 {
-// Creates the AliITSPedestalSSD objects with callibration data
-  AliITSPedestalSSD  *mc;
-  Float_t             ped;
-  if (!fStrips) return NULL;
-  mc = new AliITSPedestalSSD();
-  mc->SetMod(fModuleId);
-  mc->SetNPedestalP(fgkPNStripsPerModule);
-  mc->SetNPedestalN(fgkPNStripsPerModule);
-  for (Int_t i = 0; i < fNumberOfStrips; i++) {
-    if (!fStrips[i]) ped = AliITSChannelDaSSD::GetUndefinedValue();
-    else  ped = fStrips[i]->GetPedestal();
-    if (i < fgkPNStripsPerModule)
-          mc->AddPedestalP(i, ped);
-    else  mc->AddPedestalN((AliITSChannelDaSSD::GetMaxStripIdConst() - i), ped);                     
+// Allocates memory for the values of CM calculated in Ferom
+  if (!fCmFerom) return kFALSE;
+  for (Int_t chipind = 0; chipind < fgkChipsPerModule; chipind++) {
+      fCmFerom[chipind].Set(eventsnumber);
+      fCmFerom[chipind].Reset(0);
   }
-  return mc;
+  return kTRUE;
 }
 
+//______________________________________________________________________________
+Bool_t AliITSModuleDaSSD::SetCMFerom (const Short_t cm, const Int_t chipn, const Int_t evn)
+{ 
+// Set value of FeromCM for a given chip and event 
+  if ((!fCmFerom) || (chipn >= fgkChipsPerModule)) return kFALSE;
+  if (evn >= fCmFerom[chipn].GetSize()) return kFALSE;
+  else fCmFerom[chipn][evn] = cm;
+  return kTRUE;
+}
+
+
+void  AliITSModuleDaSSD::SetCMFerom (Short_t* cm, const Int_t chipn)
+// Set value of FeromCM for a given chip
+{ 
+  if (!fCmFerom) 
+    if (!AllocateCMFeromArray()) return;
+  if (chipn < fgkChipsPerModule) fCmFerom[chipn].Set(fCmFerom[chipn].GetSize(), cm); 
+}
 
 
 //______________________________________________________________________________
-AliITSBadChannelsSSD* AliITSModuleDaSSD::GetCalibrationBadChannels() const
-{
-// Creates the AliITSBadChannelsSSD objects with callibration data
-  AliITSBadChannelsSSD  *mc;
-  Int_t                 *chlist, nch = 0, nchn = 0, nchp = 0;
-  if (!fStrips) return NULL;
-  chlist = new Int_t [GetStripsPerModuleConst()];
-  for (Int_t i = 0; i < fNumberOfStrips; i++) {
-    if (!fStrips[i]) { chlist[nch++] = i; if (i < fgkPNStripsPerModule) nchp++; else nchn++; continue;}
-    if (fStrips[i]->GetNoiseCM() == AliITSChannelDaSSD::GetUndefinedValue())
-       { chlist[nch++] = i; if (i < fgkPNStripsPerModule) nchp++; else nchn++; }
-  }
-  mc = new AliITSBadChannelsSSD();
-  mc->SetMod(fModuleId);
-  if (!nch) return mc;
-  mc->SetNBadPChannelsList(nchp);
-  mc->SetNBadNChannelsList(nchn);
-  for (Int_t i = 0; i < nch; i++) {
-    if (chlist[i] < fgkPNStripsPerModule) mc->AddBadPChannel(chlist[i], i);
-    else mc->AddBadNChannel((AliITSChannelDaSSD::GetMaxStripIdConst() - chlist[i]), (i-nchp));
-  }
-  return mc;
+Short_t  AliITSModuleDaSSD::GetCMFerom(const Int_t chipn, const Long_t evn)   const 
+{ 
+// Get value of FeromCM for a given chip and event 
+  if ((!fCmFerom) || (chipn >= fgkChipsPerModule)) return 0;
+  if (evn >= fCmFerom[chipn].GetSize()) return 0;
+  else return fCmFerom[chipn][evn];
 }
+