Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AltModuleStpPatternRec.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AltModuleStpPatternRec.cxx,v 1.2 2004/07/26 12:22:52 west Exp $
00003 //
00004 // AltModuleStpPatternRec.cxx
00005 //
00006 //    -- A JobControl Module using algorithm objects utilizing Neural Net
00007 //       Techniques to compute the likelihoods for each strip, for all
00008 //       slices in a givel spill, to belong in a "track-like" or a
00009 //       "shower-like" formation
00010 //
00011 // Costas Andreopoulos <C.V.Andreopoulos@rl.ac.uk>
00012 // CCLRC, Rutherford Appleton Laboratory
00013 // July 01, 2003
00015 
00016 #include <cassert>
00017 
00018 #include "AltModuleStpPatternRec.h"
00019 #include "AltCandStpProbList.h"
00020 #include "AltCandStpProbListHandle.h"
00021 
00022 #include "Algorithm/AlgConfig.h"
00023 #include "Algorithm/AlgFactory.h"
00024 #include "Algorithm/AlgHandle.h"
00025 #include "CandData/CandHeader.h"
00026 #include "CandData/CandRecord.h"
00027 #include "Candidate/CandContext.h"
00028 #include "RecoBase/CandSliceListHandle.h"
00029 #include "RecoBase/CandSliceListHandle.h"
00030 #include "Conventions/Munits.h"
00031 #include "JobControl/JobCModuleRegistry.h"
00032 #include "JobControl/JobCommand.h"
00033 #include "MessageService/MsgService.h"
00034 #include "MinosObjectMap/MomNavigator.h"
00035 #include "RecoBase/CandStripListHandle.h"
00036 #include "Validity/VldContext.h"
00037 
00038 ClassImp(AltModuleStpPatternRec)
00039 
00040 //____________________________________________________________________________
00041 CVSID("$Id: AltModuleStpPatternRec.cxx,v 1.2 2004/07/26 12:22:52 west Exp $");
00042 //____________________________________________________________________________
00043 JOBMODULE(AltModuleStpPatternRec, "AltModuleStpPatternRec", "Strip Pattern Recg.");
00044 //____________________________________________________________________________
00045 AltModuleStpPatternRec::AltModuleStpPatternRec() :
00046 fListIn("CandSliceSRListHandle"),
00047 fListOut("AltCandStpProbList")
00048 {
00049   MSG("Alt", Msg::kVerbose) << "AltModuleStpPatternRec::Constructor\n";
00050 
00051   //-- Get AlgFactory Instance.
00052 
00053   AlgFactory &af = AlgFactory::GetInstance();
00054 
00055   //-- Register Algorithm configuration
00056   
00057   af.Register(
00058           "AltAlgStpPatternRec",     "default", "libAltReco.so", "AlgConfig");
00059   af.Register(
00060           "AltAlgStpPatternRecList", "default", "libAltReco.so", "AlgConfig");
00061 }
00062 //____________________________________________________________________________
00063 AltModuleStpPatternRec::~AltModuleStpPatternRec()
00064 {
00065   MSG("Alt", Msg::kVerbose) << "AltModuleStpPatternRec::Destructor\n";
00066 }
00067 //____________________________________________________________________________
00068 void AltModuleStpPatternRec::BeginJob()
00069 {
00070   MSG("Alt", Msg::kVerbose) << "AltModuleStpPatternRec::BeginJob\n";
00071 }
00072 //____________________________________________________________________________
00073 const Registry & AltModuleStpPatternRec::DefaultConfig() const
00074 {
00075   MSG("Alt", Msg::kDebug) << "AltModuleStpPatternRec::DefaultConfig" << endl;
00076 
00077   static Registry r;
00078 
00079   std::string name = this->JobCModule::GetName();
00080   name += ".config.default";
00081   r.SetName(name.c_str());
00082   r.UnLockValues();
00083   r.LockValues();
00084 
00085   //-- Get AlgFactory Instance.
00086   AlgFactory &af = AlgFactory::GetInstance();
00087 
00088   //-- Get Algorithm handle and retrieve its config
00089   AlgHandle alglisthandle = af.GetAlgHandle("AltAlgStpPatternRecList","default");
00090   AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00091 
00092   //-- Set default configuration parameters
00093   alglistconfig.Set("int_foo",   0);
00094   alglistconfig.Set("dbl_bar",   0.0);
00095 
00096   //alglistconfig.Print();
00097 
00098   return r;
00099 }
00100 //____________________________________________________________________________
00101 void AltModuleStpPatternRec::Config(const Registry &r)
00102 {
00103   MSG("Alt", Msg::kDebug) << "AltModuleStpPatternRec::Config" << endl;
00104 
00105   //-- Get AlgFactory Instance.
00106   AlgFactory &af = AlgFactory::GetInstance();
00107 
00108   //-- Get Algorithm handle and retrieve its config.
00109   AlgHandle alglisthandle = af.GetAlgHandle("AltAlgSliceList","default");
00110   AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00111 
00112   //-- Set configuration parameters
00113 
00114   int          tmpi = 0;
00115   const char * tmpc = 0;
00116   double       tmpd = 0;
00117 
00118   if (r.Get("ListIn",tmpc))     fListIn  = tmpc;
00119   if (r.Get("ListOut",tmpc))    fListOut = tmpc;
00120 
00121   alglistconfig.UnLockValues();
00122 
00123   if (r.Get("int_foo",tmpi)) alglistconfig.Set("int_foo", tmpi);
00124   if (r.Get("dbl_bar",tmpi)) alglistconfig.Set("dbl_bar", tmpd);
00125 
00126   alglistconfig.LockValues();
00127 }
00128 //____________________________________________________________________________
00129 JobCResult AltModuleStpPatternRec::Reco(MomNavigator *mom)
00130 {
00131   MSG("Alt", Msg::kVerbose) << "AltModuleStpPatternRec::Reco\n";
00132 
00133   JobCResult result(JobCResult::kPassed);
00134 
00135   //-- Find PrimaryCandidateRecord fragment in MOM & check it is not null.
00136 
00137   CandRecord *cdrec = dynamic_cast<CandRecord *>
00138                     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00139   if (cdrec == 0) {
00140      MSG("Alt", Msg::kWarning)<< "NULL PrimaryCandidateRecord pointer" << endl;
00141      result.SetWarning().SetFailed();
00142      return result;
00143   }
00144 
00145   //-- Get a handle to CandSliceList (previous step reconstruction objects).
00146 
00147   MSG("Alt", Msg::kDebug)
00148     << "Asking PrimaryCandidateRecord for fListIn: " << fListIn.Data() << endl;
00149 
00150   CandSliceListHandle *cslh = dynamic_cast<CandSliceListHandle *>
00151                                        (cdrec->FindCandHandle(fListIn.Data()));
00152 
00153   //-- Require number of CandSlices to be non-zero.
00154 
00155   if (!cslh) {
00156      MSG("Alt", Msg::kDebug) << "NULL CandSliceListHandle pointer" << endl;
00157      result.SetFailed();
00158      return result;
00159 
00160   } else {
00161       if(cslh->GetNDaughters() < 1) {
00162           MSG("Alt", Msg::kDebug) << "Empty CandSlice list." << endl;
00163           result.SetFailed();
00164           return result;
00165       }
00166   }
00167 
00168   //-- Get AlgFactory instance.
00169 
00170   AlgFactory &af = AlgFactory::GetInstance();
00171 
00172   //-- Build a CandSliceSRList.
00173 
00174   AlgHandle adlh = af.GetAlgHandle("AltAlgStpPatternRecList", "default");
00175 
00176   //-- Create a candidate context, set data_in and candidate record
00177   CandContext cx(this, mom);
00178   cx.SetDataIn(cslh);
00179   cx.SetCandRecord(cdrec);
00180 
00181   //-- Initiate Reco : AltCandStpProbList:MakeCandidate
00182   
00183   MSG("Alt", Msg::kDebug)
00184               << "probh = AltCandStpProbList:MakeCandidate(adlh, cx)" << endl;
00185   AltCandStpProbListHandle pbh  = AltCandStpProbList::MakeCandidate(adlh, cx);
00186 
00187   MSG("Alt", Msg::kDebug)
00188                      << "AltCandStpProbListHandle:: set name & title" << endl;
00189   pbh.SetName(fListOut.Data());
00190   pbh.SetTitle(
00191       TString("Brought to life by AltModuleStpPatternRec from candslicelist").
00192       Append(cslh->GetName())
00193   );
00194 
00195   //-- Secure the CandHandle in the CandRecord
00196   MSG("Alt", Msg::kDebug) << "candrec->SecureCandHandle(pbh);" << endl;
00197   cdrec->SecureCandHandle(pbh);
00198 
00199   return result;
00200 }
00201 //____________________________________________________________________________
00202 void AltModuleStpPatternRec::HandleCommand(JobCommand *command)
00203 {
00204   // Process configuration commands
00205   MSG("Alt", Msg::kDebug)
00206                          << "AltModuleStpPatternRec::HandleCommand" << endl;
00207 
00208   TString cmd = command->PopCmd();
00209   if (cmd == "Set") {
00210     TString opt = command->PopOpt();
00211     if      (opt == "ListIn" ) fListIn  = command->PopOpt();
00212     else if (opt == "ListOut") fListOut = command->PopOpt();
00213     else {
00214       MSG("Alt", Msg::kWarning)
00215              << "AltModuleStpPatternRec::HandleCommand: Unrecognized option "
00216                                                                << opt << endl;
00217     }
00218   } else {
00219       MSG("Alt", Msg::kWarning)
00220             << "AltModuleStpPatternRec::HandleCommand: Unrecognized command "
00221                                                                << cmd << endl;
00222   }
00223 }
00224 //____________________________________________________________________________
00225 

Generated on Mon Feb 15 11:06:21 2010 for loon by  doxygen 1.3.9.1