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 ---
30 // --- AliRoot header files ---
31 #include "AliPHOSConTableDB.h"
32 #include "AliPHOSCalibrationDB.h"
33 #include "AliPHOSGeometry.h"
34 ClassImp(AliPHOSCalibrationDB)
37 //____________________________________________________________________________
38 AliPHOSCalibrationDB::AliPHOSCalibrationDB():TNamed()
45 //____________________________________________________________________________
46 AliPHOSCalibrationDB::AliPHOSCalibrationDB(const char* filename ,const char * database):
47 TNamed("AliPHOSCalibrationDB",database){
48 //Creates the containers: we prepare places for all channels in PHOS
50 AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance("GPS2","") ;
51 fNChannels = geom->GetNModules()*geom->GetNPhi()*geom->GetNZ()+
52 geom->GetNumberOfCPVPadsZ()*geom->GetNumberOfCPVPadsPhi()*geom->GetNModules() ;
53 //Note, that to avoid shifting AbsId each time we access data, we do not use
54 //first slot and index runs from 1 to fNChannels inclusively
55 fPedestals = new TArrayF(fNChannels+1) ;
56 fSlopes = new TArrayF(fNChannels+1) ;
59 //____________________________________________________________________________
60 AliPHOSCalibrationDB::~AliPHOSCalibrationDB()
67 //____________________________________________________________________________
68 Float_t AliPHOSCalibrationDB::Calibrate(Int_t amp, Int_t absId)const
70 //if absID is known, return calibrated energy, else - zero
71 if(absId <=0 || absId > fNChannels)
74 Float_t ret = (amp - fPedestals->At(absId))*fSlopes->At(absId);
78 return 0.0000001 ; //Should not be zero - to avoid FPE
80 //____________________________________________________________________________
81 void AliPHOSCalibrationDB::SetAll(Float_t pedestal, Float_t slope){
82 //Set all calibration parameters to the same value
84 for(Int_t i=0;i<fNChannels;i++){
85 fPedestals->AddAt(pedestal,i) ;
86 fSlopes->AddAt(slope,i);
89 cout << "Please, create me with non-default constructor!" << endl;
91 //____________________________________________________________________________
92 void AliPHOSCalibrationDB::ReadCalibrationParameters(const char * filename, Option_t* opt){
93 //reads calibration parameters from ascii file
95 if(strcmp(opt,"gains")==0){ //read gains
97 cout << "Specify Connections Table Database first" << endl ;
100 ifstream gainfile(filename) ;
101 for(Int_t i = 1; i<=64; i++){
104 fSlopes->AddAt(slope,fctdb->Raw2AbsId(i));
109 if(strstr(opt,"pedest")){ //read pedestals
111 cout << "Specify Connections Table Database first" << endl ;
114 ifstream pfile(filename) ;
115 for(Int_t i = 1; i<=64; i++){
118 fPedestals->AddAt(pedestal,fctdb->Raw2AbsId(i));
123 cout << "Available options are " << endl ;
124 cout << " `gains' : to read gains " << endl ;
125 cout << " `pedestals : to read pedestals " << endl ;
128 //____________________________________________________________________________
129 AliPHOSCalibrationDB& AliPHOSCalibrationDB::operator=(AliPHOSCalibrationDB const & cdb)
132 fNChannels = cdb.fNChannels;
133 fFileName = cdb.fFileName;
134 fPedestals=cdb.fPedestals ;
135 fSlopes = cdb.fSlopes;