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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // $MpId: AliMpHelper.cxx,v 1.5 2006/05/24 13:58:50 ivana Exp $
19 #include "AliMpHelper.h"
22 #include "TObjArray.h"
23 #include "TObjString.h"
27 /// \class AliMpHelper
29 /// Helper class used to parse mapping files for St345 slats.
31 /// \author L. Aphecetche
37 //_____________________________________________________________________________
38 AliMpHelper::AliMpHelper() : TObject()
41 // Default (empty) ctor.
45 //_____________________________________________________________________________
46 AliMpHelper::~AliMpHelper()
53 //_____________________________________________________________________________
54 void AliMpHelper::DecodeName(const char* name, char sep, TArrayI& theList)
57 // From a string of the form "i-j;k;l;m-n" returns an integer array
58 // containing all the integers from i to j, then k, l and then from m to
65 if ( str.Length() == 0 )
67 // protection against empty input string.
71 // Get substrings separated by 'sep'
72 TObjArray* ranges = str.Tokenize(sep);
74 // Finally takes each substring (which ought to be a range of the form
75 // x-y), and decode it into the theList integer vector.
76 for ( Int_t i = 0; i < ranges->GetEntriesFast(); ++i )
82 TString& s = ((TObjString*)ranges->At(i))->String();
83 GetRange(s.Data(),m1,m2,incr,n);
87 theList.Set(theList.GetSize()+1);
88 theList[theList.GetSize()-1] = m;
97 //_____________________________________________________________________________
99 AliMpHelper::GetRange(const char* cstr, Int_t& begin, Int_t& end,
100 Int_t& incr, Int_t& n)
103 // From a string of the form "m-n" returns a range (begin,end),
104 // its ordering (incr=+-1) and its size (abs(begin-end)+1)
109 Ssiz_t pos = str.First('-');
119 end = TString(str(pos+1,str.Length()-pos)).Atoi();
132 //_____________________________________________________________________________
133 TString AliMpHelper::Normalize(const char* line)
136 // Remove multiple blanks, and blanks in the begining/end.
140 if ( rv.Length() <= 0 ) return TString();
142 while ( rv[0] == ' ' )
146 while ( rv[rv.Length()-1] == ' ' )
148 rv.Remove(rv.Length()-1,1);
152 for ( i = 0; i < rv.Length(); ++i )