Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit d03139bf authored by adrien-matta's avatar adrien-matta
Browse files

Merge branch 'NPTool.2.dev' of gitlab.in2p3.fr:np/nptool into NPTool.2.dev

parents d6991487 518e3060
Pipeline #91162 passed with stages
in 9 minutes and 53 seconds
0 1
0.1 1
0.2 1
0.3 1
0.4 1
0.5 1
0.6 1
0.7 1
0.8 1
0.9 1
1 1
1.1 1
1.2 1
1.3 1
1.4 1
1.5 1
1.6 1
1.7 1
1.8 1
1.9 1
2 1
2.1 1
2.2 1
2.3 1
2.4 1
2.5 1
2.6 1
2.7 1
2.8 1
2.9 1
3 1
3.1 1
3.2 1
3.3 1
3.4 1
3.5 1
3.6 1
3.7 1
3.8 1
3.9 1
4 1
4.1 0
4.2 0
4.3 0
4.4 0
4.5 0
4.6 0
4.7 0
4.8 0
4.9 0
5 0
5.1 0
180 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%% Reaction file for 238U transfer reaction %%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%Beam energy given in MeV ; Excitation in MeV ; emmitance in rad
Beam
Particle= 238U
Energy= 166000
SigmaEnergy= 2
SigmaX= 1 cm
SigmaY= 1 cm
SigmaThetaX= 0
SigmaPhiY= 0
MeanThetaX= 0
MeanPhiY= 0
MeanX= 0
MeanY= 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
TwoBodyReaction
Beam= 238U
Target= 208Pb
Light= 208Pb
Heavy= 238U
ExcitationEnergyLight= 0.0
ExcitationEnergyHeavy= 15.0
CrossSectionPath= sofia.txt CS
ShootLight= 1
ShootHeavy= 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FissionDecay
CompoundNucleus= 238U
FissionModel= GEF
Shoot_FF= 1
Shoot_neutron= 0
Shoot_gamma= 0
add_custom_command(OUTPUT TSofiaPhysicsDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSofiaPhysics.h TSofiaPhysicsDict.cxx TSofiaPhysics.rootmap libNPSofia.dylib DEPENDS TSofiaPhysics.h)
add_custom_command(OUTPUT TSofiaDataDict.cxx COMMAND ${CMAKE_BINARY_DIR}/scripts/build_dict.sh TSofiaData.h TSofiaDataDict.cxx TSofiaData.rootmap libNPSofia.dylib DEPENDS TSofiaData.h)
add_library(NPSofia SHARED TSofiaSpectra.cxx TSofiaData.cxx TSofiaPhysics.cxx TSofiaDataDict.cxx TSofiaPhysicsDict.cxx )
target_link_libraries(NPSofia ${ROOT_LIBRARIES} NPCore)
install(FILES TSofiaData.h TSofiaPhysics.h TSofiaSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
/*****************************************************************************
* Copyright (C) 2009-2020 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : November 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Sofia Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TSofiaData.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
ClassImp(TSofiaData)
//////////////////////////////////////////////////////////////////////
TSofiaData::TSofiaData() {
}
//////////////////////////////////////////////////////////////////////
TSofiaData::~TSofiaData() {
}
//////////////////////////////////////////////////////////////////////
void TSofiaData::Clear() {
// Energy
fTOF_DetectorNbr.clear();
fTOF_PlasticNbr.clear();
fTOF_Energy.clear();
fTOF_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TSofiaData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TSofiaData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fTOF_DetectorNbr.size();
cout << "TOF_Mult: " << mysize << endl;
}
#ifndef __SofiaDATA__
#define __SofiaDATA__
/*****************************************************************************
* Copyright (C) 2009-2020 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : November 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Sofia Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using namespace std;
// ROOT
#include "TObject.h"
class TSofiaData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
vector<int> fTOF_DetectorNbr;
vector<int> fTOF_PlasticNbr;
vector<double> fTOF_Energy;
vector<double> fTOF_Time;
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TSofiaData();
~TSofiaData();
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void Clear();
void Clear(const Option_t*) {};
void Dump() const;
//////////////////////////////////////////////////////////////
// Getters and Setters
// Prefer inline declaration to avoid unnecessary called of
// frequently used methods
// add //! to avoid ROOT creating dictionnary for the methods
public:
////////////////////// SETTERS ////////////////////////
inline void SetDetectorNbr(int det){fTOF_DetectorNbr.push_back(det);};//!
inline void SetPlasticNbr(int plastic){fTOF_PlasticNbr.push_back(plastic);};//!
inline void SetEnergy(double Energy){fTOF_Energy.push_back(Energy);};//!
inline void SetTime(double Time){fTOF_Time.push_back(Time);};//!
////////////////////// GETTERS ////////////////////////
// Energy
inline int GetMultiplicity() const {return fTOF_PlasticNbr.size();}
inline int GetDetectorNbr(const unsigned int &i) const {return fTOF_DetectorNbr[i];}//!
inline int GetPlasticNbr(const unsigned int &i) const {return fTOF_PlasticNbr[i];}//!
inline double GetEnergy(const unsigned int &i) const {return fTOF_Energy[i];}//!
inline double GetTime(const unsigned int &i) const {return fTOF_Time[i];}//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TSofiaData,1) // SofiaData structure
};
#endif
/*****************************************************************************
* Copyright (C) 2009-2020 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : November 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Sofia Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TSofiaPhysics.h"
// STL
#include <sstream>
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <limits>
using namespace std;
// NPL
#include "RootInput.h"
#include "RootOutput.h"
#include "NPDetectorFactory.h"
#include "NPOptionManager.h"
// ROOT
#include "TChain.h"
ClassImp(TSofiaPhysics)
///////////////////////////////////////////////////////////////////////////
TSofiaPhysics::TSofiaPhysics()
: m_EventData(new TSofiaData),
m_PreTreatedData(new TSofiaData),
m_EventPhysics(this),
m_Spectra(0),
m_E_RAW_Threshold(0), // adc channels
m_E_Threshold(0), // MeV
m_NumberOfDetectors(0) {
}
///////////////////////////////////////////////////////////////////////////
/// A usefull method to bundle all operation to add a detector
void TSofiaPhysics::AddDetector(TVector3 , string ){
// In That simple case nothing is done
// Typically for more complex detector one would calculate the relevant
// positions (stripped silicon) or angles (gamma array)
m_NumberOfDetectors++;
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::AddDetector(double R, double Theta, double Phi, string shape){
// Compute the TVector3 corresponding
TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta));
// Call the cartesian method
AddDetector(Pos,shape);
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::BuildSimplePhysicalEvent() {
BuildPhysicalEvent();
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::BuildPhysicalEvent() {
// apply thresholds and calibration
PreTreat();
// match energy and time together
unsigned int mysizeE = m_PreTreatedData->GetMultiplicity();
for (UShort_t e = 0; e < mysizeE ; e++) {
DetectorNumber.push_back(m_PreTreatedData->GetDetectorNbr(e));
PlasticNumber.push_back(m_PreTreatedData->GetPlasticNbr(e));
Energy.push_back(m_PreTreatedData->GetEnergy(e));
Time.push_back(m_PreTreatedData->GetTime(e));
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::PreTreat() {
// This method typically applies thresholds and calibrations
// Might test for disabled channels for more complex detector
// clear pre-treated object
ClearPreTreatedData();
// instantiate CalibrationManager
static CalibrationManager* Cal = CalibrationManager::getInstance();
// Energy
unsigned int mysize = m_EventData->GetMultiplicity();
for (UShort_t i = 0; i < mysize ; ++i) {
if (m_EventData->GetEnergy(i) > m_E_RAW_Threshold) {
Double_t Energy = Cal->ApplyCalibration("Sofia/ENERGY"+NPL::itoa(m_EventData->GetPlasticNbr(i)),m_EventData->GetEnergy(i));
if (Energy > m_E_Threshold) {
m_PreTreatedData->SetDetectorNbr(m_EventData->GetDetectorNbr(i));
m_PreTreatedData->SetPlasticNbr(m_EventData->GetPlasticNbr(i));
m_PreTreatedData->SetTime(m_EventData->GetTime(i));
m_PreTreatedData->SetEnergy(Energy);
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to file
string FileName = "./configs/ConfigSofia.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigSofia.dat found: Default parameter loaded for Analayis " << FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigSofia.dat " << endl;
// Save it in a TAsciiFile
TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
asciiConfig->AppendLine("%%% ConfigSofia.dat %%%");
asciiConfig->Append(FileName.c_str());
asciiConfig->AppendLine("");
// read analysis config file
string LineBuffer,DataBuffer,whatToDo;
while (!AnalysisConfigFile.eof()) {
// Pick-up next line
getline(AnalysisConfigFile, LineBuffer);
// search for "header"
string name = "ConfigSofia";
if (LineBuffer.compare(0, name.length(), name) == 0)
ReadingStatus = true;
// loop on tokens and data
while (ReadingStatus ) {
whatToDo="";
AnalysisConfigFile >> whatToDo;
// Search for comment symbol (%)
if (whatToDo.compare(0, 1, "%") == 0) {
AnalysisConfigFile.ignore(numeric_limits<streamsize>::max(), '\n' );
}
else if (whatToDo=="E_RAW_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_E_RAW_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_E_RAW_Threshold << endl;
}
else if (whatToDo=="E_THRESHOLD") {
AnalysisConfigFile >> DataBuffer;
m_E_Threshold = atof(DataBuffer.c_str());
cout << whatToDo << " " << m_E_Threshold << endl;
}
else {
ReadingStatus = false;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::Clear() {
DetectorNumber.clear();
PlasticNumber.clear();
Energy.clear();
Time.clear();
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::ReadConfiguration(NPL::InputParser parser) {
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Sofia");
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl;
vector<string> cart = {"POS","Shape"};
vector<string> sphe = {"R","Theta","Phi","Shape"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(cart)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Sofia " << i+1 << endl;
TVector3 Pos = blocks[i]->GetTVector3("POS","mm");
string Shape = blocks[i]->GetString("Shape");
AddDetector(Pos,Shape);
}
else if(blocks[i]->HasTokenList(sphe)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Sofia " << i+1 << endl;
double R = blocks[i]->GetDouble("R","mm");
double Theta = blocks[i]->GetDouble("Theta","deg");
double Phi = blocks[i]->GetDouble("Phi","deg");
string Shape = blocks[i]->GetString("Shape");
AddDetector(R,Theta,Phi,Shape);
}
else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::InitSpectra() {
m_Spectra = new TSofiaSpectra(m_NumberOfDetectors);
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::FillSpectra() {
m_Spectra -> FillRawSpectra(m_EventData);
m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData);
m_Spectra -> FillPhysicsSpectra(m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::CheckSpectra() {
m_Spectra->CheckSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::ClearSpectra() {
// To be done
}
///////////////////////////////////////////////////////////////////////////
map< string , TH1*> TSofiaPhysics::GetSpectra() {
if(m_Spectra)
return m_Spectra->GetMapHisto();
else{
map< string , TH1*> empty;
return empty;
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::WriteSpectra() {
m_Spectra->WriteSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::AddParameterToCalibrationManager() {
CalibrationManager* Cal = CalibrationManager::getInstance();
for (int i = 0; i < m_NumberOfDetectors; ++i) {
Cal->AddParameter("Sofia", "D"+ NPL::itoa(i+1)+"_ENERGY","Sofia_D"+ NPL::itoa(i+1)+"_ENERGY");
Cal->AddParameter("Sofia", "D"+ NPL::itoa(i+1)+"_TIME","Sofia_D"+ NPL::itoa(i+1)+"_TIME");
}
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::InitializeRootInputRaw() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchStatus("Sofia", true );
inputChain->SetBranchAddress("Sofia", &m_EventData );
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::InitializeRootInputPhysics() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchAddress("Sofia", &m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TSofiaPhysics::InitializeRootOutput() {
TTree* outputTree = RootOutput::getInstance()->GetTree();
outputTree->Branch("Sofia", "TSofiaPhysics", &m_EventPhysics);
}
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
NPL::VDetector* TSofiaPhysics::Construct() {
return (NPL::VDetector*) new TSofiaPhysics();
}
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
extern "C"{
class proxy_Sofia{
public:
proxy_Sofia(){
NPL::DetectorFactory::getInstance()->AddToken("Sofia","Sofia");
NPL::DetectorFactory::getInstance()->AddDetector("Sofia",TSofiaPhysics::Construct);
}
};
proxy_Sofia p_Sofia;
}
#ifndef TSofiaPHYSICS_H
#define TSofiaPHYSICS_H
/*****************************************************************************
* Copyright (C) 2009-2020 this file is part of the NPTool Project *
* *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/
/*****************************************************************************
* Original Author: Pierre Morfouace contact address: pierre.morfouace2@cea.fr *
* *
* Creation Date : November 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Sofia Treated data *
* *