Changeset 9226
- Timestamp:
- 01/17/09 14:52:43 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MMath.cc
r9219 r9226 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.4 3 2009-01-14 12:31:36tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MMath.cc,v 1.44 2009-01-17 14:52:37 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 20 20 ! Author(s): Thomas Bretz 3/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 21 21 ! 22 ! Copyright: MAGIC Software Development, 2000-200 522 ! Copyright: MAGIC Software Development, 2000-2009 23 23 ! 24 24 ! … … 50 50 #ifndef ROOT_TComplex 51 51 #include <TComplex.h> 52 #endif 53 54 #ifndef ROOT_TRandom 55 #include <TRandom.h> // gRandom in RndmExp 52 56 #endif 53 57 … … 875 879 e = error.Atof(); 876 880 } 881 882 Double_t MMath::RndmExp(Double_t tau) 883 { 884 // returns an exponential deviate. 885 // 886 // exp( -t/tau ) 887 888 const Double_t x = gRandom->Rndm(); // uniform on ] 0, 1 ] 889 890 return -tau * TMath::Log(x); // convert to exponential distribution 891 } -
trunk/MagicSoft/Mars/mbase/MMath.h
r9219 r9226 87 87 88 88 void Format(Double_t &v, Double_t &e); 89 90 Double_t RndmExp(Double_t tau); 89 91 } 90 92 -
trunk/MagicSoft/Mars/mextralgo/ExtralgoIncl.h
r7942 r9226 1 1 #ifndef __CINT__ 2 2 3 #include "../mbase/MArrayF.h" 4 3 5 #endif // __CINT__ -
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.cc
r9212 r9226 18 18 ! Author(s): Markus Gaug 09/2004 <mailto:markus@ifae.es> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2002-200 820 ! Copyright: MAGIC Software Development, 2002-2009 21 21 ! 22 22 ! … … 120 120 // -------------------------------------------------------------------------- 121 121 // 122 // Returns the highest x value in [min;max[ at which the spline in123 // the bin i is equal to y124 // 125 // min and max are defined to be [0;1]126 // 127 // The default for min is 0, the default for max is 1128 // The defaule for y is 0129 // 130 Double_t MExtralgoSpline::FindY(Int_t i, Bool_t downwards, Double_t y, Double_t min, Double_t max) const122 // Solve the polynomial 123 // 124 // y = a*x^3 + b*x^2 + c*x + d' 125 // 0 = a*x^3 + b*x^2 + c*x + d' - y 126 // 127 // to find y in the i-th bin. Return the result as x1, x2, x3 and the return 128 // code from MMath::SolvPol3. 129 // 130 Int_t MExtralgoSpline::SolvePol3(Int_t i, Double_t y, Double_t &x1, Double_t &x2, Double_t &x3) const 131 131 { 132 132 // y = a*x^3 + b*x^2 + c*x + d' … … 145 145 // return -2; 146 146 147 return MMath::SolvePol3(a, b, c, d, x1, x2, x3); 148 } 149 150 // -------------------------------------------------------------------------- 151 // 152 // Returns the highest x value in [min;max[ at which the spline in 153 // the bin i is equal to y 154 // 155 // min and max must be in the range [0;1] 156 // 157 // The default for min is 0, the default for max is 1 158 // The default for y is 0 159 // 160 Double_t MExtralgoSpline::FindYdn(Int_t i, Double_t y, Double_t min, Double_t max) const 161 { 147 162 Double_t x1, x2, x3; 148 const Int_t rc = MMath::SolvePol3(a, b, c, d, x1, x2, x3); 149 150 if (downwards==kTRUE) 151 { 152 Double_t x = -1; 153 154 if (rc>0 && x1>=min && x1<max && x1>x) 155 x = x1; 156 if (rc>1 && x2>=min && x2<max && x2>x) 157 x = x2; 158 if (rc>2 && x3>=min && x3<max && x3>x) 159 x = x3; 160 161 return x<0 ? -2 : x+i; 162 } 163 else 164 { 165 Double_t x = 2; 166 167 if (rc>0 && x1>min && x1<=max && x1<x) 168 x = x1; 169 if (rc>1 && x2>min && x2<=max && x2<x) 170 x = x2; 171 if (rc>2 && x3>min && x3<=max && x3<x) 172 x = x3; 173 174 return x>1 ? -2 : x+i; 175 } 176 177 return -2; 163 const Int_t rc = SolvePol3(i, y, x1, x2, x3); 164 165 Double_t x = -1; 166 167 if (rc>0 && x1>=min && x1<max && x1>x) 168 x = x1; 169 if (rc>1 && x2>=min && x2<max && x2>x) 170 x = x2; 171 if (rc>2 && x3>=min && x3<max && x3>x) 172 x = x3; 173 174 return x<0 ? -2 : x+i; 175 } 176 177 // -------------------------------------------------------------------------- 178 // 179 // Returns the lowest x value in [min;max[ at which the spline in 180 // the bin i is equal to y 181 // 182 // min and max must be in the range [0;1] 183 // 184 // The default for min is 0, the default for max is 1 185 // The default for y is 0 186 // 187 Double_t MExtralgoSpline::FindYup(Int_t i, Double_t y, Double_t min, Double_t max) const 188 { 189 Double_t x1, x2, x3; 190 const Int_t rc = SolvePol3(i, y, x1, x2, x3); 191 192 Double_t x = 2; 193 194 if (rc>0 && x1>min && x1<=max && x1<x) 195 x = x1; 196 if (rc>1 && x2>min && x2<=max && x2<x) 197 x = x2; 198 if (rc>2 && x3>min && x3<=max && x3<x) 199 x = x3; 200 201 return x>1 ? -2 : x+i; 178 202 } 179 203 … … 181 205 // 182 206 // Search analytically downward for the value y of the spline, starting 183 // at x, until x==0. If y is not found -2 is returned.207 // at x, until x==0. If y is not found or out of range -2 is returned. 184 208 // 185 209 Double_t MExtralgoSpline::SearchYdn(Float_t x, Float_t y) const … … 192 216 return -2; 193 217 194 Double_t rc = FindY (i, kTRUE, y, 0, x-i);218 Double_t rc = FindYdn(i, y, 0, x-i); 195 219 while (--i>=0 && rc<0) 196 rc = FindY (i, kTRUE, y);220 rc = FindYdn(i, y); 197 221 198 222 return rc; 199 223 } 200 224 225 // -------------------------------------------------------------------------- 226 // 227 // Search analytically upwards for the value y of the spline, starting 228 // at x, until x==fNum-1. If y is not found or out of range -2 is returned. 229 // 201 230 Double_t MExtralgoSpline::SearchYup(Float_t x, Float_t y) const 202 231 { … … 208 237 return -2; 209 238 210 Double_t rc = FindY (i, kFALSE, y, x-i, 1.);239 Double_t rc = FindYup(i, y, x-i, 1.); 211 240 while (++i<fNum-1 && rc<0) 212 rc = FindY (i, kFALSE, y);241 rc = FindYup(i, y); 213 242 214 243 return rc; … … 222 251 Float_t MExtralgoSpline::CalcIntegral(Float_t pos) const 223 252 { 224 // In the future we will calculate the intgeral analytically.225 // It has been tested that it gives identical results within226 // acceptable differences.227 228 253 // We allow extrapolation of 1/2 slice. 229 254 const Float_t min = fRiseTime; //-0.5+fRiseTime; … … 236 261 237 262 return EvalInteg(pos-fRiseTime, pos+fFallTime); 263 } 264 265 MArrayF MExtralgoSpline::GetIntegral(bool norm) const 266 { 267 MArrayF val(fNum); 268 269 //val[0] = 0; 270 271 Double_t integ = 0; 272 for (int i=0; i<fNum-1; i++) 273 { 274 integ += EvalInteg(i); 275 276 val[i+1] = integ; 277 } 278 279 if (norm) 280 for (int i=0; i<fNum-1; i++) 281 val[i+1] /= val[fNum-1]; 282 283 return val; 238 284 } 239 285 -
trunk/MagicSoft/Mars/mextralgo/MExtralgoSpline.h
r9212 r9226 6 6 #endif 7 7 8 class MArrayF; 8 9 class TComplex; 9 10 … … 75 76 } 76 77 77 Double_t FindY(Int_t i, Bool_t downwards, Double_t y=0, Double_t min=0, Double_t max=1) const; 78 Int_t SolvePol3(Int_t i, Double_t y, Double_t &x1, Double_t &x2, Double_t &x3) const; 79 Double_t FindYdn(Int_t i, Double_t y=0, Double_t min=0, Double_t max=1) const; 80 Double_t FindYup(Int_t i, Double_t y=0, Double_t min=0, Double_t max=1) const; 81 //Double_t FindY(Int_t i, Bool_t downwards, Double_t y=0, Double_t min=0, Double_t max=1) const; 78 82 79 83 Int_t EvalDerivEq0(const Int_t i, Double_t &x1, Double_t &x2) const; … … 153 157 } 154 158 155 // Identical to sum EvalInteg(i, 0, 1) for i=0 to i<b but much faster 159 // Identical to sum of EvalInteg(i, 0, 1) for i=a to i=b-1, 160 // but much faster 161 // It is identical to EvalInteg(fVal[a], fVal[b]) 156 162 // Be carefull: NO RANGECHECK! 157 163 inline Double_t EvalInteg(Int_t a, Int_t b) const … … 329 335 Double_t SearchYdn(Float_t y) const { return SearchYdn(fNum, y); } 330 336 Double_t SearchYup(Float_t y) const { return SearchYup(0, y); } 337 338 MArrayF GetIntegral(bool norm=true) const; 331 339 }; 332 340 -
trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.cc
r8565 r9226 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1. 6 2007-06-16 22:08:00tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MPedestalSubtractedEvt.cc,v 1.7 2009-01-17 14:52:41 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 32 32 // 33 33 ///////////////////////////////////////////////////////////////////////////// 34 35 34 #include "MPedestalSubtractedEvt.h" 35 36 #include "MLogManip.h" 36 37 37 38 ClassImp(MPedestalSubtractedEvt); … … 185 186 } 186 187 188 void MPedestalSubtractedEvt::Print(Option_t *o) const 189 { 190 *fLog << all << GetDescriptor() << endl; 191 *fLog << " Num Pixels: " << fNumPixels << " (" << fNumSamples << " samples)" << endl; 192 *fLog << " Samples raw:" << hex << endl;; 193 for (UInt_t idx=0; idx<fNumPixels; idx++) 194 { 195 *fLog << setw(4) << dec << idx << hex << ":"; 196 for (UInt_t i=0; i<fNumSamples; i++) 197 *fLog << " " << fSamplesRaw[idx*fNumSamples+i]; 198 *fLog << endl; 199 } 200 *fLog << dec << endl; 201 *fLog << " Samples:" << endl;; 202 for (UInt_t idx=0; idx<fNumPixels; idx++) 203 { 204 *fLog << setw(4) << idx << ":"; 205 for (UInt_t i=0; i<fNumSamples; i++) 206 *fLog << " " << fSamples[idx*fNumSamples+i]; 207 *fLog << endl; 208 } 209 *fLog << endl; 210 } 211 187 212 /* 188 213 #include <TSpline.h> -
trunk/MagicSoft/Mars/mpedestal/MPedestalSubtractedEvt.h
r8571 r9226 20 20 { 21 21 private: 22 MArrayF fSamples; // list of all samples with pedestal subtracted23 MArrayS fSamplesRaw; // list of all samples (raw)22 MArrayF fSamples; // list of all samples with pedestal subtracted 23 MArrayS fSamplesRaw; // list of all samples (raw) 24 24 25 UInt_t fNumSamples; // number of samples per pixel26 UInt_t fNumPixels; // number of pixels25 UInt_t fNumSamples; // number of samples per pixel 26 UInt_t fNumPixels; // number of pixels 27 27 28 28 public: … … 114 114 } 115 115 116 void Print(Option_t *o="") const; 117 116 118 Bool_t GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type=0) const { return kTRUE; } 117 119 void DrawPixelContent(Int_t num) const { } -
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r9212 r9226 284 284 name += pix.GetPixelId(); 285 285 286 286 287 Bool_t same = str.Contains("same"); 287 288 … … 392 393 } 393 394 395 void MRawEvtData::ResetPixels() 396 { 397 if (!fRunHeader) 398 return; 399 400 // FIXME: Better give NumNormalPixels if numconnected==0 ? 401 402 ResetPixels(fRunHeader->GetNumNormalPixels(), fRunHeader->GetNumNormalPixels()-1); 403 } 404 394 405 // -------------------------------------------------------------------------- 395 406 // … … 435 446 void MRawEvtData::Set(const MArrayI &data) 436 447 { 437 const UInt_t n = fRunHeader->GetNumSamples()*fConnectedPixels; 448 fConnectedPixels = fHiGainPixId->GetSize(); 449 450 UInt_t n = fConnectedPixels*fRunHeader->GetNumSamplesHiGain(); 451 if (n!=data.GetSize()) 452 { 453 *fLog << err << "MRawEvtData::Set: Size mismatch." << endl; 454 *fLog << " fConnectedPixels=" << fConnectedPixels << endl; 455 *fLog << " NumHiGainSamples=" << fRunHeader->GetNumSamplesHiGain() << endl; 456 *fLog << " data.GetSize()=" << data.GetSize() << endl; 457 return; 458 } 438 459 439 460 Byte_t *dest = fHiGainFadcSamples->GetArray(); … … 448 469 Byte_t *ptr = reinterpret_cast<Byte_t*>(dest); 449 470 while (src<end) 450 *ptr++ = *src++;471 *ptr++ = Byte_t(*src++); 451 472 } 452 473 return; … … 456 477 UShort_t *ptr = reinterpret_cast<UShort_t*>(dest); 457 478 while (src<end) 458 *ptr++ = *src++;479 *ptr++ = UShort_t(*src++); 459 480 } 460 481 return; … … 464 485 return; 465 486 } 487 } 488 489 void MRawEvtData::SetIndices(const MArrayS &idx) 490 { 491 if (idx.GetSize()!=fHiGainPixId->GetSize()) 492 return; 493 494 memcpy(fHiGainPixId->GetArray(), idx.GetArray(), idx.GetSize()*sizeof(UShort_t)); 495 } 496 497 void MRawEvtData::SetIndices() 498 { 499 for (UInt_t i=0; i<fHiGainPixId->GetSize(); i++) 500 (*fHiGainPixId)[i] = i; 466 501 } 467 502 -
trunk/MagicSoft/Mars/mraw/MRawEvtData.h
r9212 r9226 57 57 } 58 58 59 59 60 public: 60 61 MRawEvtData(const char *name=NULL, const char *title=NULL); … … 74 75 void Draw (Option_t * = NULL); 75 76 77 void ResetPixels(); 76 78 void ResetPixels(UShort_t npix, UShort_t maxid); 77 79 void AddPixel(UShort_t nOfPixel, const TArrayC &data); 78 80 void Set(const MArrayI &data); 81 void SetIndices(const MArrayS &idx); 82 void SetIndices(); 79 83 80 84 UShort_t GetNumHiGainSamples() const;
Note:
See TracChangeset
for help on using the changeset viewer.