Changeset 1802 for trunk/MagicSoft/Cosy/caos
- Timestamp:
- 03/02/03 16:55:47 (22 years ago)
- Location:
- trunk/MagicSoft/Cosy/caos
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Cosy/caos/Led.cc
r1798 r1802 1 1 #include "Led.h" 2 2 3 #include <iostream.h> 3 4 #include <TMath.h> 4 5 … … 11 12 fPhi = TMath::ATan2(fY-ring.GetY(), fX-ring.GetX())*180/TMath::Pi(); 12 13 } 14 15 void Led::Print(Option_t *o=NULL) const 16 { 17 cout << "Led: "; 18 cout << "x=" << fX << "+-" << fDx << ", "; 19 cout << "y=" << fY << "+-" << fDy << ", "; 20 cout << "phi=" << fPhi << "+-" << fDphi << ", "; 21 cout << "mag=" << fMag << endl; 22 } -
trunk/MagicSoft/Cosy/caos/Led.h
r1798 r1802 27 27 } 28 28 29 Double_t GetX() const { return fX; } 30 Double_t GetY() const { return fY; } 31 Double_t GetDx() const { return fDx; } 32 Double_t GetDy() const { return fDy; } 33 Double_t GetMag() const { return fMag; } 29 Int_t Compare(const TObject *obj) const 30 { 31 const Led *const l = (Led*)obj; 32 33 if (fPhi<l->fPhi) 34 return -1; 35 36 if (fPhi>l->fPhi) 37 return 1; 38 39 return 0; 40 } 41 42 Double_t GetX() const { return fX; } 43 Double_t GetY() const { return fY; } 44 Double_t GetDx() const { return fDx; } 45 Double_t GetDy() const { return fDy; } 46 Double_t GetPhi() const { return fPhi; } 47 Double_t GetDphi() const { return fDphi; } 48 Double_t GetMag() const { return fMag; } 49 50 Bool_t IsSortable() const { return kTRUE; } 34 51 35 52 void CalcPhi(const Ring &ring); 53 54 void Print(Option_t *o=NULL) const; 36 55 37 56 ClassDef(Led, 1) -
trunk/MagicSoft/Cosy/caos/Leds.cc
r1798 r1802 1 1 #include "Leds.h" 2 3 #include <iostream.h> 2 4 3 5 #include "Led.h" … … 9 11 new ((*this)[i]) Led(x, y, dx, dy, mag); 10 12 } 13 14 void Leds::Print(Option_t *o=NULL) const 15 { 16 cout << "Number of Leds: " << GetEntries() << endl; 17 TClonesArray::Print(); 18 } -
trunk/MagicSoft/Cosy/caos/Leds.h
r1798 r1802 10 10 class Leds : public TClonesArray 11 11 { 12 private:13 12 public: 14 13 Leds() : TClonesArray("Led", 1) {} … … 27 26 Led &operator()(int i) { return *(Led*)((*(Leds*)this)[i]); } 28 27 28 void Print(Option_t *o=NULL) const; 29 29 30 ClassDef(Leds, 1) 30 31 }; -
trunk/MagicSoft/Cosy/caos/Ring.cc
r1798 r1802 20 20 if (h1==0) 21 21 { 22 23 22 cout << "h1==0" <<endl; 23 return kFALSE; 24 24 } 25 25 } … … 38 38 } 39 39 40 Float_t w1 = leds(i).GetX() - leds(j).GetX();41 Float_t w2 = leds(j).GetX() - leds(k).GetX();40 const Float_t w1 = leds(i).GetX() - leds(j).GetX(); 41 const Float_t w2 = leds(j).GetX() - leds(k).GetX(); 42 42 43 Float_t m1 = -w1/h1;44 Float_t m2 = -w2/h2;43 const Float_t m1 = -w1/h1; 44 const Float_t m2 = -w2/h2; 45 45 46 46 if (m2-m1==0) 47 47 { 48 cout << " m2-m1==0" << endl;48 cout << "All three points in a row! (m2-m1==0)" << endl; 49 49 return kFALSE; 50 50 } … … 66 66 fR = 0; 67 67 68 fDx=0; 69 fDy=0; 70 fDr=0; 71 72 if (n<1) 73 return; 74 68 75 for (int i=0; i<n; i++) 69 76 { 70 const Ring &ring = *(Ring*)((Rings&)rings)[i];77 const Ring &ring = rings(i); 71 78 72 79 fX += ring.GetX(); … … 79 86 fR /= n; 80 87 88 if (n<2) 89 return; 90 81 91 // 82 92 // deviation of x- and y coordinate and radius 83 93 // 84 Float_t sumx=0;85 Float_t sumy=0;86 Float_t sumr=0;87 88 94 for (int i=0; i<n; i++) 89 95 { 90 const Ring &ring = *(Ring*)((Rings&)rings)[i];96 const Ring &ring = rings(i); 91 97 92 sumx += sqr(ring.GetX()-fX);93 sumy += sqr(ring.GetY()-fY);94 sumr += sqr(ring.GetR()-fR);98 fDx += sqr(ring.GetX()-fX); 99 fDy += sqr(ring.GetY()-fY); 100 fDr += sqr(ring.GetR()-fR); 95 101 } 96 102 97 fDx=sqrt(sumx)/(n-1); 98 fDy=sqrt(sumy)/(n-1); 99 fDr=sqrt(sumr)/(n-1); 100 103 fDx=sqrt(fDx)/(n-1); 104 fDy=sqrt(fDy)/(n-1); 105 fDr=sqrt(fDr)/(n-1); 101 106 } 102 107 108 void Ring::Print(Option_t *o=NULL) const 109 { 110 cout << "Ring: "; 111 cout << "x=" << fX << "+-" << fDx << ", "; 112 cout << "y=" << fY << "+-" << fDy << ", "; 113 cout << "r=" << fR << "+-" << fDr << ", "; 114 cout << "phi=" << fPhi << "+-" << fDphi << endl; 115 } 116 -
trunk/MagicSoft/Cosy/caos/Ring.h
r1798 r1802 41 41 void InterpolCenters(const Rings &rings); 42 42 43 void Print(Option_t *o=NULL) const; 44 43 45 ClassDef(Ring, 1) 44 46 }; -
trunk/MagicSoft/Cosy/caos/Rings.cc
r1798 r1802 1 1 #include "Rings.h" 2 3 #include <iostream.h> 2 4 3 5 #include "Led.h" … … 6 8 ClassImp(Rings); 7 9 8 Int_tRings::CalcCenters(const Leds &leds)10 void Rings::CalcCenters(const Leds &leds) 9 11 { 10 12 int nPoints = leds.GetEntries(); … … 15 17 for (int k=j+1; k<nPoints; k++) 16 18 { 17 Ring &ring = * (Ring*)(*this)[n];19 Ring &ring = *new ((*this)[n]) Ring; 18 20 19 ring.CalcCenter(leds, i, j, k); 21 if (!ring.CalcCenter(leds, i, j, k)) 22 { 23 RemoveAt(n); 24 continue; 25 } 20 26 21 27 n++; 22 28 } 23 return n; 29 30 Expand(n); 24 31 } 25 32 … … 31 38 32 39 // 33 // angles v and relative angle w40 // angles v 34 41 // 35 for (int j=0; j<leds.GetEntries(); j++) 42 const int n=leds.GetEntries(); 43 44 for (int j=0; j<n; j++) 36 45 leds(j).CalcPhi(fCenter); 37 46 } 47 48 void Rings::Print(Option_t *o=NULL) const 49 { 50 cout << "Number of Rings: " << GetEntries() << endl; 51 TClonesArray::Print(); 52 cout << "Center: " << endl; 53 fCenter.Print(); 54 } -
trunk/MagicSoft/Cosy/caos/Rings.h
r1798 r1802 17 17 Ring fCenter; 18 18 19 Int_tCalcCenters(const Leds &leds);19 void CalcCenters(const Leds &leds); 20 20 21 21 public: 22 22 Rings() : TClonesArray("Ring", 1) {} 23 23 24 //25 // rings.CalcRings(leds);26 //27 24 void CalcRings(Leds &leds); 25 26 void Print(Option_t *o=NULL) const; 27 28 const Ring &operator()(int i) const { return *(Ring*)((*(Rings*)this)[i]); } 29 Ring &operator()(int i) { return *(Ring*)((*(Rings*)this)[i]); } 30 31 const Ring &GetCenter() const { return fCenter; } 28 32 29 33 ClassDef(Rings, 1)
Note:
See TracChangeset
for help on using the changeset viewer.