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

AlgDigiPairList Class Reference

#include <AlgDigiPairList.h>

Inheritance diagram for AlgDigiPairList:

AlgBase List of all members.

Public Member Functions

 AlgDigiPairList ()
virtual ~AlgDigiPairList ()
virtual void Trace (const char *c) const
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)

Private Member Functions

Bool_t IsCosmic (PlexPlaneId pid) const
Bool_t MatchedEnds (TObjArray &cdhAr) const

Constructor & Destructor Documentation

AlgDigiPairList::AlgDigiPairList  ) 
 

Definition at line 50 of file AlgDigiPairList.cxx.

00051 {
00052 //
00053 //  Purpose:    Default constructor.
00054 //
00055 //  Arguments:  n/a
00056 //
00057 //  Return:     n/a
00058 //
00059 }

AlgDigiPairList::~AlgDigiPairList  )  [virtual]
 

Definition at line 63 of file AlgDigiPairList.cxx.

00064 {
00065 //
00066 //  Purpose:    Default destructor.
00067 //
00068 //  Arguments:  n/a
00069 //
00070 //  Return:     n/a
00071 //
00072 }


Member Function Documentation

Bool_t AlgDigiPairList::IsCosmic PlexPlaneId  pid  )  const [private]
 

Definition at line 76 of file AlgDigiPairList.cxx.

References PlexPlaneId::GetPlaneView().

Referenced by RunAlg().

00077 {
00078 //
00079 //  Purpose:    Tests whether a plane is a cosmic counter in the Caldet.
00080 //
00081 //  Arguments:
00082 //    pid       in     PlexPlaneId to test
00083 //
00084 //  Return:     kTRUE  if pid is a cosmic counter
00085 //
00086 
00087 // Check whether cosmic counter.
00088    if ((pid.GetPlaneView() == PlaneView::kA)
00089        || (pid.GetPlaneView() == PlaneView::kB))
00090       return kTRUE;
00091    else return kFALSE;
00092 }

Bool_t AlgDigiPairList::MatchedEnds TObjArray &  cdhAr  )  const [private]
 

Definition at line 96 of file AlgDigiPairList.cxx.

References PlexSEIdAltL::GetEnd(), and CandDigitHandle::GetPlexSEIdAltL().

Referenced by RunAlg().

00097 {
00098 //
00099 //  Purpose:    Tests whether a list of CandDigits has both ends of a
00100 //              strip.
00101 //
00102 //  Arguments:
00103 //    cdhAr     in    Array of CandDigits to be tested for match.
00104 //
00105 //  Return:     kTRUE  if both ends have digits.
00106 //              kFALSE otherwise.
00107 //
00108 
00109 // Iterate over CandDigits.
00110    Bool_t pos = kFALSE, neg = kFALSE;
00111    TIter cdhItr(&cdhAr);
00112    while (CandDigitHandle *cdh =
00113              dynamic_cast<CandDigitHandle *>(cdhItr())) {
00114 
00115 // Check which strip end.
00116       StripEnd::StripEnd_t end = cdh->GetPlexSEIdAltL().GetEnd();
00117       if (end == StripEnd::kNegative)      neg = kTRUE;
00118       else if (end == StripEnd::kPositive) pos = kTRUE;
00119 
00120 // Check whether both ends found.
00121       if (neg && pos) return kTRUE;
00122    }
00123    return kFALSE;
00124 }

void AlgDigiPairList::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Implements AlgBase.

Definition at line 128 of file AlgDigiPairList.cxx.

References CandHandle::AddDaughterLink(), BubKeyFromPSEId(), BubKeyFromTime(), AlgFactory::GetAlgHandle(), PlexSEIdAltL::GetBestSEId(), PlexSEIdAltL::GetBestWeight(), CandContext::GetCandRecord(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), PlexSEIdAltL::GetDemuxVetoFlag(), VldContext::GetDetector(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), CandDigitHandle::GetPlexSEIdAltL(), PlexSEIdAltL::GetSize(), CandDigitHandle::GetTime(), CandHandle::GetVldContext(), IsCosmic(), PlexStripEndId::IsSameStrip(), CandDigiPair::MakeCandidate(), MatchedEnds(), and MSG.

