void sample(unsigned int sy,unsigned int sx,double *B) { std::ofstream of("toukou.dat"); int v,u; sx % samv != 0 ? v = 0 : v = 1; sy % samv != 0 ? u = 0 : u = 1; of << ((sx/samv) + 1 - v) * ((sy/samv) + 1 - u) << std::endl; of << ((sx/samv - v) * (sy/samv - u)) * 2 << std::endl; unsigned int iy,ix; double x,y; bool search = false; unsigned int maxy,maxx; double h = 1; for(iy = 0;iy < sy;iy++){ for(ix = 0;ix < sx;ix++){ maxy = 0; maxx = 0; if(ix % samv == 0 && iy % samv == 0){ if(ix != 0 && iy < sy - samv/2){ for(unsigned int i = iy;i < iy + samv/2;i++){ for(unsigned int j = ix - samv/2;j < ix;j++){ if(B[i * sx + j] != 0){ search = true; if(B[maxy * sx + maxx] < B[i * sx + j]){ if(maxx != 0 && maxy != 0){ B[maxy * sx + maxx] = 0; } maxy = i; maxx = j; } } } } } if(iy != 0 && ix < sx - samv/2){ for(unsigned int i = iy - samv/2;i < iy;i++){ for(unsigned int j = ix;j < ix + samv/2;j++){ if(B[i * sx + j] != 0){ search = true; if(B[maxy * sx + maxx] < B[i * sx + j]){ if(maxx != 0 && maxy != 0){ B[maxy * sx + maxx] = 0; } maxy = i; maxx = j; } } } } } if(iy != 0 && ix != 0){ for(unsigned int i = iy - samv/2;i < iy;i++){ for(unsigned int j = ix - samv/2;j < ix;j++){ if(B[i * sx + j] != 0){ search = true; if(B[maxy * sx + maxx] < B[i * sx + j]){ if(maxx != 0 && maxy != 0){ B[maxy * sx + maxx] = 0; } maxy = i; maxx = j; } } } } } if(iy < sy - samv/2 && ix < sx - samv/2){ for(unsigned int i = iy;i < iy + samv/2;i++){ for(unsigned int j = ix;j < ix + samv/2;j++){ if(B[i * sx + j] != 0){ search = true; if(B[maxy * sx + maxx] < B[i * sx + j]){ if(maxx != 0 && maxy != 0){ B[maxy * sx + maxx] = 0; } maxy = i; maxx = j; } } } } } if(!search){ ix != 0 ? x = ix : x = 0.01; iy != 0 ? y = iy : y = 0.01; of << x/sx; of.put(' '); of << h/50; of.put(' '); of << y/sy << std::endl; B[iy * sx + ix] = 1; }else{ maxx != 0 ? x = maxx : x = 0.01; maxy != 0 ? y = maxy : y = 0.01; of << x/sx; of.put(' '); of << B[maxy * sx + maxx]/50; of.put(' '); of << y/sy << std::endl; } search = false; } } } for(unsigned int i = 0;i < ((sx/samv) + 1 - v) * ((sy/samv) + 1 - u);i++){ if(fmod(i + 1,sx/samv + !v) != 0 && i + sx/samv + 1 - v < ((sx/samv) + 1 - v) * ((sy/samv) + 1 - u)){ of << 3; of.put(' '); of << i + 1; of.put(' '); of << i; of.put(' '); of << i + sx/samv + 1 - v << std::endl; of << 3; of.put(' '); of << i + 1; of.put(' '); of << i + sx/samv + 1 - v; of.put(' '); of << i + sx/samv + 2 - v << std::endl; } } }
bool PreviewGenerator::SavePreview(const QString &filename, const unsigned char *data, uint width, uint height, float aspect, int desired_width, int desired_height, const QString &format) { if (!data || !width || !height) return false; const QImage img((unsigned char*) data, width, height, QImage::Format_RGB32); float ppw = max(desired_width, 0); float pph = max(desired_height, 0); bool desired_size_exactly_specified = true; if ((ppw < 1.0f) && (pph < 1.0f)) { ppw = img.width(); pph = img.height(); desired_size_exactly_specified = false; } aspect = (aspect <= 0.0f) ? ((float) width) / height : aspect; pph = (pph < 1.0f) ? (ppw / aspect) : pph; ppw = (ppw < 1.0f) ? (pph * aspect) : ppw; if (!desired_size_exactly_specified) { if (aspect > ppw / pph) pph = (ppw / aspect); else ppw = (pph * aspect); } ppw = max(1.0f, ppw); pph = max(1.0f, pph);; QImage small_img = img.scaled((int) ppw, (int) pph, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QTemporaryFile f(QFileInfo(filename).absoluteFilePath()+".XXXXXX"); f.setAutoRemove(false); if (f.open() && small_img.save(&f, format.toLocal8Bit().constData())) { // Let anybody update it bool ret = makeFileAccessible(f.fileName().toLocal8Bit().constData()); if (!ret) { LOG(VB_GENERAL, LOG_ERR, "Unable to change permissions on " "preview image. Backends and frontends " "running under different users will be " "unable to access it"); } QFile of(filename); of.remove(); if (f.rename(filename)) { LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Saved preview '%0' %1x%2") .arg(filename).arg((int) ppw).arg((int) pph)); return true; } f.remove(); } return false; }
LR::LRSplineSurface* ASMu2D::regularInterpolation (const RealArray& upar, const RealArray& vpar, const Matrix& points) const { if (lrspline->rational()) { std::cerr <<" *** ASMu2D::regularInterpolation:" <<" Rational LR B-splines not supported yet."<< std::endl; return nullptr; } // sanity check on input parameters const size_t nBasis = lrspline->nBasisFunctions(); if (upar.size() != nBasis || vpar.size() != nBasis || points.cols() != nBasis) { std::cerr <<" *** ASMu2D::regularInterpolation:" <<" Mismatching input array sizes.\n" <<" size(upar)="<< upar.size() <<" size(vpar)="<< vpar.size() <<" size(points)="<< points.cols() <<" nBasis="<< nBasis << std::endl; return nullptr; } SparseMatrix A(SparseMatrix::SUPERLU); A.resize(nBasis, nBasis); Matrix B2(points,true); // transpose to get one vector per field StdVector B(B2.ptr(), B2.size()); Go::BasisPtsSf splineValues; // Evaluate all basis functions at all points, stored in the A-matrix // (same row = same evaluation point) for (size_t i = 0; i < nBasis; i++) { int id = lrspline->getElementContaining(upar[i],vpar[i]); LR::Element* el = lrspline->getElement(id); std::cout << "id is " << id << std::endl; lrspline->computeBasis(upar[i],vpar[i],splineValues, id); auto it = splineValues.basisValues.begin(); std::cout << "ncoef is " << splineValues.basisValues.size() << std::endl; for (auto& it2 : splineValues.basisValues) std::cout << it2 << " "; std::cout << std::endl; for (LR::Basisfunction* b : el->support()) A(i+1, b->getId()+1) = *it++; } std::ofstream of("A.asc"); A.printFull(of); of.close(); // Solve for all solution components - one right-hand-side for each if (!A.solve(B)) return nullptr; std::cout << B << std::endl; // Copy all basis functions and mesh LR::LRSplineSurface* ans = lrspline->copy(); ans->rebuildDimension(points.rows()); // Back to interleaved data std::vector<double> interleave; interleave.reserve(B.dim()); for (size_t i = 0; i < nBasis; ++i) for (size_t j = 0; j < points.rows(); j++) { interleave.push_back(B(1+j*points.cols()+i)); } ans->setControlPoints(interleave); return ans; }
Void operator()(const T & t) const { std::ofstream of(filename.c_str()); of << t; return Void{}; }
bool Builder::CompileFile(QString inputFile, bool testDate, bool extractMacros) //, bool silent) { // Define the output file. msg.buildStage = 1; QString outputFile = MangleFileName(inputFile, extractMacros); // Check if the compiled object file is update. // If yes, we won't compile it again to gain time /////testDate = false; if (testDate) { QDateTime inputTime = QFileInfo(inputFile).lastModified(); QDateTime outputTime = QFileInfo(outputFile).lastModified(); if (inputTime < outputTime) { msg.AddOutput("File is up-to-date: " + inputFile, false); return true; } } if (extractMacros) { msg.AddOutput("Preprocessing file: " + inputFile, false); } else { msg.AddOutput("Compiling file: " + inputFile, false); } // Get the compiler path QString compilerPath = config.avrPath; if (QFileInfo(inputFile).suffix().toUpper() == "CPP") { compilerPath += "/avr-g++"; } else { compilerPath += "/avr-gcc"; } // Get the argument values from the project configuration map <QString, BoardDef>::const_iterator board = config.boards.find(project->boardName); if (board == config.boards.end()) { msg.Add("Could not find board configuration for project: " + project->name, mtError); return false; } // Create the list of argunts for the compiler QStringList arguments; arguments << "-c" << inputFile << "-o" << outputFile; arguments << "-g" << "-Os" << "-Wall" << "-fno-exceptions" << "-ffunction-sections"; arguments << "-fdata-sections" << "-MMD" << "-DARDUINO=105"; if (board->second.build_vid != "") { arguments << "-DUSB_VID=" + board->second.build_vid; } if (board->second.build_pid != "") { arguments << "-DUSB_PID=" + board->second.build_pid; } arguments << "-mmcu=" + board->second.build_mcu;; arguments << "-DF_CPU=" + board->second.build_f_cpu; //arguments << "-MF" << "C:/Users/aporto/Desktop/teste.txt"; //arguments << "-E" << "-dM"; if (extractMacros) { QFile of(outputFile); of.remove(); arguments << "-dN" << "-E"; } // add all include paths from the project configurations QStringList projectIncludes = project->includePaths.split(";") + config.extraArduinoLibsSearchPaths.split(";"); QStringList includes; includes << QFileInfo(inputFile).path(); QString core = config.DecodeMacros("$(ARDUINO_CORE)", project); includes << core; /*#if defined(Q_OS_WIN) includes << qApp->applicationDirPath() + "/arduino/arduino/cores/" + board->second.build_core; #endif #if defined(Q_OS_LINUX) || defined(Q_OS_MAC) qDebug() << "arduinoCoreOpt" << config.arduinoCoreOpt; includes << config.arduinoCoreOpt + "/arduino/cores/" + board->second.build_core; #endif */ QString variant = config.DecodeMacros("$(ARDUINO_VARIANT)", project); includes << variant; for (int l=0; l < projectIncludes.count(); l++) { projectIncludes[l] = projectIncludes[l].trimmed(); if (projectIncludes[l].length() < 2) { continue; } if (projectIncludes[l].indexOf("/") > 0) { QString path = config.DecodeLibraryPath(projectIncludes[l]).trimmed(); if (path.length() > 1) { includes.append(path); } } else { QString includePaths = config.DecodeMacros(projectIncludes[l], project).trimmed(); QStringList tempInc = includePaths.split(";"); for (int i=0; i < tempInc.size(); i++) { tempInc[i] = tempInc[i].trimmed(); if (tempInc[i].length() > 1) { includes.append(tempInc[i]); } } } } for (int i=0; i < includes.size(); i++) { arguments << "-I" << includes[i]; } bool ok = launcher->RunCommand(compilerPath, arguments); qDebug() << "args: " << arguments; /* bool l = (compilerPath == "avr-g++"); QStringList ls; ls << "-V"; ok = launcher->RunCommand("avr-g++", arguments); */ return ok; }
namespace serbin { #define of offsetof FieldMetadata gSimpleFieldMetadata[] = { { of(Simple, bTrue), TYPE_BOOL, NULL }, { of(Simple, bFalse), TYPE_BOOL, NULL }, { of(Simple, u16_1), TYPE_U16, NULL }, { of(Simple, i32_1), TYPE_I32, NULL }, { of(Simple, u32_1), TYPE_U32, NULL }, { of(Simple, u64_1), TYPE_U64, NULL }, { of(Simple, col_1), TYPE_COLOR, NULL }, { of(Simple, float_1), TYPE_FLOAT, NULL }, { of(Simple, str_1), TYPE_STR, NULL }, { of(Simple, str_escape), TYPE_STR, NULL }, { of(Simple, wstr_1), TYPE_WSTR, NULL }, }; StructMetadata gSimpleMetadata = { sizeof(Simple), 11, &gSimpleFieldMetadata[0] }; #undef of static const uint8_t gSimpleDefault[119] = { 0x54, 0x74, 0x65, 0x53, // magic id 'SetT' 0x00, 0x00, 0x00, 0x01, // version 1.0 0x0c, 0x00, 0x00, 0x00, // top-level struct offset 0xc // offset: 0xc Simple_9 0x54, 0x74, 0x65, 0x53, // magic id 'SetT' 0x0b, // 11 fields 0x01, // bool bTrue = true 0x00, // bool bFalse = false 0x01, // uint16_t u16_1 = 1 0x17, // int32_t i32_1 = -12 0x59, // uint32_t u32_1 = 89 0x7b, // uint64_t u64_1 = 123 0xfc, 0xac, 0xff, 0x00, 0xed, // uint32_t col_1 = #acff00ed 0x08, 0x33, 0x2e, 0x31, 0x32, 0x33, 0x34, 0x38, 0x00, // float float_1 = 3.12348 0x05, 0x6c, 0x6f, 0x6c, 0x61, 0x00, // const char * str_1 = lola 0x12, 0x5b, 0x6c, 0x6f, 0x0d, 0x20, 0x24, 0x66, 0x6f, 0x09, 0x6f, 0x5c, 0x20, 0x6c, 0x0a, 0x61, 0x5d, 0x5d, 0x00, // const char * str_escape = [lo\r $fo o\ l\na]] 0x38, 0x77, 0x69, 0x64, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0xce, 0xa0, 0xcf, 0x81, 0xce, 0xb1, 0xce, 0xb3, 0xce, 0xbc, 0xce, 0xb1, 0xcf, 0x84, 0xce, 0xb9, 0xce, 0xba, 0xcf, 0x8c, 0x20, 0x26, 0xce, 0x9c, 0xce, 0xad, 0xce, 0xb3, 0xce, 0xb5, 0xce, 0xb8, 0xce, 0xbf, 0xcf, 0x82, 0x0a, 0x43, 0x74, 0x72, 0x6c, 0x2b, 0x31, 0x00, // const WCHAR * wstr_1 = wide string &\nCtrl+1 }; Simple *DeserializeSimple(const uint8_t *data, int dataLen, bool *usedDefaultOut) { void *res = NULL; res = Deserialize(data, dataLen, SimpleVersion, &gSimpleMetadata); if (res) { *usedDefaultOut = false; return (Simple*)res; } res = Deserialize(&gSimpleDefault[0], sizeof(gSimpleDefault), SimpleVersion, &gSimpleMetadata); CrashAlwaysIf(!res); *usedDefaultOut = true; return (Simple*)res; } uint8_t *SerializeSimple(Simple *val, int *dataLenOut) { return Serialize((const uint8_t*)val, SimpleVersion, &gSimpleMetadata, dataLenOut); } void FreeSimple(Simple *val) { FreeStruct((uint8_t*)val, &gSimpleMetadata); } }
int main(int argc, char **argv) { //_CrtSetBreakAlloc(3168); #ifdef _WIN32 _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // set the version label in the global cache OFX::Host::PluginCache::getPluginCache()->setCacheVersion("hostDemoV1"); // create our derived image effect host which provides // a factory to make plugin instances and acts // as a description of the host application MyHost::Host myHost; // make an image effect plugin cache. This is what knows about // all the plugins. OFX::Host::ImageEffect::PluginCache imageEffectPluginCache(myHost); // register the image effect cache with the global plugin cache imageEffectPluginCache.registerInCache(*OFX::Host::PluginCache::getPluginCache()); // try to read an old cache std::ifstream ifs("hostDemoPluginCache.xml"); OFX::Host::PluginCache::getPluginCache()->readCache(ifs); OFX::Host::PluginCache::getPluginCache()->scanPluginFiles(); ifs.close(); /// flush out the current cache std::ofstream of("hostDemoPluginCache.xml"); OFX::Host::PluginCache::getPluginCache()->writePluginCache(of); of.close(); // get the invert example plugin which uses the OFX C++ support code OFX::Host::ImageEffect::ImageEffectPlugin* plugin = imageEffectPluginCache.getPluginById("net.sf.openfx:invertPlugin"); imageEffectPluginCache.dumpToStdOut(); if(plugin) { // create an instance of it as a filter // the first arg is the context, the second is client data we are allowed to pass down the call chain std::auto_ptr<OFX::Host::ImageEffect::Instance> instance(plugin->createInstance(kOfxImageEffectContextFilter, NULL)); if(instance.get()) { OfxStatus stat; // now we need to call the create instance action. Only call this once you have initialised all the params // and clips to their correct values. So if you are loading a saved plugin state, set up your params from // that state, _then_ call create instance. stat = instance->createInstanceAction(); assert(stat == kOfxStatOK || stat == kOfxStatReplyDefault); // now we need to to call getClipPreferences on the instance so that it does the clip component/depth // logic and caches away the components and depth on each clip. bool ok = instance->getClipPreferences(); assert(ok); // current render scale of 1 OfxPointD renderScale; renderScale.x = renderScale.y = 1.0; // The render window is in pixel coordinates // ie: render scale and a PAR of not 1 OfxRectI renderWindow; renderWindow.x1 = renderWindow.y1 = 0; renderWindow.x2 = 720; renderWindow.y2 = 576; /// RoI is in canonical coords, OfxRectD regionOfInterest; regionOfInterest.x1 = regionOfInterest.y1 = 0; regionOfInterest.x2 = renderWindow.x2 * instance->getProjectPixelAspectRatio(); regionOfInterest.y2 = 576; int numFramesToRender = OFXHOSTDEMOCLIPLENGTH; // say we are about to render a bunch of frames stat = instance->beginRenderAction(0, numFramesToRender, 1.0, false, renderScale, /*sequential=*/true, /*interactive=*/false, # ifdef OFX_SUPPORTS_OPENGLRENDER /*openGLRender=*/false, # endif /*draftRender=*/false # ifdef OFX_EXTENSIONS_NUKE , 0 /* view*/ # endif ); assert(stat == kOfxStatOK || stat == kOfxStatReplyDefault); // get the output clip MyHost::MyClipInstance* outputClip = dynamic_cast<MyHost::MyClipInstance*>(instance->getClip("Output")); assert(outputClip); for(int t = 0; t <= numFramesToRender; ++t) { // call get region of interest on each of the inputs OfxTime frame = t; // get the RoI for each input clip // the regions of interest for each input clip are returned in a std::map // on a real host, these will be the regions of each input clip that the // effect needs to render a given frame (clipped to the RoD). // // In our example we are doing full frame fetches regardless. std::map<OFX::Host::ImageEffect::ClipInstance *, OfxRectD> rois; stat = instance->getRegionOfInterestAction(frame, renderScale, #ifdef OFX_EXTENSIONS_NUKE /*view=*/0, #endif regionOfInterest, rois); assert(stat == kOfxStatOK || stat == kOfxStatReplyDefault); #if defined(OFX_EXTENSIONS_VEGAS) || defined(OFX_EXTENSIONS_NUKE) // render a stereoscopic frame { // left view stat = instance->renderAction(t,kOfxImageFieldBoth,renderWindow, renderScale, /*sequential=*/true, /*interactive=*/false, # ifdef OFX_SUPPORTS_OPENGLRENDER /*openGLRender=*/false, # endif /*draft=*/false, 0 /*view*/ # ifdef OFX_EXTENSIONS_VEGAS , 2 /*nViews*/ # endif # ifdef OFX_EXTENSIONS_NUKE , std::list<std::string>() /*planes*/ # endif ); assert(stat == kOfxStatOK); // get the output image buffer MyHost::MyImage *outputImage = outputClip->getOutputImage(); assert(outputImage); std::ostringstream ss; ss << "Output." << t << "l.ppm"; exportToPPM(ss.str(), outputImage); } { // right view instance->renderAction(t,kOfxImageFieldBoth,renderWindow, renderScale, /*sequential=*/true, /*interactive=*/false, # ifdef OFX_SUPPORTS_OPENGLRENDER /*openGLRender=*/false, # endif /*draft=*/false, 1 /*view*/ # ifdef OFX_EXTENSIONS_VEGAS , 2 /*nViews*/ # endif # ifdef OFX_EXTENSIONS_NUKE , std::list<std::string>() /*planes*/ # endif ); assert(stat == kOfxStatOK); // get the output image buffer MyHost::MyImage *outputImage = outputClip->getOutputImage(); assert(outputImage); std::ostringstream ss; ss << "Output." << t << "r.ppm"; exportToPPM(ss.str(), outputImage); } #else // render a frame stat = instance->renderAction(t,kOfxImageFieldBoth,renderWindow, renderScale, /*sequential=*/true, /*interactive=*/false, /*draft=*/false); assert(stat == kOfxStatOK); // get the output image buffer MyHost::MyImage *outputImage = outputClip->getOutputImage(); std::ostringstream ss; ss << "Output." << t << ".ppm"; exportToPPM(ss.str(), outputImage); #endif } instance->endRenderAction(0, numFramesToRender, 1.0, false, renderScale, /*sequential=*/true, /*interactive=*/false, # ifdef OFX_SUPPORTS_OPENGLRENDER /*openGLRender=*/false, # endif /*draftRender=*/false # ifdef OFX_EXTENSIONS_NUKE , 0 /* view*/ # endif ); } } OFX::Host::PluginCache::clearPluginCache(); return 0; }
void calcv2(){ const int ncent = 6; const int npt = 25; int centbin[ncent+1] = {0,5,10,20,40,60,100}; gStyle->SetOptFit(kFALSE); gStyle->SetOptStat(kFALSE); ifstream fcntbbc("c1_c2_central_ptfiner_south.dat"); ifstream fcntbbcIn("c1_c2_central_ptIn_south.dat"); ifstream fcntfvtx("c1_c2_central_ptfiner_north.dat"); ifstream fcntfvtxIn("c1_c2_central_ptIn_north.dat"); ifstream fbbcfvtx("c1_c2_central_ptIn_sn.dat"); float c1cntbbc[ncent][npt], c2cntbbc[ncent][npt], c3cntbbc[ncent][npt]; float c1cntbbcIn[ncent][npt], c2cntbbcIn[ncent][npt], c3cntbbcIn[ncent][npt]; float c1cntfvtx[ncent][npt], c2cntfvtx[ncent][npt], c3cntfvtx[ncent][npt]; float c1cntfvtxIn[ncent][npt], c2cntfvtxIn[ncent][npt], c3cntfvtxIn[ncent][npt]; float c1bbcfvtx[ncent][npt], c2bbcfvtx[ncent][npt], c3bbcfvtx[ncent][npt]; float c1errcntbbc[ncent][npt], c2errcntbbc[ncent][npt], c3errcntbbc[ncent][npt]; float c1errcntbbcIn[ncent][npt], c2errcntbbcIn[ncent][npt], c3errcntbbcIn[ncent][npt]; float c1errcntfvtx[ncent][npt], c2errcntfvtx[ncent][npt], c3errcntfvtx[ncent][npt]; float c1errcntfvtxIn[ncent][npt], c2errcntfvtxIn[ncent][npt], c3errcntfvtxIn[ncent][npt]; float c1errbbcfvtx[ncent][npt], c2errbbcfvtx[ncent][npt], c3errbbcfvtx[ncent][npt]; ifstream PPfcntbbc("c1_c2_PP_centIn_south.dat"); ifstream PPfcntbbcIn("c1_c2_PP_ptIn_south.dat"); ifstream PPfcntfvtx("c1_c2_PP_centIn_north.dat"); ifstream PPfcntfvtxIn("c1_c2_PP_ptIn_north.dat"); ifstream PPfbbcfvtx("c1_c2_bbcfvtx_PP_centIn.dat"); float c1PPcntbbc[ncent][npt], c2PPcntbbc[ncent][npt], c3PPcntbbc[ncent][npt]; float c1PPcntbbcIn[ncent][npt], c2PPcntbbcIn[ncent][npt], c3PPcntbbcIn[ncent][npt]; float c1PPcntfvtx[ncent][npt], c2PPcntfvtx[ncent][npt], c3PPcntfvtx[ncent][npt]; float c1PPcntfvtxIn[ncent][npt], c2PPcntfvtxIn[ncent][npt], c3PPcntfvtxIn[ncent][npt]; float c1PPbbcfvtx[ncent][npt], c2PPbbcfvtx[ncent][npt], c3PPbbcfvtx[ncent][npt]; float c1PPerrcntbbc[ncent][npt], c2PPerrcntbbc[ncent][npt], c3PPerrcntbbc[ncent][npt]; float c1PPerrcntbbcIn[ncent][npt], c2PPerrcntbbcIn[ncent][npt], c3PPerrcntbbcIn[ncent][npt]; float c1PPerrcntfvtx[ncent][npt], c2PPerrcntfvtx[ncent][npt], c3PPerrcntfvtx[ncent][npt]; float c1PPerrcntfvtxIn[ncent][npt], c2PPerrcntfvtxIn[ncent][npt], c3PPerrcntfvtxIn[ncent][npt]; float c1PPerrbbcfvtx[ncent][npt], c2PPerrbbcfvtx[ncent][npt], c3PPerrbbcfvtx[ncent][npt]; float tmp; int scale = 1; //0: use c1 as scale factor 1: use multiplicity as scale factor //--------------Multiplicity----------------------- float MPPbbc[ncent] = {3.8,1,1,1,1,1}; float Mbbc[ncent]= {58.9,1,1,1,1,1}; float MPPfvtx[ncent] = {0.57,1,1,1,1,1}; float Mfvtx[ncent] = {4,1,1,1,1,1}; //MPPNpart[0] = 2; //MNpart[0] = 11; float MPPNpart[ncent] = {3.8,1,1,1,1,1}; //use bbc float MNpart[ncent] = {58.9,1,1,1,1,1}; //use bbc //--------------read in parameters-------------------------------------------- for(int icent=0;icent<ncent;icent++){ //output txt ofstream of1(Form("v2cntbbcs_cent%d.dat",icent)); ofstream of2(Form("v2cntfvtxs_cent%d.dat",icent)); ofstream of(Form("v2_cent%d.dat",icent)); ofstream ofsub1(Form("v2cntbbcs_cent%d_scale%d.dat",icent,scale)); ofstream ofsub2(Form("v2cntfvtxs_cent%d_scale%d.dat",icent,scale)); ofstream ofsub(Form("v2_cent%d_scale%d.dat",icent,scale)); fcntbbcIn>>c1cntbbcIn[icent][0]>>c1errcntbbcIn[icent][0]>>c2cntbbcIn[icent][0]>>c2errcntbbcIn[icent][0]>>c3cntbbcIn[icent][0]>>c3errcntbbcIn[icent][0]; fcntfvtxIn>>c1cntfvtxIn[icent][0]>>c1errcntfvtxIn[icent][0]>>c2cntfvtxIn[icent][0]>>c2errcntfvtxIn[icent][0]>>c3cntfvtxIn[icent][0]>>c3errcntfvtxIn[icent][0]; fbbcfvtx>>c1bbcfvtx[icent][0]>>c1errbbcfvtx[icent][0]>>c2bbcfvtx[icent][0]>>c2errbbcfvtx[icent][0]>>c3bbcfvtx[icent][0]>>c3errbbcfvtx[icent][0]; PPfcntbbcIn>>c1PPcntbbcIn[icent][0]>>c1PPerrcntbbcIn[icent][0]>>c2PPcntbbcIn[icent][0]>>c2PPerrcntbbcIn[icent][0]>>c3PPcntbbcIn[icent][0]>>c3PPerrcntbbcIn[icent][0]; PPfcntfvtxIn>>c1PPcntfvtxIn[icent][0]>>c1PPerrcntfvtxIn[icent][0]>>c2PPcntfvtxIn[icent][0]>>c2PPerrcntfvtxIn[icent][0]>>c3PPcntfvtxIn[icent][0]>>c3PPerrcntfvtxIn[icent][0]; PPfbbcfvtx>>c1PPbbcfvtx[icent][0]>>c1PPerrbbcfvtx[icent][0]>>c2PPbbcfvtx[icent][0]>>c2PPerrbbcfvtx[icent][0]>>c3PPbbcfvtx[icent][0]>>c3PPerrbbcfvtx[icent][0]; // fcntbbcIn>>tmp>>tmp>>c1cntbbcIn[icent][0]>>c1errcntbbcIn[icent][0]>>c2cntbbcIn[icent][0]>>c2errcntbbcIn[icent][0]; // fcntfvtxIn>>tmp>>tmp>>c1cntfvtxIn[icent][0]>>c1errcntfvtxIn[icent][0]>>c2cntfvtxIn[icent][0]>>c2errcntfvtxIn[icent][0]; // fbbcfvtx>>tmp>>tmp>>c1bbcfvtx[icent][0]>>c1errbbcfvtx[icent][0]>>c2bbcfvtx[icent][0]>>c2errbbcfvtx[icent][0]; for(int ipt=0;ipt<npt;ipt++){ fcntbbc>>c1cntbbc[icent][ipt]>>c1errcntbbc[icent][ipt]>>c2cntbbc[icent][ipt]>>c2errcntbbc[icent][ipt]>>c3cntbbc[icent][ipt]>>c3errcntbbc[icent][ipt]; fcntfvtx>>c1cntfvtx[icent][ipt]>>c1errcntfvtx[icent][ipt]>>c2cntfvtx[icent][ipt]>>c2errcntfvtx[icent][ipt]>>c3cntfvtx[icent][ipt]>>c3errcntfvtx[icent][ipt]; PPfcntbbc>>c1PPcntbbc[icent][ipt]>>c1PPerrcntbbc[icent][ipt]>>c2PPcntbbc[icent][ipt]>>c2PPerrcntbbc[icent][ipt]>>c3PPcntbbc[icent][ipt]>>c3PPerrcntbbc[icent][ipt]; PPfcntfvtx>>c1PPcntfvtx[icent][ipt]>>c1PPerrcntfvtx[icent][ipt]>>c2PPcntfvtx[icent][ipt]>>c2PPerrcntfvtx[icent][ipt]>>c3PPcntfvtx[icent][ipt]>>c3PPerrcntfvtx[icent][ipt]; } cout<<"icent: "<<centbin[icent] << "\% to " << centbin[icent+1]<< "\%"<<endl; cout<<"cnt - bbc "<<c2cntbbcIn[icent][0]<<" "<<c2errcntbbcIn[icent][0]<<endl; cout<<"cnt - fvtx "<<c2cntfvtxIn[icent][0]<<" "<<c2errcntfvtxIn[icent][0]<<endl; cout<<"bbc - fvtx "<<c2bbcfvtx[icent][0]<<" "<<c2errbbcfvtx[icent][0]<<endl; cout<<"cnt - bbc PP"<<c2PPcntbbcIn[icent][0]<<" "<<c2PPerrcntbbcIn[icent][0]<<endl; cout<<"cnt - fvtx PP"<<c2PPcntfvtxIn[icent][0]<<" "<<c2PPerrcntfvtxIn[icent][0]<<endl; cout<<"bbc - fvtx PP"<<c2PPbbcfvtx[icent][0]<<" "<<c2PPerrbbcfvtx[icent][0]<<endl; //---------------calculating cnt/bbc/fvtx inclusive v2------------------------------ if(c2cntbbcIn[icent][0]*c2cntfvtxIn[icent][0]/c2bbcfvtx[icent][0]<=0) {cout<<"negative?"<<endl; continue;} float v2cnt = sqrt(c2cntbbcIn[icent][0]*c2cntfvtxIn[icent][0]/c2bbcfvtx[icent][0]); //float v2errcnt = 1/2.*v2cnt*sqrt(TMath::Power(c2errcntbbcIn[icent][0]/c2cntbbcIn[icent][0],2)+TMath::Power(c2errcntfvtxIn[icent][0]/c2cntfvtxIn[icent][0],2)+TMath::Power(c2errbbcfvtx[icent][0]/c2bbcfvtx[icent][0],2)); float v2errcnt = get3sqerr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0]); float v2bbc = c2cntbbcIn[icent][0]/v2cnt; //float v2errbbc = v2bbc * sqrt(TMath::Power(c2errcntbbcIn[icent][0]/c2cntbbcIn[icent][0],2)+TMath::Power(v2errcnt/v2cnt,2)); float v2errbbc = get2derr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],v2cnt,v2errcnt); float v2fvtx = c2cntfvtxIn[icent][0]/v2cnt; //float v2errfvtx = v2fvtx * sqrt(TMath::Power(c2errcntfvtxIn[icent][0]/c2cntfvtxIn[icent][0],2)+TMath::Power(v2errcnt/v2cnt,2)); float v2errfvtx = get2derr(c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],v2cnt,v2errcnt); cout<<"Integral v2 cnt = "<<v2cnt<<" "<<v2errcnt<<endl; cout<<"Integral v2 bbc = "<<v2bbc<<" "<<v2errbbc<<endl; cout<<"Integral v2 fvtx = "<<v2fvtx<<" "<<v2errfvtx<<endl; //------------calculating cnt pt dependence v2--------------------method1---------------- float v2cntpt1[ncent][npt], v2errcntpt1[ncent][npt]; float v2cntpt2[ncent][npt], v2errcntpt2[ncent][npt]; float ptmean[npt]; for(int ipt=0;ipt<npt;ipt++){ v2cntpt1[icent][ipt] = c2cntbbc[icent][ipt]/v2bbc; //v2errcntpt1[icent][ipt] = v2cntpt1[icent][ipt]*sqrt(TMath::Power(c2errcntbbc[icent][ipt]/c2cntbbc[icent][ipt],2)+TMath::Power(v2errbbc/v2bbc,2)); v2errcntpt1[icent][ipt] = get2derr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],v2bbc,v2errbbc); v2cntpt2[icent][ipt] = c2cntfvtx[icent][ipt]/v2fvtx; //v2errcntpt2[icent][ipt] = v2cntpt2[icent][ipt]*sqrt(TMath::Power(c2errcntfvtx[icent][ipt]/c2cntfvtx[icent][ipt],2)+TMath::Power(v2errfvtx/v2fvtx,2)); v2errcntpt2[icent][ipt] = get2derr(c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],v2bbc,v2errbbc); ptmean[ipt] = 0.1+0.2*ipt; } //------------calculating cnt pt dependence v2--------------------method2---------------- float v2cntpt[ncent][npt]; float v2errcntpt[ncent][npt]; for(int ipt=0;ipt<npt;ipt++){ v2cntpt[icent][ipt] = sqrt(c2cntbbc[icent][ipt]*c2cntfvtx[icent][ipt]/c2bbcfvtx[icent][0]); //v2errcntpt[icent][ipt] = v2cntpt[icent][ipt]*sqrt(TMath::Power(c2errcntbbc[icent][ipt]/c2cntbbc[icent][ipt],2)+TMath::Power(c2errcntfvtx[icent][ipt]/c2cntfvtx[icent][ipt],2)+TMath::Power(c2errbbcfvtx[icent][0]/c2bbcfvtx[icent][0],2)); v2errcntpt[icent][ipt] = get3sqerr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0]); of1<<ptmean[ipt]<<" "<<v2cntpt1[icent][ipt]<<" "<<v2errcntpt1[icent][ipt]<<endl; of2<<ptmean[ipt]<<" "<<v2cntpt2[icent][ipt]<<" "<<v2errcntpt2[icent][ipt]<<endl; of<<ptmean[ipt]<<" "<<v2cntpt[icent][ipt]<<" "<<v2errcntpt[icent][ipt]<<endl; } of1.close(); of2.close(); of.close(); //----subtract---------calculating cnt/bbc/fvtx inclusive v2------------------------------ if(scale==0){ c2cntbbcIn[icent][0] = c2cntbbcIn[icent][0] - c2PPcntbbcIn[icent][0]*c1cntbbcIn[icent][0]/c1PPcntbbcIn[icent][0]; c2cntfvtxIn[icent][0] = c2cntfvtxIn[icent][0] - c2PPcntfvtxIn[icent][0]*c1cntfvtxIn[icent][0]/c1PPcntfvtxIn[icent][0]; c2bbcfvtx[icent][0] = c2bbcfvtx[icent][0] - c2PPbbcfvtx[icent][0]*c1bbcfvtx[icent][0]/c1PPbbcfvtx[icent][0]; c2errcntbbcIn[icent][0] = get2mierr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],c2PPcntbbcIn[icent][0]*c1cntbbcIn[icent][0]/c1PPcntbbcIn[icent][0], get3err(c2PPcntbbcIn[icent][0],c2PPerrcntbbcIn[icent][0],c1cntbbcIn[icent][0],c1errcntbbcIn[icent][0],c1PPcntbbcIn[icent][0],c1PPerrcntbbcIn[icent][0])); c2errcntfvtxIn[icent][0] = get2mierr(c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],c2PPcntfvtxIn[icent][0]*c1cntfvtxIn[icent][0]/c1PPcntfvtxIn[icent][0], get3err(c2PPcntfvtxIn[icent][0],c2PPerrcntfvtxIn[icent][0],c1cntfvtxIn[icent][0],c1errcntfvtxIn[icent][0],c1PPcntfvtxIn[icent][0],c1PPerrcntfvtxIn[icent][0])); c2errbbcfvtx[icent][0] = get2mierr(c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0],c2PPbbcfvtx[icent][0]*c1bbcfvtx[icent][0]/c1PPbbcfvtx[icent][0], get3err(c2PPbbcfvtx[icent][0],c2PPerrbbcfvtx[icent][0],c1bbcfvtx[icent][0],c1errbbcfvtx[icent][0],c1PPbbcfvtx[icent][0],c1PPerrbbcfvtx[icent][0])); } else{ c2cntbbcIn[icent][0] = c2cntbbcIn[icent][0] - c2PPcntbbcIn[icent][0]*MPPbbc[icent]/Mbbc[icent]; c2cntfvtxIn[icent][0] = c2cntfvtxIn[icent][0] - c2PPcntfvtxIn[icent][0]*MPPfvtx[icent]/Mfvtx[icent]; c2bbcfvtx[icent][0] = c2bbcfvtx[icent][0] - c2PPbbcfvtx[icent][0]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent]); c2errcntbbcIn[icent][0] = get2mierr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],c2PPcntbbcIn[icent][0]*MPPbbc[icent]/Mbbc[icent],c2PPerrcntbbcIn[icent][0]*MPPbbc[icent]/Mbbc[icent]); c2errcntfvtxIn[icent][0] = get2mierr(c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],c2PPcntfvtxIn[icent][0]*MPPfvtx[icent]/Mfvtx[icent],c2PPerrcntfvtxIn[icent][0]*MPPfvtx[icent]/Mfvtx[icent]); c2errbbcfvtx[icent][0] = get2mierr(c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0],c2PPbbcfvtx[icent][0]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent]),c2PPerrbbcfvtx[icent][0]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent])); } cout<<"cnt - bbc subtract ="<<c2cntbbcIn[icent][0]<<" "<<c2errcntbbcIn[icent][0]<<endl; cout<<"cnt - fvtx subtract ="<<c2cntfvtxIn[icent][0]<<" "<<c2errcntfvtxIn[icent][0]<<endl; cout<<"bbc - fvtx subtract ="<<c2bbcfvtx[icent][0]<<" "<<c2errbbcfvtx[icent][0]<<endl; float v2cnt = sqrt(c2cntbbcIn[icent][0]*c2cntfvtxIn[icent][0]/c2bbcfvtx[icent][0]); // float v2errcnt = 1/2.*v2cnt*sqrt(TMath::Power(c2errcntbbcIn[icent][0]/c2cntbbcIn[icent][0],2)+TMath::Power(c2errcntfvtxIn[icent][0]/c2cntfvtxIn[icent][0],2)+TMath::Power(c2errbbcfvtx[icent][0]/c2bbcfvtx[icent][0],2)); float v2errcnt = get3sqerr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0]); float v2bbc = c2cntbbcIn[icent][0]/v2cnt; //float v2errbbc = v2bbc * sqrt(TMath::Power(c2errcntbbcIn[icent][0]/c2cntbbcIn[icent][0],2)+TMath::Power(v2errcnt/v2cnt,2)); float v2errbbc = get2derr(c2cntbbcIn[icent][0],c2errcntbbcIn[icent][0],v2cnt,v2errcnt); float v2fvtx = c2cntfvtxIn[icent][0]/v2cnt; //float v2errfvtx = v2fvtx * sqrt(TMath::Power(c2errcntfvtxIn[icent][0]/c2cntfvtxIn[icent][0],2)+TMath::Power(v2errcnt/v2cnt,2)); float v2errfvtx = get2derr(c2cntfvtxIn[icent][0],c2errcntfvtxIn[icent][0],v2cnt,v2errcnt); cout<<"Integral v2 subtract cnt = "<<v2cnt<<" "<<v2errcnt<<endl; cout<<"Integral v2 subtract bbc = "<<v2bbc<<" "<<v2errbbc<<endl; cout<<"Integral v2 subtract fvtx = "<<v2fvtx<<" "<<v2errfvtx<<endl; //----subtract--------calculating cnt pt dependence v2--------------------method1---------------- float v2cntpt1[ncent][npt], v2errcntpt1[ncent][npt]; float v2cntpt2[ncent][npt], v2errcntpt2[ncent][npt]; float ptmean[npt]; for(int ipt=0;ipt<npt;ipt++){ if(scale==0){ c2cntbbc[icent][ipt] = c2cntbbc[icent][ipt] - c2PPcntbbc[icent][ipt]*c1cntbbc[icent][ipt]/c1PPcntbbc[icent][ipt]; c2cntfvtx[icent][ipt] = c2cntfvtx[icent][ipt] - c2PPcntfvtx[icent][ipt]*c1cntfvtx[icent][ipt]/c1PPcntfvtx[icent][ipt]; c2bbcfvtx[icent][ipt] = c2bbcfvtx[icent][ipt] - c2PPbbcfvtx[icent][ipt]*c1bbcfvtx[icent][ipt]/c1PPbbcfvtx[icent][ipt]; c2errcntbbc[icent][ipt] = get2mierr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],c2PPcntbbc[icent][ipt]*c1cntbbc[icent][ipt]/c1PPcntbbc[icent][ipt], get3err(c2PPcntbbc[icent][ipt],c2PPerrcntbbc[icent][ipt],c1cntbbc[icent][ipt],c1errcntbbc[icent][ipt],c1PPcntbbc[icent][ipt],c1PPerrcntbbc[icent][ipt])); c2errcntfvtx[icent][ipt] = get2mierr(c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],c2PPcntfvtx[icent][ipt]*c1cntfvtx[icent][ipt]/c1PPcntfvtx[icent][ipt], get3err(c2PPcntfvtx[icent][ipt],c2PPerrcntfvtx[icent][ipt],c1cntfvtx[icent][ipt],c1errcntfvtx[icent][ipt],c1PPcntfvtx[icent][ipt],c1PPerrcntfvtx[icent][ipt])); c2errbbcfvtx[icent][ipt] = get2mierr(c2bbcfvtx[icent][ipt],c2errbbcfvtx[icent][ipt],c2PPbbcfvtx[icent][ipt]*c1bbcfvtx[icent][ipt]/c1PPbbcfvtx[icent][ipt], get3err(c2PPbbcfvtx[icent][ipt],c2PPerrbbcfvtx[icent][ipt],c1bbcfvtx[icent][ipt],c1errbbcfvtx[icent][ipt],c1PPbbcfvtx[icent][ipt],c1PPerrbbcfvtx[icent][ipt])); } else{ c2cntbbc[icent][ipt] = c2cntbbc[icent][ipt] - c2PPcntbbc[icent][ipt]*MPPbbc[icent]/Mbbc[icent]; c2cntfvtx[icent][ipt] = c2cntfvtx[icent][ipt] - c2PPcntfvtx[icent][ipt]*MPPfvtx[icent]/Mfvtx[icent]; c2bbcfvtx[icent][ipt] = c2bbcfvtx[icent][ipt] - c2PPbbcfvtx[icent][ipt]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent]); c2errcntbbc[icent][ipt] = get2mierr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],c2PPcntbbc[icent][ipt]*MPPbbc[icent]/Mbbc[icent],c2PPerrcntbbc[icent][ipt]*MPPbbc[icent]/Mbbc[icent]); c2errcntfvtx[icent][ipt] = get2mierr(c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],c2PPcntfvtx[icent][ipt]*MPPfvtx[icent]/Mfvtx[icent],c2PPerrcntfvtx[icent][ipt]*MPPfvtx[icent]/Mfvtx[icent]); c2errbbcfvtx[icent][ipt] = get2mierr(c2bbcfvtx[icent][ipt],c2errbbcfvtx[icent][ipt],c2PPbbcfvtx[icent][ipt]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent]),c2PPerrbbcfvtx[icent][ipt]*(MPPbbc[icent]*MPPfvtx[icent]/MPPNpart[icent])/(Mbbc[icent]*Mfvtx[icent]/MNpart[icent])); } } for(int ipt=0;ipt<npt;ipt++){ v2cntpt1[icent][ipt] = c2cntbbc[icent][ipt]/v2bbc; //v2errcntpt1[icent][ipt] = v2cntpt1[icent][ipt]*sqrt(TMath::Power(c2errcntbbc[icent][ipt]/c2cntbbc[icent][ipt],2)+TMath::Power(v2errbbc/v2bbc,2)); v2errcntpt1[icent][ipt] = get2derr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],v2bbc,v2errbbc); v2cntpt2[icent][ipt] = c2cntfvtx[icent][ipt]/v2fvtx; //v2errcntpt2[icent][ipt] = v2cntpt2[icent][ipt]*sqrt(TMath::Power(c2errcntfvtx[icent][ipt]/c2cntfvtx[icent][ipt],2)+TMath::Power(v2errfvtx/v2fvtx,2)); v2errcntpt2[icent][ipt] = get2derr(c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],v2fvtx,v2errfvtx); ptmean[ipt] = 0.1+0.2*ipt; } //----subtract--------calculating cnt pt dependence v2--------------------method2---------------- float v2cntpt[ncent][npt]; float v2errcntpt[ncent][npt]; for(int ipt=0;ipt<npt;ipt++){ v2cntpt[icent][ipt] = sqrt(c2cntbbc[icent][ipt]*c2cntfvtx[icent][ipt]/c2bbcfvtx[icent][0]); //v2errcntpt[icent][ipt] = v2cntpt[icent][ipt]*sqrt(TMath::Power(c2errcntbbc[icent][ipt]/c2cntbbc[icent][ipt],2)+TMath::Power(c2errcntfvtx[icent][ipt]/c2cntfvtx[icent][ipt],2)+TMath::Power(c2errbbcfvtx[icent][0]/c2bbcfvtx[icent][0],2)); v2errcntpt[icent][ipt] = get3sqerr(c2cntbbc[icent][ipt],c2errcntbbc[icent][ipt],c2cntfvtx[icent][ipt],c2errcntfvtx[icent][ipt],c2bbcfvtx[icent][0],c2errbbcfvtx[icent][0]); ofsub1<<ptmean[ipt]<<" "<<v2cntpt1[icent][ipt]<<" "<<v2errcntpt1[icent][ipt]<<endl; ofsub2<<ptmean[ipt]<<" "<<v2cntpt2[icent][ipt]<<" "<<v2errcntpt2[icent][ipt]<<endl; ofsub<<ptmean[ipt]<<" "<<v2cntpt[icent][ipt]<<" "<<v2errcntpt[icent][ipt]<<endl; } ofsub1.close(); ofsub2.close(); ofsub.close(); } }
void ChTrackTestRig::ExportComponentList(const std::string& filename) const { std::ofstream of(filename); of << ExportComponentList(); }
void mpijob::run_child() { #ifndef __WINDOWS__ // check that this child hasn't been finished by others if (check_finished()) { cout << "child " << conf.get_name() << " is already finished, do nothing." << endl; return ; // already finished, do nothing } // start timer t.start(); string cmd, log, errlog; log << "out_" << conf.get_name() << ".log"; errlog << "out_" << conf.get_name() << ".errlog"; // prepare command cmd << "cd " << outdir << " && echo \"job=" << conf.get_name(); if (conf.exists("meta_conf_shortname")) cmd << " meta_conf_shortname=" << conf.get_string("meta_conf_shortname"); // not finished, check if it has been started in the past if (check_started()) { cout << "child " << conf.get_name() << " is already started but not finished, resuming." << endl; figure_resume_out(); if (conf.exists("retrain_iteration") && conf.exists("retrain_weights") && conf.exists("retrain")) { // add retrain params at the end of job's conf ofstream of(confname.c_str(), ios_base::app); if (!of) eblerror("failed to open conf for appending retrain params: " << confname); of << endl << " retrain_iteration=" << conf.get_string("retrain_iteration") << endl << " retrain_weights=" << conf.get_string("retrain_weights") << endl << " retrain=" << conf.get_string("retrain") << endl; of.close(); } } // set classe filename if defined if (rconf.exists("train") || rconf.exists("train_classes")) { string classesname = conf.get_output_dir(); if (rconf.exists("train")) classesname << "/" << rconf.get_string("train"); else if (rconf.exists("train_classes")) classesname << "/" << rconf.get_string("train_classes"); classesname << CLASSES_NAME << MATRIX_EXTENSION; cmd << " classes=" << classesname; } // set rest of command cmd << " config=" << confname << "\" >> " << log << " && ((" << exe << " " << confname << " 3>&1 1>&2 2>&3 | tee /dev/tty | tee -a " << errlog << ") 3>&1 1>&2 2>&3) >> " << log << " 2>&1 && exit 0"; // execute child cout << endl << "(mpi) Executing job " << basename(confname.c_str()) << " with cmd:" << endl << cmd << endl; int ret = std::system(cmd.c_str()); if (ret != 0) { cerr << "child command error: " << ret << endl; cerr << "WIFSIGNALED(" << ret << "): " << WIFSIGNALED(ret) << endl; cerr << "WTERMSIG(" << ret << "): " << WTERMSIG(ret) << endl; } #else eblerror("not implemented"); #endif }
static void writeImplementationCppFile(const QString& namespaceName, const QString& baseFileName, const std::list<FunctionSignature>& functions, const QString& path, const QString &API, bool templateValue) { QString outputFilename = path + "/" + baseFileName + "_" + API + ".cpp"; QFile of(outputFilename); if ( !of.open(QIODevice::WriteOnly) ) { std::cout << "Could not open " << outputFilename.toStdString() << std::endl; throw std::runtime_error(""); } QTextStream ots(&of); ots << "/*\n" " * THIS FILE WAS GENERATED AUTOMATICALLY FROM glad.h by tools/utils/generateGLIncludes, DO NOT EDIT\n" " */\n" "\n" "#include \"" << baseFileName << ".h\"\n" "#include \"Global/Macros.h\"\n" "\n"; if (!templateValue) { ots << "#ifdef HAVE_OSMESA\n" "#include <GL/gl_mangle.h>\n" "#include <GL/glu_mangle.h>\n" "#include <GL/osmesa.h>\n" "#endif // HAVE_OSMESA\n"; ots << "\n\n"; } if (namespaceName == "Natron") { ots << "NATRON_NAMESPACE_ENTER;\n\n"; } else { ots << "namespace " << namespaceName << " {\n\n"; } // Write the load functions ots << "template <>\n" "void OSGLFunctions<" << (templateValue ? "true" : "false") << ">::load_functions() {\n"; if (!templateValue) { ots << "#ifdef HAVE_OSMESA\n"; } for (std::list<FunctionSignature>::const_iterator it = functions.begin(); it != functions.end(); ++it) { if (templateValue) { // OpenGL functions are directly pointing to the ones loaded by glad { ots << " _" << it->funcName << " = glad_defined(" << it->funcName << ");\n"; } } else { // Mesa functions are loaded ots << " _" << it->funcName << " = (" << it->funcPNType << ")OSMesaGetProcAddress(\"" << it->funcName << "\");\n"; } } if (!templateValue) { ots << "#endif // HAVE_OSMESA\n"; } ots << "} // load_functions\n" "\n"; ots << "template class OSGLFunctions<" << (templateValue ? "true" : "false") << ">;\n" "\n"; if (namespaceName == "Natron") { ots << "NATRON_NAMESPACE_EXIT;\n"; } else { ots << "} // namespace " << namespaceName << "\n"; } } // writeImplementationCppFile