41{
42
44
45 bool inputFileDefined = false;
46 bool outputFileDefined = false;
47 bool convertClusters = false;
48 bool filterTracks = false;
49 bool inputRWD = false;
50 bool inputRWC = false;
51 bool skipCatalog = false;
52 std::string inputFile;
53 std::string outputFile;
54
55 try
56 {
57 std::string exception;
58 if (argc == 1)
59 {
60 exception = "";
61 throw exception;
62 }
63 for (int argnum = 1; argnum < argc; argnum++)
64 {
65 std::string value = argv[argnum];
66
68
69
70 switch (s_mapStringValues[value.c_str()])
71 {
73 {
74 inputFileDefined = true;
75 if (argnum + 1 >= argc)
76 throw "Missing Parameters to switch \"" + value + "\"";
77 inputFile = argv[argnum + 1];
78 argnum++;
79 break;
80 }
82 {
83 outputFileDefined = true;
84 if (argnum + 1 >= argc)
85 throw "Missing Parameters to switch \"" + value + "\"";
86 outputFile = argv[argnum + 1];
87 argnum++;
88 break;
89 }
91 {
92
93 if (argnum + 1 >= argc)
94 throw "Missing Parameters to switch \"" + value + "\"";
95 std::string
opt = argv[argnum +1];
97 convertClusters = true;
98 argnum++;
99 break;
100 }
102 {
103
104 if (argnum + 1 >= argc)
105 throw "Missing Parameters to switch \"" + value + "\"";
106 std::string
opt = argv[argnum +1];
108 filterTracks = true;
109 argnum++;
110 break;
111 }
113 {
114 if (argnum + 1 >= argc)
115 throw "Missing Parameters to switch \"" + value + "\"";
116 std::string
opt = argv[argnum +1];
118 skipCatalog = true;
119 argnum++;
120 break;
121 }
123 exception = "";
124 throw exception;
125 break;
126 default:
127 {
128 exception = "Unknown switch \"" + value + "\".";
129 throw exception;
130 break;
131 }
132 }
133
134 }
135
136 if (!inputFileDefined || !outputFileDefined)
137 {
138 exception = "InputFile or OutputFile NOT defined!";
139 throw exception;
140 }
141
142
144
145
146 std::string::size_type rwc = inputFile.find( ".rwc", 0 );
147 std::string::size_type rwd = inputFile.find( ".rwd", 0 );
148
149 if( rwc != string::npos ) {
150 inputRWC = true;
151 }
152
153 if( rwd != string::npos ) {
154 inputRWD = true;
155 }
156
157 if (inputRWC)
158 {
159 process.setCatalogName(inputFile);
160 process.setRootName(outputFile);
161 process.setClOption(convertClusters);
162 process.setFilterTrackOption(filterTracks);
163 unsigned int nFragments =0;
164 unsigned int failedFragments =0;
165 if(!skipCatalog)
166 {
168 process.dumpCatalogInEdbStructure();
169 nFragments =
process.getFragmentsNumberFromCatalog();
170 }
171 else {
172 nFragments=20000;
173 }
174 char rwdname[256], temp[256];
175 for (
unsigned int f = 1;
f < nFragments+1;
f++)
176 {
177 sprintf(temp,
"%s",
process.getCatalogName());
178 sprintf(temp+strlen(temp)-1, "d");
179 sprintf(rwdname,
"%s.%08X", temp,
f);
180 cout <<"(tot. fragm.:"<<nFragments<<") ";
181 process.setFragmentName(rwdname);
183 {
184 process.dumpFragmentInEdbStructure();
185 if (
process.getFilterTracksOption())
process.makeTracksPlot(
"outputPlots.root");
186 }
187 else failedFragments++;
188 if(failedFragments>5) break;
189 }
190 }
191 else if (inputRWD)
192 {
193 process.setFragmentName(inputFile);
194 process.setRootName(outputFile);
195 process.setClOption(convertClusters);
196 process.setFilterTrackOption(filterTracks);
198 {
199 process.dumpFragmentInEdbStructure();
200 if (
process.getFilterTracksOption())
201 process.makeTracksPlot(
"outputPlots.root");
202 }
203 }
204 else
205 {
206 exception = "input file has no .rwc extension nor .rwd extension";
207 throw exception;
208 }
209
210 return 0;
211 }
212
213 catch (std::string str)
214 {
215 int strLengh = static_cast<int>(str.size());
216 char *tab = new char[strLengh];
217 for (int i = 0; i < strLengh; i++)
218 tab[i] = '=';
219 if (strLengh != 0)
220 {
221 std::cout << tab << std::endl;
222 std::cout << str << std::endl;
223 std::cout << tab << std::endl;
224 }
225 std::cout << "\nUsage: rwdToEdb.exe {parameters}" << std::endl;
226 std::cout << "/inputfile <p> - .rwc or .rwd input file." << std::endl;
227 std::cout << "/outputfile <p> - .root output file." << std::endl;
228 std::cout << "/clusters <p> - optional: on." << std::endl;
229 std::cout << "/filterTracks <p> - optional: on." << std::endl;
230 std::cout << "/skipcatalog <p> - optional: on." << std::endl;
231 std::cout << "/help - display the usage." << std::endl;
232 delete []tab;
233 return -1;
234
235 }
236}
FILE * f
Definition: RecDispMC.C:150
Definition: ProcessRawData.h:31
void process()
Definition: emrec.cpp:40
const char * opt
Definition: mc2raw.cxx:42
void Initialize()
Definition: rwcToEdb.cpp:28
void toLower(std::string &inputString)
Definition: rwcToEdb.cpp:6