Skip to content
Snippets Groups Projects
Commit 784e5e79 authored by de Séréville Nicolas's avatar de Séréville Nicolas
Browse files

+ Add spectra support for LaBr3

parent 07fc45ef
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ all: $(SHARELIB)
############### Detector ##############
## LaBr3 ##
libLaBr3.so: TLaBr3Data.o TLaBr3DataDict.o TLaBr3Physics.o TLaBr3PhysicsDict.o
libLaBr3.so: TLaBr3Data.o TLaBr3DataDict.o TLaBr3Physics.o TLaBr3PhysicsDict.o TLaBr3Spectra.o
$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
TLaBr3DataDict.cxx: TLaBr3Data.h
......@@ -20,6 +20,7 @@ TLaBr3PhysicsDict.cxx: TLaBr3Physics.h
# dependances
TLaBr3Data.o: TLaBr3Data.cxx TLaBr3Data.h
TLaBr3Physics.o: TLaBr3Physics.cxx TLaBr3Physics.h
TLaBr3Spectra.o: TLaBr3Spectra.cxx TLaBr3Spectra.h
#######################################
############# Clean and More ##########
......
......@@ -45,13 +45,13 @@ class TLaBr3Data : public TObject {
///////////////////// GETTERS ////////////////////////
// Energy
int GetEnergyMult() {return fLaBr3_E_Number.size();}
int GetENumber(int i) {return fLaBr3_E_Number[i];}
double GetEEnergy(int i) {return fLaBr3_E_Energy[i];}
unsigned int GetEnergyMult() {return fLaBr3_E_Number.size();}
int GetENumber(int i) {return fLaBr3_E_Number[i];}
double GetEEnergy(int i) {return fLaBr3_E_Energy[i];}
// Time
int GetTimeMult() {return fLaBr3_T_Number.size();}
int GetTNumber(int i) {return fLaBr3_T_Number[i];}
double GetTTime(int i) {return fLaBr3_T_Time[i];}
unsigned int GetTimeMult() {return fLaBr3_T_Number.size();}
int GetTNumber(int i) {return fLaBr3_T_Number[i];}
double GetTTime(int i) {return fLaBr3_T_Time[i];}
///////////////////// SETTERS ////////////////////////
// Energy
......
/*****************************************************************************
* Copyright (C) 2009-2013 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr *
* *
* Creation Date : dec 2013 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class holds all the online spectra needed for LaBr3 *
* *
*---------------------------------------------------------------------------*
* Comment: *
* + first version (not complete yet) *
* *
* *
*****************************************************************************/
// STL
#include <iostream>
#include <cstdlib>
#include <stdexcept>
// NPL
#include "TLaBr3Spectra.h"
#include "NPOptionManager.h"
#include "NPGlobalSystemOfUnits.h"
#include "NPPhysicalConstants.h"
#ifdef NP_SYSTEM_OF_UNITS_H
using namespace NPUNITS;
#endif
// ROOT
#include "string.h"
#include "TDirectory.h"
#include "TFile.h"
////////////////////////////////////////////////////////////////////////////////
TLaBr3Spectra::TLaBr3Spectra()
{
fNumberDetector = 0;
}
////////////////////////////////////////////////////////////////////////////////
TLaBr3Spectra::TLaBr3Spectra(unsigned int NumberOfDetectors)
{
if(NPOptionManager::getInstance()->GetVerboseLevel()>0)
cout << "************************************************" << endl
<< "TLaBr3Spectra : Initalising control spectra for "
<< NumberOfDetectors << " detectorss" << endl
<< "************************************************" << endl ;
fNumberDetector = NumberOfDetectors;
InitRawSpectra();
InitPreTreatedSpectra();
InitPhysicsSpectra();
}
////////////////////////////////////////////////////////////////////////////////
TLaBr3Spectra::~TLaBr3Spectra(){
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::InitRawSpectra()
{
string name;
int NbrBin = 512;
int MinBin = 0;
int MaxBin = 16384;
for (unsigned int i = 0; i < fNumberDetector; i++) { // loop on number of detectors
// LABR3_E_RAW
name = Form("LABR3_%d_E_RAW", i+1);
AddHisto1D(name, name, NbrBin, MinBin, MaxBin, "LABR3/RAW/ENERGY");
// LABR3_T_RAW
name = Form("LABR3_%d_T_RAW", i+1);
AddHisto1D(name, name, NbrBin, MinBin, MaxBin, "LABR3/RAW/TIME");
} // end loop on number of detectors
// LABR3_E_RAW
name = "LABR3_E_RAW";
AddHisto2D(name, name, fNumberDetector, 1, fNumberDetector+1, NbrBin, MinBin, MaxBin, "LABR3/RAW/ENERGY");
// LABR3_T_RAW
name = "LABR3_T_RAW";
AddHisto2D(name, name, fNumberDetector, 1, fNumberDetector+1, NbrBin, MinBin, MaxBin, "LABR3/RAW/TIME");
// LABR3_HIT_E_RAW
name = "LABR3_HITPATTERN_E_RAW";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/RAW/ENERGY");
// LABR3_HIT_T_RAW
name = "LABR3_HITPATTERN_T_RAW";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/RAW/TIME");
// E_RAW_MULT
name = "LABR3_E_RAW_MULT";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/RAW/MULT");
// T_RAW_MULT
name = "LABR3_T_RAW_MULT";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/RAW/MULT");
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::InitPreTreatedSpectra()
{
string name;
int NbrBin = 512;
int MinBinE = 0;
int MaxBinE = 10; // MeV
int MinBinT = 0;
int MaxBinT = 1; // us
for (unsigned int i = 0; i < fNumberDetector; i++) { // loop on number of detectors
// LABR3_E_CAL
name = Form("LABR3_%d_E_CAL", i+1);
AddHisto1D(name, name, NbrBin, MinBinE, MaxBinE, "LABR3/CAL/ENERGY");
// LABR3_T_CAL
name = Form("LABR3_%d_T_CAL", i+1);
AddHisto1D(name, name, NbrBin, MinBinT, MaxBinT, "LABR3/CAL/TIME");
} // end loop on number of detectors
// LABR3_E_CAL
name = "LABR3_ESUM_CAL";
AddHisto1D(name, name, NbrBin, MinBinE, MaxBinE, "LABR3/CAL/ENERGY");
// LABR3_E_CAL
name = "LABR3_E_CAL";
AddHisto2D(name, name, fNumberDetector, 1, fNumberDetector+1, NbrBin, MinBinE, MaxBinE, "LABR3/CAL/ENERGY");
// LABR3_T_CAL
name = "LABR3_T_CAL";
AddHisto2D(name, name, fNumberDetector, 1, fNumberDetector+1, NbrBin, MinBinT, MaxBinT, "LABR3/CAL/TIME");
// LABR3_HIT_E_CAL
name = "LABR3_HITPATTERN_E_CAL";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/CAL/ENERGY");
// LABR3_HIT_T_CAL
name = "LABR3_HITPATTERN_T_CAL";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/CAL/TIME");
// E_CAL_MULT
name = "LABR3_E_CAL_MULT";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/CAL/MULT");
// T_CAL_MULT
name = "LABR3_T_CAL_MULT";
AddHisto1D(name, name, fNumberDetector, 1, fNumberDetector+1, "LABR3/CAL/MULT");
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::InitPhysicsSpectra()
{
string name;
int NbrBin = 512;
int MinBinE = 0;
int MaxBinE = 10;
int MinBinT = 0;
int MaxBinT = 1;
// Energy-Time Correlation
for (unsigned int i = 0 ; i < fNumberDetector ; i++) { // loop on number of detectors
name = Form("LABR3_%d_E_TOF", i+1);
AddHisto2D(name, name, NbrBin, MinBinE, MaxBinE, NbrBin, MinBinT, MaxBinT, "LABR3/PHY");
}
// E-TOF:
name = "LABR3_E_TOF";
AddHisto2D(name, name, NbrBin, MinBinE, MaxBinE, NbrBin, MinBinT, MaxBinT, "LABR3/PHY");
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::FillRawSpectra(TLaBr3Data* RawData)
{
string name;
string family;
// E_RAW
for (unsigned int i = 0; i < RawData->GetEnergyMult(); i++) {
name = Form("LABR3_%d_E_RAW", RawData->GetENumber(i));
family = "LABR3/RAW/ENERGY";
GetHisto(family,name) -> Fill(RawData->GetEEnergy(i));
}
// T_RAW
for (unsigned int i = 0; i < RawData->GetTimeMult(); i++) {
name = Form("LABR3_%d_T_RAW", RawData->GetTNumber(i));
family = "LABR3/RAW/TIME";
GetHisto(family,name) -> Fill(RawData->GetTTime(i));
}
// LABR3_E_RAW
name = "LABR3_E_RAW";
family = "LABR3/RAW/ENERGY";
for (unsigned int i = 0; i < RawData->GetEnergyMult(); i++) {
GetHisto(family,name) -> Fill(RawData->GetENumber(i), RawData->GetEEnergy(i));
}
// LABR3_T_RAW
name = "LABR3_T_RAW";
family = "LABR3/RAW/TIME";
for (unsigned int i = 0; i < RawData->GetTimeMult(); i++) {
GetHisto(family,name) -> Fill(RawData->GetTNumber(i), RawData->GetTTime(i));
}
// LABR3_HIT_E_RAW
name = "LABR3_HITPATTERN_E_RAW";
family = "LABR3/RAW/ENERGY";
for (unsigned int i = 0; i < RawData->GetEnergyMult(); i++) {
GetHisto(family,name) -> Fill(RawData->GetENumber(i));
}
// LABR3_HIT_T_RAW
name = "LABR3_HITPATTERN_T_RAW";
family = "LABR3/RAW/TIME";
for (unsigned int i = 0; i < RawData->GetTimeMult(); i++) {
GetHisto(family,name) -> Fill(RawData->GetTNumber(i));
}
// E_RAW_MULT
name = "LABR3_E_RAW_MULT";
family = "LABR3/RAW/MULT";
GetHisto(family,name) -> Fill(RawData->GetEnergyMult());
// T_RAW_MULT
name = "LABR3_T_RAW_MULT";
family = "LABR3/RAW/MULT";
GetHisto(family,name) -> Fill(RawData->GetTimeMult());
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::FillPreTreatedSpectra(TLaBr3Data* PreTreatedData)
{
string name;
string family;
// E_CAL
for (unsigned int i = 0; i < PreTreatedData->GetEnergyMult(); i++) {
name = Form("LABR3_%d_E_CAL", PreTreatedData->GetENumber(i));
family = "LABR3/CAL/ENERGY";
GetHisto(family,name) -> Fill(PreTreatedData->GetEEnergy(i));
}
// T_CAL
for (unsigned int i = 0; i < PreTreatedData->GetTimeMult(); i++) {
name = Form("LABR3_%d_T_CAL", PreTreatedData->GetTNumber(i));
family = "LABR3/CAL/TIME";
GetHisto(family,name) -> Fill(PreTreatedData->GetTTime(i));
}
// LABR3_E_CAL
name = "LABR3_E_CAL";
family = "LABR3/CAL/ENERGY";
for (unsigned int i = 0; i < PreTreatedData->GetEnergyMult(); i++) {
GetHisto(family,name) -> Fill(PreTreatedData->GetENumber(i), PreTreatedData->GetEEnergy(i));
}
// LABR3_T_CAL
name = "LABR3_T_CAL";
family = "LABR3/CAL/TIME";
for (unsigned int i = 0; i < PreTreatedData->GetTimeMult(); i++) {
GetHisto(family,name) -> Fill(PreTreatedData->GetTNumber(i), PreTreatedData->GetTTime(i));
}
// LABR3_HIT_E_CAL
name = "LABR3_HITPATTERN_E_CAL";
family = "LABR3/CAL/ENERGY";
for (unsigned int i = 0; i < PreTreatedData->GetEnergyMult(); i++) {
GetHisto(family,name) -> Fill(PreTreatedData->GetENumber(i));
}
// LABR3_HIT_T_CAL
name = "LABR3_HITPATTERN_T_CAL";
family = "LABR3/CAL/TIME";
for (unsigned int i = 0; i < PreTreatedData->GetTimeMult(); i++) {
GetHisto(family,name) -> Fill(PreTreatedData->GetTNumber(i));
}
// E_CAL_MULT
name = "LABR3_E_CAL_MULT";
family = "LABR3/CAL/MULT";
GetHisto(family,name) -> Fill(PreTreatedData->GetEnergyMult());
// T_CAL_MULT
name = "LABR3_T_CAL_MULT";
family = "LABR3/CAL/MULT";
GetHisto(family,name) -> Fill(PreTreatedData->GetTimeMult());
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::FillPhysicsSpectra(TLaBr3Physics* Physics)
{
}
////////////////////////////////////////////////////////////////////////////////
TH1* TLaBr3Spectra::AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family){
// create histo
TH1 *hist = new TH1D(name.c_str(), title.c_str(), nbinsx, xlow, xup);
vector<string> index ;
index.push_back(family);
index.push_back(name);
// fill map
fMapHisto[index]=hist;
return hist;
}
////////////////////////////////////////////////////////////////////////////////
TH1* TLaBr3Spectra::AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, string family){
// create histo
TH1 *hist = new TH2D(name.c_str(), title.c_str(), nbinsx, xlow, xup, nbinsy, ylow, yup);
vector<string> index ;
index.push_back(family);
index.push_back(name);
// fill map
fMapHisto[index]=hist;
return hist;
}
////////////////////////////////////////////////////////////////////////////////
TH1* TLaBr3Spectra::GetHisto(string& family, string& name){
vector<string> index;
index.push_back(family);
index.push_back(name);
TH1* histo ;
try{
histo = fMapHisto.at(index);
}
catch(const std::out_of_range& oor){
cout << "ERROR : the folowing Histo has been requested by TLaBr3Spectra and does not exist: family:" << family << " name: " << name << endl ;
exit(1);
}
return histo;
}
////////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::WriteHisto(string filename)
{
TFile *f = NULL;
if (filename != "VOID") {
f = new TFile(filename.c_str(), "RECREATE");
}
map< vector<string>, TH1* >::iterator it;
for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it) {
it->second->Write();
}
if (filename != "VOID") {
f->Close();
delete f;
}
}
///////////////////////////////////////////////////////////////////////////////
void TLaBr3Spectra::CheckSpectra()
{
map< vector<string>, TH1* >::iterator it;
Color_t ok_color = kTeal+9;
Color_t warning_color = kOrange+8; warning_color *= 1;
Color_t bad_color = kRed; bad_color *= 1;
for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it)
{
it->second->SetLineColor(ok_color);
it->second->SetFillStyle(1001);
it->second->SetFillColor(ok_color);
}
}
#ifndef TCHARISSASPECTRA_H
#define TCHARISSASPECTRA_H
/*****************************************************************************
* Copyright (C) 2009-2013 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: N. de Sereville contact address: deserevi@ipno.in2p3.fr *
* *
* Creation Date : dec 2013 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class holds all the online spectra needed for LaBr3 *
* *
*---------------------------------------------------------------------------*
* Comment: *
* + first version (not complete yet) *
* *
* *
*****************************************************************************/
// C++ STL headers
#include <map>
// ROOT headers
#include "TObject.h"
#include <TH1.h>
#include <TH2.h>
// NPLib headers
#include "TLaBr3Data.h"
#include "TLaBr3Physics.h"
using namespace std;
// ForwardDeclaration
class TLaBr3Physics;
class TLaBr3Spectra {
public:
// constructor and destructor
TLaBr3Spectra();
TLaBr3Spectra(unsigned int NumberOfTelescope);
~TLaBr3Spectra();
private:
// Instantiate and register histo to maps
TH1* AddHisto1D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup, string family);
TH1* AddHisto2D(string name, string title, Int_t nbinsx, Double_t xlow, Double_t xup,
Int_t nbinsy, Double_t ylow, Double_t yup, string family);
// Initialization methods
void InitRawSpectra();
void InitPreTreatedSpectra();
void InitPhysicsSpectra();
public:
// Filling methods
void FillRawSpectra(TLaBr3Data*);
void FillPreTreatedSpectra(TLaBr3Data*);
void FillPhysicsSpectra(TLaBr3Physics*);
// Check the Spectra
void CheckSpectra();
public:
// get map histo which will be used for GSpectra in GUser
map< vector<string>, TH1* > GetMapHisto() const {return fMapHisto;}
TH1* GetHisto(string& family,string& name);
void WriteHisto(string filename="VOID");
private: // Information on CHARISSA
unsigned int fNumberDetector;
private:
// map holding histo pointers and their family names
map< vector<string>, TH1* > fMapHisto;
};
#endif
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