1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 /// \class AliMUONNode
20 /// A node of a segment tree
22 /// For the details of the meaning of cardinality and potent data
23 /// members, please see Diane L. Souvaine and Iliana Bjorling-Sachs,
24 /// Proceedings of the IEEE, Vol. 80, No. 9, September 1992, p. 1449
27 /// \author Laurent Aphecetche, Subatech
29 #include "AliMUONNode.h"
32 #include "AliMUONSegment.h"
33 #include "Riostream.h"
35 #include "TObjArray.h"
42 //_____________________________________________________________________________
43 AliMUONNode::AliMUONNode(Double_t a, Double_t b, Double_t midpoint)
44 : fLeftNode(0x0), fRightNode(0x0), fMin(a), fMax(b), fMidPoint(midpoint), fC(0), fP(0)
49 //_____________________________________________________________________________
50 AliMUONNode::~AliMUONNode()
57 //_____________________________________________________________________________
59 AliMUONNode::Print(const char* opt) const
62 cout << opt << Form("[%7.2f,%7.2f]",fMin,fMax);
63 if ( !TMath::IsNaN(fMidPoint) ) cout << Form(" (%7.2f)",fMidPoint);
71 fLeftNode->Print(sopt.Data());
75 fRightNode->Print(sopt.Data());
79 //_____________________________________________________________________________
81 AliMUONNode::Contribution(Double_t b, Double_t e, TObjArray& stack)
83 /// Contribution of an edge (b,e) to the final contour
86 AliError(Form("fMax(%10.5f) < fMin(%10.5f",fMax,fMin));
91 if ( IsFullyContained(b,e) && fP == 0 )
93 AliMUONSegment* back = static_cast<AliMUONSegment*>(stack.Last());
95 if ( back && AliMUONSegment::AreEqual(back->EndY(),fMin) )
97 // merge to existing segment
98 Double_t y(back->StartY());
99 back->Set(0.0,y,0.0,fMax);
104 stack.Add(new AliMUONSegment(0.0,fMin,0.0,fMax));
111 fLeftNode->Contribution(b,e,stack);
115 fRightNode->Contribution(b,e,stack);
121 //_____________________________________________________________________________
123 AliMUONNode::IsFullyContained(Double_t b, Double_t e) const
125 /// Whether this node's interval is fully contained into [b,e]
127 return ( ( b < fMin || AliMUONSegment::AreEqual(b,fMin) ) && ( fMax < e || AliMUONSegment::AreEqual(e,fMax)) );
130 //_____________________________________________________________________________
132 AliMUONNode::InsertInterval(Double_t b, Double_t e, TObjArray& stack)
134 /// Insert an interval
135 if ( IsFullyContained(b,e) )
143 fLeftNode->InsertInterval(b,e,stack);
147 fRightNode->InsertInterval(b,e,stack);
153 //_____________________________________________________________________________
155 AliMUONNode::DeleteInterval(Double_t b, Double_t e, TObjArray& stack)
157 /// Delete an interval
158 if ( IsFullyContained(b,e) )
164 if ( fC > 0 ) Demote();
167 fLeftNode->DeleteInterval(b,e,stack);
172 fRightNode->DeleteInterval(b,e,stack);
178 //_____________________________________________________________________________
180 AliMUONNode::Update()
182 /// Update internal values
189 if (fLeftNode->C() > 0 && fRightNode->C() > 0 )
193 if (fLeftNode->C()==0 && fRightNode->C()==0 && fLeftNode->P()==0 && fRightNode->P()==0 )
204 //_____________________________________________________________________________
206 AliMUONNode::Promote()
214 //_____________________________________________________________________________
216 AliMUONNode::Demote()