Commit b95c47fb authored by Adrien Matta's avatar Adrien Matta
Browse files

* Progress on catana simulation and analysis

        - now can compute position of hit from CSV file
parent 72b1d7f9
Pipeline #77744 passed with stages
in 9 minutes and 48 seconds
......@@ -35,6 +35,8 @@ using namespace std;
#include "RootOutput.h"
#include "NPDetectorFactory.h"
#include "NPOptionManager.h"
#include "NPSystemOfUnits.h"
using namespace NPUNITS;
// ROOT
#include "TChain.h"
......@@ -53,22 +55,16 @@ TCatanaPhysics::TCatanaPhysics()
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){
// 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 TCatanaPhysics::AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type){
m_NumberOfDetectors++;
TVector3 Pos(X,Y,Z);
m_Position[ID]=Pos+m_Ref;
m_Theta[ID]=Theta;
m_Phi[ID]=Phi;
m_Type[ID]=Type;
}
///////////////////////////////////////////////////////////////////////////
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() {
// apply thresholds and calibration
......@@ -202,36 +220,60 @@ void TCatanaPhysics::Clear() {
///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::ReadConfiguration(NPL::InputParser parser) {
/* vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Catana");
void TCatanaPhysics::ReadConfiguration(NPL::InputParser parser){
// CSV config
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithTokenAndValue("Catana","CSV");
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++){
if(blocks[i]->HasTokenList(cart)){
if(blocks[i]->HasTokenList(token)){
if(NPOptionManager::getInstance()->GetVerboseLevel())
cout << endl << "//// Catana " << i+1 << endl;
TVector3 Pos = blocks[i]->GetTVector3("POS","mm");
string Shape = blocks[i]->GetString("Shape");
AddDetector(Pos,Shape);
string path = blocks[i]->GetString("Path");
//double Rshift = blocks[i]->GetDouble("Rshift","micrometer");
// Reference position of the whole array
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())
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 Phi = blocks[i]->GetDouble("Phi","deg");
string Shape = blocks[i]->GetString("Shape");
AddDetector(R,Theta,Phi,Shape);
int ID = blocks[i]->GetInt("ID");
int Type = blocks[i]->GetInt("Type");
AddDetector(X,Y,Z,Theta,Phi,ID,Type);
}
else{
cout << "ERROR: check your input file formatting " << endl;
exit(1);
}
}*/
}
}
///////////////////////////////////////////////////////////////////////////
void TCatanaPhysics::InitSpectra() {
m_Spectra = new TCatanaSpectra(m_NumberOfDetectors);
......
#ifndef 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 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 : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Catana Treated data *
* This class hold Catana Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
......@@ -67,9 +67,18 @@ class TCatanaPhysics : public TObject, public NPL::VDetector {
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);
void AddDetector(double X, double Y, double Z, double Theta, double Phi, int ID, int Type);
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
public:
......
......@@ -512,7 +512,7 @@ void Catana::InitializeScorers() {
return ;
// 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* Interaction= new InteractionScorers::PS_Interactions("Interaction",ms_InterCoord, 0) ;
//and register it to the multifunctionnal detector
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment