00001
00002 #include "AlgFarDetSliceList.h"
00003 #include "FarDetSliceHandle.h"
00004 #include "FarDetSliceListHandle.h"
00005
00006 #include "Algorithm/AlgFactory.h"
00007 #include "Algorithm/AlgHandle.h"
00008 #include "Algorithm/AlgConfig.h"
00009
00010 #include "MessageService/MsgService.h"
00011 #include "MinosObjectMap/MomNavigator.h"
00012
00013 #include "Candidate/CandContext.h"
00014 #include "RecoBase/CandStripHandle.h"
00015 #include "RecoBase/CandStripListHandle.h"
00016
00017 #include "Fabrication/FabPlnInstallLookup.h"
00018
00019 ClassImp(AlgFarDetSliceList)
00020
00021 CVSID("$Id: AlgFarDetSliceList.cxx,v 1.2 2008/08/25 13:03:10 blake Exp $");
00022
00023 AlgFarDetSliceList::AlgFarDetSliceList() :
00024 fSliceList(0)
00025 {
00026 fSliceList = new TObjArray();
00027 }
00028
00029 AlgFarDetSliceList::~AlgFarDetSliceList()
00030 {
00031 if(fSliceList) delete fSliceList;
00032 }
00033
00034 void AlgFarDetSliceList::RunAlg(AlgConfig &ac, CandHandle &ch, CandContext &cx)
00035 {
00036 MSG("FarDetSlice",Msg::kDebug) << " AlgFarDetSliceList::RunAlg(...) " << endl;
00037
00038 FarDetSliceListHandle& myslicelist = dynamic_cast<FarDetSliceListHandle&>(ch);
00039
00040
00041 Int_t pln;
00042 Int_t fMinPlane = 0;
00043 Int_t fMaxPlane = 485;
00044 Int_t fCheckInstall = 0;
00045 fMinPlane = ac.GetInt("MinPlane");
00046 fMaxPlane = ac.GetInt("MaxPlane");
00047 fCheckInstall = ac.GetInt("CheckInstall");
00048
00049 MSG("FarDetSlice",Msg::kDebug) << " AlgFarDetSliceList Config: " << endl
00050 << " MinPlane=" << fMinPlane
00051 << " MaxPlane=" << fMaxPlane
00052 << " CheckInstall=" << fCheckInstall << endl;
00053
00054
00055 if( fCheckInstall ){
00056
00057
00058 MSG("FarDetSlice",Msg::kDebug) << " Checking Installation Status: " << endl;
00059 Int_t fMaxInstallPlane = 485, fTmpInstallPlane = 485;
00060 CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00061 VldContext *vldc = (VldContext*)(candrec->GetVldContext());
00062 FabPlnInstallLookup fMaxPlaneLookup(*vldc);
00063 PlexPlaneId fMaxPlaneId = fMaxPlaneLookup.GetLastNormalPlane();
00064 if(fMaxPlaneId.IsValid()) fTmpInstallPlane = fMaxPlaneId.GetPlane();
00065 if(fTmpInstallPlane<fMaxInstallPlane) fMaxInstallPlane = fTmpInstallPlane;
00066 MSG("FarDetSlice",Msg::kDebug) << " Maximum Installed Plane=" << fMaxInstallPlane << endl;
00067
00068
00069 if( fMaxInstallPlane<fMaxPlane ){
00070 MSG("FarDetSlice",Msg::kDebug) << " ... resetting MaxPlane to: " << fMaxInstallPlane << endl;
00071 fMaxPlane=fMaxInstallPlane;
00072 }
00073
00074
00075 if( fMaxInstallPlane<fMinPlane ){
00076 MSG("FarDetSlice",Msg::kDebug) << " ... resetting MinPlane to: " << fMaxInstallPlane << endl;
00077 fMinPlane=fMaxInstallPlane;
00078 }
00079 }
00080
00081
00082 const CandStripListHandle* cslh = dynamic_cast<const CandStripListHandle*>(cx.GetDataIn());
00083 TIter strpitr(cslh->GetDaughterIterator());
00084 while(CandStripHandle* csh = dynamic_cast<CandStripHandle*>(strpitr())){
00085 if(csh){
00086 pln = csh->GetPlane();
00087 if( pln>0 && pln<500
00088 && pln>fMinPlane && pln<fMaxPlane ){
00089 fSliceList->Add(csh);
00090 }
00091 }
00092 }
00093
00094
00095 AlgFactory &af = AlgFactory::GetInstance();
00096 AlgHandle ahh = af.GetAlgHandle("AlgFarDetSlice","default");
00097 CandContext cxx(this,cx.GetMom());
00098 cxx.SetCandRecord(cx.GetCandRecord());
00099
00100 cxx.SetDataIn(fSliceList);
00101 FarDetSliceHandle myslice = FarDetSlice::MakeCandidate(ahh,cxx);
00102 myslice.SetName("FarDetSlice");
00103 myslice.SetTitle(TString("Created by AlgFarDetSliceList"));
00104 myslicelist.AddDaughterLink(myslice);
00105
00106 fSliceList->Clear();
00107
00108 }
00109
00110 void AlgFarDetSliceList::Trace(const char* ) const
00111 {
00112
00113 }