Skip to content
Snippets Groups Projects
Commit b95c47fb authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

* Progress on catana simulation and analysis

        - now can compute position of hit from CSV file
parent 72b1d7f9
No related branches found
No related tags found
No related merge requests found
Pipeline #77744 passed
...@@ -35,6 +35,8 @@ using namespace std; ...@@ -35,6 +35,8 @@ using namespace std;
#include "RootOutput.h" #include "RootOutput.h"
#include "NPDetectorFactory.h" #include "NPDetectorFactory.h"
#include "NPOptionManager.h" #include "NPOptionManager.h"
#include "NPSystemOfUnits.h"
using namespace NPUNITS;
// ROOT // ROOT
#include "TChain.h" #include "TChain.h"
...@@ -53,22 +55,16 @@ TCatanaPhysics::TCatanaPhysics() ...@@ -53,22 +55,16 @@ TCatanaPhysics::TCatanaPhysics()
m_NumberOfDetectors(0) { m_NumberOfDetectors(0) {
} }
///////////////////////////////////////////////////////////////////////////
/// A usefull method to bundle all operation to add a detector
void TCatanaPhysics::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 TCatanaPhysics::AddDetector(double R, double Theta, double Phi, string shape){ void TCatanaPhysics::AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type){
// Compute the TVector3 corresponding m_NumberOfDetectors++;
TVector3 Pos(R*sin(Theta)*cos(Phi),R*sin(Theta)*sin(Phi),R*cos(Theta)); TVector3 Pos(X,Y,Z);
// Call the cartesian method m_Position[ID]=Pos+m_Ref;
AddDetector(Pos,shape); m_Theta[ID]=Theta;
} m_Phi[ID]=Phi;
m_Type[ID]=Type;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::BuildSimplePhysicalEvent() { void TCatanaPhysics::BuildSimplePhysicalEvent() {
...@@ -76,7 +72,29 @@ void TCatanaPhysics::BuildSimplePhysicalEvent() { ...@@ -76,7 +72,29 @@ void TCatanaPhysics::BuildSimplePhysicalEvent() {
} }
///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::ReadCSV(string path){
std::ifstream csv(path);
if(!csv.is_open()){
std::ostringstream message;
message << "Catana csv file " << path << " not found " << std::endl;
}
int ID, type,layer;
double X,Y,Z,Theta,Phi;
string buffer;
// ignore first line
getline(csv,buffer);
while(csv >> ID >> buffer >> type >> buffer >> layer >> buffer >> X >> buffer >> Y >> buffer >> Z >> buffer >> Theta >> buffer >> Phi){
if(type<6)
AddDetector(X,Y,Z,Theta*deg,Phi*deg,ID,type);
else{
// ignore other type for which I don't have the geometry
}
}
return;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::BuildPhysicalEvent() { void TCatanaPhysics::BuildPhysicalEvent() {
// apply thresholds and calibration // apply thresholds and calibration
...@@ -202,36 +220,60 @@ void TCatanaPhysics::Clear() { ...@@ -202,36 +220,60 @@ void TCatanaPhysics::Clear() {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::ReadConfiguration(NPL::InputParser parser) { void TCatanaPhysics::ReadConfiguration(NPL::InputParser parser){
/* vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Catana"); // CSV config
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana","CSV");
if(NPOptionManager::getInstance()->GetVerboseLevel()) if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl; cout << "//// " << blocks.size() << " CSV block found " << endl;
vector<string> token = {"Path","Pos","Rshift"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){ for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(cart)){ if(blocks[i]->HasTokenList(token)){
if(NPOptionManager::getInstance()->GetVerboseLevel()) if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Catana " << i+1 << endl; cout << endl << "//// Catana " << i+1 << endl;
string path = blocks[i]->GetString("Path");
TVector3 Pos = blocks[i]->GetTVector3("POS","mm"); //double Rshift = blocks[i]->GetDouble("Rshift","micrometer");
string Shape = blocks[i]->GetString("Shape"); // Reference position of the whole array
AddDetector(Pos,Shape); m_Ref = blocks[i]->GetTVector3("Pos","mm");
ReadCSV(path);
} }
else if(blocks[i]->HasTokenList(sphe)){ else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}
// Type 1
blocks = parser.GetAllBlocksWithTokenAndValue("Catana","Detector");
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << "//// " << blocks.size() << " detectors found " << endl;
token = {"X","Y","Z","Theta","Phi","ID","Type"};
for(unsigned int i = 0 ; i < blocks.size() ; i++){
if(blocks[i]->HasTokenList(token)){
if(NPOptionManager::getInstance()->GetVerboseLevel()) if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Catana " << i+1 << endl; cout << endl << "//// Catana " << i+1 << endl;
double R = blocks[i]->GetDouble("R","mm"); double X = blocks[i]->GetDouble("X","mm");
double Y = blocks[i]->GetDouble("Y","mm");
double Z = blocks[i]->GetDouble("Z","mm");
double Theta = blocks[i]->GetDouble("Theta","deg"); double Theta = blocks[i]->GetDouble("Theta","deg");
double Phi = blocks[i]->GetDouble("Phi","deg"); double Phi = blocks[i]->GetDouble("Phi","deg");
string Shape = blocks[i]->GetString("Shape"); int ID = blocks[i]->GetInt("ID");
AddDetector(R,Theta,Phi,Shape); int Type = blocks[i]->GetInt("Type");
AddDetector(X,Y,Z,Theta,Phi,ID,Type);
} }
else{ else{
cout << "ERROR: check your input file formatting " << endl; cout << "ERROR: check your input file formatting " << endl;
exit(1); exit(1);
} }
}*/ }
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::InitSpectra() { void TCatanaPhysics::InitSpectra() {
m_Spectra = new TCatanaSpectra(m_NumberOfDetectors); m_Spectra = new TCatanaSpectra(m_NumberOfDetectors);
......
#ifndef TCatanaPHYSICS_H #ifndef TCatanaPHYSICS_H
#define TCatanaPHYSICS_H #define TCatanaPHYSICS_H
/***************************************************************************** /*****************************************************************************
* Copyright (C) 2009-2020 this file is part of the NPTool Project * * Copyright (C) 2009-2020 this file is part of the NPTool Project *
* * * *
* For the licensing terms see $NPTOOL/Licence/NPTool_Licence * * For the licensing terms see $NPTOOL/Licence/NPTool_Licence *
* For the list of contributors see $NPTOOL/Licence/Contributors * * For the list of contributors see $NPTOOL/Licence/Contributors *
*****************************************************************************/ *****************************************************************************/
/***************************************************************************** /*****************************************************************************
* Original Author: Adrien Matta contact address: matta@lpccaen.in2p3.fr * * Original Author: Adrien Matta contact address: matta@lpccaen.in2p3.fr *
* * * *
* Creation Date : July 2020 * * Creation Date : July 2020 *
* Last update : * * Last update : *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
* Decription: * * Decription: *
* This class hold Catana Treated data * * This class hold Catana Treated data *
* * * *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
* Comment: * * Comment: *
...@@ -67,9 +67,18 @@ class TCatanaPhysics : public TObject, public NPL::VDetector { ...@@ -67,9 +67,18 @@ class TCatanaPhysics : public TObject, public NPL::VDetector {
vector<double> Time; vector<double> Time;
/// A usefull method to bundle all operation to add a detector /// A usefull method to bundle all operation to add a detector
void AddDetector(TVector3 POS, string shape); void AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type);
void AddDetector(double R, double Theta, double Phi, string shape); void ReadCSV(string path);
// Position method and variable
public:
map<int,TVector3> m_Position;//!
map<int,double> m_Theta;//!
map<int,double> m_Phi;//!
map<int,int> m_Type;//!
TVector3 m_Ref;//!
TVector3 GetPositionOfInteraction(int& i);//!
////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////
// methods inherited from the VDetector ABC class // methods inherited from the VDetector ABC class
public: public:
......
...@@ -512,7 +512,7 @@ void Catana::InitializeScorers() { ...@@ -512,7 +512,7 @@ void Catana::InitializeScorers() {
return ; return ;
// Otherwise the scorer is initialised // Otherwise the scorer is initialised
vector<int> level; level.push_back(0); vector<int> level; level.push_back(2);
G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ; G4VPrimitiveScorer* Calorimeter= new CalorimeterScorers::PS_Calorimeter("Calorimeter",level, 0) ;
G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ; G4VPrimitiveScorer* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ;
//and register it to the multifunctionnal detector //and register it to the multifunctionnal detector
......
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