Skip to content
Snippets Groups Projects
Commit 2795941e authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* npanalyis -T flag now create a unique RunToTreat file containing the

  process PID to avoid collision when running multiple npanalys in
  parallel
parent 758fa1c4
No related branches found
No related tags found
No related merge requests found
...@@ -20,70 +20,78 @@ ...@@ -20,70 +20,78 @@
* * * *
*****************************************************************************/ *****************************************************************************/
#include "NPCore.h" #include "NPCore.h"
#include<iostream> #include <iostream>
#include<string> #include <string>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void NPL::SendWarning(std::string Class, std::string Warning){ void NPL::SendWarning(std::string Class, std::string Warning) {
std::cerr << "\033[5;34m"; std::cerr << "\033[5;34m";
std::cerr << "Warning: " << Class << "::" << Warning << "\033[0m"<<std::endl; std::cerr << "Warning: " << Class << "::" << Warning << "\033[0m" << std::endl;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void NPL::SendInformation(std::string Class, std::string Information){ void NPL::SendInformation(std::string Class, std::string Information) {
std::cerr << "\033[1;32m"; std::cerr << "\033[1;32m";
std::cerr << "Information: " << Class << "::" << Information << "\033[0m"<<std::endl; std::cerr << "Information: " << Class << "::" << Information << "\033[0m" << std::endl;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void NPL::SendErrorAndExit(std::string Class , std::string Error){ void NPL::SendErrorAndExit(std::string Class, std::string Error) {
std::cerr << std::endl; std::cerr << std::endl;
std::cerr << "\033[7;30m" std::cerr << "\033[7;30m"
"******************************* NPTOOL ERROR ***********************************"; "******************************* NPTOOL ERROR ***********************************";
std::cerr << "\033[0m" << "\033[2;30m" << std::endl; std::cerr << "\033[0m"
<< "\033[2;30m" << std::endl;
std::cerr << "Class: " << Class << std::endl; std::cerr << "Class: " << Class << std::endl;
std::cerr << "Error: " << Error << std::endl; std::cerr << "Error: " << Error << std::endl;
std::cerr << "\033[7;30m********************************************************************************" std::cerr << "\033[7;30m********************************************************************************"
"\033[0m"<<std::endl; "\033[0m"
<< std::endl;
std::cerr << std::endl; std::cerr << std::endl;
exit(1); exit(1);
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
namespace NPL{ namespace NPL {
static std::string itoa_array[10000]; static std::string itoa_array[10000];
class itoa_proxy{ class itoa_proxy {
public: public:
itoa_proxy(){ itoa_proxy() {
char buffer[]="10000"; char buffer[] = "10000";
for(int i = 0 ; i < 10000 ; i++){ for (int i = 0; i < 10000; i++) {
sprintf(buffer,"%d",i); sprintf(buffer, "%d", i);
itoa_array[i] = buffer; itoa_array[i] = buffer;
}
} }
}
}; };
static itoa_proxy itoa_p ; static itoa_proxy itoa_p;
} } // namespace NPL
////////////////////////////////////////////////////////////////////////////////
std::string NPL::itoa(const int& i){ std::string NPL::itoa(const int& i) {
if (i > 10000) {
static char buffer[1024];
sprintf(buffer, "%d", i);
return std::string(buffer);
}
return NPL::itoa_array[i]; return NPL::itoa_array[i];
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
unsigned int NPL::EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal, const int& ADCMax){ unsigned int NPL::EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal,
const int& ADCMax) {
double Crange = ADCMax - Pedestal; double Crange = ADCMax - Pedestal;
double Erange = Emax - Emin; double Erange = Emax - Emin;
// Standard case where larger ADC channel means larger Energy // Standard case where larger ADC channel means larger Energy
if(Crange > 0){ if (Crange > 0) {
double answer = Crange*E/Erange + Pedestal; double answer = Crange * E / Erange + Pedestal;
if(answer > ADCMax) if (answer > ADCMax)
answer = ADCMax; answer = ADCMax;
return answer; return answer;
} }
// Reverse coding case where larger ADC channel means smaller Energy // Reverse coding case where larger ADC channel means smaller Energy
else{ else {
double answer = Crange*E/Erange + Pedestal; double answer = Crange * E / Erange + Pedestal;
if(answer < ADCMax) if (answer < ADCMax)
answer = ADCMax; answer = ADCMax;
return answer; return answer;
} }
return -1000; return -1000;
} }
...@@ -22,13 +22,14 @@ ...@@ -22,13 +22,14 @@
* * * *
*****************************************************************************/ *****************************************************************************/
#include<string> #include <string>
namespace NPL{ namespace NPL {
std::string itoa(const int&); std::string itoa(const int&);
void SendWarning(std::string Class, std::string Warning); void SendWarning(std::string Class, std::string Warning);
void SendInformation(std::string Class, std::string Information); void SendInformation(std::string Class, std::string Information);
void SendErrorAndExit(std::string Class,std::string Error); void SendErrorAndExit(std::string Class, std::string Error);
// For use to simulate electronic // For use to simulate electronic
unsigned int EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal, const int& ADCMax); unsigned int EnergyToADC(const double& E, const double& Emin, const double& Emax, const int& Pedestal,
} const int& ADCMax);
} // namespace NPL
#endif #endif
This diff is collapsed.
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