41 ReconstructionFrame::ReconstructionFrame(
const std::string& sname,
42 const std::string& stitle)
43 : RestFrame(sname, stitle)
49 ReconstructionFrame::ReconstructionFrame()
52 ReconstructionFrame::~ReconstructionFrame(){
58 m_ChildStates.clear();
63 return VisibleRecoFrame::Empty();
68 if(!frame.IsRecoFrame())
return;
69 RestFrame::AddChildFrame(frame);
74 bool contains = m_ChildFrames.Contains(frame);
75 m_ChildBoosts.erase(&frame);
76 m_ChildStates.erase(&frame);
77 m_ChildFrames.Remove(frame);
79 frame.SetParentFrame();
84 while(GetNChildren() > 0)
86 m_ChildFrames.Clear();
87 m_ChildBoosts.clear();
88 m_ChildStates.clear();
93 if(!frame.IsRecoFrame())
return;
94 RestFrame::SetParentFrame(frame);
98 const RestFrame& frame = RestFrame::GetParentFrame();
100 return static_cast<const ReconstructionFrame&>(frame);
102 return ReconstructionFrame::Empty();
106 RestFrame& frame = RestFrame::GetChildFrame(i);
108 return static_cast<ReconstructionFrame&>(frame);
110 return ReconstructionFrame::Empty();
113 StateList const& ReconstructionFrame::GetChildStates(
int i)
const {
117 StateList
const& ReconstructionFrame::GetChildStates(
const RestFrame& child)
const {
118 if(m_ChildStates.count(&child) <= 0)
119 return State::EmptyList();
121 return m_ChildStates[&child];
124 void ReconstructionFrame::SetGroup(Group& group){
125 if(IsEmpty())
return;
130 if(*m_GroupPtr != group){
131 Group* groupPtr = m_GroupPtr;
132 m_GroupPtr =
nullptr;
133 groupPtr->RemoveFrame(*
this);
137 m_GroupPtr =
nullptr;
142 Group& ReconstructionFrame::GetGroup()
const {
146 return Group::Empty();
149 GroupList ReconstructionFrame::GetListGroups()
const {
151 FillListGroupsRecursive(groups);
155 void ReconstructionFrame::FillListGroupsRecursive(GroupList& groups)
const {
156 if(m_GroupPtr) groups.Add(*m_GroupPtr);
157 int Nchild = GetNChildren();
158 for(
int i = 0; i < Nchild; i++)
162 bool ReconstructionFrame::InitializeVisibleStates(){
163 m_ChildStates.clear();
167 const VisibleStateList& states =
168 static_cast<const LabRecoFrame&
>(GetLabFrame()).GetTreeStates();
170 int Nchild = GetNChildren();
171 for(
int i = 0; i < Nchild; i++){
173 m_ChildStates[&child] = StateList();
174 RFList<ReconstructionFrame> frames = child.GetListVisibleFrames();
175 int Nf = frames.GetN();
176 for(
int f = 0; f < Nf; f++)
177 if(!frames[f].GetGroup())
178 if(!m_ChildStates[&child].Add(StateList(states).GetFrame(frames[f]))){
180 m_Log <<
"Unable to associate State with Group-less Frame:";
181 m_Log << Log(frames[f]) << LogEnd;
188 bool ReconstructionFrame::InitializeGroupStates(){
189 GroupList groups = GetListGroups();
190 int Ngroup = groups.GetN();
191 int Nchild = GetNChildren();
193 for(
int c = 0; c < Nchild; c++){
194 RestFrameList frames =
197 int Nframe = frames.GetN();
198 for(
int f = 0; f < Nframe; f++){
199 for(
int g = 0; g < Ngroup; g++){
200 if(groups[g].ContainsFrame(frames[f])){
201 State& state = groups[g].GetChildState(frames[f]);
204 m_Log <<
"Unable to get State associated with Group Frame: " << std::endl;
205 m_Log <<
" Frame:" << Log(frames[f]);
206 m_Log <<
" Group:" << Log(groups[g]) << LogEnd;
218 bool ReconstructionFrame::InitializeAnalysisRecursive(){
220 UnSoundBody(RF_FUNCTION);
221 return SetMind(
false);
224 if(!InitializeVisibleStates())
225 return SetMind(
false);
226 if(!InitializeGroupStates())
227 return SetMind(
false);
229 int Nchild = GetNChildren();
230 for(
int i = 0; i < Nchild; i++)
233 m_Log <<
"Unable to recursively initialize analysis for frame:";
235 return SetMind(
false);
238 return SetMind(
true);
241 bool ReconstructionFrame::ResetRecoFrame(){
245 bool ReconstructionFrame::ClearEventRecursive(){
247 UnSoundMind(RF_FUNCTION);
251 if(!ResetRecoFrame())
254 int Nf = GetNChildren();
255 for(
int i = 0; i < Nf; i++)
262 bool ReconstructionFrame::ReconstructFrame(){
264 UnSoundMind(RF_FUNCTION);
265 return SetSpirit(
false);
268 TLorentzVector Ptot(0,0,0,0);
270 int Nchild = GetNChildren();
271 for(
int i = 0; i < Nchild; i++){
274 TLorentzVector P = m_ChildStates[&child].GetFourVector();
276 SetChildBoostVector(child, P.BoostVector());
278 SetChildBoostVector(child, m_Empty3Vector);
281 child.SetFourVector(P,*
this);
283 if(child.IsVisibleFrame())
284 static_cast<VisibleRecoFrame&>(child).
285 SetCharge(m_ChildStates[&child].GetCharge());
288 if(IsLabFrame()) SetFourVector(Ptot,*
this);
290 return SetSpirit(
true);
293 bool ReconstructionFrame::AnalyzeEventRecursive(){
295 UnSoundMind(RF_FUNCTION);
296 return SetSpirit(
false);
298 if(!ReconstructFrame()){
300 m_Log <<
"Unable to reconstruct event for this frame.";
302 return SetSpirit(
false);
305 int Nchild = GetNChildren();
306 for(
int i = 0; i < Nchild; i++){
308 TVector3 boost = GetChildBoostVector(child);
310 bool terminal = child.IsVisibleFrame() || child.IsInvisibleFrame();
313 m_ChildStates[&child].Boost(boost);
316 if(!child.AnalyzeEventRecursive())
317 return SetSpirit(
false);
321 m_ChildStates[&child].Boost(boost);
325 return SetSpirit(
true);
virtual void Clear()
Clears ReconstructionFrame of all connections to other objects.
virtual void RemoveChildFrame(RestFrame &frame)
Remove a child of this frame.
virtual void AddChildFrame(RestFrame &frame)
Add a child RestFrame to this frame.
abstract base class for all Frame objects
virtual ReconstructionFrame & GetChildFrame(int i=0) const
Get the frame of the i th child.
void RemoveChildFrames()
Remove all the children of this frame.
virtual ReconstructionFrame const & GetParentFrame() const
Returns the parent of this frame.
virtual void SetParentFrame(RestFrame &frame=RestFrame::Empty())
Set the parent frame for this frame.