Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

TestTrackViewer.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // TestTrackViewer class Implementation
00003 // ================================================
00004 //
00005 //
00006 // Namespace ATLFast
00007 //
00008 #include "AtlfastAlgs/TestTrackViewer.h"
00009 #include "AtlfastUtils/ITrackViewer.h"
00010 #include "AtlfastAlgs/AtlfTrackViewer.h"
00011 #include "AtlfastAlgs/ITrackParameterView.h"
00012 #include "AtlfastAlgs/AtlfTrackParameterView.h"
00013 
00014 #include "AtlfastEvent/ITrackParameters.h"
00015 #include "AtlfastEvent/CollectionDefs.h"
00016 
00017 // Utilities
00018 #include <cmath> 
00019 #include <assert.h> 
00020 #include "AtlfastEvent/Phi.h"
00021 #include "AtlfastUtils/HeaderPrinter.h"
00022 
00023 // This is part of the STL and allows you to use
00024 // generic sort algorithms (amongst other things)
00025 #include <algorithm>
00026 #include "AtlfastUtils/FunctionObjects.h"
00027 
00028 // Athena/Gaudi includes
00029 #include "GaudiKernel/DataSvc.h"
00030 
00031 //#include "AtlfastEvent/MsgStreamDefs.h"
00032 
00033 namespace Atlfast {
00034   using std::abs;
00035   using std::endl;
00036   
00037   
00038   //--------------------------------
00039   // Constructors and destructors
00040   //--------------------------------
00041   
00042   TestTrackViewer::TestTrackViewer ( const std::string& name, 
00043                                ISvcLocator* pSvcLocator ) 
00044     : Algorithm( name, pSvcLocator ){
00045     
00046     // Setting the parameter defaults.
00047     m_trackLocation      = "/Event/AtlfastTracks";
00048     declareProperty( "TrackLocation",    m_trackLocation ) ;
00049     
00050   }
00051   
00052   // Destructor
00053   TestTrackViewer::~TestTrackViewer() {
00054     MsgStream log( messageService(), name() ) ;
00055     log << MSG::INFO << "Destructor called" << endreq;
00056   } 
00057   
00058   
00059   //---------------------------------
00060   // initialise() 
00061   //---------------------------------
00062   
00063   StatusCode TestTrackViewer::initialize(){
00064     
00065     // We must here instantiate items which can only be made after
00066     // any job options have been set
00067     
00068     MsgStream log( messageService(), name() ) ;
00069     log << MSG::DEBUG << "Initialising" << endreq;
00070     HeaderPrinter hp("TestTrackViewer:",log);
00071     hp.add( "TrackLocation   ",   m_trackLocation ) ;
00072     hp.print();
00073 
00074     m_nevents = 0;
00075     m_ntracks = 0;
00076     //    m_tesIO = new TesIO(eventDataService());
00077     m_tesIO = new TesIO();
00078     
00079     return StatusCode::SUCCESS ;
00080   }
00081   
00082   
00083   //---------------------------------
00084   // finalise() 
00085   //---------------------------------
00086   
00087   StatusCode TestTrackViewer::finalize(){
00088     MsgStream log( messageService(), name() ) ;
00089     log << MSG::INFO << "Finalizing" << endreq;
00090     log<<  MSG::INFO  << "Events Processed: "<<m_nevents<<endreq;
00091     log<<  MSG::INFO  << "Tracks Processed: "<<m_ntracks<<endreq;
00092     return StatusCode::SUCCESS ;
00093   }
00094   
00095   
00096   //----------------------------------------------
00097   // execute() method called once per event
00098   //----------------------------------------------
00099   //
00100   
00101   
00102   StatusCode TestTrackViewer::execute( ){
00103     
00104     //................................
00105     // make a message logging stream 
00106     
00107     MsgStream log( messageService(), name() ) ;
00108     ++m_nevents;
00109     
00110     
00111     //.........................................................
00112     // This is how you extract the things you want to look at. 
00113     // Look at the userguide for details of ReconstructedParticle, Cell
00114     // and Cluster classes
00115     std::vector<Track*> tracks;
00116     if(!m_tesIO->copy<TrackCollection >(tracks, m_trackLocation)){
00117       log << MSG::DEBUG 
00118           << "No Tracks found in TES at " 
00119           << m_trackLocation 
00120           << endreq ;
00121     }else{
00122       log << MSG::DEBUG 
00123           << "No. of Tracks found in TES  = " 
00124           << tracks.size() 
00125           << endreq ;
00126     }
00127     
00128     //.........................................................
00129     // Here are example things you might do
00130     
00131     
00132     if( tracks.size() ) this->testViewer( log, tracks ) ;
00133     
00134     return StatusCode::SUCCESS ;
00135     
00136   }
00137   
00138   
00139   //-------------------------------------------
00140   // private: testViewer
00141   //------------------------------------------
00142   
00143   
00144   void TestTrackViewer::testViewer ( MsgStream& log, 
00145                                      std::vector<Track*>& tracks){
00146     
00147     log << MSG::DEBUG << "Starting track view tester" << endreq ;
00148     
00149     
00150     
00151     // traverse collection of particles
00152     std::vector<Track*>::const_iterator track;
00153     
00154     for( track = tracks.begin(); track < tracks.end(); ++track ){
00155       
00156       log << MSG::DEBUG << *track << endreq;
00157       ++m_ntracks;
00158       TrackTrajectory traj = (*track)->trajectory();
00159       AtlfAna::AtlfTrackViewer trackViewer(*track);
00160       AtlfAna::ITrackParameterView& parameterView =  trackViewer;
00161       log<<MSG::DEBUG<<parameterView.trackParameters()<<endl;
00162       const ITrackParameters& tp = parameterView.trackParameters();
00163       double eps = 0.0000001;
00164       TrackParameters testParam = (*track)->trajectory().parameters();
00165       assert(abs( tp.eta()-testParam.eta() )                          < eps);
00166       assert(abs( tp.phi()-testParam.phi() )                          < eps);
00167       assert(abs( tp.cotTheta()-testParam.cotTheta() )                < eps);
00168       assert(abs( tp.impactParameter()-testParam.impactParameter() )  < eps);
00169       assert(abs( tp.zPerigee()-testParam.zPerigee() )                < eps);
00170       assert(abs( tp.invPtCharge()-testParam.invPtCharge() )          < eps);
00171       
00172     }
00173     
00174   }
00175   
00176   
00177 } // end of namespace bracket

Generated on Tue Mar 18 11:18:25 2003 for AtlfastAlgs by doxygen1.3-rc1