Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

FillTrackGeom.cxx

Go to the documentation of this file.
00001 // $Id: FillTrackGeom.cxx,v 1.9 2008/09/05 15:42:33 rustem Exp $
00002 
00003 // C/C++
00004 #include <cassert>
00005 #include <cmath>
00006 #include <sstream>
00007 
00008 // Local
00009 #include "PhysicsNtuple/Default.h"
00010 #include "PhysicsNtuple/Factory.h"
00011 
00012 // Local
00013 #include "FillTrackGeom.h"
00014 
00015 REGISTER_ANP_OBJECT(AlgSnarl,FillTrackGeom)
00016 
00017 using namespace std;
00018 
00019 //------------------------------------------------------------------------------------------
00020 Anp::FillTrackGeom::FillTrackGeom()
00021 {
00022 }
00023 
00024 //------------------------------------------------------------------------------------------
00025 Anp::FillTrackGeom::~FillTrackGeom()
00026 {
00027 }
00028 
00029 //------------------------------------------------------------------------------------------
00030 bool Anp::FillTrackGeom::Run(Record &record)
00031 {
00032    for(TrackIterator it = record.TrackBegIterator(); it != record.TrackEndIterator(); ++it)
00033    {
00034       Fill(*it);
00035    }
00036 
00037    return true;
00038 }
00039 
00040 //------------------------------------------------------------------------------------------
00041 void Anp::FillTrackGeom::Fill(Track &track) const
00042 {
00043    const double x_vtx = track.GetBegVtx().X();
00044    const double y_vtx = track.GetBegVtx().Y();
00045    const double z_vtx = track.GetBegVtx().Z();
00046 
00047    const double x_end = track.GetEndVtx().X();
00048    const double y_end = track.GetEndVtx().Y();
00049    const double z_end = track.GetEndVtx().Z();
00050    
00051    const double cosx_vtx = track.GetBegVtx().CosX();
00052    const double cosy_vtx = track.GetBegVtx().CosY();
00053 
00055    // transform all x,y coordinates into the new coordinates
00057    const double xy_angle_vtx = Anp::angle(x_vtx, y_vtx);
00058 
00059    const double rot_x_vtx =  x_vtx * std::cos(xy_angle_vtx) + y_vtx * std::sin(xy_angle_vtx);
00060    const double rot_y_vtx = -x_vtx * std::sin(xy_angle_vtx) + y_vtx * std::cos(xy_angle_vtx);
00061 
00062    const double rot_x_end =  x_end * std::cos(xy_angle_vtx) + y_end * std::sin(xy_angle_vtx);
00063    const double rot_y_end = -x_end * std::sin(xy_angle_vtx) + y_end * std::cos(xy_angle_vtx);
00064 
00065    const double x_rel = rot_x_end - rot_x_vtx;
00066    const double y_rel = rot_y_end - rot_y_vtx;
00067    const double z_rel = z_end - z_vtx;
00068 
00070    // determine angles of track's end relative to vtx 
00071    // in new coordinates - xy plane
00073    
00074    if(!track.KeyExists(104))
00075    {
00076       track.Add(104, Anp::angle(x_rel, y_rel));
00077    }
00078 
00080    // difference between hit and projected straight line from vtx
00082 
00083    if(track.GetBegVtx().CosZ() > 0.0)
00084    {
00085       const double t_end = z_rel/track.GetBegVtx().CosZ();
00086       
00087       const double x_proj = cosx_vtx * t_end + x_vtx;
00088       const double y_proj = cosy_vtx * t_end + y_vtx;
00089 
00090       const double x_proj_rot =  x_proj * std::cos(xy_angle_vtx) + y_proj * std::sin(xy_angle_vtx);
00091       const double y_proj_rot = -x_proj * std::sin(xy_angle_vtx) + y_proj * std::cos(xy_angle_vtx);
00092 
00093       const double x_proj_diff = rot_x_end - x_proj_rot;
00094       const double y_proj_diff = rot_y_end - y_proj_rot;
00095 
00096       const double proj_xy_angle = Anp::angle(x_proj_diff, y_proj_diff);
00097       
00098       const double proj_distance = std::sqrt(x_proj_diff*x_proj_diff + y_proj_diff*y_proj_diff);
00099 
00100       if(!track.KeyExists(108))
00101       {      
00102          track.Add(108, proj_xy_angle);
00103       }
00104       if(!track.KeyExists(109))
00105       {
00106          track.Add(109, x_proj_diff);
00107       }
00108       if(!track.KeyExists(110))
00109       {
00110          track.Add(110, y_proj_diff);
00111       }
00112       if(!track.KeyExists(111))
00113       {
00114          track.Add(111, proj_distance);
00115       }
00116    }
00117 
00118    //
00119    // Add standard track variables for convienience
00120    //
00121    if(track.Pass() && track.ErrorQP() > 0.0)
00122    {
00123       if(!track.KeyExists(120)) track.Add(120, track.ErrorQP());
00124       if(!track.KeyExists(121)) track.Add(121, track.QP());
00125       if(!track.KeyExists(122)) track.Add(122, track.QP()/track.ErrorQP());
00126    }
00127 }

Generated on Mon Feb 15 11:06:42 2010 for loon by  doxygen 1.3.9.1