Changeset 1524 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 09/16/02 10:10:17 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MH3.cc
r1483 r1524 62 62 #include <fstream.h> 63 63 64 #include <TPad.h> 65 #include <TStyle.h> 66 #include <TCanvas.h> 67 64 68 #include <TH2.h> 65 69 #include <TH3.h> 66 70 #include <TProfile.h> 67 71 #include <TProfile2D.h> 68 #include <TPad.h>69 #include <TCanvas.h>70 72 71 73 #include "MLog.h" … … 73 75 74 76 #include "MParList.h" 75 77 #include "MBinning.h" 76 78 #include "MDataChain.h" 77 79 … … 202 204 return kFALSE; 203 205 } 206 if (binsz->IsLogarithmic()) 207 fHist->SetBit(kIsLogz); 204 208 fHist->SetZTitle(fData[2]->GetTitle()); 205 209 if (!fData[2]->PreProcess(plist)) … … 212 216 return kFALSE; 213 217 } 218 if (binsy->IsLogarithmic()) 219 fHist->SetBit(kIsLogy); 214 220 fHist->SetYTitle(fData[1]->GetTitle()); 215 221 if (!fData[1]->PreProcess(plist)) … … 222 228 return kFALSE; 223 229 } 230 if (binsx->IsLogarithmic()) 231 fHist->SetBit(kIsLogx); 224 232 fHist->SetXTitle(fData[0]->GetTitle()); 225 233 if (!fData[0]->PreProcess(plist)) … … 306 314 return kFALSE; 307 315 } 316 /* 317 // -------------------------------------------------------------------------- 318 // 319 // Set the palette you wanna use: 320 // - you could set the root "Pretty Palette Violet->Red" by 321 // gStyle->SetPalette(1, 0), but in some cases this may look 322 // confusing 323 // - The maximum colors root allowes us to set by ourself 324 // is 50 (idx: 51-100). This colors are set to a grayscaled 325 // palette 326 // - the number of contours must be two less than the number 327 // of palette entries 328 // 329 void MHStarMap::PrepareDrawing() const 330 { 331 const Int_t numg = 32; // number of gray scaled colors 332 const Int_t numw = 32; // number of white 333 334 Int_t palette[numg+numw]; 335 336 // 337 // The first half of the colors are white. 338 // This is some kind of optical background supression 339 // 340 gROOT->GetColor(51)->SetRGB(1, 1, 1); 341 342 Int_t i; 343 for (i=0; i<numw; i++) 344 palette[i] = 51; 345 346 // 347 // now the (gray) scaled part is coming 348 // 349 for (;i<numw+numg; i++) 350 { 351 const Float_t gray = 1.0-(float)(i-numw)/(numg-1.0); 352 353 gROOT->GetColor(52+i)->SetRGB(gray, gray, gray); 354 palette[i] = 52+i; 355 } 356 357 // 358 // Set the palette and the number of contour levels 359 // 360 gStyle->SetPalette(numg+numw, palette); 361 fStarMap->SetContour(numg+numw-2); 362 } 363 */ 364 // -------------------------------------------------------------------------- 365 // 366 // Setup a inversed deep blue sea palette for the fCenter histogram. 367 // 368 void MH3::SetColors() const 369 { 370 // FIXME: This must be redone each time the canvas is repainted.... 371 gStyle->SetPalette(51, NULL); 372 Int_t c[50]; 373 for (int i=0; i<50; i++) 374 c[49-i] = gStyle->GetColorPalette(i); 375 gStyle->SetPalette(50, c); 376 } 308 377 309 378 // -------------------------------------------------------------------------- 310 379 // 311 380 // Draw clone of histogram. So that the object can be deleted 381 // 382 // Possible options are: 383 // PROFX: Draw a x-profile into the histogram (for 2D histograms only) 384 // PROFY: Draw a y-profile into the histogram (for 2D histograms only) 385 // ONLY: Draw the profile histogram only (for 2D histograms only) 386 // 387 // If the kIsLog?-Bit is set the axis is displayed lkogarithmically. 388 // eg this is set when applying a logarithmic MBinning 389 // 312 390 // and the histogram is still visible in the canvas. 313 391 // The cloned object are deleted together with the canvas if the canvas is … … 324 402 gROOT->SetSelectedPad(NULL); 325 403 326 fHist->DrawCopy(opt);327 328 404 TString str(opt); 405 406 if (str.Contains("COL", TString::kIgnoreCase)) 407 SetColors(); 408 409 Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2; 410 if (!only) 411 fHist->DrawCopy(opt); 412 329 413 if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2) 330 414 { 331 415 TProfile *p = ((TH2*)fHist)->ProfileX(); 332 p->Draw( "same");416 p->Draw(only?"":"same"); 333 417 p->SetBit(kCanDelete); 334 418 p->SetDirectory(NULL); … … 337 421 { 338 422 TProfile *p = ((TH2*)fHist)->ProfileY(); 339 p->Draw( "same");423 p->Draw(only?"":"same"); 340 424 p->SetBit(kCanDelete); 341 425 p->SetDirectory(NULL); 342 426 } 343 427 428 if (fHist->TestBit(kIsLogx)) c.SetLogx(); 429 if (fHist->TestBit(kIsLogy)) c.SetLogy(); 430 if (fHist->TestBit(kIsLogz)) c.SetLogz(); 431 344 432 c.Modified(); 345 433 c.Update(); … … 351 439 // 352 440 // Creates a new canvas and draws the histogram into it. 441 // 442 // Possible options are: 443 // PROFX: Draw a x-profile into the histogram (for 2D histograms only) 444 // PROFY: Draw a y-profile into the histogram (for 2D histograms only) 445 // ONLY: Draw the profile histogram only (for 2D histograms only) 446 // 447 // If the kIsLog?-Bit is set the axis is displayed lkogarithmically. 448 // eg this is set when applying a logarithmic MBinning 449 // 353 450 // Be careful: The histogram belongs to this object and won't get deleted 354 451 // together with the canvas. … … 359 456 MH::MakeDefCanvas(fHist); 360 457 361 fHist->Draw(opt);362 363 458 TString str(opt); 459 460 if (str.Contains("COL", TString::kIgnoreCase)) 461 SetColors(); 462 463 Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2; 464 if (!only) 465 fHist->Draw(opt); 466 364 467 if (str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2) 365 468 { 366 469 TProfile *p = ((TH2*)fHist)->ProfileX(); 367 p->Draw( "same");470 p->Draw(only?"":"same"); 368 471 p->SetBit(kCanDelete); 369 472 p->SetDirectory(NULL); … … 372 475 { 373 476 TProfile *p = ((TH2*)fHist)->ProfileY(); 374 p->Draw( "same");477 p->Draw(only?"":"same"); 375 478 p->SetBit(kCanDelete); 376 479 p->SetDirectory(NULL); 377 480 } 481 482 if (fHist->TestBit(kIsLogx)) gPad->SetLogx(); 483 if (fHist->TestBit(kIsLogy)) gPad->SetLogy(); 484 if (fHist->TestBit(kIsLogz)) gPad->SetLogz(); 378 485 379 486 gPad->Modified(); -
trunk/MagicSoft/Mars/mhist/MH3.h
r1481 r1524 26 26 void StreamPrimitive(ofstream &out) const; 27 27 28 enum { 29 kIsLogx = BIT(15), 30 kIsLogy = BIT(16), 31 kIsLogz = BIT(17) 32 }; 33 28 34 public: 29 35 MH3(); … … 48 54 const TH1 &GetHist() const { return *fHist; } 49 55 56 void SetColors() const; 50 57 void Draw(Option_t *opt=NULL); 51 58 TObject *DrawClone(Option_t *opt=NULL) const; -
trunk/MagicSoft/Mars/mhist/MHHillas.cc
r1504 r1524 170 170 const MBinning *bins = (MBinning*)plist->FindObject("BinningCamera"); 171 171 if (!bins) 172 *fLog << warn << "Object 'BinningCamera' [MBinning] not found... no binning applied." << endl; 172 { 173 float r = geom ? geom->GetMaxRadius() : 600; 174 r *= 0.9; 175 if (!fUseMmScale) 176 r *= fMm2Deg; 177 178 MBinning b; 179 b.SetEdges(61, -r, r); 180 SetBinning(fCenter, &b, &b); 181 } 173 182 else 174 183 SetBinning(fCenter, bins, bins); 184 175 185 176 186 return kTRUE; -
trunk/MagicSoft/Mars/mhist/MHMatrix.cc
r1511 r1524 56 56 #include "MLogManip.h" 57 57 58 #include "MFillH.h" 59 #include "MEvtLoop.h" 58 60 #include "MParList.h" 61 #include "MTaskList.h" 59 62 60 63 #include "MData.h" … … 63 66 ClassImp(MHMatrix); 64 67 65 static const TStringgsDefName = "MHMatrix";66 static const TStringgsDefTitle = "Multidimensional Matrix";68 const TString MHMatrix::gsDefName = "MHMatrix"; 69 const TString MHMatrix::gsDefTitle = "Multidimensional Matrix"; 67 70 68 71 // -------------------------------------------------------------------------- … … 105 108 // event (row) was filled into the matrix. For the syntax of the rule 106 109 // see MDataChain. 107 // 108 void MHMatrix::AddColumn(const char *rule) 110 // Returns the index of the new column, -1 in case of failure. 111 // (0, 1, 2, ... for the 1st, 2nd, 3rd, ...) 112 // 113 Int_t MHMatrix::AddColumn(const char *rule) 109 114 { 110 115 if (fM.IsValid()) 111 116 { 112 117 *fLog << warn << "Warning - matrix is already in use. Can't add a new column... skipped." << endl; 113 return; 118 return -1; 119 } 120 121 if (TestBit(kIsLocked)) 122 { 123 *fLog << warn << "Warning - matrix is locked. Can't add new column... skipped." << endl; 124 return -1; 114 125 } 115 126 … … 121 132 122 133 fData->AddEntry(rule); 134 return fData->GetNumEntries()-1; 123 135 } 124 136 … … 128 140 { 129 141 *fLog << warn << "Warning - matrix is already in use. Can't add new columns... skipped." << endl; 142 return; 143 } 144 145 if (TestBit(kIsLocked)) 146 { 147 *fLog << warn << "Warning - matrix is locked. Can't add new columns... skipped." << endl; 130 148 return; 131 149 } … … 519 537 fM = m; 520 538 } 539 540 Bool_t MHMatrix::Fill(MParList *plist, MTask *read) 541 { 542 // 543 // Read data into Matrix 544 // 545 const Bool_t is = plist->IsOwner(); 546 plist->SetOwner(kFALSE); 547 548 MTaskList tlist; 549 plist->Replace(&tlist); 550 551 MFillH fillh(this); 552 553 tlist.AddToList(read); 554 tlist.AddToList(&fillh); 555 556 MEvtLoop evtloop; 557 evtloop.SetParList(plist); 558 559 if (!evtloop.Eventloop()) 560 return kFALSE; 561 562 plist->Remove(&tlist); 563 plist->SetOwner(is); 564 565 return kTRUE; 566 } -
trunk/MagicSoft/Mars/mhist/MHMatrix.h
r1511 r1524 1 1 #ifndef MARS_MHMatrix 2 2 #define MARS_MHMatrix 3 4 #ifdef MARS_MLogManip 5 #error Please make ensure that MLogManip.h are included _after_ MHMatrix.h 6 #endif 3 7 4 8 #ifndef ROOT_TMatrix … … 10 14 11 15 class TArrayI; 16 17 class MTask; 18 class MParList; 12 19 class MDataArray; 13 20 14 21 class MHMatrix : public MH 15 22 { 16 protected: 23 private: 24 static const TString gsDefName; //! Default Name 25 static const TString gsDefTitle; //! Default Title 26 17 27 Int_t fNumRow; //! Number of dimensions of histogram 28 Int_t fRow; //! Present row 18 29 TMatrix fM; // Matrix to be filled 19 30 … … 23 34 24 35 enum { 25 kIsOwner = BIT(14) 36 kIsOwner = BIT(14), 37 kIsLocked = BIT(16) 26 38 }; 27 39 … … 39 51 ~MHMatrix(); 40 52 41 void AddColumn(const char *name); 53 void Lock() { SetBit(kIsLocked); } 54 void Unlock() { ResetBit(kIsLocked); } 55 56 Int_t AddColumn(const char *name); 42 57 void AddColumns(MDataArray *mat); 43 58 … … 45 60 46 61 const TMatrix &GetM() const { return fM; } 62 63 Bool_t IsValid() const { return fM.IsValid(); } 64 Int_t GetNumRows() const { return fNumRow; } 47 65 48 66 //void Draw(Option_t *opt=NULL); … … 56 74 Double_t CalcDist(const TVector &v, Int_t num = 25); 57 75 58 void Set IOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); }76 void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); } 59 77 60 78 void Reassign(); … … 63 81 void SortMatrixByColumn(Int_t ncol=0, Bool_t desc=kTRUE); 64 82 83 Bool_t SetNumRow(Int_t row) { if (row>=fNumRow || row<0) return kFALSE; fRow = row; return kTRUE; } 84 Int_t GetNumRow() const { return fRow; }; 85 Double_t operator[](Int_t col) { return fM(fRow, col); } 86 87 Bool_t Fill(MParList *plist, MTask *read); 88 65 89 ClassDef(MHMatrix, 1) // Multidimensional Matrix to store events 66 90 }; -
trunk/MagicSoft/Mars/mhist/MHStarMap.cc
r1330 r1524 73 73 // connect all the histogram with the container fHist 74 74 // 75 fStarMap = new TH2F("StarMap", " 2D Hillas Star Map",75 fStarMap = new TH2F("StarMap", " 2D Hillas Star Map ", 76 76 150, -300, 300, 77 77 150, -300, 300); … … 96 96 // 97 97 // Setup the Binning for the histograms automatically if the correct 98 // instances of MBinning (with the names 'Binning Width' and 'BinningLength')98 // instances of MBinning (with the names 'BinningCamera') 99 99 // are found in the parameter list 100 100 // Use this function if you want to set the conversion factor which
Note:
See TracChangeset
for help on using the changeset viewer.