Skip to content
Snippets Groups Projects
Commit 13c7d291 authored by de Séréville Nicolas's avatar de Séréville Nicolas
Browse files

+ Update the cats benchmark

parent 0ee84c64
No related branches found
No related tags found
No related merge requests found
#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 ;
}
// 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 ;
// ----------------------------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////////////////////
# 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
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: 2. To see the results of the analysis, launch root and execute the macro ShowResult.C
./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
.x 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
...@@ -9,13 +9,12 @@ void ShowResult() ...@@ -9,13 +9,12 @@ void ShowResult()
c1->cd(); c1->cd();
// Y versus X for CATS1 detector // Y versus X for CATS1 detector
chain->Draw("PositionY[0]:PositionX[0]>>h(600,-30,30,600,-30,30)","","colz"); chain->Draw("PositionY[0]:PositionX[0]>>h(600,-30,30,600,-30,30)","","colz");
return 0;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void LoadChain(){ void LoadChain(){
chain = new TChain("AnalysedTree"); chain = new TChain("PhysicsTree");
chain->Add("../../Outputs/Analysis/Analysed_test_cats_mask_e644.root"); // chain->Add("../../Outputs/Analysis/Analysed_test_cats_mask_e644.root");
} chain->Add("../../Outputs/Analysis/PhysicsTree.root");
\ No newline at end of file }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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
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