00001
00002
00003
00004
00005
00006
00008 #include "SliceFromChopModule.h"
00009 #include "DigitVector.h"
00010 #include "CandChopListHandle.h"
00011 #include "CandChopList.h"
00012
00013 #include "RecoBase/CandSliceListHandle.h"
00014 #include "RecoBase/CandSliceList.h"
00015 #include "RecoBase/CandStripListHandle.h"
00016 #include "RecoBase/CandStripList.h"
00017
00018 #include "MessageService/MsgService.h"
00019 #include "MinosObjectMap/MomNavigator.h"
00020 #include "JobControl/JobCModuleRegistry.h"
00021 #include "Algorithm/AlgFactory.h"
00022 #include "CandData/CandRecord.h"
00023 #include "Candidate/CandContext.h"
00024 #include "Navigation/XxxItr.h"
00025
00026 #include <TFolder.h>
00027 #include <TROOT.h>
00028
00029 JOBMODULE(SliceFromChopModule, "SliceFromChopModule",
00030 "Selects the biggest slice and replaces the CandDigitList with it");
00031 CVSID("$Id: SliceFromChopModule.cxx,v 1.5 2007/03/01 17:34:30 rhatcher Exp $");
00032
00033
00034 SliceFromChopModule::SliceFromChopModule()
00035 {
00036
00037
00038
00039 TFolder *lf = dynamic_cast<TFolder *>(gROOT->FindObject("Loon"));
00040 if (lf==0) {
00041 MSG("Chop", Msg::kDebug) << "Creating Loon TFolder" << endl;
00042 lf = gROOT->GetRootFolder()->AddFolder("Loon", "Loon analysis");
00043 gROOT->GetListOfBrowsables()->Add(lf, "Loon");
00044 }
00045 TFolder* statFolder = lf->AddFolder("CandStripSR", "CandStripSR statistics");
00046 statFolder->Add(&fStats);
00047
00048 }
00049
00050
00051
00052 SliceFromChopModule::~SliceFromChopModule()
00053 {
00054 }
00055
00056
00057 void SliceFromChopModule::EndJob()
00058 {
00059
00060 fStats.Print();
00061 }
00062
00063
00064
00065
00066 JobCResult SliceFromChopModule::Reco(MomNavigator* mom)
00067 {
00068 JobCResult result = JobCResult::kPassed;
00069
00070
00071 Registry& cfg = this->GetConfig();
00072 const char* chopListIn = cfg.GetCharString("ChopListIn");
00073 const char* sliceListOut = cfg.GetCharString("SliceListOut");
00074 const char* stripListOut = cfg.GetCharString("StripListOut");
00075
00076
00077 CandRecord *candrec = dynamic_cast<CandRecord *>
00078 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00079 if (candrec == 0) {
00080 MSG("SliceFromChop", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00081 << endl;
00082 result.SetWarning().SetFailed();
00083 return result;
00084 }
00085
00086
00087 CandChopListHandle *chopList = dynamic_cast<CandChopListHandle*>
00088 (candrec->FindCandHandle("CandChopListHandle", chopListIn));
00089
00090
00091 AlgFactory &af = AlgFactory::GetInstance();
00092 AlgHandle adlh = af.GetAlgHandle( cfg.GetCharString("SliceFromChopAlgorithm"),
00093 cfg.GetCharString("SliceFromChopAlgConfig") );
00094 CandContext cx(this, mom);
00095 cx.SetDataIn(chopList);
00096 cx.SetCandRecord(candrec);
00097
00098 CandSliceListHandle outSliceList = CandSliceList::MakeCandidate(adlh,cx);
00099 outSliceList.SetName(sliceListOut);
00100 outSliceList.SetTitle("Slices created from Chops");
00101 outSliceList.SetCandRecord(candrec);
00102 candrec->SecureCandHandle(outSliceList);
00103
00104
00105
00106 {
00107 adlh = af.GetAlgHandle( cfg.GetCharString("StripFromSliceAlgorithm"),
00108 cfg.GetCharString("StripFromSliceAlgConfig") );
00109 cx.SetDataIn(&outSliceList);
00110 cx.SetCandRecord(candrec);
00111
00112 CandStripListHandle outStrips = CandStripList::MakeCandidate(adlh,cx);
00113 outStrips.SetName(stripListOut);
00114 outStrips.SetTitle("Strips aggregated from Slices");
00115 outStrips.SetCandRecord(candrec);
00116 candrec->SecureCandHandle(outStrips);
00117
00118 }
00119
00120 return JobCResult::kPassed;
00121 }
00122
00123
00124
00125
00126
00127 JobCResult SliceFromChopModule::Ana(const MomNavigator* )
00128 {
00129 return JobCResult::kPassed;
00130 }
00131
00132
00133
00134 const Registry& SliceFromChopModule::DefaultConfig() const
00135 {
00136
00137
00138
00139 static Registry r;
00140
00141
00142 std::string name = this->JobCModule::GetName();
00143 name += ".config.default";
00144 r.SetName(name.c_str());
00145
00146
00147 r.UnLockValues();
00148 r.Set("SliceFromChopAlgorithm","AlgSliceListFromChopList");
00149 r.Set("SliceFromChopAlgConfig","default");
00150 r.Set("StripFromSliceAlgorithm","AlgStripListFromSliceList");
00151 r.Set("StripFromSliceAlgConfig","default");
00152 r.Set("ChopListIn", "candchoplist");
00153 r.Set("SliceListOut", "CandSliceList");
00154 r.Set("StripListOut", "candstriplist");
00155
00156 r.LockValues();
00157
00158 return r;
00159 }
00160