BLCMDcollective Class Reference

Inheritance diagram for BLCMDcollective:

BLCommand BLCollectiveComputation

List of all members.


Detailed Description

class BLCMDcollective - example collective computation.

This class simply computes the mean and sigma of the time stepping of BLRunManager, and enters them into an NTuple.

Public Member Functions

 BLCMDcollective ()
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()
virtual void beginCollectiveTracking (std::vector< BLTrackData > &v)
virtual void collectiveStep (std::vector< BLTrackData > &v)
virtual void endCollectiveTracking (std::vector< BLTrackData > &v)

Private Attributes

G4double deltaT
G4int verbose
BLNTupletimeNtuple
BLRunManagerrunManager


Constructor & Destructor Documentation

BLCMDcollective::BLCMDcollective (  ) 

References BLCMDTYPE_OTHER, deltaT, BLCommand::registerCommand(), runManager, BLCommand::setDescription(), BLCommand::setSynopsis(), timeNtuple, and verbose.

00056 {
00057         registerCommand(BLCMDTYPE_OTHER);
00058         setSynopsis("Example collective computation");
00059         setDescription("This command computes the mean and sigma related "
00060                 "to the time stepping in BLRunManager. This class is "
00061                 "intended to serve as an example for a collective "
00062                 "computation.");
00063 
00064         // initialize class variables here
00065         deltaT = 1.0*ns;
00066         verbose = -1;
00067         timeNtuple = 0;
00068         runManager = 0; // not available, yet -- see command(...)
00069 }


Member Function Documentation

G4String BLCMDcollective::commandName (  )  [inline, virtual]

Implements BLCommand.

00040 { return "collective"; }

int BLCMDcollective::command ( BLArgumentVector argv,
BLArgumentMap namedArgs 
) [virtual]

void BLCMDcollective::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argDouble(), BLCommand::argInt(), deltaT, and verbose.

00089 {
00090         argDouble(deltaT,"deltaT","Time step (1 ns).",ns);
00091         argInt(verbose,"verbose","Non-zero for verbose prints (0).");
00092 }       

void BLCMDcollective::beginCollectiveTracking ( std::vector< BLTrackData > &  v  )  [virtual]

Reimplemented from BLCollectiveComputation.

References BLNTuple::create(), deltaT, runManager, BLRunManager::setDeltaT(), timeNtuple, and verbose.

00095 {
00096         if(verbose) printf("beginCollectiveTracking v.size=%d\n",
00097                 (int)v.size());
00098 
00099         runManager->setDeltaT(deltaT);
00100 
00101         // initialize the computation here.
00102         timeNtuple = BLNTuple::create("", "Ntuples", "TimeStep",
00103                                 "T:Ntracks:meanDT:sigmaDT","TimeStep");
00104 }

void BLCMDcollective::collectiveStep ( std::vector< BLTrackData > &  v  )  [virtual]

Implements BLCollectiveComputation.

References BLNTuple::appendRow(), BLRunManager::getNextStepTime(), BLManager::getObject(), runManager, timeNtuple, and verbose.

00107 {
00108         // init variables for the computation
00109         G4double stepTime = runManager->getNextStepTime();
00110         G4double sumDT=0.0, sumDT2=0.0;
00111 
00112         // loop over tracks
00113         int active=0;
00114         for(unsigned i=0; i<v.size(); ++i) {
00115                 // get the track pointer, and verify it is alive
00116                 G4Track *track = v[i].track;
00117                 G4TrackStatus trackStatus = track->GetTrackStatus();
00118                 if(trackStatus != fAlive && trackStatus != fStopButAlive)
00119                         continue;
00120                 ++active;
00121 
00122                 // get basic track data
00123                 int evId = v[i].event->GetEventID();
00124                 int trackId = BLManager::getObject()->
00125                                         getExternalTrackID(track);
00126                 G4ThreeVector position = track->GetPosition();
00127                 G4ThreeVector momentum = track->GetMomentum();
00128                 G4double time = track->GetGlobalTime();
00129 
00130                 // do the computation for this track
00131                 G4double dt = time - stepTime;
00132                 sumDT += dt;
00133                 sumDT2 += dt*dt; 
00134         }
00135 
00136         // complete the computation
00137         G4double mean=0.0, sigma=0.0;
00138         if(active >= 2) {
00139                 mean = sumDT/active;
00140                 sigma = sqrt(sumDT2/active - mean*mean);
00141                 float field[4];
00142                 field[0] = stepTime;
00143                 field[1] = active;
00144                 field[2] = mean;
00145                 field[3] = sigma;
00146                 if(timeNtuple) timeNtuple->appendRow(field,sizeof(field)/sizeof(field[0]));
00147         }
00148 
00149         if(verbose) {
00150                 printf("CollectiveStep v.size=%d active=%d time=%.3f mean=%.3f sigma=%.3f\n",
00151                         (int)v.size(),active,
00152                         runManager->getNextStepTime(), 
00153                         mean,sigma);
00154         }
00155 }

void BLCMDcollective::endCollectiveTracking ( std::vector< BLTrackData > &  v  )  [virtual]

Reimplemented from BLCollectiveComputation.

References verbose.

00158 {
00159         if(verbose) printf("endCollectiveTracking v.size=%d\n",(int)v.size());
00160 
00161         // finalize and summarize the computation here
00162 }


Member Data Documentation

G4double BLCMDcollective::deltaT [private]

G4int BLCMDcollective::verbose [private]


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