int main(const int argc, char * argv[]) { // Program options InputOptions in; int result = processCommandLineArgs(in, argc, argv); if(result != 0) return result; const fs::path fileToLock(in.lockFile); if(!fs::exists(fileToLock)) { ::std::cerr << "Error: file " << in.lockFile << " does not exist.\n"; return 1; } ip::file_lock lock(fileToLock.string().c_str()); ::std::cout << "Locking " << fileToLock.string() << "..." << ::std::flush; if(in.tryLock) { if(!lock.try_lock()) return 1; } else lock.lock(); ::std::cout << "locked." << ::std::endl; while(true) { boost::this_thread::sleep(boost::posix_time::seconds(100)); } return 0; }
/********************************************************************************** * AUTHOR : Thanigai Murugan K * DATE : 30-AUG-2005 * NAME : main * DESCRIPTION : Main function. Process the command line options and invoke the * train/test methods after instantiating LipiEngine module. * ARGUMENTS : Command line arguments, refer to PrintUsage() function for syntax * RETURNS : -1 on error 0 on success * NOTES : * CHANGE HISTROY * Author Date Description of change *************************************************************************************/ int main(int argc, char** argv) { //char *envstring = NULL; char lipienginepath[MAX_PATH]=""; int iErrorCode; LTKOSUtil* utilPtr = LTKOSUtilFactory::getInstance(); void *functionHandle = NULL; globalArg = argv; globalArgCount = argc; utilPtr->recordStartTime(); // Assume the default log file, if user did not specify one... if(LTKSTRCMP(strLogFile, "") == 0) { strcpy(strLogFile, DEFAULT_LOG_FILE); } if(processCommandLineArgs() != 0) { printUsage(); delete utilPtr; return -1; } if(bVersionRequest) /* Then display version and exit */ { cout << "\n Version of runwordrec tool: " << SUPPORTED_MIN_VERSION << endl; delete utilPtr; return 0; } /* Get the LIPI_ROOT environment variable if the user has not provided in the command line */ if(strlen(strLipiRootPath)==0) { char *tempStr=NULL; /* Get the LIPI_ROOT environment variable */ tempStr=getenv(LIPIROOT_ENV_STRING); if(tempStr == NULL) { cout << "Error,LIPI_ROOT is neither provided in the command line nor set as an environment variable\n" << endl; delete utilPtr; return -1; } strcpy(strLipiRootPath,tempStr); } // Load the LipiEngine.DLL hLipiEngine = NULL; iErrorCode = utilPtr->loadSharedLib(strLipiRootPath, LIPIENGINE_MODULE_STR, &hLipiEngine); if(iErrorCode != SUCCESS) { cout << "Error loading LipiEngine module" << endl; delete utilPtr; return -1; } int iMajor_lipiEngine=0, iMinor_lipiEngine=0, iBugfix_lipiEngine=0; iErrorCode = utilPtr->getFunctionAddress(hLipiEngine, "getToolkitVersion", &functionHandle); if(iErrorCode != SUCCESS) { cout << "Error mapping the getToolkitVersion function" << endl; delete utilPtr; return -1; } LipiEngine_getCurrentVersion = (FN_PTR_GETCURRENTVERSION) functionHandle; LipiEngine_getCurrentVersion(&iMajor_lipiEngine, &iMinor_lipiEngine, &iBugfix_lipiEngine); // Version comparison START char toolkitVer[MAX_STRLEN]; sprintf(toolkitVer, "%d.%d.%d",iMajor_lipiEngine,iMinor_lipiEngine,iBugfix_lipiEngine); LTKVersionCompatibilityCheck verTempObj; string supportedMinVersion(SUPPORTED_MIN_VERSION); string toolkitVersion(toolkitVer); bool compatibilityResults = verTempObj.isFirstVersionHigher(toolkitVersion, supportedMinVersion); if(compatibilityResults == false) { cout<< "\nIncompatible version of LipiEngine(ver: " << toolkitVersion << ") with runwordrec(ver: " << supportedMinVersion << ")" << endl; // Unload the DLL from memory utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return FAILURE; } // Version comparison END // without reserving memory, it gives an error at the end... strLogFileName.reserve(MAX_PATH); /* Get the function address of "createLTKLipiEngine" function from the DLL module */ functionHandle = NULL; iErrorCode = utilPtr->getFunctionAddress(hLipiEngine, "createLTKLipiEngine", &functionHandle); if(iErrorCode != SUCCESS) { cout << "Error mapping the createLTKLipiEngine function" << endl; delete utilPtr; return -1; } createLTKLipiEngine = (FN_PTR_CREATELTKLIPIENGINE) functionHandle; functionHandle = NULL; // Create an instance of LipiEngine ptrObj = createLTKLipiEngine(); // set the LIPI_ROOT path in Lipiengine module instance ptrObj->setLipiRootPath(strLipiRootPath); // set the Log File Path if (strlen(strLogFile) != 0 ) { string tempString(strLogFile); ptrObj->setLipiLogFileName(tempString); } if(strlen(strLogLevel) != 0) { string tempStringLogLevel(strLogLevel); ptrObj->setLipiLogLevel(tempStringLogLevel); } // Initialize the LipiEngine iErrorCode = ptrObj->initializeLipiEngine(); if(iErrorCode != 0) { cout << "Error initializing lipiengine: " << getErrorMessage(iErrorCode) << endl; cout << "For more details, please see the log file" << endl; // Unload the DLL from memory utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } string strProjName(strProjectName), strProfName(strProfileName); // Now create the word recognizer instance using the project/profile name strings LTKWordRecognizer *pReco; iErrorCode = ptrObj->createWordRecognizer(strProjName, strProfName, &pReco); if(iErrorCode != SUCCESS) { cout << "Error creating word recognizer: " << getErrorMessage(iErrorCode) << endl; cout << "For more details, please see the log file" << endl; // Unload the DLL from memory utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } if(bComputePerformance) { utilPtr->recordStartTime(); } iErrorCode = evaluateWordRecognizer(pReco, strTestLstFile); if(iErrorCode != SUCCESS) { cout << "Error during testing the word recognizer: " << getErrorMessage(iErrorCode) << endl; cout << "For more details, please see the log file" << endl; ptrObj->deleteWordRecognizer(&pReco); // Unload the DLL from memory utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return -1; } if(bComputePerformance) { utilPtr->recordEndTime(); string timeTaken = ""; utilPtr->diffTime(timeTaken); cout << "Time taken:" << timeTaken << endl; } // Delete the word recognizer which was created... ptrObj->deleteWordRecognizer(&pReco); // Unload the DLL from memory utilPtr->unloadSharedLib(hLipiEngine); delete utilPtr; return 0; }
int main(int argc, char **argv) { time_t starttime=time(0); struct scalpelState state; if (ldiv(SIZE_OF_BUFFER,SCALPEL_BLOCK_SIZE).rem != 0) { fprintf (stderr, SCALPEL_SIZEOFBUFFER_PANIC_STRING); exit (-1); } #ifndef __GLIBC__ setProgramName(argv[0]); #endif fprintf (stdout,SCALPEL_BANNER_STRING); initializeState(argv,&state); processCommandLineArgs(argc,argv,&state); convertFileNames(&state); if (state.modeVerbose) { fprintf (stdout,"Output directory: \"%s\"\n", state.outputdirectory); fprintf (stdout,"Configuration file: \"%s\"\n", state.conffile); fprintf (stdout,"Coverage maps directory: \"%s\"\n", state.coveragedirectory); } // read configuration file if (readSearchSpecFile(&state)) { // error in configuration file, msg has already been output exit(-1); } setttywidth(); argv += optind; if (*argv != NULL || state.useInputFileList) { // prepare audit file and make sure output directory is empty. if(openAuditFile(&state)){ fprintf(stderr, "Aborting.\n\n"); exit(-1); } digAllFiles(argc,argv,&state); closeFile(state.auditFile); } else { usage(); fprintf(stdout,"\nERROR: No image files specified.\n\n"); } #ifdef __WIN32 fprintf (stdout,"\nScalpel is done, files carved = %I64u, elapsed = %ld seconds.\n", state.fileswritten, (int)time(0) - starttime); #else fprintf (stdout,"\nScalpel is done, files carved = %llu, elapsed = %ld seconds.\n", state.fileswritten, (int)time(0) - starttime); #endif return 0; }
int main(int argc,char *argv[]) { // code starts // main TApplication myApp("myApp", 0, 0 ,0,-1); vector<string> inFileList; // process the file input file list (in case it is desired to run multiple root files as input int returnCode = processCommandLineArgs( argc, argv, inFileList); if(returnCode!=0){ cerr << "Error\n"; return returnCode; } TChain *dataTree = new TChain("dataTree"); // open a TChain and add the opened root files to it for (unsigned int i = 0; i < inFileList.size(); ++i) dataTree->Add(inFileList[i].c_str()); cout << "number of events: " << dataTree->GetEntries() << endl; // check the number of entries in the TChain int sizeTDC_0,sizeTDC_1,sizeTDC_2; // cuántos hits hubieron en un evento double TDC_LE_0[kHitsTDCmax]; // todos los flancos iniciales de los pulsos de un evento, canal 0 (leading edge) double TDC_LE_1[kHitsTDCmax]; // todos los flancos iniciales de los pulsos de un evento, canal 1 double TDC_LE_2[kHitsTDCmax]; double TDC_TE_0[kHitsTDCmax]; // todos los flancos finales de los pulsos de un evento, canal 0 (trailing edge) double TDC_TE_1[kHitsTDCmax]; double TDC_TE_2[kHitsTDCmax]; // determina el estado de las ramas del árbol de root // dataTree->SetBranchStatus("*",0); // apaga todas las ramas dataTree->SetBranchStatus("sizeTDC_0",1); // enciente la rama sizeTDC_0 dataTree->SetBranchStatus("sizeTDC_1",1); // ... dataTree->SetBranchStatus("sizeTDC_2",1); dataTree->SetBranchStatus("TDC_LE_0",1); dataTree->SetBranchStatus("TDC_LE_1",1); dataTree->SetBranchStatus("TDC_LE_2",1); dataTree->SetBranchStatus("TDC_TE_0",1); dataTree->SetBranchStatus("TDC_TE_1",1); dataTree->SetBranchStatus("TDC_TE_2",1); // vincula las ramas del árbol de root con las variables declaradas más arriba dataTree->SetBranchAddress("sizeTDC_0",&sizeTDC_0); // vincula la rama entre comillas llamada sizeTDC_0 con la direccón de memoria donde vive la variable previamente declarada (que hemos llamado igual por simplicidad) dataTree->SetBranchAddress("sizeTDC_1",&sizeTDC_1); dataTree->SetBranchAddress("sizeTDC_2",&sizeTDC_2); dataTree->SetBranchAddress("TDC_LE_0",&TDC_LE_0); dataTree->SetBranchAddress("TDC_LE_1",&TDC_LE_1); dataTree->SetBranchAddress("TDC_LE_2",&TDC_LE_2); dataTree->SetBranchAddress("TDC_TE_0",&TDC_TE_0); dataTree->SetBranchAddress("TDC_TE_1",&TDC_TE_1); dataTree->SetBranchAddress("TDC_TE_2",&TDC_TE_2); { // Open the Ttree and index it event-by-event int n_events = (int) dataTree->GetEntries(); /// /// Inicio /// // Placas en Arreglo A-ch0 B-ch1 C-ch2 int ventana = 50; //Nanosegundos double totT=0, totM=0; //Time over threshold de la placa superior (Top) y media (Mid) ofstream salida; salida.open("timeOverThreshold.dat"); //archivo de salida for(int i=0; i<n_events; i++){ // loop over the number of events start dataTree->GetEntry(i); // pido que la entrada del árbol llene las variables previamente declaradas /////////////////////////////////////////////////// if (sizeTDC_0 > 0 && sizeTDC_1 > 0 ) //Por lo menos una cuenta en A y en B { if ( TDC_LE_1[0] >= TDC_LE_0[0] && TDC_LE_1[0]- TDC_LE_0[0] <= ventana ) // A y B en coincidencia, el pulso llega antes a A { if ( sizeTDC_2 >0 ) // Por lo menos una cuenta en C { if ( TDC_LE_2[0] >= TDC_LE_1[0] && TDC_LE_2[0]- TDC_LE_1[0] <= ventana ) //B y C en coincidencia { totT = TDC_TE_0[0] - TDC_LE_0[0] ; //En este caso placa A totM = TDC_TE_1[0] - TDC_LE_1[0] ; //En este caso placa B // Formato (x,y) salida << totM << "\t" << totT << endl ; } } } } ////////////////////////////////////////////////////// } // End of indexing the TTree } // myApp.Run(); return 0; // main end }
int main(int argc,char *argv[]) { // code starts // main TApplication myApp("myApp", 0, 0 ,0,-1); vector<string> inFileList; // process the file input file list (in case it is desired to run multiple root files as input int returnCode = processCommandLineArgs( argc, argv, inFileList); if(returnCode!=0){ cerr << "Error\n"; return returnCode; } TChain *dataTree = new TChain("dataTree"); // open a TChain and add the opened root files to it for (unsigned int i = 0; i < inFileList.size(); ++i) dataTree->Add(inFileList[i].c_str()); cout << "number of events: " << dataTree->GetEntries() << endl; // check the number of entries in the TChain int sizeTDC_0,sizeTDC_1,sizeTDC_2; // cuántos hits hubieron en un evento double TDC_LE_0[kHitsTDCmax]; // todos los flancos iniciales de los pulsos de un evento, canal 0 (leading edge) double TDC_LE_1[kHitsTDCmax]; // todos los flancos iniciales de los pulsos de un evento, canal 1 double TDC_LE_2[kHitsTDCmax]; double TDC_TE_0[kHitsTDCmax]; // todos los flancos finales de los pulsos de un evento, canal 0 (trailing edge) double TDC_TE_1[kHitsTDCmax]; double TDC_TE_2[kHitsTDCmax]; // determina el estado de las ramas del árbol de root // dataTree->SetBranchStatus("*",0); // apaga todas las ramas dataTree->SetBranchStatus("sizeTDC_0",1); // enciente la rama sizeTDC_0 dataTree->SetBranchStatus("sizeTDC_1",1); // ... dataTree->SetBranchStatus("sizeTDC_2",1); dataTree->SetBranchStatus("TDC_LE_0",1); dataTree->SetBranchStatus("TDC_LE_1",1); dataTree->SetBranchStatus("TDC_LE_2",1); dataTree->SetBranchStatus("TDC_TE_0",1); dataTree->SetBranchStatus("TDC_TE_1",1); dataTree->SetBranchStatus("TDC_TE_2",1); // vincula las ramas del árbol de root con las variables declaradas más arriba dataTree->SetBranchAddress("sizeTDC_0",&sizeTDC_0); // vincula la rama entre comillas llamada sizeTDC_0 con la direccón de memoria donde vive la variable previamente declarada (que hemos llamado igual por simplicidad) dataTree->SetBranchAddress("sizeTDC_1",&sizeTDC_1); dataTree->SetBranchAddress("sizeTDC_2",&sizeTDC_2); dataTree->SetBranchAddress("TDC_LE_0",&TDC_LE_0); dataTree->SetBranchAddress("TDC_LE_1",&TDC_LE_1); dataTree->SetBranchAddress("TDC_LE_2",&TDC_LE_2); dataTree->SetBranchAddress("TDC_TE_0",&TDC_TE_0); dataTree->SetBranchAddress("TDC_TE_1",&TDC_TE_1); dataTree->SetBranchAddress("TDC_TE_2",&TDC_TE_2); { // Open the Ttree and index it event-by-event int n_events = (int) dataTree->GetEntries(); /// /// Inicio /// // Placas en Arreglo A-ch0 B-ch1 C-ch2 int ventana = 50; //Nanosegundos int contadorFiltro = 0; int veto = 500; //Nanosegundos ofstream salida; salida.open("filtro.dat"); //archivo de salida for(int i=0; i<n_events; i++){ // loop over the number of events start dataTree->GetEntry(i); // pido que la entrada del árbol llene las variables previamente declaradas /////////////////////////////////////////////////// if (sizeTDC_0==1 && sizeTDC_1==1 && sizeTDC_2==1) //Exactamente un conteo en cada placa { if ( (TDC_LE_2[0]- TDC_LE_0[0]) <= ventana ) // A y C en coincidencia { if ( (TDC_LE_1[0]- TDC_LE_2[0]) >= veto ) // Sólo se toman en cuenta pulsos con mayor duración al veto { salida << TDC_LE_1[0] - TDC_LE_2[0] << endl ; //Salida al archivo contadorFiltro++; } } } } // End of indexing the TTree //Razón decaimientos muón / eventos totales double razon = static_cast <double> (contadorFiltro) / n_events ; cout << razon << endl; salida.close(); } return 0; // main end }
int main(int argc, char* argv[]) { std::unique_ptr<ExecutionArgs> exArgs(new ExecutionArgs()); if (!processCommandLineArgs(argc, argv, *exArgs)) { return -1; } else if (exArgs->helpPrompt) { std::cout << "Usage: sts [--help] || [--config]" << std::endl; std::cout << "Options:" << std::endl; std::cout << "\t --help - print this message;" << std::endl; std::cout << "\t --config - show config dialog." << std::endl; std::cout << std::endl; return 0; } try { Ogre::String lConfigFileName = "ogre.cfg"; Ogre::String lPluginsFileName = "plugins.cfg"; Ogre::String lLogFileName = "Ogre_STS.log"; std::unique_ptr<Ogre::Root> lRoot(new Ogre::Root(lPluginsFileName, lConfigFileName, lLogFileName)); if (exArgs->showConfigDialog) { if (!lRoot->showConfigDialog()) { return 0; } } Ogre::String lWindowTitle = "STS"; Ogre::String lCustomCapacities = ""; /* Check for the valid ogre.cfg */ bool lCreateAWindowAutomatically = lRoot->restoreConfig(); if (!lCreateAWindowAutomatically) { initSomeRenderSystem(lRoot); } Ogre::RenderWindow* lWindow = lRoot->initialise(lCreateAWindowAutomatically, lWindowTitle, lCustomCapacities); if (!lWindow) { /* ogre.cfg is not available - start with hardcoded parameters */ unsigned int lSizeX = 800; unsigned int lSizeY = 600; bool lFullscreen = false; Ogre::NameValuePairList lParams; lParams["FSAA"] = "0"; lParams["vsync"] = "true"; lWindow = lRoot->createRenderWindow(lWindowTitle, lSizeX, lSizeY, lFullscreen, &lParams); } /* Create a scene manager */ Ogre::SceneManager* lScene = lRoot->createSceneManager(Ogre::ST_GENERIC, "SceneManager"); Ogre::SceneNode* lRootSceneNode = lScene->getRootSceneNode(); /* Create camera */ Ogre::Camera* lCamera = lScene->createCamera("MyCamera"); /* Create viewport (camera <-> window) */ Ogre::Viewport* vp = lWindow->addViewport(lCamera); vp->setAutoUpdated(true); vp->setBackgroundColour(Ogre::ColourValue(1, 0, 1)); lCamera->setAspectRatio(float(vp->getActualWidth()) / vp->getActualHeight()); lCamera->setPosition(Ogre::Vector3(0, 100, -1)); lCamera->lookAt(Ogre::Vector3(0, 0, 0)); /* Set clipping*/ lCamera->setNearClipDistance(1.5f); lCamera->setFarClipDistance(3000.0f); /* Lighting */ Ogre::Light* lLight = lScene->createLight("MainLight"); lLight->setPosition(Ogre::Vector3(0, 100, 0)); /* Resource manager */ Ogre::String lRcGroupName = "Main group"; initResourceMainGroup(lRcGroupName); /* Load model */ Ogre::Entity* lShipEntity = lScene->createEntity("airship.mesh"); lShipEntity->setCastShadows(false); Ogre::SceneNode* lShipNode = lRootSceneNode->createChildSceneNode(); lShipNode->attachObject(lShipEntity); lShipNode->setScale(Ogre::Vector3(3.15f, 3.15f, 3.15f)); /* Starship start point */ Ogre::Vector3 razorSP(0, -200, -100); lShipNode->setPosition(razorSP); /* Sprite billboard */ Ogre::SceneNode* lSpriteNode = lRootSceneNode->createChildSceneNode(); Ogre::BillboardSet* lBillboardSet = lScene->createBillboardSet(); lBillboardSet->setMaterialName("enemy_01", lRcGroupName); lBillboardSet->setTextureStacksAndSlices(1, 4); Ogre::Billboard* lSpriteBillboard = lBillboardSet->createBillboard(Ogre::Vector3(0, 0, 0)); lSpriteBillboard->setDimensions(48.0f / 2.0f, 58.0f / 2.0f); lSpriteBillboard->setTexcoordIndex(1); lSpriteNode->attachObject(lBillboardSet); lSpriteNode->setPosition(Ogre::Vector3(0, -200, 100)); /* Obtain the timer pointer */ Ogre::Timer* lTimer = lRoot->getTimer(); /* Skip all the messages */ lWindow->setAutoUpdated(false); lRoot->clearEventTimes(); while (!lWindow->isClosed()) { float angle = Ogre::Math::Sin(float(lTimer->getMilliseconds()) * Ogre::Math::PI / 2000.0f) * Ogre::Math::PI / 4.0f; float diplacement = Ogre::Math::Cos(float(lTimer->getMilliseconds()) * Ogre::Math::PI / 2000.0f) * 100.0f; lShipNode->setOrientation(Ogre::Quaternion(Ogre::Radian(angle), Ogre::Vector3(0, 0, 1))); lShipNode->setPosition(razorSP + Ogre::Vector3(diplacement, 0.0f, 0.0f)); unsigned int spriteFrame = (lTimer->getMilliseconds() / 125) % 2; lSpriteBillboard->setTexcoordIndex(spriteFrame); lWindow->update(false); lWindow->swapBuffers(); lRoot->renderOneFrame(); Ogre::WindowEventUtilities::messagePump(); } Ogre::LogManager::getSingleton().logMessage("Render window closed."); } catch (Ogre::Exception &e) { std::cerr << "Ogre::Exception: " << e.what() << std::endl; } catch (std::exception &e) { std::cerr << "std::exception: " << e.what() << std::endl; } return 0; }