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
24 #include "AliEMCALBiasAPD.h"
28 ClassImp(AliEMCALBiasAPD)
30 //____________________________________________________________________________
31 AliEMCALBiasAPD::AliEMCALBiasAPD() :
35 //Default constructor.
38 //____________________________________________________________________________
39 void AliEMCALBiasAPD::ReadBiasAPDInfo(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("AliEMCALBiasAPD::ReadBiasAPDInfo - Cannot open the APD info file %s\n", txtFileName.Data());
51 if (fSuperModuleData) delete [] fSuperModuleData;
52 fSuperModuleData = new AliEMCALSuperModuleBiasAPD[fNSuperModule];
54 Int_t iSM = 0; // SuperModule index
61 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
63 for (Int_t i = 0; i < fNSuperModule; i++) {
64 AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[i];
66 printf("AliEMCALBiasAPD::ReadBiasAPDInfo - Error while reading input file; likely EOF..");
70 t.fSuperModuleNum = iSM;
72 for (Int_t j=0; j<nAPDPerSM; j++) {
73 inputFile >> iCol >> iRow >> iElecId >> iDAC >> voltage;
75 // assume that this info is already swapped and done for this basis?
77 // C side, oriented differently than A side: swap is requested
78 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
79 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
82 t.fElecId[iCol][iRow] = iElecId;
83 t.fDAC[iCol][iRow] = iDAC;
84 t.fVoltage[iCol][iRow] = voltage;
94 //____________________________________________________________________________
95 void AliEMCALBiasAPD::WriteBiasAPDInfo(const TString &txtFileName,
98 // write data to txt file. ; coordinates given on SuperModule basis
100 std::ofstream outputFile(txtFileName.Data());
102 printf("AliEMCALBiasAPD::WriteBiasAPDInfo - Cannot open the APD output file %s\n", txtFileName.Data());
112 Int_t nAPDPerSM = AliEMCALGeoParams::fgkEMCALCols * AliEMCALGeoParams::fgkEMCALRows;
114 for (Int_t i = 0; i < fNSuperModule; i++) {
115 AliEMCALSuperModuleBiasAPD &t = fSuperModuleData[i];
116 outputFile << t.fSuperModuleNum << endl;
118 for (Int_t j=0; j<nAPDPerSM; j++) {
119 iCol = j / AliEMCALGeoParams::fgkEMCALRows;
120 iRow = j % AliEMCALGeoParams::fgkEMCALRows;
122 iElecId = t.fElecId[iCol][iRow];
123 iDAC = t.fDAC[iCol][iRow];
124 voltage = t.fVoltage[iCol][iRow];
127 // C side, oriented differently than A side: swap is requested
128 iCol = AliEMCALGeoParams::fgkEMCALCols-1 - iCol;
129 iRow = AliEMCALGeoParams::fgkEMCALRows-1 - iRow;
132 outputFile << iCol << " " << iRow << " "
133 << iElecId << " " << iDAC << " "
144 //____________________________________________________________________________
145 AliEMCALBiasAPD::~AliEMCALBiasAPD()
147 delete [] fSuperModuleData;
150 //____________________________________________________________________________
151 AliEMCALBiasAPD::AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDId(Int_t supModIndex)const
153 AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
154 if (!fSuperModuleData)
157 return fSuperModuleData[supModIndex];
160 //____________________________________________________________________________
161 AliEMCALBiasAPD::AliEMCALSuperModuleBiasAPD AliEMCALBiasAPD::GetSuperModuleBiasAPDNum(Int_t supModIndex)const
163 AliEMCALSuperModuleBiasAPD t; // just to maybe prevent a crash, but we are returning something not-initialized so maybe not better really..
164 if (!fSuperModuleData)
167 for (int i=0; i<fNSuperModule; i++) {
168 if (fSuperModuleData[i].fSuperModuleNum == supModIndex) {
169 return fSuperModuleData[i];