Changeset 8571 for trunk/MagicSoft/Mars/mraw
- Timestamp:
- 06/17/07 15:51:55 (18 years ago)
- Location:
- trunk/MagicSoft/Mars/mraw
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r8364 r8571 47 47 // 48 48 // 49 // Version 7 50 // ------------------ 51 // + UShort_t fNumBytesPerSample; 52 // 49 53 // Version 6 50 54 // ------------------ … … 148 152 // value set so far. So we use the old methid to determin the 149 153 // numbers and calculate them from the length of the arrays. 150 return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/ fHiGainPixId->GetSize() : 0;154 return fHiGainPixId->GetSize() ? fHiGainFadcSamples->GetSize()/(fHiGainPixId->GetSize()*fNumBytesPerSample) : 0; 151 155 } 152 156 … … 160 164 // value set so far. So we use the old methid to determin the 161 165 // numbers and calculate them from the length of the arrays. 162 return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/ fLoGainPixId->GetSize() : 0;166 return fLoGainPixId->GetSize() ? fLoGainFadcSamples->GetSize()/(fLoGainPixId->GetSize()*fNumBytesPerSample) : 0; 163 167 } 164 168 … … 189 193 const UShort_t nLoSamp = GetNumLoGainSamples(); 190 194 195 const UShort_t bps = GetNumBytesPerSample(); 196 191 197 fLog->unsetf(ios::showbase); 192 198 … … 212 218 *fLog << (manip?dec:hex) << setfill(manip?' ':'0'); 213 219 214 const Byte_t *hi = pixel.GetHiGainSamples();215 const Byte_t *lo = pixel.GetLoGainSamples();216 217 for (int j=0; j<nHiSamp ; j++)220 const Byte_t *hi = (Byte_t*)pixel.GetHiGainSamples(); 221 const Byte_t *lo = (Byte_t*)pixel.GetLoGainSamples(); 222 223 for (int j=0; j<nHiSamp*bps; j++) 218 224 { 219 225 *fLog << setw(manip?3:2); 220 *fLog << ( (UShort_t)hi[j]&0xff);226 *fLog << (hi[j]&0xff); 221 227 if (manip) 222 228 *fLog << ' '; 223 229 } 224 230 225 for (int j=0; j<nLoSamp ; j++)231 for (int j=0; j<nLoSamp*bps; j++) 226 232 { 227 233 *fLog << setw(manip?3:2); … … 270 276 } 271 277 272 const Byte_t*higains = pix.GetHiGainSamples();273 const Byte_t*logains = pix.GetLoGainSamples();278 const void *higains = pix.GetHiGainSamples(); 279 const void *logains = pix.GetLoGainSamples(); 274 280 275 281 const Int_t nh = GetNumHiGainSamples(); … … 289 295 290 296 for (int i=0; i<nh; i++) 291 graphhi->SetPoint(graphhi->GetN(), i, higains[i]);297 graphhi->SetPoint(graphhi->GetN(), i, GetSample(higains, i)); 292 298 for (int i=0; i<nl; i++) 293 graphhi->SetPoint(graphhi->GetN(), i+nh, logains[i]);299 graphhi->SetPoint(graphhi->GetN(), i+nh, GetSample(logains, i)); 294 300 295 301 graphhi->SetMaximum(256); … … 321 327 histh->SetDirectory(NULL); 322 328 for (int i=0; i<nh; i++) 323 histh->Fill(i, higains[i]);329 histh->Fill(i, GetSample(higains, i)); 324 330 for (int i=0; i<nl; i++) 325 histh->Fill(i, logains[i]);331 histh->Fill(i, GetSample(logains, i)); 326 332 histh->SetBit(kCanDelete); 327 333 histh->Draw(same ? "same" : ""); … … 330 336 } 331 337 332 *fLog << warn << dbginf << "W arning- You must specify either 'GRAPH' or 'HIST'" << endl;338 *fLog << warn << dbginf << "WARNING - You must specify either 'GRAPH' or 'HIST'" << endl; 333 339 } 334 340 … … 341 347 { 342 348 // 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; 349 const Int_t numhi = fRunHeader ? fRunHeader->GetNumSamplesHiGain() : 0; 350 const Int_t numlo = fRunHeader ? fRunHeader->GetNumSamplesLoGain() : 0; 351 352 fNumBytesPerSample = fRunHeader ? fRunHeader->GetNumBytesPerSample() : 1; 345 353 346 354 fHiGainPixId = new MArrayS(numconnected); 347 355 fLoGainPixId = new MArrayS(0); 348 fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo) );356 fHiGainFadcSamples = new MArrayB(numconnected*(numhi+numlo)*fNumBytesPerSample); 349 357 fLoGainFadcSamples = new MArrayB(0); 350 358 … … 466 474 const UInt_t ns = fRunHeader->GetNumSamples(); 467 475 468 // position in higain array469 Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*ns;470 471 476 // bytes per sample 472 477 const Int_t bps = fRunHeader->GetNumBytesPerSample(); … … 475 480 const Int_t nb = ns*bps; 476 481 482 // position in higain array 483 Byte_t *pos = fHiGainFadcSamples->GetArray() + fConnectedPixels*nb; 484 477 485 // Set pixel index 478 486 fHiGainPixId->AddAt(npix, fConnectedPixels++); 479 487 480 488 // Read data for one pixel 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; 489 fin.read((char*)pos, nb); 493 490 } 494 491 -
trunk/MagicSoft/Mars/mraw/MRawEvtData.h
r8353 r8571 36 36 MArrayB *fABFlags; //-> A information about the exact trigger position 37 37 38 UShort_t fNumBytesPerSample; 39 38 40 Int_t fConnectedPixels; //! 39 41 … … 42 44 43 45 Int_t GetNumBytes() const; 46 47 UInt_t GetSample(const void *ptr, Int_t n) // Helper for Draw 48 { 49 switch (n) 50 { 51 case 1: return *(Byte_t*)ptr; 52 case 2: return *(UShort_t*)ptr; 53 case 3: return *(Int_t*)ptr; 54 } 55 return 0; 56 } 44 57 45 58 public: … … 68 81 UShort_t GetNumPixels() const; 69 82 83 UShort_t GetNumBytesPerSample() const { return fNumBytesPerSample; } 84 UInt_t GetScale() const { return 1<<((fNumBytesPerSample-1)*8); } 85 70 86 void ReadPixel(istream &fin, Int_t npix); 71 87 void SetABFlag(Int_t npix, Bool_t ab); … … 86 102 ; 87 103 88 ClassDef(MRawEvtData, 6) //Container to store the raw Event Data104 ClassDef(MRawEvtData, 7) //Container to store the raw Event Data 89 105 }; 90 106 -
trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc
r8364 r8571 63 63 MRawEvtPixelIter::MRawEvtPixelIter(MRawEvtData *dat) : fABFlags(0), fData(dat) 64 64 { 65 fNum HiGainSamples = dat->GetNumHiGainSamples();66 fNum LoGainSamples = dat->GetNumLoGainSamples();65 fNumBytesHiGain = dat->GetNumHiGainSamples()*dat->GetNumBytesPerSample(); 66 fNumBytesLoGain = dat->GetNumLoGainSamples()*dat->GetNumBytesPerSample(); 67 67 68 68 Reset(); … … 91 91 fNumHiGainEntry++; 92 92 fHiGainId++; 93 fHiGainPos += fNum HiGainSamples;93 fHiGainPos += fNumBytesHiGain; 94 94 95 95 fNumLoGainEntry++; 96 96 fLoGainId++; 97 fLoGainPos += fNum LoGainSamples;97 fLoGainPos += fNumBytesLoGain; 98 98 } 99 99 else … … 102 102 fLoGainId = ++fHiGainId; 103 103 104 fHiGainPos += fNum HiGainSamples+fNumLoGainSamples;105 fLoGainPos = fHiGainPos + fNum HiGainSamples;104 fHiGainPos += fNumBytesHiGain+fNumBytesLoGain; 105 fLoGainPos = fHiGainPos + fNumBytesHiGain; 106 106 } 107 107 … … 137 137 { 138 138 fLoGainId = fData->fLoGainPixId->GetArray(); 139 fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fNum HiGainSamples;140 fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fNum LoGainSamples;139 fHiGainPos = fData->fHiGainFadcSamples->GetArray()-fNumBytesHiGain; 140 fLoGainPos = fData->fLoGainFadcSamples->GetArray()-fNumBytesLoGain; 141 141 } 142 142 else 143 143 { 144 144 fLoGainId = fHiGainId; 145 fLoGainPos = fHiGainPos+fNum HiGainSamples;146 fHiGainPos = fData->fHiGainFadcSamples->GetArray()-(fNum HiGainSamples+fNumLoGainSamples);145 fLoGainPos = fHiGainPos+fNumBytesHiGain; 146 fHiGainPos = fData->fHiGainFadcSamples->GetArray()-(fNumBytesHiGain+fNumBytesLoGain); 147 147 } 148 148 … … 163 163 fData->Draw(Form("%s%d", t, *fHiGainId)); 164 164 } 165 166 /*167 // --------------------------------------------------------------------------168 //169 // Returns the index of the FADC slice the maximum signal in. If the highest170 // slices have the same value the first one is returned.171 //172 Byte_t MRawEvtPixelIter::GetIdxMaxHiGainSample(const Byte_t hifirst, const Byte_t hilast) const173 {174 const Int_t l = hilast>fNumHiGainSamples ? fNumHiGainSamples : hilast+1;175 176 Byte_t *beg = fHiGainPos+hifirst;177 178 Byte_t *ptr = beg+1;179 Byte_t *max = beg;180 const Byte_t *end = fHiGainPos + l;181 182 do if (*ptr>*max) max = ptr;183 while (++ptr != end);184 185 return max-fHiGainPos;186 }187 188 // --------------------------------------------------------------------------189 //190 // Returns the index of the FADC slice the maximum signal in. If no lo-gains191 // are available -1 is returned. If the highest slices have the same value192 // the first one is returned.193 //194 Short_t MRawEvtPixelIter::GetIdxMaxLoGainSample(const Byte_t lofirst, const Byte_t lolast) const195 {196 if (!HasLoGain())197 return -1; // means: not found198 199 const Int_t l = lolast>fNumLoGainSamples ? fNumLoGainSamples : lolast+1;200 201 Byte_t *beg = fLoGainPos+lofirst;202 203 Byte_t *ptr = beg+1;204 Byte_t *max = beg;205 const Byte_t *end = fLoGainPos + l;206 207 do if (*ptr>*max) max = ptr;208 while (++ptr != end);209 210 return max-fLoGainPos;211 }212 213 // --------------------------------------------------------------------------214 //215 // Returns the maximum signal of all sliced in the hi gain samples216 //217 Byte_t MRawEvtPixelIter::GetMaxHiGainSample(const Byte_t hifirst, const Byte_t hilast) const218 {219 Byte_t max = 0;220 221 const Int_t f = hifirst;222 const Int_t l = hilast>fNumHiGainSamples ? fNumHiGainSamples : hilast+1;223 224 for (int i=f; i<l; i++)225 if (fHiGainPos[i]>max)226 max = fHiGainPos[i];227 228 return max;229 }230 231 // --------------------------------------------------------------------------232 //233 // returns the sum of all hi gain fadc samples of the actual pixel234 //235 ULong_t MRawEvtPixelIter::GetSumHiGainSamples() const236 {237 //238 // return the sum of the hi gain samples of the present pixel239 //240 Byte_t *ptr = fHiGainPos;241 const Byte_t *end = fHiGainPos + fNumHiGainSamples;242 243 ULong_t sum=0;244 245 do sum += *ptr++;246 while (ptr != end);247 248 return sum;249 }250 251 // --------------------------------------------------------------------------252 //253 // returns the sum of squares of all hi gain fadc sample of the actual pixel254 //255 ULong_t MRawEvtPixelIter::GetSumSqrHiGainSamples() const256 {257 //258 // return the sum of the squares of the hi gain samples of the present pixel259 //260 Byte_t *ptr = fHiGainPos;261 const Byte_t *end = fHiGainPos + fNumHiGainSamples;262 263 ULong_t sum=0;264 265 do sum += (*ptr)*(*ptr);266 while (++ptr != end);267 268 return sum;269 }270 271 // --------------------------------------------------------------------------272 //273 // Returns the variance (sigma^2) of the HiGainSamples274 //275 Float_t MRawEvtPixelIter::GetVarHiGainSamples() const276 {277 Byte_t *ptr = fHiGainPos;278 const Byte_t *end = fHiGainPos + fNumHiGainSamples;279 280 ULong_t sum=0;281 ULong_t sqsum=0;282 283 do {284 sum += *ptr;285 sqsum += (*ptr)*(*ptr);286 } while (++ptr != end);287 288 return (sqsum-(Float_t)sum*sum/fNumHiGainSamples)/(fNumHiGainSamples-1);289 }290 291 // --------------------------------------------------------------------------292 //293 // Returns the index of the maximum FADC slice from high gain at first. If294 // high gain is saturated it returns the low gain one.295 // If no lo-gains are existing and the hi-gains have saturating values296 // a negative value (-1) is returned.297 //298 Short_t MRawEvtPixelIter::GetIdxMaxHiLoGainSample() const299 {300 Byte_t max = 0;301 Char_t maxi = 0;302 303 for (int i=fNumHiGainSamples-1; i>=0; i--)304 if (fHiGainPos[i]>max)305 {306 max = fHiGainPos[i];307 maxi = i;308 }309 310 return max<0xff ? maxi : GetIdxMaxLoGainSample();311 }312 313 // --------------------------------------------------------------------------314 //315 // Returns the maximum signal of all sliced in the hi gain samples316 //317 Byte_t MRawEvtPixelIter::GetMaxLoGainSample() const318 {319 Byte_t max = 0;320 321 for (int i=fNumLoGainSamples-1; i>=0; i--)322 if (fLoGainPos[i]>max)323 max = fLoGainPos[i];324 325 return max;326 }327 328 // --------------------------------------------------------------------------329 //330 // returns the sum of all lo gain fadc samples of the actual pixel.331 // if no lo gain information is available 0 is returned.332 //333 ULong_t MRawEvtPixelIter::GetSumLoGainSamples() const334 {335 //336 // return the sum of the lo gain samples of the present pixel337 //338 if (!HasLoGain())339 return 0;340 341 Byte_t *ptr = fLoGainPos;342 const Byte_t *end = fLoGainPos + fNumLoGainSamples;343 344 ULong_t sum=0;345 346 do sum += *ptr++;347 while (ptr != end);348 349 return sum;350 }351 352 // --------------------------------------------------------------------------353 //354 // returns the sum of squares of all hi gain fadc sample of the actual pixel355 //356 ULong_t MRawEvtPixelIter::GetSumSqrLoGainSamples() const357 {358 //359 // return the sum of the lo gain samples squares of the present pixel360 //361 if (!HasLoGain())362 return 0;363 364 Byte_t *ptr = fLoGainPos;365 const Byte_t *end = fLoGainPos + fNumLoGainSamples;366 367 ULong_t sum=0;368 369 do sum += (*ptr)*(*ptr);370 while (++ptr != end);371 372 return sum;373 }374 */ -
trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h
r8364 r8571 30 30 UShort_t fNumEntry; 31 31 32 Byte_t fNumHiGainSamples; //! 33 Byte_t fNumLoGainSamples; //! 32 Byte_t fNumBytesHiGain; //! 33 Byte_t fNumBytesLoGain; //! 34 35 UShort_t fNumBytesPerSample; //! 34 36 35 37 MRawEvtData *fData; //! pointer to object which we are iterating … … 66 68 } 67 69 68 Byte_t*GetHiGainSamples() const70 void *GetHiGainSamples() const 69 71 { 70 72 // … … 77 79 } 78 80 79 /* 80 This function is dangerous as long as MC with split hi-/lo-gain are used 81 Byte_t *GetSamples() const 82 { 83 // 84 // return a pointer to the fadc samples of the hi gains 85 // WARNING: Don't forget to get the number of valid entries 86 // (GetNumSamples) to know how many entries of the array 87 // belong to the actual pixel 88 // 89 return fHiGainPos; 90 } 91 */ 81 Byte_t GetNumBytes() const { return fNumBytesHiGain+fNumBytesLoGain; } 92 82 93 // Byte_t GetNumHiGainSamples() const { return fNumHiGainSamples ; }// Use is deprecated! 94 // Byte_t GetNumLoGainSamples() const { return fNumLoGainSamples ; }// Use is deprecated! 95 Byte_t GetNumSamples() const { return fNumHiGainSamples+fNumLoGainSamples; } 96 97 // Byte_t GetIdxMaxHiGainSample(const Byte_t hifirst=0, const Byte_t hilast=0xff) const; 98 // Short_t GetIdxMaxLoGainSample(const Byte_t lofirst=0, const Byte_t lolast=0xff) const; 99 100 // Byte_t GetMaxHiGainSample(const Byte_t hifirst=0, const Byte_t hilast=0xff) const; 101 102 // ULong_t GetSumHiGainSamples() const; 103 // ULong_t GetSumSqrHiGainSamples() const; 104 // Float_t GetVarHiGainSamples() const; 105 106 // Byte_t GetMaxLoGainSample() const; 107 // Short_t GetIdxMaxHiLoGainSample() const; 108 109 // ULong_t GetSumLoGainSamples() const; 110 // ULong_t GetSumSqrLoGainSamples() const; 111 112 Bool_t HasLoGain() const { return fNumLoGainSamples>0; } 83 Bool_t HasLoGain() const { return fNumBytesLoGain>0; } 113 84 Bool_t IsABFlagValid() const { return fABFlags ? kTRUE : kFALSE; } 114 85 Bool_t HasABFlag() const … … 127 98 } 128 99 129 Byte_t*GetLoGainSamples() const100 void *GetLoGainSamples() const 130 101 { 131 102 //
Note:
See TracChangeset
for help on using the changeset viewer.