Changeset 18163 for branches/MarsWobble


Ignore:
Timestamp:
03/16/15 16:18:36 (10 years ago)
Author:
ftemme
Message:
Restructuring the calculation of the pointing position: The old behavior is preserved, but in addition the MSimSourcePos container is filled, according to the new description in the comments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MarsWobble/msim/MSimPointingPos.cc

    r17846 r18163  
    3939//
    4040// If no view cone option was given and off-target observations are switched
    41 // on by setting fOffTargetDistance!=0 the poitnting position is calculated:
     41// on by setting fOffTargetDistance!=0 the pointing position is calculated:
    4242//
    4343//  1) fOffTargetDistance < 0:
     
    5151//     fOffTargetDistance. (phi==0 is the direction of positive theta)
    5252//
     53// The original zenith and azimuth coordinates of the shower axis are stored in
     54// the MSimSourcePos container.
     55//
     56// If the view cone option was given and off-target observations are switched on
     57// the orientation is fixed to the main direction around the view cone was
     58// produced.
     59// In addition a 'quasi'-simulated source position is calculated,
     60// depending on fOffTargetDistance and fOffTargetPhi (see 1) and 2) above).
     61// The corresponding zenith and azimuth coordinates are stored in the
     62// MSimSourcePos container. This is of course not a physical source position,
     63// but it can be used to determine the performance of wobble analysis on
     64// background events (which are homogenous distributed).
     65//
     66//
    5367//
    5468//  Input Containers:
     
    5872//  Output Containers:
    5973//   MPointingPos
     74//   MSimSourcePos
    6075//
    6176//////////////////////////////////////////////////////////////////////////////
     
    8499//
    85100MSimPointingPos::MSimPointingPos(const char* name, const char *title)
    86     : fRunHeader(0), fEvtHeader(0), fPointing(0),
     101    : fRunHeader(0), fEvtHeader(0), fPointing(0), fSimSourcePosition(0),
    87102    fOffTargetDistance(0), fOffTargetPhi(-1)
    88103
     
    139154{
    140155    fPointing = (MPointingPos*)pList->FindCreateObj("MPointingPos");
     156    if (!fPointing)
     157        return kFALSE;
     158
     159    fSimSourcePosition = (MPointingPos*)pList->FindCreateObj("MPointingPos","MSimSourcePos");
    141160    if (!fPointing)
    142161        return kFALSE;
     
    180199    {
    181200        *fLog << warn;
    182         *fLog << "WARNING - Combining the view cone option with off-target observations doesn't make sense." << endl;
    183         *fLog << "          Option for off-target observations will be ignored." << endl;
     201        *fLog << "WARNING - Combining the view cone option with off-target pointing can lead to not homogenous events." << endl;
     202        *fLog << "          A simulated source position according to the off-target parameters will be created instead." << endl;
    184203    }
    185204    // FIXME: Check also the enlightened region on the ground!
     
    209228
    210229    // Local sky coordinates (direction of telescope axis)
    211     Double_t zd = viewcone ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
    212     Double_t az = viewcone ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
    213 
    214     if (!viewcone)
    215     {
    216         Double_t dtheta, dphi;
    217         GetDelta(dtheta, dphi);
    218 
    219         const Double_t theta = zd*TMath::DegToRad();
    220         const Double_t phi   = az*TMath::DegToRad();
    221 
    222         TVector3 src, pnt;
    223         src.SetMagThetaPhi(1, theta,        phi);
    224         pnt.SetMagThetaPhi(1, theta+dtheta, phi);
    225 
    226         pnt.Rotate(dphi, src);
    227 
    228         zd = pnt.Theta()*TMath::RadToDeg();
    229         az = pnt.Phi()  *TMath::RadToDeg();
    230     }
     230    Double_t zdCorsika = viewcone ? fRunHeader->GetZdMin() : fEvtHeader->GetZd()*TMath::RadToDeg();  // x==north
     231    Double_t azCorsika = viewcone ? fRunHeader->GetAzMin() : fEvtHeader->GetAz()*TMath::RadToDeg();  // y==west
     232
     233    // Calculate off target position in local sky coordinates
     234    Double_t dtheta, dphi;
     235    GetDelta(dtheta, dphi);
     236
     237    const Double_t theta = zdCorsika*TMath::DegToRad();
     238    const Double_t phi   = azCorsika*TMath::DegToRad();
     239
     240    TVector3 originalVector, wobbleVector;
     241    originalVector.SetMagThetaPhi(1, theta,        phi);
     242    wobbleVector.SetMagThetaPhi(1, theta+dtheta, phi);
     243
     244    wobbleVector.Rotate(dphi, originalVector);
     245
     246    Double_t zdWobble, azWobble;
     247    zdWobble = wobbleVector.Theta()*TMath::RadToDeg();
     248    azWobble = wobbleVector.Phi()  *TMath::RadToDeg();
    231249
    232250    // Transform the corsika coordinate system (north is magnetic north)
    233251    // into the telescopes local coordinate system. Note, that all vectors
    234252    // are already correctly oriented.
    235     az += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
    236 
    237     // Setup the pointing position
    238     fPointing->SetLocalPosition(zd, az);
    239 
    240     // Calculate incident angle between magnetic field direction
    241     // and pointing direction ( phi and theta? )
     253    azCorsika += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
     254    azWobble += fRunHeader->GetMagneticFieldAz()*TMath::RadToDeg();
     255
     256    // Setup the pointing and the simulated source position
     257    if (!viewcone)
     258    {
     259        fPointing->SetLocalPosition(zdWobble, azWobble);
     260        fSimSourcePosition->SetLocalPosition(zdCorsika, azCorsika);
     261    }
     262    else
     263    {
     264        fPointing->SetLocalPosition(zdCorsika, azCorsika);
     265        fSimSourcePosition->SetLocalPosition(zdWobble, azWobble);
     266    }
    242267
    243268    return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.