#include <AlgStraightCluster.h>
Inheritance diagram for AlgStraightCluster:

Public Member Functions | |
| AlgStraightCluster () | |
| virtual | ~AlgStraightCluster () |
| virtual void | Trace (const char *c) const |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
|
|
Definition at line 37 of file AlgStraightCluster.cxx. 00038 {
00039 //
00040 // Purpose: Default constructor.
00041 //
00042 // Arguments: n/a
00043 //
00044 // Return: n/a
00045 //
00046 }
|
|
|
Definition at line 50 of file AlgStraightCluster.cxx. 00051 {
00052 //
00053 // Purpose: Default destructor.
00054 //
00055 // Arguments: n/a
00056 //
00057 // Return: n/a
00058 //
00059 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 63 of file AlgStraightCluster.cxx. References CandHandle::AddDaughterLink(), CandContext::GetCandRecord(), CandHandle::GetCandRecord(), CandClusterHandle::GetCandSlice(), CandDigiPairHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), CandStripHandle::GetTPos(), CandStripHandle::GetZPos(), MSG, CandHandle::SetCandRecord(), CandClusterHandle::SetCandSlice(), CandStraightClusterHandle::SetFitDet(), CandStraightClusterHandle::SetFitInter(), CandStraightClusterHandle::SetFitInterErr(), CandStraightClusterHandle::SetFitMode(), CandStraightClusterHandle::SetFitSlope(), CandStraightClusterHandle::SetFitSlopeErr(), CandStraightClusterHandle::SetT2sum(), CandStraightClusterHandle::SetTsum(), CandStraightClusterHandle::SetTZsum(), CandStraightClusterHandle::SetWtSum(), CandStraightClusterHandle::SetZ2sum(), and CandStraightClusterHandle::SetZsum(). 00065 {
00066 //
00067 // Purpose: Fills the CandStraightCluster with CandDigiPairs
00068 // constructed using the supplied CandDigiPairList.
00069 //
00070 // Argument:
00071 // ac in AlgConfig (not used).
00072 // ch in Handle to the CandStraightCluster to fill.
00073 // cx in CandContext containing a CandDigiPairList.
00074 //
00075 // Return: n/a
00076 //
00077
00078 MSG("BubAlg", Msg::kVerbose)
00079 << "Starting AlgStraightCluster::RunAlg()" << endl;
00080
00081 // Check for class of handle.
00082 assert(ch.InheritsFrom("CandStraightClusterHandle"));
00083 CandStraightClusterHandle &clh =
00084 dynamic_cast<CandStraightClusterHandle&>(ch);
00085
00086 assert(cx.GetDataIn());
00087
00088 // Check for class of input and create iterator.
00089 TIter *chhItr = 0;
00090 if (cx.GetDataIn()->InheritsFrom("TObjArray")) {
00091 const TObjArray *toay =
00092 dynamic_cast<const TObjArray*>(cx.GetDataIn());
00093 chhItr = new TIter(toay);
00094 }
00095 else if (cx.GetDataIn()->InheritsFrom("CandDigiPairListHandle")) {
00096 const CandDigiPairListHandle *chlh =
00097 dynamic_cast<const CandDigiPairListHandle*>(cx.GetDataIn());
00098 chhItr = new TIter(chlh->GetDaughterIterator());
00099 }
00100 else if (cx.GetDataIn()->InheritsFrom("CandMSTClusterHandle")) {
00101 const CandMSTClusterHandle *cch =
00102 dynamic_cast<const CandMSTClusterHandle*>(cx.GetDataIn());
00103 chhItr = new TIter(cch->GetDaughterIterator());
00104 clh.SetCandSlice(cch->GetCandSlice());
00105 }
00106
00107 // Initialize running totals.
00108 Float_t wtsum = 0;
00109 Float_t tsum = 0;
00110 Float_t t2sum = 0;
00111 Float_t zsum = 0;
00112 Float_t z2sum = 0;
00113 Float_t tzsum = 0;
00114
00115 Float_t tmin = 1e7;
00116 Float_t tmax = -1e7;
00117 Float_t zmin = 1e7;
00118 Float_t zmax = -1e7;
00119
00120 // Iterate over CandDigiPair daughters.
00121 while (CandDigiPairHandle *chh =
00122 dynamic_cast<CandDigiPairHandle *>((*chhItr)())) {
00123 if (!chh->GetCandRecord()) chh->SetCandRecord(cx.GetCandRecord());
00124 clh.AddDaughterLink(*chh);
00125
00126 // Update running totals.
00127 Float_t tpos = chh->GetTPos();
00128 Float_t zpos = chh->GetZPos();
00129 Float_t wt = chh->GetCharge();
00130
00131 wtsum += wt;
00132 tsum += wt * tpos;
00133 t2sum += wt * tpos * tpos;
00134 zsum += wt * zpos;
00135 z2sum += wt * zpos * zpos;
00136 tzsum += wt * tpos * zpos;
00137
00138 if (tpos < tmin) tmin = tpos;
00139 if (tpos > tmax) tmax = tpos;
00140 if (zpos < zmin) zmin = zpos;
00141 if (zpos > zmax) zmax = zpos;
00142 }
00143
00144 // Calculate cluster statistics and fit values.
00145 MSG("BubAlg", Msg::kVerbose) << "Calculating fit parameters." << endl;
00146 Int_t fitmode;
00147 Float_t det, inter, intererr, slope, slopeerr;
00148 if (zmax == zmin) {
00149 MSG("BubAlg", Msg::kVerbose) << "zmax == zmin" << endl;
00150 fitmode = 1;
00151 det = 0;
00152 inter = zmin;
00153 intererr = 0;
00154 slope = 0;
00155 slopeerr = 0;
00156 }
00157 else if (tmax == tmin) {
00158 MSG("BubAlg", Msg::kVerbose) << "tmax == tmin" << endl;
00159 fitmode = 0;
00160 det = 0;
00161 inter = tmin;
00162 intererr = 0;
00163 slope = 0;
00164 slopeerr = 0;
00165 }
00166 else if ((zmax - zmin) < (tmax - tmin)) {
00167 MSG("BubAlg", Msg::kVerbose) << "zdiff < tdiff" << endl;
00168 fitmode = 1;
00169 det = wtsum * t2sum - tsum * tsum;
00170 if (!det) det = 1e-9;
00171 inter = (-tzsum * tsum + zsum * t2sum) / det;
00172 intererr = 1.18 * TMath::Sqrt(TMath::Abs(tsum / det));
00173 slope = (-tsum * zsum + wtsum * tzsum) / det;
00174 slopeerr = 1.18 * TMath::Sqrt(TMath::Abs(wtsum / det));
00175 }
00176 else {
00177 MSG("BubAlg", Msg::kVerbose) << "tdiff < zdiff" << endl;
00178 fitmode = 0;
00179 det = wtsum * z2sum - zsum * zsum;
00180 if (!det) det = 1e-9;
00181 inter = (-tzsum * zsum + tsum * z2sum) / det;
00182 intererr = 1.18 * TMath::Sqrt(TMath::Abs(zsum / det));
00183 slope = (-zsum * tsum + wtsum * tzsum) / det;
00184 slopeerr = 1.18 * TMath::Sqrt(TMath::Abs(wtsum / det));
00185 }
00186
00187 // Set cluster statistics and fit values.
00188 clh.SetWtSum(wtsum);
00189 clh.SetTsum(tsum);
00190 clh.SetT2sum(t2sum);
00191 clh.SetTZsum(tzsum);
00192 clh.SetZsum(zsum);
00193 clh.SetZ2sum(z2sum);
00194
00195 clh.SetFitMode(fitmode);
00196 clh.SetFitDet(det);
00197 clh.SetFitInter(inter);
00198 clh.SetFitInterErr(intererr);
00199 clh.SetFitSlope(slope);
00200 clh.SetFitSlopeErr(slopeerr);
00201
00202 // Clean-up.
00203 delete chhItr;
00204 chhItr = 0;
00205 MSG("BubAlg", Msg::kVerbose)
00206 << "Completed AlgStraightCluster::RunAlg" << endl;
00207 }
|
|
|
Reimplemented from AlgBase. Definition at line 211 of file AlgStraightCluster.cxx. References MSG. 00212 {
00213 //
00214 // Purpose: Trace the AlgStraightCluster.
00215 //
00216 // Arguments:
00217 // c in String tag for the trace.
00218 //
00219 // Return: n/a
00220 //
00221
00222 MSG("BubCand", Msg::kDebug)
00223 << "**********Begin AlgStraightCluster::Trace(\"" << c << "\")"
00224 << endl
00225 << "**********End AlgStraightCluster::Trace(\"" << c << "\")"
00226 << endl;
00227 }
|
1.3.9.1