JobCPath Class Reference

#include <JobCPath.h>

Inheritance diagram for JobCPath:
JobCGraphVtx

List of all members.

Public Types

enum  ERunMode { kRunAll, kRunNin, kRunNpass, kRunNfail }
typedef enum JobCPath::ERunMode RunMode_t
typedef list< JobCModule * >
::const_iterator 
ModuleIterator
typedef list< JobCNode * >
::const_iterator 
NodeIterator

Public Member Functions

 JobCPath ()
 JobCPath (const char *name, MomNavigator *mom, JobCInputModule *input)
virtual ~JobCPath ()
JobCModuleMod (const char *moduleName)
JobCNodeNode (const char *nodeName)
void Report ()
void Run (int n=JOBCPATH_RUN_LIMIT, RunMode_t mode=JobCPath::kRunNin)
void RunNin (int n)
void RunNpass (int n)
void RunNfail (int n)
void SetAllFilters (bool onOff)
void ReverseAllFilters ()
JobCResult LastResult () const
const char * GetName () const
void Print (ostream &os) const
JobCModuleGetModule (const char *moduleName, bool create=false)
JobCNodeFindNode (const char *module, const char *method)
JobCInputModuleGetInputModule ()
JobCNodePushFront (const char *moduleName, const char *methodName)
JobCNodePushBack (const char *moduleName, const char *methodName)
JobCNodeAddAt (const char *moduleName, const char *methodName, int n)
JobCNodeAddBetween (const char *moduleName, const char *methodName, const char *afterNodeName, const char *beforeNodeName)
void Remove (const char *moduleName, const char *methodName)
void Attach (JobCGraphVtx *p)
void Detach (JobCGraphVtx *p)
bool EvalInput (JobCRecord *rec)
JobCResult Execute (JobCRecord *rec)
void BeginJob () const
ModuleIterator GetModuleBegin ()
ModuleIterator GetModuleEnd ()
NodeIterator GetNodeBegin ()
NodeIterator GetNodeEnd ()
void HandleResult (const JobCResult &r) const
void SetRefreshMode (bool onOff) const
JobCPathoperator= (const JobCPath &)

Private Member Functions

bool AtJobStart () const
void CheckResult (const JobCResult &r)
JobCNodeCreateNode (const char *modName, const char *metName)
bool HandleError (const JobCResult &r, const JobCNode *n)
void PropagateRefreshMode (bool onOff)
void SetUniquePaths (const char *base="")

Static Private Member Functions

static void PropagateResult (const JobCResult &r, JobCPath *p)

Private Attributes

bool fIsRefreshRun
bool fAtJobStart
string fName
int fNin
int fNpass
int fNfail
MomNavigatorfMom
JobCInputModulefInput
list< JobCModule * > fModuleList
list< JobCNode * > fNodeList
JobCResult fResult
JobCModulefDummyModule
JobCNodefDummyNode

Friends

ostream & operator<< (ostream &os, const JobCPath &p)

Detailed Description

Definition at line 49 of file JobCPath.h.


Member Typedef Documentation

typedef list<JobCModule*>::const_iterator JobCPath::ModuleIterator

Definition at line 60 of file JobCPath.h.

typedef list<JobCNode*>::const_iterator JobCPath::NodeIterator

Definition at line 61 of file JobCPath.h.


Member Enumeration Documentation

Enumerator:
kRunAll 
kRunNin 
kRunNpass 
kRunNfail 

Definition at line 53 of file JobCPath.h.

00053                         {
00054     kRunAll,
00055     kRunNin,
00056     kRunNpass,
00057     kRunNfail
00058   } RunMode_t;


Constructor & Destructor Documentation

JobCPath::JobCPath (  ) 

Definition at line 140 of file JobCPath.cxx.

References Msg::kDebug, and MSG.

00140                    :
00141   fIsRefreshRun(false),
00142   fAtJobStart(true),
00143   fName(""),
00144   fNin(0),
00145   fNpass(0),
00146   fNfail(0),
00147   fMom(0),
00148   fInput(0),
00149   fDummyModule(0),
00150   fDummyNode(0)
00151 {
00152     MSG("JobC", Msg::kDebug) << " default constructor\n";
00153     //cerr << "JobCPath::JobCPath()\n";
00154 }

JobCPath::JobCPath ( const char *  name,
MomNavigator mom,
JobCInputModule input 
)

Definition at line 158 of file JobCPath.cxx.

References Msg::kDebug, and MSG.

00160                                          :
00161   fIsRefreshRun(false),
00162   fAtJobStart(true),
00163   fName(name),
00164   fNin(0),
00165   fNpass(0),
00166   fNfail(0),
00167   fMom(mom),
00168   fInput(inp),
00169   fDummyModule(0),
00170   fDummyNode(0)
00171 {
00172 //======================================================================
00173 // Purpose: Create and empty, named path which lives in the job
00174 //          environment "env"
00175 // Input  : name - the name of this path
00176 //        : env  - pointer to the job environment data
00177 //======================================================================
00178 
00179     MSG("JobC", Msg::kDebug) << " input module at " << (void*)inp << endl;
00180     //cerr << "JobCPath::JobCPath(\""<<name<<"\","<<(void*)mom<<","<<(void*)inp<<")\n";
00181 }

JobCPath::~JobCPath (  )  [virtual]

Definition at line 185 of file JobCPath.cxx.

References fDummyModule, fDummyNode, fModuleList, fNodeList, GetName(), Msg::kVerbose, and MSG.

