Changeset 6855 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 03/18/05 17:21:58 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/HistLinkDef.h
r5068 r6855 18 18 #pragma link C++ class MHAlphaEnergyTheta+; 19 19 #pragma link C++ class MHGamma+; 20 #pragma link C++ class MHSigmaTheta;20 //#pragma link C++ class MHSigmaTheta; 21 21 #pragma link C++ class MHThetabarTime+; 22 22 #pragma link C++ class MHThetabarTheta+; -
trunk/MagicSoft/Mars/mhist/MHCamEvent.cc
r6513 r6855 33 33 // ===== 34 34 // 35 // To plot sqrt(variance) instead of the rms use:36 // MHCamEvent::SetBit(MHCamera::kSqrtVariance);37 // or38 // MHCamEvent::EnableSqrtVariance()39 //40 35 // To count how often a certain pixel is above or below a threshold do: 41 36 // MHCamEvent::SetThreshold(5.5); // Default=LowerBound … … 121 116 if (fSum) 122 117 delete fSum; 123 }124 125 // --------------------------------------------------------------------------126 //127 // use this to display the variance instead of the rms.128 //129 void MHCamEvent::EnableSqrtVariance(Bool_t b)130 {131 b ? SetBit(MHCamera::kSqrtVariance) : ResetBit(MHCamera::kSqrtVariance);132 118 } 133 119 … … 173 159 fSum->SetYTitle("a.u."); 174 160 fSum->SetBit(MHCamera::kProfile); 175 if (TestBit(MHCamera::kSqrtVariance))176 fSum->SetBit(MHCamera::kSqrtVariance);177 161 178 162 fSum->SetXTitle("Pixel Idx"); … … 261 245 { 262 246 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this); 247 const Int_t col = pad->GetFillColor(); 263 248 pad->SetBorderMode(0); 264 249 265 250 AppendPad(); 266 251 267 TString name = Form("%s_5", pad->GetName()); 268 TPad *p = new TPad(name,name,6./8,0.25,0.99,0.5,pad->GetFillColor(),0,0); 269 p->SetNumber(5); 270 p->Draw(); 271 272 name = Form("%s_6", pad->GetName()); 273 p = new TPad(name,name,6./8,0.01,0.99,0.25,pad->GetFillColor(),0,0); 274 p->SetNumber(6); 275 p->Draw(); 276 277 pad->Divide(2,2); 278 279 pad->cd(1); 280 gPad->SetBorderMode(0); 281 gPad->SetPad(0.01, 0.5, 0.66, 0.99); 252 TString name = Form("%s_1", pad->GetName()); 253 TPad *p = new TPad(name,name,0.005, 0.5, 0.66, 0.995,col,0,0); 254 p->SetNumber(1); 255 p->Draw(); 256 p->cd(); 282 257 fSum->Draw("EPhist"); 283 258 284 pad->cd(2); 285 gPad->SetBorderMode(0); 286 gPad->SetPad(0.66, 0.5, 0.99, 0.99); 259 pad->cd(); 260 name = Form("%s_2", pad->GetName()); 261 p = new TPad(name,name,0.66, 0.5, 0.995, 0.995,col,0,0); 262 p->SetNumber(2); 263 p->Draw(); 264 p->cd(); 287 265 TH1 *h = fSum->Projection(Form("%s;proj", fName.Data()), 50); 288 266 h->SetTitle("Projection"); … … 290 268 h->Draw(); 291 269 292 pad->cd(3); 293 gPad->SetPad(0.01, 0.01, 3./8, 0.5); 294 gPad->SetBorderMode(0); 270 pad->cd(); 271 name = Form("%s_3", pad->GetName()); 272 p = new TPad(name,name,0.005, 0.005, 3./8, 0.5,col,0,0); 273 p->SetNumber(3); 274 p->Draw(); 275 p->cd(); 295 276 fSum->Draw(); 296 277 297 pad->cd(4); 298 gPad->SetPad(3./8, 0.01, 6./8, 0.5); 299 gPad->SetBorderMode(0); 278 pad->cd(); 279 name = Form("%s_4", pad->GetName()); 280 p = new TPad(name,name,3./8, 0.005, 6./8-0.005, 0.5,col,0,0); 281 p->SetNumber(4); 282 p->Draw(); 283 p->cd(); 300 284 301 285 MHCamera *cam = new MHCamera(*fSum->GetGeometry()); 302 286 cam->SetName(Form("%s;err", fName.Data())); 303 cam->SetTitle( fSum->TestBit(MHCamera::kSqrtVariance)?"Sqrt(Variance)":"Root Mean Squared (rms)");287 cam->SetTitle("Sqrt(Variance)"); 304 288 cam->SetYTitle(fSum->GetYaxis()->GetTitle()); 305 289 cam->SetCamContent(*fSum, 1); … … 307 291 cam->Draw(); 308 292 309 pad->cd(5); 293 pad->cd(); 294 name = Form("%s_5", pad->GetName()); 295 p = new TPad(name,name,6./8,0.25,0.995,0.5,col,0,0); 296 p->SetNumber(5); 297 p->Draw(); 298 p->cd(); 310 299 h = (TH1*)fSum->RadialProfile(Form("%s;rad", fName.Data()), 20); 311 300 h->SetTitle("Radial Profile"); … … 313 302 h->Draw(); 314 303 315 pad->cd(6); 304 pad->cd(); 305 name = Form("%s_6", pad->GetName()); 306 p = new TPad(name,name,6./8,0.005,0.995,0.25,col,0,0); 307 p->SetNumber(6); 308 p->Draw(); 309 p->cd(); 316 310 h = (TH1*)fSum->AzimuthProfile(Form("%s;az", fName.Data()), 30); 317 311 h->SetTitle("Azimuth Profile"); -
trunk/MagicSoft/Mars/mhist/MHCamEvent.h
r6276 r6855 15 15 static const TString gsDefTitle; 16 16 17 protected: 17 18 MHCamera *fSum; // storing the sum 18 19 MCamEvent *fEvt; //! the current event … … 50 51 51 52 void SetThreshold(Float_t f, Char_t direction=kIsLowerBound) { fThreshold = f; fUseThreshold=direction; } 52 void EnableSqrtVariance(Bool_t b=kTRUE);53 53 54 54 ClassDef(MHCamEvent, 1) // Histogram to sum camera events -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r6457 r6855 164 164 fUsed.Set(geom.GetNumPixels()); 165 165 for (Int_t i=0; i<fNcells-2; i++) 166 ResetUsed(i); 166 ResetUsed(i); 167 168 fBinEntries.Set(geom.GetNumPixels()+2); 169 fBinEntries.Reset(); 167 170 } 168 171 … … 213 216 const Int_t bin = (Int_t)x+1; 214 217 AddBinContent(bin); 218 fBinEntries[bin]++; 215 219 if (fSumw2.fN) 216 220 fSumw2.fArray[bin]++; … … 249 253 const Int_t bin = (Int_t)x+1; 250 254 AddBinContent(bin, w); 255 fBinEntries[bin]++; 251 256 if (fSumw2.fN) 252 257 fSumw2.fArray[bin] += w*w; … … 319 324 if ((all || IsUsed(i)) && MatchSector(i, sector, aidx)) 320 325 { 321 mean += fArray[i+1]; 326 if (TestBit(kProfile) && fBinEntries[i+1]==0) 327 continue; 328 329 mean += TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 322 330 n++; 323 331 } 324 332 } 325 333 326 return n==0 ? 0 : Profile(mean/n);334 return n==0 ? 0 : mean/n; 327 335 } 328 336 … … 346 354 if ((all || IsUsed(i)) && MatchSector(i, sector, aidx)) 347 355 { 348 sum += fArray[i+1]; 349 sq += fArray[i+1]*fArray[i+1]; 356 if (TestBit(kProfile) && fBinEntries[i+1]==0) 357 continue; 358 359 const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 360 361 sum += val; 362 sq += val*val; 350 363 n++; 351 364 } … … 358 371 sq /= n; 359 372 360 return Profile(TMath::Sqrt(sq-sum*sum));373 return TMath::Sqrt(sq-sum*sum); 361 374 } 362 375 … … 377 390 Double_t minimum=FLT_MAX; 378 391 379 for (Int_t idx=0; idx<fNcells-2; idx++) 380 if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]<minimum) 381 minimum = fArray[idx+1]; 382 383 return Profile(minimum); 392 for (Int_t i=0; i<fNcells-2; i++) 393 { 394 if (TestBit(kProfile) && fBinEntries[i+1]==0) 395 continue; 396 397 const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 398 if (MatchSector(i, sector, aidx) && (all || IsUsed(i)) && val<minimum) 399 minimum = val; 400 } 401 402 return minimum; 384 403 } 385 404 … … 399 418 400 419 Double_t maximum=-FLT_MAX; 401 for (Int_t idx=0; idx<fNcells-2; idx++) 402 if (MatchSector(idx, sector, aidx) && (all || IsUsed(idx)) && fArray[idx+1]>maximum) 403 maximum = fArray[idx+1]; 404 405 return Profile(maximum); 420 for (Int_t i=0; i<fNcells-2; i++) 421 { 422 if (TestBit(kProfile) && fBinEntries[i+1]==0) 423 continue; 424 425 const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1]; 426 if (MatchSector(i, sector, aidx) && (all || IsUsed(i)) && val>maximum) 427 maximum = val; 428 } 429 430 return maximum; 406 431 } 407 432 … … 458 483 // resized in paint to keep the correct aspect ratio 459 484 // 460 pad->Divide(1, 1, 0, 0, col); 485 // The margin != 0 is a workaround for a problem in root 4.02/00 486 pad->Divide(1, 1, 1e-10, 1e-10, col); 461 487 pad->cd(1); 462 488 gPad->SetBorderMode(0); … … 1125 1151 Double_t val=0; 1126 1152 if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/) 1153 { 1127 1154 SetUsed(idx); 1128 1129 Fill(idx, val); // FIXME: Slow!1155 Fill(idx, val); // FIXME: Slow! 1156 } 1130 1157 } 1131 1158 fEntries++; … … 1153 1180 } 1154 1181 1182 Stat_t MHCamera::GetBinContent(Int_t bin) const 1183 { 1184 if (fBuffer) ((TProfile*)this)->BufferEmpty(); 1185 if (bin < 0) bin = 0; 1186 if (bin >= fNcells) bin = fNcells-1; 1187 if (!fArray) return 0; 1188 1189 if (!TestBit(kProfile)) 1190 return Stat_t (fArray[bin]); 1191 1192 if (fBinEntries.fArray[bin] == 0) return 0; 1193 return fArray[bin]/fBinEntries.fArray[bin]; 1194 } 1195 1155 1196 Stat_t MHCamera::GetBinError(Int_t bin) const 1156 1197 { 1198 if (!TestBit(kProfile)) 1199 return TH1D::GetBinError(bin); 1200 1201 const UInt_t n = (UInt_t)fBinEntries[bin]; 1202 1203 if (n==0) 1204 return 0; 1205 1206 const Double_t sqr = fSumw2.fArray[bin] / n; 1207 const Double_t val = fArray[bin] / n; 1208 1209 return sqr>val*val ? TMath::Sqrt(sqr - val*val) / n : 0; 1210 1211 /* 1157 1212 Double_t rc = 0; 1158 1213 if (TestBit(kSqrtVariance) && GetEntries()>0) // error on the mean … … 1165 1220 rc = TH1D::GetBinError(bin); 1166 1221 1167 return Profile(rc); 1222 return Profile(rc);*/ 1168 1223 } 1169 1224 … … 1266 1321 { 1267 1322 Double_t val=threshold; 1268 if (event.GetPixelContent(val, idx, *fGeomCam, type)/* && !IsUsed(idx)*/) 1323 const Bool_t rc = event.GetPixelContent(val, idx, *fGeomCam, type); 1324 if (rc) 1325 SetUsed(idx); 1326 1327 const Bool_t cond = 1328 ( isabove && val>threshold) || 1329 (!isabove && val<threshold); 1330 1331 Fill(idx, rc && cond ? 1 : 0); 1332 } 1333 fEntries++; 1334 } 1335 1336 // ------------------------------------------------------------------------ 1337 // 1338 // Call this function to add a MCamEvent on top of the present contents. 1339 // - the contents of the pixels in event are added to each pixel 1340 // if the pixel of thresevt<threshold (in case isabove is set 1341 // to kTRUE == default) 1342 // - the contents of the pixels in event are added to each pixel 1343 // if the pixel of thresevt<threshold (in case isabove is set 1344 // to kFALSE) 1345 // 1346 // in unused pixel is not counted if it didn't fullfill the condition. 1347 // 1348 void MHCamera::CntCamContent(const MCamEvent &event, Int_t type1, const MCamEvent &thresevt, Int_t type2, Double_t threshold, Bool_t isabove) 1349 { 1350 if (fNcells<=1 || IsFreezed()) 1351 return; 1352 1353 // FIXME: Security check missing! 1354 for (Int_t idx=0; idx<fNcells-2; idx++) 1355 { 1356 Double_t th=0; 1357 if (!thresevt.GetPixelContent(th, idx, *fGeomCam, type2)) 1358 continue; 1359 1360 if ((isabove && th>threshold) || (!isabove && th<threshold)) 1361 continue; 1362 1363 Double_t val=th; 1364 if (event.GetPixelContent(val, idx, *fGeomCam, type1)) 1269 1365 { 1270 1366 SetUsed(idx); 1271 1272 if (isabove && val>threshold) 1273 Fill(idx); 1274 if (!isabove && val<threshold) 1275 Fill(idx); 1367 Fill(idx, val); 1276 1368 } 1277 1369 } … … 1672 1764 return; 1673 1765 1674 gLog << all << GetTitle() << " <" << GetName() << ">" << endl;1766 gLog << all << GetTitle() << " <" << GetName() << ">" << dec << endl; 1675 1767 gLog << "Software Pixel Idx: " << idx << endl; 1676 1768 gLog << "Hardware Pixel Id: " << idx+1 << endl; … … 1678 1770 if (GetBinError(idx+1)>0) 1679 1771 gLog << " +/- " << GetBinError(idx+1); 1680 gLog << " <" << (IsUsed(idx)?"on":"off") << "> "<< endl;1772 gLog << " <" << (IsUsed(idx)?"on":"off") << "> n=" << fBinEntries[idx+1] << endl; 1681 1773 1682 1774 if (fNotify && fNotify->GetSize()>0) -
trunk/MagicSoft/Mars/mhist/MHCamera.h
r6276 r6855 10 10 #ifndef ROOT_TArrayI 11 11 #include <TArrayI.h> 12 #endif13 #ifndef ROOT_TArrayD14 #include <TArrayD.h>15 12 #endif 16 13 #ifndef ROOT_MArrayD … … 40 37 public: 41 38 enum { 42 kProfile = BIT(18), // FIXME: When changing change max/min! 43 kFreezed = BIT(19), 44 kNoLegend = BIT(20), 45 kSqrtVariance = BIT(21) 39 kProfile = BIT(18), // FIXME: When changing change max/min! 40 kFreezed = BIT(19), 41 kNoLegend = BIT(20)/*, 42 kSqrtVariance = BIT(21), 43 kSinglePixelProfile = BIT(22)*/ 46 44 }; 47 45 private: 48 46 MGeomCam *fGeomCam; // pointer to camera geometry (y-axis) 49 47 TArrayC fUsed; // array containing flags 48 TArrayI fBinEntries; // number of entries per bin 50 49 51 50 TArrayI fColors; //! Color conversion table … … 59 58 60 59 void Init(); 61 60 /* 62 61 Stat_t Profile(Stat_t val) const 63 62 { … … 68 67 return n>0 ? val/n : val; 69 68 } 70 69 */ 71 70 Int_t GetColor(Float_t val, Float_t min, Float_t max, Bool_t islog); 72 71 … … 162 161 virtual void CntCamContent(const MCamEvent &evt, TArrayD threshold, Int_t type=0, Bool_t isabove=kTRUE); 163 162 virtual void CntCamContent(const TArrayD &evt, Double_t threshold, Bool_t ispos=kTRUE); 164 165 Stat_t GetBinContent(Int_t bin) const { return Profile(TH1D::GetBinContent(bin)); } 163 virtual void CntCamContent(const MCamEvent &event, Int_t type1, const MCamEvent &thresevt, Int_t type2, Double_t threshold, Bool_t isabove); 164 165 Stat_t GetBinContent(Int_t bin) const; 166 166 Stat_t GetBinContent(Int_t binx, Int_t biny) const { return GetBinContent(binx); } 167 167 Stat_t GetBinContent(Int_t binx, Int_t biny, Int_t binz) const { return GetBinContent(binx); } -
trunk/MagicSoft/Mars/mhist/MHEvent.cc
r6569 r6855 59 59 #include "MTaskList.h" 60 60 #include "MParList.h" 61 #include "M CerPhotEvt.h"61 #include "MSignalCam.h" 62 62 #include "MRawEvtHeader.h" 63 63 #include "MRawRunHeader.h" … … 239 239 break; 240 240 case kEvtArrTime: 241 fHist->SetCamContent(*event, 0);241 fHist->SetCamContent(*event, 6); 242 242 break; 243 243 case kEvtTrigPix: -
trunk/MagicSoft/Mars/mhist/MHEvent.h
r5807 r6855 13 13 class MMcEvt; 14 14 class MMcTrig; 15 class M CerPhotEvt;15 class MSignalCam; 16 16 class MImgCleanStd; 17 17 … … 34 34 MMcEvt *fMcEvt; //! 35 35 MMcTrig *fMcTrig; //! 36 M CerPhotEvt*fCerPhotEvt; //!36 MSignalCam *fCerPhotEvt; //! 37 37 MImgCleanStd *fImgCleanStd; //! 38 38 -
trunk/MagicSoft/Mars/mhist/Makefile
r5676 r6855 40 40 MHThetabarTheta.cc \ 41 41 MHGamma.cc \ 42 MHSigmaTheta.cc \43 42 MHSigmaPixel.cc \ 44 43 MHSigmabarTheta.cc \
Note:
See TracChangeset
for help on using the changeset viewer.