JobCRootCommandModule Class Reference

#include <JobCRootCommandModule.h>

Inheritance diagram for JobCRootCommandModule:
JobCModule

List of all members.

Public Member Functions

 JobCRootCommandModule ()
 ~JobCRootCommandModule ()
virtual JobCResult Ana (const MomNavigator *mom)
virtual JobCResult Reco (MomNavigator *mom)
virtual void BeginJob ()
virtual void EndJob ()
virtual void BeginFile ()
virtual void EndFile ()
virtual void BeginRun ()
virtual void EndRun ()
virtual void HandleCommand (JobCommand *cmd)
virtual void Help ()
virtual void Report ()
virtual void Reset ()
virtual JobCResult Get (MomNavigator *mom)
virtual JobCResult Put (const MomNavigator *mom)

Private Member Functions

vector< string > * WhichLinesList (string method)
void ProcessLines (string whichlist)

Static Private Member Functions

static void Init ()

Private Attributes

vector< string > fAnaLines
vector< string > fRecoLines
vector< string > fBeginJobLines
vector< string > fEndJobLines
vector< string > fBeginFileLines
vector< string > fEndFileLines
vector< string > fBeginRunLines
vector< string > fEndRunLines
vector< string > fGetLines
vector< string > fPutLines

Detailed Description

Definition at line 19 of file JobCRootCommandModule.h.


Constructor & Destructor Documentation

JobCRootCommandModule::JobCRootCommandModule (  ) 

Definition at line 32 of file JobCRootCommandModule.cxx.

References Msg::kVerbose, and MSG.

00033 {
00034    MSG("Root",Msg::kVerbose) << "JobCRootCommandModule::ctor" << endl;
00035 }

JobCRootCommandModule::~JobCRootCommandModule (  ) 

Definition at line 39 of file JobCRootCommandModule.cxx.

References Msg::kVerbose, and MSG.

00040 {
00041    MSG("Root",Msg::kVerbose) << "JobCRootCommandModule::dtor" << endl;
00042 }


Member Function Documentation

JobCResult JobCRootCommandModule::Ana ( const MomNavigator mom  )  [virtual]

Implement this for read only access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 76 of file JobCRootCommandModule.cxx.

References JobCModule::GetUniqueName(), Init(), JobCResult::kAOK, Msg::kDebug, MSG, JobCRootModule::PassPtrToRoot(), and ProcessLines().

00077 {
00078    MSG("Root",Msg::kDebug) 
00079      << GetUniqueName() << " JobCRootCommandModule::Ana" << endl;
00080 
00081    static JobCResult result;
00082    result = JobCResult(JobCResult::kAOK); // initialize each time
00083 
00084    JobCRootModule::PassPtrToRoot("MomNavigator","mom",mom,true);
00085    JobCRootModule::PassPtrToRoot("JobCResult","jobcresultptr",&result,false);
00086    Init();
00087    TApplication* app = gROOT->GetApplication();
00088    app->ProcessLine("JobCResult& jobcresult = *jobcresultptr;");
00089 
00090    ProcessLines("Ana");
00091    MSG("JobC",Msg::kDebug) 
00092      << "RootCommand::Ana returned result " << result << endl;
00093    return result;
00094 }

void JobCRootCommandModule::BeginFile (  )  [virtual]

Implement for notification of begin of file. See GetCurrentFile().

Reimplemented from JobCModule.

Definition at line 129 of file JobCRootCommandModule.cxx.

References JobCModule::GetCurrentFile(), JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00130 { 
00131   MSG("JobC",Msg::kDebug)
00132     << GetUniqueName() << " RootCommand::BeginFile " 
00133     << GetCurrentFile() << endl;
00134   ProcessLines("BeginFile"); 
00135 }

void JobCRootCommandModule::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

Reimplemented from JobCModule.

Definition at line 117 of file JobCRootCommandModule.cxx.

References JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00118 { 
00119   MSG("JobC",Msg::kDebug)
00120     << GetUniqueName() << " RootCommand::BeginJob" << endl;
00121   ProcessLines("BeginJob"); 
00122 }

void JobCRootCommandModule::BeginRun (  )  [virtual]

Implement for notification of begin of run (meaningful for Daq data only). See GetCurrentRun().

Reimplemented from JobCModule.

Definition at line 143 of file JobCRootCommandModule.cxx.

References JobCModule::GetCurrentRun(), JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00144 { 
00145   MSG("JobC",Msg::kDebug)
00146     << GetUniqueName() << " RootCommand::BeginRun " 
00147     << GetCurrentRun() << endl;
00148   ProcessLines("BeginRun");
00149 }

