Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::gar_pandora::PfoCreator Class Reference

#include <PfoCreator.h>

Classes

class  Settings
 

Public Types

typedef std::unique_ptr< std::vector< rec::PFParticle > > PFParticleCollection
 
typedef std::unique_ptr< std::vector< rec::Cluster > > ClusterCollection
 

Public Member Functions

 PfoCreator (const Settings &settings, const pandora::Pandora *const pPandora, const RotationTransformation *const pRotation)
 
 ~PfoCreator ()
 
pandora::StatusCode CreateParticleFlowObjects (art::Event &pEvent)
 

Private Member Functions

void InitialiseSubDetectorNames (pandora::StringVector &subDetectorNames) const
 initialise sub detector name strings More...
 
void SetClusterSubDetectorEnergies (const pandora::StringVector &subDetectorNames, const pandora::CaloHitList &pandoraCaloHitList, pandora::FloatVector &hitE, pandora::FloatVector &hitX, pandora::FloatVector &hitY, pandora::FloatVector &hitZ) const
 Set sub detector energies for a cluster. More...
 
void SetClusterEnergyAndError (const pandora::ParticleFlowObject *const pPandoraPfo, const pandora::Cluster *const pPandoraCluster, gar::rec::Cluster &pCluster, float &clusterCorrectEnergy) const
 Set cluster energies and errors. More...
 
void SetClusterPositionAndError (const unsigned int nHitsInCluster, pandora::FloatVector &hitE, pandora::FloatVector &hitX, pandora::FloatVector &hitY, pandora::FloatVector &hitZ, gar::rec::Cluster &pCluster, pandora::CartesianVector &clusterPositionVec) const
 Set cluster position, errors and other shape info, by calculating culster shape first. More...
 
pandora::StatusCode CalculateTrackBasedReferencePoint (const pandora::ParticleFlowObject *const pPandoraPfo, pandora::CartesianVector &referencePoint) const
 Calculate reference point for pfo with tracks. More...
 
void SetRecoParticleReferencePoint (const pandora::CartesianVector &referencePoint, gar::rec::PFParticle &pReconstructedParticle) const
 Set reference point of the reconstructed particle. More...
 
void AddTracksToRecoParticle (const pandora::ParticleFlowObject *const pPandoraPfo, gar::rec::PFParticle &pReconstructedParticle) const
 Add tracks to reconstructed particle. More...
 
void SetRecoParticlePropertiesFromPFO (const pandora::ParticleFlowObject *const pPandoraPfo, gar::rec::PFParticle &pReconstructedParticle) const
 Set properties of reconstructed particle from pandora pfo. More...
 
