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

CandCluster.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CandCluster.cxx,v 1.13 2005/02/02 11:38:35 tagg Exp $
00003 //
00004 // CandCluster.cxx
00005 //
00006 // This is a concrete Event Candidate (Reconstruction) object.
00007 // CandCluster 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:  R. Lee
00014 
00015 #include "TClass.h"
00016 
00017 #include "Algorithm/AlgHandle.h"
00018 #include "MessageService/MsgService.h"
00019 #include "MessageService/MsgFormat.h"
00020 #include "RecoBase/CandCluster.h"
00021 #include "RecoBase/CandClusterHandle.h"
00022 #include "RecoBase/CandSliceHandle.h"  // Needed for IsEquivalent method
00023 
00024 ClassImp(CandCluster)
00025 
00026 //______________________________________________________________________
00027 CVSID("$Id: CandCluster.cxx,v 1.13 2005/02/02 11:38:35 tagg Exp $");
00028 
00029 #include "Candidate/CandBase.tpl"
00030 
00031 //______________________________________________________________________
00032 CandCluster::CandCluster() :
00033   fCandSlice(0),
00034   fTrackLike(0),
00035   fShowerLike(0)
00036 {
00037   MSG("Cand", Msg::kDebug)
00038                     << "Begin CandCluster::CandCluster() ctor: " << endl
00039                                            << "UidInt = " << GetUidInt()
00040                            << ", ArchUidInt " << GetArchUidInt() << endl
00041                              << "No. of links = " << GetNLinks() << endl
00042                       << "End CandCluster::CandCluster() ctor." << endl;
00043 }
00044 
00045 //______________________________________________________________________
00046 CandCluster::CandCluster(AlgHandle &ah) :
00047   CandBase(ah),       // Should be the next class up on inheritance chain
00048   fCandSlice(0),
00049   fTrackLike(0),
00050   fShowerLike(0)
00051 {
00052 
00053 // The sole purpose of this constructor is to transmit the AlgHandle
00054 // up the inheritance chain to CandBase without having to invoke the
00055 // full constructor of an intermediate Candidate type which the highest
00056 // level Candidate might inherit from.  One only wants to create the
00057 // LocalHandle and invoke the RunAlg() method in the lowest level class.
00058 }
00059 
00060 //______________________________________________________________________
00061 CandCluster::CandCluster(AlgHandle &ah, CandHandle &ch,
00062                                                       CandContext &cx) :
00063   CandBase(ah),       // Should be the next class up on inheritance chain
00064   fCandSlice(0),
00065   fTrackLike(0),
00066   fShowerLike(0)
00067 {
00068   CreateLocalHandle();
00069   MSG("Cand", Msg::kDebug)
00070          << "Begin CandCluster::CandCluster(AlgHandle &, CandHandle &, "
00071                                       << "CandContext &) ctor: " << endl
00072                                            << "UidInt = " << GetUidInt()
00073                            << ", ArchUidInt " << GetArchUidInt() << endl
00074                              << "No. of links = " << GetNLinks() << endl
00075            << "End CandCluster::CandCluster(AlgHandle &, CandHandle &, "
00076                                       << "CandContext &) ctor." << endl;
00077 
00078 // Run Algorithm to construct Candidate
00079    {                                                  // Start of scope.
00080      CandClusterHandle cdh(this);            // cdh will go out of scope
00081      ch = cdh;                                      // after setting ch.
00082    }                                                    // End of scope.
00083    ah.RunAlg(ch, cx);
00084 }
00085 
00086 //______________________________________________________________________
00087 CandCluster::CandCluster(const CandCluster &rhs) :
00088   CandBase(rhs),      // Should be the next class up on inheritance chain
00089   fCandSlice(0),
00090   fTrackLike(rhs.fTrackLike),
00091   fShowerLike(rhs.fShowerLike)
00092 {
00093 
00094 //CreateLocalHandle(); // Moved to Dup function following copy-ctor call
00095   MSG("Cand", Msg::kDebug)
00096       << "Begin CandCluster::CandCluster(const CandCluster &rhs) ctor: "
00097                                                                  << endl
00098                                            << "UidInt = " << GetUidInt()
00099                            << ", ArchUidInt " << GetArchUidInt() << endl
00100                              << "No. of links = " << GetNLinks() << endl
00101          << "End CandCluster::CandCluster(const CandCluster &rhs) ctor."
00102                                                                 << endl;
00103 
00104   if (rhs.fCandSlice)                       // Make an owned CandHandle*
00105     fCandSlice = (rhs.fCandSlice)->DupHandle();
00106 
00107 }
00108 
00109 //______________________________________________________________________
00110 CandCluster::~CandCluster()
00111 {
00112   MSG("Cand", Msg::kDebug)
00113                    << "Begin CandCluster::~CandCluster() dtor: " << endl
00114                                            << "UidInt = " << GetUidInt()
00115                            << ", ArchUidInt " << GetArchUidInt() << endl
00116                              << "No. of links = " << GetNLinks() << endl
00117                      << "End CandCluster::~CandCluster() dtor." << endl;
00118 
00119 // fCandSlice is an owned CandHandle* starting at CandCluster version 2
00120    delete fCandSlice;
00121 }
00122 
00123 //______________________________________________________________________
00124 void CandCluster::CreateLocalHandle()
00125 {
00126   SetLocalHandle(new CandClusterHandle(this));
00127 }
00128 
00129 //______________________________________________________________________
00130 CandCluster *CandCluster::Dup() const
00131 {
00132 
00133 // Base copy ctor dups owned pointers, but defers copying Daughter List.
00134 // Daughter List copy is made in the derived class Dup() function.
00135 // This is because base class copy constructor hasn't yet created
00136 // fLocalHandle with a CandHandle* of the full derived type.
00137   CandCluster *cb = new CandCluster(*this);       // Copy-ctor dups ptrs
00138   cb->CreateLocalHandle();   // Initializes fLocalHandle after copy-ctor
00139   cb->SetCandRecord(fCandRecord);
00140   TIter iterdau = GetDaughterIterator();
00141   CandHandle *dau;
00142   while ((dau=(CandHandle *) iterdau())) cb->AddDaughterLink(*dau);
00143   return cb;
00144 }
00145 
00146 //______________________________________________________________________
00147 Bool_t CandCluster::IsEquivalent(const TObject *rhs) const
00148 {
00149   Bool_t result = true;
00150   if (!CandBase::IsEquivalent(rhs)) result = false;   // superclass test
00151   TestDisplayCandBanner("CandCluster");
00152   const CandCluster* rCnd = dynamic_cast<const CandCluster*>(rhs);
00153   if (rCnd == NULL) return false;
00154 
00155   result = TestCandHandleDup("fCandSlice", this->fCandSlice,
00156                              rCnd->fCandSlice) && result;
00157   result = TestEquality("fTrackLike", this->fTrackLike, 
00158                         rCnd->fTrackLike)   && result;
00159   
00160   result = TestEquality("fShowerLike", this->fShowerLike,
00161                         rCnd->fShowerLike) && result; 
00162   return result;
00163 }
00164 
00165 //______________________________________________________________________
00166 CandClusterHandle CandCluster::MakeCandidate(AlgHandle &ah,
00167                                                         CandContext &cx)
00168 {
00169   CandClusterHandle cdh;
00170   new CandCluster(ah, cdh, cx);          // cdh owns the new CandCluster
00171   return cdh;
00172 }
00173 
00174 //______________________________________________________________________
00175 std::ostream& CandCluster::FormatToOStream(std::ostream& os,
00176                                            Option_t *option) const
00177 {
00178   CandBase::FormatToOStream(os,option);
00179 
00180 
00181   TString opt(option);
00182   if (!opt.Contains("v0")) { // v0 means suppress the data values
00183     const TString& indent = GetIndentString();
00184 
00185     os << indent << GetDataIndent()
00186        << "TrackLike=" << (fTrackLike?"true":"false")
00187        << " ShowerLike=" << (fShowerLike?"true":"false")
00188        << endl;
00189   }
00190   return os;
00191   
00192 }
00193 
00194 //______________________________________________________________________
00195 void CandCluster::Streamer(TBuffer &R__b)
00196 {
00197 
00198 // Stream an object of class CandCluster.
00199   if (R__b.IsReading()) {
00200     UInt_t R__s, R__c;
00201     Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
00202     CandCluster::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
00203     if (R__v < 2) {
00204       if (fCandSlice) fCandSlice = fCandSlice->DupHandle();
00205     }
00206   }
00207   else {
00208     CandCluster::Class()->WriteBuffer(R__b, this);
00209   }
00210 }
00211 
00212 //______________________________________________________________________

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