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

!Adding Microball classes for simulation purposes

parent 5ac8fa50
Branches
Tags
No related merge requests found
Showing
with 1613 additions and 44 deletions
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GeneralTarget
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Target
THICKNESS= 10
RADIUS= 20
MATERIAL= CD2
ANGLE= 0
X= 0
Y= 0
Z= 0
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Microball
X= 0
Y= 0
Z= 350
Shape= Square
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Microball
X= 350
Y= 350
Z= 350
Shape= Square
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Microball
R= 350
THETA= 90
PHI= 63
Shape= Cylindrical
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
GeneralTarget
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Thickness in micrometer
% Radius in mm
% Temperature in K, Pressure in bar
Target
THICKNESS= 6.26
ANGLE= 0
RADIUS= 10
MATERIAL= CD2
X= 0
Y= 0
Z= 0
%%%%%%%%%%%%%%%%%%%%%
LASSAArray
%%%%%%%%%%%%%%%%%%%%%
%%%%%%% Telescope 0 %%%%%%%
LassaTelescope
A= -3.5 -3.5 215
B= 3.5 -3.5 215
C= -3.5 3.5 215
D= 3.5 3.5 215
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Isotropic Isotropic
EnergyLow= 0 EnergyLow= 0
EnergyHigh= 525 EnergyHigh= 550
HalfOpenAngleMin= 0 HalfOpenAngleMin= 10
HalfOpenAngleMax= 90 HalfOpenAngleMax= 60
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Isotropic Isotropic
EnergyLow= 0 EnergyLow= 0
EnergyHigh= 590 EnergyHigh= 650
HalfOpenAngleMin= 0 HalfOpenAngleMin= 10
HalfOpenAngleMax= 90 HalfOpenAngleMax= 60
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
Isotropic Isotropic
EnergyLow= 0 EnergyLow= 0
EnergyHigh= 205 EnergyHigh= 205
HalfOpenAngleMin= 0 HalfOpenAngleMin= 10
HalfOpenAngleMax= 90 HalfOpenAngleMax= 60
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
% In the TH2F histogram, angle ix X-axis and energy is Y-axis % % In the TH2F histogram, angle ix X-axis and energy is Y-axis %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pBUU pBUU
AngleEnergyHistPath= sn112e120_ELab_ThetaLab_p.root h AngleEnergyHistPath= sn112e120_flat_p.root h
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
...@@ -7,7 +7,7 @@ Isotropic ...@@ -7,7 +7,7 @@ Isotropic
EnergyLow= 0 EnergyLow= 0
EnergyHigh= 250 EnergyHigh= 250
HalfOpenAngleMin= 0 HalfOpenAngleMin= 0
HalfOpenAngleMax= 90 HalfOpenAngleMax= 20
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Isotropic Isotropic
EnergyLow= 0 EnergyLow= 0
EnergyHigh= 235 EnergyHigh= 255
HalfOpenAngleMin= 0 HalfOpenAngleMin= 10
HalfOpenAngleMax= 90 HalfOpenAngleMax= 60
x0= 0 x0= 0
y0= 0 y0= 0
z0= 0 z0= 0
......
add_custom_command(OUTPUT TMicroballPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMicroballPhysics.h TMicroballPhysicsDict.cxx TMicroballPhysics.rootmap libNPMicroball.dylib DEPENDS TMicroballPhysics.h)
add_custom_command(OUTPUT TMicroballDataDict.cxx COMMAND ../../scripts/build_dict.sh TMicroballData.h TMicroballDataDict.cxx TMicroballData.rootmap libNPMicroball.dylib DEPENDS TMicroballData.h)
add_library(NPMicroball SHARED TMicroballSpectra.cxx TMicroballData.cxx TMicroballPhysics.cxx TMicroballDataDict.cxx TMicroballPhysicsDict.cxx )
target_link_libraries(NPMicroball ${ROOT_LIBRARIES} NPCore)
install(FILES TMicroballData.h TMicroballPhysics.h TMicroballSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
/*****************************************************************************
* 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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TMicroballData.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
ClassImp(TMicroballData)
//////////////////////////////////////////////////////////////////////
TMicroballData::TMicroballData() {
}
//////////////////////////////////////////////////////////////////////
TMicroballData::~TMicroballData() {
}
//////////////////////////////////////////////////////////////////////
void TMicroballData::Clear() {
// Energy
fMicroball_E_DetectorNbr.clear();
fMicroball_Energy.clear();
// Time
fMicroball_T_DetectorNbr.clear();
fMicroball_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TMicroballData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TMicroballData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fMicroball_E_DetectorNbr.size();
cout << "Microball_E_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fMicroball_E_DetectorNbr[i]
<< " Energy: " << fMicroball_Energy[i];
}
// Time
mysize = fMicroball_T_DetectorNbr.size();
cout << "Microball_T_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fMicroball_T_DetectorNbr[i]
<< " Time: " << fMicroball_Time[i];
}
}
#ifndef __MicroballDATA__
#define __MicroballDATA__
/*****************************************************************************
* 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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using namespace std;
// ROOT
#include "TObject.h"
class TMicroballData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
// Energy
vector<UShort_t> fMicroball_E_DetectorNbr;
vector<Double_t> fMicroball_Energy;
// Time
vector<UShort_t> fMicroball_T_DetectorNbr;
vector<Double_t> fMicroball_Time;
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TMicroballData();
virtual ~TMicroballData();
//////////////////////////////////////////////////////////////
// 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 ////////////////////////
// Energy
inline void SetE_DetectorNbr(const UShort_t& DetNbr)
{fMicroball_E_DetectorNbr.push_back(DetNbr);} //!
inline void Set_Energy(const Double_t& Energy)
{fMicroball_Energy.push_back(Energy);}//!
// Prefer global setter so that all vectors have the same size
inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy) {
SetE_DetectorNbr(DetNbr);
Set_Energy(Energy);
};//!
// Time
inline void SetT_DetectorNbr(const UShort_t& DetNbr)
{fMicroball_T_DetectorNbr.push_back(DetNbr);} //!
inline void Set_Time(const Double_t& Time)
{fMicroball_Time.push_back(Time);}//!
// Prefer global setter so that all vectors have the same size
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
SetT_DetectorNbr(DetNbr);
Set_Time(Time);
};//!
////////////////////// GETTERS ////////////////////////
// Energy
inline UShort_t GetMultEnergy() const
{return fMicroball_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fMicroball_E_DetectorNbr[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fMicroball_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fMicroball_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fMicroball_T_DetectorNbr[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fMicroball_Time[i];}//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TMicroballData,1) // MicroballData structure
};
#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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TMicroballPhysics.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"
// ROOT
#include "TChain.h"
ClassImp(TMicroballPhysics)
///////////////////////////////////////////////////////////////////////////
TMicroballPhysics::TMicroballPhysics()
: m_EventData(new TMicroballData),
m_PreTreatedData(new TMicroballData),
m_EventPhysics(this),
m_Spectra(0),
m_E_RAW_Threshold(0), // adc channels
m_E_Threshold(0), // MeV
m_NumberOfDetectors(0) {
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::BuildSimplePhysicalEvent() {
BuildPhysicalEvent();
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::BuildPhysicalEvent() {
// apply thresholds and calibration
PreTreat();
// match energy and time together
for (UShort_t e = 0; e < m_PreTreatedData->GetMultEnergy(); e++) {
for (UShort_t t = 0; t < m_PreTreatedData->GetMultTime(); t++) {
if (m_PreTreatedData->GetE_DetectorNbr(e) == m_PreTreatedData->GetT_DetectorNbr(t)) {
DetectorNumber.push_back(m_PreTreatedData->GetE_DetectorNbr(e));
Energy.push_back(m_PreTreatedData->Get_Energy(e));
Time.push_back(m_PreTreatedData->Get_Time(t));
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::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
for (UShort_t i = 0; i < m_EventData->GetMultEnergy(); ++i) {
if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) {
Double_t Energy = Cal->ApplyCalibration("Microball/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i));
if (Energy > m_E_Threshold) {
m_PreTreatedData->SetEnergy(m_EventData->GetE_DetectorNbr(i), Energy);
}
}
}
// Time
for (UShort_t i = 0; i < m_EventData->GetMultTime(); ++i) {
Double_t Time= Cal->ApplyCalibration("Microball/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
}
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to file
string FileName = "./configs/ConfigMicroball.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigMicroball.dat found: Default parameter loaded for Analayis " << FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigMicroball.dat " << endl;
// Save it in a TAsciiFile
TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
asciiConfig->AppendLine("%%% ConfigMicroball.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 = "ConfigMicroball";
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 TMicroballPhysics::Clear() {
DetectorNumber.clear();
Energy.clear();
Time.clear();
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::ReadConfiguration(string Path) {
ifstream ConfigFile ;
ConfigFile.open(Path.c_str()) ;
string LineBuffer ;
string DataBuffer ;
bool check_Theta = false ;
bool check_Phi = false ;
bool check_R = false ;
bool check_Shape = false ;
bool check_X = false ;
bool check_Y = false ;
bool check_Z = false ;
bool ReadingStatus = false ;
while (!ConfigFile.eof()){
getline(ConfigFile, LineBuffer);
// If line is a Start Up Microball bloc, Reading toggle to true
string name="Microball";
if (LineBuffer.compare(0, name.length(), name) == 0){
cout << "///" << endl ;
cout << "Microball found: " << endl ;
ReadingStatus = true ;
}
// Reading Block
while(ReadingStatus)
{
// Pickup Next Word
ConfigFile >> DataBuffer ;
// Comment Line
if (DataBuffer.compare(0, 1, "%") == 0) {
ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
}
// Finding another telescope (safety), toggle out
else if (DataBuffer.compare(0, name.length(), name) == 0) {
cout << "\033[1;311mWARNING: Another detector is find before standard sequence of Token, Error may occured in detector definition\033[0m" << endl ;
ReadingStatus = false ;
}
//Angle method
else if (DataBuffer=="THETA=") {
check_Theta = true;
ConfigFile >> DataBuffer ;
cout << "Theta: " << atof(DataBuffer.c_str()) << "deg" << endl;
}
else if (DataBuffer=="PHI=") {
check_Phi = true;
ConfigFile >> DataBuffer ;
cout << "Phi: " << atof( DataBuffer.c_str() ) << "deg" << endl;
}
else if (DataBuffer=="R=") {
check_R = true;
ConfigFile >> DataBuffer ;
cout << "R: " << atof( DataBuffer.c_str() ) << "mm" << endl;
}
//Position method
else if (DataBuffer=="X=") {
check_X = true;
ConfigFile >> DataBuffer ;
cout << "X: " << atof( DataBuffer.c_str() ) << "mm" << endl;
}
else if (DataBuffer=="Y=") {
check_Y = true;
ConfigFile >> DataBuffer ;
cout << "Y: " << atof( DataBuffer.c_str() ) << "mm"<< endl;
}
else if (DataBuffer=="Z=") {
check_Z = true;
ConfigFile >> DataBuffer ;
cout << "Z: " << atof( DataBuffer.c_str() ) << "mm" << endl;
}
//General
else if (DataBuffer=="Shape=") {
check_Shape = true;
ConfigFile >> DataBuffer ;
cout << "Shape: " << DataBuffer << endl;
}
///////////////////////////////////////////////////
// If no Detector Token and no comment, toggle out
else{
ReadingStatus = false; cout << "Wrong Token Sequence: Getting out " << DataBuffer << endl ;
}
/////////////////////////////////////////////////
// If All necessary information there, toggle out
if ( ((check_Theta && check_Phi && check_R) ||( check_X && check_Y && check_Z) ) && check_Shape ){
m_NumberOfDetectors++;
// Reinitialisation of Check Boolean
check_Theta = false ;
check_Phi = false ;
check_R = false ;
check_Shape = false ;
check_X = false ;
check_Y = false ;
check_Z = false ;
ReadingStatus = false ;
cout << "///"<< endl ;
}
}
}
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::InitSpectra() {
m_Spectra = new TMicroballSpectra(m_NumberOfDetectors);
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::FillSpectra() {
m_Spectra -> FillRawSpectra(m_EventData);
m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData);
m_Spectra -> FillPhysicsSpectra(m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::CheckSpectra() {
m_Spectra->CheckSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::ClearSpectra() {
// To be done
}
///////////////////////////////////////////////////////////////////////////
map< string , TH1*> TMicroballPhysics::GetSpectra() {
if(m_Spectra)
return m_Spectra->GetMapHisto();
else{
map< string , TH1*> empty;
return empty;
}
}
////////////////////////////////////////////////////////////////////////////////
vector<TCanvas*> TMicroballPhysics::GetCanvas() {
if(m_Spectra)
return m_Spectra->GetCanvas();
else{
vector<TCanvas*> empty;
return empty;
}
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::WriteSpectra() {
m_Spectra->WriteSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::AddParameterToCalibrationManager() {
CalibrationManager* Cal = CalibrationManager::getInstance();
for (int i = 0; i < m_NumberOfDetectors; ++i) {
Cal->AddParameter("Microball", "D"+ NPL::itoa(i+1)+"_ENERGY","Microball_D"+ NPL::itoa(i+1)+"_ENERGY");
Cal->AddParameter("Microball", "D"+ NPL::itoa(i+1)+"_TIME","Microball_D"+ NPL::itoa(i+1)+"_TIME");
}
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::InitializeRootInputRaw() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchStatus("Microball", true );
inputChain->SetBranchAddress("Microball", &m_EventData );
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::InitializeRootInputPhysics() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchAddress("Microball", &m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TMicroballPhysics::InitializeRootOutput() {
TTree* outputTree = RootOutput::getInstance()->GetTree();
outputTree->Branch("Microball", "TMicroballPhysics", &m_EventPhysics);
}
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
NPL::VDetector* TMicroballPhysics::Construct() {
return (NPL::VDetector*) new TMicroballPhysics();
}
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
extern "C"{
class proxy_Microball{
public:
proxy_Microball(){
NPL::DetectorFactory::getInstance()->AddToken("Microball","Microball");
NPL::DetectorFactory::getInstance()->AddDetector("Microball",TMicroballPhysics::Construct);
}
};
proxy_Microball p_Microball;
}
#ifndef TMicroballPHYSICS_H
#define TMicroballPHYSICS_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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// C++ headers
#include <vector>
#include <map>
#include <string>
using namespace std;
// ROOT headers
#include "TObject.h"
#include "TH1.h"
#include "TCanvas.h"
// NPTool headers
#include "TMicroballData.h"
#include "TMicroballSpectra.h"
#include "NPCalibrationManager.h"
#include "NPVDetector.h"
// forward declaration
class TMicroballSpectra;
class TMicroballPhysics : public TObject, public NPL::VDetector {
//////////////////////////////////////////////////////////////
// constructor and destructor
public:
TMicroballPhysics();
~TMicroballPhysics() {};
//////////////////////////////////////////////////////////////
// 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<double> Energy;
vector<double> Time;
//////////////////////////////////////////////////////////////
// methods inherited from the VDetector ABC class
public:
// read stream from ConfigFile to pick-up detector parameters
void ReadConfiguration(string);
// 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 TMicroballSpectra class
// instantiate the TMicroballSpectra 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 Microball 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 TMicroballData object to TMicroballPhysics.
// needed for online analysis for example
void SetRawDataPointer(TMicroballData* rawDataPointer) {m_EventData = rawDataPointer;}
// objects are not written in the TTree
private:
TMicroballData* m_EventData; //!
TMicroballData* m_PreTreatedData; //!
TMicroballPhysics* m_EventPhysics; //!
// getters for raw and pre-treated data object
public:
TMicroballData* GetRawData() const {return m_EventData;}
TMicroballData* 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:
TMicroballSpectra* m_Spectra; // !
// spectra getter
public:
map<string, TH1*> GetSpectra();
vector<TCanvas*> GetCanvas();
// Static constructor to be passed to the Detector Factory
public:
static NPL::VDetector* Construct();
ClassDef(TMicroballPhysics,1) // MicroballPhysics structure
};
#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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Spectra *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// class header
#include "TMicroballSpectra.h"
// STL
#include <iostream>
#include <string>
using namespace std;
// NPTool header
#include "NPOptionManager.h"
////////////////////////////////////////////////////////////////////////////////
TMicroballSpectra::TMicroballSpectra()
: fNumberOfDetectors(0) {
SetName("Microball");
}
////////////////////////////////////////////////////////////////////////////////
TMicroballSpectra::TMicroballSpectra(unsigned int NumberOfDetectors) {
if(NPOptionManager::getInstance()->GetVerboseLevel()>0)
cout << "************************************************" << endl
<< "TMicroballSpectra : Initalizing control spectra for "
<< NumberOfDetectors << " Detectors" << endl
<< "************************************************" << endl ;
SetName("Microball");
fNumberOfDetectors = NumberOfDetectors;
InitRawSpectra();
InitPreTreatedSpectra();
InitPhysicsSpectra();
}
////////////////////////////////////////////////////////////////////////////////
TMicroballSpectra::~TMicroballSpectra() {
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::InitRawSpectra() {
static string name;
for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors
// Energy
name = "Microball"+NPL::itoa(i+1)+"_ENERGY_RAW";
AddHisto1D(name, name, 4096, 0, 16384, "Microball/RAW");
// Time
name = "Microball"+NPL::itoa(i+1)+"_TIME_RAW";
AddHisto1D(name, name, 4096, 0, 16384, "Microball/RAW");
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::InitPreTreatedSpectra() {
static string name;
for (unsigned int i = 0; i < fNumberOfDetectors; i++) { // loop on number of detectors
// Energy
name = "Microball"+NPL::itoa(i+1)+"_ENERGY_CAL";
AddHisto1D(name, name, 500, 0, 25, "Microball/CAL");
// Time
name = "Microball"+NPL::itoa(i+1)+"_TIME_CAL";
AddHisto1D(name, name, 500, 0, 25, "Microball/CAL");
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::InitPhysicsSpectra() {
static string name;
// Kinematic Plot
name = "Microball_ENERGY_TIME";
AddHisto2D(name, name, 500, 0, 500, 500, 0, 50, "Microball/PHY");
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::FillRawSpectra(TMicroballData* RawData) {
static string name;
static string family;
// Energy
unsigned int sizeE = RawData->GetMultEnergy();
for (unsigned int i = 0; i < sizeE; i++) {
name = "Microball"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW";
family = "Microball/RAW";
GetHisto(family,name) -> Fill(RawData->Get_Energy(i));
}
// Time
unsigned int sizeT = RawData->GetMultTime();
for (unsigned int i = 0; i < sizeT; i++) {
name = "Microball"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW";
family = "Microball/RAW";
GetHisto(family,name) -> Fill(RawData->Get_Time(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::FillPreTreatedSpectra(TMicroballData* PreTreatedData) {
static string name;
static string family;
// Energy
unsigned int sizeE = PreTreatedData->GetMultEnergy();
for (unsigned int i = 0; i < sizeE; i++) {
name = "Microball"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL";
family = "Microball/CAL";
GetHisto(family,name) -> Fill(PreTreatedData->Get_Energy(i));
}
// Time
unsigned int sizeT = PreTreatedData->GetMultTime();
for (unsigned int i = 0; i < sizeT; i++) {
name = "Microball"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL";
family = "Microball/CAL";
GetHisto(family,name) -> Fill(PreTreatedData->Get_Time(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TMicroballSpectra::FillPhysicsSpectra(TMicroballPhysics* Physics) {
static string name;
static string family;
family= "Microball/PHY";
// Energy vs time
unsigned int sizeE = Physics->Energy.size();
for(unsigned int i = 0 ; i < sizeE ; i++){
name = "Microball_ENERGY_TIME";
GetHisto(family,name) -> Fill(Physics->Energy[i],Physics->Time[i]);
}
}
#ifndef TMicroballSPECTRA_H
#define TMicroballSPECTRA_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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Microball Spectra *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// NPLib headers
#include "NPVSpectra.h"
#include "TMicroballData.h"
#include "TMicroballPhysics.h"
// Forward Declaration
class TMicroballPhysics;
class TMicroballSpectra : public VSpectra {
//////////////////////////////////////////////////////////////
// constructor and destructor
public:
TMicroballSpectra();
TMicroballSpectra(unsigned int NumberOfDetectors);
~TMicroballSpectra();
//////////////////////////////////////////////////////////////
// Initialization methods
private:
void InitRawSpectra();
void InitPreTreatedSpectra();
void InitPhysicsSpectra();
//////////////////////////////////////////////////////////////
// Filling methods
public:
void FillRawSpectra(TMicroballData*);
void FillPreTreatedSpectra(TMicroballData*);
void FillPhysicsSpectra(TMicroballPhysics*);
//////////////////////////////////////////////////////////////
// Detector parameters
private:
unsigned int fNumberOfDetectors;
};
#endif
add_library(NPSMicroball SHARED Microball.cc)
target_link_libraries(NPSMicroball NPSCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${NPLib_LIBRARIES} -lNPMicroball)
/*****************************************************************************
* 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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class describe Microball 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"
// NPTool header
#include "Microball.hh"
#include "CalorimeterScorers.hh"
#include "RootOutput.h"
#include "MaterialManager.hh"
#include "NPSDetectorFactory.hh"
// CLHEP header
#include "CLHEP/Random/RandGauss.h"
using namespace std;
using namespace CLHEP;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace Microball_NS{
// Energy and time Resolution
const double EnergyThreshold = 0.1*MeV;
const double ResoTime = 4.5*ns ;
const double ResoEnergy = 5.0*MeV ;
const double Radius = 50*mm ;
const double Width = 100*mm ;
const double Thickness = 300*mm ;
const string Scintillator = "BC400";
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Microball Specific Method
Microball::Microball(){
m_Event = new TMicroballData() ;
m_MicroballScorer = 0;
m_SquareDetector = 0;
m_CylindricalDetector = 0;
// RGB Color + Transparency
m_VisSquare = new G4VisAttributes(G4Colour(0, 1, 0, 0.5));
m_VisCylinder = new G4VisAttributes(G4Colour(0, 0, 1, 0.5));
}
Microball::~Microball(){
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Microball::AddMicroball(double R, double Theta, double Phi, string Shape){
m_R.push_back(R);
m_Theta.push_back(Theta);
m_Phi.push_back(Phi);
m_Shape.push_back(Shape);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LogicalVolume* Microball::BuildSquareDetector(){
if(!m_SquareDetector){
G4Box* box = new G4Box("Microball_Box",Microball_NS::Width*0.5,
Microball_NS::Width*0.5,Microball_NS::Thickness*0.5);
G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator);
m_SquareDetector = new G4LogicalVolume(box,ScintMaterial,"logic_Microball_Box",0,0,0);
m_SquareDetector->SetVisAttributes(m_VisSquare);
m_SquareDetector->SetSensitiveDetector(m_MicroballScorer);
}
return m_SquareDetector;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4LogicalVolume* Microball::BuildCylindricalDetector(){
if(!m_CylindricalDetector){
G4Tubs* tub = new G4Tubs("Microball_Cyl",0,Microball_NS::Radius,Microball_NS::Thickness*0.5,0,360*deg);
G4Material* ScintMaterial = MaterialManager::getInstance()->GetMaterialFromLibrary(Microball_NS::Scintillator);
m_CylindricalDetector = new G4LogicalVolume(tub,ScintMaterial,"logic_Microball_tub",0,0,0);
m_CylindricalDetector->SetVisAttributes(m_VisSquare);
m_CylindricalDetector->SetSensitiveDetector(m_MicroballScorer);
}
return m_CylindricalDetector;
}
//....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 Microball::ReadConfiguration(string Path){
ifstream ConfigFile ;
ConfigFile.open(Path.c_str()) ;
string LineBuffer ;
string DataBuffer ;
double Theta = 0 , Phi = 0 , R = 0 ;
double X = 0 , Y = 0 , Z = 0 ;
string Shape ;
bool check_Theta = false ;
bool check_Phi = false ;
bool check_R = false ;
bool check_Shape = false ;
bool check_X = false ;
bool check_Y = false ;
bool check_Z = false ;
bool ReadingStatus = false ;
while (!ConfigFile.eof()) {
getline(ConfigFile, LineBuffer);
// If line is a Start Up Microball bloc, Reading toggle to true
string name = "Microball";
if (LineBuffer.compare(0, name.length(), name) == 0) {
G4cout << "///" << G4endl ;
G4cout << "Microball found: " << G4endl ;
ReadingStatus = true ;
}
// Else don't toggle to Reading Block Status
else ReadingStatus = false ;
// Reading Block
while(ReadingStatus){
// Pickup Next Word
ConfigFile >> DataBuffer ;
// Comment Line
if (DataBuffer.compare(0, 1, "%") == 0) {
ConfigFile.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
}
// Finding another telescope (safety), toggle out
else if (DataBuffer.compare(0, name.length(),name) == 0) {
G4cout << "WARNING: Another Detector is find before standard sequence of Token, Error may occured in Telecope definition" << G4endl ;
ReadingStatus = false ;
}
//Angle method
else if (DataBuffer.compare(0, 6, "THETA=") == 0) {
check_Theta = true;
ConfigFile >> DataBuffer ;
Theta = atof(DataBuffer.c_str()) ;
Theta = Theta * deg;
G4cout << "Theta: " << Theta / deg << G4endl;
}
else if (DataBuffer.compare(0, 4, "PHI=") == 0) {
check_Phi = true;
ConfigFile >> DataBuffer ;
Phi = atof(DataBuffer.c_str()) ;
Phi = Phi * deg;
G4cout << "Phi: " << Phi / deg << G4endl;
}
else if (DataBuffer.compare(0, 2, "R=") == 0) {
check_R = true;
ConfigFile >> DataBuffer ;
R = atof(DataBuffer.c_str()) ;
R = R * mm;
G4cout << "R: " << R/mm << G4endl;
}
//Position method
else if (DataBuffer.compare(0, 2, "X=") == 0) {
check_X = true;
ConfigFile >> DataBuffer ;
X = atof(DataBuffer.c_str()) ;
X = X * mm;
G4cout << "X: " << X / mm << G4endl;
}
else if (DataBuffer.compare(0, 2, "Y=") == 0) {
check_Y = true;
ConfigFile >> DataBuffer ;
Y = atof(DataBuffer.c_str()) ;
Y = Y * mm;
G4cout << "Y: " << Y / mm << G4endl;
}
else if (DataBuffer.compare(0, 2, "Z=") == 0) {
check_Z = true;
ConfigFile >> DataBuffer ;
Z = atof(DataBuffer.c_str()) ;
Z = Z * mm;
G4cout << "Z: " << Z / mm << G4endl;
}
//General
else if (DataBuffer.compare(0, 6, "Shape=") == 0) {
check_Shape = true;
ConfigFile >> DataBuffer ;
Shape = DataBuffer ;
G4cout << "Shape: " << Shape << G4endl;
}
///////////////////////////////////////////////////
// If no Detector Token and no comment, toggle out
else{
ReadingStatus = false;
G4cout << "Wrong Token Sequence: Getting out " << DataBuffer << G4endl ;
}
/////////////////////////////////////////////////
// If All necessary information there, toggle out
if (( check_Theta && check_Phi && check_R && check_Shape)
||
( check_X && check_Y && check_Z && check_Shape)){
// Convert Cartesian to Spherical (detector always face the target)
if (check_X){
R = sqrt (X*X+Y*Y+Z*Z);
Theta = acos(Z / (R) );
Phi = atan2(Y,X);
}
AddMicroball(R,Theta,Phi,Shape);
// Reinitialisation of Check Boolean
check_Theta = false ;
check_Phi = false ;
check_R = false ;
check_Shape = false ;
check_X = false ;
check_Y = false ;
check_Z = false ;
ReadingStatus = false ;
G4cout << "///"<< G4endl ;
}
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Construct detector and inialise sensitive part.
// Called After DetecorConstruction::AddDetector Method
void Microball::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()*Microball_NS::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);
if(m_Shape[i] == "Cylindrical"){
new G4PVPlacement(G4Transform3D(*Rot,Det_pos),
BuildCylindricalDetector(),
"Microball",world,false,i+1);
}
else if(m_Shape[i] == "Square"){
new G4PVPlacement(G4Transform3D(*Rot,Det_pos),
BuildSquareDetector(),
"Microball",world,false,i+1);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Add Detector branch to the EventTree.
// Called After DetecorConstruction::AddDetector Method
void Microball::InitializeRootOutput(){
RootOutput *pAnalysis = RootOutput::getInstance();
TTree *pTree = pAnalysis->GetTree();
pTree->Branch("Microball", "TMicroballData", &m_Event) ;
pTree->SetBranchAddress("Microball", &m_Event) ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Read sensitive part and fill the Root tree.
// Called at in the EventAction::EndOfEventAvtion
void Microball::ReadSensitive(const G4Event* event){
m_Event->Clear();
///////////
// Calorimeter scorer
G4THitsMap<G4double*>* CaloHitMap;
std::map<G4int, G4double**>::iterator Calo_itr;
G4int CaloCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID("MicroballScorer/Calorimeter");
CaloHitMap = (G4THitsMap<G4double*>*)(event->GetHCofThisEvent()->GetHC(CaloCollectionID));
// Loop on the Calo map
for (Calo_itr = CaloHitMap->GetMap()->begin() ; Calo_itr != CaloHitMap->GetMap()->end() ; Calo_itr++){
G4double* Info = *(Calo_itr->second);
//(Info[0]/2.35)*((Info[0]*1.02)*pow((Info[0]*1.8),.5))
// double Energy = RandGauss::shoot(Info[0],((Info[0]*1000*1.02/2.35)*pow((Info[0]*1000*1.8),.5)) );
double Energy = RandGauss::shoot(Info[0],Microball_NS::ResoEnergy);
if(Energy>Microball_NS::EnergyThreshold){
double Time = RandGauss::shoot(Info[1],Microball_NS::ResoTime);
int DetectorNbr = (int) Info[2];
m_Event->SetEnergy(DetectorNbr,Energy);
m_Event->SetTime(DetectorNbr,Time);
}
}
// clear map for next event
CaloHitMap->clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////
void Microball::InitializeScorers() {
// This check is necessary in case the geometry is reloaded
bool already_exist = false;
m_MicroballScorer = CheckScorer("MicroballScorer",already_exist) ;
if(already_exist)
return ;
// Otherwise the scorer is initialised
vector<int> level; level.push_back(0);
G4VPrimitiveScorer* Calorimeter= new CALORIMETERSCORERS::PS_Calorimeter("Calorimeter",level, 0) ;
//and register it to the multifunctionnal detector
m_MicroballScorer->RegisterPrimitive(Calorimeter);
G4SDManager::GetSDMpointer()->AddNewDetector(m_MicroballScorer) ;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////////////////////
// Construct Method to be pass to the DetectorFactory //
////////////////////////////////////////////////////////////////////////////////
NPS::VDetector* Microball::Construct(){
return (NPS::VDetector*) new Microball();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
////////////////////////////////////////////////////////////////////////////////
// Registering the construct method to the factory //
////////////////////////////////////////////////////////////////////////////////
extern"C" {
class proxy_nps_plastic{
public:
proxy_nps_plastic(){
NPS::DetectorFactory::getInstance()->AddToken("Microball","Microball");
NPS::DetectorFactory::getInstance()->AddDetector("Microball",Microball::Construct);
}
};
proxy_nps_plastic p_nps_plastic;
}
#ifndef Microball_h
#define Microball_h 1
/*****************************************************************************
* 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: Pierre Morfouace contact address: morfouac@nscl.msu.edu *
* *
* Creation Date : June 2016 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class describe Microball 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"
// NPTool header
#include "NPSVDetector.hh"
#include "TMicroballData.h"
class Microball : public NPS::VDetector{
////////////////////////////////////////////////////
/////// Default Constructor and Destructor /////////
////////////////////////////////////////////////////
public:
Microball() ;
virtual ~Microball() ;
////////////////////////////////////////////////////
/////// Specific Function of this Class ///////////
////////////////////////////////////////////////////
public:
// Cylindric plastic
void AddMicroball(double R,
double Theta,
double Phi,
string Shape);
G4LogicalVolume* BuildSquareDetector();
G4LogicalVolume* BuildCylindricalDetector();
private:
G4LogicalVolume* m_SquareDetector;
G4LogicalVolume* m_CylindricalDetector;
////////////////////////////////////////////////////
////// Inherite from NPS::VDetector class /////////
////////////////////////////////////////////////////
public:
// Read stream at Configfile to pick-up parameters of detector (Position,...)
// Called in DetecorConstruction::ReadDetextorConfiguration Method
void ReadConfiguration(string Path) ;
// 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_MicroballScorer ;
////////////////////////////////////////////////////
///////////Event class to store Data////////////////
////////////////////////////////////////////////////
private:
TMicroballData* m_Event ;
////////////////////////////////////////////////////
///////////////Private intern Data//////////////////
////////////////////////////////////////////////////
private: // Geometry
// Detector Coordinate
vector<double> m_R;
vector<double> m_Theta;
vector<double> m_Phi;
// Shape type
vector<string> m_Shape ;
// Visualisation Attribute
G4VisAttributes* m_VisSquare;
G4VisAttributes* m_VisCylinder;
// Needed for dynamic loading of the library
public:
static NPS::VDetector* Construct();
};
#endif
...@@ -88,10 +88,12 @@ void Analysis::TreatEvent(){ ...@@ -88,10 +88,12 @@ void Analysis::TreatEvent(){
if(Lassa->ThickSi_E.size()>0) InitialEnergy_Lassa = InitialEnergy; if(Lassa->ThickSi_E.size()>0) InitialEnergy_Lassa = InitialEnergy;
double phi_in = acos(InitialConditions->GetMomentumDirectionX(0)/sin(InitialConditions->GetThetaCM(0)*deg)); double phi_in = acos(InitialConditions->GetMomentumDirectionX(0)/sin(InitialConditions->GetThetaCM(0)*deg));
ECM_initial = alpha->GetEnergyCM(InitialEnergy, InitialConditions->GetThetaCM(0)*deg, phi_in, BetaCM); ECM_initial = helium3->GetEnergyCM(InitialEnergy, InitialConditions->GetThetaCM(0)*deg, phi_in, BetaCM);
ThetaCM = helium3->GetThetaCM(InitialEnergy, InitialConditions->GetThetaCM(0)*deg, phi_in, BetaCM)/deg;
ThetaLabInitial = InitialConditions->GetThetaLab_WorldFrame(0);
if(Lassa->ThickSi_E.size()>0){ if(Lassa->ThickSi_E.size()>0){
ECM_initial_Lassa = alpha->GetEnergyCM(InitialEnergy_Lassa, InitialConditions->GetThetaCM(0)*deg, phi_in, BetaCM); ECM_initial_Lassa = helium3->GetEnergyCM(InitialEnergy_Lassa, InitialConditions->GetThetaCM(0)*deg, phi_in, BetaCM);
} }
else ECM_initial_Lassa = -100; else ECM_initial_Lassa = -100;
///////////////////////////LOOP on Lassa Hit////////////////////////////////// ///////////////////////////LOOP on Lassa Hit//////////////////////////////////
...@@ -162,9 +164,11 @@ void Analysis::TreatEvent(){ ...@@ -162,9 +164,11 @@ void Analysis::TreatEvent(){
if(fabs(InitialEnergy-ELab_nucl)>EDelta) ELab_nucl = -100; if(fabs(InitialEnergy-ELab_nucl)>EDelta) ELab_nucl = -100;
if(ELab>0){ if(ELab>0){
ECM = alpha->GetEnergyCM(ELab, ThetaLab, PhiLab, BetaCM); ECM = helium3->GetEnergyCM(ELab, ThetaLab, PhiLab, BetaCM);
}
else{
ECM = -100;
} }
else ECM = -100;
ThetaLab = ThetaLab/deg; ThetaLab = ThetaLab/deg;
PhiLab = PhiLab/deg; PhiLab = PhiLab/deg;
...@@ -192,8 +196,10 @@ void Analysis::InitOutputBranch() { ...@@ -192,8 +196,10 @@ void Analysis::InitOutputBranch() {
RootOutput::getInstance()->GetTree()->Branch("ThicknessCsI",&ThicknessCsI,"ThicknessCsI/D"); RootOutput::getInstance()->GetTree()->Branch("ThicknessCsI",&ThicknessCsI,"ThicknessCsI/D");
RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab,"ELab/D"); RootOutput::getInstance()->GetTree()->Branch("ELab",&ELab,"ELab/D");
RootOutput::getInstance()->GetTree()->Branch("ECM",&ECM,"ECM/D"); RootOutput::getInstance()->GetTree()->Branch("ECM",&ECM,"ECM/D");
RootOutput::getInstance()->GetTree()->Branch("ThetaCM",&ThetaCM,"ThetaCM/D");
RootOutput::getInstance()->GetTree()->Branch("ELab_nucl",&ELab_nucl,"ELab_nucl/D"); RootOutput::getInstance()->GetTree()->Branch("ELab_nucl",&ELab_nucl,"ELab_nucl/D");
RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D"); RootOutput::getInstance()->GetTree()->Branch("ThetaLab",&ThetaLab,"ThetaLab/D");
RootOutput::getInstance()->GetTree()->Branch("ThetaLabInitial",&ThetaLabInitial,"ThetaLabInitial/D");
RootOutput::getInstance()->GetTree()->Branch("PhiLab",&PhiLab,"PhiLab/D"); RootOutput::getInstance()->GetTree()->Branch("PhiLab",&PhiLab,"PhiLab/D");
RootOutput::getInstance()->GetTree()->Branch("InitialEnergy",&InitialEnergy,"InitialEnergy/D"); RootOutput::getInstance()->GetTree()->Branch("InitialEnergy",&InitialEnergy,"InitialEnergy/D");
RootOutput::getInstance()->GetTree()->Branch("InitialEnergy_Lassa",&InitialEnergy_Lassa,"InitialEnergy_Lassa/D"); RootOutput::getInstance()->GetTree()->Branch("InitialEnergy_Lassa",&InitialEnergy_Lassa,"InitialEnergy_Lassa/D");
...@@ -219,8 +225,10 @@ void Analysis::ReInitValue(){ ...@@ -219,8 +225,10 @@ void Analysis::ReInitValue(){
E_CsI =-100; E_CsI =-100;
ELab = -100; ELab = -100;
ECM = -100; ECM = -100;
ThetaCM = -100;
ELab_nucl = -100; ELab_nucl = -100;
ThetaLab = -100; ThetaLab = -100;
ThetaLabInitial = -100;
PhiLab = -100; PhiLab = -100;
X = -100; X = -100;
Y = -100; Y = -100;
......
...@@ -45,11 +45,13 @@ class Analysis: public NPL::VAnalysis{ ...@@ -45,11 +45,13 @@ class Analysis: public NPL::VAnalysis{
private: private:
double ELab; double ELab;
double ECM; double ECM;
double ThetaCM;
double ELab_nucl; double ELab_nucl;
double E_ThickSi; double E_ThickSi;
double E_CsI; double E_CsI;
double PhiLab; double PhiLab;
double ThetaLab; double ThetaLab;
double ThetaLabInitial;
double X,Y,Z; double X,Y,Z;
double TelescopeNumber; double TelescopeNumber;
double thresholdEnergy; double thresholdEnergy;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment