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);
229 if (!found) return kFALSE;
234 //_____________________________________________________________________________
235 TString AliSurveyObj::RealFolderName(TString detector) const {
236 // Returns the actual folder name for a given detector
237 // Some "detectors" don't have a folder of their own
240 TString folderName = detector;
242 TObjArray *dets = fgkGRPDetectors.Tokenize(',');
243 if (dets->FindObject(detector)) folderName = "GRP";
246 dets = fgkMUONDetectors.Tokenize(',');
247 if (dets->FindObject(detector)) folderName = "MUON";
253 //_____________________________________________________________________________
254 Bool_t AliSurveyObj::Fill(TString detector, Int_t reportNumber,
256 // Fills the object from a file in the default storage location in AliEn.
257 // The highest version available is selected.
259 return Fill(detector, reportNumber, -1, username);
262 //_____________________________________________________________________________
263 Bool_t AliSurveyObj::Fill(TString detector, Int_t reportNumber,
264 Int_t reportVersion, TString username) {
265 // Fills the object from a file in the default storage location in AliEn.
266 // A specific version is selected.
270 // Check if <detector> is valid
271 if (!IsValidDetector(detector)) {
272 AliWarning(Form("Detector '%s' is not a valid detector/structure!", detector.Data()));
276 // Some "detectors" don't have a folder of their own
277 // TString detectorFolder = RealFolderName(detector);
279 // Check if <year>, <reportNumber> and <reportVersion> are valid (roughly)
280 if ((reportNumber < 1) || (reportVersion < -1) || (0 == reportVersion)) {
281 AliError("Invalid parameter values for AliSurveyObj::Fill. (Report Number or Report Version)");
285 // Check if the fGridUser is set, or specified
286 if (username.Length() > 0) SetGridUser(username);
287 else if (0 == fGridUser.Length()) {
288 AliError("GRID username not specified and not previously set!");
292 // Query AliEn for the available reports
293 TGridResult *res = QueryReports(detector, -1, reportNumber, reportVersion);
294 if (!res) AliError(Form("Error querying AliEn for detector '%s', \
295 report number '%d' and report version '%d'.",
296 detector.Data(), reportNumber, reportVersion));
297 Int_t numberEntries = res->GetEntries();
298 if (0 == numberEntries) {
299 AliError(Form("No report found for detector '%s', report number '%d' and report version '%d'",
300 detector.Data(), reportNumber, reportVersion));
304 TString fileNamePath = "";
305 if (1 == numberEntries) fileNamePath = res->GetFileNamePath(0);
306 else if (numberEntries > 1) {
307 TString higherVerFNP = res->GetFileNamePath(0);
308 Int_t lastYear = FileNamePathToReportYear(higherVerFNP);
309 for (Int_t i = 1; i < numberEntries; ++i) {
310 TString currFNP = res->GetFileNamePath(i);
311 if (FileNamePathToReportVersion(currFNP) >
312 FileNamePathToReportVersion(higherVerFNP)) higherVerFNP = currFNP;
313 if (lastYear != FileNamePathToReportYear(currFNP))
314 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.");
316 fileNamePath = higherVerFNP;
319 TString fullOpenString = "alien://" + fileNamePath + "?filetype=raw";
321 // Finally composes the full string
322 TString fullOpenString = "alien://" + fgkBaseFolder + "/" + detectorFolder + "/RawSurvey/";
323 fullOpenString += Form("%d/%d_v%d.txt?filetype=raw", year, reportNumber, reportVersion);
326 return OpenFile(fullOpenString);
330 //_____________________________________________________________________________
331 TString AliSurveyObj::FileNamePathToDetector(TString filename) const {
332 // Get the report number from the complete path in the format:
333 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
337 if (filename.Length() > fgkBaseFolder.Length()) {
338 ret = filename.Remove(0, fgkBaseFolder.Length());
339 ret.Remove(TString::kLeading, '/');
340 ret = ret(0, ret.First('/'));
341 if (!IsValidDetector(ret)) ret = "";
346 ///alice/cern.ch/user/r/rsilva/TRD/RawSurvey/2007/.816582_v2.txt/v1.0
348 //_____________________________________________________________________________
349 Int_t AliSurveyObj::FileNamePathToReportYear(TString filename) const {
350 // Get the report year from the complete path in the format:
351 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
355 if (filename.Length() > fgkBaseFolder.Length()) {
356 ret = filename.Remove(0, fgkBaseFolder.Length());
357 ret.Remove(TString::kLeading, '/');
358 Int_t beg = ret.First('/') + TString("RawSurvey/").Length() + 1;
359 ret = ret(beg, ret.Last('/') - beg);
366 //_____________________________________________________________________________
367 Int_t AliSurveyObj::FileNamePathToReportNumber(TString filename) const {
368 // Get the report number from the complete path in the format:
369 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
373 if (filename.Length() > fgkBaseFolder.Length()) {
374 ret = filename.Remove(0, fgkBaseFolder.Length());
375 ret.Remove(TString::kLeading, '/');
376 if ((ret.CountChar('/') > 3) || (ret.CountChar('.') > 1)) {
377 AliWarning("Error getting the Report Number from the filename path!");
380 ret = ret(ret.Last('/') + 1 , ret.Last('_') - ret.Last('/') - 1);
383 AliWarning("Error getting the Report Number from the filename path!");
388 //_____________________________________________________________________________
389 Int_t AliSurveyObj::FileNamePathToReportVersion(TString filename) const {
390 // Get the report version from the complete path in the format:
391 // /alice/data/Reference/HMPID/RawSurvey/2006/781282_v1.txt
395 if (filename.Length() > fgkBaseFolder.Length()) {
396 ret = filename.Remove(0, fgkBaseFolder.Length());
397 ret.Remove(TString::kLeading, '/');
398 if ((ret.CountChar('/') > 3) || (ret.CountChar('.') > 1)) {
399 AliWarning("Error getting the Report Version from the filename path!");
402 ret = ret(ret.Last('_') + 1 + 1 , ret.Last('.') - ret.Last('_') - 1 - 1);
405 AliWarning("Error getting the Report Version from the filename path!");
410 //_____________________________________________________________________________
411 void AliSurveyObj::ListValidDetectors() {
412 // List the valid detector names
413 Printf("Listing all valid detectors:\n");
414 TObjArray *dets = fgkValidDetectors.Tokenize(',');
415 for (int i = 0; i < dets->GetEntries(); ++i)
416 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
419 Printf("Some reports are stored in more general folders.\n"
420 "These reports can be opened using either name, the original or the\n"
421 "folder name. Example: 'SPACEFRAME' or 'GRP' are both valid when\n"
422 "opening a report for the Spaceframe.\n\n"
423 "Detectors stored in 'MUON' folder:");
424 dets = fgkMUONDetectors.Tokenize(',');
425 for (int i = 0; i < dets->GetEntries(); ++i)
426 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
428 Printf("Detectors stored in 'GRP' folder:");
429 dets = fgkGRPDetectors.Tokenize(',');
430 for (int i = 0; i < dets->GetEntries(); ++i)
431 Printf("%s", ((TObjString *) dets->At(i))->GetString().Data());
437 //_____________________________________________________________________________
438 TGridResult * AliSurveyObj::QueryReports(TString detector, Int_t year,
440 Int_t reportVersion) {
441 // Queries AliEn for existing reports matching the specified conditions
442 TString lsArg = fgkBaseFolder;
444 TString detectorFolder = "";
445 if (detector.Length() > 0) {
447 // Check if <detector> is valid
448 if (!IsValidDetector(detector)) {
449 AliError(Form("Detector '%s' is not a valid detector/structure!",
453 // Some "detectors" don't have a folder of their own
454 detectorFolder = "/" + RealFolderName(detector);
455 } else detectorFolder = "/*";
457 lsArg += detectorFolder + "/RawSurvey";
459 TString yearFolder = "";
460 if (year > 1950) yearFolder.Form("/%d", year);
461 else yearFolder = "/*";
463 TString reportFolder = "";
464 if (reportNumber > 0) reportFolder.Form("/%d", reportNumber);
465 else reportFolder = "/*";
467 TString versionFolder = "";
468 if (reportVersion > 0) versionFolder.Form("_v%d", reportVersion);
469 else versionFolder = "_v*";
471 lsArg += yearFolder + reportFolder + versionFolder + ".txt";
473 AliInfo(Form("\nLooking for: %s \n", lsArg.Data()));
475 // Check if fGridUser is set and Connect to AliEn
476 if (0 == fGridUser.Length()) {
477 AliError("To use this method it's necessary to call SetGridUser(...) in advance.");
479 } else if (!Connect(fgkStorage.Data(), fGridUser.Data())) {
480 AliError(Form("Error connecting to GRID"));
483 return gGrid->Ls(lsArg);
487 //_____________________________________________________________________________
488 Int_t AliSurveyObj::ListReports(TString detector, Int_t year,
490 Int_t reportVersion) {
491 // Lists all available reports matching the specified conditions
492 // Returns the number of reports found
494 TGridResult *res = QueryReports(detector, year, reportNumber, reportVersion);
497 AliError("Query failed.");
502 Int_t numberEntries = res->GetEntries();
504 if (numberEntries > 0) {
505 Printf("%d reports found:", numberEntries);
506 for (int i = 0; i < res->GetEntries(); ++i) {
507 fn = res->GetFileNamePath(i);
508 Printf("Detector:%s\tYear:%d\tEDMS Report Number:%d\tVersion:%d",
509 FileNamePathToDetector(fn).Data(),
510 FileNamePathToReportYear(fn),
511 FileNamePathToReportNumber(fn),
512 FileNamePathToReportVersion(fn));
515 return numberEntries;
517 AliInfo("No results found for the requested query.");
524 //_____________________________________________________________________________
525 void AliSurveyObj::SetGridUser(TString username){
526 // Set the username used to connect to the GRID
527 fGridUser = username;
532 //_____________________________________________________________________________
533 TString &AliSurveyObj::Sanitize(TString str) {
534 // Cleans up a line of new line and carriage return characters.
535 // (Specially usefull for files created in Windows.)
537 str.Remove(TString::kTrailing, '\r');
538 str.Remove(TString::kTrailing, '\n');
539 str.Remove(TString::kTrailing, '\r');
541 if (!str.IsAscii()) {
542 AliWarning("Warning: Non-ASCII characters!\n");
545 return str.Remove(TString::kBoth, ' ');
549 //_____________________________________________________________________________
550 Bool_t AliSurveyObj::ParseBuffer(const Char_t* buf) {
551 // Parses a character buffer assuming the format defined with the TS/SU
552 // http://aliceinfo/Offline/Activities/Alignment/SurveyInformation.html
554 // If the object is already filled clean it up
555 if (fIsValid) Reset();
557 // Copy the buffer to a TString to use Tokenize
558 TString buffer = TString(buf);
559 TObjArray *linesRaw = buffer.Tokenize('\n');
560 // replace the array of lines with an array of sanitized lines
561 // in the process we remove empty lines, particularly disturbing
562 // in case of dos fileformat
563 TString oneLine = "";
564 TObjString* oneLineObj = 0;
565 TObjArray *lines = new TObjArray();
566 for(Int_t i=0; i<linesRaw->GetEntries(); i++)
568 oneLine = ((TObjString *)(linesRaw->At(i)))->GetString().Data();
569 oneLine = Sanitize(oneLine);
570 if (oneLine.Length() == 0) continue;
571 oneLineObj = new TObjString(oneLine);
572 lines->Add(oneLineObj);
578 TObjArray *dataLine = NULL; // Used to Tokenize each point/line read
579 TObjArray *colLine = NULL; // Used to Tokenize the column names
581 // Some local variables declarations and initializations
582 const Int_t kFieldCheck = 10;
583 Bool_t check[kFieldCheck]; // used to check that mandatory column names are not missing
584 for (Int_t i = 0; i < kFieldCheck; ++i) check[i] = kFALSE;
585 TString tmpname = "";
586 Float_t tmpx = 0.0, tmpy = 0.0, tmpz = 0.0;
587 Float_t tmpprecX = -1., tmpprecY = -1., tmpprecZ = -1.;
588 Char_t tmptype = '\0';
589 Bool_t tmptarg = kTRUE;
590 AliSurveyPoint *dp = 0;
591 TString *orderedValues[9] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
594 Int_t nrLines = lines->GetEntries();
595 Printf("Lines in file: %d\n", nrLines);
597 // The main cycle, the buffer is parsed a line at a time
598 TString currLine = "", nextLine = "";
599 for (Int_t i = 0; i < nrLines; ++i) {
602 currLine = ((TObjString *)(lines->At(i)))->GetString().Data();
603 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
604 // Printf("%d: \"%s\"", i, currLine.Data());
605 // Printf("%d: \"%s\"\n", i+1, nextLine.Data());
607 // The line contains a keyword
608 if (currLine.BeginsWith(">") && !nextLine.BeginsWith(">")) {
609 currLine.Remove(TString::kLeading, '>');
610 currLine.Remove(TString::kTrailing, ':');
611 currLine.Remove(TString::kBoth, ' ');
612 nextLine.Remove(TString::kBoth, ' ');
613 AliDebug(2, Form(" -> field line: \"%s\"\n", currLine.Data()));
614 AliDebug(2, Form(" -> value line: \"%s\"\n", nextLine.Data()));
616 if (currLine.BeginsWith("Title", TString::kIgnoreCase)) {
620 } else if (currLine.BeginsWith("Date", TString::kIgnoreCase)) {
621 // Report(measurement) Date
624 } else if (currLine.BeginsWith("Subdetector", TString::kIgnoreCase)) {
625 // Subdetector or structure
626 fDetector = nextLine;
628 } else if (currLine.BeginsWith("Report URL", TString::kIgnoreCase)) {
629 // Report URL in EDMS
630 if (nextLine.BeginsWith("http://edms.cern.ch/document/", TString::kIgnoreCase) ||
631 nextLine.BeginsWith("https://edms.cern.ch/document/", TString::kIgnoreCase)) {
633 nextLine.Remove(TString::kTrailing, '/');
634 nextLine = nextLine(nextLine.Last('/') + 1, nextLine.Length() - nextLine.Last('/') + 1);
636 if (!nextLine.IsDigit()) {
637 AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
638 AliError(Form("Wrong report number string: \"%s\"",nextLine.Data()));
640 delete lines; lines = NULL;
643 fReportNr = nextLine.Atoi();
644 //Printf(" $$ %d $$\n", fReportNr);
647 // URL incorrectly formatted
648 AliError("Survey text file sintax error! (incorrectly formatted Report URL)");
651 } else if (currLine.BeginsWith("Version", TString::kIgnoreCase)) {
653 if (!nextLine.IsDigit()) {
655 delete lines; lines = NULL;
656 AliError("Survey text file sintax error! (incorrectly formatted Report Version)");
659 fVersion = nextLine.Atoi();
661 } else if (currLine.BeginsWith("General Observations", TString::kIgnoreCase)) {
664 // Can be more than 1 line. Loop until another keyword is found
665 while (('>' != nextLine[0]) && (nextLine.Length() > 0) && (i < nrLines)) {
666 fObs += (0 == fObs.Length()) ? nextLine : " / " + nextLine;
668 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
670 } else if (currLine.BeginsWith("Coordinate System", TString::kIgnoreCase)) {
672 fCoordSys = nextLine;
674 } else if (currLine.BeginsWith("Units", TString::kIgnoreCase)) {
678 } else if (currLine.BeginsWith("Nr Columns", TString::kIgnoreCase)) {
679 // Number of columns in the "Data" section
680 if (!nextLine.IsDigit()) {
682 delete lines; lines = NULL;
683 AliError("Survey text file sintax error! (incorrectly formatted Number of Columns)");
686 fNrColumns = nextLine.Atoi();
688 } else if (currLine.BeginsWith("Column Names", TString::kIgnoreCase)) {
689 // Column names separated by commas
690 fColNames = nextLine;
691 colLine = nextLine.Tokenize(',');
692 if (colLine->GetEntries() != fNrColumns) {
693 AliError("Survey text file sintax error! (Declared number of Columns doesn't match number of column names)");
696 delete lines; lines = NULL;
701 // booleans to track if precision for 1 axis is defined in more than one column
706 for (Int_t j = 0; j < fNrColumns; ++j) {
707 TString cn = ((TObjString *)(colLine->At(j)))->GetString();
708 if (cn.BeginsWith("Point Name", TString::kIgnoreCase)) {
709 orderedValues[0] = &value[j];
711 } else if (cn.BeginsWith("X", TString::kIgnoreCase)) {
712 orderedValues[1] = &value[j];
714 } else if (cn.BeginsWith("Y", TString::kIgnoreCase)) {
715 orderedValues[2] = &value[j];
717 } else if (cn.BeginsWith("Z", TString::kIgnoreCase)) {
718 orderedValues[3] = &value[j];
720 } else if (cn.BeginsWith("Precision", TString::kIgnoreCase)) {
721 TString tmpCN = cn(0, cn.First('('));
722 Int_t precLength = TString("Precision").Length();
723 if (precLength == tmpCN.Length()) {
724 if(!orderedValues[6]){
725 orderedValues[6] = &value[j];
728 AliWarning("Global precision will not be used for X axis");
730 if(!orderedValues[7]){
731 orderedValues[7] = &value[j];
734 AliWarning("Global precision will not be used for Y axis");
736 if(!orderedValues[8]){
737 orderedValues[8] = &value[j];
740 AliWarning("Global precision will not be used for Z axis");
743 Bool_t orXYZ = kFALSE;
744 TString axis = cn(precLength, tmpCN.Length() - precLength);
745 if (axis.Contains('X', TString::kIgnoreCase)) {
747 orderedValues[6] = &value[j];
752 AliError("Precision for X axis was already set!");
756 if (axis.Contains('Y', TString::kIgnoreCase)) {
758 orderedValues[7] = &value[j];
763 AliError("Precision for Y axis was already set!");
767 if (axis.Contains('Z', TString::kIgnoreCase)) {
769 orderedValues[8] = &value[j];
774 AliError("Precision for Z axis was already set!");
780 AliError("Survey text file sintax error: precision column name does not refer to any axis!");
784 } else if (cn.BeginsWith("Point Type", TString::kIgnoreCase)) {
785 orderedValues[4] = &value[j];
787 } else if (cn.BeginsWith("Target Used", TString::kIgnoreCase)) {
788 orderedValues[5] = &value[j];
793 // Check if all the mandatory fields exist in the line with column names
795 AliError("Missing mandatory column \"Point Name\"!");
798 if(!(check[1]&&check[2]&&check[3])){
799 AliError("Missing one or more mandatory columns for coordinates \"X\",\"Y\",\"Z\"");
803 AliError("Missing mandatory column \"Point Type\"!");
806 if(!(check[6]&&check[7]&&check[8])){
807 AliError("Missing one or more mandatory columns for precision along \"X\",\"Y\",\"Z\" axes");
811 } else if (currLine.BeginsWith("Data", TString::kIgnoreCase)) {
813 while ((nextLine.Length() > 0) && ('>' != nextLine[0])) {
815 // Printf("Data LINE: \"%s\": %d\n", nextLine.Data(), nextLine.Length());
817 // What is the separator used between fields?
818 // The allowed are: comma (','), tab ('\t'), and space (' ')
819 if (fNrColumns == nextLine.CountChar(',') + 1) dataLine = nextLine.Tokenize(',');
820 else if (fNrColumns == nextLine.CountChar('\t') + 1) dataLine = nextLine.Tokenize('\t');
821 else if (fNrColumns == nextLine.CountChar(' ') + 1) dataLine = nextLine.Tokenize(' ');
823 // Error (No separator was found!)
824 AliError("Survey text file syntax error! Error processing data line!");
826 delete lines; lines = NULL;
830 if (dataLine->GetEntries() != fNrColumns) {
831 // The number of columns doesn't match the number specified in the header
832 AliError("Survey text file sintax error! (Number of entries in line is different from number of Columns)");
835 delete lines; lines = NULL;
839 // Process the data line using the column names as index
840 for (Int_t j = 0; j < dataLine->GetEntries(); ++j) {
841 value[j] = ((TObjString *)(dataLine->At(j)))->GetString();
843 tmpname = *orderedValues[0];
844 tmpx = orderedValues[1]->Atof();
845 tmpy = orderedValues[2]->Atof();
846 tmpz = orderedValues[3]->Atof();
847 tmpprecX = orderedValues[6]->Atof();
848 tmpprecY = orderedValues[7]->Atof();
849 tmpprecZ = orderedValues[8]->Atof();
850 tmptype = orderedValues[4]->Data()[0];
851 if(orderedValues[5]) tmptarg = (orderedValues[5]->Data()[0] == 'Y') ? kTRUE : kFALSE;
853 dp = new AliSurveyPoint(tmpname, tmpx, tmpy, tmpz, tmpprecX, tmpprecY, tmpprecZ, tmptype, tmptarg);
854 if(AliLog::GetDebugLevel("","AliSurveyObj")>1) dp->PrintPoint();
860 nextLine = ((i + 1) < nrLines ? ((TObjString *)(lines->At(i + 1)))->GetString().Data() : "");
864 AliError("Survey text file sintax error!");
866 delete lines; lines = NULL;
871 delete lines; lines = NULL;
876 //_____________________________________________________________________________
877 void AliSurveyObj::Reset() {
878 // Resets the AliSurveyObj to a clean object.
879 // Used if the same object is filled more than once
882 fDataPoints->Delete();
888 fURL = "http://edms.cern.ch/";
897 fDataPoints = new TObjArray(1);
898 fDataPoints->SetOwner(kTRUE);