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 bias settings/voltages
25 #include "AliEMCALCalibTimeDepCorrection.h"
29 ClassImp(AliEMCALCalibTimeDepCorrection)
31 //____________________________________________________________________________
32 AliEMCALCalibTimeDepCorrection::AliEMCALCalibTimeDepCorrection() :
39 //Default constructor.
42 //____________________________________________________________________________
43 void AliEMCALCalibTimeDepCorrection::InitCorrection(Int_t nSM, Int_t nBins, Float_t val=1.0)
45 // This methods assumes that you are using SuperModules 0..nSM-1
47 if (fSuperModuleData) delete [] fSuperModuleData;
48 fSuperModuleData = new AliEMCALSuperModuleCalibTimeDepCorrection[fNSuperModule];
50 Int_t iSM = 0; // SuperModule index
54 Float_t Correction = val;
56 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
58 for (Int_t i = 0; i < fNSuperModule; i++) {
59 AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[i];
60 t.fSuperModuleNum = iSM; // assume SMs are coming in order
62 for (Int_t j=0; j<nAPDPerSM; j++) {
65 t.fCorrection[iCol][iRow].Set(nCorr);
66 for (Int_t k=0; k<nCorr; k++) {
68 t.fCorrection[iCol][iRow].AddAt(Correction, k); // AddAt = SetAt..
77 //____________________________________________________________________________
78 void AliEMCALCalibTimeDepCorrection::SetCorrection(Int_t supModIndex, Int_t iCol, Int_t iRow, Int_t iBin, Float_t val)
79 { // if you call for non-existing data, there may be a crash..
80 fSuperModuleData[supModIndex].fCorrection[iCol][iRow].AddAt(val, iBin); // AddAt = SetAt..
84 //____________________________________________________________________________
85 Float_t AliEMCALCalibTimeDepCorrection::GetCorrection(Int_t supModIndex, Int_t iCol, Int_t iRow, Int_t iBin)const
86 { // if you call for non-existing data, there may be a crash..
87 return fSuperModuleData[supModIndex].fCorrection[iCol][iRow].At(iBin);
90 //____________________________________________________________________________
91 void AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo(Int_t nSM, const TString &txtFileName,
94 //Read data from txt file. ; coordinates given on SuperModule basis
96 std::ifstream inputFile(txtFileName.Data());
98 printf("AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo - Cannot open the APD info file %s\n", txtFileName.Data());
103 if (fSuperModuleData) delete [] fSuperModuleData;
104 fSuperModuleData = new AliEMCALSuperModuleCalibTimeDepCorrection[fNSuperModule];
106 Int_t iSM = 0; // SuperModule index
110 Float_t Correction = 0;
112 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
114 for (Int_t i = 0; i < fNSuperModule; i++) {
115 AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[i];
117 printf("AliEMCALCalibTimeDepCorrection::ReadCalibTimeDepCorrectionInfo - Error while reading input file; likely EOF..");
121 t.fSuperModuleNum = iSM;
123 for (Int_t j=0; j<nAPDPerSM; j++) {
124 inputFile >> iCol >> iRow >> nCorr;
126 // assume that this info is already swapped and done for this basis?
128 // C side, oriented differently than A side: swap is requested
129 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
130 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
133 // set size of TArray
134 t.fCorrection[iCol][iRow].Set(nCorr);
135 for (Int_t k=0; k<nCorr; k++) {
136 inputFile >> Correction;
138 t.fCorrection[iCol][iRow].AddAt(Correction, k);
149 //____________________________________________________________________________
150 void AliEMCALCalibTimeDepCorrection::WriteCalibTimeDepCorrectionInfo(const TString &txtFileName,
153 // write data to txt file. ; coordinates given on SuperModule basis
155 std::ofstream outputFile(txtFileName.Data());
157 printf("AliEMCALCalibTimeDepCorrection::WriteCalibTimeDepCorrectionInfo - Cannot open the APD output file %s\n", txtFileName.Data());
165 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
167 for (Int_t i = 0; i < fNSuperModule; i++) {
168 AliEMCALSuperModuleCalibTimeDepCorrection &t = fSuperModuleData[i];
169 outputFile << t.fSuperModuleNum << endl;
171 for (Int_t j=0; j<nAPDPerSM; j++) {
172 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
173 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
175 nCorr = t.fCorrection[iCol][iRow].GetSize();
178 // C side, oriented differently than A side: swap is requested
179 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
180 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
183 outputFile << iCol << " " << iRow << " " << nCorr << endl;
184 for (Int_t k=0; k<nCorr; k++) {
185 outputFile << t.fCorrection[iCol][iRow].At(k) << " ";
198 //____________________________________________________________________________
199 AliEMCALCalibTimeDepCorrection::~AliEMCALCalibTimeDepCorrection()
201 delete [] fSuperModuleData;
204 //____________________________________________________________________________
205 AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionId(Int_t supModIndex)const
207 AliEMCALSuperModuleCalibTimeDepCorrection t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
208 if (!fSuperModuleData)
211 return fSuperModuleData[supModIndex];
214 //____________________________________________________________________________
215 AliEMCALCalibTimeDepCorrection::AliEMCALSuperModuleCalibTimeDepCorrection AliEMCALCalibTimeDepCorrection::GetSuperModuleCalibTimeDepCorrectionNum(Int_t supModIndex)const
217 AliEMCALSuperModuleCalibTimeDepCorrection t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
218 if (!fSuperModuleData)
221 for (int i=0; i<fNSuperModule; i++) {
222 if (fSuperModuleData[i].fSuperModuleNum == supModIndex) {
223 return fSuperModuleData[i];