void JobCRootCommandModule::EndFile (  )  [virtual]

Implement for notification of end of file. See GetLastFile().

Reimplemented from JobCModule.

Definition at line 136 of file JobCRootCommandModule.cxx.

References JobCModule::GetLastFile(), JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00137 { 
00138   MSG("JobC",Msg::kDebug)
00139     << GetUniqueName() << " RootCommand::EndFile " 
00140     << GetLastFile() << endl;
00141   ProcessLines("EndFile");
00142 }

void JobCRootCommandModule::EndJob (  )  [virtual]

Implement for notification of end of job

Reimplemented from JobCModule.

Definition at line 123 of file JobCRootCommandModule.cxx.

References JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00124 { 
00125   MSG("JobC",Msg::kDebug) 
00126     << GetUniqueName() << " RootCommand::EndJob" << endl;
00127   ProcessLines("EndJob"); 
00128 }

void JobCRootCommandModule::EndRun (  )  [virtual]

Implement for notification of end of run (meaningful for Daq data only). See GetLastRun().

Reimplemented from JobCModule.

Definition at line 150 of file JobCRootCommandModule.cxx.

References JobCModule::GetLastRun(), JobCModule::GetUniqueName(), Msg::kDebug, MSG, and ProcessLines().

00151 { 
00152   MSG("JobC",Msg::kDebug)
00153     << GetUniqueName() << " RootCommand::EndRun " 
00154     << GetLastRun() << endl;
00155   ProcessLines("EndRun"); 
00156 }

JobCResult JobCRootCommandModule::Get ( MomNavigator mom  )  [virtual]

Implement if your module needs to read data from some external source and fill mom

Reimplemented from JobCModule.

Definition at line 159 of file JobCRootCommandModule.cxx.

References JobCResult::kAOK, Msg::kDebug, MSG, JobCRootModule::PassPtrToRoot(), and ProcessLines().

00160 { 
00161    MSG("Root",Msg::kDebug) << "JobCRootCommandModule::Get" << endl;
00162 
00163    JobCRootModule::PassPtrToRoot("MomNavigator","mom",mom,false);
00164    ProcessLines("Get"); 
00165    return JobCResult::kAOK;
00166 }

void JobCRootCommandModule::HandleCommand ( JobCommand command  )  [virtual]

Implement to handle a JobCommand

Reimplemented from JobCModule.

Definition at line 225 of file JobCRootCommandModule.cxx.

References Help(), Init(), Msg::kInfo, Msg::kWarning, MSG, JobCommand::PopCmd(), JobCommand::PopOpt(), and WhichLinesList().

00226 {
00227 
00228    static int ncmd = 0;
00229    ncmd++;
00230 
00231    class BadJobCRootCommandCmd { };
00232 
00233    // make sure TApp is running so that CINT with <iostream.h> is defined
00234    Init();
00235 
00236    try {
00237       TApplication* app = gROOT->GetApplication();
00238       if (!app) abort();        // mostly to qwell "unsused var" warnings.
00239       const char* c = cmd->PopCmd();
00240       if (c) {
00241          string sc(c);
00242          const char* entry = cmd->PopCmd();
00243          // if no further part of the command: assume user meant "Ana"
00244          if (!entry) entry = "Ana";
00245          string sentry(entry);
00246          // which set of lines
00247          vector<string>* lines = WhichLinesList(sentry);
00248          if (!lines) {
00249             MSG("Root",Msg::kWarning) 
00250                << "\"" << sentry << "\":"
00251                << " Not a valid entry point for " << sc << " command" << endl;
00252             throw BadJobCRootCommandCmd();
00253          }
00254          if (sc == "AddLine" || sc == "Addline") {
00255             string wholeLine;
00256             // eat up rest of line
00257             while (const char* opt = cmd->PopOpt()) {
00258                wholeLine += " ";  // put back in the spaces
00259                wholeLine += opt;
00260             }
00261             lines->push_back(wholeLine);
00262          }
00263          else if (sc == "Clear") {
00264             lines->clear();
00265          }
00266          else if (sc == "Show") {
00267             vector<string>::const_iterator itrend(lines->end());
00268             vector<string>::const_iterator itr;
00269             int i = 0;
00270             for (itr = lines->begin(); itr != itrend; ++itr) {
00271                MSG("Root",Msg::kInfo) 
00272                   << " [" << i++ << "] " << (*itr) << endl;
00273             }
00274          }
00275          else {
00276             MSG("Root",Msg::kWarning) 
00277                << "\"" << sc << "\":"
00278                << " Not a valid command" << endl;
00279             throw BadJobCRootCommandCmd();
00280          }
00281       }
00282       else {
00283          throw BadJobCRootCommandCmd();
00284       }
00285    }
00286    catch ( BadJobCRootCommandCmd ) {
00287       static bool firsthelp = true;
00288       if (firsthelp) Help();
00289       firsthelp = false;
00290    }
00291 }

