Changeset 8920 for trunk


Ignore:
Timestamp:
06/03/08 13:52:54 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgeom
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h

    r8386 r8920  
    66
    77#pragma link C++ class MGeomPix+;
    8 #pragma link C++ class MGeomCam+;
     8#pragma link C++ class MGeomCam-;
    99#pragma link C++ class MGeomPMT+;
    1010#pragma link C++ class MGeomMirror+;
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r8756 r8920  
    2020!   Author(s): Markus Gaug      03/2004 <mailto:markus@ifae.es>
    2121!
    22 !   Copyright: MAGIC Software Development, 2000-2007
     22!   Copyright: MAGIC Software Development, 2000-2008
    2323!
    2424\* ======================================================================== */
     
    6565#include "MGeomCam.h"
    6666
     67#include <TMath.h>      // TMath
    6768#include <TClass.h>     // IsA()->New()
    6869#include <TArrayI.h>    // TArrayI
     
    9697
    9798    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//
     107void 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]);
    99133}
    100134
     
    348382// --------------------------------------------------------------------------
    349383//
    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//
     388void MGeomCam::Print(Option_t *o) const
    353389{
    354390    //
     
    359395    *fLog << " Min.Radius: " << GetMinRadius() << "  Max.Radius: " << GetMaxRadius() << endl;
    360396
    361     fPixels.Print();
     397    if (!TString(o).Contains("simple", TString::kIgnoreCase))
     398        fPixels.Print();
    362399}
    363400
     
    508545    return -1;
    509546}
     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//
     563void 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  
    5050    MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL);
    5151
    52     virtual TObject *Clone(const char *newname=NULL) const;
     52    TObject *Clone(const char *newname=NULL) const;
     53    void Copy(TObject &o) const;
    5354
    5455    void CalcPixRatio();
Note: See TracChangeset for help on using the changeset viewer.