00186 {
00187 //======================================================================
00188 // Purpose: Delete a path
00189 //======================================================================
00190   MSG("JobC", Msg::kVerbose) << this->GetName() << " destructor" << "\n";
00191 
00192 #ifdef SITE_HAS_SIGC
00193   this->SigDelete(this);
00194 #endif
00195 
00196   // Delete the nodes attached to this path
00197   list<JobCNode*>::iterator itrJobCNode;
00198   for (itrJobCNode = fNodeList.begin();
00199        itrJobCNode != fNodeList.end();
00200        ++itrJobCNode) {
00201     MSG("JobC", Msg::kVerbose) <<
00202       " >delete node " << (**itrJobCNode) << "\n";
00203     delete (*itrJobCNode);
00204   }
00205 
00206   // Delete modules attached to this path
00207   list<JobCModule*>::iterator itrJobCModule;
00208   for (itrJobCModule  = fModuleList.begin();
00209        itrJobCModule != fModuleList.end();
00210        ++itrJobCModule) {
00211     MSG("JobC", Msg::kVerbose) <<
00212       " >delete module " << (*itrJobCModule)->GetName() << "\n";
00213 
00214     // Tell the module the job is over before deleting it
00215     (*itrJobCModule)->EndJob();
00216 
00217     delete (*itrJobCModule);
00218   }
00219 
00220   if (fDummyModule) { delete fDummyModule; fDummyModule = 0; }
00221   if (fDummyNode)   { delete fDummyNode;   fDummyNode   = 0; }
00222 }


Member Function Documentation

JobCNode * JobCPath::AddAt ( const char *  moduleName,
const char *  methodName,
int  n 
)

Definition at line 584 of file JobCPath.cxx.

References CreateNode(), and fNodeList.

Referenced by JobCPathModule::Add().

00586 {
00587 //======================================================================
00588 // Purpose: Add a module::method pair at the nth position in the path
00589 //
00590 // Inputs: moduleName - name of the module
00591 //         methodName - name of the method
00592 //
00593 // Returns: pointer to node created
00594 //======================================================================
00595   // Create the node
00596   JobCNode *node = this->CreateNode(moduleName, methodName);
00597 
00598   // Advance to this place in the list. Note: start at 1 since that's
00599   // the way humans count. Ie. n=1 places the node first in the list,
00600   // n=2 second in the list etc.
00601   list<JobCNode*>::iterator itrJobCNode = fNodeList.begin();
00602   for (int i=1; i<n; ++i) {
00603     if (++itrJobCNode == fNodeList.end()) break;
00604   }
00605 
00606   // Insert at this point
00607   if (node) {
00608     fNodeList.insert(itrJobCNode, node);
00609 #ifdef SITE_HAS_SIGC
00610     this->SigUpdate(this,JobCPath::kAddNode);
00611 #endif
00612   }
00613 
00614   return node;
00615 }

JobCNode * JobCPath::AddBetween ( const char *  moduleName,
const char *  methodName,
const char *  afterNodeName,
const char *  beforeNodeName 
)

Definition at line 619 of file JobCPath.cxx.

References CreateNode(), FindNode(), fNodeList, it, Msg::kFatal, MSG, and JobCommand::SplitLine().

Referenced by atmo_create_path_data().

00623 {
00624 //======================================================================
00625 // Purpose: Add a module::method pair to the path between named modules
00626 //
00627 // Inputs: moduleName     - name of the module
00628 //         methodName     - name of the method
00629 //         afterNodeName  - name of the node to insert after
00630 //         beforeNodeName - name of the node to insert before
00631 //
00632 // Returns: pointer to node created
00633 //======================================================================
00634   // Create the node.
00635   JobCNode* newNode = this->CreateNode(moduleName, methodName);
00636 
00637   if(!newNode){
00638     MSG("JobCPath", Msg::kFatal) << "Could not create node "
00639                                  << moduleName << ":" << methodName << endl;
00640     return 0;
00641   }
00642 
00643   // Find the node we have to insert after.
00644   std::string afterModule, afterMethod;
00645   JobCommand::SplitLine(afterNodeName, ':', afterModule, afterMethod);
00646   JobCNode* afterNode = this->FindNode(afterModule.c_str() ,afterMethod.c_str());
00647 
00648   // Find the node we have to insert before.
00649   std::string beforeModule, beforeMethod;
00650   JobCommand::SplitLine(beforeNodeName, ':', beforeModule, beforeMethod);
00651   JobCNode* beforeNode = this->FindNode(beforeModule.c_str() ,beforeMethod.c_str());
00652 
00653   if(!afterNode){
00654     MSG("JobCPath", Msg::kFatal) << "Could not find node "
00655                                  << afterNodeName << endl;
00656     return 0;
00657   }
00658   if(!beforeNode){
00659     MSG("JobCPath", Msg::kFatal) << "Could not find node "
00660                                  << beforeNodeName << endl;
00661     return 0;
00662   }
00663 
00664   list<JobCNode*>::iterator it = fNodeList.begin();
00665 
00666   for(; it != fNodeList.end(); ++it){
00667     if(*it == afterNode){ // We found the node to go after.
00668       // Find the node we will be before.
00669       ++it;
00670       // Check it's the one we ought to be before.
00671       if(it != fNodeList.end() && *it == beforeNode){
00672         fNodeList.insert(it, newNode);
00673 #ifdef SITE_HAS_SIGC
00674         this->SigUpdate(this, JobCPath::kAddNode);
00675 #endif
00676         return newNode;
00677       }
00678       else{
00679         MSG("JobCPath", Msg::kFatal) << afterNodeName
00680                                      << " and "
00681                                      << beforeNodeName
00682                                      << " are not adjacent\n";
00683         return 0;
00684       }
00685     }
00686   }
00687 
00688   MSG("JobCPath", Msg::kFatal) << "This should never happen.\n";
00689   return 0;
00690 }

bool JobCPath::AtJobStart (  )  const [private]

Definition at line 241 of file JobCPath.cxx.

References fAtJobStart.

Referenced by Run().

00242 {
00243 //======================================================================
00244 // Are we starting a new job?
00245 //======================================================================
00246   bool tmp = fAtJobStart;
00247   fAtJobStart = false;
00248   return tmp;
00249 }

void JobCPath::Attach ( JobCGraphVtx p  ) 

Definition at line 751 of file JobCPath.cxx.

Referenced by JobCPathModule::Attach(), attach_blinded_output(), attach_mrcc_path_far(), attach_mrcc_path_near(), attach_output_mc(), attach_output_mc_srfitter(), attach_output_mc_srsafitter(), attach_output_srfitter(), and attach_output_srsafitter().

