00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #include "Algorithm/AlgHandle.h"
00016 #include "CandDigit/CandDigit.h"
00017 #include "CandDigit/CandDigitHandle.h"
00018 #include "MessageService/MsgService.h"
00019 #include "MessageService/MsgFormat.h"
00020
00021 ClassImp(CandDigit)
00022
00023
00024
00025
00026
00027
00028 static int CandDigitPlexListInEquivTestState = 1;
00029
00030 void SetCandDigitPlexListInEquivTestState(int state){
00031 CandDigitPlexListInEquivTestState = state;
00032 }
00033
00034 int GetCandDigitPlexListInEquivTestState()
00035 {
00036 return CandDigitPlexListInEquivTestState;
00037 }
00038
00039
00040 CVSID("$Id: CandDigit.cxx,v 1.12 2008/05/09 14:52:28 boehm Exp $");
00041
00042 #include "Candidate/CandBase.tpl"
00043
00044
00045 CandDigit::CandDigit() :
00046 fRawDigitIndex(-1)
00047 , fVaErrorBits(0)
00048 , fQieErrorBits(0)
00049 {
00050
00051 MSG("Cand", Msg::kDebug)
00052 << "Begin CandDigit::CandDigit() ctor: " << endl
00053 << "UidInt = " << GetUidInt()
00054 << ", ArchUidInt " << GetArchUidInt() << endl
00055 << "No. of links = " << GetNLinks() << endl
00056 << "End CandDigit::CandDigit() ctor." << endl;
00057 }
00058
00059
00060 CandDigit::CandDigit(AlgHandle &ah) :
00061 CandBase(ah)
00062 , fRawDigitIndex(-1)
00063 , fVaErrorBits(0)
00064 , fQieErrorBits(0)
00065 {
00066
00067
00068
00069
00070
00071
00072
00073 }
00074
00075
00076 CandDigit::CandDigit(AlgHandle &ah, CandHandle &ch, CandContext &cx) :
00077 CandBase(ah)
00078 , fRawDigitIndex(-1)
00079 , fVaErrorBits(0)
00080 , fQieErrorBits(0)
00081 {
00082 CreateLocalHandle();
00083
00084 #ifdef ENABLE_DEBUG_MSG
00085 MSG("Cand", Msg::kDebug)
00086 << "Begin CandDigit::CandDigit(AlgHandle &, CandHandle &, "
00087 << "CandContext &) ctor: " << endl
00088 << "UidInt = " << GetUidInt()
00089 << ", ArchUidInt " << GetArchUidInt() << endl
00090 << "No. of links = " << GetNLinks() << endl
00091 << "End CandDigit::CandDigit(AlgHandle &, CandHandle &, "
00092 << "CandContext &) ctor." << endl;
00093 #endif
00094
00095
00096 {
00097 CandDigitHandle cdh(this);
00098 ch = cdh;
00099 }
00100 ah.RunAlg(ch, cx);
00101 }
00102
00103
00104 CandDigit::CandDigit(const CandDigit &rhs) :
00105 CandBase(rhs)
00106 , fChannelId(rhs.fChannelId)
00107 , fCharge(rhs.fCharge)
00108 , fPlexSEIdAltL(rhs.fPlexSEIdAltL)
00109 , fRawDigitIndex(rhs.fRawDigitIndex)
00110 , fTime(rhs.fTime)
00111 , fVaErrorBits(rhs.fVaErrorBits)
00112 , fQieErrorBits(rhs.fQieErrorBits)
00113 {
00114
00115
00116 #ifdef ENABLE_DEBUG_MSG
00117 MSG("Cand", Msg::kDebug)
00118 << "Begin CandDigit::CandDigit(const CandDigit &rhs) ctor: " << endl
00119 << "UidInt = " << GetUidInt()
00120 << ", ArchUidInt " << GetArchUidInt() << endl
00121 << "No. of links = " << GetNLinks() << endl
00122 << "End CandDigit::CandDigit(const CandDigit &rhs) ctor." << endl;
00123 #endif
00124 }
00125
00126
00127 CandDigit::~CandDigit()
00128 {
00129 #ifdef ENABLE_DEBUG_MSG
00130 MSG("Cand", Msg::kDebug)
00131 << "Begin CandDigit::~CandDigit() dtor: " << endl
00132 << "UidInt = " << GetUidInt()
00133 << ", ArchUidInt " << GetArchUidInt() << endl
00134 << "No. of links = " << GetNLinks() << endl
00135 << "End CandDigit::~CandDigit() dtor." << endl;
00136 #endif
00137 }
00138
00139
00140 void CandDigit::CreateLocalHandle()
00141 {
00142 SetLocalHandle(new CandDigitHandle(this));
00143 }
00144
00145
00146 CandDigit *CandDigit::Dup() const
00147 {
00148
00149
00150
00151
00152
00153 CandDigit *cb = new CandDigit(*this);
00154 cb->CreateLocalHandle();
00155 TIter iterdau = GetDaughterIterator();
00156 CandHandle *dau;
00157 while ((dau=(CandHandle *) iterdau())) cb->AddDaughterLink(*dau);
00158 return cb;
00159 }
00160
00161
00162 Bool_t CandDigit::IsEquivalent(const TObject *rhs) const
00163 {
00164 Bool_t result = true;
00165 if (!CandBase::IsEquivalent(rhs)) result = false;
00166 TestDisplayCandBanner("CandDigit");
00167 const CandDigit* rCnd = dynamic_cast<const CandDigit*>(rhs);
00168 if (rCnd == NULL) return false;
00169
00170 result = TestEquality("fChannelId", this->fChannelId,
00171 rCnd->fChannelId) && result;
00172 result = TestEquality("fCharge", this->fCharge,
00173 rCnd->fCharge) && result;
00174
00175 if(CandDigitPlexListInEquivTestState == 1){
00176 result = TestEquality("fPlexSEIdAltL",
00177 this->fPlexSEIdAltL,
00178 rCnd->fPlexSEIdAltL) && result;
00179 }
00180 if(CandDigitPlexListInEquivTestState == 2){
00181
00182
00183 bool match = false;
00184 if(rCnd->fPlexSEIdAltL.size() == 1){
00185 PlexSEIdAltLItem best = rCnd->fPlexSEIdAltL.GetBestItem();
00186 for(unsigned int i = 0; i < this->fPlexSEIdAltL.size(); i++){
00187 const PlexSEIdAltLItem& item = this->fPlexSEIdAltL[i];
00188 if(item == best) match = true;
00189 }
00190 }
00191 result = match && result;
00192 }
00193
00194 result = TestEquality("fRawDigitIndex",
00195 this->fRawDigitIndex,
00196 rCnd->fRawDigitIndex) && result;
00197 result = TestEquality("fTime", this->fTime,
00198 rCnd->fTime) && result;
00199 result = TestEquality("fVaErrorBits", this->fVaErrorBits,
00200 rCnd->fVaErrorBits) && result;
00201 result = TestEquality("fQieErrorBits",this->fQieErrorBits,
00202 rCnd->fQieErrorBits) && result;
00203 return result;
00204 }
00205
00206
00207 CandDigitHandle CandDigit::MakeCandidate(AlgHandle &ah, CandContext &cx)
00208 {
00209 CandDigitHandle cdh;
00210 new CandDigit(ah, cdh, cx);
00211 return cdh;
00212 }
00213
00214
00215 std::ostream& CandDigit::FormatToOStream(std::ostream& os,
00216 Option_t *option) const
00217 {
00218 CandBase::FormatToOStream(os,option);
00219
00220 TString opt(option);
00221 if (!opt.Contains("v0")) {
00222 const TString& indent = GetIndentString();
00223
00224 static MsgFormat qfmt("f7.1");
00225 static MsgFormat indxfmt("i6");
00226 static MsgFormat timefmt("f10.9");
00227 os << indent << GetDataIndent()
00228 << "[" << indxfmt(fRawDigitIndex) << "] "
00229 << fChannelId
00230 << " Q=" << qfmt(fCharge)
00231 << " Time " << timefmt(fTime);
00232 if ( fVaErrorBits || fQieErrorBits ) {
00233 os << hex << setfill('0');
00234
00235
00236
00237 if ( fVaErrorBits ) os << " VaErr 0x" << setw(2) << (short)fVaErrorBits;
00238 if ( fQieErrorBits ) os << " QieErr 0x" << setw(2) << (short)fQieErrorBits;
00239 os << dec << setfill(' ');
00240 }
00241 os << endl;
00242
00243 }
00244 return os;
00245
00246 }
00247
00248