ReconstructedParticleDumper.cxx

Go to the documentation of this file.
00001 // ================================================
00002 //ReconstructedParticleDumper class Implementation
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 // Namespace Atlfast::
00008 //
00009 
00010 // This algorithm includes
00011 #include "AtlfastAlgs/ReconstructedParticleDumper.h"
00012 #include "AtlfastEvent/ReconstructedParticle.h"
00013 #include "AtlfastEvent/Cluster.h"
00014 #include "AtlfastEvent/MsgStreamDefs.h"
00015 #include "AtlfastEvent/CollectionDefs.h"
00016 #include "AtlfastEvent/TypeVisitor.h"
00017 #include "AtlfastEvent/SimpleAssocsDispatcher.h"
00018 //#include "AtlfastAlgs/AssocTypeRecoverer.h"
00019 #include "AtlfastAlgs/GlobalEventData.h"
00020 
00021 #include <cmath> 
00022 #include <algorithm>
00023 
00024 // Gaudi includes
00025 #include "GaudiKernel/DataSvc.h"
00026 
00027 //--------------------------------
00028 // Constructors and destructors
00029 //--------------------------------
00030 
00031 namespace Atlfast {
00032   ReconstructedParticleDumper::ReconstructedParticleDumper
00033   ( const std::string& name, ISvcLocator* pSvcLocator ) 
00034     : Algorithm( name, pSvcLocator ){
00035     
00036     
00037     // Default paths for entities in the TES
00038     m_inputLocation    = "/Event/Atlfast/ReconstructedParticle";
00039     
00040     m_writePDG        = true;
00041     m_writeFourVector = true;
00042     m_writeEta        = true;
00043     m_writePhi        = true;
00044     m_writePt         = true;
00045     m_writeEt         = false;
00046     m_writeMt         = false;
00047     m_writeTruth      = true;
00048     
00049     declareProperty( "InputLocation", m_inputLocation ) ;
00050     
00051     declareProperty( "WritePDG", m_writePDG );
00052     declareProperty( "WriteFourVector", m_writeFourVector );
00053     declareProperty( "WriteEta", m_writeEta );
00054     declareProperty( "WritePhi", m_writePhi );
00055     declareProperty( "WritePt", m_writePt );
00056     declareProperty( "WriteEt", m_writeEt );
00057     declareProperty( "WriteMt", m_writeMt );
00058     declareProperty( "WriteTruth", m_writeTruth );
00059     
00060   }
00061   
00062   
00063   ReconstructedParticleDumper::~ReconstructedParticleDumper() {} 
00064   
00065   
00066   //---------------------------------
00067   // initialise() 
00068   //---------------------------------
00069   
00070   StatusCode ReconstructedParticleDumper::initialize(){
00071     //MsgStream log( messageService(), name() ) ;
00072     
00073     // .. put any initialisation in here...
00074     
00075     // will need to build an appropriate smearer object here
00076     // when tools become avialble we will instead just pass an appropriate
00077     // tool via job options
00078 
00079     GlobalEventData* ged = GlobalEventData::Instance();
00080     // load the location of the MC in StoreGate
00081     m_mcLocation       = ged -> mcLocation();
00082 
00083     
00084     //  m_tesIO = new TesIO(eventDataService());
00085     m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00086     
00087     return StatusCode::SUCCESS ;
00088   }
00089   
00090   //---------------------------------
00091   // finalise() 
00092   //---------------------------------
00093   
00094   StatusCode ReconstructedParticleDumper::finalize(){
00095     // .. put any finalisation in here...
00096     
00097     return StatusCode::SUCCESS ;
00098   }
00099   
00100   
00101   //----------------------------------------------
00102   // execute() method called once per event
00103   //----------------------------------------------
00104   //
00105   
00106   StatusCode ReconstructedParticleDumper::execute( ){
00107     //................................
00108     // make a message logging stream
00109     
00110     MsgStream log( messageService(), name() ) ;
00111     
00112     //.............................
00113     // Make some locals stores which be used to keep pointers to
00114     // all of the entities from the event store which are needed by
00115     // this algorithm. These are all local and are typedefed in this class
00116     
00117     //t_reconstructedParticleCollection  myParticles ;
00118     //...............................
00119     // Extract the input particles which are to be tested for isolation.
00120     
00121     
00122     std::vector<ReconstructedParticle*> particles;
00123     if(!m_tesIO->copy<ReconstructedParticleCollection >
00124        (particles, m_inputLocation)){
00125       log << MSG::INFO 
00126           << "No reconstructed particles in TES at " 
00127           << m_inputLocation 
00128           << endreq ;
00129       return StatusCode::FAILURE ;
00130     }
00131     log << MSG::INFO << particles.size()  
00132         << " Reconstructed particles retrieved from TES at " 
00133         << m_inputLocation 
00134         << endreq;
00135     
00136     
00137     
00138     int count = 0;
00139     std::vector<ReconstructedParticle*>::const_iterator particle  = 
00140       particles.begin();
00141     for (; particle != particles.end(); ++particle) {
00142       count++;
00143       log << MSG::INFO << count;
00144       if (m_writePDG) {
00145         log << " PDG " << (*particle)->pdg_id();
00146       }
00147       if (m_writeFourVector) {
00148         log << " px " << (*particle)->momentum().px() 
00149             << " py " << (*particle)->momentum().py()
00150             << " pz " << (*particle)->momentum().pz()
00151             << " e  " << (*particle)->momentum().e();
00152       }
00153       if (m_writeEta) {
00154         log << " eta " << (*particle)->eta();
00155       }
00156       if (m_writePhi) {
00157         log << " phi " << (*particle)->phi();
00158       }
00159       if (m_writePt) {
00160         log << " pt " << (*particle)->pT();
00161       }
00162       if (m_writeEt) {
00163         log << " et " << (*particle)->eT();
00164       }
00165       if (m_writeMt) {
00166         log << " mt " << (*particle)->mT();
00167       }
00168       if (m_writeTruth) {
00169         log << " MC truth " << (*particle)->truth()->momentum();
00170       }
00171       
00172       log << endreq;
00173       
00174       // Now print any associations
00175       TypeVisitor tv = SimpleAssocsDispatcher( *particle, TypeVisitor());
00176       Cluster c;
00177       log << "     it has " << (tv.typeVector( Cluster() )).size() 
00178           << " associated clusters " << endreq;
00179       /*      
00180       std::vector<IAOO*> v;
00181       v.push_back(*particle);
00182       AssocTypeRecoverer atr(v.begin(), v.end());
00183       Cluster c;
00184       log << "     it has " << (atr.typeVector( c ))->size() 
00185           << " associated clusters " << endreq;
00186       */
00187     }
00188     
00189     return StatusCode::SUCCESS;
00190   }
00191   
00192 }  // end of namespace bracket
00193 
00194 
00195 
00196 
00197 
00198 

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