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 // Objects of this class contain basis for absolute calibrations
24 #include "AliEMCALCalibAbs.h"
28 ClassImp(AliEMCALCalibAbs)
30 //____________________________________________________________________________
31 AliEMCALCalibAbs::AliEMCALCalibAbs() :
35 //Default constructor.
38 //____________________________________________________________________________
39 void AliEMCALCalibAbs::ReadCalibAbsInfo(Int_t nSM, const TString &txtFileName,
42 //Read data from txt file. ; coordinates given on SuperModule basis
44 std::ifstream inputFile(txtFileName.Data());
46 printf("AliEMCALCalibAbs::ReadCalibAbsInfo - Cannot open the APD info file %s\n", txtFileName.Data());
51 if (fSuperModuleData) delete [] fSuperModuleData;
52 fSuperModuleData = new AliEMCALSuperModuleCalibAbs[fNSuperModule];
54 Int_t iSM = 0; // SuperModule index
59 // list of values to be read
60 // first: overall values for the whole SuperModule
65 // second: additional info for LED Reference and SM temperature
68 Float_t LEDRefHighLowRatio;
71 Float_t TemperatureRMS;
72 // third: info for each tower
73 Float_t RelativeGain; // (ADC>GeV relative gain/conversion), value around 1
74 Float_t HighLowRatio; // value around 16 or so
76 Float_t LEDAmp; // low gain eq. amplitude
80 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
82 for (Int_t i = 0; i < fNSuperModule; i++) {
83 AliEMCALSuperModuleCalibAbs &t = fSuperModuleData[i];
85 printf("AliEMCALCalibAbs::ReadCalibAbsInfo - Error while reading input file; likely EOF..");
89 t.fSuperModuleNum = iSM;
91 // first: overall values for the whole SuperModule
92 inputFile >> CalibMethod >> CalibPass >> CalibTime >> AbsoluteGain;
93 t.fCalibMethod = CalibMethod;
94 t.fCalibPass = CalibPass;
95 t.fCalibTime = CalibTime;
96 t.fAbsoluteGain = AbsoluteGain;
98 // second: additional info for LED Reference and SM temperature
99 for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALLEDRefs; j++) {
100 inputFile >> id >> LEDRefAmp >> LEDRefAmpRMS >> LEDRefHighLowRatio >> LEDRefHighLow;
101 t.fLEDRefAmp[id] = LEDRefAmp;
102 t.fLEDRefAmpRMS[id] = LEDRefAmpRMS;
103 t.fLEDRefHighLowRatio[id] = LEDRefHighLowRatio;
104 t.fLEDRefHighLow[id] = LEDRefHighLow;
106 for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALTempSensors; j++) {
107 inputFile >> id >> Temperature >> TemperatureRMS;
108 t.fTemperature[id] = Temperature;
109 t.fTemperatureRMS[id] = TemperatureRMS;
112 // third: info for each tower
113 for (Int_t j=0; j<nAPDPerSM; j++) {
114 inputFile >> iCol >> iRow
115 >> RelativeGain >> HighLowRatio >> HighLow >> LEDAmp >> LEDAmpRMS;
117 // assume that this info is already swapped and done for this basis?
119 // C side, oriented differently than A side: swap is requested
120 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
121 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
124 AliEMCALCalibAbsVal &v = t.fAPDVal[iCol][iRow];
126 v.fRelativeGain = RelativeGain;
127 v.fHighLowRatio = HighLowRatio;
128 v.fHighLow = HighLow;
130 v.fLEDAmpRMS = LEDAmpRMS;
140 //____________________________________________________________________________
141 void AliEMCALCalibAbs::WriteCalibAbsInfo(const TString &txtFileName,
144 // write data to txt file. ; coordinates given on SuperModule basis
146 std::ofstream outputFile(txtFileName.Data());
148 printf("AliEMCALCalibAbs::WriteCalibAbsInfo - Cannot open the APD output file %s\n", txtFileName.Data());
155 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
157 for (Int_t i = 0; i < fNSuperModule; i++) {
158 AliEMCALSuperModuleCalibAbs &t = fSuperModuleData[i];
159 // first: overall values for the whole SuperModule
160 outputFile << t.fSuperModuleNum << endl;
161 outputFile << t.fCalibMethod << " "
162 << t.fCalibPass << " "
163 << t.fCalibTime << " "
164 << t.fAbsoluteGain << endl;
166 // second: additional info for LED Reference and SM temperature
167 for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALLEDRefs; j++) {
168 outputFile << j << " " << t.fLEDRefAmp[j] << " " << t.fLEDRefAmpRMS[j]
169 << " " << t.fLEDRefHighLowRatio[j] << " " << t.fLEDRefHighLow[j]
172 for (Int_t j=0; j<AliEMCALGeoParams::fgkEMCALTempSensors; j++) {
173 outputFile << j << " " << t.fTemperature[j] << " " << t.fTemperatureRMS[j] << endl;
176 for (Int_t j=0; j<nAPDPerSM; j++) {
177 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
178 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
180 AliEMCALCalibAbsVal &v = t.fAPDVal[iCol][iRow];
183 // C side, oriented differently than A side: swap is requested
184 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
185 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
188 outputFile << iCol << " " << iRow
189 << " " << v.fRelativeGain
190 << " " << v.fHighLowRatio
193 << " " << v.fLEDAmpRMS << endl;
203 //____________________________________________________________________________
204 AliEMCALCalibAbs::~AliEMCALCalibAbs()
206 delete [] fSuperModuleData;
209 //____________________________________________________________________________
210 AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsId(Int_t supModIndex)const
212 AliEMCALSuperModuleCalibAbs t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
213 if (!fSuperModuleData)
216 return fSuperModuleData[supModIndex];
219 //____________________________________________________________________________
220 AliEMCALCalibAbs::AliEMCALSuperModuleCalibAbs AliEMCALCalibAbs::GetSuperModuleCalibAbsNum(Int_t supModIndex)const
222 AliEMCALSuperModuleCalibAbs t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
223 if (!fSuperModuleData)
226 for (int i=0; i<fNSuperModule; i++) {
227 if (fSuperModuleData[i].fSuperModuleNum == supModIndex) {
228 return fSuperModuleData[i];