bool IsValidParentTrack (const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
 Whether parent and daughter tracks are associated with the same pfo. More...
 
bool HasValidSiblingTrack (const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
 Whether sibling tracks are associated with the same pfo. More...
 
bool IsClosestTrackToIP (const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
 Whether the track is the closest (of those associated with the same pfo) to the interaction point. More...
 
bool AreAnyOtherSiblingsInList (const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
 Whether at least one track sibling track is associated to the reconstructed particle. More...
 

Private Attributes

const Settings m_settings
 The pfo creator settings. More...
 
const pandora::Pandora & m_pandora
 Reference to the pandora object from which to extract the pfos. More...
 
const RotationTransformationm_rotation
 

Detailed Description

Definition at line 20 of file PfoCreator.h.

Member Typedef Documentation

Definition at line 25 of file PfoCreator.h.

Definition at line 24 of file PfoCreator.h.

Constructor & Destructor Documentation

gar::gar_pandora::PfoCreator::PfoCreator ( const Settings settings,
const pandora::Pandora *const  pPandora,
const RotationTransformation *const  pRotation 
)

Definition at line 20 of file PfoCreator.cxx.

21  : m_settings(settings),
22  m_pandora(*pPandora),
23  m_rotation(*pRotation)
24  {
25  }
const pandora::Pandora & m_pandora
Reference to the pandora object from which to extract the pfos.
Definition: PfoCreator.h:161
const RotationTransformation & m_rotation
Definition: PfoCreator.h:162
const Settings m_settings
The pfo creator settings.
Definition: PfoCreator.h:160
gar::gar_pandora::PfoCreator::~PfoCreator ( )

Definition at line 29 of file PfoCreator.cxx.

30  {
31  }

Member Function Documentation

void gar::gar_pandora::PfoCreator::AddTracksToRecoParticle ( const pandora::ParticleFlowObject *const  pPandoraPfo,
gar::rec::PFParticle pReconstructedParticle 
) const
private

Add tracks to reconstructed particle.

Parameters
pPandoraPfothe address of the pandora pfo
pReconstructedParticlethe address of the reconstructed particle to be added tracks

Definition at line 364 of file PfoCreator.cxx.

365  {
366  const pandora::TrackList &trackList(pPandoraPfo->GetTrackList());
367 
368  for (pandora::TrackList::const_iterator tIter = trackList.begin(), tIterEnd = trackList.end(); tIter != tIterEnd; ++tIter)
369  {
370  // const pandora::Track *const pTrack(*tIter);
371  // pReconstructedParticle->addTrack((gar::rec::Track*)(pTrack->GetParentAddress()));
372  }
373  }
std::set< const gar::rec::Track * > TrackList
Definition: TrackCreator.h:14
intermediate_table::const_iterator const_iterator
bool gar::gar_pandora::PfoCreator::AreAnyOtherSiblingsInList ( const pandora::Track *const  pPandoraTrack,
const pandora::TrackList &  allTrackList 
) const
private

Whether at least one track sibling track is associated to the reconstructed particle.

Parameters
pPandoraTrackthe address of the pandora track
allTrackListlist of all tracks associated to reconstructed particle
Returns
boolean

Definition at line 341 of file PfoCreator.cxx.

342  {
343  const pandora::TrackList &siblingTrackList(pPandoraTrack->GetSiblingList());
344 
345  for (pandora::TrackList::const_iterator iter = siblingTrackList.begin(), iterEnd = siblingTrackList.end(); iter != iterEnd; ++iter)
346  {
347  if (allTrackList.end() != std::find(allTrackList.begin(), allTrackList.end(), *iter))
348  return true;
349  }
350 
351  return false;
352  }
std::set< const gar::rec::Track * > TrackList
Definition: TrackCreator.h:14
intermediate_table::const_iterator const_iterator
pandora::StatusCode gar::gar_pandora::PfoCreator::CalculateTrackBasedReferencePoint ( const pandora::ParticleFlowObject *const  pPandoraPfo,
pandora::CartesianVector &  referencePoint 
) const
private

Calculate reference point for pfo with tracks.

Parameters
pPandoraPfothe address of the pandora pfo
referencePointa CartesianVector to receive the reference point

Definition at line 204 of file PfoCreator.cxx.

205  {
206  const pandora::TrackList &trackList(pPandoraPfo->GetTrackList());
207 
208  float totalTrackMomentumAtDca(0.f), totalTrackMomentumAtStart(0.f);
209  pandora::CartesianVector referencePointAtDCAWeighted(0.f, 0.f, 0.f), referencePointAtStartWeighted(0.f, 0.f, 0.f);
210 
211  bool hasSiblings(false);
212  for (pandora::TrackList::const_iterator tIter = trackList.begin(), tIterEnd = trackList.end(); tIter != tIterEnd; ++tIter)
213  {
214  const pandora::Track *const pPandoraTrack(*tIter);
215 
216  if (!this->IsValidParentTrack(pPandoraTrack, trackList))
217  continue;
218 
219  if (this->HasValidSiblingTrack(pPandoraTrack, trackList))
220  {
221  // Presence of sibling tracks typically represents a conversion
222  const pandora::CartesianVector &trackStartPoint((pPandoraTrack->GetTrackStateAtStart()).GetPosition());
223  const float trackStartMomentum(((pPandoraTrack->GetTrackStateAtStart()).GetMomentum()).GetMagnitude());
224  referencePointAtStartWeighted += trackStartPoint * trackStartMomentum;
225  totalTrackMomentumAtStart += trackStartMomentum;
226  hasSiblings = true;
227  }
228  // else
229  // {
230  // const gar::rec::Track *const pTrack = (gar::rec::Track*)(pPandoraTrack->GetParentAddress());
231  // const float z0(pPandoraTrack->GetZ0());
232  // pandora::CartesianVector intersectionPoint(0.f, 0.f, 0.f);
233  //
234  // intersectionPoint.SetValues(pTrack->getD0() * std::cos(pTrack->getPhi()), pTrack->getD0() * std::sin(pTrack->getPhi()), z0);
235  // const float trackMomentumAtDca((pPandoraTrack->GetMomentumAtDca()).GetMagnitude());
236  // referencePointAtDCAWeighted += intersectionPoint * trackMomentumAtDca;
237  // totalTrackMomentumAtDca += trackMomentumAtDca;
238  // }
239  }
240 
241  if (hasSiblings)
242  {
243  if (totalTrackMomentumAtStart < std::numeric_limits<float>::epsilon())
244  {
245  MF_LOG_WARNING("PfoCreator::CalculateTrackBasedReferencePoint")
246  << "invalid track momentum " << totalTrackMomentumAtStart;
247  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
248  }
249  else
250  {
251  referencePoint = referencePointAtStartWeighted * (1.f / totalTrackMomentumAtStart);
252  }
253  }
254  else
255  {
256  if (totalTrackMomentumAtDca < std::numeric_limits<float>::epsilon())
257  {
258  MF_LOG_WARNING("PfoCreator::CalculateTrackBasedReferencePoint")
259  << "invalid track momentum " << totalTrackMomentumAtDca;
260  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
261  }
262  else
263  {
264  referencePoint = referencePointAtDCAWeighted * (1.f / totalTrackMomentumAtDca);
265  }
266  }
267 
268  return pandora::STATUS_CODE_SUCCESS;
269  }
bool IsValidParentTrack(const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
Whether parent and daughter tracks are associated with the same pfo.
Definition: PfoCreator.cxx:273
std::set< const gar::rec::Track * > TrackList
Definition: TrackCreator.h:14
intermediate_table::const_iterator const_iterator
bool HasValidSiblingTrack(const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
Whether sibling tracks are associated with the same pfo.
Definition: PfoCreator.cxx:298
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
#define MF_LOG_WARNING(category)
pandora::StatusCode gar::gar_pandora::PfoCreator::CreateParticleFlowObjects ( art::Event pEvent)

Definition at line 35 of file PfoCreator.cxx.

36  {
37  PFParticleCollection outputParticles( new std::vector<rec::PFParticle> );
38  ClusterCollection outputClusters( new std::vector<rec::Cluster> );
39 
40  const pandora::PfoList *pPandoraPfoList = NULL;
41  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, PandoraApi::GetCurrentPfoList(m_pandora, pPandoraPfoList));
42 
43  pandora::StringVector subDetectorNames;
44  this->InitialiseSubDetectorNames(subDetectorNames);
45 
46  for (pandora::PfoList::const_iterator pIter = pPandoraPfoList->begin(), pIterEnd = pPandoraPfoList->end(); pIter != pIterEnd; ++pIter)
47  {
48  const pandora::ParticleFlowObject *const pPandoraPfo(*pIter);
49  gar::rec::PFParticle pReconstructedParticle;
50 
51  const bool hasTrack(!pPandoraPfo->GetTrackList().empty());
52  const pandora::ClusterList &clusterList(pPandoraPfo->GetClusterList());
53 
54  float clustersTotalEnergy(0.f);
55  pandora::CartesianVector referencePoint(0.f, 0.f, 0.f), clustersWeightedPosition(0.f, 0.f, 0.f);
56 
57  for (pandora::ClusterList::const_iterator cIter = clusterList.begin(), cIterEnd = clusterList.end(); cIter != cIterEnd; ++cIter)
58  {
59  const pandora::Cluster *const pPandoraCluster(*cIter);
60  pandora::CaloHitList pandoraCaloHitList;
61  pPandoraCluster->GetOrderedCaloHitList().FillCaloHitList(pandoraCaloHitList);
62  pandoraCaloHitList.insert(pandoraCaloHitList.end(), pPandoraCluster->GetIsolatedCaloHitList().begin(), pPandoraCluster->GetIsolatedCaloHitList().end());
63 
64  pandora::FloatVector hitE, hitX, hitY, hitZ;
65  gar::rec::Cluster pCluster;
66  this->SetClusterSubDetectorEnergies(subDetectorNames, pandoraCaloHitList, hitE, hitX, hitY, hitZ);
67 
68  float clusterCorrectEnergy(0.f);
69  this->SetClusterEnergyAndError(pPandoraPfo, pPandoraCluster, pCluster, clusterCorrectEnergy);
70 
71  pandora::CartesianVector clusterPosition(0.f, 0.f, 0.f);
72  const unsigned int nHitsInCluster(pandoraCaloHitList.size());
73  this->SetClusterPositionAndError(nHitsInCluster, hitE, hitX, hitY, hitZ, pCluster, clusterPosition);
74 
75  if (!hasTrack)
76  {
77  clustersWeightedPosition += clusterPosition * clusterCorrectEnergy;
78  clustersTotalEnergy += clusterCorrectEnergy;
79  }
80 
81  MF_LOG_DEBUG("PfoCreator::CreateParticleFlowObjects")
82  << "Adding cluster " << &pCluster
83  << " with energy " << pCluster.Energy();
84 
85  outputClusters->emplace_back(pCluster);
86  }
87 
88  if (!hasTrack)
89  {
90  if (clustersTotalEnergy < std::numeric_limits<float>::epsilon())
91  {
92  MF_LOG_DEBUG("PfoCreator::CreateParticleFlowObjects")
93  << "invalid cluster energy " << clustersTotalEnergy;
94  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
95  }
96  else
97  {
98  referencePoint = clustersWeightedPosition * (1.f / clustersTotalEnergy);
99  }
100  }
101  else
102  {
103  PANDORA_RETURN_RESULT_IF(pandora::STATUS_CODE_SUCCESS, !=, this->CalculateTrackBasedReferencePoint(pPandoraPfo, referencePoint));
104  }
105 
106  this->SetRecoParticleReferencePoint(referencePoint, pReconstructedParticle);
107  this->AddTracksToRecoParticle(pPandoraPfo, pReconstructedParticle);
108  this->SetRecoParticlePropertiesFromPFO(pPandoraPfo, pReconstructedParticle);
109 
110  MF_LOG_DEBUG("PfoCreator::CreateParticleFlowObjects")
111  << "Adding PFO " << &pReconstructedParticle
112  << " with energy " << pReconstructedParticle.Energy()
113  << " , mass " << pReconstructedParticle.Mass();
114 
115  // a hack to make clang happy -- make sure m_rotation is used in the code
116  // this should never print
117 
118  if (pReconstructedParticle.Energy() < -1000)
119  MF_LOG_DEBUG("PfoCreator::CreateParticleFlowObjects")
120  << " Negative energy. Message should not be printed. " << m_rotation.kAxisX;
121 
122  outputParticles->emplace_back(pReconstructedParticle);
123  }
124 
125  pEvent.put(std::move(outputParticles));
126  pEvent.put(std::move(outputClusters));
127 
128  return pandora::STATUS_CODE_SUCCESS;
129  }
void SetRecoParticleReferencePoint(const pandora::CartesianVector &referencePoint, gar::rec::PFParticle &pReconstructedParticle) const
Set reference point of the reconstructed particle.
Definition: PfoCreator.cxx:356
std::unique_ptr< std::vector< rec::PFParticle > > PFParticleCollection
Definition: PfoCreator.h:24
pandora::StatusCode CalculateTrackBasedReferencePoint(const pandora::ParticleFlowObject *const pPandoraPfo, pandora::CartesianVector &referencePoint) const
Calculate reference point for pfo with tracks.
Definition: PfoCreator.cxx:204
float Mass() const
Definition: PFParticle.h:94
void SetClusterEnergyAndError(const pandora::ParticleFlowObject *const pPandoraPfo, const pandora::Cluster *const pPandoraCluster, gar::rec::Cluster &pCluster, float &clusterCorrectEnergy) const
Set cluster energies and errors.
Definition: PfoCreator.cxx:164
intermediate_table::const_iterator const_iterator
float Energy() const
Definition: PFParticle.h:91
const pandora::Pandora & m_pandora
Reference to the pandora object from which to extract the pfos.
Definition: PfoCreator.h:161
const RotationTransformation & m_rotation
Definition: PfoCreator.h:162
def move(depos, offset)
Definition: depos.py:107
void SetRecoParticlePropertiesFromPFO(const pandora::ParticleFlowObject *const pPandoraPfo, gar::rec::PFParticle &pReconstructedParticle) const
Set properties of reconstructed particle from pandora pfo.
Definition: PfoCreator.cxx:377
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
void SetClusterSubDetectorEnergies(const pandora::StringVector &subDetectorNames, const pandora::CaloHitList &pandoraCaloHitList, pandora::FloatVector &hitE, pandora::FloatVector &hitX, pandora::FloatVector &hitY, pandora::FloatVector &hitZ) const
Set sub detector energies for a cluster.
Definition: PfoCreator.cxx:140
void SetClusterPositionAndError(const unsigned int nHitsInCluster, pandora::FloatVector &hitE, pandora::FloatVector &hitX, pandora::FloatVector &hitY, pandora::FloatVector &hitZ, gar::rec::Cluster &pCluster, pandora::CartesianVector &clusterPositionVec) const
Set cluster position, errors and other shape info, by calculating culster shape first.
Definition: PfoCreator.cxx:182
void InitialiseSubDetectorNames(pandora::StringVector &subDetectorNames) const
initialise sub detector name strings
Definition: PfoCreator.cxx:133
void AddTracksToRecoParticle(const pandora::ParticleFlowObject *const pPandoraPfo, gar::rec::PFParticle &pReconstructedParticle) const
Add tracks to reconstructed particle.
Definition: PfoCreator.cxx:364
std::vector< string > StringVector
Definition: fcldump.cxx:29
#define MF_LOG_DEBUG(id)
std::unique_ptr< std::vector< rec::Cluster > > ClusterCollection
Definition: PfoCreator.h:25
Dft::FloatVector FloatVector
float Energy() const
Definition: Cluster.h:92
bool gar::gar_pandora::PfoCreator::HasValidSiblingTrack ( const pandora::Track *const  pPandoraTrack,
const pandora::TrackList &  allTrackList 
) const
private

Whether sibling tracks are associated with the same pfo.

Parameters
pPandoraTrackthe address of the pandora track
allTrackListlist of all tracks associated with reconstructed particle
Returns
boolean

Definition at line 298 of file PfoCreator.cxx.

299  {
300  const pandora::TrackList &siblingTrackList(pPandoraTrack->GetSiblingList());
301  for (pandora::TrackList::const_iterator iter = siblingTrackList.begin(), iterEnd = siblingTrackList.end(); iter != iterEnd; ++iter) {
302  if (allTrackList.end() != std::find(allTrackList.begin(), allTrackList.end(), *iter))
303  continue;
304 
305  // ATTN This track must have a sibling not in the all track list; still use it if it has a second sibling that is in the list
306  MF_LOG_WARNING("PfoCreator::HasValidSiblingTrack") << "mismatch in track relationship information, use information as available ";
307 
308  if (this->AreAnyOtherSiblingsInList(pPandoraTrack, allTrackList))
309  return true;
310 
311  return false;
312  }
313 
314  return true;
315  }
bool AreAnyOtherSiblingsInList(const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
Whether at least one track sibling track is associated to the reconstructed particle.
Definition: PfoCreator.cxx:341
std::set< const gar::rec::Track * > TrackList
Definition: TrackCreator.h:14
intermediate_table::const_iterator const_iterator
#define MF_LOG_WARNING(category)
void gar::gar_pandora::PfoCreator::InitialiseSubDetectorNames ( pandora::StringVector subDetectorNames) const
private

initialise sub detector name strings

Parameters
subDetectorNamesto receive the list of sub detector names

Definition at line 133 of file PfoCreator.cxx.

134  {
135  subDetectorNames.push_back("ecal");
136  }
bool gar::gar_pandora::PfoCreator::IsClosestTrackToIP ( const pandora::Track *const  pPandoraTrack,
const pandora::TrackList &  allTrackList 
) const
private

Whether the track is the closest (of those associated with the same pfo) to the interaction point.

Parameters
pPandoraTrackthe address of the pandora track
allTrackListlist of all tracks associated to reconstructed particle
Returns
boolean

Definition at line 319 of file PfoCreator.cxx.

320  {
321  const pandora::Track *pClosestTrack(NULL);
322  float closestTrackDisplacement(std::numeric_limits<float>::max());
323 
324  for (pandora::TrackList::const_iterator iter = allTrackList.begin(), iterEnd = allTrackList.end(); iter != iterEnd; ++iter)
325  {
326  const pandora::Track *const pTrack(*iter);
327  const float trialTrackDisplacement(pTrack->GetTrackStateAtStart().GetPosition().GetMagnitude());
328 
329  if (trialTrackDisplacement < closestTrackDisplacement)
330  {
331  closestTrackDisplacement = trialTrackDisplacement;
332  pClosestTrack = pTrack;
333  }
334  }
335 
336  return (pPandoraTrack == pClosestTrack);
337  }
intermediate_table::const_iterator const_iterator
static int max(int a, int b)
TrackCollectionProxyElement< TrackCollProxy > Track
Proxy to an element of a proxy collection of recob::Track objects.
Definition: Track.h:1036
bool gar::gar_pandora::PfoCreator::IsValidParentTrack ( const pandora::Track *const  pPandoraTrack,
const pandora::TrackList &  allTrackList 
) const
private

Whether parent and daughter tracks are associated with the same pfo.

Parameters
pPandoraTrackthe address of the pandora track
allTrackListlist of all tracks associated with reconstructed particle
Returns
boolean

Definition at line 273 of file PfoCreator.cxx.

274  {
275  const pandora::TrackList &parentTrackList(pPandoraTrack->GetParentList());
276 
277  for (pandora::TrackList::const_iterator iter = parentTrackList.begin(), iterEnd = parentTrackList.end(); iter != iterEnd; ++iter)
278  {
279  if (allTrackList.end() != std::find(allTrackList.begin(), allTrackList.end(), *iter))
280  continue;
281 
282  // ATTN This track must have a parent not in the all track list; still use it if it is the closest to the ip
283  MF_LOG_WARNING("PfoCreator::IsValidParentTrack")
284  << "mismatch in track relationship information, use information as available ";
285 
286  if (this->IsClosestTrackToIP(pPandoraTrack, allTrackList))
287  return true;
288 
289  return false;
290  }
291 
292  // Ideal case: All parents are associated to same pfo
293  return true;
294  }
bool IsClosestTrackToIP(const pandora::Track *const pPandoraTrack, const pandora::TrackList &allTrackList) const
Whether the track is the closest (of those associated with the same pfo) to the interaction point...
Definition: PfoCreator.cxx:319
std::set< const gar::rec::Track * > TrackList
Definition: TrackCreator.h:14
intermediate_table::const_iterator const_iterator
#define MF_LOG_WARNING(category)
void gar::gar_pandora::PfoCreator::SetClusterEnergyAndError ( const pandora::ParticleFlowObject *const  pPandoraPfo,
const pandora::Cluster *const  pPandoraCluster,
gar::rec::Cluster pCluster,
float &  clusterCorrectEnergy 
) const
private

Set cluster energies and errors.

Parameters
pPandoraPfothe address of the pandora pfo
pPandoraClusterthe address of the pandora cluster
pLcioClusterthe address of the lcio cluster to be set energies and erros
clusterCorrectEnergya number to receive the cluster correct energy

Definition at line 164 of file PfoCreator.cxx.

165  {
166  const bool isEmShower((pandora::PHOTON == pPandoraPfo->GetParticleId()) || (pandora::E_MINUS == std::abs(pPandoraPfo->GetParticleId())));
167  clusterCorrectEnergy = (isEmShower ? pPandoraCluster->GetCorrectedElectromagneticEnergy(m_pandora) : pPandoraCluster->GetCorrectedHadronicEnergy(m_pandora));
168 
169  if (clusterCorrectEnergy < std::numeric_limits<float>::epsilon())
170  throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
171 
172  const float stochasticTerm(isEmShower ? m_settings.m_emStochasticTerm : m_settings.m_hadStochasticTerm);
173  const float constantTerm(isEmShower ? m_settings.m_emConstantTerm : m_settings.m_hadConstantTerm);
174  const float energyError(std::sqrt(stochasticTerm * stochasticTerm / clusterCorrectEnergy + constantTerm * constantTerm) * clusterCorrectEnergy);
175 
176  pCluster.setEnergy(clusterCorrectEnergy);
177  pCluster.setEnergyError(energyError);
178  }
float m_hadConstantTerm
The constant term for HAD shower energy resolution.
Definition: PfoCreator.h:35
float m_hadStochasticTerm
The stochastic term for HAD shower energy resolution.
Definition: PfoCreator.h:34
void setEnergyError(float energy_error)
Definition: Cluster.cxx:23
const pandora::Pandora & m_pandora
Reference to the pandora object from which to extract the pfos.
Definition: PfoCreator.h:161
T abs(T value)
void setEnergy(float energy)
Definition: Cluster.cxx:18
float m_emConstantTerm
The constant term for EM shower energy resolution.
Definition: PfoCreator.h:33
float m_emStochasticTerm
The stochastic term for EM shower energy resolution.
Definition: PfoCreator.h:32
const Settings m_settings
The pfo creator settings.
Definition: PfoCreator.h:160
void gar::gar_pandora::PfoCreator::SetClusterPositionAndError ( const unsigned int  nHitsInCluster,
pandora::FloatVector hitE,
pandora::FloatVector hitX,
pandora::FloatVector hitY,
pandora::FloatVector hitZ,
gar::rec::Cluster pCluster,
pandora::CartesianVector &  clusterPositionVec 
) const
private

Set cluster position, errors and other shape info, by calculating culster shape first.

Parameters
nHitsInClusternumber of hits in cluster
hitEthe vector of the energy of hits
hitXthe vector of the x position of hits
hitYthe vector of the y position of hits
hitZthe vector of the z position of hits
pLcioClusterthe lcio cluster to be set positions and errors
clusterPositiona CartesianVector to receive the cluster position

Definition at line 182 of file PfoCreator.cxx.

183  {
184  util::ClusterShapes pClusterShapes(nHitsInCluster, hitE.data(), hitX.data(), hitY.data(), hitZ.data());
185 
186  try
187  {
188  pCluster.setIPhi(std::atan2(pClusterShapes.getEigenVecInertia()[1], pClusterShapes.getEigenVecInertia()[0]));
189  pCluster.setITheta(std::acos(pClusterShapes.getEigenVecInertia()[2]));
190  pCluster.setPosition(pClusterShapes.getCenterOfGravity());
191  //pCluster->setPositionError(pClusterShapes->getCenterOfGravityErrors());
192  //pCluster->setDirectionError(pClusterShapes->getEigenVecInertiaErrors());
193  clusterPositionVec.SetValues(pClusterShapes.getCenterOfGravity()[0], pClusterShapes.getCenterOfGravity()[1], pClusterShapes.getCenterOfGravity()[2]);
194  }
195  catch (...)
196  {
197  MF_LOG_WARNING("PfoCreator::SetClusterPositionAndError")
198  << "unidentified exception caught.";
199  }
200  }
void setPosition(const float *position)
Definition: Cluster.cxx:34
void setIPhi(float phi)
Definition: Cluster.cxx:44
void setITheta(float theta)
Definition: Cluster.cxx:39
#define MF_LOG_WARNING(category)
void gar::gar_pandora::PfoCreator::SetClusterSubDetectorEnergies ( const pandora::StringVector subDetectorNames,
const pandora::CaloHitList &  pandoraCaloHitList,
pandora::FloatVector hitE,
pandora::FloatVector hitX,
pandora::FloatVector hitY,
pandora::FloatVector hitZ 
) const
private

Set sub detector energies for a cluster.

Parameters
subDetectorNamesthe list of sub detector names
pLcioClusterthe address of the lcio cluster to be set sub detector energies
pandoraCaloHitListthe pandora calorimeter hit list
hitEthe vector to receive the energy of hits
hitXthe vector to receive the x position of hits
hitYthe vector to receive the y position of hits
hitZthe vector to receive the z position of hits

Definition at line 140 of file PfoCreator.cxx.

141  {
142  for (pandora::CaloHitList::const_iterator hIter = pandoraCaloHitList.begin(), hIterEnd = pandoraCaloHitList.end(); hIter != hIterEnd; ++hIter)
143  {
144  const pandora::CaloHit *const pPandoraCaloHit(*hIter);
145  gar::rec::CaloHit *const pCalorimeterHit = (gar::rec::CaloHit*)(pPandoraCaloHit->GetParentAddress());
146 
147  MF_LOG_DEBUG("PfoCreator::SetClusterSubDetectorEnergies")
148  << " hit " << pCalorimeterHit
149  << " energy " << pCalorimeterHit->Energy()
150  << " position x " << pCalorimeterHit->Position()[0]
151  << " y " << pCalorimeterHit->Position()[1]
152  << " z " << pCalorimeterHit->Position()[2];
153 
154  const float caloHitEnergy(pCalorimeterHit->Energy());
155  hitE.push_back(caloHitEnergy);
156  hitX.push_back(pCalorimeterHit->Position()[0]);
157  hitY.push_back(pCalorimeterHit->Position()[1]);
158  hitZ.push_back(pCalorimeterHit->Position()[2]);
159  }
160  }
intermediate_table::const_iterator const_iterator
float Energy() const
Definition: CaloHit.h:69
const float * Position() const
Definition: CaloHit.h:70
#define MF_LOG_DEBUG(id)
void gar::gar_pandora::PfoCreator::SetRecoParticlePropertiesFromPFO ( const pandora::ParticleFlowObject *const  pPandoraPfo,
gar::rec::PFParticle pReconstructedParticle 
) const
private

Set properties of reconstructed particle from pandora pfo.

Parameters
pPandoraPfothe address of the pandora pfo
pReconstructedParticlethe address of the reconstructed particle to be set properties

Definition at line 377 of file PfoCreator.cxx.

378  {
379  const float momentum[3] = {pPandoraPfo->GetMomentum().GetX(), pPandoraPfo->GetMomentum().GetY(), pPandoraPfo->GetMomentum().GetZ()};
380  pReconstructedParticle.setMomentum(momentum);
381  pReconstructedParticle.setEnergy(pPandoraPfo->GetEnergy());
382  pReconstructedParticle.setMass(pPandoraPfo->GetMass());
383  pReconstructedParticle.setCharge(pPandoraPfo->GetCharge());
384  pReconstructedParticle.setType(pPandoraPfo->GetParticleId());
385  }
void setMass(float mass)
Definition: PFParticle.cxx:80
void setEnergy(float energy)
Definition: PFParticle.cxx:61
void setMomentum(const float mom[3])
Definition: PFParticle.cxx:73
void setCharge(float charge)
Definition: PFParticle.cxx:85
void setType(int type)
Definition: PFParticle.cxx:56
def momentum(x1, x2, x3, scale=1.)
void gar::gar_pandora::PfoCreator::SetRecoParticleReferencePoint ( const pandora::CartesianVector &  referencePoint,
gar::rec::PFParticle pReconstructedParticle 
) const
private

Set reference point of the reconstructed particle.

Parameters
referencePointa CartesianVector of the reference point
pReconstructedParticlethe address of the reconstructed particle to be reference point

Definition at line 356 of file PfoCreator.cxx.

357  {
358  const float referencePointArray[3] = {referencePoint.GetX(), referencePoint.GetY(), referencePoint.GetZ()};
359  pReconstructedParticle.setPosition(referencePointArray);
360  }
void setPosition(const float pos[3])
Definition: PFParticle.cxx:66

Member Data Documentation

const pandora::Pandora& gar::gar_pandora::PfoCreator::m_pandora
private

Reference to the pandora object from which to extract the pfos.

Definition at line 161 of file PfoCreator.h.

const RotationTransformation& gar::gar_pandora::PfoCreator::m_rotation
private

Definition at line 162 of file PfoCreator.h.

const Settings gar::gar_pandora::PfoCreator::m_settings
private

The pfo creator settings.

Definition at line 160 of file PfoCreator.h.


The documentation for this class was generated from the following files: