00001 #include "CalibrationSmearer.h" 00002 00003 ClassImp(CalibrationSmearer) 00004 00005 CalibrationSmearer::CalibrationSmearer( Int_t size, TRandom* generator ) : 00006 fN(size), 00007 fValues(0) 00008 { 00009 TRandom* rand = generator; 00010 if(!rand) rand = gRandom; 00011 00012 fValues = new Float_t[size]; 00013 for(int i=0;i<size;i++) { 00014 fValues[i] = rand->Gaus(1.0); 00015 } 00016 00017 } 00018 00019 CalibrationSmearer:: ~CalibrationSmearer() 00020 { 00021 if(fValues) delete [] fValues; 00022 } 00023 00024 00025 // Return a single random posson number (0,inf) that is always the same for 00026 // a single value of KEY: 00027 Float_t CalibrationSmearer::GetGausSmear(Int_t key) const 00028 { 00029 return fValues[key%fN]; 00030 } 00031 00032 // Return a set of n random poisson numbers: 00033 const Float_t* CalibrationSmearer::GetGausSmears(Int_t key, Int_t n) const 00034 { 00035 return fValues + (key%(fN-n)); 00036 }
1.3.9.1