///////////////////////////////////////////////////////// /// $Id: IMidasTripTOldHisto.cxx,v 1.2 2009/09/25 06:02:32 nickwest Exp $ /// /// Implement the COMET::IMidasTripTOldHisto class... // The ProHisto class is for the prototype histogram bank used in the first implementation // of the DPT. The ITripTHistoBank and IMidasTripTHisto banks are used for the new // version of the DPT (developed in July 2009, installed a month or two later). #include "TString.h" #include "rawdpt_data_format.h" #include "ICOMETLog.hxx" #include "IMidasTripTOldHisto.hxx" #include "IDptByteEncode.hxx" #include "IMidasItr.cxx" template class COMET::IMidasItr; //_____________________________________________________________________________ UInt_t COMET::IMidasTripTOldHisto::GetPedestal() const { IDptByteEncode e; // Normally, fEncoding != 0, so skip the first two words to be decoded, // that is the pedestal and the noise value determined online if (fSize != 0 && fEncoding != 0) { Int_t n = 0; // Count through the bytes we have used UInt_t pedestal; n += e.Decode(fData+n,pedestal); // Pedestal value return pedestal; } else { return 128; // Nominal online pedestal value } } //_____________________________________________________________________________ UInt_t COMET::IMidasTripTOldHisto::GetNoise() const { IDptByteEncode e; // Normally, fEncoding != 0, so skip the first two words to be decoded, // that is the pedestal and the noise value determined online if (fSize != 0 && fEncoding != 0) { Int_t n = 0; // Count through the bytes we have used UInt_t pedestal; UInt_t noise; n += e.Decode(fData+n,pedestal); // Pedestal value n += e.Decode(fData+n,noise); // Noise squared value return noise; } else { return 2*2; // Nominal online noise value (squared) } } //_____________________________________________________________________________ void COMET::IMidasTripTOldHisto::GetBinContents(UInt_t *c) const { // The user has been told to provide an array c[] with // at least 1024 words in it */ IDptByteEncode e; Int_t n = 0; // Count through the bytes we have used // Protect against fSize = 0 - just do nothing if (fSize == 0) return; // Normally, fEncoding != 0, so skip the first two words to be decoded, // that is the pedestal and the noise value determined online if (fEncoding != 0) { UInt_t dummy; n += e.Decode(fData+n,dummy); // Pedestal value n += e.Decode(fData+n,dummy); // Noise value } Int_t bin = 0; while (n 1) { nline += snprintf(line+nline,MAXLINE-nline ,"%2d-%1d-%2.2d %4d",fTfb,fTrip,fChan,fSize); if (nline >= MAXLINE) goto lineoverflow; Int_t zero=0; // Loop over histogram bins while (size>0) { UInt_t val; Int_t s = e.Decode(fData+nbuff,val); if (val == 0) { zero++; } else { if (zero != 0) { nline += snprintf(line+nline,MAXLINE-nline ,(zero==1)?" 0":" [%d*0]",zero); zero = 0; if (nline >= MAXLINE) goto lineoverflow; } nline += snprintf(line+nline,MAXLINE-nline," %d",val); if (nline >= MAXLINE) goto lineoverflow; } size -= s; nbuff += s; } // End of loop over elements of histogram if (zero != 0) { //Eject any final accumulated zeroes nline += snprintf(line+nline,MAXLINE-nline ,(zero==1)?" 0":" [%d*0]",zero); zero = 0; if (nline >= MAXLINE) goto lineoverflow; } if (size<0) { nline += snprintf(line+nline,MAXLINE-nline ,"**Decoder mismatch fSize %d size %d nbuf %d\n" ,fSize,size,nbuff); } // Zero histogram } else if (size == 1) { TString option = opt; option.ToLower(); if ( option.Contains("z") ) { nline += snprintf(line+nline,MAXLINE-nline ,"%2d-%1d-%2.2d %4d Zero-histogram",fTfb,fTrip,fChan,fSize); if (nline >= MAXLINE) goto lineoverflow; } // Something odd } else { nline += snprintf(line+nline,MAXLINE-nline ,"%2d-%1d-%2.2d %4d Something-odd-with-fSize",fTfb,fTrip,fChan,fSize); if (nline >= MAXLINE) goto lineoverflow; } // Print the line if (nline) COMETLog(line); return; lineoverflow: line[MAXLINE-1]='\0'; // Terminate what we have COMETLog(line << "**line continues**"); return; }