Ignore:
Timestamp:
02/22/09 23:36:01 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msim/MSimPointingPos.cc

    r9354 r9362  
    2525//////////////////////////////////////////////////////////////////////////////
    2626//
    27 //  MSimPointingPos
     27// MSimPointingPos
     28//
    2829//
    2930// This task is meant to simulate the pointing position (mirror orientation).
     
    3132// on the user request (e.g. Wobble mode).
    3233//
    33 // WARNING: Currently the telescope orientation is just fixed to the
    34 //          direction in the run-header (if a view cone was given) or
    35 //          the direction in the evt-header (if no view cone given)
     34//
     35// If fOffTragetDistance==0 the telescope is oriented depending on the
     36// view cone option. If a view cone was given the orientation is fixed to
     37// the main direction around the view cone was produced. If no view
     38// cone was given the telescope is oriented parallel to the shower axis.
     39//
     40// If no view cone option was given and off-target observations are switched
     41// on by setting fOffTargetDistance!=0 the poitnting position is calculated:
     42//
     43//  1) fOffTargetDistance < 0:
     44//     The pointing position is randomly distributed in a disk of radius
     45//     -fOffTragetDistance. fOffTargetDistance is silently ignored.
     46//
     47//  2) fOffTargetDistance > 0:
     48//     The pointing position is set to a position in the given distance
     49//     away from the shower axis. If fOffTargetPhi>=0 it is fixed at
     50//     this phi value. For phi<0 it is randomly distributed at distances
     51//     fOffTargetDistance. (phi==0 is the direction of positive theta)
     52//
    3653//
    3754//  Input Containers:
     
    4158//  Output Containers:
    4259//   MPointingPos
    43 //   PointingCorsika [MPointingPos]
    4460//
    4561//////////////////////////////////////////////////////////////////////////////
     
    6884//
    6985MSimPointingPos::MSimPointingPos(const char* name, const char *title)
    70     : fRunHeader(0), fEvtHeader(0), fPointingCorsika(0), fPointingLocal(0),
    71     fOffTargetDistance(-1), fOffTargetPhi(-1)
     86    : fRunHeader(0), fEvtHeader(0), fPointing(0),
     87    fOffTargetDistance(0), fOffTargetPhi(-1)
    7288
    7389{
     
    8399Int_t MSimPointingPos::PreProcess(MParList *pList)
    84100{
    85 //    fPointingCorsika = (MPointingPos*)pList->FindCreateObj("MPointingPos", "PointingCorsika");
    86 //    if (!fPointingCorsika)
    87 //        return kFALSE;
    88 
    89     fPointingLocal = (MPointingPos*)pList->FindCreateObj("MPointingPos");
    90     if (!fPointingLocal)
     101    fPointing = (MPointingPos*)pList->FindCreateObj("MPointingPos");
     102    if (!fPointing)
    91103        return kFALSE;
    92104
     
    105117    }
    106118
    107     // FIXED offset
    108     // Diffuse?  ( FOV of camera folded with mirror diameter as Corsika input? )
    109     // Hour angle!
    110     // Angle to magnetic field!
    111 
    112     if (IsOffTargetObservation())
    113     {
    114         *fLog << inf;
    115         *fLog << "Off target observations switched on with" << endl;
     119    if (!IsOffTargetObservation())
     120        return kTRUE;
     121
     122    *fLog << inf;
     123    *fLog << "Off target observations switched on with" << endl;
     124    if (fOffTargetDistance>0)
     125    {
    116126        *fLog <<"   a pointing distance of " << GetOffTargetDistance() << "deg ";
    117127        if (fOffTargetPhi<0)
     
    120130            *fLog << "and phi=" << GetOffTargetPhi() << "deg." << endl;
    121131    }
     132    else
     133        *fLog << "   a homogenous distribution up to a distance of " << -GetOffTargetDistance() << "deg " << endl;
    122134
    123135    return kTRUE;
    124136}
    125137
    126 /*
    127138Bool_t MSimPointingPos::ReInit(MParList *pList)
    128139{
     140    if (fRunHeader->HasViewCone() && IsOffTargetObservation())
     141    {
     142        *fLog << warn;
     143        *fLog << "WARNING - Combining the view cone option with off-target observations doesn't make sense." << endl;
     144        *fLog << "          Option for off-target observations will be ignored." << endl;
     145    }
    129146    // FIXME: Check also the enlightened region on the ground!
    130147    return kTRUE;
    131148}
    132 */
     149
     150void MSimPointingPos::GetDelta(Double_t &dtheta, Double_t &dphi) const
     151{
     152    if (fOffTargetDistance>0)
     153    {
     154        dtheta = fOffTargetDistance;
     155        dphi   = fOffTargetPhi>0 ? fOffTargetPhi : gRandom->Uniform(TMath::TwoPi());
     156    }
     157    else
     158    {
     159        dtheta = TMath::Sqrt(gRandom->Uniform(fOffTargetDistance));
     160        dphi   = gRandom->Uniform(TMath::TwoPi());
     161    }
     162}
    133163
    134164// --------------------------------------------------------------------------
     
    136166Int_t MSimPointingPos::Process()
    137167{
    138 
    139168    // If a view cone is given use the fixed telescope orientation
    140     const Bool_t fixed = fRunHeader->HasViewCone();
     169    const Bool_t viewcone = fRunHeader->HasViewCone();
    141170
    142171    // Local sky coordinates (direction of telescope axis)
    143     /*const*/ Double_t zd = fixed ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
    144     /*const*/ Double_t az = fixed ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
    145 
    146     if (!fixed && IsOffTargetObservation())
    147     {
     172    Double_t zd = viewcone ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
     173    Double_t az = viewcone ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
     174
     175    if (!viewcone)
     176    {
     177        Double_t dtheta, dphi;
     178        GetDelta(dtheta, dphi);
     179
    148180        const Double_t theta = zd*TMath::DegToRad();
    149181        const Double_t phi   = az*TMath::DegToRad();
    150182
    151         /*const*/ TVector3 source;
    152         source.SetMagThetaPhi(1, theta, phi);
    153 
    154         /*const*/ TVector3 point;
    155         point.SetMagThetaPhi(1, theta+fOffTargetDistance, phi);
    156 
    157         const Double_t delta = fOffTargetPhi>0 ? fOffTargetPhi :
    158             gRandom->Uniform(TMath::TwoPi());
    159 
    160         point.Rotate(delta, source);
    161 
    162         zd = point.Theta()*TMath::RadToDeg();
    163         az = point.Phi()*TMath::RadToDeg();
    164     }
     183        TVector3 src, pnt;
     184        src.SetMagThetaPhi(1, theta,        phi);
     185        pnt.SetMagThetaPhi(1, theta+dtheta, phi);
     186
     187        pnt.Rotate(dphi, src);
     188
     189        zd = pnt.Theta()*TMath::RadToDeg();
     190        az = pnt.Phi()  *TMath::RadToDeg();
     191    }
     192
     193    // Transform the corsika coordinate system (north is magnetic north)
     194    // into the telescopes local coordinate system. Note, that all vectors
     195    // are already correctly oriented.
     196    az += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
    165197
    166198    // Setup the pointing position
    167 //    fPointingCorsika->SetLocalPosition(zd, az/*+fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg()*/);
    168     fPointingLocal->SetLocalPosition(zd, az+fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg());
     199    fPointing->SetLocalPosition(zd, az);
    169200
    170201    // Calculate incident angle between magnetic field direction
Note: See TracChangeset for help on using the changeset viewer.