BLCMDtrackermode Class Reference

Inheritance diagram for BLCMDtrackermode:

BLCommand BLCallback

List of all members.


Detailed Description

class BLCMDtrackermode sets the mode for all trackers, and manages track fitting.

modes: true normal g4beamline operation; the "true" track is tracked. Same as if no trackermode command was given. fit special BLRunManager mode in which the Root file from an earlier run is read for the TrackerHits NTuple, and a track is fit to each such track. both special BLRunManager mode in which a single event is simulated, and then a track is fitted to the first track in each tracker. Primarily for testing.

Public Member Functions

 BLCMDtrackermode ()
G4String commandName ()
int command (BLArgumentVector &argv, BLArgumentMap &namedArgs)
void defineNamedArgs ()
void callback (int type)
 callback() from BLCallback. Implements the event loop for mode=fit and mode=both.
const G4String & getMode () const

Private Attributes

G4String filename
G4String mode
G4bool registered


Constructor & Destructor Documentation

BLCMDtrackermode::BLCMDtrackermode (  ) 

References BLCMDTYPE_CONTROL, filename, mode, BLCommand::registerCommand(), registered, BLCommand::setDescription(), and BLCommand::setSynopsis().

01612                                    : BLCommand(), BLCallback()
01613 {
01614         registerCommand(BLCMDTYPE_CONTROL);
01615         setSynopsis("Sets mode for all trackers, manages track fitting.");
01616         setDescription("USAGE: trackermode mode [file=...]\n"
01617                 " mode can be any of:\n"
01618                 "    true     tracks true tracks (normal operation)\n"
01619                 "    fit      fits tracks to previous 'true' output\n"
01620                 "    both     does both true and fit at once\n"
01621                 "'fit' requires the filename argument to be the output of "
01622                 "a previous 'true' run (filename is ignored in other modes); "
01623                 "each tracker processes all of its tracks in the file. "
01624                 "'true' mode simply denotes the standard G4beamline "
01625                 "operation, and the simulated tracks are taken to be the "
01626                 "'true' tracks of the system; the response of the tracker(s) "
01627                 "to these tracks is then simulated in 'fit' mode. 'both' "
01628                 "tracks a 'true' event, and then a fit is peerformed in each "
01629                 "tracker for which its first track hit all trackerplane-s.\n\n"
01630                 "Note that in 'true' "
01631                 "mode every track that hits all trackerplane-s is considered, "
01632                 "but in 'both' mode only the first track of the event can be "
01633                 "considered.\n\n"
01634                 "One trackermode command controls the mode of all trackers. "
01635                 "'true' mode is normal G4beamline operation, and is the same "
01636                 "as if no trackermode command was present.\n\n"
01637                 "Note that the geometry of the system must not change "
01638                 "between a 'true' run and a 'fit' run. You can, however, "
01639                 "make small variations in fields to explore how errors in "
01640                 "setting them will affect the fitted tracks. The trackerplane "
01641                 "command can simulate survey errors.\n\n"
01642                 "NOTE: the trackermode command must preceed all tracker "
01643                 "commands in the input file."
01644         );
01645 
01646         filename = "";
01647         mode = "true";
01648         registered = false;
01649 }


Member Function Documentation

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

Implements BLCommand.

00417 { return "trackermode"; }

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

Implements BLCommand.

References filename, BLManager::getObject(), BLCommand::handleNamedArgs(), BLCMDtracker::list, mode, BLCommand::print(), BLCommand::printError(), BLManager::registerCallback(), and registered.

01652 {
01653         if(registered) {
01654                 printError("trackermode: Multiple commands not allowed");
01655                 return -1;
01656         }
01657 
01658         if(BLCMDtracker::list.size() > 0) {
01659                 // Ordering is required for the callbacks to work properly.
01660                 printError("trackermode: must preceed all tracker commands.");
01661                 return -1;
01662         }
01663 
01664         handleNamedArgs(namedArgs);
01665 
01666         if(argv.size() >= 1) mode = argv[0];
01667 
01668         if(mode == "true") {
01669                 ;
01670         } else if(mode == "fit") {
01671                 if(filename == "") 
01672                         printError("trackermode: mode 'fit' requires a file\n");
01673         } else if(mode == "both") {
01674                 ;
01675         } else {
01676                 printError("trackermode: invalid mode '%s'\n",mode.c_str());
01677                 mode = "true";
01678         }
01679 
01680         if(!registered) {
01681                 if(mode == "true")
01682                         BLManager::getObject()->registerCallback(this,0);
01683                 else
01684                         BLManager::getObject()->registerCallback(this,3);
01685                 registered = true;
01686         }
01687 
01688         print(mode);
01689 
01690         return 0;
01691 }

