- Timestamp:
- 06/03/08 13:52:54 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mgeom
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h
r8386 r8920 6 6 7 7 #pragma link C++ class MGeomPix+; 8 #pragma link C++ class MGeomCam +;8 #pragma link C++ class MGeomCam-; 9 9 #pragma link C++ class MGeomPMT+; 10 10 #pragma link C++ class MGeomMirror+; -
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r8756 r8920 20 20 ! Author(s): Markus Gaug 03/2004 <mailto:markus@ifae.es> 21 21 ! 22 ! Copyright: MAGIC Software Development, 2000-200 722 ! Copyright: MAGIC Software Development, 2000-2008 23 23 ! 24 24 \* ======================================================================== */ … … 65 65 #include "MGeomCam.h" 66 66 67 #include <TMath.h> // TMath 67 68 #include <TClass.h> // IsA()->New() 68 69 #include <TArrayI.h> // TArrayI … … 96 97 97 98 for (UInt_t i=0; i<npix; i++) 98 fPixels[i] = new MGeomPix; 99 fPixels.AddAt(new MGeomPix, i); 100 } 101 102 // -------------------------------------------------------------------------- 103 // 104 // Copy function. It does intentionally (see workaround in Streamer) 105 // not copy name and title. 106 // 107 void MGeomCam::Copy(TObject &o) const 108 { 109 MGeomCam &c = (MGeomCam&)o; 110 111 c.fNumPixels = fNumPixels; 112 c.fCamDist = fCamDist; 113 c.fConvMm2Deg = fConvMm2Deg; 114 115 c.fMaxRadius = fMaxRadius; 116 c.fMinRadius = fMinRadius; 117 c.fPixRatio = fPixRatio; 118 c.fPixRatioSqrt = fPixRatioSqrt; 119 120 c.fNumPixInSector = fNumPixInSector; 121 c.fNumPixWithAidx = fNumPixWithAidx; 122 123 Int_t n = fPixels.GetEntriesFast(); 124 Int_t m = c.fPixels.GetEntriesFast(); 125 126 c.fPixels.Expand(n); 127 128 for (int i=m; i<n; i++) 129 c.fPixels.AddAt(new MGeomPix, i); 130 131 for (int i=0; i<n; i++) 132 fPixels[i]->Copy(c[i]); 99 133 } 100 134 … … 348 382 // -------------------------------------------------------------------------- 349 383 // 350 // Prints the Geometry information of all pixels in the camera 351 // 352 void MGeomCam::Print(Option_t *) const 384 // Prints the Geometry information of all pixels in the camera. 385 // With the option "simple" you can suppress the output of the contents 386 // of the individual pixels. 387 // 388 void MGeomCam::Print(Option_t *o) const 353 389 { 354 390 // … … 359 395 *fLog << " Min.Radius: " << GetMinRadius() << " Max.Radius: " << GetMaxRadius() << endl; 360 396 361 fPixels.Print(); 397 if (!TString(o).Contains("simple", TString::kIgnoreCase)) 398 fPixels.Print(); 362 399 } 363 400 … … 508 545 return -1; 509 546 } 547 548 #if ROOT_VERSION_CODE >= ROOT_VERSION(5,18,00) 549 #include <TClass.h> 550 #endif 551 552 // -------------------------------------------------------------------------- 553 // 554 // This is a custom made streamer. Due to a bug in TObjArray::operator[] 555 // old root-versions didn't correctly store the contents of the TObjArray. 556 // If such a file is detected (TObjArray empty) a new MGeomCam is created 557 // with IsA()->New() and its contents is copied to this. Unfortunately 558 // this won't work for all MGeomCam derivatives which need arguments 559 // in the constructor and MGeomCam itself (no derivative). Fortunately 560 // in prodoction we have never stored anything else than MGeomCamMagic yet. 561 // The bug in root can be worked around using AddAt instead of operator[]. 562 // 563 void MGeomCam::Streamer(TBuffer &b) 564 { 565 if (b.IsReading()) 566 { 567 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 577 } 578 else 579 MGeomCam::Class()->WriteBuffer(b, this); 580 } -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r8756 r8920 50 50 MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL); 51 51 52 virtual TObject *Clone(const char *newname=NULL) const; 52 TObject *Clone(const char *newname=NULL) const; 53 void Copy(TObject &o) const; 53 54 54 55 void CalcPixRatio();
Note:
See TracChangeset
for help on using the changeset viewer.