00130 {
00131 //
00132 //  Purpose:  Fills the CandDigiPairList with CandDigiPairs constructed
00133 //            using the supplied CandDigitList.
00134 //
00135 //  Argument:
00136 //    ac        in    AlgConfig (not used).
00137 //    ch        in    Handle to the CandDigiPairList to fill.
00138 //    cx        in    CandContext containing a demuxed CandDigitList.
00139 //
00140 //  Return:   n/a
00141 //
00142 
00143    MSG("BubAlg", Msg::kVerbose)
00144       << "Starting AlgDigiPairList::RunAlg()" << endl;
00145 
00146    Bool_t needmatch = ac.GetInt("MatchEnds");
00147    Double_t maxtimesep = ac.GetDouble("TimeSepMax");
00148 
00149 // Check for CandDigitListHandle input.
00150    assert(cx.GetDataIn());
00151    if (cx.GetDataIn()->InheritsFrom("CandDigitListHandle")) {
00152 
00153 // Recover CandDigitListHandle.
00154       MSG("BubAlg", Msg::kVerbose)
00155          << "Recover CandDigitListHandle." << endl;
00156       const CandDigitListHandle *cdlh =
00157                dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00158 
00159 // Get detector type.
00160       const VldContext *vld = cdlh->GetVldContext();
00161       assert(vld);
00162       DetectorType::Detector_t dettype = vld->GetDetector();
00163 
00164 // Sort by PlaneStripEndId.
00165       MSG("BubAlg", Msg::kVerbose) << "Create iterator." << endl;
00166       CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00167 
00168       MSG("BubAlg", Msg::kVerbose)
00169          << "Sort CandDigitList by StripEndId." << endl;
00170       CandDigitHandleKeyFunc *cdhKf = cdhItr.CreateKeyFunc();
00171       cdhKf->SetFun(BubKeyFromPSEId);
00172       cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf);
00173       cdhKf = 0;
00174 
00175 // General setup.
00176       // Get singleton instance of AlgFactory.
00177       MSG("BubAlg", Msg::kVerbose)
00178          << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00179       AlgFactory &af = AlgFactory::GetInstance();
00180 
00181       // Get an AlgHandle to AlgDigiPair with "default" AlgConfig.
00182       MSG("BubAlg", Msg:: kVerbose) <<
00183         "AlgHandle ah = af.GetAlgHandle(\"AlgDigiPair\", \"default\");"
00184                                                                << endl;
00185       AlgHandle ah = af.GetAlgHandle("AlgDigiPair", "default");
00186 
00187       MSG("BubAlg", Msg::kVerbose)
00188          << "Create CandContext instance." << endl;
00189       CandContext cxx(this, cx.GetMom());
00190       cxx.SetCandRecord(cx.GetCandRecord());
00191 
00192 // Iterate over CandDigitList daughters and create CandDigiPairs.
00193       CandDigitHandle *prev = 0;
00194       TObjArray cdhAr;
00195       while(CandDigitHandle *curr = cdhItr()) {
00196 
00197          // Check whether a special CalDet digit (empty demux list).
00198          if (curr->GetPlexSEIdAltL().GetSize() == 0) continue;
00199 
00200          // Check for demux veto flag.
00201          if (curr->GetPlexSEIdAltL().GetDemuxVetoFlag()) continue;
00202 
00203          // Check for best weight of zero in Far Detector.
00204          if ((curr->GetPlexSEIdAltL().GetBestWeight() <= 0)
00205              && (dettype == DetectorType::kFar))
00206             continue;
00207 
00208          if (prev) {
00209             // Check whether same strip.
00210             PlexStripEndId pSEId =prev->GetPlexSEIdAltL().GetBestSEId();
00211             PlexStripEndId cSEId =curr->GetPlexSEIdAltL().GetBestSEId();
00212             if (pSEId.IsSameStrip(cSEId)) cdhAr.Add(curr);
00213             else {   // New strip.
00214                // Check whether need to match strip ends or have match
00215                // or is cosmic counter in Caldet
00216                if (!needmatch || MatchedEnds(cdhAr) || IsCosmic(pSEId)){
00217                   // Check number of digits.
00218                   if (cdhAr.GetEntriesFast() == 1) {
00219                      // Create CandDigiPair from previous list.
00220                      cxx.SetDataIn(&cdhAr);
00221                      CandDigiPairHandle chh =
00222                                   CandDigiPair::MakeCandidate(ah, cxx);
00223                      ch.AddDaughterLink(chh);
00224                   }
00225                   else {
00226                      // Sort digits by time.
00227                      CandDigitHandleItr tmpItr(cdhAr.MakeIterator());
00228                      cdhKf = tmpItr.CreateKeyFunc();
00229                      cdhKf->SetFun(BubKeyFromTime);
00230                      tmpItr.GetSet()->AdoptSortKeyFunc(cdhKf);
00231                      cdhKf = 0;
00232 
00233                      // Check for time separation.
00234                      TObjArray tmpAr;
00235                      CandDigitHandle *cdh = tmpItr();
00236                      tmpAr.Add(cdh);
00237                      Double_t lasttime = cdh->GetTime();
00238                      while ((cdh = tmpItr())) {
00239                         if ((cdh->GetTime() - lasttime) > maxtimesep) {
00240                            // Create strip, then start new one.
00241                            cxx.SetDataIn(&tmpAr);
00242                            CandDigiPairHandle chh =
00243                                   CandDigiPair::MakeCandidate(ah, cxx);
00244                            ch.AddDaughterLink(chh);
00245                            tmpAr.Clear();
00246                         }
00247                         lasttime = cdh->GetTime();
00248                         tmpAr.Add(cdh);
00249                      }
00250 
00251                      // Create strip from last digit added.
00252                      cxx.SetDataIn(&tmpAr);
00253                      CandDigiPairHandle chh =
00254                                   CandDigiPair::MakeCandidate(ah, cxx);
00255                      ch.AddDaughterLink(chh);
00256 
00257                      // Clean up
00258                      tmpAr.Clear();
00259                   }
00260                }
00261 
00262                // Prepare for next strip.
00263                cdhAr.Clear();
00264                cdhAr.Add(curr);
00265             }
00266          }
00267          else cdhAr.Add(curr);
00268          prev = curr;
00269       }
00270       if (prev) {
00271          // Create CandDigiPair from last digit added.
00272          PlexStripEndId pSEId =prev->GetPlexSEIdAltL().GetBestSEId();
00273          if (!needmatch || MatchedEnds(cdhAr) || IsCosmic(pSEId)) {
00274             cxx.SetDataIn(&cdhAr);
00275             CandDigiPairHandle chh =
00276                                    CandDigiPair::MakeCandidate(ah, cxx);
00277             ch.AddDaughterLink(chh);
00278          }
00279          // Clean up.
00280          cdhAr.Clear();
00281          prev = 0;
00282       }
00283    }
00284 }

void AlgDigiPairList::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 288 of file AlgDigiPairList.cxx.

References MSG.

00289 {
00290 //
00291 //  Purpose:  Trace the AlgDigiPairList.
00292 //
00293 //  Arguments:
00294 //    c          in    String tag for the trace.
00295 //
00296 //  Return:   n/a
00297 //
00298 
00299   MSG("BubCand", Msg::kDebug)
00300     << "**********Begin AlgDigiPairList::Trace(\"" << c << "\")" << endl
00301     << "**********End AlgDigiPairList::Trace(\"" << c << "\")" << endl;
00302 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 1 15:55:23 2007 for loon by  doxygen 1.3.9.1