00752 {
00753 //======================================================================
00754 // Attach a path to this one
00755 //======================================================================
00756   this->JobCGraphVtx::Attach(p);
00757 #ifdef SITE_HAS_SIGC
00758   this->SigUpdate(this,JobCPath::kAddConnection);
00759 #endif
00760 }

void JobCPath::BeginJob ( void   )  const

Definition at line 845 of file JobCPath.cxx.

References fModuleList.

00846 {
00847 //======================================================================
00848 // Purpose: Signal BeginJob for every node in the path
00849 //
00850 //======================================================================
00851 
00852   // First time entering a path, send the begin job message to each
00853   // module in the path
00854   list<JobCModule*>::const_iterator i(fModuleList.begin());
00855   list<JobCModule*>::const_iterator iEnd(fModuleList.end());
00856   for (; i!=iEnd; ++i) if (*i) (*i)->BeginJob();
00857 
00858 }

void JobCPath::CheckResult ( const JobCResult r  )  [private]

Definition at line 253 of file JobCPath.cxx.

References JobCResult::BeginFile(), JobCResult::BeginRun(), JobCResult::EndFile(), JobCResult::EndRun(), Msg::kVerbose, MSG, and PropagateResult().

Referenced by Execute(), and Run().

00254 {
00255 //======================================================================
00256 // Purpose: Check the result of a node to see if the path needs to
00257 //          emit any status changes
00258 //======================================================================
00259   // Check conditions that require a response
00260     MSG("JobC", Msg::kVerbose) << "CheckResult: Current result is " << r << endl;
00261 
00262   if ( r.BeginFile() || r.EndFile() || r.BeginRun()  || r.EndRun() ) {
00263     this->PropagateResult(r,this);
00264   }
00265 }

JobCNode * JobCPath::CreateNode ( const char *  modName,
const char *  metName 
) [private]

Definition at line 453 of file JobCPath.cxx.

References JobCMethod::GetMethodByName(), GetModule(), JobCModule::GetName(), JobCMethod::GetName(), Msg::kDebug, Msg::kWarning, MSG, and n.

Referenced by AddAt(), AddBetween(), PushBack(), and PushFront().

00454 {
00455 //======================================================================
00456 // Purpose: Create a node using a specified module and method
00457 //
00458 // Inputs: modName - name of the module to use
00459 //         metName - name of the method to use
00460 //
00461 // Returns: Pointer to the node created
00462 //======================================================================
00463   // Look the module up
00464   JobCModule *module = this->GetModule(modName, true);
00465   if (module == 0) {
00466     MSG("JobC",Msg::kWarning) <<
00467       "Get failed for module '" << modName << "'.\n";
00468     return 0;
00469   }
00470 
00471   // Get the method
00472   const JobCMethod* method = JobCMethod::GetMethodByName(metName);
00473   if (method == 0) {
00474     MSG("JobC",Msg::kWarning) <<
00475       "Look up failed for method '" << metName << "'\n";
00476     return 0;
00477   }
00478   MSG("JobC", Msg::kDebug) << "Created node "
00479                            << module->GetName() << "::"
00480                            << method->GetName() << "\n";
00481 
00482   // Create the node
00483   JobCNode* n = new JobCNode(module, method);
00484 #ifdef SITE_HAS_SIGC
00485   if (n) {
00486     // Attach the Filter update signal to the node's filter update signal
00487     n->SigUpdate.connect(SigC::slot_class(*this,&JobCPath::NodeUpdateCB));
00488   }
00489 #endif
00490   return n;
00491 }

void JobCPath::Detach ( JobCGraphVtx p  ) 

Definition at line 764 of file JobCPath.cxx.

00765 {
00766 //======================================================================
00767 // Attach a path to this one
00768 //======================================================================
00769   this->JobCGraphVtx::Detach(p);
00770 #ifdef SITE_HAS_SIGC
00771   this->SigUpdate(this,JobCPath::kRemoveConnection);
00772 #endif
00773 }

bool JobCPath::EvalInput ( JobCRecord rec  )  [virtual]

Implements JobCGraphVtx.

Definition at line 733 of file JobCPath.cxx.

References JobCResult::EndOfInputStream(), Execute(), JobCResult::Failed(), Msg::kVerbose, and MSG.

00734 {
00735 //======================================================================
00736 // Evaluate this node in the graph
00737 //======================================================================
00738   // Get the result of running this path
00739   JobCResult result = this->Execute(rec);
00740   MSG("JobC", Msg::kVerbose) << "EvalInput gets result = " << result << endl;
00741 
00742 
00743 
00744   // Decide if execute was sucessful or not
00745   if ( result.EndOfInputStream() || result.Failed() ) return false;
00746   return true;
00747 }

JobCResult JobCPath::Execute ( JobCRecord rec  ) 

Definition at line 777 of file JobCPath.cxx.

References CheckResult(), JobCResult::EndOfInputStream(), JobCResult::Failed(), fInput, fIsRefreshRun, fNfail, fNin, fNodeList, fNpass, fResult, JobCRecord::GetDataPtr(), HandleError(), JobCResult::HaveError(), MsgTripWire::Instance(), JobCMethod::kGet, Msg::kVerbose, Munits::m, MSG, JobCResult::NonPhysicsRecord(), JobCRecord::SetIsPhysics(), and MsgTripWire::StartNode().

Referenced by EvalInput().

