From 13c7d2911c05895a5ac25c1fcc41b42030218d24 Mon Sep 17 00:00:00 2001 From: Nicolas de Sereville <deserevi@ipno.in2p3.fr> Date: Fri, 11 Dec 2015 15:39:57 +0100 Subject: [PATCH] + Update the cats benchmark --- Benchmarks/cats/Analysis.cxx | 77 --------------- Benchmarks/cats/Analysis.h | 124 ------------------------ Benchmarks/cats/Makefile | 30 ------ Benchmarks/cats/README.txt | 10 +- Benchmarks/cats/ShowResult.C | 9 +- Benchmarks/cats/benchmark_cats.detector | 14 +++ 6 files changed, 22 insertions(+), 242 deletions(-) delete mode 100644 Benchmarks/cats/Analysis.cxx delete mode 100644 Benchmarks/cats/Analysis.h delete mode 100644 Benchmarks/cats/Makefile create mode 100644 Benchmarks/cats/benchmark_cats.detector diff --git a/Benchmarks/cats/Analysis.cxx b/Benchmarks/cats/Analysis.cxx deleted file mode 100644 index fa565f1cd..000000000 --- a/Benchmarks/cats/Analysis.cxx +++ /dev/null @@ -1,77 +0,0 @@ -#include "Analysis.h" -using namespace std; - -int main(int argc, char** argv) -{ - // command line parsing - NPOptionManager* myOptionManager = NPOptionManager::getInstance(argc,argv); - - // Instantiate RootInput - string runToReadfileName = myOptionManager->GetRunToReadFile(); - RootInput:: getInstance(runToReadfileName); - - // if input files are not given, use those from TAsciiFile - if (myOptionManager->IsDefault("DetectorConfiguration")) { - string name = RootInput::getInstance()->DumpAsciiFile("DetectorConfiguration"); - myOptionManager->SetDetectorFile(name); - } - - // get input files from NPOptionManager - string detectorfileName = myOptionManager->GetDetectorFile(); - string calibrationfileName = myOptionManager->GetCalibrationFile(); - string OutputfileName = myOptionManager->GetOutputFile(); - - // Instantiate RootOutput - //RootOutput::getInstance("Analysis/"+OutputfileName, "AnalysedTree"); - RootOutput::getInstance("Analysis/Analysed_test_cats_mask_e644", "AnalysedTree"); - - // Instantiate the detector using a file - NPA::DetectorManager* myDetector = new DetectorManager(); - myDetector->ReadConfigurationFile(detectorfileName); - - // Get the formed Chained Tree and Treat it - TChain* Chain = RootInput:: getInstance() -> GetChain(); - - // Get number of events to treat - cout << endl << "///////// Starting Analysis ///////// "<< endl; - int nentries = Chain->GetEntries(); - cout << " Number of Event to be treated : " << nentries << endl; - clock_t begin = clock(); - clock_t end = begin; - - // main loop on entries - for (int i = 0; i < nentries; i++) { - if (i%10000 == 0 && i!=0) { - cout.precision(5); - end = clock(); - double TimeElapsed = (end-begin) / CLOCKS_PER_SEC; - double percent = (double)i/nentries; - double TimeToWait = (TimeElapsed/percent) - TimeElapsed; - cout << " "<< flush; - cout << "\r Progression:" << percent*100 << " % \t | \t Remaining time : ~" << TimeToWait <<"s"<< flush; - } - else if (i == nentries-1) cout << "\r Progression:" << " 100% " <<endl; - - // get data - Chain -> GetEntry(i); - - - myDetector->ClearEventPhysics(); - myDetector->BuildPhysicalEvent(); - - /************************************************ - - Put your code here - - ************************************************/ - RootOutput::getInstance()->GetTree()->Fill(); - } - - cout << "A total of " << nentries << " event has been annalysed " << endl ; - - RootOutput::getInstance()->Destroy(); - RootInput::getInstance()->Destroy(); - NPOptionManager::getInstance()->Destroy(); - - return 0 ; -} diff --git a/Benchmarks/cats/Analysis.h b/Benchmarks/cats/Analysis.h deleted file mode 100644 index d5ca8c305..000000000 --- a/Benchmarks/cats/Analysis.h +++ /dev/null @@ -1,124 +0,0 @@ -// You can use this file to declare your spectra, file, energy loss , ... and whatever you want. -// This way you can remove all unnecessary declaration in the main programm. -// In order to help debugging and organizing we use Name Space. - -///////////////////////////////////////////////////////////////////////////////////////////////// -// -------------------------------------- VARIOUS INCLUDE --------------------------------------- - -// NPA -#include "DetectorManager.h" -#include "NPOptionManager.h" - -// STL C++ -#include <iostream> -#include <fstream> -#include <sstream> -#include <string> -#include <cmath> -#include <cstdlib> - -// ROOT -#include <TROOT.h> -#include <TChain.h> -#include <TFile.h> -#include <TLeaf.h> -#include <TVector3.h> -#include <TRandom.h> - -// NPL -#include "RootInput.h" -#include "RootOutput.h" -#include "NPReaction.h" -#include "TInitialConditions.h" -#include "TPlasticData.h" -#include "TMust2Data.h" -#include "TMust2Physics.h" -#include "TExogamPhysics.h" -#include "TSSSDPhysics.h" -#include "TPlasticPhysics.h" -#include "GaspardTracker.h" - -// Use CLHEP System of unit and Physical Constant -#include "NPGlobalSystemOfUnits.h" -#include "NPPhysicalConstants.h" - - -// ---------------------------------------------------------------------------------------------- -double ThetaCalculation (TVector3 A , TVector3 B) ; -///////////////////////////////////////////////////////////////////////////////////////////////// -// ----------------------------------- DOUBLE, INT, BOOL AND MORE ------------------------------- -namespace VARIABLE - { - // Declare your Variable here: - - double X1,Y1,Z1 ; - int N1,N2 = 0 ; - bool check= false ; - - // A Usefull Simple Random Generator - TRandom Rand; - } - -using namespace VARIABLE ; -// ---------------------------------------------------------------------------------------------- - - - -///////////////////////////////////////////////////////////////////////////////////////////////// -// -----------------------------------GRAPH------------------------------------------------------ -#include <TObject.h> -#include <TH1.h> -#include <TH1F.h> -#include <TH2.h> -#include <TH2F.h> -#include <TGraph2D.h> - -namespace GRAPH - { - // Declare your Spectra here: - - TH1F *myHist1D = new TH1F("Hist1D","Histogramm 1D ; x ; count", 1000 , -5 , 5 ) ; - - TH2F *myHist2D = new TH2F("Hist2D","Histogramm 2D ; x ; y ", 128 , 1 , 128 , 128 , 1 , 128 ) ; - - } - -using namespace GRAPH ; -// -------------------------------------------------------------------------------------------- - - - -/////////////////////////////////////////////////////////////////////////////////////////////// -// -----------------------------------CUT------------------------------------------------------ -#include <TCutG.h> -namespace CUT - { - // Declare your Cut here: - - } - -using namespace CUT ; -// -------------------------------------------------------------------------------------------- - - - -//////////////////////////////////////////////////////////////////////////////////////////////// -// -----------------------------------ENERGY LOSS---------------------------------------------- -#include "NPEnergyLoss.h" -using namespace NPL ; -namespace ENERGYLOSS - { - - // Declare your Energy loss here : - /* EnergyLoss ProtonTarget = EnergyLoss ( "CD2.txt" , - 100 , - 1, - 1 ); - */ - } - -using namespace ENERGYLOSS ; -// ---------------------------------------------------------------------------------------------- -///////////////////////////////////////////////////////////////////////////////////////////////// - - diff --git a/Benchmarks/cats/Makefile b/Benchmarks/cats/Makefile deleted file mode 100644 index bdfccb1e4..000000000 --- a/Benchmarks/cats/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# include same architecture file than for NPLib -# so that consistency is ensured -include $(NPTOOL)/NPLib/Makefile.arch - -# additional libraries -LIBRARY = `$(NPTOOL)/NPLib/liblist` - -PROGRAMS = Analysis - -all: $(PROGRAMS) - -Analysis: Analysis.o - $(LD) $(LDFLAGS) $^ $(LIBS) $(LIBRARY) $(OutPutOpt) $@ - @echo "$@ done" - - -# rule for creating .o from .cxx -.SUFFIXES: .$(SrcSuf) -.$(SrcSuf).$(ObjSuf): - $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< - -# some cleaning -clean: - rm -rf *.o - -distclean: - make clean; rm $(PROGRAMS) - -# dependences -Analysis.o: Analysis.cxx Analysis.h diff --git a/Benchmarks/cats/README.txt b/Benchmarks/cats/README.txt index 99e553395..2b3ad4ca4 100644 --- a/Benchmarks/cats/README.txt +++ b/Benchmarks/cats/README.txt @@ -1,9 +1,7 @@ -1- Compile program by doing in command line: make +1. Type the following command line to execute the benchmark: + npanalysis -D benchmark_cats.detector -R RunToTreat.txt -C calibration.txt -2- Type the following command line to execute the code: - ./Analysis -D e644.detector -R RunToTreat.txt -C calibration.txt - -3- To see the result of tha analysis, launch root and execute the macro ShowResult.C +2. To see the results of the analysis, launch root and execute the macro ShowResult.C .x ShowResult.C - The plot Y versus X should appear with the different spots that correspond to the holes of the mask +3. You can compare the results of the benchmark with the reference figure ResultBenchmark.png diff --git a/Benchmarks/cats/ShowResult.C b/Benchmarks/cats/ShowResult.C index c0cbae88d..e8993e792 100644 --- a/Benchmarks/cats/ShowResult.C +++ b/Benchmarks/cats/ShowResult.C @@ -9,13 +9,12 @@ void ShowResult() c1->cd(); // Y versus X for CATS1 detector chain->Draw("PositionY[0]:PositionX[0]>>h(600,-30,30,600,-30,30)","","colz"); - - return 0; } //////////////////////////////////////////////////////////////////////////////// void LoadChain(){ - chain = new TChain("AnalysedTree"); - chain->Add("../../Outputs/Analysis/Analysed_test_cats_mask_e644.root"); -} \ No newline at end of file + chain = new TChain("PhysicsTree"); +// chain->Add("../../Outputs/Analysis/Analysed_test_cats_mask_e644.root"); + chain->Add("../../Outputs/Analysis/PhysicsTree.root"); +} diff --git a/Benchmarks/cats/benchmark_cats.detector b/Benchmarks/cats/benchmark_cats.detector new file mode 100644 index 000000000..ddbb22766 --- /dev/null +++ b/Benchmarks/cats/benchmark_cats.detector @@ -0,0 +1,14 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSArray +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +CATSDetector + X1_Y1= 38.86 -34.36 -1193 + X28_Y1= -32.26 -34.36 -1193 + X1_Y28= 38.86 37.36 -1193 + X28_Y28= -32.26 37.36 -1193 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%2 +CATSDetector + X1_Y1= -35.56 -35.36 -684 + X28_Y1= 35.56 -35.36 -684 + X1_Y28= -35.56 35.76 -684 + X28_Y28= 35.56 35.76 -684 -- GitLab