Public Member Functions | |
AsciiNTuple (G4String category, G4String name, G4String fields, G4String filename) | |
~AsciiNTuple () | |
virtual void | appendRow (float data[], int n) |
virtual bool | readRow (float data[], int ndata) |
virtual void | annotate (G4String line) |
void | flush () |
void | close () |
void | doSummary () |
Private Attributes | |
FILE * | fd |
G4String | title |
int | entries |
AsciiNTuple::AsciiNTuple | ( | G4String | category, | |
G4String | name, | |||
G4String | fields, | |||
G4String | filename | |||
) |
References entries, fd, BLAsciiFile::fopen(), BLNTuple::nData, and title.
00514 : BLNTuple(name,_fields) 00515 { 00516 if(filename == "") filename = name+".txt"; 00517 if(filename.find(".txt") == filename.npos) 00518 filename += ".txt"; 00519 fd = BLAsciiFile::fopen(filename); 00520 title = name; 00521 entries = 0; 00522 fields = _fields; 00523 00524 fprintf(fd,"# %s\n",name.c_str()); 00525 G4String s(fields); 00526 nData = 1; 00527 for(;;) { 00528 G4String::size_type p = s.find(":"); 00529 if(p == s.npos) break; 00530 s.replace(p,1," "); 00531 ++nData; 00532 } 00533 fprintf(fd,"#%s\n",s.c_str()); 00534 }
AsciiNTuple::~AsciiNTuple | ( | ) | [inline] |
void AsciiNTuple::appendRow | ( | float | data[], | |
int | n | |||
) | [virtual] |
Implements BLNTuple.
References BLNTuple::doCallbacks(), entries, and fd.
00537 { 00538 for(int i=0; i<n; ++i) 00539 fprintf(fd,"%.6g ",data[i]); 00540 fprintf(fd,"\n"); 00541 ++entries; 00542 00543 doCallbacks(data,n); 00544 }
virtual bool AsciiNTuple::readRow | ( | float | data[], | |
int | ndata | |||
) | [inline, virtual] |
virtual void AsciiNTuple::annotate | ( | G4String | line | ) | [inline, virtual] |
void AsciiNTuple::close | ( | ) | [inline, virtual] |
Implements BLNTuple.
References BLAsciiFile::fclose().
00489 { if(fd != 0) BLAsciiFile::fclose(fd); fd = 0; }
void AsciiNTuple::doSummary | ( | ) | [inline, virtual] |
FILE* AsciiNTuple::fd [private] |
Referenced by appendRow(), and AsciiNTuple().
G4String AsciiNTuple::title [private] |
Referenced by AsciiNTuple().
int AsciiNTuple::entries [private] |
Referenced by appendRow(), and AsciiNTuple().