- Timestamp:
- 06/03/08 15:12:40 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mgeom
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r8920 r8921 96 96 fPixels.SetOwner(); 97 97 98 // For root versions <5.18 AddAt is mandatory, for newer 99 // root-version the []-operator can be used safely 98 100 for (UInt_t i=0; i<npix; i++) 99 101 fPixels.AddAt(new MGeomPix, i); … … 354 356 } 355 357 356 357 358 // -------------------------------------------------------------------------- 358 359 // … … 398 399 fPixels.Print(); 399 400 } 400 401 // --------------------------------------------------------------------------402 //403 // Create a clone of this container. This is very easy, because we404 // simply have to create a new object of the same type.405 //406 TObject *MGeomCam::Clone(const char *newname) const407 {408 if (IsA()==MGeomCam::Class())409 {410 MGeomCam *cam = new MGeomCam(fNumPixels, fCamDist);411 for (UInt_t i=0; i<fNumPixels; i++)412 {413 //if (fPixels.UncheckedAt(i))414 (*this)[i].Copy((*cam)[i]);415 }416 cam->InitGeometry();417 return cam;418 }419 420 return (TObject*)IsA()->New();421 }422 401 423 402 // -------------------------------------------------------------------------- … … 546 525 } 547 526 548 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,18,00) 549 #include <TClass.h> 550 #endif 527 // -------------------------------------------------------------------------- 528 // 529 // This workaround reproduces (as much as possible) the contents 530 // of fPixels which got lost writing MGeomCam in which the 531 // fPixels were filles with the []-operator instead of AddAt 532 // and a root version previous to 5.18. 533 // You try to read broken contents from file if fNumPixels is empty 534 // but fNumPixels>0. 535 // If you ever read broken contents from a split branch you 536 // MUST call this function after reading. 537 // 538 void MGeomCam::StreamerWorkaround() 539 { 540 if (fNumPixels==0 || !fPixels.IsEmpty()) 541 return; 542 543 TObject *cam = (TObject*)IsA()->New(); 544 cam->Copy(*this); 545 delete cam; 546 } 551 547 552 548 // -------------------------------------------------------------------------- … … 566 562 { 567 563 MGeomCam::Class()->ReadBuffer(b, this); 568 569 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,18,00) 570 if (IsA()!=MGeomCam::Class() && fPixels.GetEntriesFast()==0) 571 { 572 MGeomCam *c = (MGeomCam*)IsA()->New(); 573 c->Copy(*this); 574 delete c; 575 } 576 #endif 564 StreamerWorkaround(); 577 565 } 578 566 else -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r8920 r8921 50 50 MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL); 51 51 52 TObject *Clone(const char *newname=NULL) const;53 52 void Copy(TObject &o) const; 54 53 55 void CalcPixRatio();56 54 // FIXME, workaround: this function is made public just to allow 57 55 // the use of some camera files from the 0.7 beta version in which the 58 56 // array containing pixel ratios is not initialized. 57 void CalcPixRatio(); 58 59 // FIXME, workaround broken streaming 60 void StreamerWorkaround(); 61 59 62 void InitGeometry() 60 63 { … … 106 109 Int_t GetNeighbor(UInt_t idx, Int_t dir) const; 107 110 108 v irtual void Print(Option_t *opt=NULL)const;111 void Print(Option_t *opt=NULL) const; 109 112 110 113 ClassDef(MGeomCam, 5) // Geometry base class for the camera
Note:
See TracChangeset
for help on using the changeset viewer.