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

CandStripHandle.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CandStripHandle.cxx,v 1.33 2007/11/08 13:50:05 musser Exp $
00003 //
00004 // CandStripHandle.cxx
00005 //
00006 // Begin_Html<img src="../../pedestrians.gif" align=center>
00007 // <a href="../source_warning.html">Warning for beginners</a>.<br> 
00008 //
00009 // CandStripHandle is the specialized access handle to CandStrip.
00010 //
00011 // Each concrete CandHandle must define a DupHandle function.
00012 //
00013 // Author:  R. Lee
00014 //
00015 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and 
00016 // <a href="../CandStrip.html"> CandStrip Classes</a> (part of
00017 // <a href="../index.html">The MINOS Class User Guide</a>)End_Html
00019 
00020 #include <cassert>
00021 #include <iostream>
00022 
00023 #include "CandDigit/CandDigitHandle.h"
00024 #include "Conventions/CalDigitType.h"
00025 #include "Conventions/StripEnd.h"
00026 #include "MessageService/MsgService.h"
00027 #include "Navigation/NavKey.h"
00028 #include "Navigation/NavSet.h"
00029 #include "Plex/PlexStripEndId.h"
00030 #include "RecoBase/CandStripHandle.h"
00031 #include "RecoBase/CandStrip.h"
00032 #include "Validity/VldContext.h"
00033 #include "Conventions/Mphysical.h"
00034 #include "Conventions/Munits.h"
00035 #include "UgliGeometry/UgliGeomHandle.h"
00036 #include "UgliGeometry/UgliScintPlnHandle.h"
00037 #include "Plex/PlexPlaneId.h"
00038 ClassImp(CandStripHandle)
00039 
00040 //______________________________________________________________________
00041 CVSID("$Id: CandStripHandle.cxx,v 1.33 2007/11/08 13:50:05 musser Exp $");
00042 
00043 //______________________________________________________________________
00044 CandStripHandle::CandStripHandle()
00045 {
00046 }
00047 
00048 //______________________________________________________________________
00049 CandStripHandle::CandStripHandle(const CandStripHandle &cdh) :
00050   CandHandle(cdh)
00051 {
00052 }
00053 
00054 //______________________________________________________________________
00055 CandStripHandle::CandStripHandle(CandStrip *cd) :
00056   CandHandle(cd)
00057 {
00058 }
00059 
00060 //______________________________________________________________________
00061 CandStripHandle::~CandStripHandle()
00062 {
00063 }
00064 
00065 //______________________________________________________________________
00066 CandStripHandle *CandStripHandle::DupHandle() const
00067 {
00068    return (new CandStripHandle(*this));
00069 }
00070 
00071 
00072 //______________________________________________________________________
00073 void CandStripHandle::Trace(const char *c) const
00074 {
00075   MSG("Cand", Msg::kDebug)
00076     << "**********Begin CandStripHandle::Trace(\"" << c << "\")" << endl
00077            << "Information from CandStripHandle's CandHandle: " << endl;
00078   CandHandle::Trace(c);
00079   MSG("Cand", Msg::kDebug)
00080      << "**********End CandStripHandle::Trace(\"" << c << "\")" << endl;
00081 }
00082 
00083 
00084 //______________________________________________________________________
00085 
00086 
00087 Int_t CandStripHandle::GetPlane() const
00088 {
00089   return GetStripEndId().GetPlane();
00090 }
00091 
00092 //______________________________________________________________________
00093 
00094 
00095 Int_t CandStripHandle::GetStrip() const
00096 {
00097   return  GetStripEndId().GetStrip();
00098 }
00099 
00100 //______________________________________________________________________
00101 
00102 void CandStripHandle::SetZPos(Double_t dvar)
00103 {
00104   dynamic_cast<CandStrip *>(GetOwnedCandBase())->fZPos = dvar;
00105 }
00106 Double_t CandStripHandle::GetZPos() const
00107 {
00108   return   dynamic_cast<const CandStrip *>(GetCandBase())->fZPos;
00109 }
00110 
00111 //______________________________________________________________________
00112 
00113 void CandStripHandle::SetTPos(Double_t dvar)
00114 {
00115   dynamic_cast<CandStrip *>(GetOwnedCandBase())->fTPos = dvar;
00116 }
00117 Double_t CandStripHandle::GetTPos() const
00118 {
00119   return dynamic_cast<const CandStrip *>(GetCandBase())->fTPos;
00120 }
00121 Double_t CandStripHandle::GetTPos(Double_t orthopos) const
00122 {
00123   UgliGeomHandle ugh(*GetVldContext());
00124   PlexPlaneId plnid(GetVldContext()->GetDetector(),GetPlane(),false);
00125   UgliScintPlnHandle scintpln = ugh.GetScintPlnHandle(plnid); 
00126   UgliStripHandle ush = scintpln.GetStripHandle(GetStripEndId());
00127   return ush.GetTPos(orthopos);
00128 }
00129 
00130 
00131 //______________________________________________________________________
00135 void CandStripHandle::SetCalTimeType(CalTimeType::CalTimeType_t caltimetype)
00136 {
00137   dynamic_cast<CandStrip *>(GetOwnedCandBase())->fCalTimeType = caltimetype;
00138 }
00139 
00140 CalTimeType::CalTimeType_t CandStripHandle::GetCalTimeType() const
00141 {
00142   return dynamic_cast<const CandStrip *>(GetCandBase())->fCalTimeType;
00143 }
00144 //______________________________________________________________________
00145 
00149 Double_t CandStripHandle::GetTime(StripEnd::StripEnd_t stripend_t) const {
00150   Int_t i=0;
00151   Double_t time=0.;
00152   Double_t ph=0.;
00153   CalTimeType::CalTimeType_t caltimetype = GetCalTimeType();
00154   TIter cdhItr(GetDaughterIterator());
00155   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhItr())) {
00156     Double_t digittime = cdh->GetSubtractedTime(caltimetype);
00157     if (stripend_t==StripEnd::kWhole ||
00158         cdh->GetPlexSEIdAltL().GetEnd()==stripend_t) {
00159       time += digittime*cdh->GetCharge();
00160       ph += cdh->GetCharge();
00161       i++;
00162     }
00163   }
00164   if (ph>0.) time /= ph;
00165   return time;
00166 }
00167 
00170 Double_t CandStripHandle::GetBegTime(StripEnd::StripEnd_t stripend_t) const {
00171   Int_t i=0;
00172   Double_t time=0.;
00173   CalTimeType::CalTimeType_t caltimetype = GetCalTimeType();
00174   TIter cdhItr(GetDaughterIterator());
00175   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhItr())) {
00176     Double_t digittime = cdh->GetSubtractedTime(caltimetype);
00177     if ((!i || digittime<time) && (stripend_t==StripEnd::kWhole ||
00178          cdh->GetPlexSEIdAltL().GetEnd()==stripend_t)) {
00179       time = digittime;
00180       i++;
00181     }
00182   }
00183   return time;
00184 }
00185 
00189 Double_t CandStripHandle::GetCorrBegTime() const {
00190   return GetTime()-GetZPos()/Mphysical::c_light;
00191 }
00192 
00195 Double_t CandStripHandle::GetEndTime(StripEnd::StripEnd_t stripend_t) const {
00196   Int_t i=0;
00197   Double_t time=0.;
00198   CalTimeType::CalTimeType_t caltimetype = GetCalTimeType();
00199   TIter cdhItr(GetDaughterIterator());
00200   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhItr())) {
00201      if ((!i || cdh->GetSubtractedTime(caltimetype)>time) && (stripend_t==StripEnd::kWhole ||
00202          cdh->GetPlexSEIdAltL().GetEnd()==stripend_t)) {
00203        time = cdh->GetSubtractedTime(caltimetype);
00204        i++;
00205      }
00206   }
00207   return time;
00208 }
00209 
00210 //______________________________________________________________________
00211 
00215 Double_t CandStripHandle::GetCharge(StripEnd::StripEnd_t stripend_t, CalDigitType::CalDigitType_t caltype_t) const {
00216   Double_t charge=0.;
00217   TIter cdhItr(GetDaughterIterator());
00218   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhItr())) {
00219      if (stripend_t==StripEnd::kWhole ||
00220          cdh->GetPlexSEIdAltL().GetEnd()==stripend_t) {
00221        charge += cdh->GetCharge(caltype_t);
00222      }
00223   }
00224   return charge;
00225 }
00228 Double_t CandStripHandle::GetCharge(CalDigitType::CalDigitType_t caltype_t, StripEnd::StripEnd_t stripend_t) const {
00229   return GetCharge(stripend_t,caltype_t);
00230 }
00231 
00232 Double_t CandStripHandle::GetCharge() const
00233 {
00234   return GetCharge(StripEnd::kWhole,CalDigitType::kPE);
00235 }
00236 
00237 Double_t CandStripHandle::GetCharge(StripEnd::StripEnd_t stripend_t) const
00238 {
00239   return GetCharge(stripend_t,CalDigitType::kPE);
00240 }
00241 
00242 Double_t CandStripHandle::GetCharge(CalDigitType::CalDigitType_t caltype_t) const
00243 {
00244   return GetCharge(StripEnd::kWhole,caltype_t);
00245 }
00246 
00247 //______________________________________________________________________
00250 Int_t CandStripHandle::GetNDigit(StripEnd::StripEnd_t stripend_t) const {
00251   if (stripend_t == StripEnd::kWhole) {
00252     return GetNDaughters();
00253   }
00254   Int_t n=0;
00255   TIter cdhItr(GetDaughterIterator());
00256   while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(cdhItr())) {
00257     if (cdh->GetPlexSEIdAltL().GetEnd() == stripend_t) {
00258       n++;
00259     }
00260   }
00261   return n;
00262 }
00263 
00264 //______________________________________________________________________
00265 
00266 UShort_t CandStripHandle::GetDemuxVetoFlag(StripEnd::StripEnd_t stripend_t) const
00267 {
00268   UShort_t demuxveto(1);
00269   TIter digitItr(GetDaughterIterator());
00270   while (CandDigitHandle *digit = dynamic_cast<CandDigitHandle*>(digitItr())) {
00271     if (stripend_t==StripEnd::kWhole || digit->GetPlexSEIdAltL().GetBestSEId().GetEnd()==stripend_t) {
00272       if (digit->GetPlexSEIdAltL().GetDemuxVetoFlag()==0) demuxveto = 0;
00273     }
00274   }
00275   return demuxveto;
00276 }
00277 
00278 //______________________________________________________________________
00279 
00280 PlaneView::PlaneView_t CandStripHandle::GetPlaneView() const 
00281 {
00282   return GetStripEndId().GetPlaneView();
00283 }
00284 
00285 //______________________________________________________________________
00286 
00287 void CandStripHandle::SetBestStripEndId(PlexStripEndId stripendid)
00288 {
00289   CandStrip *candstrip = dynamic_cast<CandStrip *>(GetOwnedCandBase());
00290   candstrip->fBestStripEnd = stripendid;
00291   candstrip->fBestStripEnd.SetEnd(StripEnd::kWhole);
00292 }
00293 
00294 PlexStripEndId CandStripHandle::GetStripEndId(StripEnd::StripEnd_t stripend_t)
00295 const {
00296   const CandStrip *candstrip = dynamic_cast<const CandStrip *>(GetCandBase());
00297   PlexStripEndId seid = candstrip->fBestStripEnd;
00298   seid.SetEnd(stripend_t);
00299   return seid;
00300 }
00301 
00302 
00303 //______________________________________________________________________
00304 //  Navigation Helpers
00305 //______________________________________________________________________
00306 //______________________________________________________________________
00307 NavKey CandStripHandle::KeyFromPlane(const CandStripHandle *strip)
00308 {
00309   return const_cast<CandStripHandle *>(strip)->GetPlane();
00310 }
00311 
00312 //______________________________________________________________________
00313 NavKey CandStripHandle::KeyFromPlaneStripTime(const CandStripHandle *strip)
00314 {
00315 
00316    Int_t iplane = strip->GetPlane();
00317    Int_t istrip = strip->GetStrip();
00318    Float_t time = strip->GetBegTime();
00319    Int_t itime = static_cast<Int_t>((time*.1/18.7)+.5);
00320 
00321    Int_t navkey = (iplane<<22) | (istrip<<14) | itime;
00322 
00323    return navkey;
00324 
00325 }
00326 
00327 //______________________________________________________________________
00328 NavKey CandStripHandle::KeyFromView(const CandStripHandle *strip)
00329 {
00330   return static_cast<Int_t>(strip->GetStripEndId().GetPlaneView());
00331 }
00332 
00333 //______________________________________________________________________
00334 NavKey CandStripHandle::StripSRKeyFromPSEId(const CandStripHandle *csh)
00335 { 
00336         return const_cast<CandStripHandle *>(csh)->GetStripEndId().GetEncoded(); 
00337 }
00338 
00339 //______________________________________________________________________
00340 NavKey CandStripHandle::StripSRKeyFromBegTime(const CandStripHandle *csh)
00341 {   
00342         Double_t time = (Double_t)csh->GetBegTime();
00343     return time;
00344 }
00345 
00346 
00347 XXXITRIMP(CandStripHandle)

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