00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00019 #include "AtlfastAlgs/GlobalEventData.h"
00020
00021 #include <cmath>
00022 #include <algorithm>
00023
00024
00025 #include "GaudiKernel/DataSvc.h"
00026
00027
00028
00029
00030
00031 namespace Atlfast {
00032 ReconstructedParticleDumper::ReconstructedParticleDumper
00033 ( const std::string& name, ISvcLocator* pSvcLocator )
00034 : Algorithm( name, pSvcLocator ){
00035
00036
00037
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
00068
00069
00070 StatusCode ReconstructedParticleDumper::initialize(){
00071
00072
00073
00074
00075
00076
00077
00078
00079 GlobalEventData* ged = GlobalEventData::Instance();
00080
00081 m_mcLocation = ged -> mcLocation();
00082
00083
00084
00085 m_tesIO = new TesIO(m_mcLocation, ged->justHardScatter());
00086
00087 return StatusCode::SUCCESS ;
00088 }
00089
00090
00091
00092
00093
00094 StatusCode ReconstructedParticleDumper::finalize(){
00095
00096
00097 return StatusCode::SUCCESS ;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 StatusCode ReconstructedParticleDumper::execute( ){
00107
00108
00109
00110 MsgStream log( messageService(), name() ) ;
00111
00112
00113
00114
00115
00116
00117
00118
00119
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
00175 TypeVisitor tv = SimpleAssocsDispatcher( *particle, TypeVisitor());
00176 Cluster c;
00177 log << " it has " << (tv.typeVector( Cluster() )).size()
00178 << " associated clusters " << endreq;
00179
00180
00181
00182
00183
00184
00185
00186
00187 }
00188
00189 return StatusCode::SUCCESS;
00190 }
00191
00192 }
00193
00194
00195
00196
00197
00198