00778 {
00779 //======================================================================
00780 // Purpose: Run a record through every node in the path
00781 //
00782 // Inputs: rec - the MINOS Object Map that holds the data to process
00783 //
00784 // Returns: Pass/Fail depending on whether the record passed every node
00785 //======================================================================
00786 
00787   // Count events processed
00788   ++fNin;
00789 
00790   // Loop over all nodes in path
00791   list<JobCNode*>::iterator itrJobCNode(fNodeList.begin());
00792   list<JobCNode*>::iterator itrEnd(fNodeList.end());
00793   for (;itrJobCNode != itrEnd; ++itrJobCNode) {
00794 
00795     // We'll need to make some querries about what kind of node this
00796     // is, so get the method type
00797     JobCMethod m = (*itrJobCNode)->GetMethod();
00798 
00799     // Don't evalute Get methods on "refresh" runs
00800     // This makes sense in the "old" framework (hence the fInput=0
00801     if (fInput==0 && (fIsRefreshRun == true) && (m == JobCMethod::kGet)) {
00802       continue;
00803     }
00804 
00805     // Evaluate this node
00806     MsgTripWire::Instance().StartNode(); //Record start of node
00807     fResult = (*itrJobCNode)->Execute(rec->GetDataPtr());
00808     MSG("JobC", Msg::kVerbose) << "Result of node " << *(*itrJobCNode) << "execution is: " << fResult << endl;
00809 
00810 
00811     // See if the job module produced any errors, warnings, or other
00812     // conditions which require special handling
00813     if (fResult.HaveError()) {
00814       bool stopRun = this->HandleError(fResult,(*itrJobCNode));
00815       if (stopRun) return fResult;
00816     }
00817 
00818     // On end of input we have to adjust the counter since the stream
00819     // failed to deliver a new record
00820     if ( fResult.EndOfInputStream() ) {
00821       --fNin;
00822       return fResult;
00823     }
00824 
00825     // See if record was labeled non-phyiscs
00826     if ( fResult.NonPhysicsRecord() ) rec->SetIsPhysics(false);
00827 
00828     // See if this result has triggered any status changes
00829     this->CheckResult(fResult);
00830 
00831     // Exit on failure
00832     if (fResult.Failed()) {
00833       ++fNfail;
00834       return fResult;
00835     }
00836   } // loop on nodes
00837 
00838   // Passed all nodes
00839   ++fNpass;
00840   return fResult;
00841 }

JobCNode * JobCPath::FindNode ( const char *  module,
const char *  method 
)

Definition at line 347 of file JobCPath.cxx.

References fNodeList.

Referenced by AddBetween(), Node(), and JobCPathHandler::PathFilterCommand().

00348 {
00349 //======================================================================
00350 // Purpose: Look for a node which matches the module method pair
00351 //======================================================================
00352   list<JobCNode*>::const_iterator itr(fNodeList.begin());
00353   list<JobCNode*>::const_iterator itrEnd(fNodeList.end());
00354   for (; itr!=itrEnd; ++itr) {
00355     if ((*itr)->MatchModuleMethod(module,method)) {
00356       return (*itr);
00357     }
00358   }
00359   return 0;
00360 }

JobCInputModule * JobCPath::GetInputModule (  ) 

Definition at line 362 of file JobCPath.cxx.

References fInput.

Referenced by JobCModule::GetJobCInputModule().

00363 {
00364     return fInput;
00365 }

JobCModule * JobCPath::GetModule ( const char *  moduleName,
bool  create = false 
)

Definition at line 311 of file JobCPath.cxx.

References JobCModuleProxy::CreateModule(), fModuleList, fName, JobCModuleRegistry::Instance(), Msg::kVerbose, JobCModuleRegistry::LookUp(), Munits::m, MSG, and JobCModule::SetPath().

Referenced by CreateNode(), JobController::HandleCommand(), and Mod().

00312 {
00313 //======================================================================
00314 // Get the module named "moduleName" in this path. If no module is
00315 // found then the method returns 0 if create==false. If create==true
00316 // the a module with the given name is created and a pointer to it
00317 // returned.
00318 //======================================================================
00319   list<JobCModule*>::iterator itrJobCModule(fModuleList.begin());
00320   list<JobCModule*>::iterator itrEnd(fModuleList.end());
00321   for (;itrJobCModule != itrEnd; ++itrJobCModule) {
00322     if (strcmp(moduleName,(*itrJobCModule)->GetName())==0) {
00323       MSG("JobC",Msg::kVerbose) <<
00324         "Found " << moduleName << " in path " << fName << "\n";
00325       return (*itrJobCModule);
00326     }
00327   }
00328   // Failed to find the module. Either return 0 or build the module
00329   if (create == false) return 0;
00330 
00331   // Not found and we've been asked to make one.
00332   JobCModuleProxy*
00333     jmp = JobCModuleRegistry::Instance().LookUp(moduleName);
00334   if (jmp) {
00335     JobCModule* m = jmp->CreateModule(); // Remember to delete this!
00336     m->SetPath(this);
00337     fModuleList.push_back(m);            // Add to path's modules
00338     return m;
00339   }
00340 
00341   // Errors fall through to here
00342   return 0;
00343 }

ModuleIterator JobCPath::GetModuleBegin (  )  [inline]

Definition at line 104 of file JobCPath.h.

References fModuleList.

00104 { return fModuleList.begin(); }

ModuleIterator JobCPath::GetModuleEnd (  )  [inline]

Definition at line 105 of file JobCPath.h.

References fModuleList.

00105 { return fModuleList.end(); }

const char * JobCPath::GetName (  )  const

Definition at line 307 of file JobCPath.cxx.

References fName.

Referenced by Jint::AddPath(), Jint::EndPathRun(), Mod(), Node(), JobCPathHandler::PathRunCommand(), Print(), Jint::RemovePath(), Jint::UpdatePath(), and ~JobCPath().

00307 { return fName.c_str(); }

NodeIterator JobCPath::GetNodeBegin (  )  [inline]

Definition at line 106 of file JobCPath.h.

References fNodeList.

00106 { return fNodeList.begin(); }

NodeIterator JobCPath::GetNodeEnd (  )  [inline]

Definition at line 107 of file JobCPath.h.

References fNodeList.

00107 { return fNodeList.end(); }

bool JobCPath::HandleError ( const JobCResult r,
const JobCNode n 
) [private]

Definition at line 370 of file JobCPath.cxx.

References JobCResult::ErrorLevel(), Msg::kError, JobCResult::kError, JobCResult::kFatal, Msg::kFatal, JobCResult::kWarning, and MSG.

Referenced by Execute().

