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

AlgDeMuxDigitList.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgDeMuxDigitList.cxx,v 1.5 2004/02/11 20:37:14 gmieg Exp $
00003 //
00004 // AlgDeMuxDigitList.cxx
00005 //
00006 // Concrete Algorithm for filling CandDeMuxDigitList from CandDigitList
00007 //
00008 // Author:  G. Irwin 9/2002
00010 // AlgConfig parameters (with default values) are:
00011 //
00012 // "DeMuxAlgorithm" ("AlgDeMuxCosmics") - Demuxing Algorithm to call
00013 // "DeMuxAlgConfig" ("default") - Demuxing Algorithm's AlgConfig "name"
00014 // "NormalizeWeights" (1) - Normalize weights to 1. if non-zero
00015 // "TrimHyps" (1) - Drop "0" weights if neg., or keep top N (=TrimHyps)
00017 
00018 #include <cassert>
00019 
00020 #include "Algorithm/AlgConfig.h"
00021 #include "Algorithm/AlgFactory.h"
00022 #include "Algorithm/AlgHandle.h"
00023 #include "CandDigit/AlgDeMuxDigitList.h"
00024 #include "CandDigit/CandDeMuxDigit.h"
00025 #include "CandDigit/CandDeMuxDigitHandle.h"
00026 #include "CandDigit/CandDeMuxDigitList.h"
00027 #include "CandDigit/CandDeMuxDigitListHandle.h"
00028 #include "CandDigit/CandDigit.h"
00029 #include "CandDigit/CandDigitHandle.h"
00030 #include "CandDigit/CandDigitList.h"
00031 #include "CandDigit/CandDigitListHandle.h"
00032 #include "Candidate/CandContext.h"
00033 #include "MessageService/MsgService.h"
00034 
00035 ClassImp(AlgDeMuxDigitList)
00036 
00037 //______________________________________________________________________
00038 CVSID("$Id: AlgDeMuxDigitList.cxx,v 1.5 2004/02/11 20:37:14 gmieg Exp $");
00039 
00040 //______________________________________________________________________
00041 AlgDeMuxDigitList::AlgDeMuxDigitList()
00042 {
00043 }
00044 
00045 //______________________________________________________________________
00046 AlgDeMuxDigitList::~AlgDeMuxDigitList()
00047 {
00048 }
00049 
00050 //______________________________________________________________________
00051 void AlgDeMuxDigitList::RunAlg(AlgConfig &ac, CandHandle &ch,
00052                                                         CandContext &cx)
00053 {
00054    MSG("AlgDeMuxDigitList", Msg::kDebug)
00055                       << "Starting AlgDeMuxDigitList::RunAlg()" << endl;
00056 
00057 // Check for input CandDigitListHandle in CandContext
00058    assert(cx.GetDataIn());
00059 
00060 // Obtain CandContext's CandDigitList as input
00061    const CandDigitListHandle *cdlh =
00062              dynamic_cast<const CandDigitListHandle *> (cx.GetDataIn());
00063    assert(cdlh);   // Check for input CandDigitListHandle in CandContext
00064 
00065 // Set CandRecord pointer in CandDeMuxDigitList to that of CandDigitList
00066    ch.SetCandRecord((cdlh->GetCandRecord())); //Sub-algorithms need this
00067 
00068 // Copy member variables from orig CandDigitList to CandDeMuxDigitList
00069    CandDeMuxDigitListHandle &cddlh =
00070                            dynamic_cast<CandDeMuxDigitListHandle &>(ch);
00071    cddlh.SetAbsTime(cdlh->GetAbsTime());
00072    cddlh.SetIsSparse(cdlh->GetIsSparse());
00073 
00074 // Iterate over CandContext's CandDigitList to find CandDigitHandles.
00075    TIter cdhiter = cdlh->GetDaughterIterator();
00076    TObject *tob;
00077    while ((tob = cdhiter())) {
00078      CandDigitHandle *cdh = dynamic_cast<CandDigitHandle *>(tob);
00079      if (cdh == 0) continue;   // Skip daughter if not a CandDigitHandle
00080 
00081 // Effect copy from CandDigit source to a new CandDeMuxDigit
00082      CandDeMuxDigitHandle cddh =
00083                             CandDeMuxDigitHandle::DupCandFromBase(*cdh);
00084      ch.AddDaughterLink(cddh, kFALSE);           // Don't check for dups
00085    }
00086 
00087 // Get Singleton instance of AlgFactory.
00088    MSG("AlgDeMuxDigitList", Msg::kDebug)
00089                << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00090    AlgFactory &af = AlgFactory::GetInstance();
00091    AlgHandle ah;
00092 
00093 // Get correct Algorithm by name from AlgFactory
00094    const char *tmpcs = 0;
00095    const char *demuxalgorithm = 0;
00096    const char *demuxalgconfig = 0;
00097 
00098    if (ac.Get("DeMuxAlgorithm", tmpcs)) demuxalgorithm = tmpcs;
00099    if (ac.Get("DeMuxAlgConfig", tmpcs)) demuxalgconfig = tmpcs;
00100    ah = af.GetAlgHandle(demuxalgorithm, demuxalgconfig);
00101 
00102    CandContext cxx(this, cx.GetMom());
00103    
00104    ah.RunAlg(ch, cxx);
00105 
00106 // Normalize and/or de-sparsify PlexSEIdAltL, if requested
00107    if (cddlh.GetDeMuxDigitListFlagWord() == 0) {    // Demuxing is valid
00108      Int_t tmpi = 0;
00109      Int_t normwts = 0;  Int_t trimhyps = 0;
00110      if (ac.Get("NormalizeWeights", tmpi)) normwts = tmpi;
00111      if (ac.Get("TrimHyps", tmpi)) trimhyps = tmpi;
00112      if (normwts || trimhyps)  {     // Need to loop over DeMuxDigitList
00113        TIter cddhiter = ch.GetDaughterIterator();
00114        while ((tob = cddhiter())) {
00115          CandDeMuxDigitHandle *cddh =
00116                               dynamic_cast<CandDeMuxDigitHandle *>(tob);
00117          if (cddh == 0) continue;      // Require a CandDeMuxDigitHandle
00118          if (cddh->GetPlexSEIdAltL().GetDemuxVetoFlag() != 0) continue;
00119          PlexSEIdAltL &seidw = cddh->GetPlexSEIdAltLWritable();
00120          if (normwts) seidw.NormalizeWeights(); // Norm wts to 1 if ne 0
00121          if (trimhyps<0) seidw.DropZeroWeights();   // Drop 0 wts if neg
00122          else if (trimhyps>0) seidw.KeepTopWeights(trimhyps);  // Keep N
00123        }
00124      }
00125    }
00126 }
00127 
00128 //______________________________________________________________________
00129 void AlgDeMuxDigitList::Trace(const char * /* c */) const
00130 {
00131 }

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