Changeset 9578 for trunk/MagicSoft
- Timestamp:
- 05/05/10 09:51:51 (15 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9576 r9578 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2010/05/05 Thomas Bretz 22 23 * mastro/MAstro.cc: 24 - fixed AngularDistance (called a non existing function and 25 the compiler didn't complain) 26 27 * mbase/MParContainer.[h,cc]: 28 - added static function Overwrites (previously in MTask) 29 30 * mbase/MStatusDisplay.[h,cc]: 31 - allow writing a MStatusDisplay without writing a MStatusArray 32 (therefore added SeveAsPlainRoot) 33 - improved reading of files just containing canvases and objects 34 35 * mbase/MTask.[h,cc]: 36 - moved code from Overwrites to a static function in MParContainer 37 38 * msimcamera/MSimCalibrationSignal.cc: 39 - changed distribution of signal from Gauss to Poissonian 40 20 41 21 42 2010/04/22 Thomas Bretz -
trunk/MagicSoft/Mars/mastro/MAstro.cc
r9314 r9578 376 376 Double_t MAstro::AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1) 377 377 { 378 TVector3 v0(1); 379 v0.Rotate(phi0, theta0); 380 381 TVector3 v1(1); 382 v1.Rotate(phi1, theta1); 383 384 return v0.Angle(v1); 378 // v1 = theta0/phi0 --> theta0 / 0 379 // v2 = theta1/phi1 --> theta1 / phi1-phi0 380 // acos(alpha) = v1*v2/|v1||v2| |v1|*|v2|=1 381 const Double_t sin2 = TMath::Sin(theta0)*TMath::Sin(theta1); 382 const Double_t cos2 = TMath::Cos(theta0)*TMath::Cos(theta1); 383 384 return TMath::ACos(sin2*TMath::Cos(phi1-phi0) + cos2); 385 /* 386 TVector3 v0; 387 v0.SetMagThetaPhi(1, theta0, phi0); 388 389 TVector3 v1; 390 v1.SetMagThetaPhi(1, theta0, phi0); 391 392 return v0.Angle(v1); 393 */ 385 394 } 386 395 -
trunk/MagicSoft/Mars/mbase/MParContainer.cc
r9302 r9578 237 237 // -------------------------------------------------------------------------- 238 238 // 239 // Check down to base whether the class given in the argument 240 // overwrites the function given by name. 241 // 242 // This function calls itself recursively. If you want to call it, 243 // leave out the argument. 244 // 245 Bool_t MParContainer::Overwrites(const TClass *base, const TObject &obj, const char *name, TClass *cls) 246 { 247 if (!cls) 248 cls = obj.IsA(); 249 250 // 251 // Check whether we reached the base class MTask 252 // 253 if (cls==base) 254 return kFALSE; 255 256 // 257 // Check whether the class cls overwrites Process 258 // 259 if (cls->GetMethodAny(name)) 260 return kTRUE; 261 262 // 263 // If the class itself doesn't overload it check all it's base classes 264 // 265 TBaseClass *basecls=NULL; 266 TIter NextBase(cls->GetListOfBases()); 267 while ((basecls=(TBaseClass*)NextBase())) 268 { 269 if (Overwrites(base, obj, name, basecls->GetClassPointer())) 270 return kTRUE; 271 } 272 273 return kFALSE; 274 } 275 276 277 // -------------------------------------------------------------------------- 278 // 239 279 // Return a unique name for this container. It is created from 240 280 // the container name and the unique Id. (This is mostly used -
trunk/MagicSoft/Mars/mbase/MParContainer.h
r9186 r9578 82 82 static const TString GetDescriptor(const TObject &o); 83 83 84 static Bool_t Overwrites(const TClass *base, const TObject &obj, const char *name, TClass *cls=NULL); 85 84 86 virtual const TString GetDescriptor() const; 85 87 virtual const TString GetUniqueName() const; -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r9574 r9578 278 278 savemenu->AddEntry(MString::Format("%s&C", fname.Data()), kFileSaveAsC); 279 279 savemenu->AddEntry(MString::Format("%s&root", fname.Data()), kFileSaveAsRoot); 280 savemenu->AddEntry(MString::Format("%s&root (plain)", fname.Data()), kFileSaveAsPlainRoot); 280 281 savemenu->Associate(this); 281 282 … … 1723 1724 return kTRUE; 1724 1725 1726 case kFileSaveAsPlainRoot: 1727 SaveAsPlainRoot(kTRUE); 1728 return kTRUE; 1729 1725 1730 case kFilePrint: 1726 1731 PrintPS(); … … 1777 1782 case kTabSaveAsC: 1778 1783 SaveAsC(fTab->GetCurrent()); 1784 return kTRUE; 1785 1786 case kTabSaveAsPlainRoot: 1787 SaveAsPlainRoot(fTab->GetCurrent()); 1779 1788 return kTRUE; 1780 1789 … … 2276 2285 } 2277 2286 2287 // The first entry in the list is a TNamed which is expected to 2288 // contain the status display title. 2278 2289 fTitle = o->GetTitle(); 2279 2290 … … 2312 2323 // 2313 2324 // If no status display was found with this name try to find canvases 2314 // in the file and s´display them instead.2325 // in the file and display them instead. 2315 2326 // 2316 2327 if (n==0) 2317 2328 { 2329 // Either read the title from the file or create our own 2330 TNamed *n=0; 2331 gFile->GetObject("Title", n); // FIXME: Is the list allowed to take ownership? 2332 list.Add(n ? n : new TNamed(GetName(), GetTitle())); 2333 2318 2334 const Bool_t store = TH1::AddDirectoryStatus(); 2319 2335 TH1::AddDirectory(kFALSE); … … 2325 2341 TCanvas *c=0; 2326 2342 gFile->GetObject(key->GetName(), c); 2343 2344 // If key doesn't correspond to a TCanvas create a new canvas 2345 // and draw the object itself instead. 2327 2346 if (!c) 2328 2347 { 2329 AddTab(key->GetName(), key->GetTitle());2330 2348 TObject *obj = gFile->Get(key->GetName()); 2331 obj->SetBit(kCanDelete); 2332 obj->Draw(); 2349 2350 if (MParContainer::Overwrites(TObject::Class(), *obj, "Draw") || 2351 MParContainer::Overwrites(TObject::Class(), *obj, "Paint")) 2352 { 2353 AddTab(key->GetName(), key->GetTitle()); 2354 obj->SetBit(kCanDelete); 2355 obj->Draw(); 2356 } 2357 // FIXME: Is the object deleted? 2333 2358 continue; 2334 2359 } 2335 2360 2336 if (list.GetEntries()==0) 2337 list.Add(new TNamed(GetName(), GetTitle())); 2338 2361 // Add teh canvas to the list 2339 2362 c->SetTitle(gFile->GetName()); 2340 2363 list.Add(c); … … 2343 2366 TH1::AddDirectory(store); 2344 2367 2345 if (list.GetEntries() ==0)2368 if (list.GetEntries()<=1) 2346 2369 { 2347 *fLog << warn << "MStatusDisplay::Read: No objects read from " << gFile->GetName() << endl;2370 *fLog << warn << "MStatusDisplay::Read: No drawable objects read from " << gFile->GetName() << endl; 2348 2371 return 0; 2349 2372 } 2350 2373 2351 *fLog << inf << "MStatusDisplay: " << list.GetEntries() << " canvases directly read from file." << endl;2374 *fLog << inf << "MStatusDisplay: " << list.GetEntries()-1 << " canvases directly read from file." << endl; 2352 2375 } 2353 2376 … … 2358 2381 return 0; 2359 2382 } 2360 2361 2383 2362 2384 if (n==0) … … 2423 2445 } 2424 2446 2425 MStatusArray list; 2426 2427 // Be careful: So far Display() assumes that it is the first entry in the list 2428 TNamed named; 2429 named.SetTitle(fTitle); 2430 list.Add(&named); 2431 2432 FillArray(list, num); 2433 2434 const Int_t n = list.Write(name, kSingleKey); 2435 2436 //*fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl; 2447 Int_t n = 0; // Number of keys written 2448 2449 TNamed named("Title", fTitle.Data()); 2450 2451 if (TString(option)=="plain") 2452 { 2453 // Get canvas range to store 2454 Int_t from, to; 2455 GetCanvasRange(from, to, num); 2456 2457 n += named.Write(); 2458 2459 TCanvas *c; 2460 for (int i=from; i<to; i++) 2461 if ((c = GetCanvas(i))) 2462 n += c->Write(); 2463 } 2464 else 2465 { 2466 // Be careful: So far Display() assumes that the TNamed 2467 // is the first entry in the list 2468 MStatusArray list; 2469 list.Add(&named); 2470 2471 FillArray(list, num); 2472 2473 n += list.Write(name, kSingleKey); 2474 } 2475 2476 *fLog << inf << "MStatusDisplay: " << n << " keys written to file as key " << name << "." << endl; 2437 2477 2438 2478 return n; … … 3029 3069 // -------------------------------------------------------------------------- 3030 3070 // 3031 // In case of num<0 all tabs are written into the PS file. If num>0 3071 // In case of num<0 all tabs are written into a root file. As plain 3072 // TCanvas objects if plain==kTRUE otherwise in a MStatusArray. If num>0 3032 3073 // the canvas in the corresponding tab is written to the file. 3033 3074 // Name is the name of the file (with or without extension). … … 3035 3076 // Returns the number of keys written. 3036 3077 // 3037 // To write all tabs you can also use SaveAs PS(name)3038 // 3039 Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name )3078 // To write all tabs you can also use SaveAsRoot(name) 3079 // 3080 Int_t MStatusDisplay::SaveAsRoot(Int_t num, TString name, Bool_t plain) 3040 3081 { 3041 3082 num = InitWriteDisplay(num, name, "root"); … … 3045 3086 TFile *fsave = gFile; 3046 3087 TFile file(name, "RECREATE", GetTitle(), 9); 3047 const Int_t keys = Write(num );3088 const Int_t keys = Write(num, plain ? "plain" : ""); 3048 3089 gFile = fsave; 3049 3090 -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.h
r9185 r9578 49 49 kFileSaveAsPS, kFileSaveAsPDF, kFileSaveAsSVG, kFileSaveAsRoot, 50 50 kFileSaveAsPNG, kFileSaveAsGIF, kFileSaveAsJPG, kFileSaveAsXPM, 51 kFileSaveAsBMP, kFileSaveAsCSV, kFileSaveAsTIFF, 51 kFileSaveAsBMP, kFileSaveAsCSV, kFileSaveAsTIFF, kFileSaveAsPlainRoot, 52 52 kFileSaveAsXML, kFileSaveAsC, kFilePrint, kFilePrinterName, 53 53 kFileClose, kFileExit, kFileReset, … … 58 58 kTabSaveAsRoot, kTabSaveAsPNG, kTabSaveAsGIF, kTabSaveAsJPG, 59 59 kTabSaveAsXPM, kTabSaveAsBMP, kTabSaveAsCSV, kTabSaveAsTIFF, 60 kTabSaveAsXML, kTabSaveAsC, 60 kTabSaveAsXML, kTabSaveAsC, kTabSaveAsPlainRoot, 61 61 kTabPrint, kTabNext, kTabPrevious, kTabRemove, 62 62 // kSize … … 253 253 Bool_t SaveAsC(TString name="") { return SaveAsC(-1, name); } 254 254 Int_t SaveAsRoot(TString name="") { return SaveAsRoot(-1, name); } 255 Int_t SaveAsPlainRoot(TString name="") { return SaveAsRoot(-1, name, kTRUE); } 255 256 Int_t SaveAs(TString name) { return SaveAs(-1, name); } 256 257 … … 271 272 Bool_t SaveAsXML(Int_t num, TString name="") { return SaveAsImage(num, name, TImage::kXml); } 272 273 Bool_t SaveAsC(Int_t num, TString name=""); 273 Int_t SaveAsRoot(Int_t num, TString name=""); 274 Int_t SaveAsRoot(Int_t num, TString name="", Bool_t plain=kFALSE); 275 Int_t SaveAsPlainRoot(Int_t num, TString name="") { return SaveAsRoot(num, name, kTRUE); } 274 276 Int_t SaveAs(Int_t num, TString name); 275 277 -
trunk/MagicSoft/Mars/mbase/MTask.cc
r9336 r9578 505 505 } 506 506 507 // --------------------------------------------------------------------------508 //509 // Check whether the class given in the argument overwrites MTask::Process.510 // This function calls itself recursively. If you want to call it,511 // leave out the argument.512 //513 Bool_t MTask::Overwrites(const char *name, TClass *cls) const514 {515 if (!cls)516 cls = IsA();517 518 //519 // Check whether we reached the base class MTask520 //521 if (cls==MTask::Class())522 return kFALSE;523 524 //525 // Check whether the class cls overwrites Process526 //527 if (cls->GetMethodAny(name))528 return kTRUE;529 530 //531 // If the class itself doesn't overload it check all it's base classes532 //533 TBaseClass *base=NULL;534 TIter NextBase(cls->GetListOfBases());535 while ((base=(TBaseClass*)NextBase()))536 {537 if (Overwrites(name, base->GetClassPointer()))538 return kTRUE;539 }540 541 return kFALSE;542 }543 544 507 void MTask::SetDisplay(MStatusDisplay *d) 545 508 { -
trunk/MagicSoft/Mars/mbase/MTask.h
r9336 r9578 79 79 80 80 const TList *GetListOfBranches() const { return fListOfBranches; } 81 Bool_t Overwrites(const char *name, TClass *cls=NULL) const ;81 Bool_t Overwrites(const char *name, TClass *cls=NULL) const { return MParContainer::Overwrites(MTask::Class(), *this, name, cls); } 82 82 83 83 // Filter functions -
trunk/MagicSoft/Mars/msimcamera/MSimCalibrationSignal.cc
r9425 r9578 61 61 62 62 #include "MGeomCam.h" 63 #include "MParSpline.h"64 63 #include "MTriggerPattern.h" 65 64 … … 69 68 #include "MPhotonEvent.h" 70 69 #include "MPhotonData.h" 70 71 #include "MParSpline.h" 71 72 72 73 ClassImp(MSimCalibrationSignal); … … 197 198 { 198 199 // FIXME: Scale number of photons with the pixel size! 199 const Int_t num = TMath::Nint(gRandom->Gaus(fNumPhotons, fNumPhotons/10));200 const Int_t num = gRandom->Poisson(fNumPhotons); 200 201 201 202 // FIXME: How does the distribution look like? Poissonian?
Note:
See TracChangeset
for help on using the changeset viewer.