Skip to content
Snippets Groups Projects
Commit 66f037e6 authored by e628's avatar e628
Browse files

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

Merge branch 'NPTool.dev.prerelease' of https://github.com/adrien-matta/nptool into NPTool.dev.prerelease
parents caaaaeee 2aaa7237
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ all: $(SHARELIB)
############### Detector ##############
## EXOGAM ##
libExogam.so: TExogamData.o TExogamDataDict.o TExogamPhysics.o TExogamPhysicsDict.o
libExogam.so: TExogamData.o TExogamDataDict.o TExogamPhysics.o TExogamPhysicsDict.o TExogamSpectra.o
$(LD) $(SOFLAGS) $^ $(OutPutOpt) $@
TExogamDataDict.cxx: TExogamData.h
......@@ -20,6 +20,7 @@ TExogamPhysicsDict.cxx: TExogamPhysics.h
# dependances
TExogamData.o: TExogamData.cxx TExogamData.h
TExogamPhysics.o: TExogamPhysics.cxx TExogamPhysics.h
TExogamSpectra.o: TExogamSpectra.cxx TExogamSpectra.h
#######################################
############# Clean and More ##########
......
......@@ -25,7 +25,7 @@
// STL
#include <vector>
using namespace std;
#include "TObject.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 : march 2011 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class holds all the online spectra needed for Exogam *
* *
*---------------------------------------------------------------------------*
* Comment: *
* + first version (not complete yet) *
* *
* *
*****************************************************************************/
// NPL
#include "TExogamSpectra.h"
#include "NPOptionManager.h"
#include "NPGlobalSystemOfUnits.h"
#include "NPPhysicalConstants.h"
#ifdef NP_SYSTEM_OF_UNITS_H
using namespace NPUNITS;
#endif
// ROOT
#include "TString.h"
#include "TDirectory.h"
#include "TFile.h"
////////////////////////////////////////////////////////////////////////////////
TExogamSpectra::TExogamSpectra(){
fNumberOfClover = 0;
fnbinsRaw=16384;
fbinRawMin=0;
fbinRawMax=16384;
fnbinsCal=5000;
fbinCalMin=0;
fbinCalMax=5000;
}
////////////////////////////////////////////////////////////////////////////////
TExogamSpectra::TExogamSpectra(unsigned int NumberOfClover){
if(NPOptionManager::getInstance()->GetVerboseLevel()>0)
cout << "************************************************" << endl
<< "TExogamSpectra : Initalising control spectra for "
<< NumberOfClover << " Clover" << endl
<< "************************************************" << endl ;
fNumberOfClover = NumberOfClover;
fNumberOfSegments=16;
fNumberOfCores=4;
InitRawSpectra();
InitPreTreatedSpectra();
InitPhysicsSpectra();
}
////////////////////////////////////////////////////////////////////////////////
TExogamSpectra::~TExogamSpectra(){
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::InitRawSpectra(){
TString name;
for (unsigned int i = 0; i < fNumberOfClover; i++) { // loop on number of detectors
for (unsigned int j = 0; j < fNumberOfCores; j++) { // loop on number of cores
name = Form("ExogamEnergyRaw_Clover%d_ECC%d", i+1, j+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/RAW");
name = Form("ExogamTimeRaw_Clover%d_ECC%d", i+1, j+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/RAW");
for (unsigned int k = 0; k < fNumberOfSegments; k++) { // loop on number of segments
name = Form("ExogamEnergyRaw_Clover%d_ECC%d_GOCCE%d", i+1, j+1, k+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/RAW");
name = Form("ExogamEnergyDC_Clover%d_ECC%d_GOCCE%d", i+1, j+1, k+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/RAW");
}
}
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::InitPreTreatedSpectra()
{
TString name;
for (unsigned int i = 0; i < fNumberOfClover; i++) { // loop on number of detectors
for (unsigned int j = 0; j < fNumberOfCores; j++) { // loop on number of cores
name = Form("ExogamEnergyCal_Clover%d_ECC%d", i+1, j+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/Cal");
name = Form("ExogamTimeCal_Clover%d_ECC%d", i+1, j+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/Cal");
for (unsigned int k = 0; k < fNumberOfSegments; k++) { // loop on number of segments
name = Form("ExogamEnergyCal_Clover%d_ECC%d_GOCCE%d", i+1, j+1, k+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/Cal");
name = Form("ExogamTimeCal_Clover%d_ECC%d_GOCCE%d", i+1, j+1, k+1);
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/Cal");
}
}
} // end loop on number of detectors
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::InitPhysicsSpectra(){
TString name;
name = "ExogamEnergyAddBack";
AddHisto1D(name, name, fnbinsRaw, fbinRawMin, fbinRawMax, "Exogam/DC");
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::FillRawSpectra(TExogamData* RawData){
TString name;
TString family;
// Energy and Time RAw
for (unsigned int i = 0; i < RawData->GetECCEMult(); i++) {
name = Form("ExogamEnergyRaw_Clover%d_ECC%d", RawData->GetECCEClover(i)+1,RawData->GetECCECristal(i)+1);
family = "Exogam/RAW";
GetHisto(family,name)
-> Fill(RawData->GetECCEEnergy(i));
name = Form("ExogamTimeRaw_Clover%d_ECC%d", RawData->GetECCTClover(i)+1,RawData->GetECCTCristal(i)+1);
family = "Exogam/RAW";
GetHisto(family,name)
-> Fill(RawData->GetECCTTime(i));
name = Form("ExogamEnergyRaw_Clover%d_ECC%d_GOCCE%d", RawData->GetECCEClover(i)+1,RawData->GetECCECristal(i)+1,RawData->GetGOCCEESegment(i)+1);
family = "Exogam/RAW";
GetHisto(family,name)
-> Fill(RawData->GetGOCCEEEnergy(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::FillPreTreatedSpectra(TExogamData* PreTreatedData){
TString name ;
TString family;
// Energy and Time RAw
for (unsigned int i = 0; i < PreTreatedData->GetECCEMult(); i++) {
name = Form("ExogamEnergyCal_Clover%d_ECC%d", PreTreatedData->GetECCEClover(i)+1,PreTreatedData->GetECCECristal(i)+1);
family = "Exogam/Cal";
GetHisto(family,name)
-> Fill(PreTreatedData->GetECCEEnergy(i));
name = Form("ExogamTimeCal_Clover%d_ECC%d", PreTreatedData->GetECCTClover(i)+1,PreTreatedData->GetECCTCristal(i)+1);
family = "Exogam/Cal";
GetHisto(family,name)
-> Fill(PreTreatedData->GetECCTTime(i));
name = Form("ExogamEnergyCal_Clover%d_ECC%d_GOCCE%d", PreTreatedData->GetECCEClover(i)+1,PreTreatedData->GetECCECristal(i)+1,PreTreatedData->GetGOCCEESegment(i)+1);
family = "Exogam/Cal";
GetHisto(family,name)
-> Fill(PreTreatedData->GetGOCCEEEnergy(i));
}
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::FillPhysicsSpectra(TExogamPhysics* Physics){
TString name;
TString family= "Exogam/PHY";
// Doppler Correct and Add Back
name = "ExogamEnergyAddBack";
family = "Exogam/DC";
for (unsigned int i = 0; i < Physics->DopplerCorrectedEnergy.size(); i++) {
GetHisto(family,name)
-> Fill(Physics->DopplerCorrectedEnergy[i]);
}
}
////////////////////////////////////////////////////////////////////////////////
TH1* TExogamSpectra::AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family){
// create histo
TH1 *hist = new TH1D(name, title, nbinsx, xlow, xup);
vector<TString> index ;
index.push_back(family);
index.push_back(name);
// fill map
fMapHisto[index]=hist;
return hist;
}
////////////////////////////////////////////////////////////////////////////////
TH1* TExogamSpectra::AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, Int_t nbinsy, Double_t ylow, Double_t yup, TString family){
// create histo
TH1 *hist = new TH2D(name, title, nbinsx, xlow, xup, nbinsy, ylow, yup);
vector<TString> index ;
index.push_back(family);
index.push_back(name);
// fill map
fMapHisto[index]=hist;
return hist;
}
////////////////////////////////////////////////////////////////////////////////
TH1* TExogamSpectra::GetHisto(TString family, TString name){
vector<TString> index ;
index.push_back(family);
index.push_back(name);
// fill map
return fMapHisto.at(index);
}
////////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::WriteHisto(TString filename){
TFile* f=NULL;
if(filename!="VOID"){
f = new TFile(filename,"RECREATE");
}
map< vector<TString>, TH1* >::iterator it;
for (it=fMapHisto.begin(); it!=fMapHisto.end(); ++it){
it->second->Write();
}
if(filename!="VOID"){
f->Close();
delete f;
}
}
///////////////////////////////////////////////////////////////////////////////
void TExogamSpectra::CheckSpectra(){
map< vector<TString>, 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 TEXOGAMSPECTRA_H
#define TEXOGAMSPECTRA_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 : march 2011 *
* Last update : *
*---------------------------------------------------------------------------*
* Decription: *
* This class holds all the online spectra needed for Exogam *
* *
*---------------------------------------------------------------------------*
* Comment: *
* + first version (not complete yet) *
* *
* *
*****************************************************************************/
// C++ STL headers
#include <map>
// ROOT headers
#include "TObject.h"
#include <TH1.h>
#include <TH2.h>
#include <TString.h>
// NPLib headers
#include "TExogamData.h"
#include "TExogamPhysics.h"
using namespace std;
// ForwardDeclaration
class TExogamPhysics ;
class TExogamSpectra {
public:
// constructor and destructor
TExogamSpectra();
TExogamSpectra(unsigned int NumberOfClover);
~TExogamSpectra();
private:
// Instantiate and register histo to maps
TH1* AddHisto1D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup, TString family);
TH1* AddHisto2D(TString name, TString title, Int_t nbinsx, Double_t xlow, Double_t xup,
Int_t nbinsy, Double_t ylow, Double_t yup,TString family);
// Initialization methods
void InitRawSpectra();
void InitPreTreatedSpectra();
void InitPhysicsSpectra();
public:
// Filling methods
void FillRawSpectra(TExogamData*);
void FillPreTreatedSpectra(TExogamData*);
void FillPhysicsSpectra(TExogamPhysics*);
// Check the Spectra
void CheckSpectra();
public:
// get map histo which will be used for GSpectra in GUser
map< vector<TString>, TH1* > GetMapHisto() const {return fMapHisto;}
TH1* GetHisto(TString family,TString name);
void WriteHisto(TString filename="VOID");
private: // Information on Exogam
unsigned int fNumberOfClover ;
unsigned int fnbinsRaw;
unsigned int fbinRawMin;
unsigned int fbinRawMax;
unsigned int fnbinsCal;
unsigned int fbinCalMin;
unsigned int fbinCalMax;
unsigned int fNumberOfSegments;
unsigned int fNumberOfCores;
private:
// map holding histo pointers and their family names
map< vector<TString>, 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