]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSCalibrationDB.cxx
Makefile for PHOSUtils.par creation
[u/mrichter/AliRoot.git] / PHOS / AliPHOSCalibrationDB.cxx
index 7c766ee4933583d7382502612a96cada7c1900d9..780db78022ecaba960ad2293f64eeef5d0413337 100644 (file)
 //////////////////////////////////////////////////////////////////////////////
 
 // --- ROOT system ---
-#include "TFile.h"
+
 // --- Standard library ---
-#include <iostream.h>
-#include <fstream>
 
 // --- AliRoot header files ---
-#include "AliPHOSConTableDB.h"
+#include "AliLog.h"  
+#include "AliPHOSCalibrManager.h"
 #include "AliPHOSCalibrationDB.h"
-#include "AliPHOSGeometry.h"
 ClassImp(AliPHOSCalibrationDB)
 
 
 //____________________________________________________________________________ 
-  AliPHOSCalibrationDB::AliPHOSCalibrationDB():TNamed() 
+  AliPHOSCalibrationDB::AliPHOSCalibrationDB():fPedestals(), fGains()
 {
-  fPedestals = 0 ;
-  fSlopes = 0;
-  fNChannels = 0 ;
-  fctdb = 0 ;
 }
 //____________________________________________________________________________ 
-AliPHOSCalibrationDB::AliPHOSCalibrationDB(const char* filename ,const char * database):
-  TNamed("AliPHOSCalibrationDB",database){
-  //Creates the containers: we prepare places for all channels in PHOS
+AliPHOSCalibrationDB::AliPHOSCalibrationDB(const char * database):
+  TNamed("AliPHOSCalibrationDB",database),fPedestals("Pedestals"),fGains("Gains"){
 
-  AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance("GPS2","") ;
-  fNChannels = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ()+
-               geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*geom->GetNModules() ;
-  //Note, that to avoid shifting AbsId each time we access data, we do not use
-  //first slot and index runs from 1 to fNChannels inclusively
-  fPedestals = new TArrayF(fNChannels+1) ;
-  fSlopes =  new TArrayF(fNChannels+1) ;
-  fctdb = 0 ;
 } 
 //____________________________________________________________________________ 
   AliPHOSCalibrationDB::~AliPHOSCalibrationDB()
 {
-  if(fPedestals)
-    delete fPedestals ;
-  if(fSlopes)
-    delete fSlopes ;
 }
 //____________________________________________________________________________ 
 Float_t AliPHOSCalibrationDB::Calibrate(Int_t amp, Int_t absId)const 
 {
   //if absID is known, return calibrated energy, else - zero
-  if(absId <=0 || absId > fNChannels) 
-    return 0.0000001 ;
-
-  Float_t ret = (amp - fPedestals->At(absId))*fSlopes->At(absId); 
+  Float_t ret = (amp - fPedestals.Data(absId))*fGains.Data(absId); 
   if(ret > 0)
     return ret ;
   else
     return 0.0000001 ; //Should not be zero - to avoid FPE
 }
-//____________________________________________________________________________ 
-void  AliPHOSCalibrationDB::SetAll(Float_t pedestal, Float_t slope){
-  //Set all calibration parameters to the same value
-  if(fPedestals)
-    for(Int_t i=0;i<fNChannels;i++){
-      fPedestals->AddAt(pedestal,i) ;
-      fSlopes->AddAt(slope,i);
-    }
-  else
-    cout << "Please, create me with non-default constructor!" << endl;
-}
+
 //____________________________________________________________________________
-void AliPHOSCalibrationDB::ReadCalibrationParameters(const char * filename, Option_t* opt){
-  //reads calibration parameters from ascii file
+void AliPHOSCalibrationDB::GetParameters(void){
+  //In this method we read calibration parameters using AliPHOSCalibrManager
+  //This manager should be configured to read from correct source.
 
-  if(strcmp(opt,"gains")==0){  //read gains
-    if(!fctdb){
-      cout << "Specify Connections Table Database first" << endl ;
-      return ;
-    }
-    ifstream gainfile(filename) ; 
-    for(Int_t i = 1; i<=64; i++){
-      Float_t slope ;
-      gainfile >> slope  ;      
-      fSlopes->AddAt(slope,fctdb->Raw2AbsId(i));
-    }
-    gainfile.close();   
+  AliPHOSCalibrManager * man = AliPHOSCalibrManager::GetInstance() ;
+  if(!man){
+    Error("GetParameters","AliPHOSCalibrManager not instanciated") ;
+    return ;
   }
-  else
-    if(strstr(opt,"pedest")){  //read pedestals
-      if(!fctdb){
-       cout << "Specify Connections Table Database first" << endl ;
-       return ;
-      }
-      ifstream pfile(filename) ; 
-      for(Int_t i = 1; i<=64; i++){
-       Float_t pedestal ;
-       pfile >> pedestal  ;      
-       fPedestals->AddAt(pedestal,fctdb->Raw2AbsId(i));
-      }
-      pfile.close();
-   }
-   else{
-     cout << "Available options are " << endl ;
-     cout << " `gains' : to read gains " << endl ;
-     cout << " `pedestals : to read pedestals " << endl ;
-   }
+
+
+  man->GetParameters(fPedestals) ;
+  man->GetParameters(fGains) ;
 }
+
 //____________________________________________________________________________
 AliPHOSCalibrationDB& AliPHOSCalibrationDB::operator=(AliPHOSCalibrationDB const & cdb)
 {
   //
-  fNChannels = cdb.fNChannels;
-  fFileName = cdb.fFileName;
   fPedestals=cdb.fPedestals ;
-  fSlopes = cdb.fSlopes;
+  fGains = cdb.fGains;
   return *this ;
 }