]>
Commit | Line | Data |
---|---|---|
f74edaba | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
19 | // Short description | |
20 | // | |
21 | //*-- Author : D.Peressounko (RRC KI & SUBATECH) | |
22 | ////////////////////////////////////////////////////////////////////////////// | |
23 | ||
24 | // --- ROOT system --- | |
25 | #include "TFile.h" | |
26 | // --- Standard library --- | |
f74edaba | 27 | #include <fstream> |
28 | ||
29 | // --- AliRoot header files --- | |
30 | #include "AliPHOSConTableDB.h" | |
31 | #include "AliPHOSCalibrationDB.h" | |
32 | #include "AliPHOSGeometry.h" | |
33 | ClassImp(AliPHOSCalibrationDB) | |
34 | ||
35 | ||
36 | //____________________________________________________________________________ | |
37 | AliPHOSCalibrationDB::AliPHOSCalibrationDB():TNamed() | |
38 | { | |
39 | fPedestals = 0 ; | |
40 | fSlopes = 0; | |
41 | fNChannels = 0 ; | |
42 | fctdb = 0 ; | |
43 | } | |
44 | //____________________________________________________________________________ | |
90cceaf6 | 45 | AliPHOSCalibrationDB::AliPHOSCalibrationDB(const char * database): |
f74edaba | 46 | TNamed("AliPHOSCalibrationDB",database){ |
47 | //Creates the containers: we prepare places for all channels in PHOS | |
48 | ||
d6eed22f | 49 | AliPHOSGeometry * geom = AliPHOSGeometry::GetInstance("IHEP","") ; |
f74edaba | 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) ; | |
56 | fctdb = 0 ; | |
57 | } | |
58 | //____________________________________________________________________________ | |
59 | AliPHOSCalibrationDB::~AliPHOSCalibrationDB() | |
60 | { | |
61 | if(fPedestals) | |
62 | delete fPedestals ; | |
63 | if(fSlopes) | |
64 | delete fSlopes ; | |
65 | } | |
66 | //____________________________________________________________________________ | |
67 | Float_t AliPHOSCalibrationDB::Calibrate(Int_t amp, Int_t absId)const | |
68 | { | |
69 | //if absID is known, return calibrated energy, else - zero | |
70 | if(absId <=0 || absId > fNChannels) | |
71 | return 0.0000001 ; | |
72 | ||
73 | Float_t ret = (amp - fPedestals->At(absId))*fSlopes->At(absId); | |
74 | if(ret > 0) | |
75 | return ret ; | |
76 | else | |
77 | return 0.0000001 ; //Should not be zero - to avoid FPE | |
78 | } | |
79 | //____________________________________________________________________________ | |
80 | void AliPHOSCalibrationDB::SetAll(Float_t pedestal, Float_t slope){ | |
81 | //Set all calibration parameters to the same value | |
82 | if(fPedestals) | |
83 | for(Int_t i=0;i<fNChannels;i++){ | |
84 | fPedestals->AddAt(pedestal,i) ; | |
85 | fSlopes->AddAt(slope,i); | |
86 | } | |
87 | else | |
21cd0c07 | 88 | Warning("SetAll", "Please, create me with non-default constructor!") ; |
f74edaba | 89 | } |
90 | //____________________________________________________________________________ | |
91 | void AliPHOSCalibrationDB::ReadCalibrationParameters(const char * filename, Option_t* opt){ | |
92 | //reads calibration parameters from ascii file | |
93 | ||
94 | if(strcmp(opt,"gains")==0){ //read gains | |
95 | if(!fctdb){ | |
21cd0c07 | 96 | Error("ReadCalibrationParameters", "Specify Connections Table Database first") ; |
f74edaba | 97 | return ; |
98 | } | |
99 | ifstream gainfile(filename) ; | |
100 | for(Int_t i = 1; i<=64; i++){ | |
101 | Float_t slope ; | |
102 | gainfile >> slope ; | |
103 | fSlopes->AddAt(slope,fctdb->Raw2AbsId(i)); | |
104 | } | |
105 | gainfile.close(); | |
106 | } | |
107 | else | |
108 | if(strstr(opt,"pedest")){ //read pedestals | |
109 | if(!fctdb){ | |
21cd0c07 | 110 | Error("ReadCalibrationParameters", "Specify Connections Table Database first") ; |
f74edaba | 111 | return ; |
112 | } | |
113 | ifstream pfile(filename) ; | |
114 | for(Int_t i = 1; i<=64; i++){ | |
115 | Float_t pedestal ; | |
116 | pfile >> pedestal ; | |
117 | fPedestals->AddAt(pedestal,fctdb->Raw2AbsId(i)); | |
118 | } | |
119 | pfile.close(); | |
120 | } | |
121 | else{ | |
21cd0c07 | 122 | Warning("ReadCalibrationParameters", "Available options are\n `gains' : to read gains\n `pedestals : to read pedestals ") ; |
f74edaba | 123 | } |
124 | } | |
125 | //____________________________________________________________________________ | |
126 | AliPHOSCalibrationDB& AliPHOSCalibrationDB::operator=(AliPHOSCalibrationDB const & cdb) | |
127 | { | |
128 | // | |
129 | fNChannels = cdb.fNChannels; | |
130 | fFileName = cdb.fFileName; | |
131 | fPedestals=cdb.fPedestals ; | |
132 | fSlopes = cdb.fSlopes; | |
133 | return *this ; | |
134 | } |