Changeset 2178 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 06/16/03 13:45:01 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MFillH.cc
r2173 r2178 501 501 502 502 // 503 // Check whether fDisplay has previously been used (fCanvas) 504 // and fDisplay is still open. 505 // 506 if (fCanvas && fDisplay) 503 // Check whether fDisplay has previously been used (fCanvas), 504 // fDisplay is still open and the corresponding Canvas/Tab is 505 // still existing. 506 // 507 if (fDisplay && fDisplay->HasCanvas(fCanvas)) 507 508 { 508 509 fCanvas->cd(); -
trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
r2173 r2178 127 127 const UInt_t n = evt->GetNumPixels(); 128 128 129 for (UInt_t i =0; i<n; i++)129 for (UInt_t idx=0; idx<n; idx++) 130 130 { 131 const MCerPhotPix &pix = (*evt)[i]; 131 Float_t val; 132 if (!evt->GetPixelContent(val, idx)) 133 continue; 132 134 133 const Int_t id = pix.GetPixId(); 134 135 fSum[id].SetPixelUsed(); 136 fSum[id].AddNumPhotons(pix.GetNumPhotons()); 135 fSum[idx].SetPixelUsed(); 136 fSum[idx].AddNumPhotons(val); 137 137 } 138 138 … … 148 148 Bool_t MHCerPhotEvt::Finalize() 149 149 { 150 fSum.Scale(fEntries); 150 if (fEntries<1) 151 *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl; 152 else 153 fSum.Scale(fEntries); 151 154 return kTRUE; 152 155 } … … 185 188 fDispl = new MCamDisplay(fCam); 186 189 187 fDispl->Fill PhotNum(fSum);190 fDispl->Fill(fSum); 188 191 fDispl->Paint(); 189 192 } -
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 } -
trunk/MagicSoft/Mars/mhist/MHCurrents.h
r2173 r2178 6 6 #endif 7 7 8 #ifndef MARS_MCurrents9 #include "MCurrents.h"8 #ifndef ROOT_TH1 9 #include <TH1.h> 10 10 #endif 11 11 12 class TH1D; 12 #ifndef ROOT_TArrayF 13 #include <TArrayF.h> 14 #endif 15 16 class MCurrents; 13 17 class MGeomCam; 14 18 class MCamDisplay; … … 17 21 { 18 22 private: 19 MCurrents fSum; // storing the sum 23 TArrayF fSum; // storing the sum 24 TArrayF fRms; // storing the rms 20 25 Int_t fEntries; // number of entries in the histogram 21 26 MGeomCam *fCam; // the present geometry 22 27 MCurrents *fEvt; //! the current event 23 28 MCamDisplay *fDispl; //! the camera display 29 30 TH1F fHist; 24 31 25 32 public: … … 35 42 TH1 *GetHistByName(const TString name) { return NULL; } 36 43 37 const MCurrents &GetSum() const { return fSum; } 44 const TArrayF &GetSum() const { return fSum; } 45 const TArrayF &GetRms() const { return fRms; } 46 47 const TH1F &GetHist() const { return fHist; } 38 48 39 49 void Draw(Option_t *opt="");
Note:
See TracChangeset
for help on using the changeset viewer.