Changeset 5848
- Timestamp:
- 01/14/05 19:14:03 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r5845 r5848 42 42 the whole camera including a fit to the values. 43 43 44 * mpedestal/MPedCalcPedRun.[h,cc] 45 - undo some changes introduced by TB on 2/12/04 which had made the 46 use of interlaced pedestal events impossible again. 47 - Use now the new class MTriggerPattern directly to recognize an 48 interlaced pedestal event. 44 49 45 50 -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
r5832 r5848 139 139 #include "MExtractTimeAndCharge.h" 140 140 141 #include "MTriggerPattern.h" 142 141 143 ClassImp(MPedCalcPedRun); 142 144 … … 145 147 const UShort_t MPedCalcPedRun::fgExtractWinFirst = 0; 146 148 const UShort_t MPedCalcPedRun::fgExtractWinSize = 6; 147 const UInt_t MPedCalcPedRun::gkFirstRunWithFinalBits = 45589; 148 149 const UInt_t MPedCalcPedRun::gkFirstRunWithFinalBits = 45605; 149 150 // -------------------------------------------------------------------------- 150 151 // … … 162 163 // 163 164 MPedCalcPedRun::MPedCalcPedRun(const char *name, const char *title) 164 : fOverlap(0) 165 { 166 fName = name ? name : "MPedCalcPedRun"; 167 fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data"; 168 169 SetExtractWindow(fgExtractWinFirst, fgExtractWinSize); 165 : fOverlap(0), fIsFirstPedRun(kFALSE), fUsedEvents(0), fTrigPattern(NULL) 166 { 167 fName = name ? name : "MPedCalcPedRun"; 168 fTitle = title ? title : "Task to calculate pedestals from pedestal runs raw data"; 169 170 SetExtractWindow(fgExtractWinFirst, fgExtractWinSize); 171 172 // SetNumEventsDump(1001); 173 // SetNumAreasDump(1001); 174 // SetNumSectorsDump(1001); 170 175 } 171 176 … … 179 184 void MPedCalcPedRun::CheckExtractionWindow() 180 185 { 181 const UShort_t lastavailable = fRunHeader->GetNumSamplesHiGain()-1; 182 183 if (fExtractWinLast <= lastavailable) 184 return; 185 186 const UShort_t diff = fExtractWinLast - lastavailable; 187 188 *fLog << warn << endl; 189 *fLog << "Selected ExtractWindow [" << fExtractWinFirst << "," << fExtractWinLast; 190 *fLog << "] ranges out of range [0," << lastavailable << "]." << endl; 191 *fLog << "Using " << diff << " samples from the 'Lo-Gain' slices for the pedestal extraction" << endl; 192 193 fExtractWinLast -= diff; 194 fOverlap = diff; 186 const UShort_t lastavailable = fRunHeader->GetNumSamplesHiGain()-1; 187 188 if (fExtractWinLast <= lastavailable) 189 return; 190 191 const UShort_t diff = fExtractWinLast - lastavailable; 192 193 *fLog << warn << endl; 194 *fLog << "Selected ExtractWindow [" << fExtractWinFirst << "," << fExtractWinLast; 195 *fLog << "] ranges out of range [0," << lastavailable << "]." << endl; 196 *fLog << "Using " << diff << " samples from the 'Lo-Gain' slices for the pedestal extraction" << endl; 197 198 fExtractWinLast -= diff; 199 fOverlap = diff; 200 } 201 202 void MPedCalcPedRun::Reset() 203 { 204 205 MExtractPedestal::ResetArrays(); 206 fUsedEvents = 0; 195 207 } 196 208 … … 201 213 Int_t MPedCalcPedRun::PreProcess(MParList *pList) 202 214 { 203 fUsedEvents = 0; 204 fIsFirstPedRun = kTRUE; 205 return MExtractPedestal::PreProcess(pList); 215 216 fUsedEvents = 0; 217 fIsFirstPedRun = kTRUE; 218 fIsNotPedRun = kFALSE; 219 220 fTrigPattern = (MTriggerPattern*)pList->FindObject("MTriggerPattern"); 221 if (!fTrigPattern) 222 *fLog << warn << GetDescriptor() 223 << ": MTriggerPattern not found... Cannot use interlaced pedestal events." << endl; 224 225 return MExtractPedestal::PreProcess(pList); 206 226 } 207 227 … … 209 229 // 210 230 // The run type is checked for "kRTPedestal" 211 // and the variable f Skipis set in that case231 // and the variable fIsNotPedRun is set in that case 212 232 // 213 233 Bool_t MPedCalcPedRun::ReInit(MParList *pList) 214 234 { 215 if (!MExtractPedestal::ReInit(pList)) 216 return kFALSE; 217 218 CheckExtractionWindow(); 219 220 // If this is the first ped run, the next run (call to ReInit) 221 // is not the first anymore 222 if (fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal) 235 236 if (!MExtractPedestal::ReInit(pList)) 237 return kFALSE; 238 239 CheckExtractionWindow(); 240 241 // 242 // If this is the first ped run, the next run (call to ReInit) 243 // is not the first anymore 244 // 245 if (fRunHeader->GetRunType()==MRawRunHeader::kRTPedestal) 223 246 { 224 fIsFirstPedRun = kFALSE; 225 return kTRUE; 247 fIsFirstPedRun = kFALSE; 248 fIsNotPedRun = kFALSE; 249 return kTRUE; 226 250 } 227 228 // If this is the first call to ReInit (before reading the first file) 229 // nothing should be done 230 if (fIsFirstPedRun) 231 return kTRUE; 232 233 // In any other case some kind of finaliazation must be done 234 *fLog << inf << "Finalizing pedestal calculations..." << flush; 235 236 if (!Finalize()) 237 return kFALSE; 238 239 Reset(); 240 251 252 fIsNotPedRun = kTRUE; 253 // 254 // If this is the first call to ReInit (before reading the first file) 255 // nothing should be done. It occurs for the case that the first treated 256 // file is not of pedestal type. 257 // 258 if (fIsFirstPedRun) 241 259 return kTRUE; 260 261 // 262 // In the other case, produce the MPedestalCam to be use the subsequent (non-pedestal) events 263 // 264 *fLog << inf << "Finalizing pedestal calculations..." << flush; 265 266 if (!Finalize()) 267 return kFALSE; 268 269 Reset(); 270 271 return kTRUE; 242 272 } 243 273 … … 253 283 Int_t MPedCalcPedRun::Calc() 254 284 { 255 if (!IsPedBitSet()) 256 { 257 *fLog << err << GetDescriptor() << " - ERROR: IsPedBitSet() returned kFALSE... abort." << endl; 258 return kERROR; 259 } 260 261 if (fRunHeader->GetRunType() != MRawRunHeader::kRTPedestal) 262 return kTRUE; 263 285 286 if (fIsNotPedRun && !IsPedBitSet()) 287 return kTRUE; 288 289 // if (fUsedEvents == fNumEventsDump) 290 // { 291 // *fLog << endl; 292 // *fLog << inf << GetDescriptor() << " : Finalize pedestal calculations..." << flush; 293 // Finalize(); 294 // Reset(); 295 // } 296 264 297 fUsedEvents++; 265 298 … … 277 310 278 311 if (fExtractor) 279 312 CalcExtractor(pixel, sum, (*fPedestalsIn)[idx]); 280 313 else 281 314 CalcSums(pixel, sum, ab0, ab1); 282 315 283 316 fSumx[idx] += sum; … … 370 403 } 371 404 405 372 406 // -------------------------------------------------------------------------- 373 407 // … … 376 410 Int_t MPedCalcPedRun::Finalize() 377 411 { 378 if (fUsedEvents == 0) 379 return kTRUE; 380 381 MRawEvtPixelIter pixel(fRawEvt); 382 while (pixel.Next()) 383 CalcPixResults(fUsedEvents, pixel.GetPixelId()); 384 385 // 386 // Loop over the (two) area indices to get the averaged pedestal per aidx 387 // 388 for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++) 389 if (fAreaValid[aidx]>0) 390 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx); 391 392 // 393 // Loop over the (six) sector indices to get the averaged pedestal per sector 394 // 395 for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++) 396 if (fSectorValid[sector]>0) 397 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector); 398 399 fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize); 400 fPedestalsOut->SetReadyToSave(); 401 412 413 if (fUsedEvents == 0) 402 414 return kTRUE; 415 416 MRawEvtPixelIter pixel(fRawEvt); 417 while (pixel.Next()) 418 CalcPixResults(fUsedEvents, pixel.GetPixelId()); 419 420 // 421 // Loop over the (two) area indices to get the averaged pedestal per aidx 422 // 423 for (UInt_t aidx=0; aidx<fAreaValid.GetSize(); aidx++) 424 if (fAreaValid[aidx]>0) 425 CalcAreaResults(fUsedEvents, fAreaValid[aidx], aidx); 426 427 // 428 // Loop over the (six) sector indices to get the averaged pedestal per sector 429 // 430 for (UInt_t sector=0; sector<fSectorValid.GetSize(); sector++) 431 if (fSectorValid[sector]>0) 432 CalcSectorResults(fUsedEvents, fSectorValid[sector], sector); 433 434 fPedestalsOut->SetTotalEntries(fUsedEvents*fExtractWinSize); 435 fPedestalsOut->SetReadyToSave(); 436 437 return kTRUE; 403 438 } 404 439 405 440 Int_t MPedCalcPedRun::PostProcess() 406 441 { 407 408 409 410 442 if (!Finalize()) 443 return kFALSE; 444 445 return MExtractPedestal::PostProcess(); 411 446 } 412 447 … … 416 451 // The last but one bit is used for the "pedestal-bit". 417 452 // 418 // This bit is set since run gkFi nalizationTriggerBit453 // This bit is set since run gkFirstRunWithFinalBits 419 454 // 420 455 Bool_t MPedCalcPedRun::IsPedBitSet() 421 456 { 422 if (fRunHeader->GetRunNumber() == 38996) 423 return kTRUE; 424 425 if (fRunHeader->GetRunNumber() < gkFirstRunWithFinalBits) 426 return kTRUE; 427 428 return (fEvtHeader->GetTriggerID() & BIT(3)) ? kTRUE : kFALSE; 457 458 if (!fTrigPattern) 459 return kTRUE; 460 461 if (fRunHeader->GetRunNumber() < gkFirstRunWithFinalBits) 462 return kTRUE; 463 464 return (fTrigPattern->GetPrescaled() & MTriggerPattern::kPedestal) ? kTRUE : kFALSE; 429 465 } 430 466 431 467 void MPedCalcPedRun::Print(Option_t *o) const 432 468 { 469 433 470 MExtractPedestal::Print(o); 434 471 -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.h
r5715 r5848 6 6 #endif 7 7 8 class MTriggerPattern; 8 9 class MRawEvtPixelIter; 9 10 class MPedestalPix; … … 19 20 20 21 Bool_t fIsFirstPedRun; //! Flag to tell if the first run out of many is used 22 Bool_t fIsNotPedRun; //! Flag to tell if the current run is a pedestal run 21 23 ULong_t fUsedEvents; // Number of used (not skipped) events 24 25 MTriggerPattern *fTrigPattern; //! Trigger pattern decoded 22 26 23 27 Bool_t IsPedBitSet(); … … 36 40 37 41 void Print(Option_t *o="") const; 42 void Reset(); 43 38 44 Int_t Finalize(); 39 45
Note:
See TracChangeset
for help on using the changeset viewer.