Changeset 5356 for trunk/MagicSoft/Mars/mpedestal
- Timestamp:
- 11/09/04 14:55:21 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/mpedestal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.cc
r5353 r5356 107 107 // 108 108 // Call: 109 // SetCheckRange(fCheckWinFirst,fCheckWinLast); 109 // SetCheckRange(fCheckWinFirst,fCheckWinLast); 110 110 // to set the Window in which a signal is searched 111 111 // … … 179 179 : fGeom(NULL), fPedContainerName("MPedestalCam") 180 180 { 181 181 182 fName = name ? name : "MPedCalcFromLoGain"; 182 183 fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data"; … … 191 192 SetPedestalUpdate(kTRUE); 192 193 Clear(); 194 193 195 } 194 196 … … 196 198 // 197 199 // Sets: 198 // - fNumSamplesTot to 0199 200 // - fRawEvt to NULL 200 201 // - fRunHeader to NULL 201 202 // - fPedestals to NULL 202 203 // 204 // Resets: 205 // - fSumx 206 // - fSumx2 207 // - fSumAB0 208 // - fSumAB1 209 // - fNumEventsUsed 210 // - fTotalCounter 211 // 203 212 void MPedCalcFromLoGain::Clear(const Option_t *o) 204 213 { 214 205 215 fRawEvt = NULL; 206 216 fRunHeader = NULL; … … 223 233 // 224 234 // SetCheckRange: 225 // 226 // Calls: 227 // - MExtractor::SetCheckRange(hifirst,hilast,lofirst,lolast); 228 // - SetExtractWindow(fWindowSizeHiGain,fExtractWinSize); 235 // 236 // Exits, if the first argument is smaller than 0 237 // Exits, if the the last argument is smaller than the first 229 238 // 230 239 void MPedCalcFromLoGain::SetCheckRange(Int_t chfirst, Int_t chlast) 231 240 { 232 241 233 234 if(chfirst<0){ 235 *fLog << warn << GetDescriptor() 236 << Form(": First slice in window to check for Signal <0, adjust:")<< endl; 237 exit(-1); 238 } 239 240 if(chlast<=chfirst){ 241 *fLog << warn << GetDescriptor() 242 << Form(": Last slice in Check window smaller than first slice in window, adjust:")<< endl; 243 exit(-1); 244 } 245 242 if(chfirst<0) 243 { 244 *fLog << warn << GetDescriptor() 245 << ": First slice in window to check for Signal <0, adjust:" << endl; 246 exit(-1); 247 } 248 249 if(chlast<=chfirst) 250 { 251 *fLog << warn << GetDescriptor() 252 << ": Last slice in Check window smaller than first slice in window, adjust:" << endl; 253 exit(-1); 254 } 255 246 256 fCheckWinFirst = chfirst; 247 257 fCheckWinLast = chlast; 248 258 259 } 260 261 // -------------------------------------------------------------------------- 262 // 263 // Exits: 264 // - if a window is odd 265 // 266 void MPedCalcFromLoGain::SetExtractWindow(Int_t windowf, Int_t windows) 267 { 249 268 250 } 251 252 // -------------------------------------------------------------------------- 253 // 254 void MPedCalcFromLoGain::SetMaxSignalVar(Int_t maxvar) 255 { 256 fMaxSignalVar = maxvar; 257 } 258 259 // -------------------------------------------------------------------------- 260 // 261 // Checks: 262 // - if a window is odd 263 // 264 void MPedCalcFromLoGain::SetExtractWindow(Int_t windowf, Int_t windows) 265 { 266 267 if(windowf<0){ 268 *fLog << warn << GetDescriptor() 269 << Form(": First slice in Extract window has to be >0, adjust:")<< endl; 270 exit(-1); 269 if(windowf<0) 270 { 271 *fLog << warn << GetDescriptor() 272 << Form(": First slice in Extract window has to be >0, adjust:")<< endl; 273 exit(-1); 271 274 } 272 275 273 276 Int_t odd = windows & 0x1; 274 277 275 if (odd||(windows==0)){ 276 *fLog << warn << GetDescriptor() << ": Extract window size has to be even and larger 0, adjust!"<< endl; 277 exit(-1); 278 } 279 280 fExtractWinSize = windows; 278 if (odd||(windows==0)) 279 { 280 *fLog << warn << GetDescriptor() << ": Extract window size has to be even and larger 0, adjust!"<< endl; 281 exit(-1); 282 } 283 284 fExtractWinSize = windows; 281 285 fExtractWinFirst = windowf; 282 fExtractWinLast = fExtractWinFirst+fExtractWinSize-1; 283 284 // 285 // NO RANGE CHECK IMPLEMENTED, YET 286 // 286 fExtractWinLast = fExtractWinFirst+fExtractWinSize-1; 287 287 288 /* 288 289 const Byte_t availhirange = (fHiGainLast-fHiGainFirst+1) & ~1; … … 322 323 // they were not found: 323 324 // 324 // - MPedestalCam 325 // - MPedestalCam with the name fPedContainerName 325 326 // 326 327 Int_t MPedCalcFromLoGain::PreProcess(MParList *pList) 327 328 { 329 328 330 Clear(); 329 331 … … 362 364 } 363 365 364 // -------------------------------------------------------------------------- 365 // 366 // The ReInit searches for: 367 // - MRawRunHeader::GetNumSamplesHiGain() 368 // - MRawRunHeader::GetNumSamplesLoGain() 369 // 370 366 // --------------------------------------------------------------------------------- 367 // 368 // Checks: 369 // - if the number of available slices 370 // (fRunHeader->GetNumSamplesHiGain()+(Int_t)fRunHeader->GetNumSamplesLoGain()-1) 371 // is smaller than the number of used slices 372 // (fExtractWinSize+ fExtractWinFirst-1) or 373 // fCheckWinLast 374 // 375 // Sets the size (from MPedestalCam::GetSize() ) and resets the following arrays: 376 // - fSumx 377 // - fSumx2 378 // - fSumAB0 379 // - fSumAB1 380 // - fNumEventsUsed 381 // - fTotalCounter 382 // 371 383 Bool_t MPedCalcFromLoGain::ReInit(MParList *pList) 372 384 { 373 385 374 Int_t lastavailableslice = (Int_t)fRunHeader->GetNumSamplesHiGain() +(Int_t)fRunHeader->GetNumSamplesLoGain()-1;375 376 Int_t lastextractslice = fExtractWinSize+ fExtractWinFirst - 1;377 378 if ( lastextractslice > lastavailableslice )//changed to override check386 Int_t lastavailableslice = (Int_t)fRunHeader->GetNumSamplesHiGain() 387 +(Int_t)fRunHeader->GetNumSamplesLoGain()-1; 388 Int_t lastextractslice = fExtractWinSize+ fExtractWinFirst - 1; 389 390 if ( lastextractslice > lastavailableslice ) //changed to override check 379 391 { 380 392 *fLog << endl; … … 382 394 << Form(": Selected Extract Window ranges out of the available limits adjust. Last available slice is %2i", 383 395 lastavailableslice) << endl; 384 exit(-1);385 } 386 387 if ( fCheckWinLast > lastavailableslice)//changed to override check396 return kFALSE; 397 } 398 399 if ( fCheckWinLast > lastavailableslice ) //changed to override check 388 400 { 389 401 *fLog << endl; … … 391 403 << Form(": Last Check Window slice is out of the available limits adjust. Last available slice is %2i", 392 404 lastavailableslice) << endl; 393 exit(-1);405 return kFALSE; 394 406 } 395 407 … … 420 432 } 421 433 434 // --------------------------------------------------------------------------------- 435 // 436 // Calculates for pixel "idx": 437 // 438 // Ped per slice = sum / n / fExtractWinSize; 439 // RMS per slice = sqrt { (sum2 - sum*sum/n) / (n-1) / fExtractWinSize } 440 // ABOffset per slice = (fSumAB0[idx] - fSumAB1[idx]) / n / fExtractWinSize; 441 // 442 // Sets fTotalCounter up by 1. 443 // 422 444 void MPedCalcFromLoGain::Calc(ULong_t n, UInt_t idx) 423 445 { 424 const ULong_t nsamplestot = n*fExtractWinSize; 425 426 const Float_t sum = fSumx.At(idx); 427 const Float_t sum2 = fSumx2.At(idx); 428 const Float_t ped = sum/nsamplestot; 429 430 // 1. Calculate the Variance of the sums: 431 Float_t var = (sum2-sum*sum/n)/(n-1.); 432 433 // 2. Scale the variance to the number of slices: 434 var /= (Float_t)(fExtractWinSize); 435 436 // 3. Calculate the RMS from the Variance: 437 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var); 438 439 // 4. Calculate the amplitude of the 150MHz "AB" noise 440 const Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot; 441 442 (*fPedestals)[idx].Set(ped, rms, abOffs, n); 443 444 fTotalCounter[idx]++; 445 } 446 446 447 const ULong_t nsamplestot = n*fExtractWinSize; 448 449 const Float_t sum = fSumx.At(idx); 450 const Float_t sum2 = fSumx2.At(idx); 451 const Float_t ped = sum/nsamplestot; 452 453 // 1. Calculate the Variance of the sums: 454 Float_t var = (sum2-sum*sum/n)/(n-1.); 455 456 // 2. Scale the variance to the number of slices: 457 var /= (Float_t)(fExtractWinSize); 458 459 // 3. Calculate the RMS from the Variance: 460 const Float_t rms = var<0 ? 0 : TMath::Sqrt(var); 461 462 // 4. Calculate the amplitude of the 150MHz "AB" noise 463 const Float_t abOffs = (fSumAB0[idx] - fSumAB1[idx]) / nsamplestot; 464 465 (*fPedestals)[idx].Set(ped, rms, abOffs, n); 466 467 fTotalCounter[idx]++; 468 } 469 470 // --------------------------------------------------------------------------------- 471 // 472 // Returns the pointer to slice "slice". 473 // 447 474 UInt_t MPedCalcFromLoGain::GetSlice(MRawEvtPixelIter *pixel, UInt_t slice) 448 475 { … … 459 486 else 460 487 { 461 ptr = pixel->GetHiGainSamples();462 ptr += slice;488 ptr = pixel->GetHiGainSamples(); 489 ptr += slice; 463 490 } 464 491 … … 535 562 536 563 if (!fPedestalUpdate || fNumEventsUsed[idx]<fNumEventsDump) 537 564 continue; 538 565 539 566 Calc(fNumEventsDump, idx); … … 547 574 548 575 if (fPedestalUpdate) 549 576 fPedestals->SetReadyToSave(); 550 577 551 578 return kTRUE; … … 560 587 // Compute pedestals and rms from the whole run 561 588 if (fPedestalUpdate) 562 589 return kTRUE; 563 590 564 591 *fLog << flush << inf << "Calculating Pedestals..." << flush; … … 566 593 const Int_t npix = fGeom->GetNumPixels(); 567 594 for (Int_t idx=0; idx<npix; idx++) 568 {595 { 569 596 const ULong_t n = fNumEventsUsed[idx]; 570 597 if (n>1) 571 572 }598 Calc(n, idx); 599 } 573 600 574 601 fPedestals->SetReadyToSave(); 575 602 return kTRUE; 576 603 } 604 577 605 578 606 Int_t MPedCalcFromLoGain::ReadEnv(const TEnv &env, TString prefix, Bool_t print) -
trunk/MagicSoft/Mars/mpedestal/MPedCalcFromLoGain.h
r5338 r5356 69 69 void SetCheckRange(Int_t checkfirst=0, Int_t checklast=29); 70 70 void SetExtractWindow(Int_t extractfirst=15, Int_t windowsize=6); 71 void SetMaxSignalVar(Int_t maxvar=0) ;72 void SetNumEventsDump(UInt_t dumpevents = 0) { fNumEventsDump = dumpevents;}71 void SetMaxSignalVar(Int_t maxvar=0) { fMaxSignalVar = maxvar; } 72 void SetNumEventsDump(UInt_t dumpevents = 0) { fNumEventsDump = dumpevents;} 73 73 void SetPedestalUpdate(Bool_t pedupdate) {fPedestalUpdate = pedupdate;} 74 74
Note:
See TracChangeset
for help on using the changeset viewer.