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

CandDigit.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CandDigit.cxx,v 1.12 2008/05/09 14:52:28 boehm Exp $
00003 //
00004 // CandDigit.cxx
00005 //
00006 // This is a concrete Event Candidate (Reconstruction) object.
00007 // CandDigit is descended from CandBase.
00008 //
00009 // Each concrete CandBase must define a Dup function.
00010 // CandBase must grant friendship to class CandRefer.
00011 //
00012 // Author:  G. Irwin 1/2000
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 // New variable to control the ability to compare a demux and 
00024 // standard digit list
00025 // 0 - no check on the plex list is made
00026 // 1 - standard check on plex list
00027 // 2 - look for digit in full demuxed list
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 //CreateLocalHandle();       // LocalHandle is now furnished by Streamer
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)       // Should be the next class up on inheritance chain
00062 , fRawDigitIndex(-1)
00063 , fVaErrorBits(0)
00064 , fQieErrorBits(0)
00065 {
00066 
00067 // The sole purpose of this constructor is to transmit the AlgHandle
00068 // up the inheritance chain to CandBase without having to invoke the
00069 // full constructor of an intermediate Candidate type which the highest
00070 // level Candidate might inherit from.  One only wants to create the
00071 // LocalHandle and invoke the RunAlg() method in the lowest level class.
00072 
00073 }
00074 
00075 //______________________________________________________________________
00076 CandDigit::CandDigit(AlgHandle &ah, CandHandle &ch, CandContext &cx) :
00077   CandBase(ah)       // Should be the next class up on inheritance chain
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 // Run Algorithm to construct Candidate
00096    {                                         // Start of scope.
00097      CandDigitHandle cdh(this);              // cdh will go out of scope
00098      ch = cdh;                               // after setting ch.
00099    }                                         // End of scope.
00100    ah.RunAlg(ch, cx);
00101 }
00102 
00103 //______________________________________________________________________
00104 CandDigit::CandDigit(const CandDigit &rhs) :
00105   CandBase(rhs)      // Should be the next class up on inheritance chain
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 //CreateLocalHandle(); // Moved to Dup function following copy-ctor call
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 // Base copy ctor dups owned pointers, but defers copying Daughter List.
00150 // Daughter List copy is made in the derived class Dup() function.
00151 // This is because base class copy constructor hasn't yet created
00152 // fLocalHandle with a CandHandle* of the full derived type.
00153   CandDigit *cb = new CandDigit(*this);           // Copy-ctor dups ptrs
00154   cb->CreateLocalHandle();   // Initializes fLocalHandle after copy-ctor
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;   // superclass test
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     //Highly specific to a Nue search matching a demux digit against
00182     // an original digit
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);              // cdh owns the new CandDigit
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")) { // v0 means suppress the data values
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'); // prepare for hex words
00234       // the error bits are of type Char_t, but we want them interpreted 
00235       // as int-like values (rather than as ASCII chars) so we cast them 
00236       // to something larger
00237       if ( fVaErrorBits )  os << " VaErr  0x" << setw(2) << (short)fVaErrorBits;
00238       if ( fQieErrorBits ) os << " QieErr 0x" << setw(2) << (short)fQieErrorBits;
00239       os << dec << setfill(' '); // done with hex words
00240     }
00241     os << endl;
00242     //fPlexSEIdAltL.Print("C");
00243   }
00244   return os;
00245   
00246 }
00247 
00248 //______________________________________________________________________

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