Changeset 5994
- Timestamp:
- 01/25/05 14:47:59 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r5991 r5994 28 28 29 29 30 30 31 2005/01/25 Thomas Bretz 31 32 … … 37 38 - moved the empty Reset() function into the source file and 38 39 added a lot of comments 40 - implemented new helper-functions: GetNewObject 41 42 * mbase/MContinue.[h,cc]: 43 - allow to use MFilter-classes as filter in ReadEnv 44 45 * mbase/MTaskEnv.cc: 46 - replaced some code by GetNewObject 47 48 * mhbase/MFillH.cc: 49 - handle DrawOption "same" to be able to draw to the same pad 50 51 * mhbase/MH.[h,cc]: 52 - added same-argument to DrawSame 53 54 * mhbase/MH3.cc: 55 - removed some obsolete comments 56 - remove own drawing options before calling fHist->Draw 57 58 * mimage/MHHillas.cc, mimage/MHImagePar.cc: 59 - first try of implementing 'same' drawing option 39 60 40 61 -
trunk/MagicSoft/Mars/mbase/MContinue.cc
r5956 r5994 241 241 // MyContinue.0: MHillas.fSize>1000 242 242 // MyContinue.1: MHillas.fSize<10000 243 // or 243 // or (the syntax might change in the future!) 244 244 // MyContinue.Condition: <MMyClass> 245 245 // MMyClass.Variable1: ... … … 250 250 Int_t MContinue::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 251 251 { 252 MFilter *f = 0; 252 253 if (IsEnvDefined(env, prefix, "Condition", print)) 253 254 { … … 256 257 if (txt.BeginsWith("<") && txt.EndsWith(">")) 257 258 { 258 *fLog << err << "NOT YET IMPLEMENTED..." << endl; 259 return kERROR; 259 const TString name = txt(1, txt.Length()-2); 260 f = (MFilter*)GetNewObject(name, MFilter::Class()); 261 if (!f) 262 return kERROR; 260 263 } 261 264 } 262 265 263 MF *f = new MF; 266 if (!f) 267 f = new MF; 264 268 f->SetName(fName); 265 269 -
trunk/MagicSoft/Mars/mbase/MContinue.h
r5956 r5994 30 30 Int_t PostProcess(); 31 31 32 // MContinue 32 33 enum { kIsOwner = BIT(14), kFilterIsPrivate = BIT(15), kAllowEmpty = BIT(16) }; 33 34 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r5986 r5994 465 465 } 466 466 467 // -------------------------------------------------------------------------- 468 // 469 // Return the pointer to the TClass (from the root dictionary) which 470 // corresponds to the class with name name. 471 // 472 // Make sure, that a new object of this type can be created. 473 // 474 // In case of failure return NULL 475 // 476 TClass *MParContainer::GetConstructor(const char *name) const 477 { 478 // 479 // try to get class from root environment 480 // 481 TClass *cls = gROOT->GetClass(name); 482 Int_t rc = 0; 483 if (!cls) 484 rc =1; 485 else 486 { 487 if (!cls->Property()) 488 rc = 5; 489 if (!cls->Size()) 490 rc = 4; 491 if (!cls->IsLoaded()) 492 rc = 3; 493 if (!cls->HasDefaultConstructor()) 494 rc = 2; 495 } 496 497 if (!rc) 498 return cls; 499 500 *fLog << err << dbginf << GetDescriptor() << " - Cannot create new instance of class '" << name << "': "; 501 switch (rc) 502 { 503 case 1: 504 *fLog << "gROOT->GetClass() returned NULL." << endl; 505 return NULL; 506 case 2: 507 *fLog << "no default constructor." << endl; 508 return NULL; 509 case 3: 510 *fLog << "not loaded." << endl; 511 return NULL; 512 case 4: 513 *fLog << "zero size." << endl; 514 return NULL; 515 case 5: 516 *fLog << "no property." << endl; 517 return NULL; 518 } 519 520 *fLog << "rtlprmft." << endl; 521 522 return NULL; 523 } 524 525 // -------------------------------------------------------------------------- 526 // 527 // Return a new object of class 'name'. Make sure that the object 528 // derives from the class base. 529 // 530 // In case of failure return NULL 531 // 532 // The caller is responsible of deleting the object! 533 // 534 MParContainer *MParContainer::GetNewObject(const char *name, TClass *base) const 535 { 536 TClass *cls = GetConstructor(name); 537 if (!cls || !base) 538 return NULL; 539 540 if (!cls->InheritsFrom(base)) 541 { 542 *fLog << " - Class doesn't inherit from " << base->GetName() << endl; 543 return NULL; 544 } 545 546 // 547 // create the parameter container of the the given class type 548 // 549 TObject *obj = (TObject*)cls->New(); 550 if (!obj) 551 { 552 *fLog << " - Class has no default constructor." << endl; 553 *fLog << " - An abstract member functions of a base class is not overwritten." << endl; 554 return NULL; 555 } 556 557 return (MParContainer*)obj; 558 } 559 560 // -------------------------------------------------------------------------- 561 // 562 // Return a new object of class 'name'. Make sure that the object 563 // derives from the class base. 564 // 565 // In case of failure return NULL 566 // 567 // The caller is responsible of deleting the object! 568 // 569 MParContainer *MParContainer::GetNewObject(const char *name, const char *base) const 570 { 571 TClass *cls = GetConstructor(name); 572 if (!cls || !base) 573 return NULL; 574 575 if (!cls->InheritsFrom(base)) 576 { 577 *fLog << " - Class doesn't inherit from " << base << endl; 578 return NULL; 579 } 580 581 // 582 // create the parameter container of the the given class type 583 // 584 TObject *obj = (TObject*)cls->New(); 585 if (!obj) 586 { 587 *fLog << " - Class has no default constructor." << endl; 588 *fLog << " - An abstract member functions of a base class is not overwritten." << endl; 589 return NULL; 590 } 591 592 return (MParContainer*)obj; 593 } 594 467 595 TMethodCall *MParContainer::GetterMethod(const char *name) const 468 596 { -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r5986 r5994 53 53 54 54 Bool_t fReadyToSave; // should be set to true if the contents of the container is changed somehow 55 56 TClass *GetConstructor(const char *name) const; 55 57 56 58 public: … … 140 142 const char *GetEnvValue(const TEnv &env, TString prefix, const char *dflt) const; 141 143 144 MParContainer *GetNewObject(const char *name, const char *base) const; 145 MParContainer *GetNewObject(const char *name, TClass *base=MParContainer::Class()) const; 146 142 147 ClassDef(MParContainer, 0) //The basis for all parameter containers 143 148 }; -
trunk/MagicSoft/Mars/mbase/MTaskEnv.cc
r5307 r5994 100 100 MTask *MTaskEnv::GetTask(const char *name) const 101 101 { 102 // 103 // try to get class from root environment 104 // 105 TClass *cls = gROOT->GetClass(name); 106 Int_t rc = 0; 107 if (!cls) 108 rc =1; 109 else 110 { 111 if (!cls->Property()) 112 rc = 5; 113 if (!cls->Size()) 114 rc = 4; 115 if (!cls->IsLoaded()) 116 rc = 3; 117 if (!cls->HasDefaultConstructor()) 118 rc = 2; 119 } 120 121 if (rc) 122 { 123 *fLog << err << dbginf << "Cannot create new instance of class '" << name << "': "; 124 switch (rc) 125 { 126 case 1: 127 *fLog << "gROOT->GetClass() returned NULL." << endl; 128 return NULL; 129 case 2: 130 *fLog << "no default constructor." << endl; 131 return NULL; 132 case 3: 133 *fLog << "not loaded." << endl; 134 return NULL; 135 case 4: 136 *fLog << "zero size." << endl; 137 return NULL; 138 case 5: 139 *fLog << "no property." << endl; 140 return NULL; 141 } 142 } 143 144 if (!cls->InheritsFrom(MTask::Class())) 145 { 146 *fLog << " - Class doesn't inherit from MTask." << endl; 102 MTask *task = (MTask*)GetNewObject(name, MTask::Class()); 103 if (!task) 147 104 return NULL; 148 }149 150 //151 // create the parameter container of the the given class type152 //153 MTask *task = (MTask*)cls->New();154 if (!task)155 {156 *fLog << " - Class has no default constructor." << endl;157 *fLog << " - An abstract member functions of a base class is not overwritten." << endl;158 return NULL;159 }160 105 161 106 task->SetName(fName); -
trunk/MagicSoft/Mars/mhbase/MFillH.cc
r5713 r5994 358 358 // if fDisplay is set and the MH-class overwrites the Draw function 359 359 // 360 // If the draw-option contains 'same' (case insensitive) a tab with the 361 // same name as the one which would be created is searched and the 362 // MH is drawn to this canvas. If it is not found a new tab is created. 363 // 360 364 Bool_t MFillH::DrawToDisplay() 361 365 { … … 371 375 return kTRUE; 372 376 373 fCanvas = &fDisplay->AddTab(fNameTab.IsNull() ? fH->GetName() : fNameTab.Data()); 377 const TString tabname = fNameTab.IsNull() ? fH->GetName() : fNameTab.Data(); 378 379 fCanvas = 0; 380 if (fDrawOption.Contains("same", TString::kIgnoreCase)) 381 fCanvas = fDisplay->GetCanvas(tabname); 382 if (!fCanvas) 383 fCanvas = &fDisplay->AddTab(tabname); 384 385 fCanvas->cd(); 374 386 fH->Draw(fDrawOption); 375 387 -
trunk/MagicSoft/Mars/mhbase/MH.cc
r5869 r5994 795 795 // Also layout the two statistic boxes and a legend. 796 796 // 797 void MH::DrawSame(TH1 &hist1, TH1 &hist2, const TString title )797 void MH::DrawSame(TH1 &hist1, TH1 &hist2, const TString title, Bool_t same) 798 798 { 799 799 // 800 800 // Draw first histogram 801 801 // 802 hist1.Draw( );802 hist1.Draw(same?"same":""); 803 803 gPad->SetBorderMode(0); 804 804 gPad->Update(); -
trunk/MagicSoft/Mars/mhbase/MH.h
r4991 r5994 85 85 86 86 static void DrawSameCopy(const TH1 &hist1, const TH1 &hist2, const TString title); 87 static void DrawSame(TH1 &hist1, TH1 &hist2, const TString title );87 static void DrawSame(TH1 &hist1, TH1 &hist2, const TString title, Bool_t same=kFALSE); 88 88 89 89 TObject *Clone(const char *name="") const; -
trunk/MagicSoft/Mars/mhbase/MH3.cc
r5956 r5994 103 103 // 104 104 MH3::MH3(const unsigned int dim) 105 : fDimension(dim>3?3:dim), fHist(NULL)/*, 106 fNameProfX(Form("ProfX_%p", this)), 107 fNameProfY(Form("ProfY_%p", this))*/ 105 : fDimension(dim>3?3:dim), fHist(NULL) 108 106 { 109 107 switch (fDimension) … … 205 203 // 206 204 MH3::MH3(const char *memberx, const char *membery) 207 : fDimension(2) /*, fNameProfX(Form("ProjX_%p", this)), fNameProfY(Form("ProjY_%p", this))*/205 : fDimension(2) 208 206 { 209 207 fHist = new TH2F; … … 539 537 540 538 TString str(o); 541 str = str.Strip(TString::kBoth); 542 543 Bool_t only = str.Contains("ONLY", TString::kIgnoreCase) && fDimension==2; 544 Bool_t same = str.Contains("SAME", TString::kIgnoreCase) && fDimension==2; 545 Bool_t blue = str.Contains("BLUE", TString::kIgnoreCase) && fDimension==2; 539 str.ToLower(); 540 541 const Bool_t only = str.Contains("only") && fDimension==2; 542 const Bool_t same = str.Contains("same") && fDimension==2; 543 const Bool_t blue = str.Contains("blue") && fDimension==2; 544 const Bool_t profx = str.Contains("profx") && fDimension==2; 545 const Bool_t profy = str.Contains("profy") && fDimension==2; 546 // Do NOT replace 'same'-option 547 str.ReplaceAll("only", ""); 548 str.ReplaceAll("blue", ""); 549 str.ReplaceAll("profx", ""); 550 str.ReplaceAll("profy", ""); 546 551 547 552 // FIXME: We may have to remove all our own options from str! … … 549 554 fHist->Draw(str); 550 555 551 if ( str.Contains("PROFX", TString::kIgnoreCase) && fDimension==2)556 if (profx) 552 557 { 553 558 TProfile *p = ((TH2*)fHist)->ProfileX("ProfX", -1, 9999, "s"); … … 563 568 } 564 569 } 565 if ( str.Contains("PROFY", TString::kIgnoreCase) && fDimension==2)570 if (profy) 566 571 { 567 572 TProfile *p = ((TH2*)fHist)->ProfileY("ProfY", -1, 9999, "s"); -
trunk/MagicSoft/Mars/mimage/MHHillas.cc
r5142 r5994 286 286 // together with the canvas. 287 287 // 288 void MHHillas::Draw(Option_t * )288 void MHHillas::Draw(Option_t *o) 289 289 { 290 290 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this); … … 293 293 AppendPad(""); 294 294 295 pad->Divide(2,3); 295 TString opt(o); 296 opt.ToLower(); 297 298 // FIXME: If same-option given make two independant y-axis! 299 const Bool_t same = opt.Contains("same"); 300 301 if (!same) 302 pad->Divide(2,3); 303 else 304 { 305 fDistC->SetLineColor(kGreen); 306 fSize->SetLineColor(kGreen); 307 fDelta->SetLineColor(kGreen); 308 309 fWidth->SetLineColor(kMagenta); 310 fLength->SetLineColor(kCyan); 311 } 296 312 297 313 pad->cd(1); 298 314 gPad->SetBorderMode(0); 299 MH::DrawSame(*fWidth, *fLength, "Width'n'Length" );315 MH::DrawSame(*fWidth, *fLength, "Width'n'Length", same); 300 316 301 317 pad->cd(2); 302 318 gPad->SetBorderMode(0); 303 fDistC->Draw( );319 fDistC->Draw(same?"same":""); 304 320 305 321 pad->cd(3); … … 307 323 gPad->SetLogx(); 308 324 gPad->SetLogy(); 309 fSize->Draw(); 310 311 pad->cd(4); 312 gPad->SetBorderMode(0); 313 gPad->SetPad(0.51, 0.01, 0.99, 0.65); 314 SetColors(); 315 fCenter->Draw("colz"); 316 if (fGeomCam) 317 { 318 MHCamera *cam = new MHCamera(*fGeomCam); 319 cam->Draw("same"); 320 cam->SetBit(kCanDelete); 325 fSize->Draw(same?"same":""); 326 327 if (!same) 328 { 329 pad->cd(4); 330 gPad->SetBorderMode(0); 331 gPad->SetPad(0.51, 0.01, 0.99, 0.65); 332 SetColors(); 333 fCenter->Draw("colz"); 334 if (fGeomCam) 335 { 336 MHCamera *cam = new MHCamera(*fGeomCam); 337 cam->Draw("same"); 338 cam->SetBit(kCanDelete); 339 } 321 340 } 322 341 323 342 pad->cd(5); 324 343 gPad->SetBorderMode(0); 325 fDelta->Draw( );344 fDelta->Draw(same?"same":""); 326 345 327 346 pad->cd(6); 328 delete gPad; 347 if (gPad && !same) 348 delete gPad; 329 349 330 350 pad->Modified(); -
trunk/MagicSoft/Mars/mimage/MHImagePar.cc
r5142 r5994 136 136 void MHImagePar::Paint(Option_t *o) 137 137 { 138 if (TString(o)==(TString)"log1" && fHistSatHi.GetMaximum()>0) 139 gPad->SetLogy(); 140 if (TString(o)==(TString)"log2" && fHistIslands.GetMaximum()>0) 141 gPad->SetLogy(); 138 /* 139 if (TString(o)==(TString)"log1" && fHistSatHi.GetMaximum()>0) 140 gPad->SetLogy(); 141 if (TString(o)==(TString)"log2" && fHistIslands.GetMaximum()>0) 142 gPad->SetLogy(); 143 */ 144 if (fHistSatHi.GetMaximum()>0 && gPad->GetPad(1)) 145 gPad->GetPad(1)->SetLogy(); 146 if (fHistIslands.GetMaximum()>0 && gPad->GetPad(2)) 147 gPad->GetPad(2)->SetLogy(); 142 148 } 143 149 … … 148 154 // together with the canvas. 149 155 // 150 void MHImagePar::Draw(Option_t * )156 void MHImagePar::Draw(Option_t *o) 151 157 { 152 158 TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this); … … 155 161 AppendPad(""); 156 162 157 pad->Divide(1,2); 158 159 pad->cd(1); 160 gPad->SetBorderMode(0); 161 MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels"); 162 fHistSatHi.SetMinimum(); // switch off to allow log-scale 163 fHistSatLo.SetMinimum(); // switch off to allow log-scale 164 fHistSatLo.SetMaximum(0.1); // dummy value to allow log-scale 165 AppendPad("log1"); 163 TString opt(o); 164 opt.ToLower(); 165 166 // FIXME: If same-option given make two independant y-axis! 167 const Bool_t same = opt.Contains("same"); 168 169 if (!same) 170 pad->Divide(1,2); 171 else 172 fHistIslands.SetLineColor(kGreen); 173 174 if (!same) 175 { 176 pad->cd(1); 177 gPad->SetBorderMode(0); 178 MH::DrawSame(fHistSatHi, fHistSatLo, "Saturating Pixels"); 179 fHistSatHi.SetMinimum(); // switch off to allow log-scale 180 fHistSatLo.SetMinimum(); // switch off to allow log-scale 181 fHistSatLo.SetMaximum(0.1); // dummy value to allow log-scale 182 //AppendPad("log1"); 183 } 166 184 167 185 pad->cd(2); 168 186 gPad->SetBorderMode(0); 169 fHistIslands.Draw( );170 AppendPad("log2");187 fHistIslands.Draw(same?"same":""); 188 //AppendPad("log2"); 171 189 } 172 190
Note:
See TracChangeset
for help on using the changeset viewer.