00001
00002
00003
00004
00005
00006
00007
00008
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/AlgDigitList.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
00033 #define ONLYSCINT
00034 #ifdef ONLYSCINT
00035 #include "Plex/PlexHandle.h"
00036 #include "RawData/RawHeader.h"
00037 #endif
00038
00039 ClassImp(AlgDigitList)
00040
00041
00042 CVSID("$Id: AlgDigitList.cxx,v 1.15 2003/03/29 01:26:13 gmieg Exp $");
00043
00044
00045 AlgDigitList::AlgDigitList()
00046 {
00047 }
00048
00049
00050 AlgDigitList::~AlgDigitList()
00051 {
00052 }
00053
00054
00055 void AlgDigitList::RunAlg(AlgConfig &ac, CandHandle &ch,
00056 CandContext &cx)
00057 {
00058 #ifdef ENABLE_DEBUG_MSG
00059 MSG("AlgDigitList", Msg::kDebug)
00060 << "Starting AlgDigitList::RunAlg()" << endl;
00061 #endif
00062
00063 assert(cx.GetDataIn());
00064
00065
00066 const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00067
00068
00069 if (cx.GetDataIn()->InheritsFrom("RawRecord")) {
00070
00071 #ifdef ONLYSCINT
00072 PlexHandle ph(vldc);
00073 #endif
00074
00075
00076
00077
00078 #ifdef ENABLE_DEBUG_MSG
00079 MSG("AlgDigitList", Msg::kDebug)
00080 << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00081 #endif
00082 AlgFactory &af = AlgFactory::GetInstance();
00083
00084
00085 const char *tmpcs = 0;
00086 const char *digitalgorithm = 0;
00087 const char *digitalgconfig = 0;
00088
00089 if (ac.Get("DigitAlgorithm", tmpcs)) digitalgorithm = tmpcs;
00090 if (ac.Get("DigitAlgConfig", tmpcs)) digitalgconfig = tmpcs;
00091
00092
00093 #ifdef ENABLE_DEBUG_MSG
00094 MSG("AlgDigitList", Msg::kDebug)
00095 << "AlgHandle ah = af.GetAlgHandle("
00096 << digitalgorithm << ", "
00097 << digitalgconfig << ");" << endl;
00098 #endif
00099 AlgHandle ah = af.GetAlgHandle(digitalgorithm, digitalgconfig);
00100
00101 #ifdef ENABLE_DEBUG_MSG
00102 MSG("AlgDigitList", Msg::kDebug)
00103 << "Create CandContext instance." << endl
00104 << "CandContext cxx(this);" << endl;
00105 #endif
00106 CandContext cxx(this, cx.GetMom());
00107
00108
00109 #ifdef ENABLE_DEBUG_MSG
00110 MSG("AlgDigitList", Msg::kDebug)
00111 << "Set CandRecord pointer in CandContext." << endl;
00112 #endif
00113 cxx.SetCandRecord(cx.GetCandRecord());
00114
00115 Bool_t isSparse = true;
00116
00117
00118 RawRecord *rr = (RawRecord *) (cx.GetDataIn());
00119 TIter rdbit = rr->GetRawBlockIter();
00120 TObject *tob;
00121 while ((tob = rdbit())) {
00122 if (tob->InheritsFrom("RawDigitDataBlock")) {
00123 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00124 TIter rdit = rdb->GetDatumIter();
00125 RawDigit *rd;
00126 Int_t rawdigitindex = -1;
00127
00128 Int_t ndigits = rdb->GetNumberOfDigits();
00129 Bool_t blkIsSparse =
00130 ( rdb->GetNumberOfCrates() == rdb->GetNSparsModeCrates());
00131 isSparse &= blkIsSparse;
00132 if (!blkIsSparse)
00133 MSG("AlgDigitList", Msg::kInfo)
00134 << "AlgDigitList finds RawDigitDataBlock is Unsparsified with "
00135 << ndigits << " digits " << endl << endl;
00136
00137 while ((rd = (RawDigit *) rdit())) {
00138 ++rawdigitindex;
00139
00140 #ifdef ENABLE_DEBUG_MSG
00141 MSG("AlgDigitList", Msg::kDebug)
00142 << "Set RawDigit object as CandContext input data." << endl
00143 << "cxx.SetDataIn(rd);" << endl;
00144 #endif
00145
00146 #ifdef ONLYSCINT
00147
00148 if (ph.GetReadoutType(rd->GetChannel()) !=
00149 ReadoutType::kScintStrip) continue;
00150 #endif
00151
00152 cxx.SetDataIn(rd);
00153
00154 #ifdef ENABLE_DEBUG_MSG
00155 MSG("AlgDigitList", Msg::kDebug)
00156 << "Get handle to CandDigit." << endl
00157 << "cdh = CandDigit::MakeCandidate(ah, cxx);" << endl;
00158 #endif
00159
00160 CandDigitHandle cdh = CandDigit::MakeCandidate(ah, cxx);
00161 cdh.SetRawDigitIndex(rawdigitindex);
00162
00163 ch.AddDaughterLink(cdh, kFALSE);
00164 }
00165 }
00166 }
00167
00168
00169
00170 CandDigitListHandle &cdlh =
00171 dynamic_cast<CandDigitListHandle &>(ch);
00172 cdlh.SetAbsTime(((Double_t) vldc.GetTimeStamp().GetNanoSec()) *
00173 Munits::nanosecond);
00174
00175
00176 cdlh.SetIsSparse(isSparse);
00177 }
00178
00179 else if (cx.GetDataIn()->InheritsFrom("TCollection")) {
00180 TCollection *cdl = (TCollection *) cx.GetDataIn();
00181 TIter cdit(cdl);
00182 CandDigitHandle *cdh;
00183 while ((cdh = (CandDigitHandle *) cdit())) {
00184 ch.AddDaughterLink(*cdh, kFALSE);
00185 }
00186 }
00187 }
00188
00189
00190 void AlgDigitList::Trace(const char * ) const
00191 {
00192 }