void BLCMDtrackermode::defineNamedArgs (  )  [virtual]

Reimplemented from BLCommand.

References BLCommand::argString(), and filename.

01694 {
01695         argString(filename,"filename","Filename to read for fitting tracks.");
01696         argString(filename,"file","Synonym for filename.");
01697 }

void BLCMDtrackermode::callback ( int  type  )  [virtual]

callback() from BLCallback. Implements the event loop for mode=fit and mode=both.

Reimplemented from BLCallback.

References BEAM, BLRunManager::beginEvent(), BLRunManager::beginRun(), BLTRACKER_FIT, BLTRACKER_TRUE, BLRunManager::endEvent(), BLRunManager::endRun(), filename, BLManager::GeneratePrimaries(), BLRunManager::getEventManager(), BLManager::getObject(), BLRunManager::getObject(), BLManager::getPhysics(), BLRunManager::getRunAborted(), BLCMDtracker::list, mode, NORMAL, BLCommand::printError(), BLPhysics::setDoStochastics(), and BLManager::setState().

01700 {
01701         if(BLCMDtracker::list.size() == 0) {
01702                 G4Exception("trackermode","No trackers",FatalException, "");
01703         }
01704 
01705         if(mode == "true") {
01706                 assert(type == 0);
01707                 for(unsigned i=0; i<BLCMDtracker::list.size(); ++i) {
01708                         BLCMDtracker::list[i]->setMode(BLTRACKER_TRUE);
01709                 }
01710                 return;
01711         } else if(mode == "fit") {
01712                 assert(type==3);
01713                 for(unsigned i=0; i<BLCMDtracker::list.size(); ++i) {
01714                         BLCMDtracker::list[i]->handlePreviousTracks(filename);
01715                 }
01716                 return;
01717         } else if(mode != "both") {
01718                 printError("trackermode::callback: invalid mode '%s'",
01719                         mode.c_str());
01720                 return;
01721         }
01722         
01723         assert(mode == "both");
01724         assert(type==3);
01725 
01726         BLRunManager *runmgr = BLRunManager::getObject();
01727         G4EventManager *evmgr = runmgr->getEventManager();
01728         BLManager *mgr = BLManager::getObject();
01729 
01730         printf("================== Prepare Tracking Beam for Tracker Fit ==================\n");
01731         mgr->getPhysics()->setDoStochastics(NORMAL);
01732         runmgr->beginRun();
01733 
01734         printf("================== Begin Tracking Beam for Tracker Fit ===============\n");
01735         mgr->setState(BEAM);
01736 
01737         for(;;) {
01738                 runmgr->beginEvent(0);
01739                 G4Event *currentEvent = (G4Event *)runmgr->GetCurrentEvent();
01740                 mgr->GeneratePrimaries(currentEvent);
01741                 if(runmgr->getRunAborted()) break;
01742                 for(unsigned i=0; i<BLCMDtracker::list.size(); ++i)
01743                         BLCMDtracker::list[i]->setMode(BLTRACKER_TRUE);
01744                 evmgr->ProcessOneEvent(currentEvent);
01745                 if(runmgr->getRunAborted()) break;
01746                 for(unsigned i=0; i<BLCMDtracker::list.size(); ++i) {
01747                         BLCMDtracker::list[i]->setMode(BLTRACKER_FIT);
01748                         BLCMDtracker::list[i]->fitTrack();
01749                 }
01750                 runmgr->endEvent();
01751                 delete currentEvent;
01752                 currentEvent = 0;
01753         } 
01754 
01755         runmgr->endRun();
01756 }

const G4String& BLCMDtrackermode::getMode (  )  const [inline]

References mode.

Referenced by BLCMDtracker::callback().

00427 { return mode; }


Member Data Documentation

G4String BLCMDtrackermode::filename [private]

G4String BLCMDtrackermode::mode [private]

G4bool BLCMDtrackermode::registered [private]

Referenced by BLCMDtrackermode(), and command().


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