00371 {
00372 //======================================================================
00373 // Purpose: Handle any errors that might have occured from executing a
00374 // node
00375 //
00376 // Returns: true  - stop the run
00377 //          false - continue the run
00378 //======================================================================
00379   JobCResult::Error_t errlvl = result.ErrorLevel();
00380   if (errlvl == JobCResult::kWarning) {
00381 //    MSG("JobC",Msg::kWarning) << "Warning in: [" << (*n) << "]\n";
00382   }
00383   else if (errlvl == JobCResult::kError) {
00384     MSG("JobC",Msg::kError) << "Error in: [" << (*n) << "]\n";
00385   }
00386   else {
00387     MSG("JobC",Msg::kFatal) <<
00388       "Fatal error in: [" << (*n) << "]\n";
00389   }
00390 
00391   // Is error relatively mild?
00392   JobCResult::Error_t errorThreshold = JobCResult::kError;
00393   if (errlvl < errorThreshold) return false; // Keep rolling...
00394 
00395   // Is the erro fatal?
00396   if (errlvl == JobCResult::kFatal) abort();
00397 
00398   return true; // Stop the run
00399 }

void JobCPath::HandleResult ( const JobCResult r  )  const

Definition at line 269 of file JobCPath.cxx.

References JobCResult::BeginFile(), JobCResult::BeginRun(), JobCResult::EndFile(), JobCResult::EndRun(), fModuleList, Msg::kVerbose, and MSG.

00270 {
00271 //======================================================================
00272 // Purpose: Check the result of a node to see if the path needs to
00273 //          emit any status changes
00274 //======================================================================
00275     MSG("JobC", Msg::kVerbose) << "HandleResult: Current result is " << r << endl;
00276 
00277   bool beginFile = r.BeginFile();
00278   bool endFile   = r.EndFile();
00279   bool beginRun  = r.BeginRun();
00280   bool endRun    = r.EndRun();
00281 
00282   list<JobCModule*>::const_iterator itrJobCModule;
00283   for (itrJobCModule  = fModuleList.begin();
00284        itrJobCModule != fModuleList.end();
00285        ++itrJobCModule) {
00286     if (endFile)   { (*itrJobCModule)->EndFile();   }
00287     if (endRun)    { (*itrJobCModule)->EndRun();    }
00288     if (beginRun)  { (*itrJobCModule)->BeginRun();  }
00289     if (beginFile) { (*itrJobCModule)->BeginFile(); }
00290   }
00291 }

JobCResult JobCPath::LastResult (  )  const [inline]

Definition at line 80 of file JobCPath.h.

References fResult.

Referenced by Jint::EndPathRun().

00080 { return fResult; }

JobCModule & JobCPath::Mod ( const char *  moduleName  ) 

Definition at line 403 of file JobCPath.cxx.

References fDummyModule, GetModule(), GetName(), Msg::kWarning, Munits::m, and MSG.

Referenced by atmo_configure_common(), atmo_configure_data(), atmo_configure_mc(), attach_mrcc_path_far(), attach_mrcc_path_near(), attach_output(), attach_output_mc(), attach_output_mc_srfitter(), attach_output_mc_srsafitter(), attach_output_srfitter(), attach_output_srsafitter(), cosmic_configure(), cosmic_do_report(), cosmic_set_filter(), cosmic_set_prescaling(), far_all_configure(), far_all_configure_filters(), far_all_mc_configure(), far_configure(), far_configure_filters(), far_cosmic_mc_configure(), far_cosmic_mc_scale_xtalk(), far_do_report(), far_mc_configure(), far_mc_do_report(), far_spill_configure(), far_spill_configure_filters(), far_spill_do_report(), main(), mc_reco_configure(), mc_reco_cosmic_configure(), mc_reco_cosmic_configure_shower(), mc_reco_do_report(), mc_reco_far_configure(), mc_reco_far_do_report(), merge_configure(), merge_do_report(), near_configure(), near_configure_filter(), near_configure_shower(), near_cosmic_configure(), near_cosmic_do_report(), near_cosmic_mc_configure(), near_cosmic_mc_configure_shower(), near_cosmic_mc_scale_xtalk(), near_cosmic_set_filter(), near_cosmic_set_prescaling(), near_do_report(), near_mc_configure(), near_mc_do_report(), reroot_configure(), reroot_do_report(), spill_configure(), spill_configure_filter(), spill_configure_shower(), spill_do_report(), and use_new_hv_table().

00404 {
00405 //======================================================================
00406 // Return the module in this path by name. If not found return a dummy
00407 // module. This method is intened for use interactively so it doesn't
00408 // use pointers. Ie. it tries to help prevent people from doing
00409 // (JobCModule*)0->Method(); which would trash their root session
00410 //======================================================================
00411   JobCModule* m = this->GetModule(moduleName, false);
00412   if (m) { return (*m); }
00413 
00414   MSG("JobC",Msg::kWarning) <<
00415     "Path '" << this->GetName() << "' " <<
00416     "does not contain module '" << moduleName << "'.\n";
00417 
00418   // In this case return a dummy, empty module to avoid having things
00419   // complete blow up in the user's face...
00420   if (fDummyModule == 0) fDummyModule = new JobCModule;
00421   return (*fDummyModule);
00422 }

JobCNode & JobCPath::Node ( const char *  nodeName  ) 

Definition at line 426 of file JobCPath.cxx.

References fDummyNode, FindNode(), GetName(), Msg::kWarning, MSG, n, and JobCommand::SplitLine().

Referenced by attach_blinded_output(), attach_mrcc_path_far(), attach_mrcc_path_near(), cosmic_set_filter(), far_all_configure_filters(), far_configure_filters(), far_spill_configure_filters(), merge_configure_filter(), near_configure_filter(), near_cosmic_set_filter(), and spill_configure_filter().

