Changeset 5298 for trunk/MagicSoft/Mars/msignal
- Timestamp:
- 10/20/04 16:21:23 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/msignal
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.cc
r5203 r5298 51 51 #include "MExtractTimeAndChargeDigitalFilter.h" 52 52 53 #include <errno.h> 54 #include <fstream> 55 56 #include <TFile.h> 57 #include <TH1F.h> 58 #include <TH2F.h> 59 #include <TString.h> 60 #include <TMatrix.h> 61 53 62 #include "MLog.h" 54 63 #include "MLogManip.h" 55 64 56 65 #include "MPedestalPix.h" 57 58 #include "TFile.h"59 #include "TH1F.h"60 #include "TH2F.h"61 #include "TString.h"62 #include "TMatrix.h"63 64 #include <fstream>65 66 66 67 ClassImp(MExtractTimeAndChargeDigitalFilter); … … 78 79 const Int_t MExtractTimeAndChargeDigitalFilter::fgSignalStartBinHiGain = 4; 79 80 const Int_t MExtractTimeAndChargeDigitalFilter::fgSignalStartBinLoGain = 4; 81 80 82 // -------------------------------------------------------------------------- 81 83 // … … 91 93 MExtractTimeAndChargeDigitalFilter::MExtractTimeAndChargeDigitalFilter(const char *name, const char *title) 92 94 { 93 94 fName = name ? name : "MExtractTimeAndChargeDigitalFilter"; 95 fTitle = title ? title : "Digital Filter"; 96 97 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 98 SetWindowSize(); 99 SetBinningResolution(); 100 SetSignalStartBin(); 101 102 ReadWeightsFile(""); 95 fName = name ? name : "MExtractTimeAndChargeDigitalFilter"; 96 fTitle = title ? title : "Digital Filter"; 97 98 SetRange(fgHiGainFirst, fgHiGainLast, fgLoGainFirst, fgLoGainLast); 99 SetWindowSize(); 100 SetBinningResolution(); 101 SetSignalStartBin(); 102 103 ReadWeightsFile(""); 103 104 } 104 105 105 106 106 // --------------------------------------------------------------------------------------- … … 129 129 130 130 if (fWindowSizeHiGain > availhirange) 131 { 131 { 132 // Please simplify this! 132 133 *fLog << warn << GetDescriptor() 133 134 << Form("%s%2i%s%2i%s%2i%s",": Hi Gain window size: ",fWindowSizeHiGain, … … 150 151 if (fWindowSizeLoGain > availlorange) 151 152 { 153 // Please simplify this! 152 154 *fLog << warn << GetDescriptor() 153 155 << Form("%s%2i%s%2i%s%2i%s",": Lo Gain window size: ",fWindowSizeLoGain, … … 182 184 Bool_t MExtractTimeAndChargeDigitalFilter::ReInit(MParList *pList) 183 185 { 184 185 if (!MExtractTimeAndCharge::ReInit(pList)) 186 return kFALSE; 187 188 Int_t range = fHiGainLast - fHiGainFirst + 1 + fHiLoLast; 189 190 fHiGainSignal.Set(range); 191 192 range = fLoGainLast - fLoGainFirst + 1; 193 194 fLoGainSignal.Set(range); 195 196 fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain; 197 fTimeShiftLoGain = (Float_t)fLoGainFirst + 0.5 + 1./fBinningResolutionLoGain; 198 199 return kTRUE; 186 if (!MExtractTimeAndCharge::ReInit(pList)) 187 return kFALSE; 188 189 fHiGainSignal.Set(fHiGainLast - fHiGainFirst + 1 + fHiLoLast); 190 fLoGainSignal.Set(fLoGainLast - fLoGainFirst + 1); 191 192 fTimeShiftHiGain = (Float_t)fHiGainFirst + 0.5 + 1./fBinningResolutionHiGain; 193 fTimeShiftLoGain = (Float_t)fLoGainFirst + 0.5 + 1./fBinningResolutionLoGain; 194 195 return kTRUE; 200 196 } 201 197 198 Int_t MExtractTimeAndChargeDigitalFilter::PreProcess(MParList *pList) 199 { 200 *fLog << endl; 201 *fLog << inf << "Using the following weights: " << endl; 202 *fLog << "Hi-Gain:" << endl; 203 204 for (Int_t i=0; i<fBinningResolutionHiGain*fWindowSizeHiGain; i++) 205 *fLog << " " << fAmpWeightsHiGain[i] << " \t " << fTimeWeightsHiGain[i] << endl; 206 207 *fLog << "Lo-Gain:" << endl; 208 209 for (Int_t i=0; i<fBinningResolutionLoGain*fWindowSizeLoGain; i++) 210 *fLog << " " << fAmpWeightsLoGain[i] << " \t " << fTimeWeightsLoGain[i] << endl; 211 212 return MExtractTimeAndCharge::PreProcess(pList); 213 } 202 214 203 215 void MExtractTimeAndChargeDigitalFilter::FindTimeAndChargeHiGain(Byte_t *ptr, Byte_t *logain, Float_t &sum, Float_t &dsum, … … 267 279 const Float_t ABoffs = ped.GetPedestalABoffset(); 268 280 269 Float_t PedMean[2];270 PedMean[0] = pedes + ABoffs;271 PedMean[1] = pedes - ABoffs;281 Float_t pedmean[2]; 282 pedmean[0] = pedes + ABoffs; 283 pedmean[1] = pedes - ABoffs; 272 284 273 285 // … … 286 298 { 287 299 const Int_t idx = fBinningResolutionHiGain*sample+fBinningResolutionHalfHiGain; 288 const Float_t pex = fHiGainSignal[sample+i]- PedMean[(sample+i+abflag) & 0x1];300 const Float_t pex = fHiGainSignal[sample+i]-pedmean[(sample+i+abflag) & 0x1]; 289 301 sum += fAmpWeightsHiGain [idx]*pex; 290 302 time_sum += fTimeWeightsHiGain[idx]*pex; … … 298 310 } 299 311 } /* for (Int_t i=0;i<range-fWindowSizeHiGain;i++) */ 300 301 if (fmax!=0) 302 { 303 ftime_max /= fmax; 304 Int_t t_iter = Int_t(ftime_max*fBinningResolutionHiGain); 305 Int_t sample_iter = 0; 306 307 while ( t_iter > fBinningResolutionHalfHiGain-1 || t_iter < -fBinningResolutionHalfHiGain ) 308 { 309 if (t_iter > fBinningResolutionHalfHiGain-1) 310 { 311 t_iter -= fBinningResolutionHiGain; 312 max_p--; 313 sample_iter--; 314 } 315 if (t_iter < -fBinningResolutionHalfHiGain) 316 { 317 t_iter += fBinningResolutionHiGain; 318 max_p++; 319 sample_iter++; 320 } 321 } 322 323 sum = 0.; 324 // 325 // Slide with a window of size fWindowSizeHiGain over the sample 326 // and multiply the entries with the corresponding weights 327 // 328 for (Int_t sample=0; sample < fWindowSizeHiGain; sample++) 329 { 330 const Int_t idx = fBinningResolutionHiGain*sample + fBinningResolutionHalfHiGain + t_iter; 331 const Int_t ids = max_p + sample; 332 const Float_t pex = ids < 0 ? 0. : 333 ( ids > range ? 0. : fHiGainSignal[ids]-PedMean[(ids+abflag) & 0x1]); 334 sum += fAmpWeightsHiGain [idx]*pex; 335 time_sum += fTimeWeightsHiGain[idx]*pex; 336 } 337 338 if (sum != 0.) 339 time = max_p + fTimeShiftHiGain /* this shifts the time to the start of the rising edge */ 340 - ((Float_t)t_iter)/fBinningResolutionHiGain - time_sum/sum; 341 else 342 time = 0.; 343 } /* if (max!=0) */ 344 else 345 time=0.; 346 347 return; 312 313 time = 0; 314 if (fmax==0) 315 return; 316 317 ftime_max /= fmax; 318 Int_t t_iter = Int_t(ftime_max*fBinningResolutionHiGain); 319 Int_t sample_iter = 0; 320 321 while ( t_iter > fBinningResolutionHalfHiGain-1 || t_iter < -fBinningResolutionHalfHiGain ) 322 { 323 if (t_iter > fBinningResolutionHalfHiGain-1) 324 { 325 t_iter -= fBinningResolutionHiGain; 326 max_p--; 327 sample_iter--; 328 } 329 if (t_iter < -fBinningResolutionHalfHiGain) 330 { 331 t_iter += fBinningResolutionHiGain; 332 max_p++; 333 sample_iter++; 334 } 335 } 336 337 sum = 0.; 338 // 339 // Slide with a window of size fWindowSizeHiGain over the sample 340 // and multiply the entries with the corresponding weights 341 // 342 for (Int_t sample=0; sample < fWindowSizeHiGain; sample++) 343 { 344 const Int_t idx = fBinningResolutionHiGain*sample + fBinningResolutionHalfHiGain + t_iter; 345 const Int_t ids = max_p + sample; 346 const Float_t pex = ids < 0 ? 0. : 347 ( ids > range ? 0. : fHiGainSignal[ids]-pedmean[(ids+abflag) & 0x1]); 348 sum += fAmpWeightsHiGain [idx]*pex; 349 time_sum += fTimeWeightsHiGain[idx]*pex; 350 } 351 352 if (sum == 0) 353 return; 354 355 time = max_p + fTimeShiftHiGain /* this shifts the time to the start of the rising edge */ 356 - ((Float_t)t_iter)/fBinningResolutionHiGain - time_sum/sum; 348 357 } 349 358 … … 386 395 const Float_t ABoffs = ped.GetPedestalABoffset(); 387 396 388 Float_t PedMean[2];389 PedMean[0] = pedes + ABoffs;390 PedMean[1] = pedes - ABoffs;397 Float_t pedmean[2]; 398 pedmean[0] = pedes + ABoffs; 399 pedmean[1] = pedes - ABoffs; 391 400 392 401 // … … 405 414 { 406 415 const Int_t idx = fBinningResolutionLoGain*sample+fBinningResolutionHalfLoGain; 407 const Float_t pex = fLoGainSignal[sample+i]- PedMean[(sample+i+abflag) & 0x1];416 const Float_t pex = fLoGainSignal[sample+i]-pedmean[(sample+i+abflag) & 0x1]; 408 417 sum += fAmpWeightsLoGain [idx]*pex; 409 418 time_sum += fTimeWeightsLoGain[idx]*pex; … … 417 426 } 418 427 } /* for (Int_t i=0;i<range-fWindowSizeLoGain;i++) */ 419 420 if (fmax!=0) 421 { 422 ftime_max /= fmax; 423 Int_t t_iter = Int_t(ftime_max*fBinningResolutionLoGain); 424 Int_t sample_iter = 0; 425 426 while ( t_iter > fBinningResolutionHalfLoGain-1 || t_iter < -fBinningResolutionHalfLoGain ) 427 { 428 if (t_iter > fBinningResolutionHalfLoGain-1) 429 { 430 t_iter -= fBinningResolutionLoGain; 431 max_p--; 432 sample_iter--; 433 } 434 if (t_iter < -fBinningResolutionHalfLoGain) 435 { 436 t_iter += fBinningResolutionLoGain; 437 max_p++; 438 sample_iter++; 439 } 440 } 441 442 sum = 0.; 443 // 444 // Slide with a window of size fWindowSizeLoGain over the sample 445 // and multiply the entries with the corresponding weights 446 // 447 for (Int_t sample=0; sample < fWindowSizeLoGain; sample++) 448 { 449 const Int_t idx = fBinningResolutionLoGain*sample + fBinningResolutionHalfLoGain + t_iter; 450 const Int_t ids = max_p + sample; 451 const Float_t pex = ids < 0 ? 0. : 452 ( ids > range ? 0. : fLoGainSignal[ids]-PedMean[(ids+abflag) & 0x1]); 453 sum += fAmpWeightsLoGain [idx]*pex; 454 time_sum += fTimeWeightsLoGain[idx]*pex; 455 } 456 457 if (sum != 0.) 458 time = max_p + fTimeShiftLoGain /* this shifts the time to the start of the rising edge */ 459 - ((Float_t)t_iter)/fBinningResolutionLoGain - time_sum/sum; 460 else 461 time = 0.; 462 } /* if (max!=0) */ 463 else 464 time=0.; 465 466 return; 428 429 time = 0; 430 if (fmax==0) 431 return; 432 433 ftime_max /= fmax; 434 Int_t t_iter = Int_t(ftime_max*fBinningResolutionLoGain); 435 Int_t sample_iter = 0; 436 437 while ( t_iter > fBinningResolutionHalfLoGain-1 || t_iter < -fBinningResolutionHalfLoGain ) 438 { 439 if (t_iter > fBinningResolutionHalfLoGain-1) 440 { 441 t_iter -= fBinningResolutionLoGain; 442 max_p--; 443 sample_iter--; 444 } 445 if (t_iter < -fBinningResolutionHalfLoGain) 446 { 447 t_iter += fBinningResolutionLoGain; 448 max_p++; 449 sample_iter++; 450 } 451 } 452 453 sum = 0.; 454 455 // 456 // Slide with a window of size fWindowSizeLoGain over the sample 457 // and multiply the entries with the corresponding weights 458 // 459 for (Int_t sample=0; sample < fWindowSizeLoGain; sample++) 460 { 461 const Int_t idx = fBinningResolutionLoGain*sample + fBinningResolutionHalfLoGain + t_iter; 462 const Int_t ids = max_p + sample; 463 const Float_t pex = ids < 0 ? 0. : 464 ( ids > range ? 0. : fLoGainSignal[ids]-pedmean[(ids+abflag) & 0x1]); 465 sum += fAmpWeightsLoGain [idx]*pex; 466 time_sum += fTimeWeightsLoGain[idx]*pex; 467 } 468 469 if (sum == 0) 470 return; 471 472 time = max_p + fTimeShiftLoGain /* this shifts the time to the start of the rising edge */ 473 - ((Float_t)t_iter)/fBinningResolutionLoGain - time_sum/sum; 467 474 } 468 475 476 // -------------------------------------------------------------------------- 477 // 478 // Read the setup from a TEnv, eg: 479 // MJPedestal.MExtractor.WindowSizeHiGain: 6 480 // MJPedestal.MExtractor.WindowSizeLoGain: 6 481 // MJPedestal.MExtractor.BinningResolutionHiGain: 10 482 // MJPedestal.MExtractor.BinningResolutionLoGain: 10 483 // MJPedestal.MExtractor.WeightsFile: filename 484 // 469 485 Int_t MExtractTimeAndChargeDigitalFilter::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 470 486 { 471 472 Byte_t hw = fWindowSizeHiGain; 473 Byte_t lw = fWindowSizeLoGain; 474 Bool_t rc = kFALSE; 475 476 if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print)) 477 { 478 hw = GetEnvValue(env, prefix, "WindowSizeHiGain", hw); 479 rc = kTRUE; 480 } 481 if (IsEnvDefined(env, prefix, "WindowSizeLoGain", print)) 482 { 483 lw = GetEnvValue(env, prefix, "WindowSizeLoGain", lw); 484 rc = kTRUE; 485 } 486 487 if (rc) 488 SetWindowSize(hw, lw); 489 490 if (IsEnvDefined(env, prefix, "BinningResolution", print)) 491 { 492 SetBinningResolution(GetEnvValue(env, prefix, "BinningResolutionHiGain", fBinningResolutionHiGain), 493 GetEnvValue(env, prefix, "BinningResolutionLoGain", fBinningResolutionLoGain)); 494 rc = kTRUE; 495 } 496 497 rc = MExtractor::ReadEnv(env, prefix, print) ? kTRUE : rc; 498 499 return rc; 500 } 501 502 Int_t MExtractTimeAndChargeDigitalFilter::PostProcess() 503 { 504 505 *fLog << endl; 506 *fLog << inf << "Used High Gain weights in the extractor: " << endl; 507 508 for (Int_t i=0;i<fBinningResolutionHiGain*fWindowSizeHiGain; i++) 509 *fLog << inf << fAmpWeightsHiGain[i] << " " << fTimeWeightsHiGain[i] << endl; 510 511 *fLog << endl; 512 *fLog << inf << "Used Low Gain weights in the extractor: " << endl; 513 for (Int_t i=0;i<fBinningResolutionLoGain*fWindowSizeLoGain; i++) 514 *fLog << inf << fAmpWeightsLoGain[i] << " " << fTimeWeightsLoGain[i] << endl; 515 516 return kTRUE; 487 Byte_t hw = fWindowSizeHiGain; 488 Byte_t lw = fWindowSizeLoGain; 489 Bool_t rc = kFALSE; 490 491 if (IsEnvDefined(env, prefix, "WindowSizeHiGain", print)) 492 { 493 hw = GetEnvValue(env, prefix, "WindowSizeHiGain", hw); 494 rc = kTRUE; 495 } 496 if (IsEnvDefined(env, prefix, "WindowSizeLoGain", print)) 497 { 498 lw = GetEnvValue(env, prefix, "WindowSizeLoGain", lw); 499 rc = kTRUE; 500 } 501 502 if (rc) 503 SetWindowSize(hw, lw); 504 505 Bool_t rc2 = kFALSE; 506 Int_t brh = fBinningResolutionHiGain; 507 Int_t brl = fBinningResolutionLoGain; 508 509 if (IsEnvDefined(env, prefix, "BinningResolutionHiGain", print)) 510 { 511 brh = GetEnvValue(env, prefix, brh); 512 rc2 = kTRUE; 513 } 514 if (IsEnvDefined(env, prefix, "BinningResolutionLoGain", print)) 515 { 516 brl = GetEnvValue(env, prefix, brl); 517 rc2 = kTRUE; 518 } 519 520 if (rc2) 521 { 522 SetBinningResolution(brh, brl); 523 rc = kTRUE; 524 } 525 526 if (IsEnvDefined(env, prefix, "WeightsFile", print)) 527 { 528 if (!ReadWeightsFile(GetEnvValue(env, prefix, "WeightsFile", ""))) 529 return kERROR; 530 rc = kTRUE; 531 } 532 533 return MExtractTimeAndCharge::ReadEnv(env, prefix, print) ? kTRUE : rc; 517 534 } 518 535 … … 526 543 Bool_t MExtractTimeAndChargeDigitalFilter::ReadWeightsFile(TString filename) 527 544 { 528 529 fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain); 530 fAmpWeightsLoGain .Set(fBinningResolutionLoGain*fWindowSizeLoGain); 531 fTimeWeightsHiGain.Set(fBinningResolutionHiGain*fWindowSizeHiGain); 532 fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain); 533 534 if (filename.IsNull()) 535 { 536 for (UInt_t i=0; i<fAmpWeightsHiGain.GetSize(); i++) 537 { 538 fAmpWeightsHiGain [i] = 1.; 539 fTimeWeightsHiGain[i] = 1.; 540 } 541 for (UInt_t i=0; i<fAmpWeightsLoGain.GetSize(); i++) 542 { 543 fAmpWeightsLoGain [i] = 1.; 544 fTimeWeightsLoGain[i] = 1.; 545 } 546 return kTRUE; 547 } 548 549 ifstream fin(filename.Data()); 550 551 if (!fin) 552 { 553 *fLog << err << GetDescriptor() 554 << ": No weights file found: " << filename << endl; 555 return kFALSE; 556 } 557 558 Int_t len = 0; 559 Int_t cnt = 0; 560 Bool_t hi = kFALSE; 561 Bool_t lo = kFALSE; 562 563 TString str; 564 565 while (1) 566 { 567 568 str.ReadLine(fin); 569 if (!fin) 570 break; 571 572 573 if (str.Contains("# High Gain Weights:")) 574 { 575 str.ReplaceAll("# High Gain Weights:",""); 576 sscanf(str.Data(),"%2i%2i",&fWindowSizeHiGain,&fBinningResolutionHiGain); 577 *fLog << inf << "Found number of High Gain slices: " << fWindowSizeHiGain 578 << " and High Gain resolution: " << fBinningResolutionHiGain << endl; 579 len = fBinningResolutionHiGain*fWindowSizeHiGain; 580 fAmpWeightsHiGain .Set(len); 581 fTimeWeightsHiGain.Set(len); 582 hi = kTRUE; 583 continue; 584 } 585 586 if (str.Contains("# Low Gain Weights:")) 587 { 588 str.ReplaceAll("# Low Gain Weights:",""); 589 sscanf(str.Data(),"%2i%2i",&fWindowSizeLoGain,&fBinningResolutionLoGain); 590 *fLog << inf << "Found number of Low Gain slices: " << fWindowSizeLoGain 591 << " and Low Gain resolution: " << fBinningResolutionLoGain << endl; 592 len = fBinningResolutionLoGain*fWindowSizeHiGain; 593 fAmpWeightsLoGain .Set(len); 594 fTimeWeightsLoGain.Set(len); 595 lo = kTRUE; 596 continue; 597 } 598 599 if (str.Contains("#")) 600 continue; 601 602 if (len == 0) 603 continue; 604 605 sscanf(str.Data(),"\t%f\t%f",lo ? &fAmpWeightsLoGain [cnt] : &fAmpWeightsHiGain [cnt], 606 lo ? &fTimeWeightsLoGain[cnt] : &fTimeWeightsHiGain[cnt]); 607 608 if (++cnt == len) 609 { 610 len = 0; 611 cnt = 0; 612 } 613 } 614 615 if (cnt != len) 616 { 617 *fLog << err << GetDescriptor() 618 << ": Size mismatch in weights file " << filename << endl; 619 return kFALSE; 620 } 621 622 if (!hi) 623 { 624 *fLog << err << GetDescriptor() 625 << ": No correct header found in weights file " << filename << endl; 626 return kFALSE; 627 } 628 629 return kTRUE; 545 fAmpWeightsHiGain .Set(fBinningResolutionHiGain*fWindowSizeHiGain); 546 fAmpWeightsLoGain .Set(fBinningResolutionLoGain*fWindowSizeLoGain); 547 fTimeWeightsHiGain.Set(fBinningResolutionHiGain*fWindowSizeHiGain); 548 fTimeWeightsLoGain.Set(fBinningResolutionLoGain*fWindowSizeLoGain); 549 550 if (filename.IsNull()) 551 { 552 fAmpWeightsHiGain.Reset(1); 553 fTimeWeightsHiGain.Reset(1); 554 fAmpWeightsLoGain.Reset(1); 555 fTimeWeightsLoGain.Reset(1); 556 return kTRUE; 557 } 558 559 ifstream fin(filename.Data()); 560 if (!fin) 561 { 562 *fLog << err << GetDescriptor() << ": ERROR - Cannot open file " << filename << ": "; 563 *fLog << strerror(errno) << endl; 564 return kFALSE; 565 } 566 567 *fLog << inf << "Reading weights file " << filename << "..." << flush; 568 569 Int_t len = 0; 570 Int_t cnt = 0; 571 Int_t line = 0; 572 Bool_t hi = kFALSE; 573 Bool_t lo = kFALSE; 574 575 TString str; 576 577 while (1) 578 { 579 str.ReadLine(fin); 580 if (!fin) 581 break; 582 583 line++; 584 585 if (str.Contains("# High Gain Weights:")) 586 { 587 if (hi) 588 { 589 *fLog << err << "ERROR - 'High Gain Weights' found twice in line #" << line << "." << endl; 590 return kFALSE; 591 } 592 593 if (2!=sscanf(str.Data(), "# High Gain Weights:%2i %2i", &fWindowSizeHiGain, &fBinningResolutionHiGain)) 594 { 595 *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl; 596 *fLog << str << endl; 597 return kFALSE; 598 } 599 600 len = fBinningResolutionHiGain*fWindowSizeHiGain; 601 fAmpWeightsHiGain .Set(len); 602 fTimeWeightsHiGain.Set(len); 603 hi = kTRUE; 604 continue; 605 } 606 607 if (str.Contains("# Low Gain Weights:")) 608 { 609 if (lo) 610 { 611 *fLog << err << "ERROR - 'Lo Gain Weights' found twice in line #" << line << "." << endl; 612 return kFALSE; 613 } 614 615 if (2!=sscanf(str.Data(),"# Low Gain Weights:%2i %2i", &fWindowSizeLoGain, &fBinningResolutionLoGain)) 616 { 617 *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl; 618 *fLog << str << endl; 619 return kFALSE; 620 } 621 622 len = fBinningResolutionLoGain*fWindowSizeHiGain; 623 fAmpWeightsLoGain .Set(len); 624 fTimeWeightsLoGain.Set(len); 625 lo = kTRUE; 626 continue; 627 } 628 629 // Handle lines with comments 630 if (str.Contains("#")) 631 continue; 632 633 // Nothing found so far 634 if (len == 0) 635 continue; 636 637 if (2!=sscanf(str.Data(), "%f %f", 638 lo ? &fAmpWeightsLoGain [cnt] : &fAmpWeightsHiGain [cnt], 639 lo ? &fTimeWeightsLoGain[cnt] : &fTimeWeightsHiGain[cnt])) 640 { 641 *fLog << err << "ERROR - Wrong number of arguments in line #" << line << ":" << endl; 642 *fLog << str << endl; 643 return kFALSE; 644 } 645 646 if (++cnt == len) 647 { 648 len = 0; 649 cnt = 0; 650 } 651 } 652 653 if (cnt != len) 654 { 655 *fLog << err << "Size mismatch in weights file " << filename << endl; 656 return kFALSE; 657 } 658 659 if (!hi) 660 { 661 *fLog << err << "No correct header found in weights file " << filename << endl; 662 return kFALSE; 663 } 664 665 *fLog << "done." << endl; 666 667 *fLog << inf << " File contains " << fWindowSizeHiGain << " hi-gain slices "; 668 *fLog << "and with a resolution of " << fBinningResolutionHiGain << endl; 669 670 *fLog << inf << " File contains " << fWindowSizeLoGain << " lo-gain slices "; 671 *fLog << "and with a resolution of " << fBinningResolutionLoGain << endl; 672 673 return kTRUE; 630 674 } 631 675 -
trunk/MagicSoft/Mars/msignal/MExtractTimeAndChargeDigitalFilter.h
r5162 r5298 16 16 { 17 17 private: 18 19 18 static const Byte_t fgHiGainFirst; 20 19 static const Byte_t fgHiGainLast; … … 34 33 Float_t fTimeShiftLoGain; 35 34 36 Int_t fSignalStartBinHiGain; 37 Int_t fSignalStartBinLoGain; 35 Int_t fSignalStartBinHiGain; //! 36 Int_t fSignalStartBinLoGain; //! 38 37 39 Int_t fWindowSizeHiGain; 40 Int_t fWindowSizeLoGain; 38 Int_t fWindowSizeHiGain; 39 Int_t fWindowSizeLoGain; 41 40 42 41 Int_t fBinningResolutionHiGain; … … 45 44 Int_t fBinningResolutionHalfLoGain; 46 45 47 MArrayF fAmpWeightsHiGain; 48 MArrayF fTimeWeightsHiGain; 49 MArrayF fAmpWeightsLoGain; 50 MArrayF fTimeWeightsLoGain; 46 MArrayF fAmpWeightsHiGain; //! 47 MArrayF fTimeWeightsHiGain; //! 48 MArrayF fAmpWeightsLoGain; //! 49 MArrayF fTimeWeightsLoGain; //! 51 50 52 Bool_t ReInit( MParList *pList);53 Int_t P ostProcess();54 51 Bool_t ReInit(MParList *pList); 52 Int_t PreProcess(MParList *pList); 53 55 54 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 56 55 57 56 protected: 58 59 57 virtual void FindTimeAndChargeHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Float_t &dsum, 60 58 Float_t &time, Float_t &dtime, … … 89 87 } 90 88 91 ClassDef(MExtractTimeAndChargeDigitalFilter, 0) // Hendrik's digital filter89 ClassDef(MExtractTimeAndChargeDigitalFilter, 1) // Hendrik's digital filter 92 90 }; 93 91 94 92 #endif 95 96 97
Note:
See TracChangeset
for help on using the changeset viewer.