/* * Pack up more characters in this word */ static int Dpack(struct Strbuf *wbuf) { eChar c; for (;;) { c = DgetC(DODOL); if (c == '\\') { c = DgetC(0); if (c == DEOF) { unDredc(c); return 1; } if (c == '\n') c = ' '; else c |= QUOTE; } if (c == DEOF) { unDredc(c); return 1; } if (cmap(c, _SP | _NL | _QF | _QB)) { /* sp \t\n'"` */ unDgetC(c); if (cmap(c, QUOTES)) return 0; return 1; } Strbuf_append1(wbuf, (Char) c); } }
inline Optimizer* OptimizerRegistry::Find(const std::string& name) { MXNETCPP_REGISTER_OPTIMIZER(sgd, SGDOptimizer); MXNETCPP_REGISTER_OPTIMIZER(ccsgd, SGDOptimizer); // For backward compatibility MXNETCPP_REGISTER_OPTIMIZER(rmsprop, RMSPropOptimizer); MXNETCPP_REGISTER_OPTIMIZER(adam, AdamOptimizer); MXNETCPP_REGISTER_OPTIMIZER(adagrad, AdaGradOptimizer); MXNETCPP_REGISTER_OPTIMIZER(adadelta, AdaDeltaOptimizer); auto it = cmap().find(name); if (it == cmap().end()) return nullptr; return it->second(); }
static void Dtestq(int c) { if (cmap(c, QUOTES)) gflag = 1; }
int main (void) { enum { N = 20, L = 10, resolution = 600}; Matrix M = TestMatrix(N,N); Vector level(1,L); double mi = Min(M), ma = Max(M); for (int i = 1; i <= L; ++i) level[i] = mi + (i-1)*(ma-mi)/(L-1); level[4] = -3; level[5] = -2.5; cerr << mi << " " << ma << endl << level << endl; ColorMap cmap("spectral-256"); MpImage image(resolution,resolution); Scene scene(image); MpContourSurface(scene,M, M.Rlo(),M.Rhi(), M.Clo(),M.Chi(), level,cmap,Min(M),Max(M)); scene.LookFrom(Vector3D(100,50,-30)); // define the camera position scene.SetColoring(Scene::PerVertex); // coloring (GLobal/PerVertex/PerFacet) scene.SetGlobalShading(Facet::Flat); // shading (Constant/Flat/Gouraud/Phong) scene.SetGlobalEdgeLines(true); // edge lines (true/false) scene.Show(); // now start rendering of the surface MpFrame display("Contour",resolution+4,resolution+4); new MpScrollImageWindow(display,image,resolution+4,resolution+4); new MpQuitButton(display,"Quit",80,25,0,0); display.EventLoop(); }
static void Dtestq(Char c) { if (cmap(c, QUOTES)) gflag = 1; }
//----------------------------------------------------------------------------- void KBusyPtr :: loadCursor (const char* cursorName,const char* maskName) { int i, ix, iy, numX, numY, x, y; QBitmap map, mask; QBitmap cmap(16,16), cmask(16,16); numCursors = 0; if (!loadBitmap(map,cursorName)) return; if (!loadBitmap(mask,maskName)) return; numX = map.width() >> 4; numY = map.height() >> 4; numCursors = numX * numY; if (bitmapList) delete[] bitmapList; QSize size(16,16); bitmapList = new QBitmap[numCursors];//(size); if (cursorList) delete[] cursorList; cursorList = new QCursor[numCursors]; for (i=0,iy=0,y=0; iy<numY; iy++, y+=16) { for (ix=0,x=0; ix<numX; ix++, x+=16, i++) { bitBlt(&cmap, 0, 0, &map, x, y, 16, 16); bitBlt(&cmask, 0, 0, &mask, x, y, 16, 16); cursorList[i] = QCursor(cmap, cmask, 8, 8); } } }
void charToNetworkMap (wireworld_message_t * networkMap, char * charMap, uint32_t width, uint32_t height, uint32_t xs, uint32_t ys, uint32_t xe, uint32_t ye) { (void) height; // iterators uint32_t messageIndex = 0; int bitIndex = 0; uint32_t i, j; networkMap[0] = 0; for (j = ys; j < ye; ++j) { for (i = xs; i < xe ; ++i) { // Set value networkMap[messageIndex] |= *cmap (charMap, i, j, width) << (C_BIT_SIZE * bitIndex); // Update counters, and init next word bitIndex++; if (bitIndex == M_BIT_SIZE / C_BIT_SIZE) { messageIndex++; networkMap[messageIndex] = 0; bitIndex = 0; } } } }
/****************************************************************************** * public メソッド *****************************************************************************/ UploaderConfig *CGIConfigReader::read(apr_pool_t *pool, const char *conf_file_path) { UploaderConfig *config; APR_PCALLOC(config, UploaderConfig *, pool, sizeof(UploaderConfig)); new(config) UploaderConfig(pool); std::auto_ptr<ConfigReader::config_map> cmap(ConfigReader::read(pool, conf_file_path)); for (ConfigReader::config_map::const_iterator i = cmap.get()->begin(); i != cmap.get()->end(); i++) { SET_STR_PARAM(BASE_URL, base_url); SET_STR_PARAM(DATA_DIRECTORY, data_dir_path); SET_STR_PARAM(FILE_DIRECTORY, file_dir_path); SET_STR_PARAM(THUMB_DIRECTORY, thumb_dir_path); SET_STR_PARAM(TEMP_DIRECTORY, temp_dir_path); SET_INT64_PARAM(TOTAL_FILE_SIZE, total_file_size_limit); SET_INT_PARAM(TOTAL_FILE_NUMBER, total_file_number_limit); SET_INT64_PARAM(FILE_SIZE_LIMIT, file_size_limit); SET_INT_PARAM(PER_PAGE_ITEM_NUMBER, per_page_item_number); SET_TMPL_PARAM(INDEX_VIEW_TEMPLATE, INDEX_VIEW); SET_TMPL_PARAM(PROGRESS_VIEW_TEMPLATE, PROGRESS_VIEW); SET_TMPL_PARAM(DOWNLOAD_VIEW_TEMPLATE, DOWNLOAD_VIEW); SET_TMPL_PARAM(THUMBNAIL_VIEW_TEMPLATE, THUMBNAIL_VIEW); SET_TMPL_PARAM(ADMIN_VIEW_TEMPLATE, ADMIN_VIEW); SET_TMPL_PARAM(ERROR_VIEW_TEMPLATE, ERROR_VIEW); } config->init(); return config; }
void proba::on_pushButton_clicked() { //Leemos el texto QString texto = ui->plainTextEdit->toPlainText(); QByteArray bytes = texto.toAscii(); char* frase = bytes.data(); int lon = strlen(frase); if(lon==0) this->close(); if(aprox == 4) { cmap(words, texto, lon); this->close(); } if(aprox == 1) { cuno(probabilidades, texto, lon); this->close(); } if(aprox == 2) { cdos(probabilidades, texto, lon); this->close(); } }
void MainWindow::loadColormaps() { QSettings settings; if ( settings.contains( "colormaps" ) ) { qDebug() << "restore colormaps"; QByteArray ar = settings.value( "colormaps" ).toByteArray(); QDataStream in( &ar,QIODevice::ReadOnly ); int countColormaps; in >> countColormaps; for ( int i = 0; i < countColormaps; ++i ) { QString name; QVector< ColormapPair >values; in >> name; int cmapSize; in >> cmapSize; for ( int k = 0; k < cmapSize; ++k) { ColormapPair pair; in >> pair.value; in >> pair.color; values.push_back( pair ); } ColormapBase cmap( name, values ); ColormapFunctions::addColormap( cmap ); } }
const Char * quote_meta(struct Strbuf *buf, const Char *s) { buf->len = 0; while (*s != '\0') { if (cmap(*s, _META | _DOL | _QF | _QB | _ESC | _GLOB)) Strbuf_append1(buf, '\\'); Strbuf_append1(buf, *s++); } Strbuf_terminate(buf); return buf->s; }
void ExtractEdges::calculate_colors( const kvs::VolumeObjectBase* volume ) { const T* value = reinterpret_cast<const T*>( volume->values().data() ); const T* const end = value + volume->values().size(); kvs::ValueArray<kvs::UInt8> colors( 3 * volume->numberOfNodes() ); kvs::UInt8* color = colors.data(); kvs::ColorMap cmap( BaseClass::colorMap() ); if ( !volume->hasMinMaxValues() ) { volume->updateMinMaxValues(); } const kvs::Real64 min_value = volume->minValue(); const kvs::Real64 max_value = volume->maxValue(); const kvs::Real64 normalize_factor = static_cast<kvs::Real64>( cmap.resolution() - 1 ) / ( max_value - min_value ); const size_t veclen = BaseClass::volume()->veclen(); if ( veclen == 1 ) { while ( value < end ) { const kvs::UInt32 color_level = static_cast<kvs::UInt32>( normalize_factor * ( static_cast<kvs::Real64>( *( value++ ) ) - min_value ) ); *( color++ ) = cmap[ color_level ].r(); *( color++ ) = cmap[ color_level ].g(); *( color++ ) = cmap[ color_level ].b(); } } else { while( value < end ) { kvs::Real64 magnitude = 0.0; for ( size_t i = 0; i < veclen; ++i ) { magnitude += kvs::Math::Square( static_cast<kvs::Real64>( *value ) ); ++value; } magnitude = std::sqrt( magnitude ); const kvs::UInt32 color_level = static_cast<kvs::UInt32>( normalize_factor * ( magnitude - min_value ) ); *( color++ ) = cmap[ color_level ].r(); *( color++ ) = cmap[ color_level ].g(); *( color++ ) = cmap[ color_level ].b(); } } SuperClass::setColors( colors ); }
void plot(const char * fname, grid2D< > & G1, grid2D< > & G2, ml_color (*cmap)(double, double ) ) { plot2D plot(G1.a1,G1.b1,G1.a2,G1.b2, G1.n1,G1.n2); for (int i = 0; i<plot.NX; i++) for (int j = 0; j<plot.NY; j++) { plot.set_px(i,j, cmap(G1(i,j),G2(i,j)) ); } plot.png(fname); }
/* * Pack up more characters in this word */ static Char * Dpack(Char *wbuf, Char *wp) { int c; int i = MAXWLEN - (wp - wbuf); for (;;) { c = DgetC(DODOL); if (c == '\\') { c = DgetC(0); if (c == DEOF) { unDredc(c); *wp = 0; Gcat(STRNULL, wbuf); return (NULL); } if (c == '\n') c = ' '; else c |= QUOTE; } if (c == DEOF) { unDredc(c); *wp = 0; Gcat(STRNULL, wbuf); return (NULL); } if (cmap(c, _SP | _NL | _QF | _QB)) { /* sp \t\n'"` */ unDgetC(c); if (cmap(c, QUOTES)) return (wp); *wp++ = 0; Gcat(STRNULL, wbuf); return (NULL); } if (--i <= 0) stderror(ERR_WTOOLONG); *wp++ = c; } }
/* * Get a character, performing $ substitution unless flag is 0. * Any QUOTES character which is returned from a $ expansion is * QUOTEd so that it will not be recognized above. */ int DgetC(int flag) { int c; top: if (c = Dpeekc) { Dpeekc = 0; return (c); } if (lap) { c = *lap++ & (QUOTE|TRIM); if (c == 0) { lap = 0; goto top; } quotspec: /* * don't quote things if there was an error (err!=0) * the input is original, not from a substitution and * therefore should not be quoted */ if (!err && cmap(c, QUOTES)) return (c | QUOTE); return (c); } if (dolp) { if (c = *dolp++ & (QUOTE|TRIM)) goto quotspec; if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; return (' '); } dolp = 0; } if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; goto top; } c = Dredc(); if (c == '$' && flag) { Dgetdol(); goto top; } return (c); }
/* * Get a character, performing $ substitution unless flag is 0. * Any QUOTES character which is returned from a $ expansion is * QUOTEd so that it will not be recognized above. */ static int DgetC(int flag) { int c; top: if ((c = Dpeekc) != '\0') { Dpeekc = 0; return (c); } if (lap) { c = *lap++ & (QUOTE | TRIM); if (c == 0) { lap = 0; goto top; } quotspec: if (cmap(c, QUOTES)) return (c | QUOTE); return (c); } if (dolp) { if ((c = *dolp++ & (QUOTE | TRIM)) != '\0') goto quotspec; if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; return (' '); } dolp = 0; } if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; goto top; } c = Dredc(); if (c == '$' && flag) { Dgetdol(); goto top; } return (c); }
/* * Fix up the $ expansions and quotations in the * argument list to command t. */ void Dfix(struct command *t) { Char **pp; Char *p; if (noexec) return; /* Note that t_dcom isn't trimmed thus !...:q's aren't lost */ for (pp = t->t_dcom; (p = *pp++) != NULL;) for (; *p; p++) { if (cmap(*p, _DOL | QUOTES)) { /* $, \, ', ", ` */ Dfix2(t->t_dcom); /* found one */ blkfree(t->t_dcom); t->t_dcom = gargv; gargv = 0; return; } } }
/* * Get a character, performing $ substitution unless flag is 0. * Any QUOTES character which is returned from a $ expansion is * QUOTEd so that it will not be recognized above. */ static eChar DgetC(int flag) { eChar c; top: if ((c = Dpeekc) != 0) { Dpeekc = 0; return (c); } if (lap < labuf.len) { c = labuf.s[lap++] & (QUOTE | TRIM); quotspec: if (cmap(c, QUOTES)) return (c | QUOTE); return (c); } if (dolp) { if ((c = *dolp++ & (QUOTE | TRIM)) != 0) goto quotspec; if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; return (' '); } dolp = 0; } if (dolcnt > 0) { setDolp(*dolnxt++); --dolcnt; goto top; } c = Dredc(); if (c == '$' && flag) { Dgetdol(); goto top; } return (c); }
/* * Fix up the $ expansions and quotations in the * argument list to command t. */ void Dfix(struct command *t) { tchar **pp; tchar *p; #ifdef TRACE tprintf("TRACE- Dfix()\n"); #endif if (noexec) return; /* Note that t_dcom isn't trimmed thus !...:q's aren't lost */ for (pp = t->t_dcom; p = *pp++; ) while (*p) if (cmap(*p++, _DOL|QUOTES)) { /* $, \, ', ", ` */ Dfix2(t->t_dcom); /* found one */ blkfree(t->t_dcom); t->t_dcom = gargv; gargv = 0; return; } }
bool IdentifyLiaisonTunnel::doILT3( EdgeArray& edges ) { if( !isInitNetworkOk() ) return false; if( airEdges.isEmpty() ) return false; NodeFilter nf( dg, true ); BuildNodeFilter( dg, airEdges, sn, tn, nf ); double st = Timer::rdtscSeconds(); double et = Timer::rdtscSeconds(); acutPrintf( _T( "\n过滤阻断分支耗费时间:%.5f" ), et - st ); IntMap cmap( dg ); Init_CMap( dg, cmap ); st = Timer::rdtscSeconds(); // 对用风地点按距离进行排序 EdgeArray sortedAirEdges; SortAirEdges( dg, ef, sn, tn, airEdges, sortedAirEdges ); et = Timer::rdtscSeconds(); acutPrintf( _T( "\n对用风地点按距离排序耗费时间:%.5f" ), et - st ); ILT_Helper( dg, datas, ef, nf, sortedAirEdges, cmap ); st = Timer::rdtscSeconds(); // 查找联络巷 FindILTEdges( dg, datas, cmap, edges ); et = Timer::rdtscSeconds(); acutPrintf( _T( "\n查找联络巷耗费时间:%.5f" ), et - st ); return true; }
/* Save the two dimensional array as a png image * Arguments: * double *data is a pointer to an array of nx*ny values * int nx is the number of COLUMNS to be written * int ny is the number of ROWS to be written * char *fname is the name of the picture * char lang is either 'c' or 'f' denoting the memory * layout. That is, if 'f' is given, then rows * and columns are swapped. */ int save_png(double *data, const int height, const int width, const char *fname, const char lang) { FILE *fp; png_structp pngstruct_ptr = NULL; png_infop pnginfo_ptr = NULL; png_byte **row_pointers = NULL; int i, j; /* Default return status is failure */ int status = -1; int pixel_size = 3; int depth = 8; fp = fopen(fname, "wb"); if (fp == NULL) goto fopen_failed; pngstruct_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (pngstruct_ptr == NULL) goto pngstruct_create_failed; pnginfo_ptr = png_create_info_struct(pngstruct_ptr); if (pnginfo_ptr == NULL) goto pnginfo_create_failed; if (setjmp(png_jmpbuf(pngstruct_ptr))) goto setjmp_failed; png_set_IHDR(pngstruct_ptr, pnginfo_ptr, (size_t) width, (size_t) height, depth, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); row_pointers = png_malloc(pngstruct_ptr, height * sizeof(png_byte *)); for (i = 0; i < height; i++) { png_byte *row = png_malloc(pngstruct_ptr, sizeof(uint8_t) * width * pixel_size); row_pointers[i] = row; // Branch according to the memory layout if (lang == 'c' || lang == 'C') { for (j = 0; j < width; j++) { pixel_t pixel; // Scale the values so that values between // 0 and 100 degrees are mapped to values // between 0 and 255 cmap(data[j + i * width], 2.55, 0.0, &pixel); *row++ = pixel.red; *row++ = pixel.green; *row++ = pixel.blue; } } else { for (j = 0; j < width; j++) { pixel_t pixel; // Scale the values so that values between // 0 and 100 degrees are mapped to values // between 0 and 255 cmap(data[i + j * height], 2.55, 0.0, &pixel); *row++ = pixel.red; *row++ = pixel.green; *row++ = pixel.blue; } } } png_init_io(pngstruct_ptr, fp); png_set_rows(pngstruct_ptr, pnginfo_ptr, row_pointers); png_write_png(pngstruct_ptr, pnginfo_ptr, PNG_TRANSFORM_IDENTITY, NULL); status = 0; for (i = 0; i < height; i++) { png_free(pngstruct_ptr, row_pointers[i]); } png_free(pngstruct_ptr, row_pointers); setjmp_failed: pnginfo_create_failed: png_destroy_write_struct(&pngstruct_ptr, &pnginfo_ptr); pngstruct_create_failed: fclose(fp); fopen_failed: return status; }
/* * Get a word. This routine is analogous to the routine * word() in sh.lex.c for the main lexical input. One difference * here is that we don't get a newline to terminate our expansion. * Rather, DgetC will return a DEOF when we hit the end-of-input. */ int Dword(void) { int c, c1; static tchar *wbuf = NULL; static int wbufsiz = BUFSIZ; int wp = 0; bool dolflg; bool sofar = 0; #define DYNAMICBUFFER() \ do { \ if (wp >= wbufsiz) { \ wbufsiz += BUFSIZ; \ wbuf = xrealloc(wbuf, (wbufsiz+1) * sizeof (tchar)); \ } \ } while (0) #ifdef TRACE tprintf("TRACE- Dword()\n"); #endif if (wbuf == NULL) wbuf = xalloc((wbufsiz+1) * sizeof (tchar)); loop: c = DgetC(DODOL); switch (c) { case DEOF: deof: if (sofar == 0) return (0); /* finish this word and catch the code above the next time */ unDredc(c); /* fall into ... */ case '\n': wbuf[wp] = 0; goto ret; case ' ': case '\t': goto loop; case '`': /* We preserve ` quotations which are done yet later */ wbuf[wp++] = c; case '\'': case '"': /* * Note that DgetC never returns a QUOTES character * from an expansion, so only true input quotes will * get us here or out. */ c1 = c; dolflg = c1 == '"' ? DODOL : 0; for (;;) { c = DgetC(dolflg); if (c == c1) break; if (c == '\n' || c == DEOF) error("Unmatched %c", (tchar) c1); if ((c & (QUOTE|TRIM)) == ('\n' | QUOTE)) --wp; DYNAMICBUFFER(); switch (c1) { case '"': /* * Leave any `s alone for later. * Other chars are all quoted, thus `...` * can tell it was within "...". */ wbuf[wp++] = c == '`' ? '`' : c | QUOTE; break; case '\'': /* Prevent all further interpretation */ wbuf[wp++] = c | QUOTE; break; case '`': /* Leave all text alone for later */ wbuf[wp++] = c; break; } } if (c1 == '`') { DYNAMICBUFFER(); wbuf[wp++] = '`'; } goto pack; /* continue the word */ case '\\': c = DgetC(0); /* No $ subst! */ if (c == '\n' || c == DEOF) goto loop; c |= QUOTE; break; #ifdef MBCHAR /* Could be a space char from aux. codeset. */ default: if (isauxsp(c)) goto loop; #endif /* MBCHAR */ } unDgetC(c); pack: sofar = 1; /* pack up more characters in this word */ for (;;) { c = DgetC(DODOL); if (c == '\\') { c = DgetC(0); if (c == DEOF) goto deof; if (c == '\n') c = ' '; else c |= QUOTE; } if (c == DEOF) goto deof; if (cmap(c, _SP|_NL|_Q|_Q1) || isauxsp(c)) { /* sp \t\n'"` or aux. sp */ unDgetC(c); if (cmap(c, QUOTES)) goto loop; DYNAMICBUFFER(); wbuf[wp++] = 0; goto ret; } DYNAMICBUFFER(); wbuf[wp++] = c; } ret: Gcat(S_ /* "" */, wbuf); return (1); }
icycle() { int op,a1,a2,x1,x2,i1,i2,setting,setmask,onemask,oldmask; int ecd; /* Error Code */ /* setjmp(svstck) to save stack for return */ /* from possible segment and page faults */ if((ecd=setjmp(svstck)) != 0) { goto except; } ir = pm[cmap(pc)]; pc++; /* extract instruction fields into op, a1, a2; */ /* generate the eff. virtual addresses v1, v2 */ /* using the algorithm in the Reference Manual */ op = extract(ir,24,6); a1 = extract(ir,12,10); a2 = extract(ir,0,10); x1 = extract(ir,22,1); x2 = extract(ir,10,1); i1 = extract(ir,23,1); i2 = extract(ir,11,1); v1 = a1; v2 = a2; /* address field forms initial value */ if (i1 == 1) v1 = pm[dmap(v1)]; /* if indirection, get ind. loc */ if (i2 == 1) v2 = pm[dmap(v2)]; if (x1 == 1) v1 = v1 + xr; /* if indexing specified, add xr */ if (x2 == 1) v2 = v2 + xr; switch(op) { case 1: gr = pm[dmap(v1)]; /* gr load */ break; case 2: pm[dmap(v1)] = gr; /* gr store */ break; case 3: xr = pm[dmap(v1)]; /* xr load */ break; case 4: pm[dmap(v1)] = xr; /* xr store */ break; case 5: sr = pm[dmap(v1)]; /* sr load */ break; case 6: pm[dmap(v1)] = sr; /* sr store */ break; case 8: pm[dmap(v2)] = pm[dmap(v1)]; /* copy */ break; case 9: pm[dmap(v2)] += pm[dmap(v1)]; /* add */ break; case 10: pm[dmap(v2)] -= pm[dmap(v1)]; /* subtract */ break; case 11: pm[dmap(v2)] *= pm[dmap(v1)]; /* multiply */ break; case 12: /* Divide */ if (pm[dmap(v1)] == 0) { ecd = ARITFLT; printf ("\nDivide Fault\n"); goto except; } else pm[dmap(v2)] /= pm[dmap(v1)]; break; case 13: pm[dmap(v2)] &= pm[dmap(v1)]; /* and */ break; case 14: pm[dmap(v2)] |= pm[dmap(v1)]; /* or */ break; case 16: pc = v1; /* go to */ break; case 17: if (pm[dmap(v1)] != pm[dmap(v2)]) pc++; /* if = */ break; case 18: if (pm[dmap(v1)] == pm[dmap(v2)]) pc++; /* if != */ break; case 19: if (pm[dmap(v1)] >= pm[dmap(v2)]) pc++; /* if < */ break; case 20: if (pm[dmap(v1)] < pm[dmap(v2)]) pc++; /* if >= */ break; case 21: xr++; /* loop */ if (xr < pm[dmap(v1)]) pc = v2; break; case 22: sr = pc; pc = v1; /* call */ break; case 23: pc = sr + pm[dmap(v1)]; /* return */ break; case 26: xr = v1; /* xr set */ break; case 27: pm[dmap(v2)] = v1; /* vm set */ break; case 28: pm[dmap(v2)] = extract(pm[dmap(v1 + gr/4)],(gr%4)*8,8); /* get byte */ break; case 29: setting = extract(pm[dmap(v2)],0, 8); /* set byte */ /* Byte want to set in pos with 0s other */ setmask = setting << (gr%4)*8; onemask = 0xFFFFFFFF - (0xFF << (gr%4) * 8); /* mask with ones 'cept 0's in pos. */ oldmask = pm[dmap(v1+(gr/4))] & onemask; /* old value of word with 0's in pos */ pm[dmap(v1+(gr/4))] = oldmask | setmask; /* new word to write to memory */ break; case 31: ; /* noop */ break; case 32: hlt = TRUE; /* halt */ break; case 33: /* error */ hlt = TRUE; /* A1 serves as error code */ printf("\n ERROR: %x\n",a1); break; case 34: /* PmVmCp -- Primary Mem V Mem copy */ if (md < 0) goto illins; pm [dmap(v2)] = pm [v1]; break; case 35: /* VmPmCp */ if (md < 0) goto illins; pm [v2] = pm[dmap(v1)]; break; case 36: /* Arm */ if (md < 0) goto illins; ar |= pm [dmap(v1)]; break; case 37: /* Disarm */ if (md < 0) goto illins; ar &= (-1-pm[dmap(v1)]); break; case 38: /* OS Call */ if (md > 0) goto illins; ie |= EBIT; /* set exception */ pm [sp+PSR_ECD] = a1; /* OS Call Number */ break; case 40: /* Floppy IO */ if (md < 0) goto illins; if (pm[LCL_FCP] < 0) { hlt = TRUE; break; } floppy_io (); break; case 41: /* Disk IO */ if (md < 0) goto illins; if (pm[LCL_DCP] < 0) { hlt = TRUE; break; } disk_io (); break; case 42: /* Print IO */ /* Advance one line and printf pm[v1] */ if (md < 0) goto illins; fprintf (printer,"\t%s\t%8x\n",LP_STR,pm[v1]); fflush(printer); break; case 43: /* Log */ if (md < 0) goto illins; log (v1, v2); break; /* Cases 44 and 45 not written yet */ case 44: /* TTY IN */ if (md < 0) goto illins; break; case 45: /* TTY Out */ if (md < 0) goto illins; break; /*********************************************/ case 48: /* Head Record */ if (moverec(v1,v2,pm[dmap(v1)])) pc++; break; case 49: /* Move Record */ if (moverec (v1, v2, xr)) pc++; break; case 50: /* Insert Record */ if (xr < 0) break; insrec (v1, pm[dmap(v2)], xr); pc++; break; case 51: /* Find Record */ while (((pm[dmap(v1)+1] & pm[dmap(v2)]) != gr) && (pm[dmap(v1)] > 0)) { v1 = pm[dmap(v1)]; } if ((pm[dmap(v1)+1] & pm[dmap(v2)]) == gr) { xr = v1; pc++; } break; case 53: /* Allocate */ if (allocate(v1,v2,gr)) pc++; break; case 54: /* DeAllocate */ if (deallocate(v1,v2,gr)) pc++; break; case 56: /* SP Load */ if (md < 0) goto illins; sp = pm [dmap(v1)]; break; case 57: /* Switch Process */ if (md < 0) goto illins; swcontxt (v1, v2); break; case 60: /* Send Message */ if (md < 0) goto illins; if (pm [LCL_MSF] > 0) send_mesg (); break; case 61: /* Receive Message */ if (md < 0) goto illins; if (pm[dmap(sp + PSR_MSQ)] > 0) recv_mesg (); else { /* reset M bit and switch to scheduler */ pc--; pm[dmap(sp + PSR_STW)] |= MBIT; swcontxt (pm[LCL_SCH], pc); } break; default: hlt = TRUE; /* Unused Op */ break; } /* End Case */ goto realtm ; /* Ready for real time section */ /* Real Time Code */ realtm: pm [LCL_TOD]++; /* Increment Time of Day */ pm [LCL_ALM]++; /* Increment Alarm */ if (pm [LCL_ALM] == 0) ie |= ABIT; /* Set the Alarm */ if (sp > 0) pm [sp+PSR_CPT]++; /* Increment CPU time */ if (fbsyrd) /* Floppy busy? Get 2 wrds */ { /* Read two words */ /* is it pointing to the correct place? */ if (fread (&pm[ftx], WD_B, 2, floppy) != 2) { fbsyrd = 0; pc --; } else { ftx += 2; if (ftx == ftul) { fbsyrd = 0; ie |= FBIT; md &= ~(1<<FBIT); } } } if (dbsyrd) /* Disk Busy Reading ? Get 2 Words */ { recv (dmasock, &pm[dtx], 2*WD_B, 0); dtx += 2; if (dtx == dtul) { dbsyrd = 0; ie |= DBIT; md &= ~(1<<DBIT); } } else if (dbsywr) /* Disk Writing (and not reading) Send 2 words */ { write (dmasock, &pm[dtx], 2*WD_B); dtx += 2; if (dtx == dtul) { dbsywr = 0; ie |= DBIT; md &= ~(1<<DBIT); } } /* Interrupt Handling */ if (ie != 0 && ar < 0) { int intr; int md_sign; int md_val; /* If something else running and this is not a greater one ignore for now */ if ((extract (md,0,WD_L-1) != 0) && (md <= ie)) return; /* Go away */ /* Get sign bit */ md_sign = (extract (md,(WD_L-1),1)) << (WD_L-1) ; /* Get the rightmost interrupt and make sure it can execute */ for (i=0; i< LEV_N; i++) { if ( (intr = (ffs (ie)-1)) != -1) /* Find the int */ if (extract (ar,intr,1)) /* Is it armed? */ { if (sp > 0) /* Set the "return to" value to SP */ pm [LCL_ITV + (2*intr) +1] = sp; else { hlt = TRUE ; break ; } ie &= ~(1<<intr); /* Clear the int */ swcontxt (pm[LCL_ITV+(2*intr)], pc); /* Switch to it */ md = (1 << intr); /* Set mode register */ /* md = ((1<<intr) | md_sign); /* Set mode register */ break; } } } return; /* Illegal instruction */ illins: ecd = INSTFLT; printf ("\n\nIll Ins ECD : %x\n\n", ecd); goto except; /* Exception */ except: ie |= EBIT; printf ("\nException Handler ECD : %x\n", ecd); if (sp > 0) pm [sp+PSR_ECD] = ecd; else hlt = TRUE; return; }
void ilparser::comAssign( symptyp sympnt, bool def ) { datpnt *symdatp = mContext->hasher->tabdatadr( &sympnt ); int valstack = sympnt.local ? IDVAL : GLBVAL; int idt = symdatp->tp; int vlt = newval.tp; if ( idt ) { if ( def ) { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 294 ); return; } if ( idt != vlt ) { implinst coercf; if ( idt == ULmap && ilstatic( vlt ) ) { genpar par; par.parp = mContext->stacks->stackadr( OPAND, newval.sp ); par.type = vlt; mContext->stacks->chkdel( valstack, symdatp ); cmap( 1, &par, (maptyp*)mContext->stacks->stackadr( valstack, symdatp->sp ), NULL, NULL, mContext ); } else if ( coercf = coercible( idt, vlt, -1 ) ) { genpar par; par.parp = mContext->stacks->stackadr( OPAND, newval.sp ); par.type = vlt; (*coercf)( 1, &par, mContext->stacks->stackadr( valstack, symdatp->sp ), NULL, NULL, mContext ); } else { mContext->stacks->chkdel( OPAND, &newval ); mContext->cycles->errormsg( 140 ); } } else { mContext->stacks->chkdel( valstack, symdatp ); memcpy( mContext->stacks->stackadr( valstack, symdatp->sp ), mContext->stacks->stackadr( OPAND, newval.sp ), typesize( vlt ) ); } } else { symdatp->sp = mContext->stacks->push( valstack, mContext->stacks->stackadr( OPAND, newval.sp ), typesize( newval.tp ) ); if ( mContext->cycles->error ) { mContext->stacks->chkdel( OPAND, &newval ); return; } symdatp->tp = vlt; if ( def ) mContext->hasher->pprotect( &sympnt ); } if ( mContext->cycles->error ) return; mContext->stacks->setspnt( OPAND, idadr.sp - 1 ); mContext->stacks->chkref( OPAND, &newval ); mContext->stacks->pushand( vlt, mContext->stacks->stackadr( OPAND, newval.sp ) ); }
int main(int argc, char * argv[]) { try { ::libmaus::util::ArgInfo arginfo(argc,argv); ::libmaus::util::TempFileRemovalContainer::setup(); ::std::vector<std::string> const & inputfilenames = arginfo.restargs; char const * fasuffixes[] = { ".fa", ".fasta", 0 }; std::string deftmpname = libmaus::util::OutputFileNameTools::endClipLcp(inputfilenames,&fasuffixes[0]) + ".fa.tmp"; while ( ::libmaus::util::GetFileSize::fileExists(deftmpname) ) deftmpname += "_"; std::string defoutname = libmaus::util::OutputFileNameTools::endClipLcp(inputfilenames,&fasuffixes[0]) + ".fa.recoded"; while ( ::libmaus::util::GetFileSize::fileExists(defoutname) ) defoutname += "_"; std::string const tempfilename = arginfo.getValue<std::string>("tempfilename",deftmpname); std::string const outfilename = arginfo.getValue<std::string>("outputfilename",defoutname); std::string const indexfilename = tempfilename + ".index"; unsigned int const addterm = arginfo.getValue<unsigned int>("addterm",0); unsigned int const termadd = addterm ? 1 : 0; ::libmaus::util::TempFileRemovalContainer::addTempFile(tempfilename); ::libmaus::util::TempFileRemovalContainer::addTempFile(indexfilename); std::cerr << "temp file name " << tempfilename << std::endl; std::cerr << "output file name " << outfilename << std::endl; /* uint64_t const numseq = */ ::libmaus::fastx::FastAReader::rewriteFiles(inputfilenames,tempfilename,indexfilename); uint64_t curpos = 0; ::libmaus::aio::CheckedOutputStream COS(outfilename); // 0,A,C,G,T,N // map forward ::libmaus::autoarray::AutoArray<char> cmap(256,false); std::fill(cmap.begin(),cmap.end(),5+termadd); cmap['\n'] = 0 + termadd; cmap['a'] = cmap['A'] = 1 + termadd; cmap['c'] = cmap['C'] = 2 + termadd; cmap['g'] = cmap['G'] = 3 + termadd; cmap['t'] = cmap['T'] = 4 + termadd; cmap['n'] = cmap['N'] = 5 + termadd; // map to reverse complement ::libmaus::autoarray::AutoArray<char> rmap(256,false); std::fill(rmap.begin(),rmap.end(),5+termadd); rmap['\n'] = 0 + termadd; rmap['a'] = rmap['A'] = 4 + termadd; rmap['c'] = rmap['C'] = 3 + termadd; rmap['g'] = rmap['G'] = 2 + termadd; rmap['t'] = rmap['T'] = 1 + termadd; rmap['n'] = rmap['N'] = 5 + termadd; // reverse complement for mapped data ::libmaus::autoarray::AutoArray<char> xmap(256,false); std::fill(xmap.begin(),xmap.end(),5+termadd); xmap[0] = 0 + termadd; xmap[1] = 4 + termadd; xmap[2] = 3 + termadd; xmap[3] = 2 + termadd; xmap[4] = 1 + termadd; xmap[5] = 5 + termadd; ::libmaus::autoarray::AutoArray<char> imap(256,false); for ( uint64_t i = 0; i < imap.size(); ++i ) imap[i] = static_cast<char>(i); ::libmaus::fastx::FastAReader::RewriteInfoDecoder::unique_ptr_type infodec(new ::libmaus::fastx::FastAReader::RewriteInfoDecoder(indexfilename)); ::libmaus::fastx::FastAReader::RewriteInfo info; uint64_t maxseqlen = 0; while ( infodec->get(info) ) maxseqlen = std::max(maxseqlen,info.seqlen); std::cerr << "[V] max seq len " << maxseqlen << std::endl; ::libmaus::fastx::FastAReader::RewriteInfoDecoder::unique_ptr_type tinfodec(new ::libmaus::fastx::FastAReader::RewriteInfoDecoder(indexfilename)); infodec = UNIQUE_PTR_MOVE(tinfodec); if ( maxseqlen <= 256*1024 ) { ::libmaus::aio::CheckedInputStream CIS(tempfilename); ::libmaus::autoarray::AutoArray<uint8_t> B(maxseqlen+1,false); while ( infodec->get(info) ) { // skip id CIS.ignore(info.idlen+2); // read sequence plus following terminator CIS.read(reinterpret_cast<char *>(B.begin()), info.seqlen+1); // map for ( uint64_t i = 0; i < info.seqlen+1; ++i ) B[i] = cmap[B[i]]; // write COS.write(reinterpret_cast<char const *>(B.begin()),info.seqlen+1); // remap for ( uint64_t i = 0; i < info.seqlen+1; ++i ) B[i] = xmap[B[i]]; // reverse std::reverse(B.begin(),B.begin()+info.seqlen); // write COS.write(reinterpret_cast<char const *>(B.begin()),info.seqlen+1); } } else { while ( infodec->get(info) ) { // std::cerr << info.valid << "\t" << info.idlen << "\t" << info.seqlen << "\t" << info.getIdPrefix() << std::endl; uint64_t const seqbeg = curpos + (info.idlen+2); uint64_t const seqend = seqbeg + info.seqlen; ::libmaus::aio::CheckedInputStream CIS(tempfilename); CIS.seekg(seqbeg); ::libmaus::util::GetFileSize::copyMap(CIS,COS,cmap.begin(),seqend-seqbeg+1); ::libmaus::aio::CircularReverseWrapper CRW(tempfilename,seqend); ::libmaus::util::GetFileSize::copyMap(CRW,COS,rmap.begin(),seqend-seqbeg+1); curpos += (info.idlen+2) + (info.seqlen+1); } } if ( addterm ) COS.put(0); return EXIT_SUCCESS; } catch(std::exception const & ex) { std::cerr << ex.what() << std::endl; return EXIT_FAILURE; } }
Point2d InputProcessing::getEyeCenter(Mat frame, Rect eye) { //find derivatives Mat ROI = frame(eye); Mat gx, gy; GaussianBlur(ROI, ROI, Size(3, 3), 0, 0); Scharr(ROI, gx, CV_32F, 1, 0); Scharr(ROI, gy, CV_32F, 0, 1); //initialize variables Point cmaxPoint; double cmax = DBL_MIN; double c = 0; Mat cmap(gx.size(), CV_64FC1, Scalar(0)); //compute cmap field float * px, *py; unsigned char * w; double * pc; //for each vector g = gradient with origin at ROI(j,i) for (int i = 0; i < gx.rows; i++) { px = gx.ptr<float>(i); py = gy.ptr<float>(i); for (int j = 0; j < gx.cols; j++) { float plen = sqrtf(px[j] * px[j] + py[j] * py[j]); if (plen == 0) continue; px[j] /= plen; py[j] /= plen; double dxt, dyt = 0; //d^T.x, d^T.y where d is vector from c to origin of g if (plen < 300) { continue; } //for each possibl centre c = ROI(l,k) for (int k = 0; k < gx.rows; k++) { dxt = -k + i; pc = cmap.ptr<double>(k); w = ROI.ptr<unsigned char>(k); for (int l = 0; l < gx.cols; l++) { if (i == k && j == l) continue; dyt = l - j; double dlen = sqrt(dxt*dxt + dyt*dyt); double cz = px[j] * dyt / dlen - py[j] * dxt / dlen; //cross product pc[l] += cz*cz * (255 - w[l]); // inverted intensity value, since pupil is usually darker } } } } for (int i = 8; i < gx.rows - 8; i++) { pc = cmap.ptr<double>(i); for (int j = 8; j < gx.cols - 8; j++) { if (pc[j] > cmax) { cmaxPoint.x = j; cmaxPoint.y = i; cmax = pc[j]; } } } cmaxPoint += Point(eye.x, eye.y); return cmaxPoint; }
void TransferFunctionEditor::loadColorMapFile(string filename) { VColorMap cmap(filename); addColorMap(cmap); }
icycle() { int op,a1,a2,x1,x2,i1,i2,setting,setmask,onemask,oldmask; int fault; char pop [6]; if((fault=setjmp(svstck)) != 0) { if (fault == PAGEFLT) printf ("\nPage Fault.\n"); if (fault == SEGMFLT) printf ("\nSegmentation Fault.\n"); hlt = TRUE; return; } /* setjmp(svstck) to save stack for return */ /* from possible segment and page faults */ ir = pm[cmap(pc)]; pc++; /* extract instruction fields into op, a1, a2; */ /* generate the eff. virtual addresses v1, v2 */ /* using the algorithm in the Reference Manual */ op = extract(ir,24,6); strcpy(pop,ir_val[op]); printf ("***** POP: %s\n",pop); a1 = extract(ir,12,10); a2 = extract(ir,0,10); x1 = extract(ir,22,1); x2 = extract(ir,10,1); i1 = extract(ir,23,1); i2 = extract(ir,11,1); v1 = a1; v2 = a2; /* address field forms initial value */ if (i1 == 1) v1 = pm[dmap(v1)]; /* if indirection, get ind. loc */ if (i2 == 1) v2 = pm[dmap(v2)]; if (x1 == 1) v1 = v1 + xr; /* if indexing specified, add xr */ if (x2 == 1) v2 = v2 + xr; switch(op) { case 1: gr = pm[dmap(v1)]; /* gr load */ break; case 2: pm[dmap(v1)] = gr; /* gr store */ break; case 3: xr = pm[dmap(v1)]; /* xr load */ break; case 4: pm[dmap(v1)] = xr; /* xr store */ break; case 5: sr = pm[dmap(v1)]; /* sr load */ break; case 6: pm[dmap(v1)] = sr; /* sr store */ break; case 8: pm[dmap(v2)] = pm[dmap(v1)]; /* copy */ break; case 9: pm[dmap(v2)] += pm[dmap(v1)]; /* add */ break; case 10: pm[dmap(v2)] -= pm[dmap(v1)]; /* subtract */ break; case 11: pm[dmap(v2)] *= pm[dmap(v1)]; /* multiply */ break; case 12: if (pm[dmap(v1)] == 0) hlt=TRUE; /* divide */ else pm[dmap(v2)] /= pm[dmap(v1)]; break; case 13: pm[dmap(v2)] &= pm[dmap(v1)]; /* and */ break; case 14: pm[dmap(v2)] |= pm[dmap(v1)]; /* or */ break; case 16: pc = v1; /* go to */ break; case 17: if (pm[dmap(v1)] != pm[dmap(v2)]) pc++; /* if = */ break; case 18: if (pm[dmap(v1)] == pm[dmap(v2)]) pc++; /* if != */ break; case 19: if (pm[dmap(v1)] >= pm[dmap(v2)]) pc++; /* if < */ break; case 20: if (pm[dmap(v1)] < pm[dmap(v2)]) pc++; /* if >= */ break; case 21: xr++; /* loop */ if (xr < pm[dmap(v1)]) pc = v2; break; case 22: sr = pc; pc = v1; /* call */ break; case 23: pc = sr + pm[dmap(v1)]; /* return */ break; case 26: xr = v1; /* xr set */ break; case 27: pm[dmap(v2)] = v1; /* vm set */ break; case 28: pm[dmap(v2)] = extract(pm[dmap(v1 + gr/4)],(gr%4)*8,8); /* get byte */ break; case 29: setting = extract(pm[dmap(v2)],0, 8); /* set byte */ setmask = setting << (gr%4)*8; /* byte want to set in pos with 0's other */ onemask = 0xFFFFFFFF - (0xFF << (gr%4) * 8); /* mask with ones 'cept 0's in pos. */ oldmask = pm[dmap(v1+(gr/4))] & onemask; /* old value of word with 0's in pos */ pm[dmap(v1+(gr/4))] = oldmask | setmask; /* new word to write to memory */ break; /*case 29: pm[dmap(v1 + gr)] = 0x00FFFFFF & pm[dmap(v1 + gr)] extract(pm[dmap(v2)],0,8); */ /* put byte */ /* break; */ case 31: ; /* noop */ break; case 32: hlt = TRUE; /* halt */ break; default: hlt = TRUE; /* unused op */ break; } }
/* Save the two dimensional array as a png image */ int save_png(double *data, const int nx, const int ny, const char *fname) { FILE *fp; png_structp pngstruct_ptr = NULL; png_infop pnginfo_ptr = NULL; png_byte **row_pointers = NULL; int i, j; /* Default return status is failure */ int status = -1; int pixel_size = 3; int depth = 8; if ((fp = fopen(fname, "wb")) != NULL) { pngstruct_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (pngstruct_ptr != NULL) { pnginfo_ptr = png_create_info_struct(pngstruct_ptr); if (pnginfo_ptr != NULL) { if (!setjmp(png_jmpbuf(pngstruct_ptr))) { png_set_IHDR(pngstruct_ptr, pnginfo_ptr, (size_t) ny, (size_t) nx, depth, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); row_pointers = png_malloc(pngstruct_ptr, ny * sizeof(png_byte *)); for (i = 0; i < nx; i++) { png_byte *row = png_malloc(pngstruct_ptr, sizeof(uint8_t) * ny * pixel_size); row_pointers[i] = row; for (j = 0; j < ny; j++) { pixel_t pixel; // Scale the values so that values between // 0 and 100 degrees are mapped to values // between 0 and 255 cmap(data[j + i * ny], 2.55, 0.0, &pixel); *row++ = pixel.red; *row++ = pixel.green; *row++ = pixel.blue; } } png_init_io(pngstruct_ptr, fp); png_set_rows(pngstruct_ptr, pnginfo_ptr, row_pointers); png_write_png(pngstruct_ptr, pnginfo_ptr, PNG_TRANSFORM_IDENTITY, NULL); status = 0; for (i = 0; i < ny; i++) { png_free(pngstruct_ptr, row_pointers[i]); } png_free(pngstruct_ptr, row_pointers); } } png_destroy_write_struct(&pngstruct_ptr, &pnginfo_ptr); } fclose(fp); } return status; }
int main(int argc, char * argv[]) { TFile *f = new TFile("compare.root", "RECREATE"); Int_t N = 3; std::string *fileNames = new std::string[N]; std::string *date = new std::string[N]; // for(int n = 0 ; n < N ; n++) // { fileNames[0] = "/data/acqmanager/calibration/resumes/2015-02-20_04:24:50.root"; fileNames[1] = "/data/acqmanager/calibration/resumes/2015-07-17_02:04:06.root"; fileNames[2] = "/data/acqmanager/calibration/resumes/2015-09-15_05:19:05.root"; // } for (int n = 0 ; n < N ; n++) { std::size_t found = fileNames[n].find_last_of("/\\"); date[n] = fileNames[n].substr(found+1,fileNames[n].substr(found+1).size()-5); std::cout << " date: " << fileNames[n].substr(found+1,fileNames[n].substr(found+1).size()-5) << std::endl; } gSystem->Load("libCalibration.so"); gStyle->SetPalette(1); gStyle->SetOptFit(1); gStyle->SetOptStat(0); Int_t crystalX [6144]; Int_t crystalY [6144]; ifstream cmap ("crystal_map.txt"); while(!cmap.eof()) { int cid, x, y; cmap >> cid >> x >> y; if(cid >= 6144/2) y += 48; crystalX[cid] = x; crystalY[cid] = y; } char *smPrefix = "K"; TH2F **hTop = new TH2F*[N]; TH2F **hBottom = new TH2F*[N];; TH2F **hDifference = new TH2F*[N-1]; TH2F **hRatioTop = new TH2F*[N-1]; TH2F **hRatioBottom = new TH2F*[N-1]; TCanvas **cComparisons = new TCanvas*[N-1]; TCanvas **cCoefficients = new TCanvas*[N]; for(Int_t n = 0; n < N; n++) { char hName[128]; char hTitle[128]; //kTop sprintf(hName, "hTop _ %s", date[n].c_str()); sprintf(hTitle, "%s, Top APD %s", smPrefix, date[n].c_str()); hTop[n] = new TH2F(hName, hTitle, 64, 0, 64, 48+48, 0, 48+48); //kBottom sprintf(hName, "hBottom_%s", date[n].c_str()); sprintf(hTitle, "%s, Bottom APD %s", smPrefix, date[n].c_str()); hBottom[n] = new TH2F(hName, hTitle, 64, 0, 64, 48+48, 0, 48+48); // sprintf(hName, "hDifference_%s", date[n]); // sprintf(hTitle, "%s Difference Top - Bottom (comparison %s)", smPrefix, date[n]); // hDifference[n] = new TH2F(hName, hTitle, 64, 0, 64, 48+48, 0, 48+48); TFile * calibrationFile = new TFile(fileNames[n].c_str(), "READ"); TTree * calibrationTree = (TTree *)calibrationFile->Get("T2"); CalibrationSummaryData *csd; calibrationTree->SetBranchAddress("event", &csd); for(int i = 0; i < calibrationTree->GetEntries(); i++) { calibrationTree->GetEntry(i); if(csd == NULL) continue; Int_t crystalID = csd->GetCrystalID(); Int_t cx = crystalX[crystalID]+1; Int_t cy = crystalY[crystalID]+1; Int_t asic = (crystalID / 192) % 2; hTop[n]->SetBinContent(cx, cy, csd->Get22NaKAbsolute()); hBottom[n]->SetBinContent(cx, cy, csd->Get22NaKAbsolute() * csd->Get176LuKrel()); hTop[n]->GetZaxis()->SetRangeUser(0, 10); hBottom[n]->GetZaxis()->SetRangeUser(0, 10); } } // for(Int_t n = N-1; n > 0; n--) { //comparisons //ktop char hName[128]; char hTitle[128]; sprintf(hName, "ratio hTop_ %s - %s", date[n].c_str(),date[n-1].c_str()); sprintf(hTitle, "(%s2 - %s1)/%s1, Top APD. %s1 = %s , %s2 %s",smPrefix,smPrefix,smPrefix,smPrefix,date[n-1].c_str(),smPrefix,date[n].c_str()); hRatioTop[n-1] = new TH2F(hName, hTitle, 64, 0, 64, 48+48, 0, 48+48); //kbottom sprintf(hName, "ratio hBottom_ %s - %s", date[n].c_str(),date[n-1].c_str()); sprintf(hTitle, "(%s2 - %s1)/%s1, Bottom APD. %s1 = %s , %s2 %s",smPrefix,smPrefix,smPrefix,smPrefix,date[n-1].c_str(),smPrefix,date[n].c_str()); hRatioBottom[n-1] = new TH2F(hName, hTitle, 64, 0, 64, 48+48, 0, 48+48); for(Int_t cx = 0; cx < 64; cx++) { for(Int_t cy = 0; cy < 2*48; cy++) { Float_t v1 = hTop[n-1]->GetBinContent(cx+1, cy+1); Float_t v2 = hTop[n]->GetBinContent(cx+1, cy+1); Float_t d = 0; if(v1 != 0 && v2 != 0) d = (v2 - v1)/v1; hRatioTop[n-1]->SetBinContent(cx+1, cy+1, d ); } } hRatioTop[n-1]->GetZaxis()->SetRangeUser(-0.2, 0.2); for(Int_t cx = 0; cx < 64; cx++) { for(Int_t cy = 0; cy < 2*48; cy++) { Float_t v1 = hBottom[n-1]->GetBinContent(cx+1, cy+1); Float_t v2 = hBottom[n]->GetBinContent(cx+1, cy+1); Float_t d = 0; if(v1 != 0 && v2 != 0) d = (v2 - v1)/v1; hRatioBottom[n-1]->SetBinContent(cx+1, cy+1, d ); } } hRatioBottom[n-1]->GetZaxis()->SetRangeUser(-0.2, 0.2); // h1 = hBottom[n-1]; // h2 = hBottom[n]; // // // for(Int_t cx = 0; cx < 64; cx++) { // for(Int_t cy = 0; cy < 2*48; cy++) { // Float_t v1 = h1->GetBinContent(cx+1, cy+1); // Float_t v2 = h2->GetBinContent(cx+1, cy+1); // Float_t d = 0; // if(v1 != 0 && v2 != 0) // d = (v2 - v1)/v1; // h2->SetBinContent(cx+1, cy+1, d ); // } // } // h2->GetZaxis()->SetRangeUser(-0.2, 0.2); } for(Int_t n = 0; n < N; n++) { char cName[128]; char cTitle[128]; sprintf(cName, "canvas_%s", date[n].c_str()); sprintf(cTitle, "%s Coefficients - Calibration %s", smPrefix, date[n].c_str()); cCoefficients[n] = new TCanvas(cName,cTitle,1200,800); cCoefficients[n]->Divide(2,1); cCoefficients[n]->cd(1); hTop[n]->Draw("COLZ"); cCoefficients[n]->cd(2); hBottom[n]->Draw("COLZ"); f->cd(); cCoefficients[n]->Write(); } for(Int_t n = 0; n < N-1; n++) { char cName[128]; char cTitle[128]; sprintf(cName, "canvas %s %s", date[n].c_str(),date[n+1].c_str()); sprintf(cTitle, "%s canvas comparison %s %s", smPrefix, date[n].c_str(),date[n+1].c_str()); cComparisons[n] = new TCanvas(cName,cTitle,1200,800); cComparisons[n]->Divide(3,1); cComparisons[n]->cd(1); hRatioTop[n]->Draw("COLZ"); cComparisons[n]->cd(2); hRatioBottom[n]->Draw("COLZ"); cComparisons[n]->cd(3); f->cd(); cComparisons[n]->Write(); // hDifference[n-1]->Draw("COLZ"); } f->Close(); return 0; }