00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #include <cassert>
00014
00015 #include "AltModuleSliceList.h"
00016
00017 #include "RecoBase/CandSliceListHandle.h"
00018 #include "RecoBase/CandSliceList.h"
00019 #include "RecoBase/CandSliceHandle.h"
00020
00021 #include "Algorithm/AlgConfig.h"
00022 #include "Algorithm/AlgFactory.h"
00023 #include "Algorithm/AlgHandle.h"
00024 #include "CandData/CandHeader.h"
00025 #include "CandData/CandRecord.h"
00026 #include "Candidate/CandContext.h"
00027 #include "Conventions/Munits.h"
00028 #include "JobControl/JobCModuleRegistry.h"
00029 #include "JobControl/JobCommand.h"
00030 #include "MessageService/MsgService.h"
00031 #include "MinosObjectMap/MomNavigator.h"
00032 #include "RecoBase/CandStripListHandle.h"
00033 #include "Validity/VldContext.h"
00034
00035 ClassImp(AltModuleSliceList)
00036
00037
00038 CVSID("$Id: AltModuleSliceList.cxx,v 1.16 2004/07/26 12:22:52 west Exp $");
00039
00040 JOBMODULE(AltModuleSliceList, "AltModuleSliceList", "CandSliceList Reco.");
00041
00042 AltModuleSliceList::AltModuleSliceList() :
00043 fListIn("CandStripListHandle"),
00044 fListOut("CandSliceList")
00045 {
00046 MSG("Alt", Msg::kVerbose) << "AltModuleSliceList::Constructor\n";
00047
00048
00049
00050 AlgFactory &af = AlgFactory::GetInstance();
00051
00052
00053
00054 af.Register("AltAlgSlice", "default", "libAltReco.so", "AlgConfig");
00055 af.Register("AltAlgSliceList", "default", "libAltReco.so", "AlgConfig");
00056 }
00057
00058
00059 AltModuleSliceList::~AltModuleSliceList()
00060 {
00061 MSG("Alt", Msg::kVerbose) << "AltModuleSliceList::Destructor\n";
00062 }
00063
00064 void AltModuleSliceList::BeginJob()
00065 {
00066 MSG("Alt", Msg::kVerbose) << "AltModuleSliceList::BeginJob\n";
00067 }
00068
00069 const Registry & AltModuleSliceList::DefaultConfig() const
00070 {
00071 MSG("Alt", Msg::kDebug) << "AltModuleSliceList::DefaultConfig" << endl;
00072
00073 static Registry r;
00074
00075 std::string name = this->JobCModule::GetName();
00076 name += ".config.default";
00077 r.SetName(name.c_str());
00078 r.UnLockValues();
00079 r.LockValues();
00080
00081
00082 AlgFactory &af = AlgFactory::GetInstance();
00083
00084
00085 AlgHandle alglisthandle = af.GetAlgHandle("AltAlgSliceList","default");
00086 AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00087
00088
00089 alglistconfig.Set("Grfx_DebugGraphics", 0);
00090 alglistconfig.Set("Grfx_TimeProfileLogView", 1);
00091 alglistconfig.Set("Pkf_PeakThreshold", 40);
00092 alglistconfig.Set("Pkf_NSuccessiveEmptyBins", 1);
00093 alglistconfig.Set("Pkf_MuSpecPeakThreshold", 20);
00094 alglistconfig.Set("Pkf_MuSpecNSuccessiveEmptyBins", 2);
00095 alglistconfig.Set("Pkf_LowPeakThreshold", 30);
00096 alglistconfig.Set("Pkf_LowNSuccessiveEmptyBins", 2);
00097 alglistconfig.Set("Pkf_NofMergedTimeBins", 1);
00098 alglistconfig.Set("Pkf_WeightProfileWithCharge", 1);
00099 alglistconfig.Set("Pkf_RecursivePeakSearch", 0);
00100 alglistconfig.Set("Pkf_TimeWindowBefPeak", 2);
00101 alglistconfig.Set("Pkf_TimeWindowAftPeak", 3);
00102 alglistconfig.Set("Refinement_Dissolving", 1);
00103 alglistconfig.Set("Refinement_Merging", 0);
00104 alglistconfig.Set("Refinement_KMeansClustering", 1);
00105 alglistconfig.Set("Refinement_MSTClustering", 0);
00106 alglistconfig.Set("OrphanStrips_TimeWindow", 60*Munits::ns);
00107 alglistconfig.Set("OrphanStrips_PlaneWindow", 10);
00108 alglistconfig.Set("OrphanStrips_QWeight", 1);
00109 alglistconfig.Set("KMeans_TimeWindow", 40.*Munits::ns);
00110 alglistconfig.Set("KMeans_PlaneWindow", 3);
00111 alglistconfig.Set("KMeans_TPosWindow", 30.*Munits::cm);
00112 alglistconfig.Set("MuSpec_TimeAftUpstrActivity", 80.*Munits::ns);
00113 alglistconfig.Set("MuSpec_TimeBefUpstrActivity", 40.*Munits::ns);
00114 alglistconfig.Set("MuSpec_NUpstrPlanes", 30);
00115 alglistconfig.Set("MuSpec_HitStripsBefSpectr", 1);
00116 alglistconfig.Set("MuSpec_NPlnBefSpectr", 15);
00117 alglistconfig.Set("MuSpec_SuppressUnmatchedSlices", 1);
00118 alglistconfig.Set("MinHitStripsInSlice", 4);
00119 alglistconfig.Set("MinChargeInSlice", 5.);
00120 alglistconfig.Set("TimeResolution", 19.*Munits::ns);
00121 alglistconfig.Set("TimeDiffBetweenPeaks", 70.*Munits::ns);
00122 alglistconfig.Set("ZDiffBetweenPeaks", 200.*Munits::cm);
00123 alglistconfig.Set("ZDiffBetweenEnds", 40.*Munits::cm);
00124 alglistconfig.Set("UVDiffBetweenPeaks", 40.*Munits::cm);
00125
00126
00127
00128 return r;
00129 }
00130
00131 void AltModuleSliceList::Config(const Registry &r)
00132 {
00133 MSG("Alt", Msg::kDebug) << "AltModuleSliceList::Config" << endl;
00134
00135
00136 AlgFactory &af = AlgFactory::GetInstance();
00137
00138
00139 AlgHandle alglisthandle = af.GetAlgHandle("AltAlgSliceList","default");
00140 AlgConfig &alglistconfig = alglisthandle.GetAlgConfig();
00141
00142
00143
00144 int tmpi = 0;
00145 const char * tmpc = 0;
00146 double tmpd = 0;
00147
00148 if (r.Get("ListIn",tmpc)) fListIn = tmpc;
00149 if (r.Get("ListOut",tmpc)) fListOut = tmpc;
00150
00151 alglistconfig.UnLockValues();
00152
00153 if (r.Get("Grfx_DebugGraphics",tmpi))
00154 alglistconfig.Set("Grfx_DebugGraphics", tmpi);
00155 if (r.Get("Grfx_TimeProfileLogView",tmpi))
00156 alglistconfig.Set("Grfx_TimeProfileLogView", tmpi);
00157 if (r.Get("Pkf_PeakThreshold",tmpi))
00158 alglistconfig.Set("Pkf_PeakThreshold", tmpi);
00159 if (r.Get("Pkf_NSuccessiveEmptyBins",tmpi))
00160 alglistconfig.Set("Pkf_NSuccessiveEmptyBins", tmpi);
00161 if (r.Get("Pkf_MuSpecPeakThreshold",tmpi))
00162 alglistconfig.Set("Pkf_MuSpecPeakThreshold", tmpi);
00163 if (r.Get("Pkf_MuSpecNSuccessiveEmptyBins",tmpi))
00164 alglistconfig.Set("Pkf_MuSpecNSuccessiveEmptyBins", tmpi);
00165 if (r.Get("Pkf_LowPeakThreshold",tmpi))
00166 alglistconfig.Set("Pkf_LowPeakThreshold", tmpi);
00167 if (r.Get("Pkf_LowNSuccessiveEmptyBins",tmpi))
00168 alglistconfig.Set("Pkf_LowNSuccessiveEmptyBins", tmpi);
00169 if (r.Get("Pkf_NofMergedTimeBins",tmpi))
00170 alglistconfig.Set("NumberOfMergedTimeBins", tmpi);
00171 if (r.Get("Pkf_WeightProfileWithCharge",tmpi))
00172 alglistconfig.Set("Pkf_WeightProfileWithCharge", tmpi);
00173 if (r.Get("Pkf_RecursivePeakSearch",tmpi))
00174 alglistconfig.Set("Pkf_RecursivePeakSearch", tmpi);
00175 if (r.Get("Pkf_TimeWindowBefPeak",tmpi))
00176 alglistconfig.Set("Pkf_TimeWindowBefPeak", tmpi);
00177 if (r.Get("Pkf_TimeWindowAftPeak",tmpi))
00178 alglistconfig.Set("Pkf_TimeWindowAftPeak", tmpi);
00179 if (r.Get("Refinement_Dissolving",tmpi))
00180 alglistconfig.Set("Refinement_Dissolving", tmpi);
00181 if (r.Get("Refinement_Merging",tmpi))
00182 alglistconfig.Set("Refinement_Merging", tmpi);
00183 if (r.Get("Refinement_KMeansClustering",tmpi))
00184 alglistconfig.Set("Refinement_KMeansClustering", tmpi);
00185 if (r.Get("Refinement_MSTClustering",tmpi))
00186 alglistconfig.Set("Refinement_MSTClustering", tmpi);
00187 if (r.Get("OrphanStrips_QWeight",tmpi))
00188 alglistconfig.Set("OrphanStrips_QWeight", tmpi);
00189 if (r.Get("OrphanStrips_PlaneWindow",tmpi))
00190 alglistconfig.Set("OrphanStrips_PlaneWindow", tmpi);
00191 if (r.Get("OrphanStrips_TimeWindow",tmpd))
00192 alglistconfig.Set("OrphanStrips_TimeWindow", tmpd);
00193 if (r.Get("KMeans_TimeWindow",tmpd))
00194 alglistconfig.Set("KMeans_TimeWindow", tmpd);
00195 if (r.Get("KMeans_PlaneWindow",tmpi))
00196 alglistconfig.Set("KMeans_PlaneWindow", tmpi);
00197 if (r.Get("KMeans_TPosWindow",tmpd))
00198 alglistconfig.Set("KMeans_TPosWindow", tmpd);
00199 if (r.Get("MuSpec_TimeAftUpstrActivity",tmpd))
00200 alglistconfig.Set("MuSpec_TimeAftUpstrActivity", tmpd);
00201 if (r.Get("MuSpec_TimeBefUpstrActivity",tmpd))
00202 alglistconfig.Set("MuSpec_TimeBefUpstrActivity", tmpd);
00203 if (r.Get("MuSpec_NUpstrPlanes",tmpi))
00204 alglistconfig.Set("MuSpec_NUpstrPlanes", tmpi);
00205 if (r.Get("MuSpec_HitStripsBefSpectr",tmpi))
00206 alglistconfig.Set("MuSpec_HitStripsBefSpectr", tmpi);
00207 if (r.Get("MuSpec_NPlnBefSpectr",tmpi))
00208 alglistconfig.Set("MuSpec_NPlnBefSpectr", tmpi);
00209 if (r.Get("MuSpec_SuppressUnmatchedSlices",tmpi))
00210 alglistconfig.Set("MuSpec_SuppressUnmatchedSlices", tmpi);
00211 if (r.Get("TimeResolution",tmpd))
00212 alglistconfig.Set("TimeResolution", tmpd);
00213 if (r.Get("MinHitStripsInSlice",tmpi))
00214 alglistconfig.Set("MinHitStripsInSlice", tmpi);
00215 if (r.Get("TimeDiffBetweenPeaks",tmpd))
00216 alglistconfig.Set("TimeDiffBetweenPeaks", tmpd);
00217 if (r.Get("ZDiffBetweenPeaks",tmpd))
00218 alglistconfig.Set("ZDiffBetweenPeaks", tmpd);
00219 if (r.Get("ZDiffBetweenEnds",tmpd))
00220 alglistconfig.Set("ZDiffBetweenEnds", tmpd);
00221 if (r.Get("UVDiffBetweenPeaks",tmpd))
00222 alglistconfig.Set("UVDiffBetweenPeaks", tmpd);
00223 if (r.Get("MinChargeInSlice",tmpd))
00224 alglistconfig.Set("MinChargeInSlice", tmpd);
00225
00226 alglistconfig.LockValues();
00227 }
00228
00229 JobCResult AltModuleSliceList::Reco(MomNavigator *mom)
00230 {
00231 MSG("Alt", Msg::kVerbose) << "AltModuleSliceList::Reco\n";
00232
00233 JobCResult result(JobCResult::kPassed);
00234
00235
00236
00237 CandRecord *cdrec = dynamic_cast<CandRecord *>
00238 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00239 if (cdrec == 0) {
00240 MSG("Alt", Msg::kWarning)
00241 << "NULL PrimaryCandidateRecord pointer" << endl;
00242 result.SetWarning().SetFailed();
00243 return result;
00244 }
00245
00246
00247
00248 MSG("Alt", Msg::kDebug) << "Asking PrimaryCandidateRecord for fListIn: "
00249 << fListIn.Data() << endl;
00250
00251 CandStripListHandle *cslh = dynamic_cast<CandStripListHandle *>
00252 (cdrec->FindCandHandle(fListIn.Data()));
00253
00254
00255
00256 if (!cslh) {
00257 MSG("Alt", Msg::kDebug) << "NULL CandStripListHandle pointer" << endl;
00258 result.SetFailed();
00259 return result;
00260
00261 } else {
00262 if(cslh->GetNDaughters() < 1) {
00263 MSG("Alt", Msg::kDebug) << "Empty CandStrip list." << endl;
00264 result.SetFailed();
00265 return result;
00266 }
00267 }
00268
00269
00270
00271 AlgFactory &af = AlgFactory::GetInstance();
00272
00273
00274
00275 AlgHandle adlh = af.GetAlgHandle("AltAlgSliceList", "default");
00276
00277 MSG("Alt", Msg::kDebug) << "CandContext cx(this, mom);" << endl;
00278 CandContext cx(this, mom);
00279
00280 MSG("Alt", Msg::kDebug) << "cx.SetDataIn(cslh);" << endl;
00281 cx.SetDataIn(cslh);
00282
00283 MSG("Alt", Msg::kDebug) << "cx.SetCandRecord(cdrec);" << endl;
00284 cx.SetCandRecord(cdrec);
00285
00286
00287 MSG("Alt", Msg::kDebug)
00288 << "csllh = CandSliceList::MakeCandidate(adlh, cx);" << endl;
00289 CandSliceListHandle csllh = CandSliceList::MakeCandidate(adlh, cx);
00290 MSG("Alt", Msg::kDebug)
00291 << "CandSliceListHandle::SetName() & SetTitle()" << endl;
00292 csllh.SetName(fListOut.Data());
00293 csllh.SetTitle(
00294 TString("Brought to life by AltModuleSliceList from candstriplist").
00295 Append(cslh->GetName())
00296 );
00297
00298
00299 MSG("Alt", Msg::kDebug) << "candrec->SecureCandHandle(csllh);" << endl;
00300 cdrec->SecureCandHandle(csllh);
00301
00302 return result;
00303 }
00304
00305 void AltModuleSliceList::HandleCommand(JobCommand *command)
00306 {
00307
00308 MSG("Alt", Msg::kDebug)
00309 << "AltModuleSliceList::HandleCommand" << endl;
00310
00311 TString cmd = command->PopCmd();
00312 if (cmd == "Set") {
00313 TString opt = command->PopOpt();
00314 if (opt == "ListIn" ) fListIn = command->PopOpt();
00315 else if (opt == "ListOut") fListOut = command->PopOpt();
00316 else {
00317 MSG("Alt", Msg::kWarning)
00318 << "AltModuleSliceList::HandleCommand: Unrecognized option "
00319 << opt << endl;
00320 }
00321 } else {
00322 MSG("Alt", Msg::kWarning)
00323 << "AltModuleSliceList::HandleCommand: Unrecognized command "
00324 << cmd << endl;
00325 }
00326 }
00327
00328