slicPandora/src
diff -u -r1.10 -r1.11
--- PfoProcessor.cpp 21 May 2010 21:12:48 -0000 1.10
+++ PfoProcessor.cpp 26 May 2010 21:00:59 -0000 1.11
@@ -1,4 +1,4 @@
-// $Id: PfoProcessor.cpp,v 1.10 2010/05/21 21:12:48 jeremy Exp $
+// $Id: PfoProcessor.cpp,v 1.11 2010/05/26 21:00:59 ngraf Exp $
#include "PfoProcessor.h"
// lcio
@@ -17,6 +17,7 @@
#include "PfoConstructionAlgorithm.h"
#include "JobManager.h"
#include "ClusterShapes.h"
+#include "DetectorGeometry.h"
using IMPL::LCCollectionVec;
using IMPL::LCFlagImpl;
@@ -155,6 +156,32 @@
delete[] pHitE; delete[] pHitX; delete[] pHitY; delete[] pHitZ;
}
+ // Set the ReconstructedParticle parameters from the PFO.
+#ifdef PFOPROCESSOR_DEBUG
+ std::cout << "PFO momentum " << (*itPFO)->GetMomentum().GetX()<< " " << (*itPFO)->GetMomentum().GetY()<< " " << (*itPFO)->GetMomentum().GetZ() << std::endl;
+ std::cout << " PFO energy " << (*itPFO)->GetEnergy() << std::endl;
+#endif
+ float momentum[3] = {(*itPFO)->GetMomentum().GetX(), (*itPFO)->GetMomentum().GetY(), (*itPFO)->GetMomentum().GetZ()};
+ pReconstructedParticle->setMomentum(momentum);
+ pReconstructedParticle->setEnergy((*itPFO)->GetEnergy());
+ pReconstructedParticle->setMass((*itPFO)->GetMass());
+ pReconstructedParticle->setCharge((*itPFO)->GetCharge());
+ pReconstructedParticle->setType((*itPFO)->GetParticleId());
+
+ //temporary variables to access the track momentum...
+ DetectorGeometry* detector = getJobManager()->getDetectorGeometry();
+ PandoraApi::Geometry::Parameters* pandoraGeomParams = detector->getGeometryParameters();
+ double magneticField = pandoraGeomParams->m_bField.Get();
+#ifdef PFOPROCESSOR_DEBUG
+ std::cout << "BField= " << magneticField << std::endl;
+#endif
+ double fieldConversion = 2.99792458e-4;
+ double px = 0.;
+ double py = 0.;
+ double pz = 0.;
+ double pT =0.;
+ double energy = 0.;
+ if(trackAddressList.size()>1) std::cout << " PFO has "<< trackAddressList.size() << std::endl;
// Associate the Tracks with the ReconstructedParticles.
for (pandora::TrackAddressList::iterator itTrack = trackAddressList.begin(), itTrackEnd = trackAddressList.end();
itTrack != itTrackEnd;
@@ -163,16 +190,31 @@
#ifdef PFOPROCESSOR_DEBUG
std::cout << "adding track to RP" << std::endl;
#endif
- pReconstructedParticle->addTrack((Track*) (*itTrack));
+ Track* t = (Track*) (*itTrack);
+ double omega = t->getOmega();
+ double phi = t->getPhi();
+ double tanLambda = t->getTanLambda();
+ pT = fabs(1./omega)*magneticField*fieldConversion;
+ px = pT*cos(phi);
+ py = pT*sin(phi);
+ pz = pT*tanLambda;
+ energy = sqrt(px*px+py*py+pz*pz+(*itPFO)->GetMass()*(*itPFO)->GetMass());
+
+ momentum[0] = px;
+ momentum[1] = py;
+ momentum[2] = pz;
+ pReconstructedParticle->addTrack(t);
}
- // Set the ReconstructedParticle parameters from the PFO.
- float momentum[3] = {(*itPFO)->GetMomentum().GetX(), (*itPFO)->GetMomentum().GetY(), (*itPFO)->GetMomentum().GetZ()};
- pReconstructedParticle->setMomentum(momentum);
- pReconstructedParticle->setEnergy((*itPFO)->GetEnergy());
- pReconstructedParticle->setMass((*itPFO)->GetMass());
- pReconstructedParticle->setCharge((*itPFO)->GetCharge());
- pReconstructedParticle->setType((*itPFO)->GetParticleId());
+ //TODO understand why this is necessary
+ //Some oddness in the PFO, seems PFOs with tracks do not have either their momentum
+ // or their energy correctly set
+ // override with information from the track.
+ if(trackAddressList.size()!=0)
+ {
+ pReconstructedParticle->setMomentum(momentum);
+ pReconstructedParticle->setEnergy(energy);
+ }
// Add the ReconstructedParticle to the collection.
pReconstructedParticleCollection->addElement(pReconstructedParticle);