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"
44 //_____________________________________________________________________________
45 AliMUONNode::AliMUONNode(Double_t a, Double_t b, Double_t midpoint)
46 : fLeftNode(0x0), fRightNode(0x0), fMin(a), fMax(b), fMidPoint(midpoint), fC(0), fP(0)
51 //_____________________________________________________________________________
52 AliMUONNode::~AliMUONNode()
59 //_____________________________________________________________________________
61 AliMUONNode::Print(const char* opt) const
64 cout << opt << Form("[%7.2f,%7.2f]",fMin,fMax);
65 if ( !TMath::IsNaN(fMidPoint) ) cout << Form(" (%7.2f)",fMidPoint);
73 fLeftNode->Print(sopt.Data());
77 fRightNode->Print(sopt.Data());
81 //_____________________________________________________________________________
83 AliMUONNode::Contribution(Double_t b, Double_t e, TObjArray& stack)
85 /// Contribution of an edge (b,e) to the final contour
88 AliError(Form("fMax(%10.5f) < fMin(%10.5f",fMax,fMin));
93 if ( IsFullyContained(b,e) && fP == 0 )
95 AliMUONSegment* back = static_cast<AliMUONSegment*>(stack.Last());
97 if ( back && AliMUONSegment::AreEqual(back->EndY(),fMin) )
99 // merge to existing segment
100 Double_t y(back->StartY());
101 back->Set(0.0,y,0.0,fMax);
106 stack.Add(new AliMUONSegment(0.0,fMin,0.0,fMax));
113 fLeftNode->Contribution(b,e,stack);
117 fRightNode->Contribution(b,e,stack);
123 //_____________________________________________________________________________
125 AliMUONNode::IsFullyContained(Double_t b, Double_t e) const
127 /// Whether this node's interval is fully contained into [b,e]
129 return ( ( b < fMin || AliMUONSegment::AreEqual(b,fMin) ) && ( fMax < e || AliMUONSegment::AreEqual(e,fMax)) );
132 //_____________________________________________________________________________
134 AliMUONNode::InsertInterval(Double_t b, Double_t e, TObjArray& stack)
136 /// Insert an interval
137 if ( IsFullyContained(b,e) )
145 fLeftNode->InsertInterval(b,e,stack);
149 fRightNode->InsertInterval(b,e,stack);
155 //_____________________________________________________________________________
157 AliMUONNode::DeleteInterval(Double_t b, Double_t e, TObjArray& stack)
159 /// Delete an interval
160 if ( IsFullyContained(b,e) )
166 if ( fC > 0 ) Demote();
169 fLeftNode->DeleteInterval(b,e,stack);
174 fRightNode->DeleteInterval(b,e,stack);
180 //_____________________________________________________________________________
182 AliMUONNode::Update()
184 /// Update internal values
191 if (fLeftNode->C() > 0 && fRightNode->C() > 0 )
195 if (fLeftNode->C()==0 && fRightNode->C()==0 && fLeftNode->P()==0 && fRightNode->P()==0 )
206 //_____________________________________________________________________________
208 AliMUONNode::Promote()
216 //_____________________________________________________________________________
218 AliMUONNode::Demote()