00001
00002
00003
00004
00005
00006
00007
00009 #include <cassert>
00010
00011
00012 extern "C" {
00013 #include <unistd.h>
00014 #include <sys/times.h>
00015 }
00016
00017
00018 #include "MessageService/MsgService.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "JobControl/JobCModuleRegistry.h"
00021
00022
00023 #include "Algorithm/AlgFactory.h"
00024 #include "Algorithm/AlgHandle.h"
00025 #include "Algorithm/AlgConfig.h"
00026
00027
00028 #include "CandData/CandRecord.h"
00029 #include "Candidate/CandContext.h"
00030
00031 #include "RecoBase/CandSliceHandle.h"
00032 #include "RecoBase/CandSliceListHandle.h"
00033 #include "RecoBase/CandTrack.h"
00034 #include "RecoBase/CandTrackHandle.h"
00035 #include "RecoBase/CandTrackListHandle.h"
00036
00037 #include "RawData/RawRecord.h"
00038 #include "RawData/RawDaqSnarlHeader.h"
00039
00040
00041 #include "AtNuReco/AtmosShowerListModule.h"
00042 #include "AtNuReco/CandShowerAtNuListHandle.h"
00043 #include "AtNuReco/CandShowerAtNuList.h"
00044
00045 JOBMODULE(AtmosShowerListModule, "AtmosShowerListModule", "Shower finder");
00046 CVSID("$Id: AtmosShowerListModule.cxx,v 1.3 2006/04/25 17:17:32 chapman Exp $");
00047
00049 AtmosShowerListModule::AtmosShowerListModule()
00050 {
00051 fAlgName="AlgAtmosShowerList";
00052 fAlgConfig="default";
00053
00054 fListIn="CandSliceList";
00055 fTrackListIn="CandFitTrackCamList";
00056 }
00058
00059
00061 AtmosShowerListModule::~AtmosShowerListModule()
00062 {
00063 }
00065
00066
00068 void AtmosShowerListModule::BeginJob()
00069 {
00070
00071 AlgFactory &af = AlgFactory::GetInstance();
00072 af.Register("AlgAtmosShowerList", "default", "libAtNuReco.so", "AlgConfig");
00073 af.Register("AlgShowerCam", "default", "libAtNuReco.so", "AlgConfig");
00074
00075 MSG("AtmosShowerListModule", Msg::kInfo) << " Shower finder startup complete " << endl;
00076 }
00078
00079
00081 void AtmosShowerListModule::EndJob()
00082 {
00083 }
00085
00086
00088 JobCResult AtmosShowerListModule::Reco(MomNavigator* mom)
00089 {
00090 JobCResult result(JobCResult::kPassed);
00091
00092 const char* alg_name = 0;
00093 const char* alg_config_name = 0;
00094
00095
00096 CandRecord *candrec = dynamic_cast<CandRecord *> (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00097 if(!candrec)
00098 {
00099 MSG("AtmosShowerListModule", Msg::kWarning) << " Failed to Find CandRecord " << endl;
00100 return result.SetFailed();
00101 }
00102
00103
00104 RawRecord *rr = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00105 if(rr==0){
00106 MSG("AtmosShowerListModule", Msg::kWarning) << " Failed to Find RawRecord " << endl;
00107 return result.SetFailed();
00108 }
00109
00110
00111 else {
00112 const RawDaqSnarlHeader* hdr = dynamic_cast<const RawDaqSnarlHeader*>(rr->GetRawHeader());
00113 if(hdr){
00114 MSG("AtmosShowerListModule", Msg::kVerbose) << "AtmosShowerListModule:Reco Run:Snarl "<<hdr->GetRun()<<":"<< hdr->GetSnarl()<<endl;
00115 }
00116 }
00117
00118
00119 CandContext cx(this, mom);
00120 cx.SetCandRecord(candrec);
00121 TObjArray shwlistcxt;
00122
00123
00124 CandSliceListHandle* slice_list = dynamic_cast<CandSliceListHandle*>(candrec->FindCandHandle("CandSliceListHandle",fListIn.Data()));
00125 if( !slice_list || (slice_list && slice_list->GetNDaughters()<1) )
00126 {
00127
00128 MSG("AtmosShowerListModule", Msg::kWarning) << " Failed to Find " << fListIn.Data() << endl;
00129
00130 return JobCResult::kAOK;
00131 }
00132 else { shwlistcxt.Add(slice_list); MSG("AtmosShowerListModule", Msg::kDebug) << "Found " << fListIn.Data() << endl; }
00133
00134
00135 CandTrackListHandle* track_list = dynamic_cast<CandTrackListHandle*>(candrec->FindCandHandle("CandTrackListHandle",fTrackListIn.Data()));
00136 if( !track_list || (track_list && track_list->GetNDaughters()<1) )
00137 {
00138
00139 MSG("AtmosShowerListModule", Msg::kWarning) << " Failed to Find " << fTrackListIn.Data() << endl;
00140 }
00141 else { shwlistcxt.Add(track_list); MSG("AtmosShowerListModule", Msg::kDebug) << "Found " << fTrackListIn.Data() << endl; }
00142
00143 AlgFactory &af = AlgFactory::GetInstance();
00144 alg_name=fAlgName.Data(); alg_config_name=fAlgConfig.Data();
00145 AlgHandle adlh = af.GetAlgHandle(alg_name,alg_config_name);
00146
00147 cx.SetDataIn(&shwlistcxt);
00148
00149 clock_t dummyt;
00150 struct tms t1;
00151 struct tms t2;
00152 static double ticksPerSecond = sysconf(_SC_CLK_TCK);
00153
00154 dummyt = times(&t1);
00155 CandShowerAtNuListHandle cslh = CandShowerAtNuList::MakeCandidate(adlh, cx);
00156 dummyt = times(&t2);
00157
00158
00159 MSG("AtmosShowerListModule", Msg::kInfo) << "CandShowerAtNu CPUTime " << (Double_t)(t2.tms_utime+t2.tms_stime-t1.tms_utime-t1.tms_stime)/ticksPerSecond << endl;
00160
00161 cslh.SetName(fListOut.Data());
00162 cslh.SetTitle(TString("Created by AtmosShowerListModule"));
00163 candrec->SecureCandHandle(cslh);
00164
00165 return JobCResult::kPassed;
00166 }
00168
00169
00171 const char* AtmosShowerListModule::GetName() const
00172 {
00173 const char* tmps = "AtmosShowerListModule";
00174 return tmps;
00175 }
00177
00178
00180 const Registry& AtmosShowerListModule::DefaultConfig() const
00181 {
00182
00183
00184
00185 static Registry r;
00186
00187
00188 std::string name = this->GetName();
00189 name += ".config.default";
00190 r.SetName(name.c_str());
00191
00192
00193 r.UnLockValues();
00194 r.Set("NameListIn","CandSliceList");
00195 r.Set("NameTrackListIn","CandFitTrackCamList");
00196 r.Set("NameListOut","CandShowerAtNuList");
00197 r.Set("AtmosShowerAlgorithm","AlgAtmosShowerList");
00198 r.Set("AtmosShowerAlgConfig","default");
00199 r.LockValues();
00200
00201 return r;
00202 }
00204
00205
00207 void AtmosShowerListModule::Config(const Registry& r)
00208 {
00209
00210
00211
00212 const char* tmps;
00213 if (r.Get("NameListIn",tmps)) { fListIn = tmps; }
00214 if (r.Get("NameTrackListIn",tmps)) { fTrackListIn = tmps; }
00215 if (r.Get("NameListOut",tmps)) { fListOut = tmps; }
00216 if (r.Get("AtmosShowerAlgorithm",tmps)) { fAlgName = tmps; }
00217 if (r.Get("AtmosShowerAlgConfig",tmps)) { fAlgConfig = tmps; }
00218 }