00427 {
00428 //======================================================================
00429 // Return the module in this path by name. If not found return a dummy
00430 // module. This method is intened for use interactively so it doesn't
00431 // use pointers. Ie. it tries to help prevent people from doing
00432 // (JobCModule*)0->Method(); which would trash their root session
00433 //======================================================================
00434   std::string module;
00435   std::string method;
00436   JobCommand::SplitLine(nodeName,':',module,method);
00437 
00438   JobCNode* n = this->FindNode(module.c_str(),method.c_str());
00439   if (n) { return (*n); }
00440 
00441   MSG("JobC",Msg::kWarning) <<
00442     "Path '" << this->GetName() << "' " <<
00443     "does contain node '" << nodeName << "'.\n";
00444 
00445   // In this case return a dummy, empty module to avoid having things
00446   // complete blow up in the user's face...
00447   if (fDummyNode == 0) fDummyNode = new JobCNode;
00448   return (*fDummyNode);
00449 }

JobCPath& JobCPath::operator= ( const JobCPath  )  [inline]

Definition at line 135 of file JobCPath.h.

00135 { abort(); return *this; } // no assignment

void JobCPath::Print ( ostream &  os  )  const

Definition at line 97 of file JobCPath.cxx.

References fName, fNfail, fNin, fNodeList, fNpass, JobCGraphVtx::GetAttached(), and GetName().

00098 {
00099 //======================================================================
00100 // Print the job path to the MsgStream os
00101 //======================================================================
00102   os << fName.c_str()
00103      << "("
00104      << fNin   << " in "
00105      << fNpass << " out "
00106      << fNfail << " filt.)\n";
00107   int i=0;
00108   MsgFormat i1("%3d");
00109   list<JobCNode*>::const_iterator      itrEnd      = fNodeList.end();
00110   for (list<JobCNode*>::const_iterator itrJobCNode = fNodeList.begin();
00111        itrJobCNode != itrEnd;
00112        ++itrJobCNode) {
00113     os << i1(++i) << ") " << (**itrJobCNode) << "\n";
00114   }
00115 
00116   // Print list of paths attached to this one
00117   bool haveconnect = false;
00118   const JobCGraphVtx* v = 0;
00119   for (i=0; (v=this->GetAttached(i))!=0; ++i) {
00120     const JobCPath* p2 = dynamic_cast<const JobCPath*>(v);
00121     if (p2!=0 && haveconnect==false) {
00122       os << "  |-->";
00123     }
00124     os << "/" << p2->GetName();
00125     haveconnect = true;
00126   }
00127   if (haveconnect) os << "/\n";
00128 }

void JobCPath::PropagateRefreshMode ( bool  onOff  )  [private]

Definition at line 870 of file JobCPath.cxx.

References JobCPathConnectionHelper::SetRefreshMode().

Referenced by Run().

00871 {
00872 //======================================================================
00873 // Tell this path and all others attached that we're in refresh mode m
00874 //======================================================================
00875   JobCPathConnectionHelper h(this);
00876   h.SetRefreshMode(m);
00877 }

void JobCPath::PropagateResult ( const JobCResult r,
JobCPath p 
) [static, private]

Definition at line 295 of file JobCPath.cxx.

References JobCPathConnectionHelper::DoHandleResult().

Referenced by CheckResult().

00296 {
00297 //======================================================================
00298 // Send the result r to all the paths attached to path p
00299 //======================================================================
00300   // Use the print helper to get the list of attached paths
00301   JobCPathConnectionHelper h(p);
00302   h.DoHandleResult(r);
00303 }

JobCNode * JobCPath::PushBack ( const char *  moduleName,
const char *  methodName 
)

Definition at line 553 of file JobCPath.cxx.

References CreateNode(), fNodeList, Msg::kWarning, and MSG.

Referenced by JobCPathModule::Add(), atmo_create_path_datafilter(), atmo_create_path_mc(), attach_mrcc_path_far(), attach_mrcc_path_near(), attach_output_mc(), attach_output_mc_srfitter(), attach_output_mc_srsafitter(), attach_output_srfitter(), attach_output_srsafitter(), JobController::BuildSystemPath(), JobCPathModule::Create(), far_all_create_path(), far_cosmic_mc_create_path(), far_create_path(), far_mc_create_path(), merge_create_path(), near_cosmic_create_path(), near_cosmic_mc_create_path(), near_create_path(), near_mc_create_path(), and reroot_create_path().

00554 {
00555 //======================================================================
00556 // Purpose: Add a module::method pair to the end of the path
00557 //
00558 // Inputs: moduleName - name of the module
00559 //         methodName - name of the method
00560 //
00561 // Returns: pointer to the node created
00562 //======================================================================
00563   // Create a node
00564   JobCNode *node = this->CreateNode(moduleName, methodName);
00565   if (node == 0) {
00566     MSG("JobC", Msg::kWarning)
00567       << "Failed to create node "
00568       << moduleName << "::" << methodName << "\n";
00569     return 0;
00570   }
00571 
00572   // Add the node to the front of the list
00573   if (node) {
00574     fNodeList.push_back(node);
00575 #ifdef SITE_HAS_SIGC
00576     this->SigUpdate(this,JobCPath::kAddNode);
00577 #endif
00578   }
00579   return node;
00580 }

JobCNode * JobCPath::PushFront ( const char *  moduleName,
const char *  methodName 
)

Definition at line 528 of file JobCPath.cxx.

References CreateNode(), and fNodeList.

00529 {
00530 //======================================================================
00531 // Purpose: Add a module::method pair to the begining of the path
00532 //
00533 // Inputs: moduleName - name of the module
00534 //         methodName - name of the method
00535 //
00536 // Returns: pointer to node created
00537 //======================================================================
00538   // Create a node
00539   JobCNode *node = this->CreateNode(moduleName, methodName);
00540 
00541   // Add the node to the front of the list
00542   if (node) {
00543     fNodeList.push_front(node);
00544 #ifdef SITE_HAS_SIGC
00545     this->SigUpdate(this,JobCPath::kAddNode);
00546 #endif
00547   }
00548   return node;
00549 }

void JobCPath::Remove ( const char *  moduleName,
const char *  methodName 
)

Definition at line 694 of file JobCPath.cxx.

References fNodeList, Msg::kWarning, and MSG.

