Commit 658ccfb3 authored by Valérian Alcindor's avatar Valérian Alcindor
Browse files

Merge branch 'NPTool.2.dev' of https://github.com/adrien-matta/nptool into NPTool.2.dev

parents 867a9c6d 9d030d49
......@@ -46,9 +46,11 @@ TDaliData::~TDaliData() {
void TDaliData::Clear() {
// Energy
fDali_E_DetectorNbr.clear();
fDali_ADC.clear();
fDali_Energy.clear();
// Time
fDali_T_DetectorNbr.clear();
fDali_TDC.clear();
fDali_Time.clear();
}
......@@ -65,6 +67,7 @@ void TDaliData::Dump() const {
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fDali_E_DetectorNbr[i]
<< " ADC: " << fDali_ADC[i]
<< " Energy: " << fDali_Energy[i];
}
......@@ -74,6 +77,7 @@ void TDaliData::Dump() const {
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fDali_T_DetectorNbr[i]
<< " TDC: " << fDali_TDC[i]
<< " Time: " << fDali_Time[i];
}
}
......@@ -36,10 +36,12 @@ class TDaliData : public TObject {
private:
// Energy
vector<UShort_t> fDali_E_DetectorNbr;
vector<Double_t> fDali_ADC;
vector<Double_t> fDali_Energy;
// Time
vector<UShort_t> fDali_T_DetectorNbr;
vector<Double_t> fDali_TDC;
vector<Double_t> fDali_Time;
......@@ -65,22 +67,48 @@ class TDaliData : public TObject {
// add //! to avoid ROOT creating dictionnary for the methods
public:
////////////////////// SETTERS ////////////////////////
// ADC
inline void SetADC(const UShort_t& DetNbr,const Double_t& Energy){
fDali_E_DetectorNbr.push_back(DetNbr);
fDali_ADC.push_back(Energy);
};//!
inline void SetADC_Only(const Double_t& Energy){
fDali_ADC.push_back(Energy);
};//!
// Energy
inline void SetEnergy(const UShort_t& DetNbr,const Double_t& Energy){
fDali_E_DetectorNbr.push_back(DetNbr);
fDali_Energy.push_back(Energy);
};//!
// TDC
inline void SetTDC(const UShort_t& DetNbr,const Double_t& Time) {
fDali_T_DetectorNbr.push_back(DetNbr);
fDali_TDC.push_back(Time);
};//!
// Time
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
fDali_T_DetectorNbr.push_back(DetNbr);
fDali_Time.push_back(Time);
};//!
// (A&T DC)
inline void SetADCAndTDC(const UShort_t& DetNbr,const Double_t& Energy,const Double_t& Time){
fDali_ADC.push_back(Energy);
fDali_TDC.push_back(Time);
fDali_T_DetectorNbr.push_back(DetNbr);
fDali_E_DetectorNbr.push_back(DetNbr);
};//!
// (E&T)
inline void SetEnergyAndTime(const UShort_t& DetNbr,const Double_t& Energy,const Double_t& Time){
fDali_Energy.push_back(Energy);
fDali_Time.push_back(Time);
fDali_T_DetectorNbr.push_back(DetNbr);
fDali_E_DetectorNbr.push_back(DetNbr);
};//!
//
......@@ -90,14 +118,18 @@ class TDaliData : public TObject {
{return fDali_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fDali_E_DetectorNbr[i];}//!
inline Double_t Get_ADC(const unsigned int &i) const
{return fDali_ADC[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fDali_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fDali_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fDali_T_DetectorNbr[i];}//!
inline Double_t Get_TDC(const unsigned int &i) const
{return fDali_TDC[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fDali_Time[i];}//!
......
......@@ -63,7 +63,9 @@ class TDaliPhysics : public TObject, public NPL::VDetector {
// output ROOT file
public:
vector<int> DetectorNumber;
vector<double> ADC;
vector<double> Energy;
vector<double> TDC;
vector<double> Time;
/// A usefull method to bundle all operation to add a detector
......
;; -*- mode: emacs-lisp; coding: utf-8-unix -*-
;; Minibuffer history file, automatically generated by `savehist'.
(setq savehist-minibuffer-history-variables '(query-replace-history extended-command-history))
(setq query-replace-history '("^\\1" "\\^{\\([0-9]?\\)}" "\\^{\\([0-9]?\\)}" "_\\1" "_{\\([0-9]?\\)}" "_{\\([0-9]?\\)}" "_\\1" "_{\\([0_9]?\\)}" "_{\\([0_9]?\\)}" "_\\&" "_{\\([0_9]?\\)}" "_{\\([0_9]?\\)}" "_" "_{1}"))
(setq extended-command-history '("query-replace-regexp" "query-replace" "query-replace-regexp"))
add_custom_command(OUTPUT TMinosPhysicsDict.cxx COMMAND ../../scripts/build_dict.sh TMinosPhysics.h TMinosPhysicsDict.cxx TMinosPhysics.rootmap libNPMinos.dylib DEPENDS TMinosPhysics.h)
add_custom_command(OUTPUT TMinosDataDict.cxx COMMAND ../../scripts/build_dict.sh TMinosData.h TMinosDataDict.cxx TMinosData.rootmap libNPMinos.dylib DEPENDS TMinosData.h)
add_library(NPMinos SHARED TMinosSpectra.cxx TMinosData.cxx TMinosPhysics.cxx TMinosDataDict.cxx TMinosPhysicsDict.cxx )
target_link_libraries(NPMinos ${ROOT_LIBRARIES} NPCore)
install(FILES TMinosData.h TMinosPhysics.h TMinosSpectra.h DESTINATION ${CMAKE_INCLUDE_OUTPUT_DIRECTORY})
/*****************************************************************************
* Copyright (C) 2009-2018 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: Elidiano Tronchin contact address: tronchin@lpccaen.in2p3.fr *
* *
* Creation Date : October 2018 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Minos Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TMinosData.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
ClassImp(TMinosData)
//////////////////////////////////////////////////////////////////////
TMinosData::TMinosData() {
}
//////////////////////////////////////////////////////////////////////
TMinosData::~TMinosData() {
}
//////////////////////////////////////////////////////////////////////
void TMinosData::Clear() {
// Energy
fMinos_E_DetectorNbr.clear();
fMinos_Energy.clear();
// Time
fMinos_T_DetectorNbr.clear();
fMinos_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TMinosData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TMinosData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fMinos_E_DetectorNbr.size();
cout << "Minos_E_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fMinos_E_DetectorNbr[i]
<< " Energy: " << fMinos_Energy[i];
}
// Time
mysize = fMinos_T_DetectorNbr.size();
cout << "Minos_T_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fMinos_T_DetectorNbr[i]
<< " Time: " << fMinos_Time[i];
}
}
#ifndef __MinosDATA__
#define __MinosDATA__
/*****************************************************************************
* Copyright (C) 2009-2018 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: Elidiano Tronchin contact address: tronchin@lpccaen.in2p3.fr *
* *
* Creation Date : October 2018 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Minos Raw data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
// STL
#include <vector>
using namespace std;
// ROOT
#include "TObject.h"
class TMinosData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
// Energy
vector<UShort_t> fMinos_E_DetectorNbr;
vector<Double_t> fMinos_Energy;
// Time
vector<UShort_t> fMinos_T_DetectorNbr;
vector<Double_t> fMinos_Time;
// maybe directions with angle varagles have to be added?
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TMinosData();
~TMinosData();
//////////////////////////////////////////////////////////////
// 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){
fMinos_E_DetectorNbr.push_back(DetNbr);
fMinos_Energy.push_back(Energy);
};//!
// Time
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
fMinos_T_DetectorNbr.push_back(DetNbr);
fMinos_Time.push_back(Time);
};//!
// (E&T)
inline void SetEnergyAndTime(const UShort_t& DetNbr,const Double_t& Energy,const Double_t& Time){
fMinos_Energy.push_back(Energy);
fMinos_Time.push_back(Time);
fMinos_T_DetectorNbr.push_back(DetNbr);
};//!
//
////////////////////// GETTERS ////////////////////////
// Energy
inline UShort_t GetMultEnergy() const
{return fMinos_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fMinos_E_DetectorNbr[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fMinos_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fMinos_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fMinos_T_DetectorNbr[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fMinos_Time[i];}//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TMinosData,1) // MinosData structure
};
#endif
/*****************************************************************************
* Copyright (C) 2009-2018 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: Elidiano Tronchin contact address: tronchin@lpccaen.in2p3.fr *
* *
* Creation Date : October 2018 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class hold Minos Treated data *
* *
*---------------------------------------------------------------------------*
* Comment: *
* *
* *
*****************************************************************************/
#include "TMinosPhysics.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(TMinosPhysics)
///////////////////////////////////////////////////////////////////////////
TMinosPhysics::TMinosPhysics()
: m_EventData(new TMinosData),
m_PreTreatedData(new TMinosData),
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 TMinosPhysics::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 TMinosPhysics::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 TMinosPhysics::BuildSimplePhysicalEvent() {
BuildPhysicalEvent();
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::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 TMinosPhysics::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("Minos/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("Minos/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
}
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::ReadAnalysisConfig() {
bool ReadingStatus = false;
// path to file
string FileName = "./configs/ConfigMinos.dat";
// open analysis config file
ifstream AnalysisConfigFile;
AnalysisConfigFile.open(FileName.c_str());
if (!AnalysisConfigFile.is_open()) {
cout << " No ConfigMinos.dat found: Default parameter loaded for Analayis " << FileName << endl;
return;
}
cout << " Loading user parameter for Analysis from ConfigMinos.dat " << endl;
// Save it in a TAsciiFile
TAsciiFile* asciiConfig = RootOutput::getInstance()->GetAsciiFileAnalysisConfig();
asciiConfig->AppendLine("%%% ConfigMinos.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 = "ConfigMinos";
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 TMinosPhysics::Clear() {
DetectorNumber.clear();
Energy.clear();
Time.clear();
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::ReadConfiguration(NPL::InputParser parser) {
vector<NPL::InputBlock*> blocks = parser.GetAllBlocksWithToken("Minos");
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 << "//// Minos " << 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 << "//// Minos " << 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 TMinosPhysics::InitSpectra() {
m_Spectra = new TMinosSpectra(m_NumberOfDetectors);
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::FillSpectra() {
m_Spectra -> FillRawSpectra(m_EventData);
m_Spectra -> FillPreTreatedSpectra(m_PreTreatedData);
m_Spectra -> FillPhysicsSpectra(m_EventPhysics);
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::CheckSpectra() {
m_Spectra->CheckSpectra();
}
///////////////////////////////////////////////////////////////////////////
void TMinosPhysics::ClearSpectra() {
// To be done
}
///////////////////////////////////////////////////////////////////////////
map< string , TH1*> TMinosPhysics::GetSpectra() {
if(m_Spectra)
return m_Spectra->GetMapHisto();
else{
map< string , TH1*> empty;
return empty;
}
}
///////////////////////////////////////////////////////////////////////////