00001 00002 // $Id: CandSliceHandle.cxx,v 1.12 2004/08/19 16:15:01 musser Exp $ 00003 // 00004 // CandSliceHandle.cxx 00005 // 00006 // Begin_Html<img src="../../pedestrians.gif" align=center> 00007 // <a href="../source_warning.html">Warning for beginners</a>.<br> 00008 // 00009 // CandSliceHandle is the specialized access handle to CandSlice. 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="../CandSlice.html"> CandSlice 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 #include <map> 00023 00024 #include "RecoBase/CandSliceHandle.h" 00025 #include "RecoBase/CandSlice.h" 00026 #include "MessageService/MsgService.h" 00027 00028 ClassImp(CandSliceHandle) 00029 00030 //______________________________________________________________________ 00031 CVSID("$Id: CandSliceHandle.cxx,v 1.12 2004/08/19 16:15:01 musser Exp $"); 00032 00033 //______________________________________________________________________ 00034 CandSliceHandle::CandSliceHandle() 00035 { 00036 } 00037 00038 //______________________________________________________________________ 00039 CandSliceHandle::CandSliceHandle(const CandSliceHandle &cdh) : 00040 CandHandle(cdh) 00041 { 00042 } 00043 00044 //______________________________________________________________________ 00045 CandSliceHandle::CandSliceHandle(CandSlice *cd) : 00046 CandHandle(cd) 00047 { 00048 } 00049 00050 //______________________________________________________________________ 00051 CandSliceHandle::~CandSliceHandle() 00052 { 00053 } 00054 00055 //______________________________________________________________________ 00056 CandSliceHandle *CandSliceHandle::DupHandle() const 00057 { 00058 return (new CandSliceHandle(*this)); 00059 } 00060 00061 00062 //______________________________________________________________________ 00063 void CandSliceHandle::Trace(const char *c) const 00064 { 00065 MSG("Cand", Msg::kDebug) 00066 << "**********Begin CandSliceHandle::Trace(\"" << c << "\")" << endl 00067 << "Information from CandSliceHandle's CandHandle: " << endl; 00068 CandHandle::Trace(c); 00069 MSG("Cand", Msg::kDebug) 00070 << "**********End CandSliceHandle::Trace(\"" << c << "\")" << endl; 00071 } 00072 00073 Int_t CandSliceHandle::GetNStrip(PlaneView::PlaneView_t planeview_t) const 00074 { 00075 if (planeview_t==PlaneView::kUnknown) { 00076 return GetNDaughters(); 00077 } 00078 Int_t n=0; 00079 TIter stripItr(GetDaughterIterator()); 00080 CandStripHandle *strip; 00081 while ((strip = dynamic_cast<CandStripHandle*>(stripItr()))) { 00082 PlaneView::PlaneView_t planeview = strip->GetPlaneView(); 00083 if (planeview == planeview_t) { 00084 n++; 00085 } 00086 } 00087 return n; 00088 } 00089 00090 Int_t CandSliceHandle::GetNDigit(StripEnd::StripEnd_t stripend_t) const 00091 { 00092 Int_t n=0; 00093 TIter stripItr(GetDaughterIterator()); 00094 CandStripHandle *strip; 00095 while ((strip = dynamic_cast<CandStripHandle*>(stripItr()))) { 00096 n += strip->GetNDigit(stripend_t); 00097 } 00098 return n; 00099 } 00100 00101 00102 Int_t CandSliceHandle::GetNPlane(PlaneView::PlaneView_t planeview_t) const 00103 { 00104 TIter stripItr(GetDaughterIterator()); 00105 map<Int_t,Bool_t> occupancy; 00106 CandStripHandle *strip; 00107 Int_t minplane = -1; 00108 Int_t maxplane = -1; 00109 while ((strip = dynamic_cast<CandStripHandle*>(stripItr()))) { 00110 PlaneView::PlaneView_t planeview = strip->GetPlaneView(); 00111 if (planeview!=PlaneView::kA && planeview!=PlaneView::kB && 00112 (planeview_t==PlaneView::kUnknown || planeview==planeview_t)) { 00113 occupancy[strip->GetPlane()] = kTRUE; 00114 if (minplane<0 || strip->GetPlane()<minplane) minplane = strip->GetPlane(); 00115 if (maxplane<0 || strip->GetPlane()>maxplane) maxplane = strip->GetPlane(); 00116 } 00117 } 00118 Int_t nplane = 0; 00119 map<Int_t,Bool_t>::iterator iter; 00120 for (Int_t iplane=minplane; iplane<=maxplane; iplane++) { 00121 iter = occupancy.find(iplane); 00122 if (iter!=occupancy.end()) { 00123 nplane++; 00124 } 00125 } 00126 00127 return nplane; 00128 } 00129 00130 00131 Int_t CandSliceHandle::GetBegPlane(PlaneView::PlaneView_t planeview_t) const 00132 { 00133 TIter stripItr(GetDaughterIterator()); 00134 CandStripHandle *strip; 00135 Bool_t first(1); 00136 Int_t plane=0; 00137 while ((strip = dynamic_cast<CandStripHandle*>(stripItr()))) { 00138 PlaneView::PlaneView_t planeview = strip->GetPlaneView(); 00139 if (planeview!=PlaneView::kA && planeview!=PlaneView::kB && 00140 (planeview_t==PlaneView::kUnknown || planeview_t==planeview) && 00141 (first || strip->GetPlane()<plane)) { 00142 first = 0; 00143 plane = strip->GetPlane(); 00144 } 00145 } 00146 return plane; 00147 } 00148 00149 Int_t CandSliceHandle::GetEndPlane(PlaneView::PlaneView_t planeview_t) const 00150 { 00151 TIter stripItr(GetDaughterIterator()); 00152 CandStripHandle *strip; 00153 Bool_t first(1); 00154 Int_t plane=0; 00155 while ((strip = dynamic_cast<CandStripHandle*>(stripItr()))) { 00156 PlaneView::PlaneView_t planeview = strip->GetPlaneView(); 00157 if (planeview!=PlaneView::kA && planeview!=PlaneView::kB && 00158 (planeview_t==PlaneView::kUnknown || planeview_t==planeview) && 00159 (first || strip->GetPlane()>plane)) { 00160 first = 0; 00161 plane = strip->GetPlane(); 00162 } 00163 } 00164 return plane; 00165 } 00166 00167 00168 Double_t CandSliceHandle::GetBegTime() const 00169 { 00170 TIter stripItr(GetDaughterIterator()); 00171 Double_t time = 0.; 00172 Bool_t first = 1; 00173 while (CandStripHandle *strip = dynamic_cast<CandStripHandle*>(stripItr())) { 00174 if (first || strip->GetBegTime()<time) { 00175 time = strip->GetBegTime(); 00176 first = 0; 00177 } 00178 } 00179 return time; 00180 } 00181 00182 00183 Double_t CandSliceHandle::GetEndTime() const 00184 { 00185 TIter stripItr(GetDaughterIterator()); 00186 Double_t time = 0.; 00187 Bool_t first = 1; 00188 while (CandStripHandle *strip = dynamic_cast<CandStripHandle*>(stripItr())) { 00189 if (first || strip->GetEndTime()>time) { 00190 time = strip->GetEndTime(); 00191 first = 0; 00192 } 00193 } 00194 return time; 00195 } 00196 00197 00198 Double_t CandSliceHandle::GetCharge(CalDigitType::CalDigitType_t caltype_t) const 00199 { 00200 TIter stripItr(GetDaughterIterator()); 00201 Double_t charge = 0.; 00202 while (CandStripHandle *strip = dynamic_cast<CandStripHandle*>(stripItr())) { 00203 charge += strip->GetCharge(caltype_t); 00204 } 00205 return charge; 00206 } 00207 00208 //______________________________________________________________________ 00209 Double_t CandSliceHandle::GetCorrTime() const 00210 { 00211 Double_t corrtime=0.; 00212 Double_t totph=0.; 00213 TIter stripItr(GetDaughterIterator()); 00214 while (CandStripHandle *striphandle = dynamic_cast<CandStripHandle*>(stripItr())) { 00215 corrtime += striphandle->GetCharge()*striphandle->GetCorrBegTime(); 00216 totph += striphandle->GetCharge(); 00217 } 00218 if (totph>0.) corrtime /= totph; 00219 return corrtime; 00220 } 00221 00222 00223 //______________________________________________________________________ 00224 Double_t CandSliceHandle::GetCorrBegTime() const 00225 { 00226 Double_t corrtime=0.; 00227 TIter stripItr(GetDaughterIterator()); 00228 while (CandStripHandle *striphandle = dynamic_cast<CandStripHandle*>(stripItr())) { 00229 if (!corrtime || striphandle->GetCorrBegTime()<corrtime) { 00230 corrtime = striphandle->GetCorrBegTime(); 00231 } 00232 } 00233 return corrtime; 00234 } 00235 00236 00237 00238 //______________________________________________________________________ 00239 Double_t CandSliceHandle::GetCorrEndTime() const 00240 { 00241 Double_t corrtime=0.; 00242 TIter stripItr(GetDaughterIterator()); 00243 while (CandStripHandle *striphandle = dynamic_cast<CandStripHandle*>(stripItr())) { 00244 if (!corrtime || striphandle->GetCorrBegTime()>corrtime) { 00245 corrtime = striphandle->GetCorrBegTime(); 00246 } 00247 } 00248 return corrtime; 00249 } 00250 00251 00252 00253 00254 00255 XXXITRIMP(CandSliceHandle)
1.3.9.1