Changeset 3701 for trunk/MagicSoft
- Timestamp:
- 04/09/04 19:17:17 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r3700 r3701 38 38 39 39 * manalysis/MPedestalCam.[h,cc] 40 * manalysis/MPedCalcPedRun.[h,cc] 40 41 * manalysis/MGeomApply.cc 41 42 - added average pixels in the way like it is done in MCalibrationCam -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.cc
r3374 r3701 96 96 #include "MExtractedSignalCam.h" 97 97 98 #include "MGeomPix.h" 99 #include "MGeomCam.h" 98 100 99 101 #include "MGeomCamMagic.h" … … 142 144 Int_t MPedCalcPedRun::PreProcess( MParList *pList ) 143 145 { 144 Clear(); 145 146 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData"); 147 if (!fRawEvt) 148 { 149 *fLog << err << "MRawEvtData not found... aborting." << endl; 150 return kFALSE; 151 } 152 153 fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam"); 154 if (!fPedestals) 155 return kFALSE; 156 157 return kTRUE; 146 147 Clear(); 148 149 fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData"); 150 if (!fRawEvt) 151 { 152 *fLog << err << "MRawEvtData not found... aborting." << endl; 153 return kFALSE; 154 } 155 156 fGeom = (MGeomCam*)pList->FindObject("MGeomCam"); 157 if (!fGeom) 158 { 159 *fLog << err << "MGeomCam not found... aborting." << endl; 160 return kFALSE; 161 } 162 163 fPedestals = (MPedestalCam*)pList->FindCreateObj("MPedestalCam"); 164 if (!fPedestals) 165 return kFALSE; 166 167 return kTRUE; 158 168 } 159 169 … … 175 185 } 176 186 else 177 if (runheader->IsMonteCarloRun()) 178 return kTRUE; 179 180 Int_t n = fPedestals->GetSize(); 187 if (runheader->IsMonteCarloRun()) 188 return kTRUE; 189 190 Int_t npixels = fPedestals->GetSize(); 191 Int_t areas = fPedestals->GetAverageAreas(); 192 Int_t sectors = fPedestals->GetAverageSectors(); 181 193 182 194 if (fSumx.GetSize()==0) 183 195 { 184 fSumx.Set(n); 185 fSumx2.Set(n); 196 fSumx. Set(npixels); 197 fSumx2.Set(npixels); 198 199 fAreaSumx. Set(areas); 200 fAreaSumx2.Set(areas); 201 fAreaValid.Set(areas); 202 203 fSectorSumx. Set(sectors); 204 fSectorSumx2.Set(sectors); 205 fSectorValid.Set(sectors); 186 206 187 207 fSumx.Reset(); … … 204 224 Int_t MPedCalcPedRun::Process() 205 225 { 206 MRawEvtPixelIter pixel(fRawEvt); 207 208 while (pixel.Next()) 209 { 210 Byte_t *ptr = pixel.GetHiGainSamples(); 211 const Byte_t *end = ptr + fNumHiGainSamples; 212 213 UInt_t sum = 0; 214 UInt_t sqr = 0; 226 227 MRawEvtPixelIter pixel(fRawEvt); 228 229 while (pixel.Next()) 230 { 231 232 const UInt_t idx = pixel.GetPixelId(); 233 const UInt_t aidx = (*fGeom)[idx].GetAidx(); 234 const UInt_t sector = (*fGeom)[idx].GetSector(); 235 236 Byte_t *ptr = pixel.GetHiGainSamples(); 237 const Byte_t *end = ptr + fNumHiGainSamples; 238 239 UInt_t sum = 0; 240 UInt_t sqr = 0; 215 241 216 do 217 { 218 sum += *ptr; 219 sqr += *ptr * *ptr; 220 } 221 while (++ptr != end); 222 223 const Float_t msum = (Float_t)sum; 224 225 const UInt_t idx = pixel.GetPixelId(); 226 // 227 // These three lines have been uncommented by Markus Gaug 228 // If anybody needs them, please contact me!! 229 // 230 // const Float_t higainped = msum/fNumHiGainSamples; 231 // const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSamples)/(fNumHiGainSamples-1.)); 232 // (*fPedestals)[idx].Set(higainped, higainrms); 233 234 fSumx[idx] += msum; 235 // 236 // The old version: 237 // 238 // const Float_t msqr = (Float_t)sqr; 239 // fSumx2[idx] += msqr; 240 // 241 // The new version: 242 // 243 fSumx2[idx] += msum*msum; 244 245 } 246 247 fPedestals->SetReadyToSave(); 248 fNumSamplesTot += fNumHiGainSamples; 249 250 251 return kTRUE; 242 do 243 { 244 sum += *ptr; 245 sqr += *ptr * *ptr; 246 } 247 while (++ptr != end); 248 249 const Float_t msum = (Float_t)sum; 250 251 // 252 // These three lines have been uncommented by Markus Gaug 253 // If anybody needs them, please contact me!! 254 // 255 // const Float_t higainped = msum/fNumHiGainSamples; 256 // const Float_t higainrms = TMath::Sqrt((msqr-msum*msum/fNumHiGainSamples)/(fNumHiGainSamples-1.)); 257 // (*fPedestals)[idx].Set(higainped, higainrms); 258 259 fSumx[idx] += msum; 260 fAreaSumx[aidx] += msum; 261 fSectorSumx[sector] += msum; 262 // 263 // The old version: 264 // 265 // const Float_t msqr = (Float_t)sqr; 266 // fSumx2[idx] += msqr; 267 // 268 // The new version: 269 // 270 const Float_t sqrsum = msum*msum; 271 fSumx2[idx] += sqrsum; 272 fAreaSumx2[aidx] += sqrsum; 273 fSectorSumx2[sector] += sqrsum; 274 } 275 276 fPedestals->SetReadyToSave(); 277 fNumSamplesTot += fNumHiGainSamples; 278 279 280 return kTRUE; 252 281 } 253 282 … … 267 296 while (pixel.Next()) 268 297 { 269 const Int_t pixid = pixel.GetPixelId(); 270 298 299 const Int_t pixid = pixel.GetPixelId(); 300 const UInt_t aidx = (*fGeom)[pixid].GetAidx(); 301 const UInt_t sector = (*fGeom)[pixid].GetSector(); 302 303 fAreaValid [aidx]++; 304 fSectorValid[sector]++; 305 271 306 const Float_t sum = fSumx.At(pixid); 272 307 const Float_t sum2 = fSumx2.At(pixid); … … 290 325 291 326 } 327 328 // 329 // Loop over the (two) area indices to get the averaged pedestal per aidx 330 // 331 for (Int_t aidx=0; aidx<fAreaValid.GetSize(); aidx++) 332 { 333 334 const Int_t napix = fAreaValid.At(aidx); 335 const Float_t sum = fAreaSumx.At(aidx); 336 const Float_t sum2 = fAreaSumx2.At(aidx); 337 const ULong_t an = napix * n; 338 const ULong_t aevts = napix * nevts; 339 340 const Float_t higainped = sum/an; 341 342 // 1. Calculate the Variance of the sums: 343 Float_t higainVar = (sum2-sum*sum/aevts)/(aevts-1.); 344 // 2. Scale the variance to the number of slices: 345 higainVar /= (Float_t)fNumHiGainSamples; 346 // 3. Calculate the RMS from the Variance: 347 Float_t higainrms = TMath::Sqrt(higainVar); 348 // 4. Re-scale it with the square root of the number of involved pixels 349 // in order to be comparable to the mean of pedRMS of that area 350 higainrms *= TMath::Sqrt((Float_t)napix); 351 352 fPedestals->GetAverageArea(aidx).Set(higainped, higainrms); 353 } 354 355 // 356 // Loop over the (six) sector indices to get the averaged pedestal per sector 357 // 358 for (Int_t sector=0; sector<fSectorValid.GetSize(); sector++) 359 { 360 361 const Int_t nspix = fSectorValid.At(sector); 362 const Float_t sum = fSectorSumx.At(sector); 363 const Float_t sum2 = fSectorSumx2.At(sector); 364 const ULong_t sn = nspix * n; 365 const ULong_t sevts = nspix * nevts; 366 367 const Float_t higainped = sum/sn; 368 369 // 1. Calculate the Variance of the sums: 370 Float_t higainVar = (sum2-sum*sum/sevts)/(sevts-1.); 371 // 2. Scale the variance to the number of slices: 372 higainVar /= (Float_t)fNumHiGainSamples; 373 // 3. Calculate the RMS from the Variance: 374 Float_t higainrms = TMath::Sqrt(higainVar); 375 // 4. Re-scale it with the square root of the number of involved pixels 376 // in order to be comparable to the mean of pedRMS of that sector 377 higainrms *= TMath::Sqrt((Float_t)nspix); 378 379 fPedestals->GetAverageSector(sector).Set(higainped, higainrms); 380 } 292 381 293 382 fPedestals->SetTotalEntries(fNumSamplesTot); -
trunk/MagicSoft/Mars/manalysis/MPedCalcPedRun.h
r3199 r3701 10 10 #endif 11 11 12 #ifndef ROOT_TArrayI 13 #include <TArrayI.h> 14 #endif 15 12 16 class MRawEvtData; 13 17 class MPedestalCam; 14 18 class MGeomCam; 15 19 class MPedCalcPedRun : public MTask 16 20 { 17 Byte_t fNumHiGainSamples;18 UInt_t fNumSamplesTot;19 21 20 MRawEvtData *fRawEvt; // raw event data (time slices) 21 MPedestalCam *fPedestals; // Pedestals of all pixels in the camera 22 Byte_t fNumHiGainSamples; 23 UInt_t fNumSamplesTot; 24 25 MRawEvtData *fRawEvt; // raw event data (time slices) 26 MPedestalCam *fPedestals; // Pedestals of all pixels in the camera 27 MGeomCam *fGeom; // Camera geometry 28 29 TArrayF fSumx; // sum of values 30 TArrayF fSumx2; // sum of squared values 31 TArrayF fAreaSumx; // averaged sum of values per area idx 32 TArrayF fAreaSumx2; // averaged sum of squared values per area idx 33 TArrayI fAreaValid; // number of valid pixel with area idx 34 TArrayF fSectorSumx; // averaged sum of values per sector 35 TArrayF fSectorSumx2; // averaged sum of squared values per sector 36 TArrayI fSectorValid; // number of valid pixel with sector idx 37 38 Int_t PreProcess ( MParList *pList ); 39 Bool_t ReInit ( MParList *pList ); 40 Int_t Process (); 41 Int_t PostProcess(); 42 43 public: 22 44 23 TArrayF fSumx; // sum of values 24 TArrayF fSumx2; // sum of squared values 25 26 Bool_t ReInit(MParList *pList); 27 28 Int_t PreProcess(MParList *pList); 29 Int_t Process(); 30 Int_t PostProcess(); 31 32 public: 33 MPedCalcPedRun(const char *name=NULL, const char *title=NULL); 34 35 void Clear(const Option_t *o=""); 36 void SetNumHiGainSamples(const Byte_t n) { fNumHiGainSamples = n; } 37 38 ClassDef(MPedCalcPedRun, 0) // Task to calculate pedestals from pedestal runs raw data 45 MPedCalcPedRun(const char *name=NULL, const char *title=NULL); 46 47 void Clear(const Option_t *o=""); 48 void SetNumHiGainSamples(const Byte_t n) { fNumHiGainSamples = n; } 49 50 ClassDef(MPedCalcPedRun, 0) // Task to calculate pedestals from pedestal runs raw data 39 51 }; 40 52
Note:
See TracChangeset
for help on using the changeset viewer.