00001
00002
00003
00004
00005
00006
00007
00009
00010 #include <cassert>
00011
00012 #include "Algorithm/AlgConfig.h"
00013 #include "Algorithm/AlgFactory.h"
00014 #include "Algorithm/AlgHandle.h"
00015 #include "CandData/CandHeader.h"
00016 #include "CandData/CandRecord.h"
00017 #include "CandSubShowerSR/CandSubShowerSRListHandle.h"
00018 #include "CandSubShowerSR/CandSubShowerSRList.h"
00019 #include "CandSubShowerSR/CandSubShowerSRHandle.h"
00020 #include "CandSubShowerSR/SubShowerSRListModule.h"
00021 #include "Candidate/CandContext.h"
00022 #include "Conventions/Munits.h"
00023 #include "JobControl/JobCModuleRegistry.h"
00024 #include "JobControl/JobCommand.h"
00025 #include "MessageService/MsgService.h"
00026 #include "MinosObjectMap/MomNavigator.h"
00027 #include "RecoBase/CandSliceListHandle.h"
00028 #include "RecoBase/CandTrackListHandle.h"
00029 #include "RecoBase/CandClusterListHandle.h"
00030 #include "RecoBase/CandStripListHandle.h"
00031 #include "Validity/VldContext.h"
00032
00033 ClassImp(SubShowerSRListModule)
00034
00035
00036 CVSID("$Id: SubShowerSRListModule.cxx,v 1.3 2006/04/13 12:16:15 cbs Exp $");
00037 JOBMODULE(SubShowerSRListModule, "SubShowerSRListModule",
00038 "Builds CandSubShowerSRList from CandSliceList and CandClusterList");
00039
00040
00041 SubShowerSRListModule::SubShowerSRListModule()
00042 {
00043 }
00044
00045
00046 SubShowerSRListModule::~SubShowerSRListModule()
00047 {
00048 }
00049
00050
00051 void SubShowerSRListModule::BeginJob()
00052 {
00053 }
00054
00055 const Registry &SubShowerSRListModule::DefaultConfig() const
00056 {
00057
00058 static Registry def_cfg;
00059 static bool been_here = false;
00060 if(been_here)return def_cfg;
00061 been_here=true;
00062 string name = this->JobCModule::GetName();
00063 name += ".config.default";
00064 def_cfg.SetName(name.c_str());
00065
00066
00067 def_cfg.Set("SubShowerSRListAlgorithm","AlgSubShowerSRList");
00068 def_cfg.Set("SubShowerSRListAlgConfig","default");
00069 def_cfg.Set("ListIn","CandSliceList");
00070 def_cfg.Set("TrackListIn","CandTrackSRList");
00071 def_cfg.Set("ClusterListIn","CandClusterList");
00072 def_cfg.Set("ListOut","CandSubShowerSRList");
00073 def_cfg.Set("LogLevel","Fatal");
00074 return def_cfg;
00075 }
00076
00077
00078
00079 JobCResult SubShowerSRListModule::Reco(MomNavigator *mom)
00080 {
00081 JobCResult result(JobCResult::kPassed);
00082
00083
00084 const char* tmps = 0;
00085 const char* alg_name = 0;
00086 const char* alg_config_name = 0;
00087 const char* list_in = 0;
00088 const char* track_list = 0;
00089 const char* cluster_list = 0;
00090 const char* list_out = 0;
00091
00092 Registry& cfg = this->GetConfig();
00093 if (cfg.Get("SubShowerSRListAlgorithm",tmps)) alg_name = tmps;
00094 if (cfg.Get("SubShowerSRListAlgConfig",tmps)) alg_config_name = tmps;
00095 if (cfg.Get("ListIn",tmps)) list_in = tmps;
00096 if (cfg.Get("TrackListIn",tmps)) track_list = tmps;
00097 if (cfg.Get("ClusterListIn",tmps)) cluster_list = tmps;
00098 if (cfg.Get("ListOut",tmps)) list_out = tmps;
00099
00100
00101 CandRecord *candrec = dynamic_cast<CandRecord *>
00102 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00103 if (candrec == 0) {
00104 MSG("SubShowerSR", Msg::kWarning) << "No PrimaryCandidateRecord in MOM." << endl;
00105 result.SetWarning().SetFailed();
00106 return result;
00107 }
00108
00109
00110
00111 CandSliceListHandle *cslh = dynamic_cast<CandSliceListHandle *>
00112 (candrec->FindCandHandle("CandSliceListHandle",list_in));
00113
00114
00115 if (!cslh || cslh->GetNDaughters() < 1) {
00116 MSG("SubShowerSR", Msg::kWarning)
00117 << "Null CandSlice list. Bail out of event." << endl;
00118 result.SetFailed();
00119 return result;
00120 }
00121
00122 CandClusterListHandle *cclh = dynamic_cast<CandClusterListHandle *>
00123 (candrec->FindCandHandle("CandClusterListHandle",cluster_list));
00124 if(!cclh) {
00125 MSG("SubShowerSR", Msg::kWarning)
00126 << "Null CandCluster list. Bail out of event." << endl;
00127 return result;
00128 }
00129
00130 CandTrackListHandle *ctlh = dynamic_cast<CandTrackListHandle *>
00131 (candrec->FindCandHandle("CandTrackListHandle",track_list));
00132 if(!ctlh) {
00133 MSG("SubShowerSR", Msg::kWarning)
00134 << "Null CandTrack list." << endl;
00135
00136 }
00137 TObjArray cxin;
00138 cxin.Add(cslh);
00139 cxin.Add(cclh);
00140 cxin.Add(ctlh);
00141
00142 AlgFactory &af = AlgFactory::GetInstance();
00143
00144
00145 AlgHandle adlh = af.GetAlgHandle(alg_name,alg_config_name);
00146 CandContext cx(this, mom);
00147 cx.SetDataIn(&cxin);
00148 cx.SetCandRecord(candrec);
00149
00150 MSG("SubShowerSR",Msg::kVerbose) << "Making SubShowerSRList" << endl;
00151 CandSubShowerSRListHandle csslh = CandSubShowerSRList::MakeCandidate(adlh, cx);
00152 csslh.SetName(list_out);
00153 csslh.SetTitle(TString("Created by SubShowerSRListModule from ").
00154 Append(cslh->GetName()));
00155 candrec->SecureCandHandle(csslh);
00156
00157 return result;
00158 }
00159