///////////////////////////////////////////////////////// /// $Id: IMidasTripTHisto.cxx,v 1.3 2009/07/28 20:44:11 barr Exp $ /// /// Implement the COMET::IMidasTripTHisto class... #include "TString.h" #include "rawdpt_data_format.h" #include "ICOMETLog.hxx" #include "IMidasTripTHisto.hxx" #include "IDptByteEncode.hxx" #include "IMidasItr.cxx" template class COMET::IMidasItr; //_____________________________________________________________________________ void COMET::IMidasTripTHisto::Print(const Option_t* opt /* = "" */ ) const { // This was adapted from dptHistoManager which prints out bits of a line at a time.. const Int_t MAXLINE = 2000; Char_t line[MAXLINE]; Int_t nline = 0; Int_t zero=0; Int_t tval = 0; // Count the total in the histogram nline += snprintf(line+nline,MAXLINE-nline ,"%2d-%1d-%2.2d %4d",this->GetTFB(),this->GetTrip(),this->GetChan(),this->GetNBins()); if (nline >= MAXLINE) goto lineoverflow; if (fBinData == NULL) { nline += snprintf(line+nline,MAXLINE-nline," error-marker histogram"); goto endit; } // Loop over histogram bins for (UInt_t i = 0; iGetNBins(); i++) { UInt_t val = fBinData[i]; tval+=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; } } // 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; } nline += snprintf(line+nline,MAXLINE-nline, " nbins %d tval %d",this->GetNBins(),tval); if (nline >= MAXLINE) goto lineoverflow; // Print the line endit: if (nline) COMETLog(line); return; lineoverflow: line[MAXLINE-1]='\0'; // Terminate what we have COMETLog(line << "**line continues**"); return; }