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/AlgMCDigitList.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 ClassImp(AlgMCDigitList)
00034
00035
00036 CVSID("$Id: AlgMCDigitList.cxx,v 1.12 2003/03/29 01:26:13 gmieg Exp $");
00037
00038
00039 AlgMCDigitList::AlgMCDigitList()
00040 {
00041 }
00042
00043
00044 AlgMCDigitList::~AlgMCDigitList()
00045 {
00046 }
00047
00048
00049 void AlgMCDigitList::RunAlg(AlgConfig &ac, CandHandle &ch,
00050 CandContext &cx)
00051 {
00052 MSG("AlgMCDigitList", Msg::kDebug)
00053 << "Starting AlgMCDigitList::RunAlg()" << endl;
00054
00055 assert(cx.GetDataIn());
00056
00057
00058 const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00059
00060
00061 if (cx.GetDataIn()->InheritsFrom("RawRecord")) {
00062
00063
00064
00065
00066 MSG("AlgMCDigitList", Msg::kDebug)
00067 << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00068 AlgFactory &af = AlgFactory::GetInstance();
00069
00070
00071 const char *tmpcs = 0;
00072 const char *mcdigitalgorithm = 0;
00073 const char *mcdigitalgconfig = 0;
00074
00075 if (ac.Get("MCDigitAlgorithm", tmpcs)) mcdigitalgorithm = tmpcs;
00076 if (ac.Get("MCDigitAlgConfig", tmpcs)) mcdigitalgconfig = tmpcs;
00077
00078
00079 MSG("AlgMCDigitList", Msg::kDebug)
00080 << "AlgHandle ah = af.GetAlgHandle("
00081 << mcdigitalgorithm << ", "
00082 << mcdigitalgconfig << ");" << endl;
00083 AlgHandle ah = af.GetAlgHandle(mcdigitalgorithm, mcdigitalgconfig);
00084
00085 MSG("AlgMCDigitList", Msg::kDebug)
00086 << "Create CandContext instance." << endl
00087 << "CandContext cxx(this);" << endl;
00088 CandContext cxx(this, cx.GetMom());
00089
00090
00091 MSG("AlgMCDigitList", Msg::kDebug)
00092 << "Set CandRecord pointer in CandContext." << endl;
00093 cxx.SetCandRecord(cx.GetCandRecord());
00094
00095
00096 RawRecord *rr = (RawRecord *) (cx.GetDataIn());
00097 TIter rdbit = rr->GetRawBlockIter();
00098 TObject *tob;
00099 while ((tob = rdbit())) {
00100 if (tob->InheritsFrom("RawDigitDataBlock")) {
00101 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00102 TIter rdit = rdb->GetDatumIter();
00103 RawDigit *rd;
00104 Int_t rawdigitindex = -1;
00105 while ((rd = (RawDigit *) rdit())) {
00106 ++rawdigitindex;
00107
00108 MSG("AlgMCDigitList", Msg::kDebug)
00109 << "Set RawDigit object as CandContext input data." << endl
00110 << "cxx.SetDataIn(rd);" << endl;
00111 cxx.SetDataIn(rd);
00112
00113 MSG("AlgMCDigitList", Msg::kDebug)
00114 << "Get handle to CandDigit." << endl
00115 << "cdh = CandDigit::MakeCandidate(ah, cxx);" << endl;
00116
00117 CandDigitHandle cdh = CandDigit::MakeCandidate(ah, cxx);
00118 cdh.SetRawDigitIndex(rawdigitindex);
00119
00120 ch.AddDaughterLink(cdh, kFALSE);
00121 }
00122 }
00123 }
00124
00125
00126
00127 CandDigitListHandle &cdlh =
00128 dynamic_cast<CandDigitListHandle &>(ch);
00129 cdlh.SetAbsTime(((Double_t) vldc.GetTimeStamp().GetNanoSec()) *
00130 Munits::nanosecond);
00131 }
00132
00133 else if (cx.GetDataIn()->InheritsFrom("TCollection")) {
00134 TCollection *cdl = (TCollection *) cx.GetDataIn();
00135 TIter cdit(cdl);
00136 CandDigitHandle *cdh;
00137 while ((cdh = (CandDigitHandle *) cdit())) {
00138 ch.AddDaughterLink(*cdh, kFALSE);
00139 }
00140 }
00141 }
00142
00143
00144 void AlgMCDigitList::Trace(const char * ) const
00145 {
00146 }