Commit df0882d8 authored by Elidiano Tronchin's avatar Elidiano Tronchin
Browse files

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

Added EventGeneratorCosmic
parents 34f347bb 12c375e1
......@@ -48,4 +48,5 @@ Projects/T40/19Fdp.reaction
Projects/T40/configs/*.dat
Outputs
Outputs/*
Outputs/*/*.*
\ No newline at end of file
Outputs/*/*.*
NPLib/Utility/npspectra_test
\ No newline at end of file
......@@ -40,40 +40,4 @@ TLightPipeData::TLightPipeData() {
TLightPipeData::~TLightPipeData() {
}
//////////////////////////////////////////////////////////////////////
void TLightPipeData::Clear() {
// Energy
fLightPipe_E_DetectorNbr.clear();
fLightPipe_Energy.clear();
// Time
fLightPipe_T_DetectorNbr.clear();
fLightPipe_Time.clear();
}
//////////////////////////////////////////////////////////////////////
void TLightPipeData::Dump() const {
// This method is very useful for debuging and worth the dev.
cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TLightPipeData::Dump()] XXXXXXXXXXXXXXXXX" << endl;
// Energy
size_t mysize = fLightPipe_E_DetectorNbr.size();
cout << "LightPipe_E_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fLightPipe_E_DetectorNbr[i]
<< " Energy: " << fLightPipe_Energy[i];
}
// Time
mysize = fLightPipe_T_DetectorNbr.size();
cout << "LightPipe_T_Mult: " << mysize << endl;
for (size_t i = 0 ; i < mysize ; i++){
cout << "DetNbr: " << fLightPipe_T_DetectorNbr[i]
<< " Time: " << fLightPipe_Time[i];
}
}
......@@ -24,7 +24,7 @@
// STL
#include <vector>
using namespace std;
#include <iostream>
// ROOT
#include "TObject.h"
......@@ -33,29 +33,75 @@ class TLightPipeData : public TObject {
//////////////////////////////////////////////////////////////
// data members are hold into vectors in order
// to allow multiplicity treatment
private:
// Energy
vector<UShort_t> fLightPipe_E_DetectorNbr;
vector<Double_t> fLightPipe_Energy;
// Time
vector<UShort_t> fLightPipe_T_DetectorNbr;
vector<Double_t> fLightPipe_Time;
public:
// Energy (# of photons)
// Left side
std::vector<UShort_t> fLightPipe_Left_LayerNbr;
std::vector<UShort_t> fLightPipe_Left_RowNbr;
std::vector<Double_t> fLightPipe_Left_Energy;
// Right side
std::vector<UShort_t> fLightPipe_Right_LayerNbr;
std::vector<UShort_t> fLightPipe_Right_RowNbr;
std::vector<Double_t> fLightPipe_Right_Energy;
// Top
std::vector<UShort_t> fLightPipe_Top_LayerNbr;
std::vector<UShort_t> fLightPipe_Top_RowNbr;
std::vector<Double_t> fLightPipe_Top_Energy;
// Bottom
std::vector<UShort_t> fLightPipe_Bottom_LayerNbr;
std::vector<UShort_t> fLightPipe_Bottom_RowNbr;
std::vector<Double_t> fLightPipe_Bottom_Energy;
public:
enum { Left_t, Right_t, Top_t, Bottom_t };
//////////////////////////////////////////////////////////////
// Constructor and destructor
public:
TLightPipeData();
~TLightPipeData();
public:
TLightPipeData();
~TLightPipeData();
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void Clear();
void Clear(const Option_t*) {};
void Dump() const;
public:
void Clear()
{
fLightPipe_Left_LayerNbr.clear();
fLightPipe_Left_RowNbr.clear();
fLightPipe_Left_Energy.clear();
fLightPipe_Right_LayerNbr.clear();
fLightPipe_Right_RowNbr.clear();
fLightPipe_Right_Energy.clear();
fLightPipe_Top_LayerNbr.clear();
fLightPipe_Top_RowNbr.clear();
fLightPipe_Top_Energy.clear();
fLightPipe_Bottom_LayerNbr.clear();
fLightPipe_Bottom_RowNbr.clear();
fLightPipe_Bottom_Energy.clear();
}
void Clear(const Option_t*) {};
void Dump() const
{
#if 0
// This method is very useful for debuging and worth the dev.
std::cout << "XXXXXXXXXXXXXXXXXXXXXXXX New Event [TLightPipeData::Dump()] XXXXXXXXXXXXXXXXX\n";
// Energy
size_t mysize = fLightPipe_E_DetectorNbr.size();
std::cout << "LightPipe_E_Mult: " << mysize << "\n";
for (size_t i = 0 ; i < mysize ; i++){
std::cout << "DetNbr: " << fLightPipe_E_DetectorNbr[i]
<< "RowNbr (x): " << fLightPipe_E_RowNbr[i]
<< "ColumnNbr (y): " << fLightPipe_E_ColumnNbr[i]
<< "DetNbr (z): " << fLightPipe_E_DetectorNbr[i]
<< " Energy: " << fLightPipe_Energy[i];
}
std::cout << "\n";
#endif
}
//////////////////////////////////////////////////////////////
......@@ -63,42 +109,40 @@ class TLightPipeData : public TObject {
// 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){
fLightPipe_E_DetectorNbr.push_back(DetNbr);
fLightPipe_Energy.push_back(Energy);
};//!
// Time
inline void SetTime(const UShort_t& DetNbr,const Double_t& Time) {
fLightPipe_T_DetectorNbr.push_back(DetNbr);
fLightPipe_Time.push_back(Time);
};//!
////////////////////// GETTERS ////////////////////////
// Energy
inline UShort_t GetMultEnergy() const
{return fLightPipe_E_DetectorNbr.size();}
inline UShort_t GetE_DetectorNbr(const unsigned int &i) const
{return fLightPipe_E_DetectorNbr[i];}//!
inline Double_t Get_Energy(const unsigned int &i) const
{return fLightPipe_Energy[i];}//!
// Time
inline UShort_t GetMultTime() const
{return fLightPipe_T_DetectorNbr.size();}
inline UShort_t GetT_DetectorNbr(const unsigned int &i) const
{return fLightPipe_T_DetectorNbr[i];}//!
inline Double_t Get_Time(const unsigned int &i) const
{return fLightPipe_Time[i];}//!
public:
////////////////////// SETTERS ////////////////////////
// Energy
void SetEnergy(Int_t side, UShort_t layer, UShort_t row, Double_t energy) {
switch(side) {
case Left_t:
fLightPipe_Left_LayerNbr.push_back(layer);
fLightPipe_Left_RowNbr.push_back(row);
fLightPipe_Left_Energy.push_back(energy);
break;
case Right_t:
fLightPipe_Right_LayerNbr.push_back(layer);
fLightPipe_Right_RowNbr.push_back(row);
fLightPipe_Right_Energy.push_back(energy);
break;
case Top_t:
fLightPipe_Top_LayerNbr.push_back(layer);
fLightPipe_Top_RowNbr.push_back(row);
fLightPipe_Top_Energy.push_back(energy);
break;
case Bottom_t:
fLightPipe_Bottom_LayerNbr.push_back(layer);
fLightPipe_Bottom_RowNbr.push_back(row);
fLightPipe_Bottom_Energy.push_back(energy);
break;
default:
std::cerr << "WARNING: Invalid side: " << side << " specified to TLightPipeData::SetEnergy(); nothing will be set!\n";
break;
}
};//!
//////////////////////////////////////////////////////////////
// Required for ROOT dictionnary
ClassDef(TLightPipeData,1) // LightPipeData structure
ClassDef(TLightPipeData,1); // LightPipeData structure
};
#endif
......@@ -28,6 +28,8 @@
#include <cmath>
#include <stdlib.h>
#include <limits>
#include <algorithm>
#include <iterator>
using namespace std;
// NPL
......@@ -81,19 +83,13 @@ void TLightPipePhysics::BuildSimplePhysicalEvent() {
void TLightPipePhysics::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));
}
}
}
#if 0
// copy calibrated data
copy(m_PreTreatedData->GetE_RowNbr().begin(), m_PreTreatedData->GetE_RowNbr().end(), back_inserter(RowNumber));
copy(m_PreTreatedData->GetE_ColumnNbr().begin(), m_PreTreatedData->GetE_ColumnNbr().end(), back_inserter(ColumnNumber));
copy(m_PreTreatedData->GetE_DetectorNbr().begin(), m_PreTreatedData->GetE_DetectorNbr().end(), back_inserter(DetectorNumber));
copy(m_PreTreatedData->Get_Energy().begin(), m_PreTreatedData->Get_Energy().end(), back_inserter(Energy));
#endif
}
///////////////////////////////////////////////////////////////////////////
......@@ -107,23 +103,18 @@ void TLightPipePhysics::PreTreat() {
// instantiate CalibrationManager
static CalibrationManager* Cal = CalibrationManager::getInstance();
#if 0
// 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("LightPipe/ENERGY"+NPL::itoa(m_EventData->GetE_DetectorNbr(i)),m_EventData->Get_Energy(i));
Double_t Energy = m_EventData->Get_Energy(i); // ORIGINAL:: Cal->ApplyCalibration("LightPipe/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);
m_PreTreatedData->SetEnergy(m_EventData->GetE_RowNbr(i), m_EventData->GetE_ColumnNbr(i), m_EventData->GetE_DetectorNbr(i), Energy);
}
}
}
// Time
mysize = m_EventData->GetMultTime();
for (UShort_t i = 0; i < mysize; ++i) {
Double_t Time= Cal->ApplyCalibration("LightPipe/TIME"+NPL::itoa(m_EventData->GetT_DetectorNbr(i)),m_EventData->Get_Time(i));
m_PreTreatedData->SetTime(m_EventData->GetT_DetectorNbr(i), Time);
}
#endif
}
......@@ -194,9 +185,10 @@ void TLightPipePhysics::ReadAnalysisConfig() {
///////////////////////////////////////////////////////////////////////////
void TLightPipePhysics::Clear() {
RowNumber.clear();
ColumnNumber.clear();
DetectorNumber.clear();
Energy.clear();
Time.clear();
}
......
......@@ -46,25 +46,26 @@ class TLightPipeSpectra;
class TLightPipePhysics : public TObject, public NPL::VDetector {
//////////////////////////////////////////////////////////////
// constructor and destructor
public:
TLightPipePhysics();
~TLightPipePhysics() {};
public:
TLightPipePhysics();
~TLightPipePhysics() {};
//////////////////////////////////////////////////////////////
// Inherited from TObject and overriden to avoid warnings
public:
void Clear();
void Clear(const Option_t*) {};
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;
public:
vector<int> RowNumber; // x
vector<int> ColumnNumber; // y
vector<int> DetectorNumber; // z
vector<double> Energy;
/// A usefull method to bundle all operation to add a detector
void AddDetector(TVector3 POS, string shape);
......@@ -72,109 +73,109 @@ class TLightPipePhysics : public TObject, public NPL::VDetector {
//////////////////////////////////////////////////////////////
// methods inherited from the VDetector ABC class
public:
// read stream from ConfigFile to pick-up detector parameters
void ReadConfiguration(NPL::InputParser);
public:
// read stream from ConfigFile to pick-up detector parameters
void ReadConfiguration(NPL::InputParser);
// add parameters to the CalibrationManger
void AddParameterToCalibrationManager();
// add parameters to the CalibrationManger
void AddParameterToCalibrationManager();
// method called event by event, aiming at extracting the
// physical information from detector
void BuildPhysicalEvent();
// 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 BuildPhysicalEvent() method but with a simpler
// treatment
void BuildSimplePhysicalEvent();
// same as above but for online analysis
void BuildOnlinePhysicalEvent() {BuildPhysicalEvent();};
// 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 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();
// 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();
// 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();}
// clear the raw and physical data objects event by event
void ClearEventPhysics() {Clear();}
void ClearEventData() {m_EventData->Clear();}
// methods related to the TLightPipeSpectra class
// instantiate the TLightPipeSpectra class and
// declare list of histograms
void InitSpectra();
// methods related to the TLightPipeSpectra class
// instantiate the TLightPipeSpectra class and
// declare list of histograms
void InitSpectra();
// fill the spectra
void FillSpectra();
// 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 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();
// used for Online only, clear all the spectra
void ClearSpectra();
// write spectra to ROOT output file
void WriteSpectra();
// write spectra to ROOT output file
void WriteSpectra();
//////////////////////////////////////////////////////////////
// specific methods to LightPipe array
public:
// remove bad channels, calibrate the data and apply thresholds
void PreTreat();
public:
// remove bad channels, calibrate the data and apply thresholds
void PreTreat();
// clear the pre-treated object
void ClearPreTreatedData() {m_PreTreatedData->Clear();}
// 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();
// read the user configuration file. If no file is found, load standard one
void ReadAnalysisConfig();
// give and external TLightPipeData object to TLightPipePhysics.
// needed for online analysis for example
void SetRawDataPointer(TLightPipeData* rawDataPointer) {m_EventData = rawDataPointer;}
// give and external TLightPipeData object to TLightPipePhysics.
// needed for online analysis for example
void SetRawDataPointer(TLightPipeData* rawDataPointer) {m_EventData = rawDataPointer;}
// objects are not written in the TTree
private:
TLightPipeData* m_EventData; //!
TLightPipeData* m_PreTreatedData; //!
TLightPipePhysics* m_EventPhysics; //!
private:
TLightPipeData* m_EventData; //!
TLightPipeData* m_PreTreatedData; //!
TLightPipePhysics* m_EventPhysics; //!
// getters for raw and pre-treated data object
public:
TLightPipeData* GetRawData() const {return m_EventData;}
TLightPipeData* GetPreTreatedData() const {return m_PreTreatedData;}
public:
TLightPipeData* GetRawData() const {return m_EventData;}
TLightPipeData* GetPreTreatedData() const {return m_PreTreatedData;}
// parameters used in the analysis
private:
// thresholds
double m_E_RAW_Threshold; //!
double m_E_Threshold; //!
private:
// thresholds
double m_E_RAW_Threshold; //!
double m_E_Threshold; //!
// number of detectors
private:
int m_NumberOfDetectors; //!
private:
int m_NumberOfDetectors; //!
// spectra class
private:
TLightPipeSpectra* m_Spectra; // !
private:
TLightPipeSpectra* m_Spectra; // !
// spectra getter
public:
map<string, TH1*> GetSpectra();
public:
map<string, TH1*> GetSpectra();
// Static constructor to be passed to the Detector Factory
public:
static NPL::VDetector* Construct();
public:
static NPL::VDetector* Construct();
ClassDef(TLightPipePhysics,1) // LightPipePhysics structure
ClassDef(TLightPipePhysics,1) // LightPipePhysics structure
};
#endif
......@@ -108,67 +108,67 @@ void TLightPipeSpectra::InitPhysicsSpectra() {
////////////////////////////////////////////////////////////////////////////////
void TLightPipeSpectra::FillRawSpectra(TLightPipeData* RawData) {
static string name;
static string family;
// Energy
unsigned int sizeE = RawData->GetMultEnergy();
for (unsigned int i = 0; i < sizeE; i++) {
name = "LightPipe"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW";
family = "LightPipe/RAW";
FillSpectra(family,name,RawData->Get_Energy(i));
}
// Time
unsigned int sizeT = RawData->GetMultTime();
for (unsigned int i = 0; i < sizeT; i++) {
name = "LightPipe"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW";
family = "LightPipe/RAW";
FillSpectra(family,name,RawData->Get_Time(i));
}
// static string name;
// static string family;
// // Energy
// unsigned int sizeE = RawData->GetMultEnergy();
// for (unsigned int i = 0; i < sizeE; i++) {
// name = "LightPipe"+NPL::itoa(RawData->GetE_DetectorNbr(i))+"_ENERGY_RAW";
// family = "LightPipe/RAW";
// FillSpectra(family,name,RawData->Get_Energy(i));
// }
// // Time
// unsigned int sizeT = RawData->GetMultTime();
// for (unsigned int i = 0; i < sizeT; i++) {
// name = "LightPipe"+NPL::itoa(RawData->GetT_DetectorNbr(i))+"_TIME_RAW";
// family = "LightPipe/RAW";
// FillSpectra(family,name,RawData->Get_Time(i));
// }
}
////////////////////////////////////////////////////////////////////////////////
void TLightPipeSpectra::FillPreTreatedSpectra(TLightPipeData* PreTreatedData) {
static string name;
static string family;
// static string name;
// static string family;
// Energy
unsigned int sizeE = PreTreatedData->GetMultEnergy();
for (unsigned int i = 0; i < sizeE; i++) {
name = "LightPipe"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL";
family = "LightPipe/CAL";
FillSpectra(family,name,PreTreatedData->Get_Energy(i));
}
// Time
unsigned int sizeT = PreTreatedData->GetMultTime();
for (unsigned int i = 0; i < sizeT; i++) {
name = "LightPipe"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL";
family = "LightPipe/CAL";
FillSpectra(family,name,PreTreatedData->Get_Time(i));
}
// // Energy
// unsigned int sizeE = PreTreatedData->GetMultEnergy();
// for (unsigned int i = 0; i < sizeE; i++) {
// name = "LightPipe"+NPL::itoa(PreTreatedData->GetE_DetectorNbr(i))+"_ENERGY_CAL";
// family = "LightPipe/CAL";
// FillSpectra(family,name,PreTreatedData->Get_Energy(i));
// }
// // Time
// unsigned int sizeT = PreTreatedData->GetMultTime();
// for (unsigned int i = 0; i < sizeT; i++) {
// name = "LightPipe"+NPL::itoa(PreTreatedData->GetT_DetectorNbr(i))+"_TIME_CAL";
// family = "LightPipe/CAL";
// FillSpectra(family,name,PreTreatedData->Get_Time(i));
// }