int SIC::CompressRowGrey(uint8_t *linebuf,uint8_t *outbuf) { BitBuffer bitout(outbuf+4); bool runmode=false; int runlen=0; vector <int>rhist(256); for (int i=0;i<width;i++) { int x=linebuf[i]; int w=0,ww=0; if (i>0) w=linebuf[i-1]; if (i>1) ww=linebuf[i-2]; if (!runmode && w==ww) {runmode=1;runlen=0;}; if (!runmode) { EncodeVal(bitout,x,w); } else { if (x==w) runlen++; else { bitout.PutEliasGamma(runlen+1); if (runlen<256) rhist[runlen]++; EncodeVal(bitout,x,w); runmode=false; } } } /*for (int i=0;i<32;i++) cout << rhist[i] << " "; cout << endl;*/ if (runmode) bitout.PutEliasGamma(runlen+1); bitout.Flush(); Utils::Put32LH(outbuf,bitout.GetBytesProcessed()); return bitout.GetBytesProcessed()+4; }
void addTemplate(string procname, RooArgList& varlist, RooWorkspace& ws, TH1F* hist) { RooDataHist rhist(procname.c_str(), "", varlist, hist); ws.import(rhist); }