00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include <cassert>
00012
00013 #include "Algorithm/AlgConfig.h"
00014 #include "Algorithm/AlgFactory.h"
00015 #include "Algorithm/AlgHandle.h"
00016 #include "Calibrator/Calibrator.h"
00017 #include "CandData/CandHeader.h"
00018 #include "CandData/CandRecord.h"
00019 #include "CandDigit/CandDigitListHandle.h"
00020 #include "CandShowerEM/CandShowerEMListHandle.h"
00021 #include "CandShowerEM/CandShowerEMList.h"
00022 #include "CandShowerEM/CandShowerEMHandle.h"
00023 #include "CandShowerEM/ShowerEMListModule.h"
00024 #include "Candidate/CandContext.h"
00025 #include "Conventions/Munits.h"
00026 #include "JobControl/JobCModuleRegistry.h"
00027 #include "JobControl/JobCommand.h"
00028 #include "MessageService/MsgService.h"
00029 #include "MinosObjectMap/MomNavigator.h"
00030 #include "RawData/RawDigit.h"
00031 #include "RawData/RawHeader.h"
00032 #include "RawData/RawRecord.h"
00033 #include "RawData/RawChannelId.h"
00034 #include "RawData/RawDaqSnarlHeader.h"
00035 #include "RawData/RawDaqHeaderBlock.h"
00036 #include "RawData/RawDigitDataBlock.h"
00037 #include "RawData/RawVarcErrorInTfBlock.h"
00038 #include "RecoBase/CandStripHandle.h"
00039 #include "RecoBase/CandStripListHandle.h"
00040 #include "RecoBase/CandClusterListHandle.h"
00041 #include "RecoBase/CandSliceListHandle.h"
00042 #include "RecoBase/CandShowerListHandle.h"
00043 #include "RecoBase/CandShowerHandle.h"
00044 #include "Validity/VldContext.h"
00045
00046 ClassImp(ShowerEMListModule)
00047
00048
00049 CVSID("$Id: ShowerEMListModule.cxx,v 1.5 2010/01/06 18:47:35 rhatcher Exp $");
00050 JOBMODULE(ShowerEMListModule, "ShowerEMListModule",
00051 "Builds CandShowerEMList from CandSliceList");
00052
00053
00054 ShowerEMListModule::ShowerEMListModule()
00055 {
00056
00057 }
00058
00059
00060 ShowerEMListModule::~ShowerEMListModule()
00061 {
00062
00063 }
00064
00065
00066 void ShowerEMListModule::BeginJob()
00067 {
00068
00069 }
00070
00071 const Registry &ShowerEMListModule::DefaultConfig() const
00072 {
00073
00074 static Registry def_cfg;
00075 static bool been_here = false;
00076 if(been_here) return def_cfg;
00077 been_here=true;
00078
00079 std::string name = this->JobCModule::GetName();
00080 name += ".config.default";
00081 def_cfg.SetName(name.c_str());
00082
00083 def_cfg.Set("ShowerEMListAlgorithm","AlgShowerEMList");
00084 def_cfg.Set("ShowerEMListAlgConfig","default");
00085 def_cfg.Set("ListIn","CandSliceList");
00086 def_cfg.Set("ClusterListIn","CandClusterList");
00087 def_cfg.Set("ListOut","CandShowerEMList");
00088 def_cfg.Set("LogLevel","Fatal");
00089 return def_cfg;
00090
00091 }
00092
00093
00094 JobCResult ShowerEMListModule::Reco(MomNavigator *mom)
00095 {
00096 JobCResult result(JobCResult::kPassed);
00097
00098 MSG("ShowerEM", Msg::kVerbose) << "ShowerEMListModule::Reco\n";
00099
00100
00101 const char* tmps = 0;
00102 const char* alg_name = 0;
00103 const char* alg_config_name = 0;
00104 const char* list_in = 0;
00105 const char* cluster_list=0;
00106 const char* list_out = 0;
00107
00108 Registry& cfg = this->GetConfig();
00109 if (cfg.Get("ShowerEMListAlgorithm",tmps)) alg_name = tmps;
00110 if (cfg.Get("ShowerEMListAlgConfig",tmps)) alg_config_name = tmps;
00111 if (cfg.Get("ListIn",tmps)) list_in = tmps;
00112 if (cfg.Get("ClusterListIn",tmps)) cluster_list = tmps;
00113 if (cfg.Get("ListOut",tmps)) list_out = tmps;
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 CandRecord *candrec = dynamic_cast<CandRecord *>
00129 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00130 if (candrec == 0) {
00131 MSG("ShowerEM", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00132 << endl;
00133 result.SetWarning().SetFailed();
00134 return result;
00135 }
00136
00137
00138 Calibrator::Instance().Reset(*candrec->GetVldContext());
00139
00140
00141 CandSliceListHandle *cslh = dynamic_cast<CandSliceListHandle *>
00142 (candrec->FindCandHandle("CandSliceListHandle"));
00143 if(!cslh){
00144 MSG("ShowerEM", Msg::kDebug)
00145 << "Null CandSlice list. Bail out of event." << endl;
00146 result.SetFailed();
00147 return result;
00148 }
00149
00150
00151 CandClusterListHandle *cclh = dynamic_cast<CandClusterListHandle *>
00152 (candrec->FindCandHandle("CandClusterListHandle"));
00153 if(!cclh){
00154 MSG("ShowerEM", Msg::kDebug)
00155 << "Null CandCluster list. Bail out of event." << endl;
00156 return result;
00157 }
00158
00159 TObjArray cxin;
00160 cxin.Add(cslh);
00161 cxin.Add(cclh);
00162
00163 AlgFactory &af = AlgFactory::GetInstance();
00164 AlgHandle adlh = af.GetAlgHandle(alg_name,alg_config_name);
00165 CandContext cx(this, mom);
00166 cx.SetDataIn(&cxin);
00167 cx.SetCandRecord(candrec);
00168 CandShowerEMListHandle csllh = CandShowerEMList::MakeCandidate(adlh, cx);
00169 csllh.SetName(list_out);
00170 csllh.SetTitle(TString("Created by ShowerEMListModule from ").
00171 Append(cslh->GetName()));
00172 candrec->SecureCandHandle(csllh);
00173
00174 return result;
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224