00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include <cassert>
00012
00013 #include "Calibrator/Calibrator.h"
00014 #include "CandData/CandRecord.h"
00015 #include "CandDigit/AlgMCDigit.h"
00016 #include "CandDigit/CandDigitHandle.h"
00017 #include "Candidate/CandContext.h"
00018 #include "Conventions/Munits.h"
00019 #include "MessageService/MsgService.h"
00020 #include "Plex/PlexHandle.h"
00021 #include "Plex/PlexSEIdAltL.h"
00022 #include "RawData/RawChannelId.h"
00023 #include "RawData/RawHeader.h"
00024 #include "RawData/RawRecord.h"
00025 #include "RawData/RawQieMCDigit.h"
00026 #include "RawData/RawVaMCDigit.h"
00027 #include "Validity/VldContext.h"
00028
00029 ClassImp(AlgMCDigit)
00030
00031
00032 CVSID("$Id: AlgMCDigit.cxx,v 1.19 2005/04/08 12:26:29 tagg Exp $");
00033
00034
00035 AlgMCDigit::AlgMCDigit()
00036 {
00037 }
00038
00039
00040 AlgMCDigit::~AlgMCDigit()
00041 {
00042 }
00043
00044
00045 void AlgMCDigit::RunAlg(AlgConfig & , CandHandle &ch,
00046 CandContext &cx)
00047 {
00048 MSG("Alg", Msg::kDebug) << "Starting AlgMCDigit::RunAlg()" << endl;
00049 const Calibrator& cal = Calibrator::Instance();
00050
00051 assert(ch.InheritsFrom("CandDigitHandle"));
00052 CandDigitHandle &cdh = (CandDigitHandle &) ch;
00053
00054 const RawDigit *digit =
00055 dynamic_cast<const RawDigit *> (cx.GetDataIn());
00056 assert(digit);
00057
00058 const RawChannelId digitRCId = digit->GetChannel();
00059
00060
00061 const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00062
00063
00064 cdh.SetChannelId(digitRCId);
00065
00066
00067 Double_t adc_offset = 0.;
00068 if (digitRCId.GetElecType()==ElecType::kQIE) {
00069 adc_offset = 50.;
00070 cdh.SetQieErrorBits(digit->GetErrorCode());
00071 }
00072 else
00073 cdh.SetVaErrorBits(digit->GetErrorCode());
00074
00075
00076 cdh.SetCharge(((Double_t) digit->GetADC()) - adc_offset);
00077
00078
00079 Double_t t = cal.GetTimeFromTDC(digit->GetTDC(), digitRCId);
00080
00081
00082 t += (digit->GetCrateT0()).GetNanoSec() * Munits::ns;
00083
00084
00085
00086
00087
00088 t += ( (digit->GetCrateT0()).GetSec() -
00089 (vldc.GetTimeStamp()).GetSec() ) * Munits::s;
00090
00091 #ifdef ENABLE_DEBUG_MSG
00092 MSG("Alg", Msg::kDebug) << "rdid = " << digitRCId << endl
00093 << " tdc = " << digit->GetTDC() << " nsec = "
00094 << cal.GetTimeFromTDC(digit->GetTDC(),
00095 digitRCId) << " t = " << t << endl << " CrT0_ns = "
00096 << (digit->GetCrateT0()).GetNanoSec()*Munits::ns
00097 << " CrT0_s = " << (digit->GetCrateT0()).GetSec()
00098 << " TrigTime_s = " << (vldc.GetTimeStamp()).GetSec() << endl;
00099 #endif
00100
00101 cdh.SetTime(t);
00102
00103
00104 PlexHandle ph(vldc);
00105
00106
00107 PlexSEIdAltL altlist =
00108 ph.GetSEIdAltL(digitRCId, &cal,
00109 (int)(digit->GetADC()-adc_offset), cdh.GetTime());
00110 altlist.ClearWeights();
00111 altlist.DropZeroWeights();
00112
00113 const RawMCDigitMixIn *truthDigit =
00114 dynamic_cast<const RawMCDigitMixIn*>(digit);
00115 if (truthDigit) {
00116 PlexStripEndId seid(truthDigit->GetTrueSEIdEncoded());
00117 PlexPixelSpotId spotid = ph.GetPixelSpotId(seid);
00118 altlist.AddStripEndId(seid,spotid,1.0);
00119 }
00120
00121 cdh.SetPlexSEIdAltL(altlist);
00122 }
00123
00124
00125 void AlgMCDigit::Trace(const char * ) const
00126 {
00127 }