TrackDumper.cxx

Go to the documentation of this file.
00001 // ================================================
00002 // TrackDumper class Implementation
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 // Namespace Atlfast::
00008 //
00009 #include "AtlfastAlgs/TrackDumper.h"
00010 #include "AtlfastAlgs/GlobalEventData.h"
00011 #include "AtlfastEvent/Track.h"
00012 #include "AtlfastEvent/CollectionDefs.h"
00013 
00014 
00015 // Gaudi includes
00016 #include "GaudiKernel/DataSvc.h"
00017 #include "GaudiKernel/MsgStream.h"
00018 #include <iostream>
00019 #include <iomanip>
00020 //--------------------------------
00021 // Constructors and destructors
00022 //--------------------------------
00023 
00024 namespace Atlfast {
00025   
00026   class TrackPrinter{
00027   public:
00028     TrackPrinter(MsgStream& log):m_count(0), m_log(log){}
00029     void operator()(const Track* t){
00030       //      cout<<setw(10)<<++m_count<<" "<<*t<<endl;
00031       m_log<< MSG::INFO <<++m_count<<" "<<*t<<endreq;
00032     }
00033   private:
00034     int m_count;
00035     MsgStream& m_log;
00036   };
00037 
00038   TrackDumper::TrackDumper (const std::string& name, 
00039                             ISvcLocator* pSvcLocator ) 
00040     : Algorithm( name, pSvcLocator ),
00041       m_tesIO(0) {
00042     
00043     // Default paths for entities in the TES
00044     m_inputLocation    = "/Event/AtlfastTracks";
00045     declareProperty( "InputLocation",    m_inputLocation ) ;
00046   }
00047   
00048   //----------------------------
00049   // Destructor
00050   //----------------------------
00051   TrackDumper::~TrackDumper() {
00052     if (m_tesIO) delete m_tesIO;
00053   } 
00054   
00055   
00056   //---------------------------------
00057   // initialise() 
00058   //---------------------------------
00059   
00060   StatusCode TrackDumper::initialize(){
00061     MsgStream log( messageService(), name() ) ;
00062  
00063     GlobalEventData* ged = GlobalEventData::Instance();
00064     //int randSeed = ged->randSeed() ;
00065     // load the location of the MC in StoreGate
00066     m_mcLocation       = ged -> mcLocation();
00067    
00068     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00069 
00070     HeaderPrinter hp("Atlfast TrackDumper:", log);
00071     hp.add("Input Location         ", m_inputLocation);    
00072     hp.print();
00073     log << MSG::INFO << "Initialised successfully " << endreq ;    
00074     return StatusCode::SUCCESS ;
00075   }
00076   
00077   //---------------------------------
00078   // finalise() 
00079   //---------------------------------
00080   
00081   StatusCode TrackDumper::finalize(){
00082     
00083     MsgStream log( messageService(), name() ) ;
00084     
00085     log << MSG::INFO << "Finalised successfully " << endreq ;
00086     
00087     return StatusCode::SUCCESS ;
00088   }
00089   
00090   
00091   //----------------------------------------------
00092   // execute() method called once per event
00093   //----------------------------------------------
00094   //
00095   //  This algorithm creates smeared Tracks passing cuts. 
00096   //  It scans the list of HepMC::GenParticles from the Monte Carlo truth. 
00097   //  It creates a Track object by smearing the Trajectory track parameters
00098   //  corresponding to the HepMC::GenParticle. 
00099   // 
00100   //  It then applies kinematic criteria on the properties of the Track
00101   //  Those which pass the cuts are kept.
00102   //  Finally all successful ReconstructedParticles are added to 
00103   //the event store.
00104   //
00105   
00106   StatusCode TrackDumper::execute( ){
00107 
00108     //................................
00109     // make a message logging stream
00110     
00111     MsgStream log( messageService(), name() ) ;
00112     log << MSG::DEBUG << "Execute() " << endreq;
00113     
00114 
00115     //.........................................................
00116     // We now need to access the HepMC event record(s) in the event store
00117     // and iterate over them to extract HepMC::GenParticles.
00118     // This method will only select the particles which are required
00119     // and add them to a local store (mcParticles)
00120     
00121     std::vector<Track*> tracks;
00122     
00123     m_tesIO->copy<TrackCollection>( tracks, m_inputLocation );
00124     TrackPrinter printer(log);
00125     HeaderPrinter hp("TrackDump:", log);
00126     std::for_each(tracks.begin(), tracks.end(), printer);
00127     return StatusCode::SUCCESS;
00128   }
00129 } // end namespace bracket
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 

Generated on Mon Sep 24 14:19:12 2007 for AtlfastAlgs by  doxygen 1.5.1