Ignore:
Timestamp:
02/15/09 13:24:59 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msim
Files:
4 edited

Legend:

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

    r9319 r9336  
    8484        return kFALSE;
    8585
    86     fPointingPos = (MPointingPos*)plist->FindObject("MPointingPos");
    87     if (!fPointingPos)
     86    fPointingTel = (MPointingPos*)plist->FindObject("MPointingPos");
     87    if (!fPointingTel)
    8888    {
    8989        *fLog << err << "MPointingPos not found... aborting." << endl;
     
    134134
    135135    //    fNumPheFromDNSB        MMcPedestalNSBAdd   // Number of phe/ns from diffuse NSB
     136
     137    // FIXME: Is there a way to write them as LAST entry in the file?
    136138    mrh->SetNumSimulatedShowers(fRunHeader->GetNumEvents());
    137139    mrh->SetImpactMax(fRunHeader->GetImpactMax());
     140    mrh->SetCorsikaVersion(TMath::Nint(fRunHeader->GetProgramVersion()*100));
    138141
    139142    // ----------------------------------------------------
     
    148151    const UInt_t id = fRunHeader->GetParticleID();
    149152
     153    // FIXME: Is there a way to write them as LAST entry in the file?
    150154    rh->SetRunInfo(1, fRunHeader->GetRunNumber(), 0);
    151155    rh->SetSourceInfo(MMcEvtBasic::GetParticleName(id));
     
    166170    fMcEvtBasic->SetImpact(fEvtHeader->GetImpact());
    167171
    168     fMcEvtBasic->SetTelescopeTheta(fPointingPos->GetZdRad());
    169     fMcEvtBasic->SetTelescopePhi(fPointingPos->GetAzRad());
     172    fMcEvtBasic->SetTelescopeTheta(fPointingTel->GetZdRad());
     173    fMcEvtBasic->SetTelescopePhi(fPointingTel->GetAzRad());
    170174
    171175    fMcEvtBasic->SetReadyToSave();
     
    173177    static_cast<MMcEvtBasic&>(*fMcEvt) = *fMcEvtBasic;
    174178
     179    // Convert from corsika franme to telescope frame, taking
     180    // the magnetic field into account: tel = corsika+offset
    175181    fMcEvt->SetTheta(fEvtHeader->GetZd());
    176     fMcEvt->SetPhi(fEvtHeader->GetAz());
     182    fMcEvt->SetPhi(fEvtHeader->GetAz()+fRunHeader->GetMagneticFieldAz());
    177183
    178184    fMcEvt->SetEvtNumber(fEvtHeader->GetEvtNumber());
  • trunk/MagicSoft/Mars/msim/MSimMMCS.h

    r9319 r9336  
    1818    MMcEvtBasic       *fMcEvtBasic;
    1919    MMcEvt            *fMcEvt;
    20     MPointingPos      *fPointingPos;
     20    MPointingPos      *fPointingTel;  //! telescope poiting position in local (telescope) coordinate system
    2121    MCorsikaEvtHeader *fEvtHeader;
    2222    MCorsikaRunHeader *fRunHeader;
  • 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
  • trunk/MagicSoft/Mars/msim/MSimPointingPos.h

    r9232 r9336  
    1414{
    1515private:
    16     MCorsikaRunHeader *fRunHeader;  //! Header storing event information
    17     MCorsikaEvtHeader *fEvtHeader;  //! Header storing event information
    18     MPointingPos      *fPointing;   //! Output storing telescope poiting position
     16    MCorsikaRunHeader *fRunHeader;         //! Header storing event information
     17    MCorsikaEvtHeader *fEvtHeader;         //! Header storing event information
     18    MPointingPos      *fPointingCorsika;   //! Output storing telescope poiting position in corsika coordinate system (modulo magnetig field declination)
     19    MPointingPos      *fPointingLocal;     //! Output storing telescope poiting position in local (telescope) coordinate system
     20
     21    Double_t fOffTargetDistance;  // [rad] Distance of the observed off-target position from the source
     22    Double_t fOffTargetPhi;       // [rad] Rotation angle of the off-target position (phi==0 means south, phi=90 west) [0;2pi], phi<0 means random
    1923
    2024    // MParContainer
    21     //Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
     25    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print=kFALSE);
    2226
    2327    // MTask
    24     Int_t PreProcess(MParList *pList);
    25     Int_t Process();
    26 
     28    Int_t  PreProcess(MParList *pList);
     29    //Bool_t ReInit(MParList *pList);
     30    Int_t  Process();
    2731
    2832public:
    2933    MSimPointingPos(const char *name=NULL, const char *title=NULL);
    3034
     35    // Getter
     36    Double_t GetOffTargetDistance() const { return fOffTargetDistance*TMath::RadToDeg(); }
     37    Double_t GetOffTargetPhi() const { return fOffTargetPhi*TMath::RadToDeg(); }
     38
     39    // Setter
     40    void SetOffTargetDistance(Double_t d=-1) { fOffTargetDistance = d*TMath::DegToRad(); }
     41    void SetOffTargetPhi(Double_t p=-1) { fOffTargetPhi = p*TMath::DegToRad(); }
     42
    3143    // MSimPointingPos
     44    Bool_t IsOffTargetObservation() const { return fOffTargetDistance>0; }
    3245
    3346    // TObject
Note: See TracChangeset for help on using the changeset viewer.