Changeset 2178 for trunk/MagicSoft/Mars/mhist/MHCurrents.cc
- Timestamp:
- 06/16/03 13:45:01 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHCurrents.cc
r2173 r2178 36 36 37 37 #include "MParList.h" 38 #include "MBinning.h" 38 39 #include "MCurrents.h" 39 40 #include "MCamDisplay.h" … … 54 55 // FIXME: Implement a clear function with setmem 55 56 for (int i=0; i<577; i++) 57 { 56 58 fSum[i] = 0; 59 fRms[i] = 0; 60 } 57 61 58 62 fEntries = 0; … … 65 69 // 66 70 MHCurrents::MHCurrents(const char *name, const char *title) 67 : fSum(577), f Cam(NULL), fEvt(NULL), fDispl(NULL)71 : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL) 68 72 { 69 73 // … … 74 78 75 79 Clear(); 80 81 fHist.SetName("currents"); 82 fHist.SetTitle("Avg.Currents [nA]"); 83 fHist.SetDirectory(NULL); 84 fHist.Sumw2(); 76 85 } 77 86 … … 105 114 Clear(); 106 115 116 MBinning bins; 117 bins.SetEdges(577, -0.5, 576.5); 118 bins.Apply(fHist); 119 107 120 return kTRUE; 108 121 } … … 121 134 } 122 135 136 for (UInt_t idx=0; idx<577; idx++) 137 { 138 Float_t val; 139 if (!evt->GetPixelContent(val, idx)) 140 continue; 141 142 fSum[idx] += val; 143 fRms[idx] += val*val; 144 } 145 146 fEntries++; 147 148 return kTRUE; 149 } 150 151 // -------------------------------------------------------------------------- 152 // 153 // Scale the sum container with the number of entries 154 // 155 Bool_t MHCurrents::Finalize() 156 { 157 if (fEntries<2) 158 { 159 *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain enough entries." << endl; 160 return kTRUE; 161 } 162 123 163 for (UInt_t i=0; i<577; i++) 124 fSum[i] += (*evt)[i]; 125 126 fEntries++; 127 164 { 165 // calc sdev^2 for pixel index i 166 // var^2 = (sum[xi^2] - sum[xi]^2/n) / (n-1); 167 fRms[i] -= fSum[i]*fSum[i]/fEntries; 168 fRms[i] /= fEntries-1; 169 fRms[i] = TMath::Sqrt(fRms[i]); 170 171 // calc mean value for pixel index i 172 fSum[i] /= fEntries; 173 174 fHist.SetBinContent(i+1, fSum[i]); 175 fHist.SetBinError( i+1, fRms[i]); 176 } 128 177 return kTRUE; 129 178 } … … 131 180 // -------------------------------------------------------------------------- 132 181 // 133 // Scale the sum container with the number of entries134 //135 Bool_t MHCurrents::Finalize()136 {137 for (UInt_t i=0; i<577; i++)138 fSum[i] /= fEntries;139 140 return kTRUE;141 }142 143 // --------------------------------------------------------------------------144 //145 182 // Draw the present 'fill status' 146 183 // 147 void MHCurrents::Draw(Option_t * )184 void MHCurrents::Draw(Option_t *o) 148 185 { 149 186 if (!fCam) … … 156 193 pad->SetBorderMode(0); 157 194 195 SetDrawOption(o); 158 196 AppendPad(""); 159 197 } … … 174 212 fDispl = new MCamDisplay(fCam); 175 213 176 fDispl->FillCurrents(fSum); 214 TString opt(GetDrawOption()); 215 216 fDispl->Fill(opt.Contains("rms", TString::kIgnoreCase) ? fRms : fSum); 177 217 fDispl->Paint(); 178 218 }
Note:
See TracChangeset
for help on using the changeset viewer.