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 **************************************************************************/
16 /////////////////////////////////////////////////////////////////////
18 // class AliSurveyObj //
19 // Retrieve and Convert survey data into ROOT Objects //
21 /////////////////////////////////////////////////////////////////////
23 #include "AliSurveyObj.h"
26 #include "TObjArray.h"
28 #include "TGridResult.h"
30 #include "TObjString.h"
34 #include "AliSurveyPoint.h"
36 ClassImp(AliSurveyObj)
39 const TString AliSurveyObj::fgkStorage = "alien://alice.cern.ch";
40 const TString AliSurveyObj::fgkBaseFolder = "/alice/data/Reference";
41 const TString AliSurveyObj::fgkValidDetectors = "ACORDE,BABYFRAME,BACKFRAME,\
42 EMCAL,FMD,HMPID,ITS,L3 MAGNET,MUON,MUON ABSORBERS,MUON DIPOLE,PHOS,PMD,\
43 SPACEFRAME,SUPERSTRUCTURE,T0,TOF,TPC,TRD,VZERO,ZDC,GRP";
44 const TString AliSurveyObj::fgkGRPDetectors = "BABYFRAME,BACKFRAME,L3 MAGNET,\
45 SPACEFRAME,MUON DIPOLE,MUON ABSORBERS,GRP";
46 const TString AliSurveyObj::fgkMUONDetectors = "MUON,SUPERSTRUCTURE";
49 //_____________________________________________________________________________
50 AliSurveyObj::AliSurveyObj():
55 fURL("http://edms.cern.ch/"),
65 fDataPoints(new TObjArray(1))
68 fDataPoints->SetOwner(kTRUE);
72 //_____________________________________________________________________________
73 AliSurveyObj::~AliSurveyObj() {
76 fDataPoints->Delete();
82 //_____________________________________________________________________________
83 AliSurveyObj::AliSurveyObj(const AliSurveyObj& surveyObj):
85 fTitle(surveyObj.fTitle),
86 fDate(surveyObj.fDate),
87 fDetector(surveyObj.fDetector),
89 fReportNr(surveyObj.fReportNr),
90 fVersion(surveyObj.fVersion),
92 fCoordSys(surveyObj.fCoordSys),
93 fUnits(surveyObj.fUnits),
94 fNrColumns(surveyObj.fNrColumns),
95 fColNames(surveyObj.fColNames),
96 fIsValid(surveyObj.fIsValid),
97 fGridUser(surveyObj.fGridUser),
98 fDataPoints(new TObjArray(1))
101 TObject *curr = surveyObj.fDataPoints->First();
103 fDataPoints->Add(curr);
104 curr = surveyObj.fDataPoints->After(curr);
109 //_____________________________________________________________________________
110 AliSurveyObj& AliSurveyObj::operator=(const AliSurveyObj& surveyObj)
112 // assignment operator
113 if (this != &surveyObj) {
114 fTitle = surveyObj.fTitle;
115 fDate = surveyObj.fDate;
116 fDetector = surveyObj.fDetector;
117 fURL = surveyObj.fURL;
118 fReportNr = surveyObj.fReportNr;
119 fVersion = surveyObj.fVersion;
120 fObs = surveyObj.fObs;
121 fCoordSys = surveyObj.fCoordSys;
122 fUnits = surveyObj.fUnits;
123 fNrColumns = surveyObj.fNrColumns;
124 fColNames = surveyObj.fColNames;
125 fIsValid = surveyObj.fIsValid;
126 fGridUser = surveyObj.fGridUser;
127 TObject *curr = surveyObj.fDataPoints->First();
129 fDataPoints->Add(curr);
130 curr = surveyObj.fDataPoints->After(curr);
137 //_____________________________________________________________________________
138 void AliSurveyObj::AddPoint(AliSurveyPoint* point) {
139 // Adds a point to the TObjArray which containst the list of points
140 fDataPoints->Add(point);
145 //_____________________________________________________________________________
146 Bool_t AliSurveyObj::Connect(const char *gridUrl, const char *user) {
147 // Connects to the grid
149 // If the same "Grid" is alreay active, skip connection
150 if (!gGrid || gridUrl != gGrid->GridUrl() ||
151 (( strcmp(user,"") ) && ( strcmp(user,gGrid->GetUser()) )) ) {
152 // connection to the Grid
153 AliInfo("\nConnecting to the Grid...");
155 AliInfo(Form("gGrid = %p; GridUrl = %s; gGrid->GridUrl() = %s",
156 gGrid, gridUrl, gGrid->GridUrl()));
157 AliInfo(Form("User = %s; gGrid->GetUser() = %s",
158 user, gGrid->GetUser()));
160 TGrid::Connect(gridUrl,user);
164 AliError("Connection failed!");
171 //_____________________________________________________________________________
172 Bool_t AliSurveyObj::OpenFile(TString openString) {
173 // Opens the file and reads it to a buffer
175 AliInfo(Form("Opening file \"%s\"\n for survey data", openString.Data()));
177 if (openString.BeginsWith("alien://"))
178 if (!Connect(fgkStorage.Data(), fGridUser.Data())) {
179 AliError(Form("Error connecting to GRID"));
183 TFile *file = TFile::Open(openString.Data(), "READ");
185 AliError(Form("Error opening file \"%s\"", openString.Data()));
189 Int_t size = file->GetSize();
191 char *buf = new Char_t[size + 1];
192 memset(buf, '\0', size + 1);
195 if ( file->ReadBuffer(buf, size) ) {
196 AliError("Error reading file contents to buffer!");
199 AliInfo(Form("%lld bytes read!\n", file->GetBytesRead()));
201 Bool_t goodParsing = ParseBuffer(buf);
209 //_____________________________________________________________________________
210 Bool_t AliSurveyObj::FillFromLocalFile(const Char_t* filename) {
211 // Fills the object from a file in a local filesystem
213 TString fullOpenString = "file://" + TString(filename) + "?filetype=raw";
215 return OpenFile(fullOpenString);
219 //_____________________________________________________________________________
220 Bool_t AliSurveyObj::IsValidDetector(TString detector) const {
221 // Checks if the detector name is valid
225 TObjArray *dets = fgkValidDetectors.Tokenize(',');
226 TObject *found = dets->FindObject(detector);
230 if (!found) return kFALSE;
235 //_____________________________________________________________________________
236 TString AliSurveyObj::RealFolderName(TString detector) const {
237 // Returns the actual folder name for a given detector
238 // Some "detectors" don't have a folder of their own
241 TString folderName = detector;
243 TObjArray *dets = fgkGRPDetectors.Tokenize(',');
244 if (dets->FindObject(detector)) folderName = "GRP";
248 dets = fgkMUONDetectors.Tokenize(',');
249 if (dets->FindObject(detector)) folderName = "MUON";
259 //_____________________________________________________________________________
260 Bool_t AliSurveyObj::Fill(TString detector, Int_t reportNumber,
262 // Fills the object from a file in the default storage location in AliEn.
263 // The highest version available is selected.
265 return Fill(detector, reportNumber, -1, username);
268 //_____________________________________________________________________________
269 Bool_t AliSurveyObj::Fill(TString detector, Int_t reportNumber,
270 Int_t reportVersion, TString username) {
271 // Fills the object from a file in the default storage location in AliEn.
272 // A specific version is selected.
276 // Check if <detector> is valid
277 if (!IsValidDetector(detector)) {
278 AliWarning(Form("Detector '%s' is not a valid detector/structure!", detector.Data()));
282 // Some "detectors" don't have a folder of their own
283 // TString detectorFolder = RealFolderName(detector);
285 // Check if <year>, <reportNumber> and <reportVersion> are valid (roughly)
286 if ((reportNumber < 1) || (reportVersion < -1) || (0 == reportVersion)) {
287 AliError("Invalid parameter values for AliSurveyObj::Fill. (Report Number or Report Version)");
291 // Check if the fGridUser is set, or specified
292 if (username.Length() > 0) SetGridUser(username);
293 else if (0 == fGridUser.Length()) {
294 AliError("GRID username not specified and not previously set!");
298 // Query AliEn for the available reports
299 TGridResult *res = QueryReports(detector, -1, reportNumber, reportVersion);
300 if (!res) AliError(Form("Error querying AliEn for detector '%s', \
301 report number '%d' and report version '%d'.",
302 detector.Data(), reportNumber, reportVersion));
303 Int_t numberEntries = res->GetEntries();
304 if (0 == numberEntries) {
305 AliError(Form("No report found for detector '%s', report number '%d' and report version '%d'",
306 detector.Data(), reportNumber, reportVersion));
310 TString fileNamePath = "";
311 if (1 == numberEntries) fileNamePath = res->GetFileNamePath(0);
312 else if (numberEntries > 1) {
313 TString higherVerFNP = res->GetFileNamePath(0);
314 Int_t lastYear = FileNamePathToReportYear(higherVerFNP);
315 for (Int_t i = 1; i < numberEntries; ++i) {
316 TString currFNP = res->GetFileNamePath(i);
317 if (FileNamePathToReportVersion(currFNP) >
318 FileNamePathToReportVersion(higherVerFNP)) higherVerFNP = currFNP;
319 if (lastYear != FileNamePathToReportYear(currFNP))
320 AliWarning("Inconsistency detected, year differs for reports with the same report number! Please inform the responsible and check the report against the one in DCDB.");
322 fileNamePath = higherVerFNP;
325 TString fullOpenString = "alien://" + fileNamePath + "?filetype=raw";
327 // Finally composes the full string
328 TString fullOpenString = "alien://" + fgkBaseFolder + "/" + detectorFolder + "/RawSurvey/";
329 fullOpenString += Form("%d/%d_v%d.txt?filetype=raw", year, reportNumber, reportVersion);
332 return OpenFile(fullOpenString);
336 //_____________________________________________________________________________
337 TString AliSurveyObj::FileNamePathToDetector(TString filename) const {
338 // Get the report number from the complete path in the format:
339 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
343 if (filename.Length() > fgkBaseFolder.Length()) {
344 ret = filename.Remove(0, fgkBaseFolder.Length());
345 ret.Remove(TString::kLeading, '/');
346 ret = ret(0, ret.First('/'));
347 if (!IsValidDetector(ret)) ret = "";
352 ///alice/cern.ch/user/r/rsilva/TRD/RawSurvey/2007/.816582_v2.txt/v1.0
354 //_____________________________________________________________________________
355 Int_t AliSurveyObj::FileNamePathToReportYear(TString filename) const {
356 // Get the report year from the complete path in the format:
357 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
361 if (filename.Length() > fgkBaseFolder.Length()) {
362 ret = filename.Remove(0, fgkBaseFolder.Length());
363 ret.Remove(TString::kLeading, '/');
364 Int_t beg = ret.First('/') + TString("RawSurvey/").Length() + 1;
365 ret = ret(beg, ret.Last('/') - beg);
372 //_____________________________________________________________________________
373 Int_t AliSurveyObj::FileNamePathToReportNumber(TString filename) const {
374 // Get the report number from the complete path in the format:
375 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
379 if (filename.Length() > fgkBaseFolder.Length()) {
380 ret = filename.Remove(0, fgkBaseFolder.Length());
381 ret.Remove(TString::kLeading, '/');
382 if ((ret.CountChar('/') > 3) || (ret.CountChar('.') > 1)) {
383 AliWarning("Error getting the Report Number from the filename path!");
386 ret = ret(ret.Last('/') + 1 , ret.Last('_') - ret.Last('/') - 1);
389 AliWarning("Error getting the Report Number from the filename path!");
394 //_____________________________________________________________________________
395 Int_t AliSurveyObj::FileNamePathToReportVersion(TString filename) const {
396 // Get the report version from the complete path in the format:
397 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
401 if (filename.Length() > fgkBaseFolder.Length()) {
402 ret = filename.Remove(0, fgkBaseFolder.Length());
403 ret.Remove(TString::kLeading, '/');
404 if ((ret.CountChar('/') > 3) || (ret.CountChar('.') > 1)) {
405 AliWarning("Error getting the Report Version from the filename path!");
408 ret = ret(ret.Last('_') + 1 + 1 , ret.Last('.') - ret.Last('_') - 1 - 1);
411 AliWarning("Error getting the Report Version from the filename path!");
416 //_____________________________________________________________________________
417 void AliSurveyObj::ListValidDetectors() {
418 // List the valid detector names
419 Printf("Listing all valid detectors:\n");
420 TObjArray *dets = fgkValidDetectors.Tokenize(',');
421 for (int i = 0; i < dets->GetEntries(); ++i)
422 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
425 Printf("Some reports are stored in more general folders.\n"
426 "These reports can be opened using either name, the original or the\n"
427 "folder name. Example: 'SPACEFRAME' or 'GRP' are both valid when\n"
428 "opening a report for the Spaceframe.\n\n"
429 "Detectors stored in 'MUON' folder:");
430 dets = fgkMUONDetectors.Tokenize(',');
431 for (int i = 0; i < dets->GetEntries(); ++i)
432 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
435 Printf("Detectors stored in 'GRP' folder:");
436 dets = fgkGRPDetectors.Tokenize(',');
437 for (int i = 0; i < dets->GetEntries(); ++i)
438 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
445 //_____________________________________________________________________________
446 TGridResult * AliSurveyObj::QueryReports(TString detector, Int_t year,
448 Int_t reportVersion) {
449 // Queries AliEn for existing reports matching the specified conditions
450 TString lsArg = fgkBaseFolder;
452 TString detectorFolder = "";
453 if (detector.Length() > 0) {
455 // Check if <detector> is valid
456 if (!IsValidDetector(detector)) {
457 AliError(Form("Detector '%s' is not a valid detector/structure!",
461 // Some "detectors" don't have a folder of their own
462 detectorFolder = "/" + RealFolderName(detector);
463 } else detectorFolder = "/*";
465 lsArg += detectorFolder + "/RawSurvey";
467 TString yearFolder = "";
468 if (year > 1950) yearFolder.Form("/%d", year);
469 else yearFolder = "/*";
471 TString reportFolder = "";
472 if (reportNumber > 0) reportFolder.Form("/%d", reportNumber);
473 else reportFolder = "/*";
475 TString versionFolder = "";
476 if (reportVersion > 0) versionFolder.Form("_v%d", reportVersion);
477 else versionFolder = "_v*";
479 lsArg += yearFolder + reportFolder + versionFolder + ".txt";
481 AliInfo(Form("\nLooking for: %s \n", lsArg.Data()));
483 // Check if fGridUser is set and Connect to AliEn
484 if (0 == fGridUser.Length()) {
485 AliError("To use this method it's necessary to call SetGridUser(...) in advance.");
487 } else if (!Connect(fgkStorage.Data(), fGridUser.Data())) {
488 AliError(Form("Error connecting to GRID"));
491 return gGrid->Ls(lsArg);
495 //_____________________________________________________________________________
496 Int_t AliSurveyObj::ListReports(TString detector, Int_t year,
498 Int_t reportVersion) {
499 // Lists all available reports matching the specified conditions
500 // Returns the number of reports found
502 TGridResult *res = QueryReports(detector, year, reportNumber, reportVersion);
505 AliError("Query failed.");
510 Int_t numberEntries = res->GetEntries();
512 if (numberEntries > 0) {
513 Printf("%d reports found:", numberEntries);
514 for (int i = 0; i < res->GetEntries(); ++i) {
515 fn = res->GetFileNamePath(i);
516 Printf("Detector:%s\tYear:%d\tEDMS Report Number:%d\tVersion:%d",
517 FileNamePathToDetector(fn).Data(),
518 FileNamePathToReportYear(fn),
519 FileNamePathToReportNumber(fn),
520 FileNamePathToReportVersion(fn));
523 return numberEntries;
525 AliInfo("No results found for the requested query.");
532 //_____________________________________________________________________________
533 void AliSurveyObj::SetGridUser(TString username){
534 // Set the username used to connect to the GRID
535 fGridUser = username;
540 //_____________________________________________________________________________
541 TString &AliSurveyObj::Sanitize(TString str) {
542 // Cleans up a line of new line and carriage return characters.
543 // (Specially usefull for files created in Windows.)
545 str.Remove(TString::kTrailing, '\r');
546 str.Remove(TString::kTrailing, '\n');
547 str.Remove(TString::kTrailing, '\r');
549 if (!str.IsAscii()) {
550 AliWarning("Warning: Non-ASCII characters!\n");
553 return str.Remove(TString::kBoth, ' ');
557 //_____________________________________________________________________________
558 Bool_t AliSurveyObj::ParseBuffer(const Char_t* buf) {
559 // Parses a character buffer assuming the format defined with the TS/SU
560 // http://aliceinfo/Offline/Activities/Alignment/SurveyInformation.html
562 // If the object is already filled clean it up
563 if (fIsValid) Reset();
565 // Copy the buffer to a TString to use Tokenize
566 TString buffer = TString(buf);
567 TObjArray *linesRaw = buffer.Tokenize('\n');
568 // replace the array of lines with an array of sanitized lines
569 // in the process we remove empty lines, particularly disturbing
570 // in case of dos fileformat
571 TString oneLine = "";
572 TObjString* oneLineObj = 0;
573 TObjArray *lines = new TObjArray();
574 for(Int_t i=0; i<linesRaw->GetEntries(); i++)
576 oneLine = ((TObjString *)(linesRaw->At(i)))->GetString().Data();
577 oneLine = Sanitize(oneLine);
578 if (oneLine.Length() == 0) continue;
579 oneLineObj = new TObjString(oneLine);
580 lines->Add(oneLineObj);
587 TObjArray *dataLine = NULL; // Used to Tokenize each point/line read
588 TObjArray *colLine = NULL; // Used to Tokenize the column names
590 // Some local variables declarations and initializations
591 const Int_t kFieldCheck = 10;
592 Bool_t check[kFieldCheck]; // used to check that mandatory column names are not missing
593 for (Int_t i = 0; i < kFieldCheck; ++i) check[i] = kFALSE;
594 TString tmpname = "";
595 Float_t tmpx = 0.0, tmpy = 0.0, tmpz = 0.0;
596 Float_t tmpprecX = -1., tmpprecY = -1., tmpprecZ = -1.;
597 Char_t tmptype = '\0';
598 Bool_t tmptarg = kTRUE;
599 AliSurveyPoint *dp = 0;
600 TString *orderedValues[9] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
603 Int_t nrLines = lines->GetEntries();
604 Printf("Lines in file: %d\n", nrLines);
606 // The main cycle, the buffer is parsed a line at a time
607 TString currLine = "", nextLine = "";
608 for (Int_t i = 0; i < nrLines; ++i) {
611 currLine = ((TObjString *)(lines->At(i)))->GetString().Data();
612 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
613 // Printf("%d: \"%s\"", i, currLine.Data());
614 // Printf("%d: \"%s\"\n", i+1, nextLine.Data());
616 // The line contains a keyword
617 if (currLine.BeginsWith(">") && !nextLine.BeginsWith(">")) {
618 currLine.Remove(TString::kLeading, '>');
619 currLine.Remove(TString::kTrailing, ':');
620 currLine.Remove(TString::kBoth, ' ');
621 nextLine.Remove(TString::kBoth, ' ');
622 AliDebug(2, Form(" -> field line: \"%s\"\n", currLine.Data()));
623 AliDebug(2, Form(" -> value line: \"%s\"\n", nextLine.Data()));
625 if (currLine.BeginsWith("Title", TString::kIgnoreCase)) {
629 } else if (currLine.BeginsWith("Date", TString::kIgnoreCase)) {
630 // Report(measurement) Date
633 } else if (currLine.BeginsWith("Subdetector", TString::kIgnoreCase)) {
634 // Subdetector or structure
635 fDetector = nextLine;
637 } else if (currLine.BeginsWith("Report URL", TString::kIgnoreCase)) {
638 // Report URL in EDMS
639 if (nextLine.BeginsWith("http://edms.cern.ch/document/", TString::kIgnoreCase) ||
640 nextLine.BeginsWith("https://edms.cern.ch/document/", TString::kIgnoreCase)) {
642 nextLine.Remove(TString::kTrailing, '/');
643 nextLine = nextLine(nextLine.Last('/') + 1, nextLine.Length() - nextLine.Last('/') + 1);
645 if (!nextLine.IsDigit()) {
646 AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
647 AliError(Form("Wrong report number string: \"%s\"",nextLine.Data()));
649 delete lines; lines = NULL;
652 fReportNr = nextLine.Atoi();
653 //Printf(" $$ %d $$\n", fReportNr);
656 // URL incorrectly formatted
657 AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
660 } else if (currLine.BeginsWith("Version", TString::kIgnoreCase)) {
662 if (!nextLine.IsDigit()) {
664 delete lines; lines = NULL;
665 AliError("Survey text file sintax error! (incorrectly formatted Report Version)");
668 fVersion = nextLine.Atoi();
670 } else if (currLine.BeginsWith("General Observations", TString::kIgnoreCase)) {
673 // Can be more than 1 line. Loop until another keyword is found
674 while (('>' != nextLine[0]) && (nextLine.Length() > 0) && (i < nrLines)) {
675 fObs += (0 == fObs.Length()) ? nextLine : " / " + nextLine;
677 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
679 } else if (currLine.BeginsWith("Coordinate System", TString::kIgnoreCase)) {
681 fCoordSys = nextLine;
683 } else if (currLine.BeginsWith("Units", TString::kIgnoreCase)) {
687 } else if (currLine.BeginsWith("Nr Columns", TString::kIgnoreCase)) {
688 // Number of columns in the "Data" section
689 if (!nextLine.IsDigit()) {
691 delete lines; lines = NULL;
692 AliError("Survey text file sintax error! (incorrectly formatted Number of Columns)");
695 fNrColumns = nextLine.Atoi();
697 } else if (currLine.BeginsWith("Column Names", TString::kIgnoreCase)) {
698 // Column names separated by commas
699 fColNames = nextLine;
700 colLine = nextLine.Tokenize(',');
701 if (colLine->GetEntries() != fNrColumns) {
702 AliError("Survey text file sintax error! (Declared number of Columns doesn't match number of column names)");
705 delete lines; lines = NULL;
710 // booleans to track if precision for 1 axis is defined in more than one column
715 for (Int_t j = 0; j < fNrColumns; ++j) {
716 TString cn = ((TObjString *)(colLine->At(j)))->GetString();
717 if (cn.BeginsWith("Point Name", TString::kIgnoreCase)) {
718 orderedValues[0] = &value[j];
720 } else if (cn.BeginsWith("X", TString::kIgnoreCase)) {
721 orderedValues[1] = &value[j];
723 } else if (cn.BeginsWith("Y", TString::kIgnoreCase)) {
724 orderedValues[2] = &value[j];
726 } else if (cn.BeginsWith("Z", TString::kIgnoreCase)) {
727 orderedValues[3] = &value[j];
729 } else if (cn.BeginsWith("Precision", TString::kIgnoreCase)) {
730 TString tmpCN = cn(0, cn.First('('));
731 Int_t precLength = TString("Precision").Length();
732 if (precLength == tmpCN.Length()) {
733 if(!orderedValues[6]){
734 orderedValues[6] = &value[j];
737 AliWarning("Global precision will not be used for X axis");
739 if(!orderedValues[7]){
740 orderedValues[7] = &value[j];
743 AliWarning("Global precision will not be used for Y axis");
745 if(!orderedValues[8]){
746 orderedValues[8] = &value[j];
749 AliWarning("Global precision will not be used for Z axis");
752 Bool_t orXYZ = kFALSE;
753 TString axis = cn(precLength, tmpCN.Length() - precLength);
754 if (axis.Contains('X', TString::kIgnoreCase)) {
756 orderedValues[6] = &value[j];
761 AliError("Precision for X axis was already set!");
765 if (axis.Contains('Y', TString::kIgnoreCase)) {
767 orderedValues[7] = &value[j];
772 AliError("Precision for Y axis was already set!");
776 if (axis.Contains('Z', TString::kIgnoreCase)) {
778 orderedValues[8] = &value[j];
783 AliError("Precision for Z axis was already set!");
789 AliError("Survey text file sintax error: precision column name does not refer to any axis!");
793 } else if (cn.BeginsWith("Point Type", TString::kIgnoreCase)) {
794 orderedValues[4] = &value[j];
796 } else if (cn.BeginsWith("Target Used", TString::kIgnoreCase)) {
797 orderedValues[5] = &value[j];
802 // Check if all the mandatory fields exist in the line with column names
804 AliError("Missing mandatory column \"Point Name\"!");
807 if(!(check[1]&&check[2]&&check[3])){
808 AliError("Missing one or more mandatory columns for coordinates \"X\",\"Y\",\"Z\"");
812 AliError("Missing mandatory column \"Point Type\"!");
815 if(!(check[6]&&check[7]&&check[8])){
816 AliError("Missing one or more mandatory columns for precision along \"X\",\"Y\",\"Z\" axes");
820 } else if (currLine.BeginsWith("Data", TString::kIgnoreCase)) {
822 while ((nextLine.Length() > 0) && ('>' != nextLine[0])) {
824 // Printf("Data LINE: \"%s\": %d\n", nextLine.Data(), nextLine.Length());
826 // What is the separator used between fields?
827 // The allowed are: comma (','), tab ('\t'), and space (' ')
828 if (fNrColumns == nextLine.CountChar(',') + 1) dataLine = nextLine.Tokenize(',');
829 else if (fNrColumns == nextLine.CountChar('\t') + 1) dataLine = nextLine.Tokenize('\t');
830 else if (fNrColumns == nextLine.CountChar(' ') + 1) dataLine = nextLine.Tokenize(' ');
832 // Error (No separator was found!)
833 AliError("Survey text file syntax error! Error processing data line!");
835 delete lines; lines = NULL;
839 if (dataLine->GetEntries() != fNrColumns) {
840 // The number of columns doesn't match the number specified in the header
841 AliError("Survey text file sintax error! (Number of entries in line is different from number of Columns)");
844 delete lines; lines = NULL;
848 // Process the data line using the column names as index
849 for (Int_t j = 0; j < dataLine->GetEntries(); ++j) {
850 value[j] = ((TObjString *)(dataLine->At(j)))->GetString();
852 tmpname = *orderedValues[0];
853 tmpx = orderedValues[1]->Atof();
854 tmpy = orderedValues[2]->Atof();
855 tmpz = orderedValues[3]->Atof();
856 tmpprecX = orderedValues[6]->Atof();
857 tmpprecY = orderedValues[7]->Atof();
858 tmpprecZ = orderedValues[8]->Atof();
859 tmptype = orderedValues[4]->Data()[0];
860 if(orderedValues[5]) tmptarg = (orderedValues[5]->Data()[0] == 'Y') ? kTRUE : kFALSE;
862 dp = new AliSurveyPoint(tmpname, tmpx, tmpy, tmpz, tmpprecX, tmpprecY, tmpprecZ, tmptype, tmptarg);
863 if(AliLog::GetDebugLevel("","AliSurveyObj")>1) dp->PrintPoint();
869 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
873 AliError("Survey text file sintax error!");
875 delete lines; lines = NULL;
880 delete lines; lines = NULL;
885 //_____________________________________________________________________________
886 void AliSurveyObj::Reset() {
887 // Resets the AliSurveyObj to a clean object.
888 // Used if the same object is filled more than once
891 fDataPoints->Delete();
897 fURL = "http://edms.cern.ch/";
906 fDataPoints = new TObjArray(1);
907 fDataPoints->SetOwner(kTRUE);