1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //_________________________________________________________________________
21 //*-- Author : D.Peressounko (RRC KI & SUBATECH)
22 //////////////////////////////////////////////////////////////////////////////
24 // --- ROOT system ---
26 // --- Standard library ---
29 // --- AliRoot header files ---
30 #include "AliPHOSConTableDB.h"
31 #include "AliPHOSCalibrationDB.h"
32 #include "AliPHOSGeometry.h"
33 ClassImp(AliPHOSCalibrationDB)
36 //____________________________________________________________________________
37 AliPHOSCalibrationDB::AliPHOSCalibrationDB():TNamed()
44 //____________________________________________________________________________
45 AliPHOSCalibrationDB::AliPHOSCalibrationDB(const char* filename ,const char * database):
46 TNamed("AliPHOSCalibrationDB",database){
47 //Creates the containers: we prepare places for all channels in PHOS
49 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance("GPS2","") ;
50 fNChannels = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ()+
51 geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*geom->GetNModules() ;
52 //Note, that to avoid shifting AbsId each time we access data, we do not use
53 //first slot and index runs from 1 to fNChannels inclusively
54 fPedestals = new TArrayF(fNChannels+1) ;
55 fSlopes = new TArrayF(fNChannels+1) ;
58 //____________________________________________________________________________
59 AliPHOSCalibrationDB::~AliPHOSCalibrationDB()
66 //____________________________________________________________________________
67 Float_t AliPHOSCalibrationDB::Calibrate(Int_t amp, Int_t absId)const
69 //if absID is known, return calibrated energy, else - zero
70 if(absId <=0 || absId > fNChannels)
73 Float_t ret = (amp - fPedestals->At(absId))*fSlopes->At(absId);
77 return 0.0000001 ; //Should not be zero - to avoid FPE
79 //____________________________________________________________________________
80 void AliPHOSCalibrationDB::SetAll(Float_t pedestal, Float_t slope){
81 //Set all calibration parameters to the same value
83 for(Int_t i=0;i<fNChannels;i++){
84 fPedestals->AddAt(pedestal,i) ;
85 fSlopes->AddAt(slope,i);
88 Warning("SetAll", "Please, create me with non-default constructor!") ;
90 //____________________________________________________________________________
91 void AliPHOSCalibrationDB::ReadCalibrationParameters(const char * filename, Option_t* opt){
92 //reads calibration parameters from ascii file
94 if(strcmp(opt,"gains")==0){ //read gains
96 Error("ReadCalibrationParameters", "Specify Connections Table Database first") ;
99 ifstream gainfile(filename) ;
100 for(Int_t i = 1; i<=64; i++){
103 fSlopes->AddAt(slope,fctdb->Raw2AbsId(i));
108 if(strstr(opt,"pedest")){ //read pedestals
110 Error("ReadCalibrationParameters", "Specify Connections Table Database first") ;
113 ifstream pfile(filename) ;
114 for(Int_t i = 1; i<=64; i++){
117 fPedestals->AddAt(pedestal,fctdb->Raw2AbsId(i));
122 Warning("ReadCalibrationParameters", "Available options are\n `gains' : to read gains\n `pedestals : to read pedestals ") ;
125 //____________________________________________________________________________
126 AliPHOSCalibrationDB& AliPHOSCalibrationDB::operator=(AliPHOSCalibrationDB const & cdb)
129 fNChannels = cdb.fNChannels;
130 fFileName = cdb.fFileName;
131 fPedestals=cdb.fPedestals ;
132 fSlopes = cdb.fSlopes;