KaliVeda
Toolkit for HIC analysis
KVIDCutLine.cpp
1 /*
2 $Id: KVIDCutLine.cpp,v 1.2 2009/03/03 13:36:00 franklan Exp $
3 $Revision: 1.2 $
4 $Date: 2009/03/03 13:36:00 $
5 */
6 
7 //Created by KVClassFactory on Fri Feb 15 15:00:17 2008
8 //Author: franklan
9 
10 #include "KVIDCutLine.h"
11 #include "Riostream.h"
12 #include "KVIDGraph.h"
13 
14 using namespace std;
15 
16 ClassImp(KVIDCutLine)
17 
18 
19 
23 {
24  // Default constructor
25  SetTitle("cut line");
26 }
27 
28 
29 
32 
34 {
35  // Destructor
36 }
37 
38 
39 
50 
51 Bool_t KVIDCutLine::TestPoint(Double_t x, Double_t y)
52 {
53  // Test whether point \f$(x,y)\f$ is in the acceptable region defined
54  // by this cut line and the direction given to SetAcceptedDirection()
55  //
56  // e.g. if the accepted direction has been set to `left`,
57  // the point \f$(x,y)\f$ must be to the left of this line in
58  // order for this method to return kTRUE.
59  //
60  // If no accepted direction has been defined, the cut is inoperative (all points are accepted)
61  // and an error message is printed
62 
63  if(!IsAcceptedDirectionSet())
64  {
65  KVError::Error(this, "TestPoint(x,y)", "No accepted direction defined for cut %s in grid %s: all points accepted",
66  GetName(), GetParent()->GetName());
67  return true;
68  }
69  return WhereAmI(x, y, fAcceptedDirection.Data());
70 }
71 
72 
73 
76 
77 const Char_t* KVIDCutLine::GetSelectionType() const
78 {
79  // \return give name of selection made by cut
80  if(!IsAcceptedDirectionSet())
81  return "???";
82  return Form("accept %s", GetAcceptedDirection());
83 }
84 
85 
86 
87 
90 
91 void KVIDCutLine::WriteAsciiFile_extras(ofstream& file, const Char_t*)
92 {
93  // Write accepted direction for cut
94 
95  if (!IsAcceptedDirectionSet())
96  {
97  KVError::Error(this, "WriteAsciiFile_extras", "No accepted direction defined for cut %s in grid %s: all points accepted",
98  GetName(), GetParent()->GetName());
99  file << "[undefined accepted direction]" << endl;
100  }
101  else file << fAcceptedDirection.Data() << endl;
102 }
103 
104 
105 
106 
109 
110 void KVIDCutLine::ReadAsciiFile_extras(ifstream& file)
111 {
112  // Read accepted direction for cut
113 
114  fAcceptedDirection.ReadLine(file);
115  if (fAcceptedDirection == "[undefined accepted direction]")
116  {
117  fAcceptedDirection = "";
118  KVError::Error(this, "ReadAsciiFile_extras", "No accepted direction defined for cut %s in grid %s: all points accepted",
119  GetName(), GetParent() ? GetParent()->GetName() : "???");
120  }
121 }
122 
123 
124 
125 
126 
Line in ID grid used to delimit regions where no identification is possible.
Definition: KVIDCutLine.h:23
Bool_t TestPoint(Double_t x, Double_t y) override
Definition: KVIDCutLine.cpp:51
const Char_t * GetSelectionType() const override
Definition: KVIDCutLine.cpp:77
virtual ~KVIDCutLine()
Destructor.
Definition: KVIDCutLine.cpp:33
void Error(UserClass p, const char *location, const char *va_(fmt),...)
Definition: KVError.h:116