/************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id: $ */ // Objects of this class read txt file with APD number data // #include #include #include "AliEMCALCalibAPD.h" const int kMaxLen = 1000; // maximum length of single line (# of characters) // an OK line with complete info should have a certain number of characters const int kMinLenAPDLine = 135; const int kMaxLenAPDLine = 1000; ClassImp(AliEMCALCalibAPD) //____________________________________________________________________________ AliEMCALCalibAPD::AliEMCALCalibAPD() : fNCalibAPD(0), fData(0) { //Default constructor. } //____________________________________________________________________________ void AliEMCALCalibAPD::ReadCalibAPDInfo(Int_t nAPD, const TString &txtFileName) { //Read data from txt file. ; coordinates given on SuperModule basis std::ifstream inputFile(txtFileName.Data()); if (!inputFile) { printf("AliEMCALCalibAPD::ReadCalibAPDInfo - Cannot open the APD info file %s\n", txtFileName.Data()); return; } fNCalibAPD = nAPD; if (fData) delete [] fData; fData = new AliEMCALCalibAPDData[fNCalibAPD]; char line[kMaxLen]; /* DS: header lines skipped when switched to white-spaced separeted dat files instead of csv: conversion from spreadsheet can be done a la sed 's/,/ /g' APD-database-Houston.csv | egrep ^2 | awk '{if (NF==19) {print $0}}' > APD-database-Houston.dat - meaning "replace , with whitespace, only get the columns that start with the number 2 (Houston APDs), and only get rows with the full 19 fields // get header lines: inputFile.getline(line, kMaxLen); // printf(" 1st header line character count %d\n", inputFile.gcount()); inputFile.getline(line, kMaxLen); // printf(" 2nd header line character count %d\n", inputFile.gcount()); */ // variables for reading int i1,i2,i3,i4,i5; float f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12; char c1[10], c2[20]; int j = 0; // index for the ones that were read OK for (Int_t i = 0; i < fNCalibAPD; i++) { AliEMCALCalibAPDData &t = fData[j]; if (!inputFile) { printf("AliEMCALCalibAPD::ReadCalibAPDInfo - Error while reading input file; likely EOF..\n"); fNCalibAPD = j; // that's how many we actually read succesfully printf("AliEMCALCalibAPD::ReadCalibAPDInfo - read %d OK\n", fNCalibAPD); return; } // use some temporary/local values to perhaps help with the order when // trying to read all the many fields in a line.. inputFile.getline(line, kMaxLen); int nchar = inputFile.gcount(); //printf(" line %d ok %d - character count %d\n", i, j, nchar); if (nchar>kMinLenAPDLine && nchar