APRILContent
Algorithm of Particle Reconstruction for ILC - implementation with PandoraSDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations
ConnectorCleaningTool.h
Go to the documentation of this file.
1 /*
3  *
4  * ConnectorCleaningTool.h header template automatically generated by a class generator
5  * Creation date : mar. d�c. 8 2015
6  *
7  * This file is part of APRILContent libraries.
8  *
9  * APRILContent is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  * based upon these libraries are permitted. Any copy of these libraries
14  * must include this copyright notice.
15  *
16  * APRILContent is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with APRILContent. If not, see <http://www.gnu.org/licenses/>.
23  *
24  * @author Remi Ete
25  * @copyright CNRS , IPNL
26  */
27 
28 
29 #ifndef CONNECTORCLEANINGTOOL_H
30 #define CONNECTORCLEANINGTOOL_H
31 
33 
34 #include "Objects/CartesianVector.h"
35 
36 namespace april_content
37 {
38 
39 class CaloHit;
40 class Connector;
41 
47 {
48 public:
50  : m_distance(std::numeric_limits<float>::max()),
51  m_openingAngle(std::numeric_limits<float>::max()),
52  m_nConnectons(0),
53  m_creationStage(-1),
54  m_fromHitPos(0., 0., 0.),
55  m_orderParameter(std::numeric_limits<float>::max())
56  {
57  //std::cout << "best ConnectorOrderParameter: " << m_distance << ", " << m_openingAngle << ", " << m_orderParameter << std::endl;
58  //std::cout << " --- small angle range: " << m_smallAngleRange << std::endl;
59  }
60 
61  ConnectorOrderParameter(float distance, float openingAngle, unsigned int nConnections, unsigned int creationStage, pandora::CartesianVector formHitPos)
62  : m_distance(distance),
63  m_openingAngle(openingAngle),
64  m_nConnectons(nConnections),
65  m_creationStage(creationStage),
66  m_fromHitPos(formHitPos)
67  {
68  m_orderParameter = std::pow(m_openingAngle, m_orderParameterAnglePower) *
69  std::pow(m_distance, m_orderParameterDistancePower);
70  }
71 
72  bool operator==(ConnectorOrderParameter& a) const
73  {
74  if( m_creationStage == a.m_creationStage &&
75  m_openingAngle == a.m_openingAngle &&
76  m_distance == a.m_distance &&
77  m_nConnectons == a.m_nConnectons &&
78  m_fromHitPos == a.m_fromHitPos )
79  {
80  return true;
81  }
82  else
83  {
84  return false;
85  }
86  }
87 
88  bool operator<(const ConnectorOrderParameter& a) const
89  {
90  //std::cout << " ---+++ small angle range: " << m_smallAngleRange << std::endl;
91 
92  if( m_creationStage != a.m_creationStage )
93  {
94  return m_creationStage < a.m_creationStage;
95  }
96 
97  if(m_openingAngle < m_smallAngleRange && a.m_openingAngle < m_smallAngleRange && m_distance != a.m_distance)
98  {
99  //std::cout << "small angle, distance: " << m_distance << ", " << a.m_distance << std::endl;
100  return m_distance < a.m_distance;
101  }
102 
103  if(m_openingAngle == a.m_openingAngle && m_distance == a.m_distance && m_nConnectons != a.m_nConnectons)
104  {
105  // sure, hit with more connectors has small (good) order ...
106  return m_nConnectons > a.m_nConnectons;
107  }
108 
109  if(m_nConnectons == a.m_nConnectons && m_orderParameter == a.m_orderParameter)
110  {
111  // if all parameters but position are the same, just take position to sort the hit
112  if(!(m_fromHitPos == a.m_fromHitPos))
113  {
114  return ( m_fromHitPos.GetX() < a.m_fromHitPos.GetX() ||
115  m_fromHitPos.GetY() < a.m_fromHitPos.GetY() ||
116  m_fromHitPos.GetZ() < a.m_fromHitPos.GetZ() );
117  }
118  else
119  {
120  //std::cout << "Connector are completely the same." << std::endl;
121  //std::cout << "m_fromHitPos1: " << m_fromHitPos.GetX() << ", " << m_fromHitPos.GetY() << ", " << m_fromHitPos.GetZ() << std::endl;
122  //std::cout << "m_fromHitPos2: " << a.m_fromHitPos.GetX() << ", " << a.m_fromHitPos.GetY() << ", " << a.m_fromHitPos.GetZ() << std::endl;
123  //throw pandora::StatusCodeException(pandora::STATUS_CODE_FAILURE);
124  return false;
125  }
126  }
127 
128  return m_orderParameter < a.m_orderParameter;
129  }
130 
131  float m_distance;
132  float m_openingAngle;
133  unsigned int m_nConnectons;
134  unsigned int m_creationStage;
135  pandora::CartesianVector m_fromHitPos;
136  float m_orderParameter;
137 
138  static float m_smallAngleRange;
139  static float m_orderParameterAnglePower;
140  static float m_orderParameterDistancePower;
141 };
142 
144 {
145  typedef std::map<const april_content::CaloHit*, pandora::CaloHitList> CaloHitCleaningMap;
146 
147 public:
151  class Factory : public pandora::AlgorithmToolFactory
152  {
153  public:
154  pandora::AlgorithmTool *CreateAlgorithmTool() const;
155  };
156 
161 
168  pandora::StatusCode Process(const pandora::Algorithm &algorithm, const pandora::CaloHitList *const pCaloHitList = nullptr);
169 
175  pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle);
176 
177 private:
186  //float GetOrderParameter(const april_content::Connector *const pConnector, const pandora::CartesianVector &referenceDirection) const;
187 
195  pandora::CartesianVector GetReferenceVector(const april_content::CaloHit *const pCaloHit) const;
196 
202  pandora::StatusCode CleanCaloHits(const pandora::CaloHitList *const pCaloHitList) const;
203 
209  pandora::StatusCode CleanCaloHits(const pandora::OrderedCaloHitList &orderedCaloHitList) const;
210 
211 private:
212  unsigned int m_strategy;
213  float m_backwardConnectorWeight;
214  float m_forwardConnectorWeight;
215  unsigned int m_backwardReferenceDirectionDepth;
216  unsigned int m_forwardReferenceDirectionDepth;
217  float m_orderParameterAnglePower;
218  float m_orderParameterDistancePower;
219 };
220 
221 //------------------------------------------------------------------------------------------------------------------------------------------
222 
223 inline pandora::AlgorithmTool *ConnectorCleaningTool::Factory::CreateAlgorithmTool() const
224 {
225  return new ConnectorCleaningTool();
226 }
227 
228 //------------------------------------------------------------------------------------------------------------------------------------------
229 
231 {
232 
233 }
234 
235 }
236 
237 #endif // CONNECTORCLEANINGTOOL_H
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read settings from the xml handle.
Definition: ConnectorCleaningTool.cc:249
Factory class for instantiating algorithm tool.
Definition: ConnectorCleaningTool.h:151
CaloHit class.
Definition: CaloHit.h:52
Definition: ConnectorCleaningTool.h:143
ConnectorCleaningTool class.
Definition: ConnectorCleaningTool.h:46
pandora::StatusCode CleanCaloHits(const pandora::CaloHitList *const pCaloHitList) const
Clean the connectors of the calo hits, ending with a tree structure.
Definition: ConnectorCleaningTool.cc:124
pandora::CartesianVector GetReferenceVector(const april_content::CaloHit *const pCaloHit) const
Get the order parameter of the connector in the backward direction.
Definition: ConnectorCleaningTool.cc:73
pandora::StatusCode Process(const pandora::Algorithm &algorithm, const pandora::CaloHitList *const pCaloHitList=nullptr)
Clean the connectors of the calo hit list.
Definition: ConnectorCleaningTool.cc:48
~ConnectorCleaningTool()
Destructor.
Definition: ConnectorCleaningTool.h:230
ConnectorAlgorithmTool class.
Definition: ConnectorAlgorithmTool.h:41