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 info on APD calibration and map info
24 #include "AliEMCALCalibMapAPD.h"
28 ClassImp(AliEMCALCalibMapAPD)
30 //____________________________________________________________________________
31 AliEMCALCalibMapAPD::AliEMCALCalibMapAPD() :
35 //Default constructor.
38 //____________________________________________________________________________
39 void AliEMCALCalibMapAPD::ReadCalibMapAPDInfo(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("AliEMCALCalibMapAPD::ReadCalibMapAPDInfo - Cannot open the APD info file %s\n", txtFileName.Data());
51 if (fSuperModuleData) delete [] fSuperModuleData;
52 fSuperModuleData = new AliEMCALSuperModuleCalibMapAPD[fNSuperModule];
54 Int_t iSM = 0; // SuperModule index
57 // list of values to be read
62 Float_t ParErr[3] = {0};
64 Float_t DarkCurrent = 0;
67 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
69 for (Int_t i = 0; i < fNSuperModule; i++) {
70 AliEMCALSuperModuleCalibMapAPD &t = fSuperModuleData[i];
72 printf("AliEMCALCalibMapAPD::ReadCalibMapAPDInfo - Error while reading input file; likely EOF..");
76 t.fSuperModuleNum = iSM;
78 for (Int_t j=0; j<nAPDPerSM; j++) {
79 inputFile >> iCol >> iRow >> iHW
81 >> Par[0] >> Par[1] >> Par[2]
82 >> ParErr[0] >> ParErr[1] >> ParErr[2]
83 >> BreakDown >> DarkCurrent;
85 // assume that this info is already swapped and done for this basis?
87 // C side, oriented differently than A side: swap is requested
88 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
89 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
92 AliEMCALCalibMapAPDVal &v = t.fAPDVal[iCol][iRow];
100 v.fParErr[0] = ParErr[0];
101 v.fParErr[1] = ParErr[1];
102 v.fParErr[2] = ParErr[2];
103 v.fBreakDown = BreakDown;
104 v.fDarkCurrent = DarkCurrent;
114 //____________________________________________________________________________
115 void AliEMCALCalibMapAPD::WriteCalibMapAPDInfo(const TString &txtFileName,
118 // write data to txt file. ; coordinates given on SuperModule basis
120 std::ofstream outputFile(txtFileName.Data());
122 printf("AliEMCALCalibMapAPD::WriteCalibMapAPDInfo - Cannot open the APD output file %s\n", txtFileName.Data());
129 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
131 for (Int_t i = 0; i < fNSuperModule; i++) {
132 AliEMCALSuperModuleCalibMapAPD &t = fSuperModuleData[i];
133 outputFile << t.fSuperModuleNum << endl;
135 for (Int_t j=0; j<nAPDPerSM; j++) {
136 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
137 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
139 AliEMCALCalibMapAPDVal &v = t.fAPDVal[iCol][iRow];
142 // C side, oriented differently than A side: swap is requested
143 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
144 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
147 outputFile << iCol << " " << iRow << " " << v.fHardWareId
148 << " " << v.fAPDNum << " " << v.fV30
149 << " " << v.fPar[0] << " " << v.fPar[1] << " " << v.fPar[2]
150 << " " << v.fParErr[0] << " " << v.fParErr[1] << " " << v.fParErr[2]
151 << " " << v.fBreakDown << " " << v.fDarkCurrent << endl;
161 //____________________________________________________________________________
162 AliEMCALCalibMapAPD::~AliEMCALCalibMapAPD()
164 delete [] fSuperModuleData;
167 //____________________________________________________________________________
168 AliEMCALCalibMapAPD::AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDId(Int_t supModIndex)const
170 AliEMCALSuperModuleCalibMapAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
171 if (!fSuperModuleData)
174 return fSuperModuleData[supModIndex];
177 //____________________________________________________________________________
178 AliEMCALCalibMapAPD::AliEMCALSuperModuleCalibMapAPD AliEMCALCalibMapAPD::GetSuperModuleCalibMapAPDNum(Int_t supModIndex)const
180 AliEMCALSuperModuleCalibMapAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
181 if (!fSuperModuleData)
184 for (int i=0; i<fNSuperModule; i++) {
185 if (fSuperModuleData[i].fSuperModuleNum == supModIndex) {
186 return fSuperModuleData[i];