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

CandTrack.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CandTrack.cxx,v 1.20 2006/08/03 18:09:13 musser Exp $
00003 //
00004 // CandTrack.cxx
00005 //
00006 // This is a concrete Event Candidate (Reconstruction) object.
00007 // CandTrack is descended from CandReco.
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 "Algorithm/AlgHandle.h"
00016 #include "MessageService/MsgService.h"
00017 #include "MessageService/MsgFormat.h"
00018 #include "RecoBase/CandStrip.h"
00019 #include "RecoBase/CandStripHandle.h"
00020 #include "RecoBase/CandTrack.h"
00021 #include "RecoBase/CandTrackHandle.h"
00022 
00023 ClassImp(CandTrack)
00024 
00025 //______________________________________________________________________
00026 CVSID("$Id: CandTrack.cxx,v 1.20 2006/08/03 18:09:13 musser Exp $");
00027 
00028 #include "Candidate/CandBase.tpl"
00029 
00030 //______________________________________________________________________
00031 CandTrack::CandTrack() :
00032   fMomentum(0.),
00033   fVtxTrace(0.),
00034   fVtxTraceZ(0.),
00035   fEndTrace(0.),
00036   fEndTraceZ(0.),
00037   fVtxDistToEdge(0.),
00038   fEndDistToEdge(0.),
00039   fVtxnActiveUpstream(0),
00040   fEndnActiveDownstream(0),
00041   fNTrackStrip(0),
00042   fNTrackDigit(0),
00043   fNTimeFitDigit(0),
00044   fTimeFitChi2(0.),
00045   fTimeForwardFitRMS(0.),
00046   fTimeForwardFitNDOF(0),
00047   fTimeBackwardFitRMS(0.),
00048   fTimeBackwardFitNDOF(0)
00049 {
00050   MSG("Cand", Msg::kDebug)
00051                         << "Begin CandTrack::CandTrack() ctor: " << endl
00052                                            << "UidInt = " << GetUidInt()
00053                            << ", ArchUidInt " << GetArchUidInt() << endl
00054                              << "No. of links = " << GetNLinks() << endl
00055                           << "End CandTrack::CandTrack() ctor." << endl;
00056 }
00057 
00058 //______________________________________________________________________
00059 CandTrack::CandTrack(AlgHandle &ah) :
00060   CandReco(ah),      // Should be the next class up on inheritance chain
00061   fMomentum(0.),
00062   fVtxTrace(0.),
00063   fVtxTraceZ(0.),
00064   fEndTrace(0.),
00065   fEndTraceZ(0.),
00066   fVtxDistToEdge(0.),
00067   fEndDistToEdge(0.),
00068   fVtxnActiveUpstream(0),
00069   fEndnActiveDownstream(0),
00070   fNTrackStrip(0),
00071   fNTrackDigit(0),
00072   fNTimeFitDigit(0),
00073   fTimeFitChi2(0.),
00074   fTimeForwardFitRMS(0.),
00075   fTimeForwardFitNDOF(0),
00076   fTimeBackwardFitRMS(0.),
00077   fTimeBackwardFitNDOF(0)
00078 
00079 {
00080 
00081 // The sole purpose of this constructor is to transmit the AlgHandle
00082 // up the inheritance chain to CandBase without having to invoke the
00083 // full constructor of an intermediate Candidate type which the highest
00084 // level Candidate might inherit from.  One only wants to create the
00085 // LocalHandle and invoke the RunAlg() method in the lowest level class.
00086 }
00087 
00088 //______________________________________________________________________
00089 CandTrack::CandTrack(AlgHandle &ah, CandHandle &ch, CandContext &cx) :
00090   CandReco(ah),      // Should be the next class up on inheritance chain
00091   fMomentum(0.),
00092   fVtxTrace(0.),
00093   fVtxTraceZ(0.),
00094   fEndTrace(0.),
00095   fEndTraceZ(0.),
00096   fVtxDistToEdge(0.),
00097   fEndDistToEdge(0.),
00098   fVtxnActiveUpstream(0),
00099   fEndnActiveDownstream(0),
00100   fNTrackStrip(0),
00101   fNTrackDigit(0),
00102   fNTimeFitDigit(0),
00103   fTimeFitChi2(0.),
00104   fTimeForwardFitRMS(0.),
00105   fTimeForwardFitNDOF(0),
00106   fTimeBackwardFitRMS(0.),
00107   fTimeBackwardFitNDOF(0)
00108 
00109 {
00110   CreateLocalHandle();
00111   MSG("Cand", Msg::kDebug)
00112              << "Begin CandTrack::CandTrack(AlgHandle &, CandHandle &, "
00113                                       << "CandContext &) ctor: " << endl
00114                                            << "UidInt = " << GetUidInt()
00115                            << ", ArchUidInt " << GetArchUidInt() << endl
00116                              << "No. of links = " << GetNLinks() << endl
00117                << "End CandTrack::CandTrack(AlgHandle &, CandHandle &, "
00118                                       << "CandContext &) ctor." << endl;
00119 
00120 // Run Algorithm to construct Candidate
00121   {                                                   // Start of scope.
00122     CandTrackHandle csh(this);               // csh will go out of scope
00123     ch = csh;                                       // after setting ch.
00124   }                                                     // End of scope.
00125   ah.RunAlg(ch, cx);
00126 }
00127 
00128 //______________________________________________________________________
00129 CandTrack::CandTrack(const CandTrack &rhs) :
00130   CandReco(rhs)      // Should be the next class up on inheritance chain
00131 , fMomentum(rhs.fMomentum)
00132 , fVtxTrace(rhs.fVtxTrace)
00133 , fVtxTraceZ(rhs.fVtxTraceZ)
00134 , fEndTrace(rhs.fEndTrace)
00135 , fEndTraceZ(rhs.fEndTraceZ)
00136 ,  fVtxDistToEdge(rhs.fVtxDistToEdge)
00137 ,  fEndDistToEdge(rhs.fEndDistToEdge)
00138 ,  fVtxnActiveUpstream(rhs.fVtxnActiveUpstream)
00139 ,  fEndnActiveDownstream(rhs.fEndnActiveDownstream)
00140 , fNTrackStrip(rhs.fNTrackStrip)
00141 , fNTrackDigit(rhs.fNTrackDigit)
00142 , fNTimeFitDigit(rhs.fNTimeFitDigit)
00143 , fTimeFitChi2(rhs.fTimeFitChi2)
00144 , fTimeForwardFitRMS(rhs.fTimeForwardFitRMS)
00145 , fTimeForwardFitNDOF(rhs.fTimeForwardFitNDOF)
00146 , fTimeBackwardFitRMS(rhs.fTimeBackwardFitRMS)
00147 , fTimeBackwardFitNDOF(rhs.fTimeBackwardFitNDOF)
00148 {
00149 //CreateLocalHandle(); // Moved to Dup function following copy-ctor call
00150   MSG("Cand", Msg::kDebug)
00151     << "Begin CandTrack::CandTrack(const CandTrack &rhs) ctor: " << endl
00152                                            << "UidInt = " << GetUidInt()
00153                            << ", ArchUidInt " << GetArchUidInt() << endl
00154                              << "No. of links = " << GetNLinks() << endl
00155       << "End CandTrack::CandTrack(const CandTrack &rhs) ctor." << endl;
00156   fInShower.erase(fInShower.begin(),fInShower.end());
00157   fUPos.erase(fUPos.begin(),fUPos.end());
00158   fVPos.erase(fVPos.begin(),fVPos.end());
00159   fdS.erase(fdS.begin(),fdS.end());
00160   fRange.erase(fRange.begin(),fRange.end());
00161   fTPosError.erase(fTPosError.begin(),fTPosError.end());
00162   fTime[0].erase(fTime[0].begin(),fTime[0].end());
00163   fTime[1].erase(fTime[1].begin(),fTime[1].end());
00164   TIter stripItr(rhs.GetDaughterIterator());
00165   while (const CandStripHandle *striphandle =
00166                            dynamic_cast<CandStripHandle*>(stripItr())) {
00167     const CandStrip *strip =
00168              dynamic_cast<const CandStrip*>(striphandle->GetCandBase());
00169     fInShower[strip] = rhs.fInShower[strip];
00170     fUPos[striphandle->GetPlane()] = rhs.fUPos[striphandle->GetPlane()];
00171     fVPos[striphandle->GetPlane()] = rhs.fVPos[striphandle->GetPlane()];
00172     fdS[striphandle->GetPlane()] = rhs.fdS[striphandle->GetPlane()];
00173     fTPosError[striphandle->GetPlane()] = rhs.fTPosError[striphandle->GetPlane()];
00174     fRange[striphandle->GetPlane()] =
00175                                     rhs.fRange[striphandle->GetPlane()];
00176     for (int i=0; i<2; i++) {
00177       fTime[i][striphandle->GetPlane()] =
00178                                   rhs.fTime[i][striphandle->GetPlane()];
00179     }
00180   }
00181 
00182 }
00183 
00184 //______________________________________________________________________
00185 CandTrack::~CandTrack()
00186 {
00187   MSG("Cand", Msg::kDebug)
00188                        << "Begin CandTrack::~CandTrack() dtor: " << endl
00189                                            << "UidInt = " << GetUidInt()
00190                            << ", ArchUidInt " << GetArchUidInt() << endl
00191                              << "No. of links = " << GetNLinks() << endl
00192                          << "End CandTrack::~CandTrack() dtor." << endl;
00193 }
00194 
00195 //______________________________________________________________________
00196 void CandTrack::CreateLocalHandle()
00197 {
00198   SetLocalHandle(new CandTrackHandle(this));
00199 }
00200 
00201 //______________________________________________________________________
00202 CandTrack *CandTrack::Dup() const
00203 {
00204 
00205 // Base copy ctor dups owned pointers, but defers copying Daughter List.
00206 // Daughter List copy is made in the derived class Dup() function.
00207 // This is because base class copy constructor hasn't yet created
00208 // fLocalHandle with a CandHandle* of the full derived type.
00209   CandTrack *cb = new CandTrack(*this);           // Copy-ctor dups ptrs
00210   cb->CreateLocalHandle();   // Initializes fLocalHandle after copy-ctor
00211   cb->SetCandRecord(fCandRecord);
00212   TIter iterdau = GetDaughterIterator();
00213   CandHandle *dau;
00214   while ((dau=(CandHandle *) iterdau())) cb->AddDaughterLink(*dau);
00215   return cb;
00216 }
00217 
00218 //______________________________________________________________________
00219 Bool_t CandTrack::IsEquivalent(const TObject *rhs) const
00220 {
00221   Bool_t result = true;
00222   if (!CandReco::IsEquivalent(rhs)) result = false;   // superclass test
00223   TestDisplayCandBanner("CandTrack");
00224   const CandTrack* rCnd = dynamic_cast<const CandTrack*>(rhs);
00225   if (rCnd == NULL) return false;
00226 
00227   result = TestArrayEquality("fTime", 2, this->fTime,
00228                                          rCnd->fTime)     && result;
00229   result = TestEquality("fMomentum",   this->fMomentum, 
00230                                        rCnd->fMomentum)   && result;
00231   result = TestEquality("fInShower",   this->fInShower, 
00232                                        rCnd->fInShower)   && result;
00233   result = TestEquality("fUPos",       this->fUPos, 
00234                                        rCnd->fUPos)       && result;
00235   result = TestEquality("fVPos",       this->fVPos, 
00236                                        rCnd->fVPos)       && result;
00237   result = TestEquality("fdS",         this->fdS, 
00238                                        rCnd->fdS)         && result;
00239   result = TestEquality("fTPosError",  this->fTPosError, 
00240                                        rCnd->fTPosError)         && result;
00241   result = TestEquality("fRange",      this->fRange, 
00242                                        rCnd->fRange)      && result;
00243   result = TestEquality("fVtxTrace",   this->fVtxTrace,
00244                                        rCnd->fVtxTrace)   && result;
00245   result = TestEquality("fVtxTraceZ",  this->fVtxTraceZ, 
00246                                        rCnd->fVtxTraceZ)  && result;
00247   result = TestEquality("fEndTrace",   this->fEndTrace, 
00248                                        rCnd->fEndTrace)   && result;
00249   result = TestEquality("fEndTraceZ",  this->fEndTraceZ, 
00250                                        rCnd->fEndTraceZ)  && result;
00251   result = TestEquality("fNTrackStrip", this->fNTrackStrip,
00252                                         rCnd->fNTrackStrip)   && result;
00253   result = TestEquality("fNTrackDigit", this->fNTrackDigit,
00254                                         rCnd->fNTrackDigit)   && result;
00255   result = TestEquality("fNTimeFitDigit",
00256                                         this->fNTimeFitDigit,
00257                                         rCnd->fNTimeFitDigit) && result;
00258   result = TestEquality("fTimeForwardFitRMS", this->fTimeForwardFitRMS,
00259                                         rCnd->fTimeForwardFitRMS)   && result;
00260   result = TestEquality("fTimeForwardFitNDOF", this->fTimeForwardFitNDOF,
00261                                         rCnd->fTimeForwardFitNDOF)   && result;
00262   result = TestEquality("fTimeBackwardFitRMS", this->fTimeBackwardFitRMS,
00263                                         rCnd->fTimeBackwardFitRMS)   && result;
00264   result = TestEquality("fTimeBackwardFitNDOF", this->fTimeBackwardFitNDOF,
00265                                         rCnd->fTimeBackwardFitNDOF)   && result;
00266   result = TestEquality("fTimeFitChi2", this->fTimeFitChi2,
00267                                         rCnd->fTimeFitChi2)   && result;
00268 
00269   return result;
00270 }
00271 
00272 //______________________________________________________________________
00273 CandTrackHandle CandTrack::MakeCandidate(AlgHandle &ah, CandContext &cx)
00274 {
00275   CandTrackHandle csh;
00276   new CandTrack(ah, csh, cx);              // csh owns the new CandTrack
00277   return csh;
00278 }
00279 
00280 //______________________________________________________________________
00281 std::ostream& CandTrack::FormatToOStream(std::ostream& os,
00282                                          Option_t *option) const
00283 {
00284   CandReco::FormatToOStream(os,option);
00285 
00286   TString opt(option);
00287   if (!opt.Contains("v0")) { // v0 means suppress the data values
00288     const TString& indent = GetIndentString();
00289 
00290     static MsgFormat timefmt("f10.9");
00291     os  << indent << GetDataIndent()
00292        << "Trace Vtx: " << fVtxTrace << " " << fVtxTraceZ
00293        << " End: " << fEndTrace << " " << fEndTraceZ
00294        << endl;
00295 
00296   }
00297   return os;
00298   
00299 }
00300 
00301 //______________________________________________________________________

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