Changeset 2629 for trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
- Timestamp:
- 12/10/03 08:24:42 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r2599 r2629 50 50 #include "MPedestalCam.h" 51 51 52 #include "MGeomCamMagic.h" 53 52 54 ClassImp(MPedCalcPedRun); 53 55 … … 61 63 AddToBranchList("fHiGainPixId"); 62 64 AddToBranchList("fHiGainFadcSamples"); 65 66 fCounter=0; 63 67 } 64 68 … … 75 79 if (!fPedestals) 76 80 return kFALSE; 81 82 MGeomCamMagic magiccam; 83 84 fSumx.Set(magiccam.GetNumPixels()); 85 fSumx2.Set(magiccam.GetNumPixels()); 86 87 for(UInt_t i=0;i<magiccam.GetNumPixels();i++) 88 { 89 fSumx.AddAt(0,i); 90 fSumx2.AddAt(0,i); 91 } 77 92 78 93 return kTRUE; … … 110 125 while (pixel.Next()) 111 126 { 112 Byte_t *ptr = pixel.GetHiGainSamples(); 113 const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples(); 127 Byte_t shift=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? 0:1; 128 Byte_t *ptr = pixel.GetHiGainSamples(); 129 const Byte_t *end = ptr + fRawEvt->GetNumHiGainSamples()-shift; 114 130 115 131 const Float_t higainped = CalcHiGainMean(ptr, end); … … 118 134 const UInt_t pixid = pixel.GetPixelId(); 119 135 MPedestalPix &pix = (*fPedestals)[pixid]; 120 136 137 // cumulate the sum of pedestals and of pedestal squares 138 fSumx.AddAt(higainped+fSumx.At(pixid),pixid); 139 fSumx2.AddAt(GetSumx2(ptr, end)+fSumx2.At(pixid),pixid); 140 141 // set the value of the pedestal and rms computed from the processed event 121 142 pix.Set(higainped, higainrms); 122 123 } 143 } 144 145 146 fCounter++; 124 147 125 148 fPedestals->SetReadyToSave(); … … 128 151 } 129 152 153 Int_t MPedCalcPedRun::PostProcess() 154 { 155 // Compute pedestals and rms from the whole run 156 157 MRawEvtPixelIter pixel(fRawEvt); 158 159 while (pixel.Next()) 160 { 161 const UInt_t pixid = pixel.GetPixelId(); 162 MPedestalPix &pix = (*fPedestals)[pixid]; 163 164 const Int_t N = fCounter; 165 const Float_t sum = fSumx.At(pixid); 166 const Float_t sum2 = fSumx2.At(pixid); 167 const Float_t higainped = sum/N; 168 const Float_t higainrms = sqrt(1./(N-1.)*(sum2-sum*sum/N)); 169 pix.Set(higainped,higainrms); 170 171 } 172 return kTRUE; 173 174 } 175 176 130 177 Float_t MPedCalcPedRun::CalcHiGainMean(Byte_t *ptr, const Byte_t *end) const 131 178 { 132 179 Int_t sum=0; 180 Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1; 133 181 134 182 do sum += *ptr; 135 183 while (++ptr != end); 136 137 return (Float_t)sum/fNumHiGainSamples; 184 185 return (Float_t)sum/EvenNumSamples; 186 } 187 188 189 190 Float_t MPedCalcPedRun::GetSumx2(Byte_t *ptr, const Byte_t *end) const 191 { 192 Float_t square = 0; 193 194 // Take an even number of time slices to avoid biases due to A/B effect 195 Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1; 196 197 do 198 { 199 const Float_t val = (Float_t)(*ptr); 200 201 square += val*val; 202 } while (++ptr != end); 203 204 return square/EvenNumSamples; 138 205 } 139 206 … … 142 209 { 143 210 Float_t rms = 0; 211 Byte_t EvenNumSamples=(fNumHiGainSamples/2*2==fNumHiGainSamples) ? fNumHiGainSamples:fNumHiGainSamples-1; 144 212 145 213 do … … 150 218 } while (++ptr != end); 151 219 152 return sqrt(rms/fNumHiGainSamples); 153 } 220 return sqrt(rms/EvenNumSamples); 221 } 222 223 224 154 225 /* 155 226 Float_t MPedCalcPedRun::CalcHiGainMeanErr(Float_t higainrms) const
Note:
See TracChangeset
for help on using the changeset viewer.