Changeset 8406 for trunk/MagicSoft/Mars/mmovie
- Timestamp:
- 04/15/07 10:38:08 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mmovie
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmovie/MMovieData.h
r8397 r8406 23 23 24 24 Float_t fMax; 25 Float_t fMedianPedestalRms; 25 26 UInt_t fNumSlices; 26 27 … … 41 42 Float_t GetMax() const { return fMax; } 42 43 44 void SetMedianPedestalRms(Float_t m) { fMedianPedestalRms = m; } 45 Float_t GetMedianPedestalRms() const { return fMedianPedestalRms; } 46 43 47 void SetNumSlices(UInt_t n) { fNumSlices=n; } 44 48 UInt_t GetNumSlices() const { return fNumSlices; } -
trunk/MagicSoft/Mars/mmovie/MMoviePrepare.cc
r8397 r8406 48 48 // MGeomCam 49 49 // MPedestalSubtractedEvt 50 // MPedestalFundamental [MPedestalCam] 50 51 // MCalibrateData 51 52 // MCalibrationRelTimeCam … … 70 71 #include "MGeomCam.h" 71 72 #include "MGeomPix.h" 73 74 #include "MPedestalCam.h" 75 #include "MPedestalPix.h" 76 72 77 73 78 #include "MCalibrationRelTimeCam.h" … … 78 83 #include "MRawRunHeader.h" 79 84 #include "MCalibrateData.h" 80 //#include "MExtractedSignalCam.h"81 85 #include "MPedestalSubtractedEvt.h" 82 86 … … 111 115 // MGeomCam 112 116 // MPedestalSubtractedEvt 117 // MPedestalFundamental [MPedestalCam] 113 118 // MCalibrateData 114 119 // MCalibrationRelTimeCam … … 132 137 return kFALSE; 133 138 } 139 fPed = (MPedestalCam*)plist->FindObject("MPedestalFundamental", "MPedestalCam"); 140 if (!fPed) 141 { 142 *fLog << err << "MPedestalFundamental [MPedestalCam] not found ... aborting." << endl; 143 return kFALSE; 144 } 134 145 fCal = (MCalibrateData*)plist->FindTaskListWithTask("MCalibrateData")->FindTask("MCalibrateData"); 135 146 if (!fCal) … … 184 195 const MArrayF &calco = fCal->GetCalibConsts(); 185 196 186 Int_t n = fCam->GetNumPixWithA rea(0);187 188 MArrayF calco0(n);197 Int_t n = fCam->GetNumPixWithAidx(0); 198 199 MArrayF arr(n); 189 200 190 201 for (UInt_t i=0; i<fCam->GetNumPixels(); i++) 191 202 if ((*fCam)[i].GetAidx()==0) 192 calco0[--n] = calco[i]; 193 194 return TMath::Median(calco0.GetSize(), calco0.GetArray()); 203 arr[--n] = calco[i]; 204 205 return TMath::Median(arr.GetSize(), arr.GetArray()); 206 } 207 208 // -------------------------------------------------------------------------- 209 // 210 // Return the median of the pedestal rms of all pixels with area index 0 211 // 212 Double_t MMoviePrepare::GetMedianPedestalRms() const 213 { 214 Int_t n = fCam->GetNumPixWithAidx(0); 215 216 MArrayF rms(n); 217 218 for (UInt_t i=0; i<fCam->GetNumPixels(); i++) 219 if ((*fCam)[i].GetAidx()==0) 220 rms[--n] = (*fPed)[i].GetPedestalRms(); 221 222 return TMath::Median(rms.GetSize(), rms.GetArray()); 195 223 } 196 224 … … 252 280 fOut->SetMax(max); 253 281 fOut->SetNumSlices(width); 282 fOut->SetMedianPedestalRms(GetMedianPedestalRms()); 254 283 255 284 return kTRUE; -
trunk/MagicSoft/Mars/mmovie/MMoviePrepare.h
r8397 r8406 9 9 class MExtractor; 10 10 class MMovieData; 11 class MSignalCam; 12 class MRawEvtHeader; 11 class MPedestalCam; 13 12 class MRawRunHeader; 14 13 class MCalibrateData; … … 24 23 MRawRunHeader *fRun; //! Run Header (sampling frequency) 25 24 MGeomCam *fCam; //! Pixel size 26 // MCalibConstCam *fCal; 25 MPedestalCam *fPed; //! Fundamental pedestal (slice by slice) 27 26 28 27 MMovieData *fOut; //! Prepared output container … … 31 30 UInt_t fLastSlice; 32 31 33 //Float_t fSlope;34 35 32 // MTask 36 33 Int_t PreProcess(MParList *plist); 37 //Bool_t ReInit(MParList *plist);38 34 Int_t Process(); 39 35 … … 43 39 // MMoviePrepare 44 40 Double_t GetMedianCalibConst() const; 41 Double_t GetMedianPedestalRms() const; 45 42 46 43 public: … … 53 50 54 51 #endif 55 -
trunk/MagicSoft/Mars/mmovie/MMovieWrite.cc
r8397 r8406 60 60 // 61 61 // The interpolation of the frames is done using a TSpline3. If the spline 62 // would extrapolate the contents is set to zero. Unsuitable pixels are 63 // interpolated frame by frame using the surrounding suitable pixels. 64 // 65 // 66 // Input: 67 // - MGeomCam 68 // - MRawRunHeader 69 // - MRawEvtHeader 70 // - MSignalCam 71 // - MBadPixelsCam 72 // - MPedestalFundamental [MPedestalCam] 73 // - MMovieData 62 // would extrapolate due to the shift by the relative time calibration the 63 // contents is set to zero. Unsuitable pixels are interpolated frame by 64 // frame using the surrounding suitable pixels. 65 // 66 // A few words about file size: MPEG is a motion compensation compression, 67 // which means that if a region of a past frame is shown again at the same 68 // place or somewhere else this region is referenced instead of encoded again. 69 // This means that in our case (almost all frames are identical!) the 70 // increase of file size is far from linear with the number of encoded events! 71 // 72 // 73 // Input: 74 // MGeomCam 75 // MRawRunHeader 76 // MRawEvtHeader 77 // MSignalCam 78 // MBadPixelsCam 79 // MMovieData 74 80 // 75 81 ///////////////////////////////////////////////////////////////////////////// … … 91 97 #include "MGeomCam.h" 92 98 #include "MGeomPix.h" 93 94 #include "MPedestalCam.h"95 #include "MPedestalPix.h"96 99 97 100 #include "MH.h" … … 117 120 // 118 121 MMovieWrite::MMovieWrite(const char *name, const char *title) 119 : fPipe(0), fTargetLength(5), fThreshold(2), fNumEvents( 1000), fFilename("movie.mpg")122 : fPipe(0), fTargetLength(5), fThreshold(2), fNumEvents(25000), fFilename("movie.mpg") 120 123 { 121 124 fName = name ? name : "MMovieWrite"; … … 172 175 173 176 fPipe = gSystem->OpenPipe(name, "w"); 174 if (fPipe) 175 return kTRUE; 176 177 *fLog << err; 178 *fLog << "Pipe: " << name << endl; 179 *fLog << "Couldn't open pipe... aborting." << endl; 180 CheckPipe(); 181 return kFALSE; 177 if (!fPipe) 178 { 179 *fLog << err; 180 *fLog << "Pipe: " << name << endl; 181 *fLog << "Couldn't open pipe... aborting." << endl; 182 CheckPipe(); 183 return kFALSE; 184 } 185 186 *fLog << inf << "Setup pipe to ppmtoy4m and mpeg2enc to encode " << fFilename << "." << endl; 187 188 return kTRUE; 182 189 183 190 // 1: 37M name += "-f 9 -E 40 -H -4 1 -2 1 --dualprime-mpeg2"; … … 229 236 // - MSignalCam 230 237 // - MBadPixelsCam 231 // - MPedestalFundamental [MPedestalCam]232 238 // - MMovieData 233 239 // … … 265 271 { 266 272 *fLog << err << "MBadPixelsCam not found ... aborting." << endl; 267 return kFALSE;268 }269 fPed = (MPedestalCam*)plist->FindObject("MPedestalFundamental", "MPedestalCam");270 if (!fPed)271 {272 *fLog << err << "MPedestalFundamental [MPedestalCam] not found ... aborting." << endl;273 273 return kFALSE; 274 274 } … … 317 317 // and everything above gets colors. 318 318 // 319 voidMMovieWrite::SetPalette(Double_t rms, const TH1 &h) const319 Int_t MMovieWrite::SetPalette(Double_t rms, const TH1 &h) const 320 320 { 321 321 const Double_t min = h.GetMinimum(); … … 335 335 336 336 TArrayI col(99); 337 gStyle->CreateGradientColorTable(6, s, r, g, b, col.GetSize()); 337 338 const Int_t rc = gStyle->CreateGradientColorTable(6, s, r, g, b, col.GetSize()); 338 339 339 340 // --- Overwrite the 'underflow' bin with white --- … … 347 348 348 349 gStyle->SetPalette(col.GetSize(), col.GetArray()); 350 351 return rc; 352 } 353 354 // -------------------------------------------------------------------------- 355 // 356 // The created colors are not overwritten and must be deleted manually 357 // because having more than 32768 color in a palette will crash 358 // gPad->PaintBox 359 // 360 void MMovieWrite::DeletePalette(Int_t colidx) const 361 { 362 for (int i=0; i<99; i++) 363 { 364 TColor *col = gROOT->GetColor(colidx+i); 365 if (col) 366 delete col; 367 } 349 368 } 350 369 … … 563 582 // -------------------------------------------------------------------------- 564 583 // 565 // Return the median of the pedestal rms of all pixels with area index 0566 //567 Double_t MMovieWrite::GetMedianPedestalRms() const568 {569 Int_t n = fCam->GetNumPixWithAidx(0);570 571 MArrayF rms(n);572 573 for (UInt_t i=0; i<fCam->GetNumPixels(); i++)574 if ((*fCam)[i].GetAidx()==0)575 rms[--n] = (*fPed)[i].GetPedestalRms();576 577 return TMath::Median(rms.GetSize(), rms.GetArray());578 }579 580 // --------------------------------------------------------------------------581 //582 584 Bool_t MMovieWrite::Process(TH1 &h, TVirtualPad &c) 583 585 { … … 589 591 //const Float_t len = (slices-2)/freq; // [ns] length of data stream in data-time 590 592 591 const Double_t rms = GetMedianPedestalRms();593 const Double_t rms = fIn->GetMedianPedestalRms(); 592 594 593 595 h.SetMinimum(fIn->GetMax()-(fIn->GetMax()-rms)*99/98); // rms0 … … 601 603 602 604 // Set new adapted palette for further rendering 603 SetPalette(rms, h);605 const Int_t colidx = SetPalette(rms, h); 604 606 605 607 // Get the pad containing the camera with the movie … … 638 640 return kFALSE; 639 641 } 642 643 DeletePalette(colidx); 640 644 641 645 cout << setw(3) << GetNumExecutions() << ": " << Form("%6.2f", (float)numframes/(slices-2)) << " f/sl " << slices << " " << numframes+1 << endl; -
trunk/MagicSoft/Mars/mmovie/MMovieWrite.h
r8397 r8406 54 54 void TreatBadPixels(TH1 &h) const; 55 55 56 void SetPalette(Double_t rms, const TH1 &h) const; 56 Int_t SetPalette(Double_t rms, const TH1 &h) const; 57 void DeletePalette(Int_t colidx) const; 57 58 58 59 void UpdateImage(TASImage &img, TVirtualPad &pad);
Note:
See TracChangeset
for help on using the changeset viewer.