00695 {
00696 //======================================================================
00697 // Purpose: Remove a module::method pair from the path
00698 //
00699 // Inputs: moduleName - name of the module
00700 //         methodName - name of the method
00701 //======================================================================
00702   // Find the node coresponding to this module/method
00703   bool haveMatch = false; // Is there a node that matches
00704   list<JobCNode*>::iterator itrJobCNode(fNodeList.begin());
00705   list<JobCNode*>::iterator itrEnd(fNodeList.end());
00706   for (;itrJobCNode != itrEnd; ++itrJobCNode) {
00707     if ( (haveMatch =
00708           (*itrJobCNode)->MatchModuleMethod(moduleName, methodName))) {
00709       break;
00710     }
00711   }
00712 
00713   if (haveMatch) {
00714     // Delete the node object pointed to
00715     delete (*itrJobCNode);
00716 
00717     // Remove pointer from list
00718     fNodeList.erase(itrJobCNode);
00719 #ifdef SITE_HAS_SIGC
00720     this->SigUpdate(this,JobCPath::kRemoveNode);
00721 #endif
00722     return;
00723   }
00724 
00725   // No match in list
00726   MSG("JobC", Msg::kWarning)
00727     << "Path does not contain "
00728     << moduleName << "::" << methodName << ".\n";
00729 }

void JobCPath::Report (  ) 

Definition at line 881 of file JobCPath.cxx.

References Msg::kInfo, and MSG.

Referenced by main(), and run().

00881 { MSG("JobCReport",Msg::kInfo) << (*this) << "\n"; }

void JobCPath::ReverseAllFilters (  ) 

Definition at line 514 of file JobCPath.cxx.

References fNodeList.

Referenced by JobCPathHandler::PathFilterCommand().

00515 {
00516 //======================================================================
00517 // Purpose: Reverse the meaning of pass/fail for all active filters
00518 //======================================================================
00519   list<JobCNode*>::iterator itr(fNodeList.begin());
00520   list<JobCNode*>::iterator itrEnd(fNodeList.end());
00521   for (; itr!=itrEnd; ++itr) {
00522     (*itr)->ReverseFilter();
00523   }
00524 }

void JobCPath::Run ( int  n = JOBCPATH_RUN_LIMIT,
JobCPath::RunMode_t  runmode = JobCPath::kRunNin 
)

Definition at line 885 of file JobCPath.cxx.

References AtJobStart(), CheckResult(), JobCEnv::ContinueRun(), JobCPathConnectionHelper::DoBeginJob(), done(), JobCResult::EndOfInputStream(), JobCGraphVtx::EvaluateGraph(), fInput, fMom, fNfail, fNin, fNpass, fResult, JobCInputModule::GetCurrentRun(), JobCInputModule::GetCurrentSnarl(), MsgTripWire::Instance(), MsgService::Instance(), JobCEnv::Instance(), JOBCPATH_RUN_LIMIT, kRunAll, kRunNfail, kRunNin, kRunNpass, Msg::kVerbose, Msg::kWarning, MSG, JobCInputModule::Next(), PropagateRefreshMode(), JobCRecord::Reset(), SetUniquePaths(), and MsgTripWire::StartRecordSet().

Referenced by main(), JobCPathHandler::PathRunCommand(), run(), RunNfail(), RunNin(), and RunNpass().

00886 {
00887 //======================================================================
00888 // Purpose: Run records through the path until the path cannot find
00889 //          records to process
00890 //======================================================================
00891   assert(fMom);
00892   JobCRecord rec(fMom);
00893 
00894   this->SetUniquePaths();
00895 
00896 #ifdef SITE_HAS_SIGC
00897   this->SigStartRun(this);
00898 #endif
00899 
00900   // n = 0 is a flag to re-run the current event
00901   if (n == 0) {
00902     this->PropagateRefreshMode(true);
00903     this->EvaluateGraph(&rec);
00904     this->PropagateRefreshMode(false);
00905 #ifdef SITE_HAS_SIGC
00906     this->SigEndRun(this);
00907 #endif
00908     return;
00909   }
00910   else {
00911 
00912     // First time entering a path, send the begin job message to each
00913     // module in the path, as well as the attached paths.
00914     // Use the path helper to process the list of attached paths.
00915     if (this->AtJobStart()) {
00916       JobCPathConnectionHelper h(this);
00917       h.DoBeginJob();
00918     }
00919 
00920     // n != 0 runs new events
00921     bool done  = false;  // Are we done with the run?
00922     int nIn0   = fNin;   // Number events already read at start of run
00923     int nPass0 = fNpass; // Number events already passed at start of run
00924     int nFail0 = fNfail; // Number events already failed at start of run
00925     while (done == false) {
00926       MsgTripWire::Instance().StartRecordSet(); //Record start of record set
00927       rec.Reset();
00928       if (fInput) {
00929         fResult = fInput->Next();
00930         // Reset the prefix on future MsgService calls.
00931         (MsgService::Instance())->SetCurrentRunSnarl(fInput->GetCurrentRun(),
00932                                                      fInput->GetCurrentSnarl());
00933 
00934         MSG("JobC", Msg::kVerbose) << "Result input module is: "
00935                                    << fResult << endl;
00936         this->CheckResult(fResult);
00937 
00938         if (fResult.EndOfInputStream()) {
00939           done |= true;
00940           break;
00941         }
00942       }
00943       this->EvaluateGraph(&rec);
00944 
00945       // Decide if we're done based on number of events processed
00946       // The variables fNin, fNpass, and fNfail get updated as we run
00947       done |= ( (runmode == JobCPath::kRunAll)   && (false) );
00948       done |= ( (runmode == JobCPath::kRunNin)   && (fNin  -nIn0  )==n );
00949       done |= ( (runmode == JobCPath::kRunNpass) && (fNpass-nPass0)==n );
00950       done |= ( (runmode == JobCPath::kRunNfail) && (fNfail-nFail0)==n );
00951 
00952       // Check if we've reached the end of the input stream
00953       if (fResult.EndOfInputStream()) done |= true;
00954 
00955       // Check run limits from the job environmemt
00956       if (JobCEnv::Instance().ContinueRun(fNin) == false) {
00957         done |= true;
00958       }
00959 
00960       // Prevent running forever...
00961       if ( (fNin-nIn0)==JOBCPATH_RUN_LIMIT ) {
00962         MSG("JobC",Msg::kWarning) <<
00963           "Run limit (" << JOBCPATH_RUN_LIMIT << " records) reached.\n";
00964         done |= true;
00965       }
00966     }
00967   }
00968 #ifdef SITE_HAS_SIGC
00969   this->SigEndRun(this);
00970 #endif
00971 }

