Skip to content
Snippets Groups Projects
Commit ab65add2 authored by Morfouace's avatar Morfouace
Browse files

* adding sofia project to nptool for simple simulation

parent 8eb8e7c0
No related branches found
No related tags found
No related merge requests found
Pipeline #91013 failed
Showing
with 1585 additions and 144 deletions
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 1
4.2 1
4.3 1
4.4 1
4.5 1
4.6 1
4.7 1
4.8 1
4.9 1
5.0 1
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= 166600
SigmaEnergy= 1e-5
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 *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// C++ headers
#include <vector>
#include <map>
#include <string>
using namespace std;
// ROOT headers
#include "TObject.h"
#include "TH1.h"
#include "TVector3.h"
// NPTool headers
#include "TSofiaData.h"
#include "TSofiaSpectra.h"
#include "NPCalibrationManager.h"
#include "NPVDetector.h"
#include "NPInputParser.h"
// forward declaration
class TSofiaSpectra;
class TSofiaPhysics : public TObject, public NPL::VDetector {
//////////////////////////////////////////////////////////////
// constructor and destructor
public:
TSofiaPhysics();
~TSofiaPhysics() {};
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void Clear();
void Clear(const Option_t*) {};
//////////////////////////////////////////////////////////////
// data obtained after BuildPhysicalEvent() and stored in
// output ROOT file
public:
vector<int> DetectorNumber;
vector<int> PlasticNumber;
vector<double> Energy;
vector<double> Time;
/// A usefull method to bundle all operation to add a detector
void AddDetector(TVector3 POS, string shape);
void AddDetector(double R, double Theta, double Phi, string shape);
//////////////////////////////////////////////////////////////
// methods inherited from the VDetector ABC class
public:
// read stream from ConfigFile to pick-up detector parameters
void ReadConfiguration(NPL::InputParser);
// add parameters to the CalibrationManger
void AddParameterToCalibrationManager();
// method called event by event, aiming at extracting the
// physical information from detector
void BuildPhysicalEvent();
// same as BuildPhysicalEvent() method but with a simpler
// treatment
void BuildSimplePhysicalEvent();
// same as above but for online analysis
void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();};
// activate raw data object and branches from input TChain
// in this method mother branches (Detector) AND daughter leaves
// (fDetector_parameter) have to be activated
void InitializeRootInputRaw();
// activate physics data object and branches from input TChain
// in this method mother branches (Detector) AND daughter leaves
// (fDetector_parameter) have to be activated
void InitializeRootInputPhysics();
// create branches of output ROOT file
void InitializeRootOutput();
// clear the raw and physical data objects event by event
void ClearEventPhysics() {Clear();}
void ClearEventData() {m_EventData->Clear();}
// methods related to the TSofiaSpectra class
// instantiate the TSofiaSpectra class and
// declare list of histograms
void InitSpectra();
// fill the spectra
void FillSpectra();
// used for Online mainly, sanity check for histograms and
// change their color if issues are found, for example
void CheckSpectra();
// used for Online only, clear all the spectra
void ClearSpectra();
// write spectra to ROOT output file
void WriteSpectra();
//////////////////////////////////////////////////////////////
// specific methods to Sofia array
public:
// remove bad channels, calibrate the data and apply thresholds
void PreTreat();
// clear the pre-treated object
void ClearPreTreatedData() {m_PreTreatedData->Clear();}
// read the user configuration file. If no file is found, load standard one
void ReadAnalysisConfig();
// give and external TSofiaData object to TSofiaPhysics.
// needed for online analysis for example
void SetRawDataPointer(TSofiaData* rawDataPointer) {m_EventData = rawDataPointer;}
// objects are not written in the TTree
private:
TSofiaData* m_EventData; //!
TSofiaData* m_PreTreatedData; //!
TSofiaPhysics* m_EventPhysics; //!
// getters for raw and pre-treated data object
public:
TSofiaData* GetRawData() const {return m_EventData;}
TSofiaData* GetPreTreatedData() const {return m_PreTreatedData;}
// parameters used in the analysis
private:
// thresholds
double m_E_RAW_Threshold; //!
double m_E_Threshold; //!
// number of detectors
private:
int m_NumberOfDetectors; //!
// spectra class
private:
TSofiaSpectra* m_Spectra; // !
// spectra getter
public:
map<string, TH1*> GetSpectra();
// Static constructor to be passed to the Detector Factory
public:
static NPL::VDetector* Construct();
ClassDef(TSofiaPhysics,1) // SofiaPhysics 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 Spectra *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// class header
#include "TSofiaSpectra.h"
// STL
#include <iostream>
#include <string>
using namespace std;
// NPTool header
#include "NPOptionManager.h"
////////////////////////////////////////////////////////////////////////////////
TSofiaSpectra::TSofiaSpectra()
: fNumberOfDetectors(0) {
SetName("Sofia");
}
////////////////////////////////////////////////////////////////////////////////
TSofiaSpectra::TSofiaSpectra(unsigned int NumberOfDetectors) {
if(NPOptionManager::getInstance()->GetVerboseLevel()>0)
cout << "************************************************" << endl
<< "TSofiaSpectra : Initalizing control spectra for "
<< NumberOfDetectors << " Detectors" << endl
<< "************************************************" << endl ;
SetName("Sofia");
fNumberOfDetectors = NumberOfDetectors;
InitRawSpectra();
InitPreTreatedSpectra();
InitPhysicsSpectra();
}
////////////////////////////////////////////////////////////////////////////////
TSofiaSpectra::~TSofiaSpectra() {
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::InitRawSpectra() {
static string name;
for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors
// Energy
name = "Sofia"+NPL::itoa(i+1)+"_ENERGY_RAW";
AddHisto1D(name, name, 4096, 0, 16384, "Sofia/RAW");
// Time
name = "Sofia"+NPL::itoa(i+1)+"_TIME_RAW";
AddHisto1D(name, name, 4096, 0, 16384, "Sofia/RAW");
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::InitPreTreatedSpectra() {
static string name;
for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors
// Energy
name = "Sofia"+NPL::itoa(i+1)+"_ENERGY_CAL";
AddHisto1D(name, name, 500, 0, 25, "Sofia/CAL");
// Time
name = "Sofia"+NPL::itoa(i+1)+"_TIME_CAL";
AddHisto1D(name, name, 500, 0, 25, "Sofia/CAL");
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::InitPhysicsSpectra() {
static string name;
// Kinematic Plot
name = "Sofia_ENERGY_TIME";
AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "Sofia/PHY");
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::FillRawSpectra(TSofiaData* RawData) {
static string name;
static string family;
// Energy
unsigned int sizeE = RawData->GetMultiplicity();
for (unsigned int i = 0; i < sizeE; i++) {
name = "Sofia"+NPL::itoa(RawData->GetPlasticNbr(i))+"_ENERGY_RAW";
family = "Sofia/RAW";
FillSpectra(family,name,RawData->GetEnergy(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::FillPreTreatedSpectra(TSofiaData* PreTreatedData) {
static string name;
static string family;
// Energy
unsigned int sizeE = PreTreatedData->GetMultiplicity();
for (unsigned int i = 0; i < sizeE; i++) {
name = "Sofia"+NPL::itoa(PreTreatedData->GetPlasticNbr(i))+"_ENERGY_CAL";
family = "Sofia/CAL";
FillSpectra(family,name,PreTreatedData->GetEnergy(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TSofiaSpectra::FillPhysicsSpectra(TSofiaPhysics* Physics) {
static string name;
static string family;
family= "Sofia/PHY";
// Energy vs time
unsigned int sizeE = Physics->Energy.size();
for(unsigned int i = 0 ; i < sizeE ; i++){
name = "Sofia_ENERGY_TIME";
FillSpectra(family,name,Physics->Energy[i],Physics->Time[i]);
}
}
#ifndef TSofiaSPECTRA_H
#define TSofiaSPECTRA_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 Spectra *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// NPLib headers
#include "NPVSpectra.h"
#include "TSofiaData.h"
#include "TSofiaPhysics.h"
// Forward Declaration
class TSofiaPhysics;
class TSofiaSpectra : public VSpectra {
//////////////////////////////////////////////////////////////
// constructor and destructor
public:
TSofiaSpectra();
TSofiaSpectra(unsigned int NumberOfDetectors);
~TSofiaSpectra();
//////////////////////////////////////////////////////////////
// Initialization methods
private:
void InitRawSpectra();
void InitPreTreatedSpectra();
void InitPhysicsSpectra();
//////////////////////////////////////////////////////////////
// Filling methods
public:
void FillRawSpectra(TSofiaData*);
void FillPreTreatedSpectra(TSofiaData*);
void FillPhysicsSpectra(TSofiaPhysics*);
//////////////////////////////////////////////////////////////
// Detector parameters
private:
unsigned int fNumberOfDetectors;
};
#endif
#include "NPXmlParser.h"
#include <stdio.h>
#include <iostream>
using namespace NPL;
////////////////////////////////////////////////////////////////////////////////
block::block(){};
block::~block(){};
int block::AsInt(std::string name){
parameter p(name,"void");
auto it = m_parameters.find(p);
if(it!=m_parameters.end()){
std::string s = it->GetValue();
return atoi(s.c_str());
}
else
return -1000;
}
double block::AsDouble(std::string name){
parameter p(name,"void");
auto it = m_parameters.find(p);
if(it!=m_parameters.end()){
std::string s = it->GetValue();
return atof(s.c_str());
}
else
return -1000;
}
std::string block::AsString(std::string name){
parameter p(name,"void");
auto it = m_parameters.find(p);
if(it!=m_parameters.end()){
std::string s = it->GetValue();
return s;
}
else
return "void";
}
////////////////////////////////////////////////////////////////////////////////
parameter::parameter(){};
parameter::~parameter(){};
////////////////////////////////////////////////////////////////////////////////
Channel::Channel(){};
Channel::~Channel(){};
////////////////////////////////////////////////////////////////////////////////
void XmlParser::LoadFile(std::string file){
// First create engine
TXMLEngine* xml = new TXMLEngine;
// Now try to parse xml file
// Only file with restricted xml syntax are supported
XMLDocPointer_t xmldoc = xml->ParseFile(file.c_str());
if (xmldoc==0) {
delete xml;
return;
}
// take access to main node
XMLNodePointer_t mainnode = xml->DocGetRootElement(xmldoc);
// display recursively all nodes and subnodes
LoadNode(xml, mainnode, 1);
// Release memory before exit
xml->FreeDoc(xmldoc);
delete xml;
}
//////////////////////////////////////////////////////////////////////////////////
void XmlParser::DisplayNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level){
// this function display all accessible information about xml node and its children
printf("%*c node: %s\n",level,' ', xml->GetNodeName(node));
// display namespace
XMLNsPointer_t ns = xml->GetNS(node);
if (ns!=0)
printf("%*c namespace: %s refer: %s\n",level+2,' ', xml->GetNSName(ns), xml->GetNSReference(ns));
// display attributes
XMLAttrPointer_t attr = xml->GetFirstAttr(node);
while (attr!=0) {
printf("%*c attr: %s value: %s\n",level+2,' ', xml->GetAttrName(attr), xml->GetAttrValue(attr));
attr = xml->GetNextAttr(attr);
}
// display content (if exists)
const char* content = xml->GetNodeContent(node);
if (content!=0)
printf("%*c cont: %s\n",level+2,' ', content);
// display all child nodes
XMLNodePointer_t child = xml->GetChild(node);
while (child!=0) {
DisplayNode(xml, child, level+2);
child = xml->GetNext(child);
}
}
//////////////////////////////////////////////////////////////////////////////////
void XmlParser::LoadNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level){
// namespace
XMLNsPointer_t ns = xml->GetNS(node);
XMLNodePointer_t child = xml->GetChild(node);
if(xml->GetNodeName(child)=="dataroot"){// main node
std::cout <<" Loading XML file" << std::endl;
}
else{
while(child!=0) {
block b;
// getting attribute:
XMLNodePointer_t param = xml->GetChild(child);
while (param!=0) {
parameter p(xml->GetNodeName(param),xml->GetNodeContent(param));
b.AddParameter(p);
param=xml->GetNext(param);
}
std::string name = xml->GetNodeName(child);
m_blocks[name].push_back(b);
child = xml->GetNext(child);
}
std::cout << " XML file loaded for " <<m_blocks.size() << " detectors" << std::endl;
}
}
//////////////////////////////////////////////////////////////////////////////////
std::vector<NPL::block*> XmlParser::GetAllBlocksWithName(std::string name){
std::vector<NPL::block*> res;
auto it=m_blocks.find(name);
if(it!=m_blocks.end()){
unsigned int size = it->second.size();
for(unsigned int i = 0 ; i < size ; i++){
res.push_back(&(it->second[i]));
}
}
return res;
}
/////////////////////////////////////////////////////////////////////////////////
std::vector<std::string> XmlParser::GetAllBlocksName(){
std::vector<std::string> res;
for(auto it=m_blocks.begin(); it!= m_blocks.end();++it){
res.push_back(it->first);
}
return res;
}
add_library(NPSSofia SHARED Sofia.cc)
target_link_libraries(NPSSofia NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPSofia)
/******************************************************************************
* 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 describe a simple Sofia setup for simulation *
* *
*----------------------------------------------------------------------------*
* Comment: *
* *
******************************************************************************/
// C++ headers
#include <sstream>
#include <cmath>
#include <limits>
//G4 Geometry object
#include "G4Tubs.hh"
#include "G4Box.hh"
//G4 sensitive
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
//G4 various object
#include "G4Material.hh"
#include "G4Transform3D.hh"
#include "G4PVPlacement.hh"
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4FieldManager.hh"
#include "G4UniformMagField.hh"
#include "G4TransportationManager.hh"
// NPTool header
#include "Sofia.hh"
#include "CalorimeterScorers.hh"
#include "InteractionScorers.hh"
#include "RootOutput.h"
#include "MaterialManager.hh"
#include "NPSDetectorFactory.hh"
#include "NPOptionManager.h"
#include "NPSHitsMap.hh"
// CLHEP header
#include "CLHEP/Random/RandGauss.h"
using namespace std;
using namespace CLHEP;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace Sofia_NS{
// Energy and time Resolution
const double EnergyThreshold = 0.1*MeV;
const double ResoTime = 0.007*ns;
const double ResoEnergy = 1.0*MeV;
const double tof_plastic_height = 600*mm;
const double tof_plastic_width = 32*mm;
const double tof_plastic_thickness = 0.5*mm;
const string Material = "BC400";
const double GLAD_height = 3*m;
const double GLAD_width = 5*m;
const double GLAD_length = 2*m;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Sofia Specific Method
Sofia::Sofia(){
m_Event = new TSofiaData() ;
m_TofScorer = 0;
m_PlasticTof = 0;
m_TofWall = 0;
m_GLAD_MagField = 0;
m_GLAD_DistanceFromTarget = 0;
// RGB Color + Transparency
m_VisSquare = new G4VisAttributes(G4Colour(0.3, 0.8, 0.2, 0.5));
m_VisGLAD = new G4VisAttributes(G4Colour(0.5, 0.5, 0.5, 0.5));
}
Sofia::~Sofia(){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Sofia::AddDetector(G4ThreeVector POS){
// Convert the POS value to R theta Phi as Spherical coordinate is easier in G4
m_R.push_back(POS.mag());
m_Theta.push_back(POS.theta());
m_Phi.push_back(POS.phi());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Sofia::AddDetector(double R, double Theta, double Phi){
m_R.push_back(R);
m_Theta.push_back(Theta);
m_Phi.push_back(Phi);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4AssemblyVolume* Sofia::BuildTOFDetector(){
m_TofWall = new G4AssemblyVolume();
if(!m_PlasticTof){
G4Box* box = new G4Box("Sofia_Box",Sofia_NS::tof_plastic_height*0.5,
Sofia_NS::tof_plastic_width*0.5,Sofia_NS::tof_plastic_thickness*0.5);
G4Material* DetectorMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Sofia_NS::Material);
m_PlasticTof = new G4LogicalVolume(box,DetectorMaterial,"logic_Sofia_Box",0,0,0);
m_PlasticTof->SetVisAttributes(m_VisSquare);
m_PlasticTof->SetSensitiveDetector(m_TofScorer);
G4RotationMatrix* Rv = new G4RotationMatrix(0,0,0);
G4ThreeVector Tv;
Tv.setX(0);
Tv.setY(0);
Tv.setZ(0);
for(unsigned int i=0; i<28; i++){
int k = -14+i;
Tv.setY(k*(Sofia_NS::tof_plastic_width+0.5));
m_TofWall->AddPlacedVolume(m_PlasticTof, Tv, Rv);
}
}
return m_TofWall;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LogicalVolume* Sofia::BuildGLAD()
{
G4Box* box = new G4Box("glad_Box",Sofia_NS::GLAD_width*0.5,
Sofia_NS::GLAD_height*0.5,Sofia_NS::GLAD_length*0.5);
G4Material* GLADMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary("Vaccuum");
m_GLAD = new G4LogicalVolume(box,GLADMaterial,"logic_GLAD_Box",0,0,0);
m_GLAD->SetVisAttributes(m_VisGLAD);
G4UniformMagField* magField = new G4UniformMagField(G4ThreeVector(0,m_GLAD_MagField,0));
//G4FieldManager* fieldMgr = G4TransportationManager::GetTransportationManager()->GetFieldManager();
G4FieldManager* fieldMgr = new G4FieldManager(magField);
//fieldMgr->SetDetectorField(magField);
fieldMgr->CreateChordFinder(magField);
m_GLAD->SetFieldManager(fieldMgr,true);
return m_GLAD;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Virtual Method of NPS::VDetector class
// Read stream at Configfile to pick-up parameters of detector (Position,...)
// Called in DetecorConstruction::ReadDetextorConfiguration Method
void Sofia::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","Build_GLAD"};
vector<string> sphe = {"R","Theta","Phi","Build_GLAD"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(cart)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Sofia " << i+1 << endl;
G4ThreeVector Pos = NPS::ConvertVector(blocks[i]->GetTVector3("POS","mm"));
m_Build_GLAD = blocks[i]->GetInt("Build_GLAD");
AddDetector(Pos);
}
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");
m_Build_GLAD = blocks[i]->GetInt("Build_GLAD");
m_GLAD_MagField = blocks[i]->GetDouble("GLAD_MagField","T");
m_GLAD_DistanceFromTarget = blocks[i]->GetDouble("GLAD_DistanceFromTarget", "m");
AddDetector(R,Theta,Phi);
}
else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Construct detector and inialise sensitive part.
// Called After DetecorConstruction::AddDetector Method
void Sofia::ConstructDetector(G4LogicalVolume* world){
for (unsigned short i = 0 ; i < m_R.size() ; i++) {
G4double wX = m_R[i] * sin(m_Theta[i] ) * cos(m_Phi[i] ) ;
G4double wY = m_R[i] * sin(m_Theta[i] ) * sin(m_Phi[i] ) ;
G4double wZ = m_R[i] * cos(m_Theta[i] ) ;
G4ThreeVector Det_pos = G4ThreeVector(wX, wY, wZ) ;
// So the face of the detector is at R instead of the middle
Det_pos+=Det_pos.unit()*Sofia_NS::tof_plastic_thickness*0.5;
// Building Detector reference frame
G4double ii = cos(m_Theta[i]) * cos(m_Phi[i]);
G4double jj = cos(m_Theta[i]) * sin(m_Phi[i]);
G4double kk = -sin(m_Theta[i]);
G4ThreeVector Y(ii,jj,kk);
G4ThreeVector w = Det_pos.unit();
G4ThreeVector u = w.cross(Y);
G4ThreeVector v = w.cross(u);
v = v.unit();
u = u.unit();
G4RotationMatrix* Rot = new G4RotationMatrix(u,v,w);
BuildTOFDetector()->MakeImprint(world,Det_pos,Rot);
if(m_Build_GLAD==1){
G4ThreeVector GLAD_pos = G4ThreeVector(0,0,m_GLAD_DistanceFromTarget+0.5*Sofia_NS::GLAD_length);
new G4PVPlacement(0, GLAD_pos,
BuildGLAD(),
"GLAD",
world, false, 0);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Add Detector branch to the EventTree.
// Called After DetecorConstruction::AddDetector Method
void Sofia::InitializeRootOutput(){
RootOutput *pAnalysis = RootOutput::getInstance();
TTree *pTree = pAnalysis->GetTree();
if(!pTree->FindBranch("Sofia")){
pTree->Branch("Sofia", "TSofiaData", &m_Event) ;
}
pTree->SetBranchAddress("Sofia", &m_Event) ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Read sensitive part and fill the Root tree.
// Called at in the EventAction::EndOfEventAvtion
void Sofia::ReadSensitive(const G4Event* ){
m_Event->Clear();
///////////
// Calorimeter scorer
CalorimeterScorers::PS_Calorimeter* Scorer= (CalorimeterScorers::PS_Calorimeter*) m_TofScorer->GetPrimitive(0);
unsigned int size = Scorer->GetMult();
for(unsigned int i = 0 ; i < size ; i++){
vector<unsigned int> level = Scorer->GetLevel(i);
double Energy = RandGauss::shoot(Scorer->GetEnergy(i),Sofia_NS::ResoEnergy);
if(Energy>Sofia_NS::EnergyThreshold){
double Time = RandGauss::shoot(Scorer->GetTime(i),Sofia_NS::ResoTime);
int DetectorNbr = level[0];
int PlasticNbr = level[1];
m_Event->SetDetectorNbr(DetectorNbr);
m_Event->SetPlasticNbr(PlasticNbr);
m_Event->SetEnergy(Energy);
m_Event->SetTime(Time);
//cout << DetectorNbr << " " << PlasticNbr << " " << Energy << " " << Time << endl;
}
}
//m_Event->Dump();
Scorer->clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////
void Sofia::InitializeScorers() {
// This check is necessary in case the geometry is reloaded
bool already_exist = false;
m_TofScorer = CheckScorer("SofiaScorer",already_exist) ;
if(already_exist)
return ;
// Otherwise the scorer is initialised
vector<int> level;
level.push_back(1);
level.push_back(0);
G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ;
G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ;
//and register it to the multifunctionnal detector
m_TofScorer->RegisterPrimitive(Calorimeter);
m_TofScorer->RegisterPrimitive(Interaction);
G4SDManager::GetSDMpointer()->AddNewDetector(m_TofScorer) ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
NPS::VDetector* Sofia::Construct(){
return (NPS::VDetector*) new Sofia();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
extern"C" {
class proxy_nps_Sofia{
public:
proxy_nps_Sofia(){
NPS::DetectorFactory::getInstance()->AddToken("Sofia","Sofia");
NPS::DetectorFactory::getInstance()->AddDetector("Sofia",Sofia::Construct);
}
};
proxy_nps_Sofia p_nps_Sofia;
}
#ifndef Sofia_h
#define Sofia_h 1
/*****************************************************************************
* 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 describe Sofia simulation *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
*****************************************************************************/
// C++ header
#include <string>
#include <vector>
using namespace std;
// G4 headers
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
#include "G4LogicalVolume.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4AssemblyVolume.hh"
// NPTool header
#include "NPSVDetector.hh"
#include "TSofiaData.h"
#include "NPInputParser.h"
class Sofia : public NPS::VDetector{
////////////////////////////////////////////////////
/////// Default Constructor and Destructor /////////
////////////////////////////////////////////////////
public:
Sofia() ;
virtual ~Sofia() ;
////////////////////////////////////////////////////
/////// Specific Function of this Class ///////////
////////////////////////////////////////////////////
public:
// Cartesian
void AddDetector(G4ThreeVector POS);
// Spherical
void AddDetector(double R,double Theta,double Phi);
G4AssemblyVolume* BuildTOFDetector();
G4LogicalVolume* BuildGLAD();
private:
G4LogicalVolume* m_PlasticTof;
G4LogicalVolume* m_GLAD;
G4AssemblyVolume* m_TofWall;
////////////////////////////////////////////////////
////// Inherite from NPS::VDetector class /////////
////////////////////////////////////////////////////
public:
// Read stream at Configfile to pick-up parameters of detector (Position,...)
// Called in DetecorConstruction::ReadDetextorConfiguration Method
void ReadConfiguration(NPL::InputParser) ;
// Construct detector and inialise sensitive part.
// Called After DetecorConstruction::AddDetector Method
void ConstructDetector(G4LogicalVolume* world) ;
// Add Detector branch to the EventTree.
// Called After DetecorConstruction::AddDetector Method
void InitializeRootOutput() ;
// Read sensitive part and fill the Root tree.
// Called at in the EventAction::EndOfEventAvtion
void ReadSensitive(const G4Event* event) ;
public: // Scorer
// Initialize all Scorer used by the MUST2Array
void InitializeScorers() ;
// Associated Scorer
G4MultiFunctionalDetector* m_TofScorer ;
////////////////////////////////////////////////////
///////////Event class to store Data////////////////
////////////////////////////////////////////////////
private:
TSofiaData* m_Event ;
////////////////////////////////////////////////////
///////////////Private intern Data//////////////////
////////////////////////////////////////////////////
private: // Geometry
// Detector Coordinate
vector<double> m_R;
vector<double> m_Theta;
vector<double> m_Phi;
int m_Build_GLAD;
double m_GLAD_MagField;
double m_GLAD_DistanceFromTarget;
// Visualisation Attribute
G4VisAttributes* m_VisSquare;
G4VisAttributes* m_VisGLAD;
// Needed for dynamic loading of the library
public:
static NPS::VDetector* Construct();
};
#endif
/*****************************************************************************
* Copyright (C) 2009-2016 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: XAUTHORX contact address: XMAILX *
* *
* Creation Date : XMONTHX XYEARX *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class describe Sofia analysis project *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
*****************************************************************************/
#include<iostream>
using namespace std;
#include"Analysis.h"
#include"NPAnalysisFactory.h"
#include"NPDetectorManager.h"
////////////////////////////////////////////////////////////////////////////////
Analysis::Analysis(){
}
////////////////////////////////////////////////////////////////////////////////
Analysis::~Analysis(){
}
////////////////////////////////////////////////////////////////////////////////
void Analysis::Init(){
Sofia= (TSofiaPhysicsPhysics*) m_DetectorManager->GetDetector("Sofia");
}
////////////////////////////////////////////////////////////////////////////////
void Analysis::TreatEvent(){
}
////////////////////////////////////////////////////////////////////////////////
void Analysis::End(){
}
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
NPL::VAnalysis* Analysis::Construct(){
return (NPL::VAnalysis*) new Analysis();
}
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
extern "C"{
class proxy{
public:
proxy(){
NPL::AnalysisFactory::getInstance()->SetConstructor(Analysis::Construct);
}
};
proxy p;
}
#ifndef Analysis_h
#define Analysis_h
/*****************************************************************************
* Copyright (C) 2009-2016 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: XAUTHORX contact address: XMAILX *
* *
* Creation Date : XMONTHX XYEARX *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class describe Sofia analysis project *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
*****************************************************************************/
#include"NPVAnalysis.h"
#include"TSofiaPhysics.h"
class Analysis: public NPL::VAnalysis{
public:
Analysis();
~Analysis();
public:
void Init();
void TreatEvent();
void End();
static NPL::VAnalysis* Construct();
private:
TSofiaPhysics* Sofia;
};
#endif
cmake_minimum_required (VERSION 2.8)
# Setting the policy to match Cmake version
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
# include the default NPAnalysis cmake file
include("../../NPLib/ressources/CMake/NPAnalysis.cmake")
EmPhysicsList Option4
DefaultCutOff 1000
IonBinaryCascadePhysics 0
NPIonInelasticPhysics 0
EmExtraPhysics 0
HadronElasticPhysics 0
StoppingPhysics 0
OpticalPhysics 0
HadronPhysicsINCLXX 0
HadronPhysicsQGSP_BIC_HP 0
Decay 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Target
THICKNESS= 10 micrometer
RADIUS= 40 mm
MATERIAL= CD2
ANGLE= 0 deg
X= 0 mm
Y= 0 mm
Z= 0 m
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Sofia
% POS= 0 0 350 mm
% Shape= Square
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Sofia
R= 8 m
THETA= -9 deg
PHI= 0 deg
Build_GLAD= 1
GLAD_DistanceFromTarget= 3 m
GLAD_MagField= 1.7 T
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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