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

CandClusterHandle.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CandClusterHandle.cxx,v 1.20 2005/11/01 20:12:24 gmieg Exp $
00003 //
00004 // CandClusterHandle.cxx
00005 //
00006 // CandClusterHandle is the specialized access handle to CandCluster.
00007 //
00008 // Each concrete CandHandle must define a DupHandle function.
00009 //
00010 // Author:  R. Lee
00012 
00013 #include <cassert>
00014 #include <iostream>
00015 
00016 #include "MessageService/MsgService.h"
00017 #include "Navigation/NavKey.h"
00018 #include "Navigation/NavSet.h"
00019 #include "Plex/PlexStripEndId.h"
00020 #include "RecoBase/CandCluster.h"
00021 #include "RecoBase/CandClusterHandle.h"
00022 #include "RecoBase/CandSliceHandle.h"
00023 #include "RecoBase/CandStripHandle.h"
00024 
00025 ClassImp(CandClusterHandle)
00026 
00027 //______________________________________________________________________
00028 CVSID("$Id: CandClusterHandle.cxx,v 1.20 2005/11/01 20:12:24 gmieg Exp $");
00029 
00030 //______________________________________________________________________
00031 CandClusterHandle::CandClusterHandle()
00032 {
00033 }
00034 
00035 //______________________________________________________________________
00036 CandClusterHandle::CandClusterHandle(const CandClusterHandle &cdh) :
00037   CandHandle(cdh)
00038 {
00039 }
00040 
00041 //______________________________________________________________________
00042 CandClusterHandle::CandClusterHandle(CandCluster *cd) :
00043   CandHandle(cd)
00044 {
00045 }
00046 
00047 //______________________________________________________________________
00048 CandClusterHandle::~CandClusterHandle()
00049 {
00050 }
00051 
00052 //______________________________________________________________________
00053 CandClusterHandle *CandClusterHandle::DupHandle() const
00054 {
00055   return (new CandClusterHandle(*this));
00056 }
00057 
00058 //______________________________________________________________________
00059 void CandClusterHandle::Trace(const char *c) const
00060 {
00061   MSG("Cand", Msg::kDebug)
00062   << "**********Begin CandClusterHandle::Trace(\"" << c << "\")" << endl
00063          << "Information from CandClusterHandle's CandHandle: " << endl;
00064   CandHandle::Trace(c);
00065   MSG("Cand", Msg::kDebug)
00066    << "**********End CandClusterHandle::Trace(\"" << c << "\")" << endl;
00067 }
00068 
00069 //______________________________________________________________________
00070 void CandClusterHandle::SetCandSlice(const CandSliceHandle *slice)
00071 {
00072   if (slice) {                 // fCandSlice is now an owned CandHandle*
00073     CandSliceHandle *ch = slice->DupHandle();
00074     delete (dynamic_cast<CandCluster *>
00075                                       (GetOwnedCandBase()))->fCandSlice;
00076     dynamic_cast<CandCluster *>(GetOwnedCandBase())->fCandSlice = ch;
00077   }
00078 }
00079 
00080 const CandSliceHandle *CandClusterHandle::GetCandSlice() const
00081 {
00082   return dynamic_cast<const CandCluster *>(GetCandBase())->fCandSlice;
00083 }
00084 
00085 //______________________________________________________________________
00086 
00087 void CandClusterHandle::IsTrackLike(Bool_t bvar)
00088 {
00089   dynamic_cast<CandCluster *>(GetOwnedCandBase())->fTrackLike = bvar;
00090 }
00091 
00092 Bool_t CandClusterHandle::IsTrackLike() const
00093 {
00094   return dynamic_cast<const CandCluster *>(GetCandBase())->fTrackLike;
00095 }
00096 
00097 //______________________________________________________________________
00098 
00099 void CandClusterHandle::IsShowerLike(Bool_t bvar)
00100 {
00101   dynamic_cast<CandCluster *>(GetOwnedCandBase())->fShowerLike = bvar;
00102 
00103 }
00104 
00105 Bool_t CandClusterHandle::IsShowerLike() const
00106 {
00107   return dynamic_cast<const CandCluster *>(GetCandBase())->fShowerLike;
00108 }
00109 
00110 //______________________________________________________________________
00111 
00112 PlaneView::PlaneView_t CandClusterHandle::GetPlaneView() const 
00113 {
00114   CandStripHandleItr cshItr(GetDaughterIterator());
00115   if (CandStripHandle *csh = cshItr()) {
00116     return csh->GetPlaneView();
00117   }
00118   else {
00119     return PlaneView::kUnknown;
00120   }
00121 }
00122 
00123 //______________________________________________________________________
00124 
00125 Int_t CandClusterHandle::GetNStrip() const 
00126 {
00127   return GetNDaughters();
00128 }
00129 
00130 Int_t CandClusterHandle::GetNPlane() const
00131 {
00132   Int_t begplane = GetBegPlane();
00133   if (begplane==0) {
00134     return 0;
00135   }
00136   Int_t endplane = GetEndPlane();
00137   if (begplane==endplane) {
00138     return 1;
00139   }
00140   Int_t ncount = 2;
00141   CandStripHandleItr stripItr(GetDaughterIterator());
00142   CandStripHandleKeyFunc *stripKf = stripItr.CreateKeyFunc();
00143   stripKf->SetFun(CandStripHandle::KeyFromPlane);
00144   stripItr.GetSet()->AdoptSortKeyFunc(stripKf);
00145   stripKf = 0;
00146   while (stripItr.IsValid() && stripItr.Ptr()->GetPlane()<=begplane) {
00147     stripItr.Next();
00148   }
00149   Int_t oldplane = stripItr.Ptr()->GetPlane();
00150   while (CandStripHandle *strip =
00151                            dynamic_cast<CandStripHandle*>(stripItr())) {
00152     if (strip->GetPlaneView()!=PlaneView::kA &&
00153         strip->GetPlaneView()!=PlaneView::kB) {
00154       if (strip->GetPlane()!=oldplane) {
00155         ncount++;
00156       }
00157       oldplane = strip->GetPlane();
00158     }
00159   }
00160   return ncount;
00161 }
00162 
00163 //______________________________________________________________________
00164 
00165 Int_t CandClusterHandle::GetBegPlane() const 
00166 {
00167   TIter cshItr(GetDaughterIterator());
00168   Int_t plane = 0;
00169   Bool_t first = 1;
00170   while (CandStripHandle *csh =
00171                              dynamic_cast<CandStripHandle*>(cshItr())) {
00172     if (first || csh->GetPlane()<plane) {
00173       plane = csh->GetPlane();
00174       first = 0;
00175     }
00176   }
00177   return plane;
00178 }
00179 
00180 Int_t CandClusterHandle::GetEndPlane() const 
00181 {
00182   TIter cshItr(GetDaughterIterator());
00183   Int_t plane = 0;
00184   Bool_t first = 1;
00185   while (CandStripHandle *csh =
00186                              dynamic_cast<CandStripHandle*>(cshItr())) {
00187     if (first || csh->GetPlane()>plane) {
00188       plane = csh->GetPlane();
00189       first = 0;
00190     }
00191   }
00192   return plane;
00193 }
00194 
00195 //______________________________________________________________________
00196 
00197 Double_t CandClusterHandle::GetBegTime() const 
00198 {
00199   TIter cshItr(GetDaughterIterator());
00200   Double_t time = 0.;
00201   Bool_t first = 1;
00202   while (CandStripHandle *csh =
00203                              dynamic_cast<CandStripHandle*>(cshItr())) {
00204     if (first || csh->GetBegTime()<time) {
00205       time = csh->GetBegTime();
00206       first = 0;
00207     }
00208   }
00209   return time;
00210 }
00211 
00212 Double_t CandClusterHandle::GetEndTime() const 
00213 {
00214   TIter cshItr(GetDaughterIterator());
00215   Double_t time = 0.;
00216   Bool_t first = 1;
00217   while (CandStripHandle *csh =
00218                              dynamic_cast<CandStripHandle*>(cshItr())) {
00219     if (first || csh->GetEndTime()>time) {
00220       time = csh->GetEndTime();
00221       first = 0;
00222     }
00223   }
00224   return time;
00225 }
00226 
00227 //______________________________________________________________________
00228 
00229 Double_t CandClusterHandle::GetCharge() const 
00230 {
00231   TIter cshItr(GetDaughterIterator());
00232   Double_t charge = 0.;
00233   while (CandStripHandle *csh =
00234                              dynamic_cast<CandStripHandle*>(cshItr())) {
00235     charge += csh->GetCharge();
00236   }
00237   return charge;
00238 }
00239 
00240 //______________________________________________________________________
00241 
00242 Double_t CandClusterHandle::GetTPos() const 
00243 {
00244   TIter cshItr(GetDaughterIterator());
00245   Double_t charge = 0.;
00246   Double_t tpos = 0.;
00247   while (CandStripHandle *csh =
00248                              dynamic_cast<CandStripHandle*>(cshItr())) {
00249     charge += csh->GetCharge();
00250     tpos += csh->GetCharge()*csh->GetTPos();
00251   }
00252   tpos /= charge;
00253   return tpos;
00254 }
00255 
00256 
00257 //______________________________________________________________________
00258 // Navigation Helpers
00259 //______________________________________________________________________
00260 
00261 NavKey CandClusterHandle::KeyFromObject(const CandClusterHandle *cluster)
00262 {
00263   if (cluster->IsShowerLike()) {
00264     return 1;
00265   }
00266   if (cluster->IsTrackLike()) {
00267     return 2;
00268   }
00269   return 0;
00270 }
00271 
00272 
00273 NavKey CandClusterHandle::KeyFromView(const CandClusterHandle *cluster)
00274 {
00275   if (const CandStripHandle *strip =
00276        dynamic_cast<const CandStripHandle *>(cluster->FindDaughter())) {
00277     return static_cast<Int_t>(const_cast<CandStripHandle *>
00278       (strip)->GetPlaneView());
00279   }
00280   return static_cast<Int_t>(PlaneView::kUnknown);
00281 }
00282 
00283 NavKey CandClusterHandle::KeyFromSlice(const CandClusterHandle *cluster)
00284 {
00285   if (cluster->GetCandSlice()) {
00286     return static_cast<Int_t>(cluster->GetCandSlice()->GetUidInt());
00287   } 
00288   return 0;
00289 
00290 }
00291 
00292 
00293 XXXITRIMP(CandClusterHandle)

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