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

FitTrackSRListModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: FitTrackSRListModule.cxx,v 1.32 2005/04/20 17:23:53 minoscvs Exp $
00003 //
00004 // FitTrackSRListModule.cxx
00005 //
00006 // Begin_Html<img src="../../pedestrians.gif" align=center>
00007 // <a href="../source_warning.html">Warning for beginners</a>.<br> 
00008 //
00009 // A JobControl Module for filling raw CandFitTrackSRList from CandTrackList.
00010 //
00011 // Author:  R. Lee 2001.03.30
00012 //
00013 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and 
00014 // <a href="../CandFitTrackSR.html"> CandFitTrackSR Classes</a> (part of
00015 // <a href="../index.html">The MINOS Class User Guide</a>)End_Html
00017 
00018 #include <cassert>
00019 extern "C" {
00020 #include <unistd.h>    // sysconf
00021 #include <sys/times.h> // times()
00022 }
00023 
00024 
00025 #include "CandFitTrackSR/FitTrackSRListModule.h"
00026 
00027 #include "Algorithm/AlgConfig.h"
00028 #include "Algorithm/AlgFactory.h"
00029 #include "Algorithm/AlgHandle.h"
00030 #include "CandData/CandHeader.h"
00031 #include "CandData/CandRecord.h"
00032 #include "CandFitTrackSR/CandFitTrackSRListHandle.h"
00033 #include "CandFitTrackSR/CandFitTrackSRList.h"
00034 #include "CandFitTrackSR/CandFitTrackSRHandle.h"
00035 #include "Candidate/CandContext.h"
00036 #include "Conventions/Munits.h"
00037 #include "JobControl/JobCModuleRegistry.h"
00038 #include "JobControl/JobCommand.h"
00039 #include "MessageService/MsgService.h"
00040 #include "MinosObjectMap/MomNavigator.h"
00041 #include "RawData/RawHeader.h"
00042 #include "RawData/RawRecord.h"
00043 #include "RecoBase/CandClusterListHandle.h"
00044 #include "RecoBase/CandSliceListHandle.h"
00045 #include "Validity/VldContext.h"
00046 
00047 ClassImp(FitTrackSRListModule)
00048 
00049 //......................................................................
00050 CVSID("$Id: FitTrackSRListModule.cxx,v 1.32 2005/04/20 17:23:53 minoscvs Exp $");
00051 JOBMODULE(FitTrackSRListModule, "FitTrackSRListModule",
00052          "Builds CandFitTrackSRList from CandTrackList");
00053 
00054 //......................................................................
00055 FitTrackSRListModule::FitTrackSRListModule()
00056 {
00057 }
00058 
00059 //......................................................................
00060 FitTrackSRListModule::~FitTrackSRListModule() 
00061 {
00062 }
00063 
00064 //......................................................................
00065 void FitTrackSRListModule::BeginJob() 
00066 {
00067 }
00068 
00069 //......................................................................
00070 
00071 const Registry &FitTrackSRListModule::DefaultConfig() const
00072 {
00073 //  
00074 //  Purpose:    Method to return default configuration.
00075 //  
00076 //  Arguments:  n/a
00077 //  
00078 //  Return:     Registry item containing default configuration.
00079 //
00080 
00081 
00082   static Registry def_cfg;
00083   static bool been_here = false;
00084   if(been_here)return def_cfg;
00085   been_here=true;
00086 
00087   string name = this->JobCModule::GetName();
00088   name += ".config.default";
00089   def_cfg.SetName(name.c_str());
00090 
00091   // Set default
00092   def_cfg.Set("FitTrackListAlgorithm","AlgFitTrackSRList");
00093   def_cfg.Set("FitTrackListAlgConfig","default");
00094   def_cfg.Set("ListIn","CandSliceList");
00095   def_cfg.Set("ListOut","CandFitTrackSRList");
00096   def_cfg.Set("LogLevel","Fatal");
00097   return def_cfg;
00098 }
00099 
00100 
00101 
00102 //......................................................................
00103 JobCResult FitTrackSRListModule::Reco(MomNavigator *mom)
00104 {
00105   
00106   JobCResult result(JobCResult::kPassed); // The default result
00107   // load configuration 
00108   const char* tmps = 0;
00109   const char* alg_name = 0;
00110   const char* alg_config_name = 0;
00111   const char* list_in = 0;
00112   const char* list_out = 0;
00113   
00114   Registry& cfg = this->GetConfig();
00115   if (cfg.Get("FitTrackListAlgorithm",tmps)) alg_name = tmps;
00116   if (cfg.Get("FitTrackListAlgConfig",tmps)) alg_config_name = tmps;
00117   if (cfg.Get("ListIn",tmps)) list_in = tmps;
00118   if (cfg.Get("ListOut",tmps)) list_out = tmps;
00119 
00120 
00121 // Find PrimaryCandidateRecord fragment in MOM.
00122    CandRecord *candrec = dynamic_cast<CandRecord *>
00123              (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00124    if (candrec == 0) {
00125      MSG("FitTrackSR", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00126                                       << endl;
00127      // Return failed with warning result
00128      result.SetWarning().SetFailed();
00129      return result;
00130    }
00131 
00132 // Require number of CandSlices to be non-zero.
00133    CandSliceListHandle *cslh = dynamic_cast<CandSliceListHandle *>
00134       (candrec->FindCandHandle("CandSliceListHandle",list_in));
00135    if (!cslh || cslh->GetNDaughters() < 1) {
00136      MSG("FitTrackSR", Msg::kDebug)
00137                   << "Null CandSlice list.  Bail out of event." << endl;
00138      result.SetFailed();
00139      return result;
00140    }
00141 
00142    CandTrackListHandle *ctlh = dynamic_cast<CandTrackListHandle *>
00143      (candrec->FindCandHandle("CandTrackListHandle"));
00144    // Require number of CandTracks to be non-zero.
00145    if (!ctlh || ctlh->GetNDaughters() < 1) {
00146      MSG("FitTrackSR", Msg::kDebug)
00147        << "Null CandTrack list.  Bail out of event." << endl;
00148      return result;
00149    }
00150 
00151    /*
00152    clock_t dummyt;
00153    struct tms t1;
00154    struct tms t2;
00155    static double ticksPerSecond = sysconf(_SC_CLK_TCK);
00156    dummyt = times(&t1);
00157    */
00158 
00159    TObjArray cxin;
00160    cxin.Add(cslh);
00161    cxin.Add(ctlh);
00162 
00163    AlgFactory &af = AlgFactory::GetInstance();
00164 
00165 // Build a CandFitTrackSRList containing all CandFitTrackSRs in Frame.
00166    AlgHandle adlh = af.GetAlgHandle(alg_name,alg_config_name);
00167    CandContext cx(this, mom);
00168    cx.SetDataIn(&cxin);
00169    cx.SetCandRecord(candrec);
00170    CandFitTrackSRListHandle ctllh = CandFitTrackSRList::MakeCandidate(adlh, cx);
00171 
00172    //      dummyt = times(&t2);
00173    //   cout << " fitter time " << (Double_t)(t2.tms_utime+t2.tms_stime-t1.tms_utime-t1.tms_stime)/ticksPerSecond << endl;
00174    ctllh.SetName(list_out);
00175    ctllh.SetTitle(TString("Created by FitTrackSRListModule from ").
00176                  Append(ctlh->GetName()));
00177    candrec->SecureCandHandle(ctllh);
00178 
00179    return result;
00180 }
00181 

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