00001
00002
00003
00004
00005
00007
00008 #include <cassert>
00009 #include <vector>
00010 extern "C" {
00011 #include <unistd.h>
00012 #include <sys/times.h>
00013 }
00014
00015 #include "Algorithm/AlgFactory.h"
00016 #include "Algorithm/AlgHandle.h"
00017 #include "Algorithm/AlgConfig.h"
00018 #include "Candidate/CandContext.h"
00019 #include "CandFitShowerEM/AlgFitShowerEMList.h"
00020 #include "CandFitShowerEM/CandFitShowerEM.h"
00021 #include "CandFitShowerEM/CandFitShowerEMHandle.h"
00022 #include "CandFitShowerEM/CandFitShowerEMList.h"
00023 #include "CandFitShowerEM/CandFitShowerEMListHandle.h"
00024 #include "CandShowerEM/CandShowerEMListHandle.h"
00025 #include "Conventions/Mphysical.h"
00026 #include "Conventions/Munits.h"
00027 #include "Conventions/PlaneView.h"
00028 #include "MessageService/MsgService.h"
00029 #include "MinosObjectMap/MomNavigator.h"
00030 #include "Navigation/NavKey.h"
00031 #include "Navigation/NavSet.h"
00032 #include "RecoBase/CandSliceHandle.h"
00033 #include "RecoBase/CandSliceListHandle.h"
00034 #include "RecoBase/LinearFit.h"
00035 #include "UgliGeometry/UgliGeomHandle.h"
00036 #include "Validity/VldContext.h"
00037
00038 ClassImp(AlgFitShowerEMList)
00039
00040
00041
00042 CVSID("$Id: AlgFitShowerEMList.cxx,v 1.2 2004/09/29 00:07:29 cbs Exp $");
00043
00044
00045 AlgFitShowerEMList::AlgFitShowerEMList()
00046 {
00047
00048 }
00049
00050
00051 AlgFitShowerEMList::~AlgFitShowerEMList()
00052 {
00053
00054 }
00055
00056
00057 void AlgFitShowerEMList::RunAlg(AlgConfig &ac, CandHandle &ch,CandContext &cx)
00058 {
00059 MSG("Alg", Msg::kDebug)
00060 << "Starting AlgFitShowerEMList::RunAlg()" << endl;
00061
00062 assert(cx.GetDataIn());
00063
00064 if (!(cx.GetDataIn()->InheritsFrom("TObjArray"))) {
00065 return;
00066 }
00067
00068 const CandSliceListHandle *slicelist = 0;
00069 const CandShowerEMListHandle *showerlist = 0;
00070 const TObjArray *cxin = dynamic_cast<const TObjArray *>(cx.GetDataIn());
00071 for (Int_t i=0; i<=cxin->GetLast(); i++) {
00072 TObject *tobj = cxin->At(i);
00073 if (tobj->InheritsFrom("CandSliceListHandle")) {
00074 slicelist = dynamic_cast<CandSliceListHandle*>(tobj);
00075 }
00076 if (tobj->InheritsFrom("CandShowerEMListHandle")) {
00077 showerlist = dynamic_cast<CandShowerEMListHandle*>(tobj);
00078 }
00079 }
00080 if (!slicelist || !showerlist) {
00081 MSG("error",Msg::kError) <<
00082 "CandSliceListHandle or CandShowerEMListHandle missing\n";
00083 }
00084
00085
00086 CandContext cxx(this,cx.GetMom());
00087
00088
00089 const char *charFitShowerEMAlgConfig = 0;
00090 ac.Get("FitShowerEMAlgConfig",charFitShowerEMAlgConfig);
00091
00092
00093 AlgFactory &af = AlgFactory::GetInstance();
00094 AlgHandle ah = af.GetAlgHandle("AlgFitShowerEM",charFitShowerEMAlgConfig);
00095
00096 TIter showerItr(showerlist->GetDaughterIterator());
00097
00098 clock_t dummyt;
00099 struct tms t1;
00100 struct tms t2;
00101 static double ticksPerSecond = sysconf(_SC_CLK_TCK);
00102 while (CandShowerEMHandle *shower
00103 = dynamic_cast<CandShowerEMHandle*>(showerItr())) {
00104 if(shower->GetShwStatus()!=1) continue;
00105 TObjArray cxin;
00106 cxin.Add(shower);
00107 cxx.SetDataIn(&cxin);
00108 dummyt = times(&t1);
00109 CandFitShowerEMHandle fitshower = CandFitShowerEM::MakeCandidate(ah,cxx);
00110 dummyt = times(&t2);
00111 Double_t CPUTime = Double_t(t2.tms_utime+t2.tms_stime
00112 -t1.tms_utime-t1.tms_stime)/ticksPerSecond;
00113 fitshower.SetCPUTime(CPUTime);
00114 MSG("FitShowerEM",Msg::kDebug) << "CPUTime = "<<CPUTime<<endl;
00115 ch.AddDaughterLink(fitshower);
00116 }
00117
00118 }
00119