Changeset 8353
- Timestamp:
- 03/02/07 12:15:34 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8347 r8353 19 19 -*-*- END OF LINE -*-*- 20 20 21 2007/03/02 Thomas Bretz 22 23 * mraw/MRawRunHeader.h: 24 - added GetNumBytesPerSample() member function 25 26 * mraw/MRawRead.cc: 27 - splitted ReadPixel and setting ab-flag into function calls 28 - fixed skipping pixels if bps>1 29 30 * mraw/MRawEvtData.[h,cc]: 31 - removed last argument from AddPixel 32 - split reading pixel data and setting ab-flag into two functions 33 - increased version number from 5 to 6 34 - adapted Print function 35 - adapted Draw function 36 - adapted ReadPixel function 37 38 39 21 40 2007/03/01 Thomas Bretz 22 41 … … 70 89 - according to this the lower signal limit has been decresed 71 90 by 15 91 - changed "saturation" limit accordingly from 254 to 245 92 93 * mpedestal/MPedestalsubtractedEvt.h: 94 - added a shortcut for GetSaturation 72 95 73 96 * mjobs/MJPedestal.cc: -
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r6253 r8353 18 18 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 47 47 // 48 48 // 49 // Version 6 50 // ------------------ 51 // - The data can now be stoe in a single array keeping he full 52 // compatibility 53 // 49 54 // Version 5 (0.8.5): 50 55 // ------------------ … … 68 73 // 69 74 ///////////////////////////////////////////////////////////////////////////// 70 71 75 #include "MRawEvtData.h" 72 76 … … 141 145 UShort_t MRawEvtData::GetNumHiGainSamples() const 142 146 { 147 // If value<0 we are reading old MC files which don't have the 148 // value set so far. So we use the old methid to determin the 149 // numbers and calculate them from the length of the arrays. 143 150 return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/fHiGainPixId->GetSize() : 0; 144 151 } … … 150 157 UShort_t MRawEvtData::GetNumLoGainSamples() const 151 158 { 159 // If value<0 we are reading old MC files which don't have the 160 // value set so far. So we use the old methid to determin the 161 // numbers and calculate them from the length of the arrays. 152 162 return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/fLoGainPixId->GetSize() : 0; 153 163 } … … 159 169 UShort_t MRawEvtData::GetNumPixels() const 160 170 { 161 return fHiGainPixId->GetSize(); 162 } 163 171 return fHiGainPixId ? fHiGainPixId->GetSize() : 0; 172 } 164 173 165 174 // -------------------------------------------------------------------------- … … 180 189 const UShort_t nLoSamp = GetNumLoGainSamples(); 181 190 182 const UShort_t nHiPix = fHiGainPixId->GetSize();;183 const UShort_t nLoPix = fLoGainPixId->GetSize();;184 185 191 fLog->unsetf(ios::showbase); 186 192 187 193 *fLog << dec << all; 188 194 *fLog << GetDescriptor() << ": " << endl; 189 *fLog << "HiGain: " << nHiPix << " Pixels with " << (Int_t)nHiSamp << " Samples" << endl; 190 *fLog << "LoGain: " << nLoPix << " Pixels with " << (Int_t)nLoSamp << " Samples"; 195 *fLog << GetNumPixels() << " Pixels with " << (Int_t)nHiSamp << "/" << (Int_t)nLoSamp << " samples" << endl; 191 196 192 197 TString str(opt); 193 198 Int_t manip = str.Contains("dec", TString::kIgnoreCase); 194 199 195 Int_t l=0;196 for (int i=0; i<nHiPix; i++)197 {198 const UShort_t idx = (*fHiGainPixId)[i];199 200 *fLog << endl; 201 *fLog << " " << setfill(' ') << setw(3) << dec << i << " - " << setw(3);202 *fLog << dec<< idx << " ";203 204 if ( fABFlags->GetSize())205 {206 *fLog << "<" << hex << setfill('0') << setw(2); 207 *fLog << ((Int_t)(*fABFlags)[idx/8]&0xff) << "> ";208 } 209 210 *fLog << (manip?dec:hex) << (manip ? setfill(' ') : setfill('0'));200 MRawEvtPixelIter pixel(const_cast<MRawEvtData*>(this)); 201 Int_t i = 0; 202 while (pixel.Next()) 203 { 204 const UShort_t idx = pixel.GetPixelId(); 205 206 *fLog << endl << dec << setfill(' '); 207 *fLog << " " << setw(3) << i++ << " - " << setw(3) << idx << " "; 208 209 if (pixel.IsABFlagValid()) 210 *fLog << "<" << (pixel.HasABFlag()?"B":"A") << "> "; 211 212 *fLog << (manip?dec:hex) << setfill(manip?' ':'0'); 213 214 const Byte_t *hi = pixel.GetHiGainSamples(); 215 const Byte_t *lo = pixel.GetLoGainSamples(); 211 216 212 217 for (int j=0; j<nHiSamp; j++) 213 218 { 214 219 *fLog << setw(manip?3:2); 215 *fLog << ((UShort_t) (*fHiGainFadcSamples)[j+i*nHiSamp]&0xff);220 *fLog << ((UShort_t)hi[j]&0xff); 216 221 if (manip) 217 222 *fLog << ' '; 218 223 } 219 224 220 if (!(l<nLoPix && (*fLoGainPixId)[l]==idx))221 continue;222 223 if (manip)224 *fLog << "/ ";225 226 225 for (int j=0; j<nLoSamp; j++) 227 226 { 228 227 *fLog << setw(manip?3:2); 229 *fLog << ((UShort_t) (*fLoGainFadcSamples)[j+i*nLoSamp]&0xff);228 *fLog << ((UShort_t)lo[j]&0xff); 230 229 if (manip) 231 230 *fLog << ' '; 232 231 } 233 l++; 234 } 235 *fLog << endl; 232 } 233 *fLog << dec << endl; 236 234 } 237 235 … … 292 290 for (int i=0; i<nh; i++) 293 291 graphhi->SetPoint(graphhi->GetN(), i, higains[i]); 292 for (int i=0; i<nl; i++) 293 graphhi->SetPoint(graphhi->GetN(), i+nh, logains[i]); 294 294 295 295 graphhi->SetMaximum(256); … … 305 305 histhi->SetXTitle("Time/FADC Slices"); 306 306 histhi->SetYTitle("Signal/FADC Units"); 307 308 if (nl>0)309 {310 TGraph *graphlo = new TGraph;311 312 for (int i=0; i<nl; i++)313 graphlo->SetPoint(graphlo->GetN(), i, logains[i]);314 315 graphlo->SetMaximum(256);316 graphlo->SetMinimum(0);317 graphlo->SetLineColor(kBlue);318 319 graphlo->SetBit(kCanDelete);320 graphlo->Draw("C*");321 322 TH1F *histlo = graphlo->GetHistogram();323 324 histlo->SetXTitle("Time/FADC Slices");325 histlo->SetYTitle("Signal/FADC Units");326 }327 307 328 308 return; … … 342 322 for (int i=0; i<nh; i++) 343 323 histh->Fill(i, higains[i]); 324 for (int i=0; i<nl; i++) 325 histh->Fill(i, logains[i]); 344 326 histh->SetBit(kCanDelete); 345 327 histh->Draw(same ? "same" : ""); 346 328 347 if (nl>0)348 {349 TH1F *histl = new TH1F(name+";2", "FADC Samples", nl, -0.5, nl-.5);350 histl->SetLineColor(kBlue);351 histl->SetDirectory(NULL);352 for (int i=0; i<nl; i++)353 histl->Fill(i, logains[i]);354 histl->SetBit(kCanDelete);355 histl->Draw("same");356 }357 329 return; 358 330 } … … 368 340 void MRawEvtData::InitArrays(UShort_t numconnected, UShort_t maxid) 369 341 { 370 const Int_t numhi = fRunHeader ? fRunHeader->GetNumSamplesHiGain() : 0; 371 const Int_t numlo = fRunHeader ? fRunHeader->GetNumSamplesLoGain() : 0; 342 // fRunHeader should not be set only in the constructor! 343 const Int_t numhi = fRunHeader ? fRunHeader->GetNumSamplesHiGain() : -1; 344 const Int_t numlo = fRunHeader ? fRunHeader->GetNumSamplesLoGain() : -1; 372 345 373 346 fHiGainPixId = new MArrayS(numconnected); 374 fLoGainPixId = new MArrayS( numconnected);375 fHiGainFadcSamples = new MArrayB(numconnected* numhi);376 fLoGainFadcSamples = new MArrayB( numconnected*numlo);347 fLoGainPixId = new MArrayS(0); 348 fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo)); 349 fLoGainFadcSamples = new MArrayB(0); 377 350 378 351 fABFlags = new MArrayB(maxid==0 ? 0 : maxid/8+1); … … 416 389 // This is to fill the data of one pixel to the MRawEvtHeader Class. 417 390 // The parameters are the pixelnumber and the FADC_SLICES values of ADCs 418 // Add to lo gains if lflag = 1 419 // 391 // 392 void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data) 393 { 394 const Int_t n = fRunHeader->GetNumSamples(); 395 if (data->GetSize()!=n) 396 { 397 *fLog << err << "RawEvtData::AddPixel: Error, number of samples in "; 398 *fLog << "TArrayC " << data->GetSize() << " doesn't match current number " << n << endl; 399 return; 400 } 401 402 // 403 // enhance pixel array by one 404 // 405 fHiGainPixId->Set(fHiGainPixId->GetSize()+1); 406 407 // 408 // add the number of the new pixel to the array as last entry 409 // 410 fHiGainPixId->AddAt(nOfPixel, fHiGainPixId->GetSize()-1); 411 412 // 413 // enhance the array by the number of new samples 414 // 415 fHiGainFadcSamples->Set(fHiGainFadcSamples->GetSize()+n); 416 417 // 418 // add the new slices as last entries to array 419 // 420 fHiGainFadcSamples->AddAt((Byte_t*)data->GetArray(), fHiGainFadcSamples->GetSize()-n, n); 421 } 422 /* 420 423 void MRawEvtData::AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag) 421 424 { … … 456 459 arrsam->AddAt((Byte_t*)data->GetArray(), arrsam->GetSize()-ns, ns); 457 460 } 458 459 void MRawEvtData::ReadPixel(istream &fin, Int_t npix, Bool_t ab) 460 { 461 Byte_t *poshi = fHiGainFadcSamples->GetArray() + fConnectedPixels*fRunHeader->GetNumSamplesHiGain(); 462 Byte_t *poslo = fLoGainFadcSamples->GetArray() + fConnectedPixels*fRunHeader->GetNumSamplesLoGain(); 461 */ 462 463 void MRawEvtData::ReadPixel(istream &fin, Int_t npix) 464 { 465 // number of samples 466 const UInt_t ns = fRunHeader->GetNumSamples(); 467 468 // position in higain array 469 Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*ns; 470 471 // bytes per sample 472 const Int_t bps = fRunHeader->GetNumBytesPerSample(); 473 474 // Number of bytes 475 const Int_t nb = ns*bps; 476 477 // Set pixel index 478 fHiGainPixId->AddAt(npix, fConnectedPixels++); 463 479 464 480 // Read data for one pixel 465 fin.read((char*)poshi, fRunHeader->GetNumSamplesHiGain()); 466 fHiGainPixId->AddAt(npix, fConnectedPixels); 467 468 if (poslo) 469 { 470 fin.read((char*)poslo, fRunHeader->GetNumSamplesLoGain()); 471 // FIXME: Not implemented in the raw files yet 472 //if (IsLoGainOn(i, j)) 473 //{ 474 fLoGainPixId->AddAt(npix, fConnectedPixels); 475 //} 476 } 477 481 if (bps==1) 482 { 483 fin.read((char*)pos, nb); 484 return; 485 } 486 487 // Read data for one pixel 488 Byte_t arr[nb]; 489 fin.read((char*)arr, nb); 490 491 for (Byte_t *p=arr+bps-1; p<arr+nb; p+=bps) 492 *pos++ = *p; 493 } 494 495 void MRawEvtData::SetABFlag(Int_t npix, Bool_t ab) 496 { 478 497 if (ab) 479 498 SETBIT((*fABFlags)[npix/8], npix%8); 480 499 else 481 500 CLRBIT((*fABFlags)[npix/8], npix%8); 482 483 fConnectedPixels++;484 501 } 485 502 -
trunk/MagicSoft/Mars/mraw/MRawEvtData.h
r5399 r8353 36 36 MArrayB *fABFlags; //-> A information about the exact trigger position 37 37 38 Int_t fConnectedPixels; //!38 Int_t fConnectedPixels; //! 39 39 40 40 void InitArrays(UShort_t numconnected=0, UShort_t maxid=0); … … 61 61 62 62 void ResetPixels(UShort_t npix, UShort_t maxid); 63 void AddPixel(UShort_t nOfPixel, TArrayC *data , Bool_t lflag=kFALSE);63 void AddPixel(UShort_t nOfPixel, TArrayC *data); 64 64 65 65 UShort_t GetNumHiGainSamples() const; 66 66 UShort_t GetNumLoGainSamples() const; 67 UInt_t GetNumSamples() const { return GetNumHiGainSamples()+GetNumLoGainSamples(); } 67 68 UShort_t GetNumPixels() const; 68 69 69 void ReadPixel(istream &fin, Int_t npix , Bool_t ab);70 //void ReadEvt(istream &fin, Int_t posinarray);70 void ReadPixel(istream &fin, Int_t npix); 71 void SetABFlag(Int_t npix, Bool_t ab); 71 72 void SkipEvt(istream &fin); 72 73 … … 85 86 ; 86 87 87 ClassDef(MRawEvtData, 5) //Container to store the raw Event Data88 ClassDef(MRawEvtData, 6) //Container to store the raw Event Data 88 89 }; 89 90
Note:
See TracChangeset
for help on using the changeset viewer.