Changeset 10938 for trunk/FACT++/src/EventBuilderWrapper.h
- Timestamp:
- 06/08/11 20:16:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilderWrapper.h
r10923 r10938 46 46 MessageImp &fMsg; 47 47 48 enum 49 { 50 kCurrent = 0, 51 kTotal = 1 52 }; 53 54 bool fFitsFormat; 55 56 uint32_t fMaxRun; 57 uint32_t fNumEvts[2]; 58 48 59 DimDescribedService fDimFiles; 60 DimDescribedService fDimRuns; 61 DimDescribedService fDimEvents; 62 DimDescribedService fDimCurrentEvent; 49 63 50 64 public: 51 EventBuilderWrapper(MessageImp &msg) : fMsg(msg), 52 fDimFiles("FAD_CONTROL/FILES", "X:1", "") 65 EventBuilderWrapper(MessageImp &msg) : fMsg(msg), 66 fFitsFormat(false), fMaxRun(0), 67 fDimFiles ("FAD_CONTROL/FILES", "X:1", ""), 68 fDimRuns ("FAD_CONTROL/RUNS", "I:1", ""), 69 fDimEvents("FAD_CONTROL/EVENTS", "I:3", ""), 70 fDimCurrentEvent("FAD_CONTROL/CURRENT_EVENT", "I:1", "") 53 71 { 54 72 if (This) … … 57 75 This = this; 58 76 59 fFitsFormat = false; 77 memset(fNumEvts, 0, sizeof(fNumEvts)); 78 79 Update(fDimRuns, uint32_t(0)); 80 Update(fDimCurrentEvent, uint32_t(0)); 81 Update(fDimEvents, fNumEvts); 60 82 } 61 83 ~EventBuilderWrapper() … … 165 187 size_t GetUsedMemory() const { return gi_usedMem; } 166 188 189 virtual int CloseOpenFiles() { CloseRunFile(0, 0); return 0; } 190 191 167 192 /* 168 193 struct OpenFileToDim … … 223 248 vector<DataFileImp*> fFiles; 224 249 225 bool fFitsFormat;226 227 250 template<class T> 228 251 void Update(DimDescribedService &svc, const T &data) const … … 236 259 { 237 260 // Check if file already exists... 238 cout << "OPEN_FILE #" << runid << endl; 261 DataFileImp *file = NULL; 262 try 263 { 264 file = fFitsFormat ? 265 static_cast<DataFileImp*>(new DataFileFits(runid)) : 266 static_cast<DataFileImp*>(new DataFileRaw(runid)); 267 } 268 catch (const exception &e) 269 { 270 return 0; 271 } 272 273 cout << "OPEN_FILE #" << runid << " (" << file << ")" << endl; 239 274 cout << " Ver= " << h->Version << endl; 240 275 cout << " Typ= " << h->RunType << endl; … … 244 279 cout << " roi= " << h->Nroi << endl; 245 280 246 DataFileImp *file = NULL;247 try248 {249 file = fFitsFormat ?250 static_cast<DataFileImp*>(new DataFileFits(runid)) :251 static_cast<DataFileImp*>(new DataFileRaw(runid));252 }253 catch (const exception &e)254 {255 return 0;256 }257 258 281 fFiles.push_back(file); 282 283 if (runid>fMaxRun) 284 { 285 fMaxRun = runid; 286 fNumEvts[kCurrent] = 0; 287 288 Update(fDimRuns, fMaxRun); 289 Update(fDimEvents, fNumEvts); 290 Update(fDimCurrentEvent, uint32_t(0)); 291 } 259 292 260 293 Update(fDimFiles, fFiles.size()); … … 281 314 return -1; 282 315 316 if (file->GetRunId()==fMaxRun) 317 { 318 Update(fDimCurrentEvent, e->EventNum); 319 fNumEvts[kCurrent]++; 320 } 321 322 fNumEvts[kTotal]++; 323 Update(fDimEvents, fNumEvts); 324 283 325 // ===> SignalEvtWritten(runid); 284 326 // Send num events written of newest file … … 295 337 DataFileImp *file = reinterpret_cast<DataFileImp*>(handler); 296 338 297 cout << "CLOSE_RUN " << file->GetRunId() << endl; 298 299 fFiles.erase(find(fFiles.begin(), fFiles.end(), file)); 339 const vector<DataFileImp*>::iterator it = find(fFiles.begin(), fFiles.end(), file); 340 if (it==fFiles.end()) 341 { 342 ostringstream str; 343 str << "File handler (" << handler << ") requested to close by event builder doesn't exist."; 344 fMsg.Fatal(str); 345 return -1; 346 } 347 348 ostringstream str; 349 str << "CLOSE_RUN requested for " << file->GetRunId() << " (" << file << ")" <<endl; 350 fMsg.Debug(str); 351 352 fFiles.erase(it); 300 353 301 354 Update(fDimFiles, fFiles.size());
Note:
See TracChangeset
for help on using the changeset viewer.