Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

AlgFilterChannels.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgFilterChannels.cxx,v 1.2 2008/11/18 17:09:29 rhatcher Exp $
00003 //
00004 // AlgFilterChannels.cxx
00005 //
00006 // Concrete Algorithm for filtering CandDigit's from CandChannels
00007 //
00008 // Author:  G. Irwin 2/2003
00010 // AlgConfig parameters (with default values) are:
00011 //
00012 // "FilterStrategy" - Filtering strategy to use
00014 
00015 #include <cassert>
00016 
00017 #include "CalDetDST/AlgFilterChannels.h"
00018 #include "CalDetDST/ChannelsToFilter.h"
00019 #include "DatabaseInterface/DbiResultPtr.h"
00020 
00021 #include "Algorithm/AlgConfig.h"
00022 #include "Algorithm/AlgFactory.h"
00023 #include "Algorithm/AlgHandle.h"
00024 #include "CandDigit/CandDigit.h"
00025 #include "CandDigit/CandDigitHandle.h"
00026 #include "CandDigit/CandDigitList.h"
00027 #include "CandDigit/CandDigitListHandle.h"
00028 #include "Candidate/CandContext.h"
00029 #include "MessageService/MsgService.h"
00030 
00031 
00032 ClassImp(AlgFilterChannels)
00033 
00034 //______________________________________________________________________
00035 CVSID("$Id: AlgFilterChannels.cxx,v 1.2 2008/11/18 17:09:29 rhatcher Exp $");
00036 
00037 //______________________________________________________________________
00038 AlgFilterChannels::AlgFilterChannels()
00039 {
00040 }
00041 
00042 //______________________________________________________________________
00043 AlgFilterChannels::~AlgFilterChannels()
00044 {
00045 }
00046 
00047 //______________________________________________________________________
00048 void AlgFilterChannels::RunAlg(AlgConfig & /* ac */, CandHandle &ch,
00049                                                         CandContext &cx)
00050 {
00051    MSG("AlgFilterChannels", Msg::kDebug)
00052                      << "Starting AlgFilterChannels::RunAlg()" << endl;
00053 
00054 // Check for input CandDigitListHandle in CandContext
00055    assert(cx.GetDataIn());
00056 
00057 // Obtain CandContext's CandDigitList as input
00058    const CandDigitListHandle *cdlh =
00059              dynamic_cast<const CandDigitListHandle *> (cx.GetDataIn());
00060    assert(cdlh);   // Check for input CandDigitListHandle in CandContext
00061 
00062 // Set CandRecord pointer in new CandDigitList to that of CandDigitList
00063    ch.SetCandRecord((cdlh->GetCandRecord())); //Sub-algorithms need this
00064 
00065 // Copy member variables from orig CandDigitList to new CandDigitList
00066    CandDigitListHandle &cddlh = dynamic_cast<CandDigitListHandle &>(ch);
00067    cddlh.SetAbsTime(cdlh->GetAbsTime());
00068    cddlh.SetIsSparse(cdlh->GetIsSparse());
00069 
00070 // open a connection to the db
00071 
00072 /*
00073    // this bit of code doesn't work!
00074    // apparently, cx.GetCandRecord() returns a bad pointer
00075    // as cx.SetCandRecord() never gets called by the module
00076    // arghh!
00077 
00078    const VldContext* vcp = cx.GetCandRecord()->GetVldContext();
00079    if(!vcp ){
00080       MSG("AlgFilterChannels", Msg::kFatal)
00081          << "Couldn't get a VldContext?!" << endl;
00082       return;
00083    }
00084 */
00085    // try to get a vld context from the digitlisthandle
00086    const VldContext* vcp = cdlh->GetVldContext();
00087    if(!vcp ){
00088       MSG("AlgFilterChannels", Msg::kFatal)
00089          << "Couldn't get a VldContext?!" << endl;
00090       return;
00091    }
00092    
00093  
00094    DbiResultPtr<ChannelsToFilter> rptr(*vcp);   
00095 
00096 // Iterate over CandContext's CandDigitList to find CandDigitHandles.
00097    TIter cdhiter = cdlh->GetDaughterIterator();
00098    TObject *tob;
00099    while ((tob = cdhiter())) {
00100      CandDigitHandle *cdh = dynamic_cast<CandDigitHandle *>(tob);
00101      if (cdh == 0) continue;   // Skip daughter if not a CandDigitHandle
00102      MSG("AlgFilterChannels", Msg::kVerbose)
00103         << "Considering: "<<cdh->GetChannelId()
00104         <<" --> "<<cdh->GetPlexSEIdAltL()<< endl;
00105 
00106      // very simple, just ask the result pointer if this is a 
00107      // channel in its list
00108      bool cutit=false;
00109      MSG("AlgFilterChannels", Msg::kVerbose)
00110         << "Filtering out "<<rptr.GetNumRows()<<" channels."<<endl;
00111 
00112      for(unsigned int i=0; i<rptr.GetNumRows(); i++){
00113         const ChannelsToFilter* ctof = rptr.GetRow(i);
00114         MSG("AlgFilterChannels", Msg::kVerbose)
00115            <<"Is it this one? :  "<<(*ctof)<<endl;
00116            if( ctof->IsSameChannel(cdh) ) {
00117               cutit=true;
00118               MSG("AlgFilterChannels", Msg::kDebug)
00119                  <<"Cut this "<< (*ctof) <<endl;
00120               break;
00121            }
00122      }
00123      if(cutit) continue; // don't add this digit to the new list!
00124 
00125 // Effect copy of wanted digits from orig CandDigitList to daughter list
00126      CandDigitHandle cddh(*cdh);
00127      ch.AddDaughterLink(cddh, kFALSE);           // Don't check for dups
00128    }
00129 }
00130 
00131 //______________________________________________________________________
00132 void AlgFilterChannels::Trace(const char * /* c */) const
00133 {
00134 }

Generated on Mon Feb 15 11:06:18 2010 for loon by  doxygen 1.3.9.1