BLCMDeventcuts Class Reference

Inheritance diagram for BLCMDeventcuts:

BLCommand

List of all members.

Public Member Functions

 BLCMDeventcuts ()
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()
void readFile (G4String filename, bool skipflag)

Private Attributes

G4String keep
G4String skip


Constructor & Destructor Documentation

BLCMDeventcuts::BLCMDeventcuts (  ) 

References BLCMDTYPE_CUTS, keep, BLCommand::registerCommand(), BLCommand::setDescription(), BLCommand::setSynopsis(), and skip.

00042 {
00043         registerCommand(BLCMDTYPE_CUTS);
00044         setSynopsis("Implements cuts on event number via lists in files.");
00045         setDescription("The files are ASCII, with one event number per line. "
00046                 "If the keep file is not empty, only event numbers listed in "
00047                 "it will be analyzed (except those listed in the skip file). "
00048                 "The skip file lists event numbers that will be skipped, and "
00049                 "event numbers listed in both files will be skipped. "
00050                 "When reading the files, lines beginning with '#' are ignored; "
00051                 "blank lines are interpreted as event 0.");
00052 
00053         keep = "";
00054         skip = "";
00055 }


Member Function Documentation

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

Implements BLCommand.

00030 { return "eventcuts"; }

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

Implements BLCommand.

References BLCommand::handleNamedArgs(), keep, BLCommand::print(), readFile(), and skip.

00058 {
00059         int retval = handleNamedArgs(namedArgs);
00060 
00061         print("");
00062 
00063         if(skip.size() > 0) readFile(skip, true);
00064         if(keep.size() > 0) readFile(keep, false);
00065 
00066         return retval;
00067 }

void BLCMDeventcuts::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argString(), keep, and skip.

00070 {
00071         argString(keep,"keep","The file containing a list of event numbers to analyze (default is all).");
00072         argString(skip,"skip","The file containing a list of event numbers to skip.");
00073         argString(keep,"filename","Synonym for keep.");
00074         argString(keep,"file","Synonym for keep.");
00075 }

void BLCMDeventcuts::readFile ( G4String  filename,
bool  skipflag 
)

References BLManager::getObject(), BLCommand::in, BLCommand::printError(), BLManager::setKeepEvent(), and BLManager::setSkipEvent().

Referenced by command().

00078 {
00079         FILE *in = fopen(filename.c_str(),"r");
00080         if(!in) {
00081                 printError("eventcuts: cannot read '%s'",filename.c_str());
00082                 return;
00083         }
00084 
00085         char line[128];
00086         while(fgets(line,sizeof(line),in)) {
00087                 if(line[0] == '#') continue;
00088                 int ev=strtol(line,0,0);
00089                 if(skipflag)
00090                         BLManager::getObject()->setSkipEvent(ev);
00091                 else
00092                         BLManager::getObject()->setKeepEvent(ev);
00093         }
00094         fclose(in);
00095 }


Member Data Documentation

G4String BLCMDeventcuts::keep [private]

G4String BLCMDeventcuts::skip [private]


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