Commit 5abb3b07 authored by Adrien Matta's avatar Adrien Matta
Browse files

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

parents c0bafd0d e397d977
Pipeline #85822 passed with stages
in 55 minutes and 31 seconds
......@@ -78,7 +78,6 @@ void Analysis::TreatEvent(){
TVector3 vX = TVector3(1,0,0);
TVector3 aTrack, vB;
if(TrackMult>1){
vTrack = Actar->GetTracks();
double scalarproduct=0;
......@@ -106,7 +105,8 @@ void Analysis::TreatEvent(){
double ZBeamPoint = vTrack[BeamTrack].GetZh();
TVector3 vBeamPos = TVector3(XBeamPoint,YBeamPoint,ZBeamPoint);
vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam*DriftVelocity);
//vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam*DriftVelocity);
vB = TVector3(XBeam*PadSizeX, YBeam*PadSizeY,ZBeam);
BeamAngle = (vX.Angle(vB))*180/TMath::Pi();
for(unsigned int i=0; i<TrackMult; i++){
......@@ -117,9 +117,11 @@ void Analysis::TreatEvent(){
double vertex_x = vTrack[i].GetVertexPostion(vBeam,vBeamPos).X()*PadSizeX;
double vertex_y = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Y()*PadSizeY;
double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z()*DriftVelocity;
//double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z()*DriftVelocity;
double vertex_z = vTrack[i].GetVertexPostion(vBeam,vBeamPos).Z();
aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir*DriftVelocity);
//aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir*DriftVelocity);
aTrack = TVector3(Xdir*PadSizeX, Ydir*PadSizeY, Zdir);
double angle = vX.Angle(aTrack)*180/TMath::Pi();
//double angle = vB.Angle(aTrack)*180/TMath::Pi();
if(angle>90) angle = 180-angle;
......@@ -130,8 +132,10 @@ void Analysis::TreatEvent(){
double y2 = vTrack[i].GetYh()*PadSizeY-0.5*NumberOfPadsY*PadSizeY;
//double z1 = -(vTrack[i].GetZm()-256)*DriftVelocity;
//double z2 = -(vTrack[i].GetZh()-256)*DriftVelocity;
double z1 = vTrack[i].GetZm()*DriftVelocity;
double z2 = vTrack[i].GetZh()*DriftVelocity;
//double z1 = vTrack[i].GetZm()*DriftVelocity;
double z1 = vTrack[i].GetZm();
//double z2 = vTrack[i].GetZh()*DriftVelocity;
double z2 = vTrack[i].GetZh();
if(vertex_x>0 && vertex_x<256){
......
ConfigActar
RecoRansac= 0
RecoCluster= 1
RecoVisu= 0
RecoRansac= 1
RecoCluster= 0
RecoVisu= 1
HIT_THRESHOLD= 2
Q_THRESHOLD= 0
T_THRESHOLD= 0
......@@ -17,4 +17,4 @@ Gas= iC4H10
%Gas= D2
%Pressure in mbar
Pressure= 100
DriftVelocity= 2.66
DriftVelocity= 0.8e-2
......@@ -17,7 +17,7 @@ void LoadCut()
void LoadChain()
{
chain = new TChain("PhysicsTree");
chain->Add("../../Outputs/Analysis/Example4.root");
chain->Add("../../../Outputs/Analysis/Example4.root");
}
////////////////////////////////////////////////
......
......@@ -18,7 +18,7 @@ void LoadCut()
void LoadChain()
{
chain = new TChain("PhysicsTree");
chain->Add("../../Outputs/Analysis/Example4.root");
chain->Add("../../../Outputs/Analysis/Example4.root");
}
////////////////////////////////////////////////
......
......@@ -45,34 +45,34 @@ using namespace std;
ClassImp(TActarPhysics)
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
TActarPhysics::TActarPhysics()
: m_EventData(new TActarData),
m_EventReduced(new MEventReduced),
m_PreTreatedData(new TActarData),
m_EventPhysics(this),
m_Spectra(0),
fRecoRansac(1),
fRecoCluster(0),
fRecoVisu(0),
fHitThreshold(20),
fQ_Threshold(0),
fT_Threshold(0),
fXBeamMin(0),
fXBeamMax(128),
fYBeamMin(60),
fYBeamMax(67),
fNumberOfPadsX(128),
fNumberOfPadsY(128),
fPadSizeX(2),
fPadSizeY(2),
fDriftVelocity(40),
fPressure(100),
fGas("iC4H10"),
m_NumberOfPadSilicon(20),
m_NumberOfDetectors(0) {
}
: m_EventData(new TActarData),
m_EventReduced(new MEventReduced),
m_PreTreatedData(new TActarData),
m_EventPhysics(this),
m_Spectra(0),
fRecoRansac(1),
fRecoCluster(0),
fRecoVisu(0),
fHitThreshold(20),
fQ_Threshold(0),
fT_Threshold(0),
fXBeamMin(0),
fXBeamMax(128),
fYBeamMin(60),
fYBeamMax(67),
fNumberOfPadsX(128),
fNumberOfPadsY(128),
fPadSizeX(2),
fPadSizeY(2),
fDriftVelocity(40),
fPressure(100),
fGas("iC4H10"),
m_NumberOfPadSilicon(20),
m_NumberOfDetectors(0) {
}
///////////////////////////////////////////////////////////////////////////
/// A usefull method to bundle all operation to add a detector
......@@ -112,6 +112,7 @@ void TActarPhysics::BuildPhysicalEvent() {
PadCharge.push_back(m_PreTreatedData->GetPadCharge(e));
}*/
if(fRecoRansac && PadX.size()>fHitThreshold){
//m_Ransac->Init(PadX, PadY, PadZ, PadCharge);
m_Ransac->Init(PadX, PadY, PadZ, PadCharge);
m_Track = m_Ransac->SimpleRansac();
}
......@@ -150,16 +151,15 @@ void TActarPhysics::PreTreat() {
unsigned int mysize = m_EventReduced->CoboAsad.size();
for (unsigned int it = 0; it < mysize ; ++it) {
int co=m_EventReduced->CoboAsad[it].globalchannelid>>11;
int as=(m_EventReduced->CoboAsad[it].globalchannelid - (co<<11))>>9;
int ag=(m_EventReduced->CoboAsad[it].globalchannelid - (co<<11)-(as<<9))>>7;
int ch=m_EventReduced->CoboAsad[it].globalchannelid - (co<<11)-(as<<9)-(ag<<7);
int where=co*NumberOfASAD*NumberOfAGET*NumberOfChannel + as*NumberOfAGET*NumberOfChannel + ag*NumberOfChannel + ch;
if(co!=31){
unsigned int vector_size = m_EventReduced->CoboAsad[it].peakheight.size();
//cout << vector_size << endl;
for(unsigned int hh=0; hh<vector_size; hh++){
if(m_EventReduced->CoboAsad[it].peakheight[hh]>fQ_Threshold && m_EventReduced->CoboAsad[it].peaktime[hh]>fT_Threshold){
if(GoodHit(TABLE[4][where],TABLE[5][where])){
......@@ -169,13 +169,13 @@ void TActarPhysics::PreTreat() {
BeamPadCharge.push_back(m_EventReduced->CoboAsad[it].peakheight[hh]);
BeamPadX.push_back(TABLE[4][where]);
BeamPadY.push_back(TABLE[5][where]);
BeamPadZ.push_back(m_EventReduced->CoboAsad[it].peaktime[hh]);
BeamPadZ.push_back(int(m_EventReduced->CoboAsad[it].peaktime[hh]*fDriftVelocity));
}
else{
PadCharge.push_back(m_EventReduced->CoboAsad[it].peakheight[hh]);
PadX.push_back(TABLE[4][where]);
PadY.push_back(TABLE[5][where]);
PadZ.push_back(m_EventReduced->CoboAsad[it].peaktime[hh]);
PadZ.push_back(int(m_EventReduced->CoboAsad[it].peaktime[hh]*fDriftVelocity));
}
}
......@@ -183,7 +183,7 @@ void TActarPhysics::PreTreat() {
PadCharge.push_back(m_EventReduced->CoboAsad[it].peakheight[hh]);
PadX.push_back(TABLE[4][where]);
PadY.push_back(TABLE[5][where]);
PadZ.push_back(m_EventReduced->CoboAsad[it].peaktime[hh]);
PadZ.push_back(int(m_EventReduced->CoboAsad[it].peaktime[hh]*fDriftVelocity));
}
//}
}
......@@ -639,7 +639,7 @@ void TActarPhysics::AddParameterToCalibrationManager() {
TChain* inputChain = RootInput::getInstance()->GetChain();
inputChain->SetBranchStatus("Actar", true );
inputChain->SetBranchAddress("Actar", &m_EventData );
}*/
}*/
///////////////////////////////////////////////////////////////////////////
void TActarPhysics::InitializeRootInputRaw() {
......
add_custom_command(OUTPUT TFissionChamberPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TFissionChamberPhysics.h TFissionChamberPhysicsDict.cxx TFissionChamberPhysics.rootmap libNPFissionChamber.dylib DEPENDS TFissionChamberPhysics.h)
add_custom_command(OUTPUT TFissionChamberDataDict.cxx COMMAND ../../scripts/build_dict.sh TFissionChamberData.h TFissionChamberDataDict.cxx TFissionChamberData.rootmap libNPFissionChamber.dylib DEPENDS TFissionChamberData.h)
add_library(NPFissionChamber SHARED TFissionChamberSpectra.cxx TFissionChamberData.cxx TFissionChamberPhysics.cxx TFissionChamberDataDict.cxx TFissionChamberPhysicsDict.cxx )
target_link_libraries(NPFissionChamber ${ROOT_LIBRARIES} NPCore)
install(FILES TFissionChamberData.h TFissionChamberPhysics.h TFissionChamberSpectra.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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TFissionChamberData.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
ClassImp(TFissionChamberData)
//////////////////////////////////////////////////////////////////////
TFissionChamberData::TFissionChamberData() {
}
//////////////////////////////////////////////////////////////////////
TFissionChamberData::~TFissionChamberData() {
}
//////////////////////////////////////////////////////////////////////
void TFissionChamberData::Clear() {
// Energy
fFissionChamber_E_DetectorNbr.clear();
fFissionChamber_Energy.clear();
// Time
fFissionChamber_T_DetectorNbr.clear();
fFissionChamber_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TFissionChamberData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TFissionChamberData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fFissionChamber_E_DetectorNbr.size();
cout << "FissionChamber_E_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fFissionChamber_E_DetectorNbr[i]
<< " Energy: " << fFissionChamber_Energy[i];
}
// Time
mysize = fFissionChamber_T_DetectorNbr.size();
cout << "FissionChamber_T_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fFissionChamber_T_DetectorNbr[i]
<< " Time: " << fFissionChamber_Time[i];
}
}
#ifndef __FissionChamberDATA__
#define __FissionChamberDATA__
/*****************************************************************************
* 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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using namespace std;
// ROOT
#include "TObject.h"
class TFissionChamberData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
// Energy
vector<UShort_t> fFissionChamber_E_DetectorNbr;
vector<Double_t> fFissionChamber_Energy;
// Time
vector<UShort_t> fFissionChamber_T_DetectorNbr;
vector<Double_t> fFissionChamber_Time;
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TFissionChamberData();
~TFissionChamberData();
//////////////////////////////////////////////////////////////
// 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 SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){
fFissionChamber_E_DetectorNbr.push_back(DetNbr);
fFissionChamber_Energy.push_back(Energy);
};//!
// Time
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
fFissionChamber_T_DetectorNbr.push_back(DetNbr);
fFissionChamber_Time.push_back(Time);
};//!
////////////////////// GETTERS ////////////////////////
// Energy
inline UShort_t GetMultEnergy() const
{return fFissionChamber_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fFissionChamber_E_DetectorNbr[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fFissionChamber_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fFissionChamber_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fFissionChamber_T_DetectorNbr[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fFissionChamber_Time[i];}//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TFissionChamberData,1) // FissionChamberData 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 : September 2020 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold FissionChamber Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TFissionChamberPhysics.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(TFissionChamberPhysics)
///////////////////////////////////////////////////////////////////////////
TFissionChamberPhysics::TFissionChamberPhysics()
: m_EventData(new TFissionChamberData),
m_PreTreatedData(new TFissionChamberData),
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 TFissionChamberPhysics::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 TFissionChamberPhysics::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 TFissionChamberPhysics::BuildSimplePhysicalEvent() {
BuildPhysicalEvent();
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::BuildPhysicalEvent() {
// apply thresholds and calibration
PreTreat();
// match energy and time together
unsigned int mysizeE = m_PreTreatedData->GetMultEnergy();
unsigned int mysizeT = m_PreTreatedData->GetMultTime();
for (UShort_t e = 0; e < mysizeE ; e++) {
for (UShort_t t = 0; t < mysizeT ; 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 TFissionChamberPhysics::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->GetMultEnergy();
for (UShort_t i = 0; i < mysize ; ++i) {
if (m_EventData->Get_Energy(i) > m_E_RAW_Threshold) {
Double_t Energy = Cal->ApplyCalibration("FissionChamber/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
mysize = m_EventData->GetMultTime();
for (UShort_t i = 0; i < mysize; ++i) {
Double_t Time= Cal->ApplyCalibration("FissionChamber/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
}
}
///////////////////////////////////////////////////////////////////////////
void TFissionChamberPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to file
string FileName = "./configs/ConfigFissionChamber.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigFissionChamber.dat found: Default parameter loaded for Analayis " << FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigFissionChamber.dat " << endl;
// Save it in a TAsciiFile
TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
asciiConfig->AppendLine("%%% ConfigFissionChamber.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 = "ConfigFissionChamber";
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 TFissionChamberPhysics::Clear() {
DetectorNumber.clear();