#include "AliSurveyObj.h"
//ROOT includes
-//#include "TROOT.h"
-//#include "Riostream.h"
#include "TObjArray.h"
#include "TGrid.h"
#include "TGridResult.h"
const TString AliSurveyObj::fgkBaseFolder = "/alice/data/Reference";
const TString AliSurveyObj::fgkValidDetectors = "ACORDE,BABYFRAME,BACKFRAME,\
EMCAL,FMD,HMPID,ITS,L3 MAGNET,MUON,MUON ABSORBERS,MUON DIPOLE,PHOS,PMD,\
-SPACEFRAME,SUPERSTRUCTURE,T0,TOF,TPC,TRD,V0,ZDC,GRP";
+SPACEFRAME,SUPERSTRUCTURE,T0,TOF,TPC,TRD,VZERO,ZDC,GRP";
const TString AliSurveyObj::fgkGRPDetectors = "BABYFRAME,BACKFRAME,L3 MAGNET,\
SPACEFRAME,MUON DIPOLE,MUON ABSORBERS,GRP";
const TString AliSurveyObj::fgkMUONDetectors = "MUON,SUPERSTRUCTURE";
// If the same "Grid" is alreay active, skip connection
if (!gGrid || gridUrl != gGrid->GridUrl() ||
- (( user != "" ) && ( user != gGrid->GetUser() )) ) {
+ (( strcmp(user,"") ) && ( strcmp(user,gGrid->GetUser()) )) ) {
// connection to the Grid
AliInfo("\nConnecting to the Grid...");
if (gGrid) {
- AliInfo(Form("gGrid = %x; GridUrl = %s; gGrid->GridUrl() = %s",
+ AliInfo(Form("gGrid = %p; GridUrl = %s; gGrid->GridUrl() = %s",
gGrid, gridUrl, gGrid->GridUrl()));
AliInfo(Form("User = %s; gGrid->GetUser() = %s",
user, gGrid->GetUser()));
Bool_t AliSurveyObj::OpenFile(TString openString) {
// Opens the file and reads it to a buffer
- Printf("Open string: \n -> \"%s\"\n", openString.Data());
+ AliInfo(Form("Opening file \"%s\"\n for survey data", openString.Data()));
if (openString.BeginsWith("alien://"))
if (!Connect(fgkStorage.Data(), fGridUser.Data())) {
AliError("Error reading file contents to buffer!");
return kFALSE;
}
- Printf("%d bytes read!\n", file->GetBytesRead());
+ AliInfo(Form("%lld bytes read!\n", file->GetBytesRead()));
- ParseBuffer(buf);
+ Bool_t goodParsing = ParseBuffer(buf);
file->Close();
delete[] buf;
- return kTRUE;
+ return goodParsing;
}
//_____________________________________________________________________________
void AliSurveyObj::ListValidDetectors() {
- // List the valid detector names
- Printf("");
- Printf("Listing all valid detectors:\n");
- TObjArray *dets = fgkValidDetectors.Tokenize(',');
- for (int i = 0; i < dets->GetEntries(); ++i)
- Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
- dets->Delete();
- dets = 0;
- Printf("");
- Printf("Some reports are stored in more general folders.");
- Printf("These reports can be opened using either name, the original or the");
- Printf("folder name. Example: 'SPACEFRAME' or 'GRP' are both valid when");
- Printf("opening a report for the Spaceframe.");
- Printf("");
- Printf("Detectors stored in 'MUON' folder:");
- dets = fgkMUONDetectors.Tokenize(',');
- for (int i = 0; i < dets->GetEntries(); ++i)
- Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
- dets->Delete();
- dets = 0;
- Printf("");
- Printf("Detectors stored in 'GRP' folder:");
- dets = fgkGRPDetectors.Tokenize(',');
- for (int i = 0; i < dets->GetEntries(); ++i)
- Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
- dets->Delete();
- dets = 0;
- return;
+ // List the valid detector names
+ Printf("Listing all valid detectors:\n");
+ TObjArray *dets = fgkValidDetectors.Tokenize(',');
+ for (int i = 0; i < dets->GetEntries(); ++i)
+ Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
+ dets->Delete();
+ dets = 0;
+ Printf("Some reports are stored in more general folders.\n"
+ "These reports can be opened using either name, the original or the\n"
+ "folder name. Example: 'SPACEFRAME' or 'GRP' are both valid when\n"
+ "opening a report for the Spaceframe.\n\n"
+ "Detectors stored in 'MUON' folder:");
+ dets = fgkMUONDetectors.Tokenize(',');
+ for (int i = 0; i < dets->GetEntries(); ++i)
+ Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
+ dets->Delete();
+ dets = 0;
+ Printf("Detectors stored in 'GRP' folder:");
+ dets = fgkGRPDetectors.Tokenize(',');
+ for (int i = 0; i < dets->GetEntries(); ++i)
+ Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
+ dets->Delete();
+ dets = 0;
+ return;
}
lsArg += yearFolder + reportFolder + versionFolder + ".txt";
- Printf("");
- Printf(Form("Looking for: %s \n", lsArg.Data()));
+ AliInfo(Form("\nLooking for: %s \n", lsArg.Data()));
// Check if fGridUser is set and Connect to AliEn
if (0 == fGridUser.Length()) {
Int_t numberEntries = res->GetEntries();
if (numberEntries > 0) {
- Printf("");
- Printf(Form("%d reports found:", numberEntries));
+ Printf("%d reports found:", numberEntries);
for (int i = 0; i < res->GetEntries(); ++i) {
fn = res->GetFileNamePath(i);
- Printf(Form("Detector:%s\tYear:%d\tEDMS Report Number:%d\tVersion:%d",
+ Printf("Detector:%s\tYear:%d\tEDMS Report Number:%d\tVersion:%d",
FileNamePathToDetector(fn).Data(),
FileNamePathToReportYear(fn),
FileNamePathToReportNumber(fn),
- FileNamePathToReportVersion(fn)));
+ FileNamePathToReportVersion(fn));
}
delete res;
return numberEntries;
str.Remove(TString::kTrailing, '\r');
str.Remove(TString::kTrailing, '\n');
str.Remove(TString::kTrailing, '\r');
+
if (!str.IsAscii()) {
AliWarning("Warning: Non-ASCII characters!\n");
str = "";
// Copy the buffer to a TString to use Tokenize
TString buffer = TString(buf);
- TObjArray *lines = buffer.Tokenize('\n');
+ TObjArray *linesRaw = buffer.Tokenize('\n');
+ // replace the array of lines with an array of sanitized lines
+ // in the process we remove empty lines, particularly disturbing
+ // in case of dos fileformat
+ TString oneLine = "";
+ TObjString* oneLineObj = 0;
+ TObjArray *lines = new TObjArray();
+ for(Int_t i=0; i<linesRaw->GetEntries(); i++)
+ {
+ oneLine = ((TObjString *)(linesRaw->At(i)))->GetString().Data();
+ oneLine = Sanitize(oneLine);
+ if (oneLine.Length() == 0) continue;
+ oneLineObj = new TObjString(oneLine);
+ lines->Add(oneLineObj);
+ }
+
+ linesRaw->Delete();
+ delete linesRaw;
+ linesRaw = NULL;
+
TObjArray *dataLine = NULL; // Used to Tokenize each point/line read
TObjArray *colLine = NULL; // Used to Tokenize the column names
// Get the next line
currLine = ((TObjString *)(lines->At(i)))->GetString().Data();
nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
- currLine = Sanitize(currLine);
- nextLine = Sanitize(nextLine);
- // Printf("\n%d: \"\"%s\"\"\"\n", i + 1, currLine.Data());
+ // Printf("%d: \"%s\"", i, currLine.Data());
+ // Printf("%d: \"%s\"\n", i+1, nextLine.Data());
- // Skip empty line
- if (0 == currLine.Length()) Printf("Info: Empty line skipped\n\n");
-
// The line contains a keyword
- else if (currLine.BeginsWith(">") && !nextLine.BeginsWith(">")) {
+ if (currLine.BeginsWith(">") && !nextLine.BeginsWith(">")) {
currLine.Remove(TString::kLeading, '>');
currLine.Remove(TString::kTrailing, ':');
currLine.Remove(TString::kBoth, ' ');
nextLine.Remove(TString::kTrailing, '/');
nextLine = nextLine(nextLine.Last('/') + 1, nextLine.Length() - nextLine.Last('/') + 1);
- Int_t sscanftmp = 0;
- if (1 != sscanf(nextLine.Data(), "%d", &sscanftmp)) {
- AliError("Survey text file sintax error! (incorrectly formated Report URL)");
+ if (!nextLine.IsDigit()) {
+ AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
+ AliError(Form("Wrong report number string: \"%s\"",nextLine.Data()));
lines->Delete();
+ delete lines; lines = NULL;
return kFALSE;
}
fReportNr = nextLine.Atoi();
//Printf(" $$ %d $$\n", fReportNr);
++i;
} else {
- // URL incorrectly formated
- AliError("Survey text file sintax error! (incorrectly formated Report URL)");
+ // URL incorrectly formatted
+ AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
return kFALSE;
}
} else if (currLine.BeginsWith("Version", TString::kIgnoreCase)) {
// Report version
if (!nextLine.IsDigit()) {
lines->Delete();
- AliError("Survey text file sintax error! (incorrectly formated Report Version)");
+ delete lines; lines = NULL;
+ AliError("Survey text file sintax error! (incorrectly formatted Report Version)");
return kFALSE;
}
fVersion = nextLine.Atoi();
fObs += (0 == fObs.Length()) ? nextLine : " / " + nextLine;
++i;
nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
- nextLine = Sanitize(nextLine);
}
} else if (currLine.BeginsWith("Coordinate System", TString::kIgnoreCase)) {
// Coordinate System
// Number of columns in the "Data" section
if (!nextLine.IsDigit()) {
lines->Delete();
- AliError("Survey text file sintax error! (incorrectly formated Number of Columns)");
+ delete lines; lines = NULL;
+ AliError("Survey text file sintax error! (incorrectly formatted Number of Columns)");
return kFALSE;
}
fNrColumns = nextLine.Atoi();
AliError("Survey text file sintax error! (Declared number of Columns doesn't match number of column names)");
colLine->Delete();
lines->Delete();
+ delete lines; lines = NULL;
return kFALSE;
}
++i;
// Check if all the mandatory fields exist in the line with column names
if(!check[0]){
- Printf("Missing mandatory column \"Point Name\"!");
+ AliError("Missing mandatory column \"Point Name\"!");
return kFALSE;
}
if(!(check[1]&&check[2]&&check[3])){
- Printf("Missing one or more mandatory columns for coordinates \"X\",\"Y\",\"Z\"");
+ AliError("Missing one or more mandatory columns for coordinates \"X\",\"Y\",\"Z\"");
return kFALSE;
}
if(!check[4]){
- Printf("Missing mandatory column \"Point Type\"!");
+ AliError("Missing mandatory column \"Point Type\"!");
return kFALSE;
}
if(!(check[6]&&check[7]&&check[8])){
- Printf("Missing one or more mandatory columns for precision along \"X\",\"Y\",\"Z\" axes");
+ AliError("Missing one or more mandatory columns for precision along \"X\",\"Y\",\"Z\" axes");
return kFALSE;
}
// Error (No separator was found!)
AliError("Survey text file syntax error! Error processing data line!");
lines->Delete();
+ delete lines; lines = NULL;
return kFALSE;
}
AliError("Survey text file sintax error! (Number of entries in line is different from number of Columns)");
dataLine->Delete();
lines->Delete();
+ delete lines; lines = NULL;
return kFALSE;
}
if(orderedValues[5]) tmptarg = (orderedValues[5]->Data()[0] == 'Y') ? kTRUE : kFALSE;
dp = new AliSurveyPoint(tmpname, tmpx, tmpy, tmpz, tmpprecX, tmpprecY, tmpprecZ, tmptype, tmptarg);
- dp->PrintPoint();
+ if(AliLog::GetDebugLevel("","AliSurveyObj")>1) dp->PrintPoint();
AddPoint(dp);
dataLine->Delete();
dataLine = NULL;
++i;
nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
- nextLine = Sanitize(nextLine);
}
}
} else {
AliError("Survey text file sintax error!");
lines->Delete();
+ delete lines; lines = NULL;
return kFALSE;
}
}
lines->Delete();
+ delete lines; lines = NULL;
fIsValid = kTRUE;
return kTRUE;
}