void JobCPath::RunNfail ( int  n  ) 

Definition at line 996 of file JobCPath.cxx.

References kRunNfail, and Run().

Referenced by JobCPathHandler::PathRunCommand().

00997 {
00998 //======================================================================
00999 // Purpose: Run records through the path until n fail
01000 //======================================================================
01001   this->Run(n,JobCPath::kRunNfail);
01002 }

void JobCPath::RunNin ( int  n  ) 

Definition at line 975 of file JobCPath.cxx.

References kRunNin, and Run().

Referenced by JobCPathHandler::PathRunCommand().

00976 {
00977 //======================================================================
00978 // Purpose: Run n records through the path - n=0 is a special case for
00979 //          interactive jobs
00980 //======================================================================
00981   this->Run(n,JobCPath::kRunNin);
00982 }

void JobCPath::RunNpass ( int  n  ) 

Definition at line 986 of file JobCPath.cxx.

References kRunNpass, and Run().

Referenced by JobCPathHandler::PathRunCommand().

00987 {
00988 //======================================================================
00989 // Purpose: Run records through the path until n pass
00990 //======================================================================
00991   this->Run(n,JobCPath::kRunNpass);
00992 }

void JobCPath::SetAllFilters ( bool  onOff  ) 

Definition at line 495 of file JobCPath.cxx.

References fNodeList.

Referenced by attach_blinded_output(), attach_mrcc_path_far(), attach_mrcc_path_near(), cosmic_set_filter(), far_all_configure_filters(), far_configure_filters(), far_spill_configure_filters(), merge_configure(), near_configure_filter(), near_cosmic_set_filter(), near_mc_configure(), JobCPathHandler::PathFilterCommand(), reroot_configure(), and spill_configure_filter().

00496 {
00497 //======================================================================
00498 // Purpose: Set all nodes to filter (true) or not to filter (false)
00499 //======================================================================
00500   list<JobCNode*>::iterator itr(fNodeList.begin());
00501   list<JobCNode*>::iterator itrEnd(fNodeList.end());
00502   for (; itr!=itrEnd; ++itr) {
00503     if (onOff) {
00504       (*itr)->FilterOn();
00505     }
00506     else {
00507       (*itr)->FilterOff();
00508     }
00509   }
00510 }

void JobCPath::SetRefreshMode ( bool  onOff  )  const

Definition at line 862 of file JobCPath.cxx.

References fIsRefreshRun.

00863 {
00864   // This bool is mutable so the const is OK
00865   fIsRefreshRun = m;
00866 }

void JobCPath::SetUniquePaths ( const char *  base = ""  )  [private]

Definition at line 1003 of file JobCPath.cxx.

References done(), fName, fNodeList, Form(), JobCGraphVtx::GetAttached(), JobCModule::GetName(), JobCModule::SetUniqueName(), and SetUniquePaths().

Referenced by Run(), and SetUniquePaths().

01004 {
01005     string path = Form("%s/%s",base,fName.c_str());
01006 
01007     list<JobCNode*>::const_iterator nit, done =  fNodeList.end();
01008     for (nit = fNodeList.begin(); nit != done; ++nit) {
01009         JobCModule* mod = (*nit)->GetModule();
01010         string name = Form("%s/%s",path.c_str(),mod->GetName());
01011         mod->SetUniqueName(name.c_str());
01012     }
01013 
01014     JobCGraphVtx* v = 0;
01015     for (int ind = 0; (v=this->GetAttached(ind))!=0; ++ind) {
01016         JobCPath* p2 = dynamic_cast<JobCPath*>(v);
01017         p2->SetUniquePaths(path.c_str());
01018     }
01019 }


Friends And Related Function Documentation

ostream& operator<< ( ostream &  os,
const JobCPath p 
) [friend]

Member Data Documentation

bool JobCPath::fAtJobStart [mutable, private]

Definition at line 149 of file JobCPath.h.

Referenced by AtJobStart().

JobCModule* JobCPath::fDummyModule [mutable, private]

Definition at line 161 of file JobCPath.h.

Referenced by Mod(), and ~JobCPath().

JobCNode* JobCPath::fDummyNode [mutable, private]

Definition at line 162 of file JobCPath.h.

Referenced by Node(), and ~JobCPath().

Definition at line 156 of file JobCPath.h.

Referenced by Execute(), GetInputModule(), and Run().

bool JobCPath::fIsRefreshRun [mutable, private]

Definition at line 148 of file JobCPath.h.

Referenced by Execute(), and SetRefreshMode().

Definition at line 157 of file JobCPath.h.

Referenced by BeginJob(), GetModule(), GetModuleBegin(), GetModuleEnd(), HandleResult(), and ~JobCPath().

Definition at line 155 of file JobCPath.h.

Referenced by Run().

string JobCPath::fName [private]

Definition at line 150 of file JobCPath.h.

Referenced by GetModule(), GetName(), Print(), and SetUniquePaths().

int JobCPath::fNfail [private]

Definition at line 153 of file JobCPath.h.

Referenced by Execute(), Print(), and Run().

int JobCPath::fNin [private]

Definition at line 151 of file JobCPath.h.

Referenced by Execute(), Print(), and Run().

list<JobCNode*> JobCPath::fNodeList [private]
int JobCPath::fNpass [private]

Definition at line 152 of file JobCPath.h.

Referenced by Execute(), Print(), and Run().

Definition at line 159 of file JobCPath.h.

Referenced by Execute(), LastResult(), and Run().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1