Changeset 9947 for trunk/Mars


Ignore:
Timestamp:
09/29/10 08:07:08 (14 years ago)
Author:
tbretz
Message:
Implemented a new mirror type MMirrorHex90 and a possibility to write a file with a relfector definition.
Location:
trunk/Mars
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/Changelog

    r9945 r9947  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2010/09/29 Thomas Bretz
     22
     23   * msimreflector/MMirrorHex.[h,cc]:
     24     - implemented WriteM
     25     - implemented new class MMirrorHex90
     26
     27   * msimreflector/SimReflectorLinkDef.h:
     28     - added MMirrorHex90
     29
     30   * msimreflector/MMirrorDisk.[h,cc], msimreflector/MMirrorSquare.[h,cc]:
     31     - implemented WriteM
     32
     33   * msimreflector/MReflector.[h,cc]:
     34     - added function to write a file with a reflector definition
     35
     36   * msimreflector/MMirror.h:
     37     - added virtual WriteM
     38     - added several Getter for Z, Nx, Ny, Nz and Shape
     39
     40
    2041
    2142 2010/09/28 Thomas Bretz
  • trunk/Mars/NEWS

    r9937 r9947  
    6969
    7070   * Added reading of re-used corsika showers (only supported if MMCS is used)
     71
     72   * Added new mirror type MMirrorHex90 (MMirrorHex rotated by 90deg)
    7173
    7274 ;star:
  • trunk/Mars/msimreflector/MMirror.h

    r9565 r9947  
    5656    Double_t X() const { return fPos.X(); }
    5757    Double_t Y() const { return fPos.Y(); }
     58    Double_t Z() const { return fPos.Z(); }
     59
     60    Double_t Nx() const { return fNorm.X(); }
     61    Double_t Ny() const { return fNorm.Y(); }
     62    Double_t Nz() const { return fNorm.Z(); }
    5863
    5964    TVector2 GetPosXY() const { return fPos.XYvector(); }
     
    6570
    6671    Double_t GetDist() const { return fPos.Perp(); }
     72    Int_t GetShape() const { return fShape; }
    6773
    6874    virtual Double_t GetMaxR() const=0;// { return TMath::Max(fMaxRX, fMaxRY); }
     
    8692
    8793    virtual Int_t ReadM(const TObjArray &tok)=0;
     94    virtual void  WriteM(std::ostream &out) const=0;
    8895
    8996    // TObject
  • trunk/Mars/msimreflector/MMirrorDisk.cc

    r9594 r9947  
    166166    return 1;
    167167}
     168
     169// ------------------------------------------------------------------------
     170//
     171void MMirrorDisk::WriteM(ostream &out) const
     172{
     173    out << fR*2;
     174}
  • trunk/Mars/msimreflector/MMirrorDisk.h

    r9371 r9947  
    2222
    2323    Int_t ReadM(const TObjArray &tok);
     24    void  WriteM(std::ostream &out) const;
    2425
    2526    //TObject
  • trunk/Mars/msimreflector/MMirrorHex.cc

    r9371 r9947  
    184184    return 1;
    185185}
     186
     187// ------------------------------------------------------------------------
     188//
     189void MMirrorHex::WriteM(ostream &out) const
     190{
     191    out << fD*2;
     192}
     193
     194// ------------------------------------------------------------------------
     195//
     196// Check if the given position coincides with the mirror. The position
     197// is assumed to be the incident point on the mirror's surface.
     198//
     199// The coordinates are in the mirrors coordinate frame.
     200//
     201// The action should coincide with what is painted in Paint()
     202//
     203Bool_t MMirrorHex90::HasHit(const MQuaternion &p) const
     204{
     205    // p is the incident point in the mirror in the mirror's
     206    // coordinate frame
     207
     208    // Black spot in the mirror center (here we can fairly ignore
     209    // the distance from the plane to the mirror surface, as long
     210    // as the black spot does not become too large)
     211    if (p.R2()<0.5*0.5)
     212        return kFALSE;
     213
     214    //
     215    // Now check if point is outside of hexagon; just check x coordinate
     216    // in three coordinate systems: the default one, in which two sides of
     217    // the hexagon are paralel to the y axis (see camera displays) and two
     218    // more, rotated with respect to that one by +- 60 degrees.
     219    //
     220    if (TMath::Abs(p.Y())>fD)
     221        return kFALSE;
     222
     223    const Double_t dxs = p.X()*fgSin60;
     224    const Double_t dyc = p.Y()*fgCos60;
     225
     226    if (TMath::Abs(dxs+dyc)>fD)
     227        return kFALSE;
     228
     229    if (TMath::Abs(dxs-dyc)>fD)
     230        return kFALSE;
     231
     232    return kTRUE;
     233}
     234
     235// ------------------------------------------------------------------------
     236//
     237// Paint the mirror in x/y.
     238//
     239// The graphic should coincide with the action in HasHit
     240//
     241void MMirrorHex90::Paint(Option_t *opt)
     242{
     243    MHexagon h;
     244    TEllipse e;
     245    h.SetFillColor(18);
     246    if (!TString(opt).Contains("line", TString::kIgnoreCase))
     247    {
     248        h.SetFillColor(17);
     249        h.SetLineStyle(0);
     250        e.SetLineStyle(0);
     251        e.SetFillColor(gPad->GetFillColor());
     252    }
     253
     254    if (TString(opt).Contains("same", TString::kIgnoreCase))
     255    {
     256        h.SetFillStyle(0);
     257        e.SetFillStyle(0);
     258    }
     259
     260    h.PaintHexagon(X(), Y(), fD*2, TMath::Pi()/2);
     261
     262    if (!TString(opt).Contains("border", TString::kIgnoreCase))
     263        e.PaintEllipse(X(), Y(), 0.5, 0.5, 0, 360, 0);
     264}
  • trunk/Mars/msimreflector/MMirrorHex.h

    r9573 r9947  
    88class MMirrorHex : public MMirror
    99{
    10 private:
     10protected:
    1111    const static Double_t fgCos30;
    1212    const static Double_t fgCos60;
     
    3030
    3131    Int_t ReadM(const TObjArray &tok);
     32    void  WriteM(std::ostream &out) const;
    3233
    3334    // TObject
     
    3839};
    3940
     41class MMirrorHex90 : public MMirrorHex
     42{
     43public:
     44    MMirrorHex90() : MMirrorHex() { }
     45
     46    // MMirror
     47    Bool_t HasHit(const MQuaternion &p) const;
     48
     49    // TObject
     50    void Paint(Option_t *);
     51
     52    ClassDef(MMirrorHex90, 1) // A spherical hexagon type mirror (MMirrorHex rotated by 90deg)
     53};
     54
    4055#endif
  • trunk/Mars/msimreflector/MReflector.cc

    r9565 r9947  
    351351}
    352352
     353// ------------------------------------------------------------------------
     354//
     355Bool_t MReflector::WriteFile(TString fname) const
     356{
     357    gSystem->ExpandPathName(fname);
     358
     359    ofstream fout(fname);
     360    if (!fout)
     361    {
     362        *fLog << err << "Cannot open file " << fname << ": ";
     363        *fLog << (errno!=0?strerror(errno):"Insufficient memory for decompression") << endl;
     364        return kFALSE;
     365    }
     366
     367    TIter Next(&fMirrors);
     368    MMirror *m = 0;
     369    while ((m=static_cast<MMirror*>(Next())))
     370    {
     371        //  x:         x-coordinate of the mirror's center
     372        //  y:         y-coordinate of the mirror's center
     373        //  z:         z-coordinate of the mirror's center
     374        //  nx:        x-component of the normal vecor in the mirror center
     375        //  ny:        y-component of the normal vecor in the mirror center
     376        //  nz:        z-component of the normal vecor in the mirror center
     377        //  [shape]:   S for spherical <default>, P for parabolic
     378        //  F:         Focal distance of a spherical mirror
     379        //  [psf]:     This number is the psf given in the units of x,y,z and
     380        //             defined at the focal distance F. It can be used to overwrite
     381        //             the second argument given in ReadFile for individual mirrors.
     382        //  Type:      A instance of a mirrot of the class Type MMirrorType is created
     383        //             (Type can be, for example, Hex for for MMirrorHex).
     384        //  ...:       Additional arguments as defined in MMirrorType::ReadM
     385
     386        fout << setw(12) << m->X() << " ";
     387        fout << setw(12) << m->Y() << " ";
     388        fout << setw(12) << m->Z() << "  ";
     389        fout << setw(12) << m->Nx() << " ";
     390        fout << setw(12) << m->Ny() << " ";
     391        fout << setw(12) << m->Nz() << " ";
     392        if (m->GetShape()==1)
     393            fout << "P ";
     394        fout << m->GetFocalLength() << " ";
     395        // cout << m->GetSigmaPSF() << " ";
     396        fout << m->ClassName()+7 << " ";
     397        m->WriteM(fout);
     398        fout << endl;
     399    }
     400    return kTRUE;
     401}
     402
    353403// --------------------------------------------------------------------------
    354404//
  • trunk/Mars/msimreflector/MReflector.h

    r9371 r9947  
    4343
    4444    Bool_t ReadFile(TString fname, Double_t defpsf=-1);
     45    Bool_t WriteFile(TString fname) const;
    4546
    4647    Double_t GetMaxR() const { return fMaxR; }
  • trunk/Mars/msimreflector/SimReflectorLinkDef.h

    r9903 r9947  
    1313#pragma link C++ class MMirrorDisk+;
    1414#pragma link C++ class MMirrorHex+;
     15#pragma link C++ class MMirrorHex90+;
    1516
    1617#endif
Note: See TracChangeset for help on using the changeset viewer.