00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
00052
00053 AlgFactory &af = AlgFactory::GetInstance();
00054
00055
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
00086 AlgFactory &af = AlgFactory::GetInstance();
00087
00088
00089 AlgHandle alglisthandle = af.GetAlgHandle("AltAlgStpPatternRecList","default");
00090 AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00091
00092
00093 alglistconfig.Set("int_foo", 0);
00094 alglistconfig.Set("dbl_bar", 0.0);
00095
00096
00097
00098 return r;
00099 }
00100
00101 void AltModuleStpPatternRec::Config(const Registry &r)
00102 {
00103 MSG("Alt", Msg::kDebug) << "AltModuleStpPatternRec::Config" << endl;
00104
00105
00106 AlgFactory &af = AlgFactory::GetInstance();
00107
00108
00109 AlgHandle alglisthandle = af.GetAlgHandle("AltAlgSliceList","default");
00110 AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00111
00112
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
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
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
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
00169
00170 AlgFactory &af = AlgFactory::GetInstance();
00171
00172
00173
00174 AlgHandle adlh = af.GetAlgHandle("AltAlgStpPatternRecList", "default");
00175
00176
00177 CandContext cx(this, mom);
00178 cx.SetDataIn(cslh);
00179 cx.SetCandRecord(cdrec);
00180
00181
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
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
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