void JobCRootCommandModule::Help (  )  [virtual]

Implement to spew some useful help to cout

Reimplemented from JobCModule.

Definition at line 295 of file JobCRootCommandModule.cxx.

References JobCModule::GetName(), Msg::kInfo, and MSG.

Referenced by HandleCommand().

00296 {
00297    //
00298    // Print help for this module
00299    //
00300 
00301    const char *name = this->GetName();
00302 
00303    MSG("JobC", Msg::kInfo)
00304       << "Help for '" << name << "': " << endl
00305       << name 
00306       << " is a JobCModule allowing access to scripts from JobControl." 
00307       << endl
00308       << " Lines of text are processed as if typed at the ROOT prompt at"
00309       << endl
00310       << " various stages of the job process (ala entry points)."
00311       << endl
00312       << " The legal entry points are: " 
00313       << endl << "   Analysis/Reconstruction:"
00314       << endl << "     Ana            - read-only analysis of data records"
00315       << endl << "     Reco           - read-write access to data records"
00316       << endl << "   Status changes:"
00317       << endl << "     BeginJob  - Notice of begin job"
00318       << endl << "     EndJob    - Notice of end job"
00319       << endl << "     BeginFile - Notice of begin of file"
00320       << endl << "     EndFile   - Notice of end of file"
00321       << endl << "     BeginRun  - Notice of begin of run"
00322       << endl << "     EndRun    - Notice of end of run"
00323       << endl << "   I/O Methods (in general provided by framework):"
00324       << endl << "     Get - get a header/event"
00325       << endl << "     Put - write a header/event"
00326       << endl << endl
00327       << " As necessary the relevant MomNavigator* is made available to ROOT as \"mom\""
00328       << endl 
00329       << " \"Ana\" is the default entry point"
00330       << endl << endl
00331       << "Commands implemented:" 
00332       << endl << endl
00333 //--------------
00334       << "  /" << name << "/AddLine[/<entrypoint>] <arbitrary text>"
00335       << endl
00336       << "     Add a line of text to end of the list -- text is interpeted when the "
00337       << endl
00338       << "     entry point is processed in the path"
00339       << endl << endl
00340 //--------------
00341       << "  /" << name << "/Show[/<entrypoint>]"
00342       << endl
00343       << "     Show the ordered list of lines. "
00344       << endl << endl
00345 //--------------
00346       << "  /" << name << "/Clear[/<entrypoint>]"
00347       << endl
00348       << "     Clear the list of lines. "
00349       << endl << endl
00350 //--------------
00351       << endl;
00352 }

void JobCRootCommandModule::Init ( void   )  [static, private]

Definition at line 60 of file JobCRootCommandModule.cxx.

References JobCRootModule::InitRoot(), Msg::kVerbose, and MSG.

Referenced by Ana(), HandleCommand(), ProcessLines(), and Reco().

00061 {
00062    // Perform any necessary initialization
00063    // including putting TApplication into TRint-like mode
00064    // use JobCRootModule to do most of the work
00065    MSG("Root",Msg::kVerbose) << "JobCRootCommandModule::Init" << endl;
00066 
00067    static bool first = true;
00068    if (!first) return;
00069 
00070    first = false;
00071    JobCRootModule::InitRoot();
00072 
00073 }

void JobCRootCommandModule::ProcessLines ( string  whichlist  )  [private]

Definition at line 202 of file JobCRootCommandModule.cxx.

References Init(), and WhichLinesList().

Referenced by Ana(), BeginFile(), BeginJob(), BeginRun(), EndFile(), EndJob(), EndRun(), Get(), Put(), and Reco().

00203 {
00204    // process (ie. feed to ROOT) some set of command lines
00205    // relevant for a new Mom of data or a status change
00206 
00207    vector<string>* lines = WhichLinesList(whichlist);
00208    if (!lines) return;
00209 
00210    // make sure TApp is running so that CINT with <iostream.h> is defined
00211    Init();
00212    TApplication* app = gROOT->GetApplication();
00213    
00214    vector<string>::const_iterator itrend(lines->end());
00215    vector<string>::const_iterator itr;
00216 
00217    for (itr = lines->begin(); itr != itrend; ++itr) {
00218       app->ProcessLine((*itr).c_str());
00219    }
00220 
00221 }

