Changeset 1965 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 04/19/03 18:39:05 (22 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MFillH.cc
r1715 r1965 72 72 73 73 #include <TClass.h> 74 #include <TCanvas.h> 74 75 75 76 #include "MDataChain.h" … … 82 83 83 84 #include "MParList.h" 85 #include "MStatusDisplay.h" 84 86 85 87 ClassImp(MFillH); … … 99 101 100 102 fIndex = NULL; 103 fCanvas = NULL; 101 104 } 102 105 … … 143 146 144 147 fTitle = "Fill " + fHName; 145 if ( !par)148 if (fParContainerName.IsNull()) 146 149 return; 147 150 … … 313 316 } 314 317 318 Bool_t MFillH::DrawToDisplay() 319 { 320 if (!fDisplay) 321 return kTRUE; 322 323 fCanvas = &fDisplay->AddTab(fH->GetName()); 324 fH->Draw(); 325 326 return kTRUE; 327 } 328 315 329 // -------------------------------------------------------------------------- 316 330 // … … 353 367 if (!obj) 354 368 { 369 /* 355 370 if (cls==name) 356 *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl; 371 *fLog << inf << "Object '" << fHName << "' not found in parlist... creating." << endl; 372 */ 357 373 obj = pList->FindCreateObj(cls, name); 358 374 } … … 369 385 if (!obj->InheritsFrom(tcls)) 370 386 { 371 *fLog << err << dbginf <<obj->GetName() << " doesn't inherit ";387 *fLog << err << obj->GetName() << " doesn't inherit "; 372 388 *fLog << "from " << tcls->GetName() << " - cannot be used for MFillH..."; 373 389 *fLog << "aborting." << endl; … … 383 399 if (!fH->SetupFill(pList)) 384 400 { 385 *fLog << err << dbginf << "Error: calling SetupFill for ";401 *fLog << err << "ERROR - Calling SetupFill for "; 386 402 *fLog << fH->GetDescriptor() << "... aborting." << endl; 387 403 return kFALSE; … … 392 408 // 393 409 if (fParContainer) 394 return kTRUE;395 396 // 397 // If a name is given try to find the input container in the398 // list. If it could not be found we cannot proceed.410 return DrawToDisplay(); 411 412 // 413 // This case means, that the MH sets up its container to be filled 414 // by itself. Check there if it has something to be filled with! 399 415 // 400 416 if (fParContainerName.IsNull()) 401 417 { 402 fParContainer = NULL; 403 return kTRUE;418 fParContainer = NULL; 419 return DrawToDisplay(); 404 420 } 405 421 406 422 fParContainer = (MParContainer*)pList->FindObject(fParContainerName); 407 408 423 if (fParContainer) 409 return kTRUE;410 411 *fLog << err << dbginf << "'" << fParContainerName << "'[MParContainer] not found... aborting." << endl;424 return DrawToDisplay(); 425 426 *fLog << err << fParContainerName << " [MParContainer] not found... aborting." << endl; 412 427 return kFALSE; 413 428 } … … 443 458 if (!fH->Finalize()) 444 459 { 445 *fLog << err << dbginf << "Error: calling Finalize for ";460 *fLog << err << "ERROR - Calling Finalize for "; 446 461 *fLog << fH->GetDescriptor() << "... aborting." << endl; 447 462 return kFALSE; … … 449 464 450 465 fH->SetReadyToSave(); 466 467 if (fDisplay) 468 { 469 fCanvas->cd(); 470 fH->DrawClone("nonew"); 471 } 472 451 473 return kTRUE; 452 474 } -
trunk/MagicSoft/Mars/mhist/MFillH.h
r1574 r1965 7 7 8 8 class MH; 9 class MMap; 9 10 class MData; 10 11 class MParList; 11 12 12 class MMap;13 class TCanvas; 13 14 14 15 class MFillH : public MTask … … 24 25 MMap *fMapIdx; //! Map to map key-index-pair for an MHArray (MMap see MFillH.cc) 25 26 27 TCanvas *fCanvas; 28 26 29 TString ExtractName(const char *name) const; 27 30 TString ExtractClass(const char *name) const; … … 30 33 31 34 void StreamPrimitive(ofstream &out) const; 35 36 Bool_t DrawToDisplay(); 32 37 33 38 public: -
trunk/MagicSoft/Mars/mhist/MH.cc
r1880 r1965 585 585 // 586 586 TH1 *h1 = (TH1*)((TH1&)hist1).DrawCopy(); 587 gPad->SetBorderMode(0); 587 588 gPad->Update(); 588 589 … … 653 654 // 654 655 hist1.Draw(); 656 gPad->SetBorderMode(0); 655 657 gPad->Update(); 656 658 … … 710 712 } 711 713 714 // -------------------------------------------------------------------------- 715 // 716 // If the opt string contains 'nonew' or gPad is not given NULL is returned. 717 // Other wise the present gPad is cleared and returned. 718 // 719 TVirtualPad *MH::GetNewPad(Option_t *opt) 720 { 721 TString str(opt); 722 723 if (!str.Contains("nonew", TString::kIgnoreCase) || !gPad) 724 return NULL; 725 726 gPad->Clear(); 727 return gPad; 728 } 729 730 // -------------------------------------------------------------------------- 731 // 732 // The object is cloned and drawn to the present pad. The kCanDelete 733 // bit is set for the clone. 734 // 735 TObject *MH::DrawClone(Option_t *opt="") const 736 { 737 gROOT->SetSelectedPad(NULL); 738 739 TObject *o = MParContainer::DrawClone(opt); 740 o->SetBit(kCanDelete); 741 return o; 742 } 743 744 // -------------------------------------------------------------------------- 745 // 746 // If the opt string contains 'nonew' or gPad is not given a new canvas 747 // with size w/h is created. Otherwise the object is cloned and drawn 748 // to the present pad. The kCanDelete bit is set for the clone. 749 // 750 TObject *MH::DrawClone(Option_t *opt, Int_t w, Int_t h) const 751 { 752 TVirtualPad *p = GetNewPad(opt); 753 if (!p) 754 p = MakeDefCanvas(this, w, h); 755 756 return MH::DrawClone(opt); 757 } -
trunk/MagicSoft/Mars/mhist/MH.h
r1879 r1965 15 15 class MBinning; 16 16 class MParList; 17 17 #include <iostream.h> 18 #include <TClass.h> 18 19 class MH : public MParContainer 19 20 { 21 private: 22 /* 23 void Draw(Option_t *opt="") 24 { 25 cout << "MH::Draw" << endl; 26 MParContainer::Draw(opt); 27 } 28 */ 29 20 30 public: 21 31 MH(const char *name=NULL, const char *title=NULL); … … 59 69 static void Draw(TH1 &hist1, TH1 &hist2, const TString title); 60 70 71 void Draw(Option_t *o="") { MParContainer::Draw(o); } 72 TObject *DrawClone(Option_t *opt="") const; 73 TObject *DrawClone(Option_t *opt, Int_t w, Int_t h) const; 74 75 static TVirtualPad *GetNewPad(Option_t *opt); 76 61 77 static void FindGoodLimits(Int_t nbins, Int_t &newbins, Double_t &xmin, Double_t &xmax, Bool_t isInteger); 62 78 static Double_t GetMinimumGT(const TH1 &h, Double_t gt=0); 79 80 63 81 64 82 ClassDef(MH, 1) //A histogram base class for Mars histograms -
trunk/MagicSoft/Mars/mhist/MH3.cc
r1838 r1965 600 600 MParContainer *MH3::New() const 601 601 { 602 cout << "1" <<endl;603 602 MH3 *h = NULL; 604 cout << "1a" <<endl; 605 606 if (fData[0] == NULL) 607 { 608 h=new MH3(fDimension); 609 } 610 else 611 switch (fDimension) 612 { 613 case 1: 614 h=new MH3(fData[0]->GetRule()); 615 break; 616 case 2: 617 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule()); 618 break; 619 case 3: 620 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule()); 621 break; 622 } 603 604 if (fData[0] == NULL) 605 h=new MH3(fDimension); 606 else 607 switch (fDimension) 608 { 609 case 1: 610 h=new MH3(fData[0]->GetRule()); 611 break; 612 case 2: 613 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule()); 614 break; 615 case 3: 616 h=new MH3(fData[0]->GetRule(), fData[1]->GetRule(), fData[2]->GetRule()); 617 break; 618 } 623 619 switch (fDimension) 624 620 { -
trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc
r1715 r1965 30 30 #include "MHCerPhotEvt.h" 31 31 32 #include <TCanvas.h> 33 32 34 #include "MLog.h" 33 35 #include "MLogManip.h" … … 35 37 #include "MParList.h" 36 38 #include "MCerPhotEvt.h" 39 #include "MCamDisplay.h" 40 41 #include "MGeomCam.h" 42 #include "MGeomPix.h" 37 43 38 44 ClassImp(MHCerPhotEvt); … … 40 46 // -------------------------------------------------------------------------- 41 47 // 42 // Setup four histograms for Width, Length 43 // 44 MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title) 45 : fEvt(NULL) 46 { 47 // 48 // set the name and title of this object 49 // 50 fName = name ? name : "MHCerPhotEvt"; 51 fTitle = title ? title : "Sum up camera events"; 52 48 // Reset all pixels to 0 and reset fEntries to 0. 49 // 50 void MHCerPhotEvt::Clear() 51 { 52 fSum.Reset(); 53 53 fSum.InitSize(577); 54 54 for (int i=0; i<577; i++) 55 { 55 56 fSum.AddPixel(i, 0, 0); 57 fSum[i].SetPixelUnused(); 58 } 59 60 fEntries = 0; 61 } 62 63 // -------------------------------------------------------------------------- 64 // 65 // Setup four histograms for Width, Length 66 // 67 MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title) 68 : fEvt(NULL), fCam(NULL), fDispl(NULL) 69 { 70 // 71 // set the name and title of this object 72 // 73 fName = name ? name : "MHCerPhotEvt"; 74 fTitle = title ? title : "Average of MCerPhotEvts"; 75 76 Clear(); 77 } 78 79 MHCerPhotEvt::~MHCerPhotEvt() 80 { 81 if (fDispl) 82 delete fDispl; 56 83 } 57 84 … … 72 99 *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl; 73 100 101 fCam = (MGeomCam*)plist->FindObject("MGeomCam"); 102 if (!fCam) 103 *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl; 104 105 Clear(); 106 74 107 return kTRUE; 75 108 } … … 95 128 const MCerPhotPix &pix = (*evt)[i]; 96 129 97 fSum[pix.GetPixId()].AddNumPhotons(pix.GetNumPhotons()); 98 } 130 const Int_t id = pix.GetPixId(); 131 132 const Double_t ratio = fCam ? fCam->GetPixRatio(id) : 1; 133 134 const Double_t val = pix.GetNumPhotons()/ratio; 135 136 fSum[id].SetPixelUsed(); 137 fSum[id].AddNumPhotons(val); 138 } 139 140 fEntries++; 141 99 142 return kTRUE; 100 143 } 101 144 145 Bool_t MHCerPhotEvt::Finalize() 146 { 147 fSum.Scale(fEntries); 148 return kTRUE; 149 } 150 151 TObject *MHCerPhotEvt::DrawClone(Option_t *opt) const 152 { 153 return MH::DrawClone(opt, 750, 600); 154 } 155 156 void MHCerPhotEvt::Draw(Option_t *) 157 { 158 if (!fCam) 159 { 160 *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl; 161 return; 162 } 163 164 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600); 165 pad->SetBorderMode(0); 166 167 // 168 // All this is necessary to get the background in the correct color 169 // 170 pad->Divide(1,1); 171 pad->cd(1); 172 173 gPad->SetBorderMode(0); 174 gPad->SetFillColor(gPad->GetFillColor()); 175 176 // 177 // set the color palette for the TBox elements 178 // 179 AppendPad(""); 180 181 // 182 // Necessary to visualize the background color (FIXME?) 183 // 184 gPad->Modified(); 185 gPad->Update(); 186 } 187 188 void MHCerPhotEvt::Paint(Option_t *option="") 189 { 190 if (!fCam) 191 { 192 *fLog << warn << "WARNING - Cannot paint " << GetDescriptor() << ": No Camera Geometry available." << endl; 193 return; 194 } 195 196 if (!fDispl) 197 fDispl = new MCamDisplay(fCam); 198 199 fDispl->FillPhotNum(fSum); 200 fDispl->Paint(); 201 } -
trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.h
r1715 r1965 11 11 12 12 class TH1D; 13 class MGeamCam; 14 class MCamDisplay; 13 15 14 16 class MHCerPhotEvt : public MH … … 16 18 private: 17 19 MCerPhotEvt fSum; 18 MCerPhotEvt *fEvt; //! 20 Int_t fEntries; 21 MCerPhotEvt *fEvt; //! 22 MGeomCam *fCam; 23 MCamDisplay *fDispl; //! 19 24 20 25 public: 21 26 MHCerPhotEvt(const char *name=NULL, const char *title=NULL); 27 ~MHCerPhotEvt(); 28 29 // TObject *Clone(const char *newname="") const; 30 31 void Clear(); 22 32 23 33 Bool_t SetupFill(const MParList *pList); 24 34 Bool_t Fill(const MParContainer *par); 35 Bool_t Finalize(); 25 36 26 37 TH1 *GetHistByName(const TString name) { return NULL; } … … 28 39 const MCerPhotEvt &GetSum() const { return fSum; } 29 40 30 ClassDef(MHCerPhotEvt, 1) // Container which holds histograms for the source independent image parameters 41 TObject *DrawClone(Option_t *opt) const; 42 void Draw(Option_t *); 43 void Paint(Option_t *option=""); 44 45 ClassDef(MHCerPhotEvt, 1) // Histogram to sum camera events 31 46 }; 32 47 -
trunk/MagicSoft/Mars/mhist/MHStarMap.cc
r1956 r1965 68 68 fTitle = title ? title : "Container for a Star Map" ; 69 69 70 *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl;71 72 70 // 73 71 // loop over all Pixels and create two histograms … … 137 135 return kTRUE; 138 136 } 137 138 *fLog << warn << "WARNING - Using MHStarMap doesn't take care of the Source Position!" << endl; 139 139 140 140 return kTRUE; … … 293 293 } 294 294 295 296 295 // -------------------------------------------------------------------------- 297 296 // … … 304 303 TObject *MHStarMap::DrawClone(Option_t *opt) const 305 304 { 306 TCanvas *c=MakeDefCanvas(fStarMap, 500, 500); 307 308 // 309 // This is necessary to get the expected bahviour of DrawClone 310 // 311 gROOT->SetSelectedPad(NULL); 312 313 PrepareDrawing(); 314 315 fStarMap->DrawCopy("colz"); 316 317 c->Modified(); 318 c->Update(); 319 320 return c; 305 return MH::DrawClone(opt, 500, 500); 321 306 } 322 307 … … 329 314 void MHStarMap::Draw(Option_t *) 330 315 { 331 if (!gPad) 332 MakeDefCanvas(fStarMap, 500, 500); 333 316 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 500, 500); 317 pad->SetBorderMode(0); 318 319 pad->Divide(1,1); 320 321 pad->cd(1); 322 gPad->SetBorderMode(0); 323 324 AppendPad(""); 325 } 326 327 void MHStarMap::Paint(Option_t *opt="") 328 { 329 // 330 // Maintain aspect ratio 331 // 332 const float w = gPad->GetWw(); 333 const float h = gPad->GetWh(); 334 335 if (h<w) 336 gPad->SetPad((1.-h/w)/2, 0, (h/w+1)/2, 1); 337 else 338 gPad->SetPad(0, (1.-w/h)/2, 1, (w/h+1)/2); 339 340 // 341 // Maintain colors 342 // 334 343 PrepareDrawing(); 335 344 336 fStarMap->Draw("colz");337 338 gPad->Modified();339 gPad->Update();340 } 345 // 346 // Paint Histogram 347 // 348 fStarMap->Paint("colz"); 349 } -
trunk/MagicSoft/Mars/mhist/MHStarMap.h
r1574 r1965 15 15 { 16 16 private: 17 TH2F *fStarMap; 17 TH2F *fStarMap; //-> 18 18 19 19 Float_t fMm2Deg; … … 22 22 23 23 void PrepareDrawing() const; 24 25 void Paint(Option_t *opt=""); 24 26 25 27 public: -
trunk/MagicSoft/Mars/mhist/Makefile
r1940 r1965 23 23 # 24 24 INCLUDES = -I. -I../mbase -I../mraw -I../manalysis -I../mmc \ 25 -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage 25 -I../mgui -I../mgeom -I../mdata -I../mfilter -I../mimage \ 26 -I../mmain 26 27 27 28 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.