Ignore:
Timestamp:
02/15/09 13:24:59 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r9243 r9336  
    4141//  Output Containers:
    4242//   MPointingPos
     43//   PointingCorsika [MPointingPos]
    4344//
    4445//////////////////////////////////////////////////////////////////////////////
    4546#include "MSimPointingPos.h"
     47
     48#include <TRandom.h>
     49#include <TVector3.h>
    4650
    4751#include "MLog.h"
     
    6468//
    6569MSimPointingPos::MSimPointingPos(const char* name, const char *title)
    66     : fRunHeader(0), fEvtHeader(0), fPointing(0)
     70    : fRunHeader(0), fEvtHeader(0), fPointingCorsika(0), fPointingLocal(0),
     71    fOffTargetDistance(-1), fOffTargetPhi(-1)
     72
    6773{
    6874    fName  = name  ? name  : "MSimPointingPos";
     
    7783Int_t MSimPointingPos::PreProcess(MParList *pList)
    7884{
    79     fPointing = (MPointingPos*)pList->FindCreateObj("MPointingPos");
    80     if (!fPointing)
     85    fPointingCorsika = (MPointingPos*)pList->FindCreateObj("MPointingPos", "PointingCorsika");
     86    if (!fPointingCorsika)
     87        return kFALSE;
     88
     89    fPointingLocal = (MPointingPos*)pList->FindCreateObj("MPointingPos");
     90    if (!fPointingLocal)
    8191        return kFALSE;
    8292
     
    95105    }
    96106
     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;
     116        *fLog <<"   a pointing distance of " << GetOffTargetDistance() << "deg ";
     117        if (fOffTargetPhi<0)
     118            *fLog << "randomly distributed in phi." << endl;
     119        else
     120            *fLog << "and phi=" << GetOffTargetPhi() << "deg." << endl;
     121    }
     122
    97123    return kTRUE;
    98124}
     125
     126/*
     127Bool_t MSimPointingPos::ReInit(MParList *pList)
     128{
     129    // FIXME: Check also the enlightened region on the ground!
     130    return kTRUE;
     131}
     132*/
    99133
    100134// --------------------------------------------------------------------------
     
    102136Int_t MSimPointingPos::Process()
    103137{
     138
    104139    // If a view cone is given use the fixed telescope orientation
    105140    const Bool_t fixed = fRunHeader->HasViewCone();
    106141
    107142    // Local sky coordinates (direction of telescope axis)
    108     const Double_t zd = fixed ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
    109     const Double_t az = fixed ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
     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    {
     148        const Double_t theta = zd*TMath::DegToRad();
     149        const Double_t phi   = az*TMath::DegToRad();
     150
     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    }
    110165
    111166    // Setup the pointing position
    112     fPointing->SetLocalPosition(zd, az);
     167    fPointingCorsika->SetLocalPosition(zd, az);
     168    fPointingLocal->SetLocalPosition(zd, az+fRunHeader->GetMagneticFieldAz());
     169
     170    // Calculate incident angle between magnetic field direction
     171    // and pointing direction ( phi and theta? )
    113172
    114173    return kTRUE;
    115174}
    116175
    117 /*
    118176Int_t MSimPointingPos::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    119177{
    120178    Bool_t rc = kFALSE;
    121     if (IsEnvDefined(env, prefix, "FileName", print))
     179    if (IsEnvDefined(env, prefix, "OffTargetDistance", print))
    122180    {
    123181        rc = kTRUE;
    124         SetFileName(GetEnvValue(env, prefix, "FileName", fFileName));
     182        SetOffTargetDistance(GetEnvValue(env, prefix, "OffTargetDistance", GetOffTargetDistance()));
    125183    }
    126184
    127     if (IsEnvDefined(env, prefix, "UseTheta", print))
     185    if (IsEnvDefined(env, prefix, "OffTargetPhi", print))
    128186    {
    129187        rc = kTRUE;
    130         SetUseTheta(GetEnvValue(env, prefix, "UseTheta", fUseTheta));
     188        SetOffTargetPhi(GetEnvValue(env, prefix, "OffTargetPhi", GetOffTargetPhi()));
    131189    }
    132190
    133191    return rc;
    134192}
    135 */
     193
Note: See TracChangeset for help on using the changeset viewer.