JobCResult JobCRootCommandModule::Put ( const MomNavigator mom  )  [virtual]

Implement if your module needs to write data to some external sink.

Reimplemented from JobCModule.

Definition at line 168 of file JobCRootCommandModule.cxx.

References JobCResult::kAOK, Msg::kDebug, MSG, JobCRootModule::PassPtrToRoot(), and ProcessLines().

00169 { 
00170    MSG("Root",Msg::kDebug) << "JobCRootCommandModule::Put" << endl;
00171 
00172    JobCRootModule::PassPtrToRoot("MomNavigator","mom",mom,true);
00173    ProcessLines("Put");
00174    return JobCResult::kAOK;
00175 }

JobCResult JobCRootCommandModule::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

Reimplemented from JobCModule.

Definition at line 96 of file JobCRootCommandModule.cxx.

References JobCModule::GetUniqueName(), Init(), JobCResult::kAOK, Msg::kDebug, MSG, JobCRootModule::PassPtrToRoot(), and ProcessLines().

00097 { 
00098    MSG("Root",Msg::kDebug)
00099      << GetUniqueName() << " JobCRootCommandModule::Reco" << endl;
00100 
00101    static JobCResult result;
00102    result = JobCResult(JobCResult::kAOK); // initialize each time
00103    Init();
00104    JobCRootModule::PassPtrToRoot("MomNavigator","mom",mom,false);
00105    JobCRootModule::PassPtrToRoot("JobCResult","jobcresultptr",&result,false);
00106 
00107    TApplication* app = gROOT->GetApplication();
00108    app->ProcessLine("JobCResult& jobcresult = *jobcresultptr;");
00109 
00110    ProcessLines("Reco");
00111    MSG("JobC",Msg::kDebug) 
00112      << "RootCommand::Reco returned result " << result << endl;
00113    return result;
00114 }

void JobCRootCommandModule::Report (  )  [virtual]

Implement to spew end of running report

Reimplemented from JobCModule.

Definition at line 46 of file JobCRootCommandModule.cxx.

References Msg::kWarning, and MSG.

00047 {
00048    MSG("Root",Msg::kWarning) << "JobCRootCommandModule::Report" << endl;
00049 }

void JobCRootCommandModule::Reset (  )  [virtual]

Implement to reset oneself

Reimplemented from JobCModule.

Definition at line 53 of file JobCRootCommandModule.cxx.

References Msg::kWarning, and MSG.

00054 {
00055    MSG("Root",Msg::kWarning) << "JobCRootCommandModule::Reset" << endl;
00056 }

vector< string > * JobCRootCommandModule::WhichLinesList ( string  method  )  [private]

Definition at line 178 of file JobCRootCommandModule.cxx.

References fAnaLines, fBeginFileLines, fBeginJobLines, fBeginRunLines, fEndFileLines, fEndJobLines, fEndRunLines, fGetLines, fPutLines, fRecoLines, Msg::kInfo, and MSG.

Referenced by HandleCommand(), and ProcessLines().

00179 {
00180    if (whichlist == "Ana"           ) return &fAnaLines;
00181    if (whichlist == "Reco"          ) return &fRecoLines;
00182 
00183    if (whichlist == "BeginJob"      ) return &fBeginJobLines;
00184    if (whichlist == "EndJob"        ) return &fEndJobLines;
00185    if (whichlist == "BeginFile"     ) return &fBeginFileLines;
00186    if (whichlist == "EndFile"       ) return &fEndFileLines;
00187    if (whichlist == "BeginRun"      ) return &fBeginRunLines;
00188    if (whichlist == "EndRun"        ) return &fEndRunLines;
00189 
00190    if (whichlist == "Get"           ) return &fGetLines;
00191    if (whichlist == "Put"           ) return &fPutLines;
00192 
00193    MSG("Root",Msg::kInfo) 
00194       << "JobCRootCommandModule::WhichLinesList \"" 
00195       << whichlist
00196       << "\" not a recoginized list"
00197       << endl;
00198 
00199    return 0;
00200 }


Member Data Documentation

Definition at line 58 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 63 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 61 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 65 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 64 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 62 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 66 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 68 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 69 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().

Definition at line 59 of file JobCRootCommandModule.h.

Referenced by WhichLinesList().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1