Skip to content
Snippets Groups Projects
Commit a70ab3e3 authored by adrien-matta's avatar adrien-matta
Browse files

* Fixing npanalysis

parent f2dd4d32
No related branches found
No related tags found
No related merge requests found
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
// STL // STL
#include<iostream> #include<iostream>
#include <dlfcn.h> #include<stdio.h>
#include<dlfcn.h>
#include<stdlib.h>
#ifndef SHARED_LIB_EXTENSION_GLOB #ifndef SHARED_LIB_EXTENSION_GLOB
#define SHARED_LIB_EXTENSION_GLOB #define SHARED_LIB_EXTENSION_GLOB
...@@ -25,10 +27,12 @@ std::string SHARED_LIB_EXTENSION = ".dylib"; ...@@ -25,10 +27,12 @@ std::string SHARED_LIB_EXTENSION = ".dylib";
#endif #endif
#endif #endif
void ProgressDisplay(clock_t&,clock_t&,unsigned int&, unsigned int&, int&);
int main(int argc , char** argv){ int main(int argc , char** argv){
// command line parsing // command line parsing
NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv);
// if input files are not given, use those from TAsciiFile // if input files are not given, use those from TAsciiFile
if (myOptionManager->IsDefault("DetectorConfiguration")) { if (myOptionManager->IsDefault("DetectorConfiguration")) {
string name = RootInput::getInstance()->DumpAsciiFile("DetectorConfiguration"); string name = RootInput::getInstance()->DumpAsciiFile("DetectorConfiguration");
...@@ -42,7 +46,7 @@ int main(int argc , char** argv){ ...@@ -42,7 +46,7 @@ int main(int argc , char** argv){
// Instantiate RootOutput // Instantiate RootOutput
RootOutput::getInstance("Analysis/"+OutputfileName, "ResultTree"); RootOutput::getInstance("Analysis/"+OutputfileName, "ResultTree");
TTree* tree= RootOutput::getInstance()->GetTree(); TTree* tree= RootOutput::getInstance()->GetTree();
// Instantiate the detector using a file // Instantiate the detector using a file
NPA::DetectorManager* myDetector = new DetectorManager(); NPA::DetectorManager* myDetector = new DetectorManager();
myDetector->ReadConfigurationFile(detectorfileName); myDetector->ReadConfigurationFile(detectorfileName);
...@@ -66,9 +70,14 @@ int main(int argc , char** argv){ ...@@ -66,9 +70,14 @@ int main(int argc , char** argv){
nentries = myOptionManager->GetNumberOfEntryToAnalyse() ; nentries = myOptionManager->GetNumberOfEntryToAnalyse() ;
std::cout << " Number of Event to be treated : " << nentries << std::endl; std::cout << " Number of Event to be treated : " << nentries << std::endl;
clock_t begin = clock();
clock_t end = begin;
unsigned int treated = 0;
unsigned int inter = 0;
if(UserAnalysis==NULL){ if(UserAnalysis==NULL){
for (int i = 0 ; i < nentries; i++) { for (unsigned int i = 0 ; i < nentries; i++) {
ProgressDisplay(begin,end,treated,inter,nentries);
// Get the raw Data // Get the raw Data
Chain -> GetEntry(i); Chain -> GetEntry(i);
// Clear previous Event // Clear previous Event
...@@ -81,7 +90,8 @@ int main(int argc , char** argv){ ...@@ -81,7 +90,8 @@ int main(int argc , char** argv){
} }
else{ else{
for (int i = 0 ; i < nentries; i++) { for (unsigned int i = 0 ; i < nentries; i++) {
ProgressDisplay(begin,end,treated,inter,nentries);
// Get the raw Data // Get the raw Data
Chain -> GetEntry(i); Chain -> GetEntry(i);
// Clear previous Event // Clear previous Event
...@@ -95,7 +105,29 @@ int main(int argc , char** argv){ ...@@ -95,7 +105,29 @@ int main(int argc , char** argv){
} }
UserAnalysis->End(); UserAnalysis->End();
} }
ProgressDisplay(begin,end,treated,inter,nentries);
RootOutput::getInstance()->Destroy(); RootOutput::getInstance()->Destroy();
return 0; return 0;
} }
////////////////////////////////////////////////////////////////////////////////
void ProgressDisplay(clock_t& begin, clock_t& end, unsigned int& treated,unsigned int& inter,int& total){
end = clock();
if((end-begin)/CLOCKS_PER_SEC>CLOCKS_PER_SEC||treated>=total ){
long double elapsed =(long double) (end-begin)/CLOCKS_PER_SEC;
double event_rate = inter/elapsed;
double percent = 100*treated/total;
double remain = (total-treated)/event_rate;
if(treated!=total)
printf("\r \033[1;31m ******* Progress: %.1f | Rate: %.1f evt/s | Remain: %.1fs *******\033[0m", percent,event_rate,remain);
else
printf("\r \033[1;32m ******* Progress: %.1f | Rate: %.1f evt/s | Remain: %.1fs *******\033[0m", percent,event_rate,remain);
fflush(stdout);
begin = clock() ;
inter=0;
}
treated++;
inter++;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment