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

AlgMCDigit.cxx

Go to the documentation of this file.
00001 
00002 // $Id: AlgMCDigit.cxx,v 1.19 2005/04/08 12:26:29 tagg Exp $
00003 //
00004 // AlgMCDigit.cxx
00005 //
00006 // AlgMCDigit is a concrete MCDigit Algorithm class.
00007 //
00008 // Author:  G. Irwin 4/2000
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 & /* ac */, 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 // Get VldContext
00061    const VldContext &vldc = *(cx.GetCandRecord()->GetVldContext());
00062 
00063 // Use CandDigitHandle methods to set CandDigit member variables.
00064    cdh.SetChannelId(digitRCId);
00065 
00066 // Take off a 50 ADC offset from QIE channels.
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 // Set charge to offset-subtracted ADC value ( ~60. * p.e. )
00076    cdh.SetCharge(((Double_t) digit->GetADC()) - adc_offset);
00077 
00078 // Convert TDC counts to Double_t.  Don't subtract Trigger time offset.
00079    Double_t t = cal.GetTimeFromTDC(digit->GetTDC(), digitRCId);
00080 
00081 // Add CrateT0
00082    t += (digit->GetCrateT0()).GetNanoSec() * Munits::ns;
00083 
00084 // And account for snarls overlapping 1 sec boundary.
00085 // This assumes that the crate t0 is the t0 coresponding to the hit.
00086 // t now be <0 or >1
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 // Get a PlexHandle for PlexStripEndId to RawChannelId conversions
00104    PlexHandle ph(vldc);
00105 
00106 // Fill and calibrate PlexSEIdAltL
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 * /* c */) const
00126 {
00127 }

Generated on Mon Feb 15 11:06:19 2010 for loon by  doxygen 1.3.9.1