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

AlgCaldetDigitList.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgCaldetDigitList.cxx,v 1.1 2003/09/01 15:51:30 tagg Exp $
00003 //
00004 // AlgCaldetDigitList.cxx
00005 //
00006 // AlgCaldetDigitList is a concrete DigitList Algorithm class.
00007 //
00008 // Author:  G. Irwin 4/2000
00010 
00011 #include <cassert>
00012 
00013 #include "Algorithm/AlgConfig.h"
00014 #include "Algorithm/AlgFactory.h"
00015 #include "Algorithm/AlgHandle.h"
00016 #include "CandData/CandRecord.h"
00017 #include "CandDigit/AlgCaldetDigitList.h"
00018 #include "CandDigit/CandDigit.h"
00019 #include "CandDigit/CandDigitHandle.h"
00020 #include "CandDigit/CandDigitList.h"
00021 #include "CandDigit/CandDigitListHandle.h"
00022 #include "Candidate/CandContext.h"
00023 #include "Conventions/Munits.h"
00024 #include "MessageService/MsgService.h"
00025 #include "Plex/PlexSEIdAltL.h"
00026 #include "Plex/PlexSEIdAltLItem.h"
00027 #include "RawData/RawDigit.h"
00028 #include "RawData/RawRecord.h"
00029 #include "RawData/RawDigitDataBlock.h"
00030 #include "Validity/VldContext.h"
00031 #include "Validity/VldTimeStamp.h"
00032 #include "Plex/PlexHandle.h"
00033 #include "RawData/RawHeader.h"
00034 #include "CaldetRawDigitWrapper.h"
00035 ClassImp(AlgCaldetDigitList)
00036 
00037 //______________________________________________________________________
00038 CVSID("$Id: AlgCaldetDigitList.cxx,v 1.1 2003/09/01 15:51:30 tagg Exp $");
00039 
00040 //______________________________________________________________________
00041 AlgCaldetDigitList::AlgCaldetDigitList()
00042 {
00043 }
00044 
00045 //______________________________________________________________________
00046 AlgCaldetDigitList::~AlgCaldetDigitList()
00047 {
00048 }
00049 
00050 //______________________________________________________________________
00051 void AlgCaldetDigitList::RunAlg(AlgConfig &ac, CandHandle &ch,
00052                                                         CandContext &cx)
00053 {
00054    assert(cx.GetDataIn());
00055    
00056    // Get VldContext
00057    const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00058    
00059    // Iterate over RawDigitDataBlock or CandDigitList daughters.
00060    if (cx.GetDataIn()->InheritsFrom("RawRecord")) {
00061      
00062      PlexHandle ph(vldc);
00063      
00064      // Set up to iterate over input RawDigit's to fill output CandDigitList.
00065      
00066      // Get Singleton instance of AlgFactory.
00067      AlgFactory &af = AlgFactory::GetInstance();
00068      
00069      // Get correct Algorithm by name from AlgFactory
00070      const char *tmpcs = 0;
00071      const char *digitalgorithm = 0;
00072      const char *digitalgconfig = 0;
00073 
00074      if (ac.Get("DigitAlgorithm", tmpcs)) digitalgorithm = tmpcs;
00075      if (ac.Get("DigitAlgConfig", tmpcs)) digitalgconfig = tmpcs;
00076 
00077      // Get an AlgHandle to an Algorithm with requested AlgConfig.
00078      AlgHandle ah = af.GetAlgHandle(digitalgorithm, digitalgconfig);
00079 
00080      CandContext cxx(this, cx.GetMom());
00081 
00082      // Set CandRecord pointer in CandContext.
00083      cxx.SetCandRecord(cx.GetCandRecord());
00084 
00085      Bool_t isSparse = true;              // sparsified unless otherwise
00086 
00087      // Iterate over RawRecord's RawDataBlockList to find RawDigitDataBlock.
00088      RawRecord *rr = (RawRecord *) (cx.GetDataIn());
00089      TIter rdbit = rr->GetRawBlockIter();
00090      TObject *tob;
00091      while ((tob = rdbit())) {
00092        if (tob->InheritsFrom("RawDigitDataBlock")) {
00093          RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00094          TIter rdit = rdb->GetDatumIter();
00095          RawDigit *rd;
00096          Int_t rawdigitindex = -1;
00097 
00098          Int_t ndigits = rdb->GetNumberOfDigits();
00099          Bool_t blkIsSparse = 
00100             ( rdb->GetNumberOfCrates() == rdb->GetNSparsModeCrates());
00101          isSparse &= blkIsSparse;
00102          if (!blkIsSparse) 
00103            MSG("AlgCaldetDigitList", Msg::kInfo) 
00104          << "AlgCaldetDigitList finds RawDigitDataBlock is Unsparsified with " 
00105                                << ndigits << " digits " << endl << endl;
00106 
00107 
00108          // This object will contain our data.
00109          CaldetRawDigitWrapper wrapper;
00110 
00111          // Loop through, looking for a timing fiducial hit.
00112          rdit.Reset();   
00113          rawdigitindex = -1;
00114          while ((rd = (RawDigit *) rdit())) { 
00115            ++rawdigitindex;
00116            
00117            if (ph.GetReadoutType(rd->GetChannel()) == ReadoutType::kTimingFid) {
00118              wrapper.fFiducialDigit = rd;
00119            }
00120          }
00121 
00122          if(wrapper.fFiducialDigit==0) {
00123            MSG("AlgCaldetDigitList",Msg::kInfo)
00124              << "Event has no fiducial digit." << endl;
00125          }
00126 
00127          // Loop through again, getting the actual hits we want.
00128          // skip all non-scint readouts
00129          rdit.Reset();   
00130          rawdigitindex = -1;
00131          while ((rd = (RawDigit *) rdit())) { 
00132            ++rawdigitindex;
00133            
00134            // Make canddigits out of everything.
00135            //if (ph.GetReadoutType(rd->GetChannel()) != 
00136            //    ReadoutType::kScintStrip) continue;
00137 
00138            wrapper.fDigit = rd;
00139 
00140            cxx.SetDataIn(&wrapper);
00141            CandDigitHandle cdh = CandDigit::MakeCandidate(ah, cxx);
00142            cdh.SetRawDigitIndex(rawdigitindex);
00143 
00144            ch.AddDaughterLink(cdh, kFALSE);      // Don't check for dups
00145          }
00146        }
00147      }
00148 
00149      // Set absolute time offset in CandDigitList.
00150      // It's no longer subtracted from CandDigits in AlgDigit.
00151      CandDigitListHandle &cdlh =
00152        dynamic_cast<CandDigitListHandle &>(ch);
00153      cdlh.SetAbsTime(((Double_t) vldc.GetTimeStamp().GetNanoSec()) *
00154                      Munits::nanosecond);
00155      
00156      // Set CandDigitList sparsification flag.
00157      cdlh.SetIsSparse(isSparse);
00158    }
00159    
00160    else if (cx.GetDataIn()->InheritsFrom("TCollection")) {
00161      TCollection *cdl = (TCollection *) cx.GetDataIn();
00162      TIter cdit(cdl);
00163      CandDigitHandle *cdh;
00164      while ((cdh = (CandDigitHandle *) cdit())) {
00165        ch.AddDaughterLink(*cdh, kFALSE);         // Don't check for dups
00166      }
00167    }
00168 }
00169 
00170 //______________________________________________________________________
00171 void AlgCaldetDigitList::Trace(const char * /* c */) const
00172 {
00173 }

Generated on Fri Mar 28 15:26:50 2008 for loon by  doxygen 1.3.9.1