Changeset 3874 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 04/28/04 19:25:36 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MRunIter.cc
r3002 r3874 17 17 ! 18 18 ! Author(s): Thomas Bretz, 1/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Author(s): Javier Rico, 4/2004 <mailto:jrico@ifae.es> 19 20 ! 20 21 ! Copyright: MAGIC Software Development, 2000-2004 … … 35 36 36 37 #include <TSystem.h> 38 #include <iostream> 37 39 38 40 ClassImp(MRunIter); … … 60 62 return AddDirectory(gSystem->DirName(name), gSystem->BaseName(name), -1); 61 63 } 64 65 // -------------------------------------------------------------------------- 66 // 67 // Add runs specified in a character chain with the format: 68 // run1,run2-run3,run4-run5,... 69 // e.g if runrange="100,105-107,110-112,115" 70 // runs 100,105,106,107,110,111,112 and 115 are included in the iterator list 71 // 72 Int_t MRunIter::AddRuns(const char* runrange, const char* path) 73 { 74 char* last; 75 char chcopy[100]; 76 Int_t lowrun=-1; 77 Int_t upprun; 78 Int_t totdir=0; 79 80 // cout << "Analyzing chain " << runrange << " in path " << path << endl; 81 82 sprintf(chcopy,"%s",runrange); 83 last=&chcopy[0]; 84 85 // loop over the elements of the character chain (break inside the loop) 86 for(char* cp=last;cp;cp++) 87 { 88 // look for a digit, a '-' or a ',' or end of string 89 char c=*cp; 90 if(! ((c>='0' && c<='9') || c=='-' || c==',' || c=='\0')) 91 return totdir; 92 93 // if '-' is found, save the previous number as initial run 94 if(c=='-' && lowrun<0) 95 { 96 char chrun[100]; 97 strncpy(chrun,last,cp-last); 98 lowrun=atoi(chrun); 99 last=cp+1; 100 } 101 // if ',' or the end of the string are found, save the previous run or run range 102 if(c==',' || c=='\0') 103 { 104 char chrun[100]; 105 strncpy(chrun,last,cp-last); 106 upprun=atoi(chrun); 107 if(lowrun>=0 && lowrun<=upprun) 108 totdir+=AddRuns(lowrun,upprun,path); 109 else if(lowrun<0) 110 totdir+=AddRun(upprun,path); 111 112 if(c=='\0') 113 break; 114 lowrun=-1; 115 last=cp+1; 116 } 117 } 118 return totdir; 119 } -
trunk/MagicSoft/Mars/mbase/MRunIter.h
r2993 r3874 42 42 43 43 Int_t AddRun(UInt_t run, const char *path=0); 44 Int_t AddRuns(const char* runrange, const char *path=0); 44 45 Int_t AddRuns(UInt_t from, UInt_t to, const char *path=0) 45 46 {
Note:
See TracChangeset
for help on using the changeset viewer.