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

* Fixing bug in progress display

* make the programm sleep a milli second after the thread started
parent fbf75e48
No related branches found
No related tags found
No related merge requests found
......@@ -68,20 +68,17 @@ void NPA::DetectorManager::ReadConfigurationFile(string Path) {
// All The detector will then add to it their parameter (see AddDetector)
CalibrationManager::getInstance(NPOptionManager::getInstance()->GetCalibrationFile());
// Access the DetectorFactory and ask it to load the Class List
string classlist = getenv("NPTOOL");
classlist += "/NPLib/DetectorClassList.txt";
NPA::DetectorFactory* theFactory = NPA::DetectorFactory::getInstance();
theFactory->ReadClassList(classlist);
ifstream ConfigFile;
ConfigFile.open(Path.c_str());
string LineBuffer;
set<string> check;
if (ConfigFile.is_open()) {
cout << endl << "/////////// Detector geometry ///////////" << endl;
cout << "Configuration file " << Path << " loading " << endl;
......@@ -290,8 +287,9 @@ void NPA::DetectorManager::InitThreadPool(){
th.detach();
}
cout << "\033[1;33m Detector Manager : Started " << i << " Threads \033[0m" << endl ;
cout << "\033[1;33m**** Detector Manager : Started " << i << " Threads ****\033[0m" << endl ;
// Sleep to let the time to the thread to start
this_thread::sleep_for (std::chrono::milliseconds(1));
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -31,9 +31,8 @@
#include "TAsciiFile.h"
RootInput* RootInput::instance = 0;
RootInput* RootInput::getInstance(string configFileName)
{
////////////////////////////////////////////////////////////////////////////////
RootInput* RootInput::getInstance(string configFileName){
// A new instance of RootInput is created if it does not exist:
if (instance == 0) {
instance = new RootInput(configFileName);
......@@ -43,21 +42,16 @@ RootInput* RootInput::getInstance(string configFileName)
return instance;
}
void RootInput::Destroy()
{
////////////////////////////////////////////////////////////////////////////////
void RootInput::Destroy(){
if (instance != 0) {
delete instance;
instance = 0;
}
}
// fileNameBase doit etre le nom du TChain.
RootInput::RootInput(string configFileName)
{
////////////////////////////////////////////////////////////////////////////////
RootInput::RootInput(string configFileName){
NumberOfFriend = 0;
bool CheckTreeName = false;
bool CheckRootFileName = false;
......@@ -77,8 +71,8 @@ RootInput::RootInput(string configFileName)
cout << "Initializing input TChain" << endl;
if (!inputConfigFile) {
cout << "Run to Read file :" << configFileName << " not found " << endl;
return;
cout << "\033[1;31mError : Run to Read file :" << configFileName << " not found\033[0m" << endl;
exit(1);
}
else {
while (!inputConfigFile.eof()) {
......@@ -143,12 +137,11 @@ RootInput::RootInput(string configFileName)
if (!CheckRootFileName || !CheckTreeName)
cout << "\033[1;33mWARNING: Token not found for InputTree Declaration : Input Tree may not be instantiate properly\033[0m" << endl;
}
}
void RootInput::AddFriendChain(string RunToAdd)
{
////////////////////////////////////////////////////////////////////////////////
void RootInput::AddFriendChain(string RunToAdd){
NumberOfFriend++;
ostringstream suffix_buffer;
suffix_buffer << "_" << NumberOfFriend ;
......@@ -217,10 +210,8 @@ void RootInput::AddFriendChain(string RunToAdd)
cout << "/////////////////////////////////" << endl;
}
string RootInput::DumpAsciiFile(const char* type, const char* folder)
{
////////////////////////////////////////////////////////////////////////////////
string RootInput::DumpAsciiFile(const char* type, const char* folder){
string name;
string sfolder = folder;
......@@ -283,10 +274,8 @@ string RootInput::DumpAsciiFile(const char* type, const char* folder)
return name;
}
RootInput::~RootInput()
{
////////////////////////////////////////////////////////////////////////////////
RootInput::~RootInput(){
// delete default directory ./.tmp
struct stat dirInfo;
int res = stat("./.tmp", &dirInfo);
......@@ -298,9 +287,8 @@ RootInput::~RootInput()
//delete pRootChain;
}
/////////////////////////////////////////////////////////////////////
TChain* MakeFriendTrees(string RunToRead1,string RunToRead2)
{
////////////////////////////////////////////////////////////////////////////////
TChain* MakeFriendTrees(string RunToRead1,string RunToRead2){
RootInput:: getInstance(RunToRead1) ;
RootInput:: getInstance()->AddFriendChain(RunToRead2);
return RootInput:: getInstance()->GetChain();
......
......@@ -84,20 +84,19 @@ int main(int argc , char** argv){
unsigned int treated = 0;
if(UserAnalysis==NULL){
for (unsigned int i = 0 ; i < nentries; i++) {
ProgressDisplay(begin,end,treated,inter,nentries);
// Get the raw Data
Chain -> GetEntry(i);
// Build the current event
myDetector->BuildPhysicalEvent();
// Fill the tree
tree->Fill();
ProgressDisplay(begin,end,treated,inter,nentries);
}
}
else{
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);
// Build the current event
myDetector->BuildPhysicalEvent();
......@@ -105,6 +104,7 @@ int main(int argc , char** argv){
UserAnalysis->TreatEvent();
// Fill the tree
tree->Fill();
ProgressDisplay(begin,end,treated,inter,nentries);
}
UserAnalysis->End();
}
......@@ -128,21 +128,21 @@ void ProgressDisplay(clock_t& begin, clock_t& end, unsigned int& treated,unsigne
char* timer;
if(remain>60)
asprintf(&timer,"%.dmin",(int)(remain/60.));
asprintf(&timer,"%dmin",(int)(remain/60.));
else
asprintf(&timer,"%.ds",(int)(remain));
asprintf(&timer,"%ds",(int)(remain));
if(treated!=total){
printf("\r ");
if(treated!=total)
printf("\r \033[1;31m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,event_rate/1000.,timer);
}
else
printf("\r \033[1;32m ******* Progress: %.1f%% | Rate: %.1fk evt/s | Remain: %s *******\033[0m", percent,event_rate/1000.,timer);
fflush(stdout);
begin = clock() ;
inter=0;
}
treated++;
treated++;
inter++;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment