TrackFileNTuple Class Reference

Inheritance diagram for TrackFileNTuple:

BLNTuple

List of all members.


Detailed Description

class TrackFileNTuple implements a BLTrackFile NTuple.

Public Member Functions

 TrackFileNTuple (G4String category, G4String name, G4String fields, G4String filename)
 ~TrackFileNTuple ()
virtual void appendRow (float data[], int n)
virtual bool readRow (float data[], int ndata)
void flush ()
void close ()
void doSummary ()

Private Attributes

BLTrackFiletf
G4String title
int entries

Static Private Attributes

static std::vector
< TrackFileNTuple * > 
list

Constructor & Destructor Documentation

TrackFileNTuple::TrackFileNTuple ( G4String  category,
G4String  name,
G4String  fields,
G4String  filename 
)

References entries, list, BLNTuple::nData, NTrackFields, tf, title, and TrackFields.

00322                                                      : BLNTuple(name,_fields)
00323 {
00324         nData = NTrackFields;
00325         fields = TrackFields;
00326         if(filename == "") filename = name+".txt";
00327         if(filename.find(".txt") == filename.npos)
00328                 filename += ".txt";
00329         tf = new BLTrackFile(filename,category+"/"+name,"w");
00330         title = name;
00331         entries = 0;
00332         list.push_back(this);
00333 }

TrackFileNTuple::~TrackFileNTuple (  )  [inline]

References BLNTuple::close().

00292 { close(); }


Member Function Documentation

void TrackFileNTuple::appendRow ( float  data[],
int  n 
) [virtual]

Implements BLNTuple.

References BLNTuple::doCallbacks(), entries, BLManager::getEventID(), BLManager::getObject(), NTrackFields, tf, and BLTrackFile::write().

00336 {
00337         assert(n == NTrackFields);
00338 
00339         G4ThreeVector pos(data[0]*mm,data[1]*mm,data[2]*mm);
00340         G4ThreeVector momentum(data[3]*MeV,data[4]*MeV,data[5]*MeV);
00341         G4double time = data[6]*ns;
00342         int PDGid = (int)data[7];
00343         int eventID = (int)data[8];
00344         int trackID = (int)data[9];
00345         int parentID = (int)data[10];
00346         double weight = data[11];
00347 
00348         // special fix for eventID to avoid truncation due to float
00349         int eventID2=BLManager::getObject()->getEventID();
00350         if(fabs((double)(data[8]-(float)eventID2)) < 0.1)
00351                 eventID = eventID2;
00352 
00353         tf->write(pos,time,momentum,PDGid,eventID,trackID,parentID,weight);
00354 
00355         ++entries;
00356 
00357         doCallbacks(data,n);
00358 }

virtual bool TrackFileNTuple::readRow ( float  data[],
int  ndata 
) [inline, virtual]

Implements BLNTuple.

00294 { return false; }

void TrackFileNTuple::flush (  )  [inline, virtual]

Implements BLNTuple.

00295 { if(tf) tf->flush(); }

void TrackFileNTuple::close (  )  [inline, virtual]

Implements BLNTuple.

00296 { if(tf) delete tf; tf = 0; }

void TrackFileNTuple::doSummary (  )  [inline, virtual]

Implements BLNTuple.

00297                          {
00298                 printf("NTuple %-15s %8d entries\n",title.c_str(), entries);
00299         }


Member Data Documentation

Referenced by appendRow(), and TrackFileNTuple().

G4String TrackFileNTuple::title [private]

Referenced by TrackFileNTuple().

int TrackFileNTuple::entries [private]

Referenced by appendRow(), and TrackFileNTuple().

std::vector< TrackFileNTuple * > TrackFileNTuple::list [static, private]

Reimplemented from BLNTuple.

Referenced by TrackFileNTuple().


The documentation for this class was generated from the following file:
g4beamline