...
 
Commits (20)
*~
# Ignore compiled files
*.o
*.out
*.d
*.so
#Ignore files automatically build by ROOT
*.pcm
*Dict.cpp
# Ignore log files
*.log
# Ignore build directories
build/
# Ignore data and calibration files
*.root
*.cal
#Ignore VS code stuff
.vscode/
# config.ini
\ No newline at end of file
/*
* AculCalParameters.cpp
*
* Created on: Oct 20, 2016
* Author: vratik
*/
#include "AculCalPars.h"
AculCalPars::AculCalPars() {
// TODO Auto-generated constructor stub
Reset();
}
AculCalPars::AculCalPars(const char* parFile) {
// TODO Auto-generated constructor stub
SetParFile(parFile);
Init();
}
AculCalPars::~AculCalPars() {
// TODO Auto-generated destructor stub
}
void AculCalPars::Init() {
SetPars();
}
void AculCalPars::SetParFile(const char* parfile) {
fParFileName = parfile;
return;
}
void AculCalPars::Reset() {
fParFileName = "";
fEtab.clear();
}
/*
* AculCalParameters.h
*
* Created on: Oct 20, 2016
* Author: vratik
*/
#ifndef ACULCALIB_ACULCALPARS_H_
#define ACULCALIB_ACULCALPARS_H_
#include <iostream>
#include <fstream>
#include <vector>
#include "TString.h"
#include "TArrayD.h"
#include "TArrayI.h"
#include "TCutG.h"
using std::cout;
using std::cerr;
using std::endl;
using std::vector;
class AculCalPars {
protected:
//general
TString fParFileName;
vector<Double_t> fEtab; //energy which will be used for calibration
//todo energies used for calibration should be in this class
public:
AculCalPars();
AculCalPars(const char* parFile);
virtual ~AculCalPars();
ClassDef(AculCalPars,1);
virtual void Init();
//getters
const char* GetParFileName() {return fParFileName.Data();}
// Int_t GetNoCrystals() {return fNoCrystals;}
virtual const char* GetDetName() {return 0;}
virtual const char* GetParticleName() {return 0;}
virtual Int_t GetNoRawFiles() {return 0;};
virtual const char* GetFileName(Int_t i) {return 0;};
virtual Int_t GetNoEPoints() {return 0;}
virtual Double_t GetCalEnergy(Int_t i) {return 0.;};
//todo check functions with cuts
// virtual const char* GetCutsFileName() {return 0;}
// virtual Int_t GetNoCuts() {return 0;}
// virtual TCutG* GetCut(Int_t i) {return 0;};
virtual TCutG* GetCut(const char* cutName, Int_t treeID = 0) {return 0;};
virtual Int_t GetMinChannel(Int_t energy, Int_t crystal) {return 0;};
virtual Int_t GetMaxChannel(Int_t energy, Int_t crystal) {return 0;};
void SetParFileName(const char* parFile) {fParFileName = parFile;}
void SetParFile(const char* parfile);
virtual void PrintParameters(const char* option = "") {};
virtual void Reset();
protected:
virtual void SetPars() {};
};
#endif /* ACULCALIB_ACULCALPARS_H_ */
/*
* AculCalParsScint.cpp
*
* Created on: Oct 21, 2016
* Author: vratik
*/
#include "AculCalParsScint.h"
#include "TFile.h"
AculCalParsScint::AculCalParsScint() {
// TODO Auto-generated constructor stub
Reset();
}
AculCalParsScint::AculCalParsScint(const char* parFile) {
// TODO Auto-generated constructor stub
SetParFile(parFile);
Init();
}
AculCalParsScint::~AculCalParsScint() {
// TODO Auto-generated destructor stub
}
void AculCalParsScint::Init() {
SetPars();
// LoadCuts();
}
void AculCalParsScint::SetPars() {
std::ifstream infile(fParFileName.Data());
if ( !infile.is_open() ) {
printf("AculCalParsScint::ReadParFile: File %s was not open and parameters were not set.\n", fParFileName.Data());
Reset();
return;
}
fEnergyPoints = 0;
TString line;
TString word;
Int_t i, min, max;
Int_t lineLength = 400;
Char_t det[lineLength];
Char_t part[lineLength];
Char_t fname[lineLength];
Char_t cname[lineLength];
double en; //energy
while (!infile.eof()) {
line.ReadLine(infile);
if ( line.BeginsWith("#") || line.BeginsWith("//") ) continue;
if ( line.BeginsWith("energies") ) {
sscanf(line.Data(), "%*s %d", &i);
continue;
}
if ( line.BeginsWith("crystals") ) {
sscanf(line.Data(), "%*s %d", &i);
fNoCrystals = i;
continue;
}
if ( line.BeginsWith("files") ) {
sscanf(line.Data(), "%*s %d", &i);
fNoFiles = i;
fFilePars.resize(fNoFiles);
for (Int_t j = 0; j < fNoFiles; j++) {
line.ReadLine(infile);
if ( line.BeginsWith("#") || line.BeginsWith("//") ) {
j--;
continue;
}
sscanf(line, "%s", fname);
word = fname;
fFilePars[j].SetRawFileName(fname);
fFilePars[j].SetNoCrystals(fNoCrystals);
fFilePars[j].Init();
}
continue;
}
/*if ( line.BeginsWith("cutFile") ) {
sscanf(line.Data(), "%*s %s %d", fname, &fNoCuts);
fCutsFileName = fname;
for (Int_t j = 0; j < fNoCuts; j++) {
line.ReadLine(infile);
if ( line.BeginsWith("#") || line.BeginsWith("//") ) {
j--;
continue;
}
sscanf(line, "%s", cname);
fCutName.push_back(cname);
}
continue;
}*/
if ( line.BeginsWith("detector") ) {
sscanf(line.Data(), "%*s %s %s", det, part);
fDetName = det;
fPartName = part;
continue;
}
if ( line.BeginsWith("energy") ) {
sscanf(line.Data(), "%*s %lf", &en);
fFilePars[fEnergyPoints].SetEnergy(en);
do {line.ReadLine(infile);}
while (line.BeginsWith("#") || line.BeginsWith("//"));
if ( line.BeginsWith("cutFile") ) {
Int_t noCuts;
// sscanf(line.Data(), "%*s %s %d", fname, &fNoCuts);
sscanf(line.Data(), "%*s %s %d", fname, &noCuts);
fFilePars[fEnergyPoints].SetNoCuts(noCuts);
fFilePars[fEnergyPoints].SetCutFileName(fname);
// cout << line << endl;
// cout << noCuts << endl;
// fCutsFileName = fname;
for (Int_t j = 0; j < noCuts; j++) {
line.ReadLine(infile);
// cout << line << endl;
if ( line.BeginsWith("#") || line.BeginsWith("//") ) {
j--;
continue;
}
sscanf(line, "%s", cname);
fFilePars[fEnergyPoints].SetCutName(j, cname);
// fCutName.push_back(cname);
}
fFilePars[fEnergyPoints].LoadCuts();
line.ReadLine(infile);
// cout << line << endl;
// continue;
}
// cout << fNoCrystals << endl;
for (Int_t j = 0; j < fNoCrystals; j++) {
// line.ReadLine(infile);
// cout << j << endl;
if ( line.BeginsWith("#") || line.BeginsWith("//") ) {
j--;
line.ReadLine(infile);
continue;
}
sscanf(line.Data(), "%d %d %d", &j, &min, &max);
// cout << j << endl;
fFilePars.at(fEnergyPoints).SetPeakMin(j, min);
fFilePars.at(fEnergyPoints).SetPeakMax(j, max);
line.ReadLine(infile);
}
fEnergyPoints++;
continue;
}
// cout << "aklsjdlaksjd" << endl;
// sscanf(line.Data(), "%d %d %d", &i, &min, &max);
// fFilePars.at(fEnergyPoints-1).SetPeakMin(i, min);
// fFilePars.at(fEnergyPoints-1).SetPeakMax(i, max);
}//while
infile.close();
return;
}
void AculCalParsScint::PrintParameters(const char* option) {
TString opt = option;
cout << "Parameters read from file \"" << fParFileName.Data() << "\"." << endl;
cout << "\tCalibration of detector \"" << fDetName << "\" with " << fNoCrystals << " crystals." << endl;
cout << "\tParticle: " << fPartName << endl;
cout << "\tInput files with raw data (" << fNoFiles << "):" << endl;
for (Int_t i = 0; i < (Int_t)fFilePars.size(); i++) {
cout << "\t " << GetFileName(i) << endl;
}
cout << "\tInput energies (" << fNoFiles << "):" << endl;
for (Int_t i = 0; i < (Int_t)fFilePars.size(); i++) {
cout << "\t " << fFilePars[i].GetEnergy() << " MeV" << endl;
}
// cout << "\tInput file with " << fNoCuts << " cuts: \"" << fCutsFileName << "\"" << endl;
// if (opt.Contains("all")) {
// for (Int_t i = 0; i < (Int_t)fCutName.size(); i++) {
// cout << "\t cut: \"" << fCutName[i] << "\"" << endl;
// }
// }
for (Int_t k = 0; k < (Int_t)fFilePars.size(); k++) {
cout << "\t" << fFilePars[k].GetNoCuts() << " cuts from file \"" << fFilePars[k].GetCutFileName() << "\":" << endl;
for (Int_t i = 0; i < fFilePars[k].GetNoCuts(); i++) {
cout << "\t " << fFilePars[k].GetCut(i)->GetName() << endl;
}
if (!opt.Contains("all")) continue;
cout << "\tPeak limits for particular channels and energies:" << endl;
cout << "\t Set number: " << k << "; energy: " << fFilePars[k].GetEnergy() << " MeV" << endl;
for (Int_t i = 0; i < (Int_t)fFilePars[k].GetNoCrystals(); i++) {
cout << "\t\t " << fFilePars[k].GetPeakMin(i) << "\t" << fFilePars[k].GetPeakMax(i) << endl;
}
}
return;
}
void AculCalParsScint::Reset() {
fNoCrystals = 0;
fParFileName = "";
fDetName = "";
fPartName = "";
fNoFiles = 0;
fFilePars.clear();
fEnergyPoints = 0;
// fCutsFileName = "";
// fNoCuts = 0; //number of cuts
// fCutName.clear();
return;
}
const char* AculCalParsScint::GetFileName(Int_t i) {
if ( i >= (Int_t)fFilePars.size() ) {
cerr << "\"AculCalParsScint::GetFileName\" index i cannot be higher than " << fFilePars.size() - 1 << endl;
return 0;
}
return fFilePars[i].GetRawFileName();
}
/*const char* AculCalParsScint::GetCutName(Int_t i) {
if ( i > (Int_t)fCutName.size()-1 ) {
cerr << "\"AculCalParsScint::GetCutName\" index i cannot be higher than " << fCutName.size() - 1 << endl;
return 0;
}
return fCutName[i].Data();
}*/
/*TCutG* AculCalParsScint::GetCut(Int_t i) {
if ( i >= (Int_t)fCuts.size() ) {
cerr << "\"AculCalParsScint::GetCut\" index i cannot be higher than " << fCuts.size() - 1 << endl;
return 0;
}
return &fCuts[i];
}*/
TCutG* AculCalParsScint::GetCut(const char* cutName, Int_t treeID) {
const TString cName = cutName;
if (treeID >= (Int_t)fFilePars.size()) {
cerr << "\"AculCalParsScint::GetCut\" treeID does not exist. It cannot be higher than "
<< fFilePars.size() << "." << endl;
return 0;
}
// TCutG *curCut = 0;
for (Int_t i = 0; i < fFilePars[treeID].GetNoCuts(); i++) {
// if (cName.EqualTo(fFilePars[treeID])) { return &fCuts[i]; }
if ( cName.EqualTo( fFilePars[treeID].GetCutName(i) ) ) {
return fFilePars[treeID].GetCut(i);
// return curCut;
}
}
cerr << "\"AculCalParsScint::GetCut\" cut \"" << cutName << "\" was not found." << endl;
return 0;
}
Double_t AculCalParsScint::GetCalEnergy(Int_t i) {
if ( i >= (Int_t)fFilePars.size() ) {
cerr << "\"AculCalParsScint::GetCalEnergy\" index i cannot be higher than " << fFilePars.size() - 1 << endl;
return 0;
}
return fFilePars[i].GetEnergy();
}
Int_t AculCalParsScint::GetMinChannel(Int_t energy, Int_t crystal) {
if ( energy >= (Int_t)fFilePars.size() ) {
cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than "
<< fFilePars.size() - 1 << endl;
return 0;
}
if ( crystal >= fFilePars[energy].GetNoCrystals() ) {
cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than "
<< fFilePars[energy].GetNoCrystals() - 1 << endl;
return 0;
}
return fFilePars[energy].GetPeakMin(crystal);
}
Int_t AculCalParsScint::GetMaxChannel(Int_t energy, Int_t crystal) {
if ( energy >= (Int_t)fFilePars.size() ) {
cerr << "\"AculCalParsScint::GetMinChannel\" index \"energy\" cannot be higher than "
<< fFilePars.size() - 1 << endl;
return 0;
}
if ( crystal >= fFilePars[energy].GetNoCrystals() ) {
cerr << "\"AculCalParsScint::GetMinChannel\" index \"crystal\" cannot be higher than "
<< fFilePars[energy].GetNoCrystals() - 1 << endl;
return 0;
}
return fFilePars[energy].GetPeakMax(crystal);
}
/*void AculCalParsScint::LoadCuts() {
if (fCutsFileName.Length() == 0) {
printf("AculCalParsScint::LoadCuts: Name of file (*.root) with cuts was not provided.\n");
printf("AculCalParsScint::LoadCuts: No cuts has been loaded.\n");
return;
}
TFile cutFile(fCutsFileName.Data(), "READ");
if(!cutFile.IsOpen()) {
cerr << "\"AculCalParsScint::LoadCuts\" File " << fCutsFileName.Data()
<< " was not open and no cuts were loaded." << endl;
return;
}
for (Int_t i = 0; i < (Int_t)fCutName.size(); i++) {
TCutG *currentCut = (TCutG*)cutFile.Get(fCutName[i]);
if (!currentCut) {
cout << "\"AculCalParsScint::LoadCuts\" Cut \"" << fCutName[i]
<< "\" was not found in file " << fCutsFileName << "." << endl;
continue;
}
fCuts.push_back(*currentCut);
}
}*/
/*
* AculCalParsScint.h
*
* Created on: Oct 21, 2016
* Author: vratik
*/
#ifndef ACULCALIB_ACULCALPARSSCINT_H_
#define ACULCALIB_ACULCALPARSSCINT_H_
#include "AculCalPars.h"
#include "AculCalParsScintFile.h"
//#include "TCutG.h"
using std::cerr;
class AculCalParsScint: public AculCalPars {
private:
Int_t fNoCrystals;
TString fDetName;
TString fPartName;
Int_t fNoFiles;
vector<AculCalParsScintFile> fFilePars;
//todo following parameters should be probably moved to AculCalParsScintFile
//as far as they are related to each file separately
// vector<TString> fCutName;
// vector<TCutG> fCuts;
Int_t fEnergyPoints;
// TString fCutsFileName;
// Int_t fNoCuts; //number of cuts
public:
AculCalParsScint();
AculCalParsScint(const char* parFile);
virtual ~AculCalParsScint();
ClassDef(AculCalParsScint, 1);
virtual void Init();
void PrintParameters(const char* option = "");
// If option contains "all", all parameters will be printed out.
// By default important parameters only will be printed out.
void Reset();
//getters
Int_t GetNoCrystals() {return fNoCrystals;}
const char* GetDetName() {return fDetName.Data();}
const char* GetParticleName() {return fPartName.Data();}
Int_t GetNoRawFiles() {return fNoFiles;}
const char* GetFileName(Int_t i);
const char* GetCutName(Int_t i);
Int_t GetNoEPoints() {return fEnergyPoints;}
Double_t GetCalEnergy(Int_t i);
// const char* GetCutsFileName() {return fCutsFileName.Data();}
// Int_t GetNoCuts() {return fNoCuts;}
// TCutG* GetCut(Int_t i);
TCutG* GetCut(const char* cutName, Int_t treeID = 0);
Int_t GetMinChannel(Int_t energy, Int_t crystal);
Int_t GetMaxChannel(Int_t energy, Int_t crystal);
//private:
// void LoadCuts();
protected:
void SetPars();
};
#endif /* ACULCALIB_ACULCALPARSSCINT_H_ */
/*
* AculCalParsScintFile.cpp
*
* Created on: Oct 25, 2016
* Author: vratik
*/
#include "AculCalParsScintFile.h"
AculCalParsScintFile::AculCalParsScintFile() {
// TODO Auto-generated constructor stub
// fFileID = 0;
fNoCrystals = 0;
fE = 0;
Init();
}
AculCalParsScintFile::~AculCalParsScintFile() {
// TODO Auto-generated destructor stub
}
void AculCalParsScintFile::Init() {
// fNoCrystals = 0;
// fE = 0;
fPeakMin.resize(fNoCrystals);
fPeakMax.resize(fNoCrystals);
fCutName.resize(0);
}
const char* AculCalParsScintFile::GetCutName(Int_t i) {
if ( i >= (Int_t)fCutName.size() ) {
cout << "\"AculCalParsScintFile::GetCutName\" Cut number " << i
<< " is not available. Maximal i can be set as "
<< fCutName.size() - 1 << "." << endl;
}
return fCutName[i].Data();
}
TCutG* AculCalParsScintFile::GetCut(Int_t i) {
if ( i >= (Int_t)fCut.size() ) {
cerr << "\"AculCalParsScintFile::GetCut\" index i cannot be higher than " << fCut.size() - 1 << endl;
return 0;
}
return &fCut[i];
}
TCutG* AculCalParsScintFile::GetCut(const char* cutName) {
const TString cName = cutName;
for (Int_t i = 0; i <= (Int_t)fCut.size(); i++) {
if (cName.EqualTo(fCutName[i])) { return &fCut[i]; }
}
cerr << "\"AculCalParsScint::GetCut\" cut \"" << cutName << "\" was not found." << endl;
return 0;
}
Int_t AculCalParsScintFile::GetPeakMin(Int_t crystalID) {
if ( crystalID >= (Int_t)fPeakMin.size() ) {
cerr << "\"AculCalParsScintFile::GetPeakMin\" index \"crystal\" cannot be higher than "
<< fPeakMin.size() - 1 << endl;
return 0;
}
return fPeakMin[crystalID];
}
Int_t AculCalParsScintFile::GetPeakMax(Int_t crystalID) {
if ( crystalID >= (Int_t)fPeakMax.size() ) {
cerr << "\"AculCalParsScintFile::GetPeakMax\" index \"crystal\" cannot be higher than "
<< fPeakMax.size() - 1 << endl;
return 0;
}
return fPeakMax[crystalID];
}
void AculCalParsScintFile::SetRawFileName(const char* filename) {
fFileName = filename;
// fFileID++;
}
void AculCalParsScintFile::SetCutFileName(const char* filename) {
fCutsFileName = filename;
}
void AculCalParsScintFile::SetNoCuts(Int_t noCuts) {
fCutName.resize(noCuts);
}
void AculCalParsScintFile::SetCutName(Int_t i, const char* cutname) {
if ( i >= (Int_t)fCutName.size() ) {
cout << "\"AculCalParsScintFile::SetCutName\" vector for cut names is not enough large. Maximal i can be set as "
<< fCutName.size() - 1 << "." << endl;
}
fCutName[i] = cutname;
}
void AculCalParsScintFile::SetPeakMin(Int_t crystalID, Double_t limit) {
if ( crystalID>=(Int_t)fPeakMin.size() ) {
cerr << "\"AculCalParsScintFile::SetPeakMin\" maximal allowed crystal ID is " << fPeakMin.size() << "."<< endl;
return;
}
fPeakMin[crystalID] = limit;
}
void AculCalParsScintFile::SetPeakMax(Int_t crystalID, Double_t limit) {
if ( crystalID>=(Int_t)fPeakMax.size() ) {
cerr << "\"AculCalParsScintFile::SetPeakMax\" maximal allowed crystal ID is " << fPeakMax.size() << "."<< endl;
return;
}
fPeakMax[crystalID] = limit;
}
void AculCalParsScintFile::LoadCuts() {
if (fCutsFileName.Length() == 0) {
printf("AculCalParsScintFile::LoadCuts: Name of file (*.root) with cuts was not provided.\n");
printf("AculCalParsScintFile::LoadCuts: No cuts has been loaded.\n");
return;
}
TFile cutFile(fCutsFileName.Data(), "READ");
if(!cutFile.IsOpen()) {
cerr << "\"AculCalParsScintFile::LoadCuts\" File " << fCutsFileName.Data()
<< " was not open and no cuts were loaded." << endl;
return;
}
for (Int_t i = 0; i < (Int_t)fCutName.size(); i++) {
TCutG *currentCut = (TCutG*)cutFile.Get(fCutName[i]);
if (!currentCut) {
cout << "\"AculCalParsScintFile::LoadCuts\" Cut \"" << fCutName[i]
<< "\" was not found in file " << fCutsFileName << "." << endl;
continue;
}
fCut.push_back(*currentCut);
}
}
/*void AculCalParsScintFile::Reset() {
}*/
/*
* AculCalParsScintFile.h
*
* Created on: Oct 25, 2016
* Author: vratik
*/
#ifndef ACULCALIB_ACULCALPARSSCINTFILE_H_
#define ACULCALIB_ACULCALPARSSCINTFILE_H_
#include <vector>
#include <iostream>
#include "TFile.h"
#include "TCutG.h"
#include "TString.h"
using std::vector;
using std::cout;
using std::endl;
using std::cerr;
class AculCalParsScintFile {
private:
// UInt_t fFileID;
Int_t fNoCrystals;
Double_t fE;
// TCutG fCuts;
TString fFileName;
TString fCutsFileName;
vector<TString> fCutName;
vector<TCutG> fCut;
vector<Int_t> fPeakMin;
vector<Int_t> fPeakMax;
public:
AculCalParsScintFile();
virtual ~AculCalParsScintFile();
ClassDef(AculCalParsScintFile, 1);
void Init();
Int_t GetNoCrystals() {return fNoCrystals;}
const char* GetRawFileName() {return fFileName.Data();}
const char* GetCutFileName() {return fCutsFileName.Data();}
Double_t GetEnergy() {return fE;}
Int_t GetNoCuts() {return (Int_t)fCut.size();}
const char* GetCutName(Int_t i);
TCutG* GetCut(Int_t i);
TCutG* GetCut(const char* cutName);
Int_t GetPeakMin(Int_t crystalID);
Int_t GetPeakMax(Int_t crystalID);
void SetNoCrystals(Int_t nocrystals) {fNoCrystals = nocrystals;};
void SetEnergy(Double_t energy) {fE = energy;};
void SetRawFileName(const char* filename);
void SetCutFileName(const char* filename);
void SetNoCuts(Int_t noCuts);
void SetCutName(Int_t i, const char* cutname);
void SetPeakMin(Int_t crystalID, Double_t limit);
void SetPeakMax(Int_t crystalID, Double_t limit);
void LoadCuts();
// void Reset();
private:
// void LoadCuts();
};
#endif /* ACULCALIB_ACULCALPARSSCINTFILE_H_ */
/*
* AculCalParsSi.cpp
*
* Created on: Oct 26, 2016
* Author: vratik
*/
#include "AculCalParsSi.h"
AculCalParsSi::AculCalParsSi() {
// TODO Auto-generated constructor stub
Reset();
}
AculCalParsSi::AculCalParsSi(const char* parFile) {
SetParFile(parFile);
Init();
}
AculCalParsSi::~AculCalParsSi() {
// TODO Auto-generated destructor stub
}
void AculCalParsSi::Init() {
SetELosses();
SetPars();
SetCalEnergies();
}
void AculCalParsSi::Reset() {
fParFileName = "";
kRaNOPEAKS = 0;
fEnergyInput.clear();
fLowerChannel = 0.;
fUpperChannel = 0.;
fLowerPeakRelativeHight = 0.;
fUpperPeakRelativeHight = 0.;
fPeakPositionTolerance = 0.;
fFitFuncLineWidth = 1;
fFitMinSigma = 0.;
fFitPeakThreshold = 0.;
fDeadLayer = 0.;
return;
}
void AculCalParsSi::SetPars() {
if (fParFileName.Length()==0) {
cerr << "\'AculCalibration::SetInputsParameters\" File with input parameters was not set." << endl;
return;
}
const Int_t lineLength = 400;
Char_t line[lineLength];
Char_t parameter[100];
Char_t identificator[100];
std::ifstream fipr;
fipr.open(fParFileName.Data());
if (!fipr.is_open()) {
cerr << "\"AculCalibration::SetInputsParameters\" File with input parameters \""
<< fParFileName << "\" was not opened." << endl;
return;
}
cout << "\"AculCalibration::SetInputsParameters\" File with input parameters \""
<< fParFileName << "\" will be processed." << endl;
while (!fipr.eof()) {
fipr.getline(line, lineLength);
if (strlen(line) < 2) {
continue;
}
sscanf(line, "%s %s", parameter, identificator);
if ( strcmp(identificator, "noPeaks") == 0 ) {
kRaNOPEAKS = static_cast<Int_t>(atoi(parameter));
fEnergyInput.resize(kRaNOPEAKS);
fEtab.resize(kRaNOPEAKS);
for (Int_t i = 0; i < kRaNOPEAKS; i++) {
fipr.getline(line, lineLength);
sscanf(line, "%s", parameter);
fEnergyInput[i] = static_cast<Double_t>(atof(parameter));
}
continue;
}//if
if ( strcmp(identificator, "lowerChannel") == 0 ) {
sscanf(line, "%s", parameter);
fLowerChannel = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "upperChannel") == 0 ) {
sscanf(line, "%s", parameter);
fUpperChannel = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "lowerPeakHight") == 0 ) {
sscanf(line, "%s", parameter);
fLowerPeakRelativeHight = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "upperPeakHight") == 0 ) {
sscanf(line, "%s", parameter);
fUpperPeakRelativeHight = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "peakPositionTolerance") == 0 ) {
sscanf(line, "%s", parameter);
fPeakPositionTolerance = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "fitFunctionLineWidth") == 0 ) {
sscanf(line, "%s", parameter);
fFitFuncLineWidth = static_cast<Width_t>(atoi(parameter));
}
if ( strcmp(identificator, "minFitSigma") == 0 ) {
sscanf(line, "%s", parameter);
fFitMinSigma = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "fitHightThreshold") == 0 ) {
sscanf(line, "%s", parameter);
fFitPeakThreshold = static_cast<Double_t>(atof(parameter));
}
if ( strcmp(identificator, "deadLayer") == 0 ) {
sscanf(line, "%s", parameter);
fDeadLayer = static_cast<Double_t>(atof(parameter));
}
}
fipr.close();
return;
}
void AculCalParsSi::PrintParameters(const char* option)
{
//print alpha source parameters
cout << "AculCalibration::PrintInputParameters:" << endl;
cout << "\tNumber of peaks: " << kRaNOPEAKS << endl;
for (Int_t i = 0; i < kRaNOPEAKS; i++) {
cout << "\t\tfEnergyInput[" << i << "] = " << fEnergyInput[i] << " MeV" << endl;
}
cout << "\tEnergies used for calibration:" << endl;
cout << "\t(deadLayer: " << fDeadLayer << " mcm)" << endl;
for (Int_t i = 0; i < kRaNOPEAKS; i++) {
cout << "\t\tfE[" << i << "] = " << fEtab[i] << " MeV" << endl;
}
cout << "\tlowerChannel: " << fLowerChannel << "; upperChannel: " << fUpperChannel << ";" << endl;
cout << "\tlowerPeakHight: " << fLowerPeakRelativeHight << "; upperPeakHight: " << fUpperPeakRelativeHight << ";" << endl;
cout << "\tfitHightThreshold: " << fFitPeakThreshold << "; minFitSigma: " << fFitMinSigma << ";" << endl;
cout << "\tpeakPositionTolerance: " << fPeakPositionTolerance << ";" << endl;
cout << "\tfitFunctionLineWidth: " << fFitFuncLineWidth << ";" << endl;
return;
}
void AculCalParsSi::SetELosses() {
Info("AculCalibration::SetELosses", "Combination of aplha particle with silicon material only.");
fAlphaSi.SetEL(1, 2.321); // density in g/cm3
fAlphaSi.AddEL(14., 28.086, 1); //Z, mass
// mSi.SetZP(1., 1.); //protons
fAlphaSi.SetZP(2., 4.); //alphas, Z, A
fAlphaSi.SetEtab(100000, 200.); // ?, MeV calculate ranges
fAlphaSi.SetDeltaEtab(300);
}
void AculCalParsSi::SetCalEnergies() {
if (fDeadLayer<=0.) {
Warning("AculCalibration::SetCalEnergies", "Dead layer was set equal or less than 0.");
for(Int_t i = 0; i < kRaNOPEAKS; i++) {
fEtab[i] = fEnergyInput[i];
}
Info("AculCalibration::SetCalEnergies", "Energies used for calibration are the same as input file.");
return;
}
for(Int_t i = 0; i < kRaNOPEAKS; i++) {
fEtab[i] = fAlphaSi.GetE(fEnergyInput[i], fDeadLayer);
}
Info("AculCalibration::SetCalEnergies", "Energies used for calibration considering %f mcm dead layer were set.", fDeadLayer);
return;
}
/*
* AculCalParsSi.h
*
* Created on: Oct 26, 2016
* Author: vratik
*/
#ifndef ACULCALIB_ACULCALPARSSI_H_
#define ACULCALIB_ACULCALPARSSI_H_
#include "AculCalPars.h"
#include "../TELoss/TELoss.h"
class AculCalParsSi: public AculCalPars {
private:
Int_t kRaNOPEAKS;
// TArrayD fEnergy; //energy after passing through deadlayer
vector<Double_t> fEnergyInput; //incidental energy, set from .par
Double_t fLowerChannel;
Double_t fUpperChannel;
Double_t fLowerPeakRelativeHight; //pouziva se, private
Double_t fUpperPeakRelativeHight; //pouziva se, private, nastavit nenulovou prednastavenou hodnotu
Double_t fPeakPositionTolerance; //pouziva se, private
Width_t fFitFuncLineWidth; //private
Double_t fFitMinSigma; //pouziva se, private
Double_t fFitPeakThreshold; //pouziva se, private, prozkoumat, k cemu vlastne slouzi ve fci ShowPeaks, popremyslet o vhodnem prednastaveni v konstruktoru
Double_t fDeadLayer; //in mcm; it will be used for recalculation of energies outcomming from the alpha source
TELoss fAlphaSi;
public:
AculCalParsSi();
AculCalParsSi(const char* parFile);
virtual ~AculCalParsSi();
ClassDef(AculCalParsSi, 1);
void Init();
// Function which loads text file containing parameters for calibration
//
// -inputparfile: file containing information on calibration source
// -In file with the data must be preserved systematic
// -There cannot be whitelines (probably)
//
//Example of "parforcal.par" file
//................................................................
//223Ra
//
//4 nopeaks //number of peaks
//4.415 E1 //in MeV
//5.153 E2 //in MeV
//5.683 E3 //in MeV
//7.419 E4 //in MeV
//100 lowerchannel //in channels
//4096 upperchannel //in channels
//0.1 lowerpeakhight //in relative units
//0.1 upperpeakhight //in relative units
//0.1 peakpositiontolerance //in relative units
//2 fitfunctionlinewidth //integer 1 - 10
//5 minfitsigma //minimal sigma of the peaks to be fitted
//0.4 fithightthreshold //
//................................................................
void Reset();
void PrintParameters(const char* option = "");
//I hope this is selfunderstanding function
private:
void SetPars();
void SetELosses();
void SetCalEnergies();
};
#endif /* ACULCALIB_ACULCALPARSSI_H_ */
#include "AculCalib.h"
//----------------------------------------------------------------------------
AculCalib::AculCalib() {
//documentation example
printf("AculCalib::Default constructor called.\n");
Init();
}
//----------------------------------------------------------------------------
/*AculCalib::AculCalib(const char* parfile) {
printf("AculCalib::Constructor called.\n");
SetParFile(parfile);
Init();
}*/
//----------------------------------------------------------------------------
AculCalib::~AculCalib() {
printf("AculCalib::Destructor called.\n");
delete fPars;
}
//----------------------------------------------------------------------------
void AculCalib::Init() {
fPars = 0;
}
//----------------------------------------------------------------------------
void AculCalib::SetParFile(const char* parfile) {
fParFileName = parfile;
return;
}
//----------------------------------------------------------------------------
void AculCalib::PrintParameters(const char* option) {
if (!fPars) {
cerr << "\"AculCalib::PrintParameters\" parameters were not initialized." << endl;
return;
}
fPars->PrintParameters(option);
}
//----------------------------------------------------------------------------
void AculCalib::PrintCalibParameters() {
cout << "i\ta\t\b" << endl;
for (Int_t i = 0; i<=(Int_t)fA.size(); i++) {
cout << i << "\t" << fA[i] << "\t" << fB[i] << endl;
}
}
//----------------------------------------------------------------------------
Double_t AculCalib::GetA(Int_t i) {
if (i >= (Int_t)fA.size()) //if i >= number of array element
{
return 0.;
}
return fA[i];
}
//----------------------------------------------------------------------------
Double_t AculCalib::GetB(Int_t i) {
if (i >= (Int_t)fB.size()) //if i >= number of array element
{
return 0.;
}
return fB[i];
}
//----------------------------------------------------------------------------
void AculCalib::CanDivider(TCanvas *c, Int_t noPads, Int_t columns, Int_t rows) {
c->Clear();
if (noPads == 16) {
c->Divide(4, 4);
return;
}
if (rows != 0 && columns != 0) {
c->Divide(columns, rows);
return;
}
}
//----------------------------------------------------------------------------
ClassImp(AculCalib);
////////////////////////////////////////////////////////////////
// //
// TMyClass //
// //
// This is the description block. //
// //
////////////////////////////////////////////////////////////////
#ifndef ACULCALIB_ACULCALIB_H_
#define ACULCALIB_ACULCALIB_H_
//#include "TObject.h"
//#include "TROOT.h"
#include <iostream>
#include <fstream>
#include "TArrayD.h"
#include "TString.h"
#include "TCanvas.h"
#include "./AculCalPars.h"
using std::cout;
using std::endl;
using std::cerr;
class AculCalib {
protected:
vector<Double_t> fA; //calibration parameter A
vector<Double_t> fB; //calibration parameter A
TString fParFileName; //name of file with parameters
AculCalPars *fPars; //parameters used for calibration
public:
//Default constructor.
AculCalib();
//Destructor.
virtual ~AculCalib();
ClassDef(AculCalib,1);
virtual void Init();
void SetParFile(const char* parfile);
const char* GetParFileName() {return fParFileName.Data();}
//Print parameters used for calibration.
void PrintParameters(const char* option = "");
//Print calibration parameters.
void PrintCalibParameters();
//Get calibration parameter A.
Double_t GetA(Int_t i);
//Get calibration parameter B.
Double_t GetB(Int_t i);
protected:
void CanDivider(TCanvas *c, Int_t noPads, Int_t columns = 0, Int_t rows = 0);
};
#endif
################################################################################
# AculData input with some variables
################################################################################
# ACULCALIBLIBS := -lCore -lCint -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf -lSpectrum #-lTELoss
ACULCALIBLIBS := -lCore -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf -lSpectrum #-lTELoss
# Add inputs and outputs from these tool invocations to the build variables
ACULCALIB_HEADERS += \
$(ACULCALIB)/AculCalib.h \
$(ACULCALIB)/AculCalibScint.h \
$(ACULCALIB)/AculCalibSi.h \
$(ACULCALIB)/AculCalPars.h \
$(ACULCALIB)/AculCalParsScint.h \
$(ACULCALIB)/AculCalParsScintFile.h \
$(ACULCALIB)/AculCalParsSi.h \
$(ACULCALIB)/AculCalibLinkDef.h
ACULCALIBCPP_SRCS += \
$(ACULCALIB)/AculCalib.cpp \
$(ACULCALIB)/AculCalibScint.cpp \
$(ACULCALIB)/AculCalibSi.cpp \
$(ACULCALIB)/AculCalPars.cpp \
$(ACULCALIB)/AculCalParsScint.cpp \
$(ACULCALIB)/AculCalParsScintFile.cpp \
$(ACULCALIB)/AculCalParsSi.cpp \
$(ACULCALIB)/AculCalibDict.cpp
ACULCALIBOBJS += \
$(ACULCALIB)/AculCalib.o \
$(ACULCALIB)/AculCalibScint.o \
$(ACULCALIB)/AculCalibSi.o \
$(ACULCALIB)/AculCalPars.o \
$(ACULCALIB)/AculCalParsScint.o \
$(ACULCALIB)/AculCalParsScintFile.o \
$(ACULCALIB)/AculCalParsSi.o \
$(ACULCALIB)/AculCalibDict.o
ACULCALIBCPP_DEPS += \
$(ACULCALIB)/AculCalib.d \
$(ACULCALIB)/AculCalibScint.d \
$(ACULCALIB)/AculCalibSi.d \
$(ACULCALIB)/AculCalPars.d \
$(ACULCALIB)/AculCalParsScint.d \
$(ACULCALIB)/AculCalParsScintFile.d \
$(ACULCALIB)/AculCalParsSi.d \
$(ACULCALIB)/AculCalibDict.d
\ No newline at end of file
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
//#pragma link C++ class AculRaw;
//#pragma link C++ class AculConvert;
#pragma link C++ class AculCalib;
#pragma link C++ class AculCalibScint;
#pragma link C++ class AculCalibSi;
#pragma link C++ class AculCalPars;
#pragma link C++ class AculCalParsScint;
#pragma link C++ class AculCalParsScintFile;
#pragma link C++ class AculCalParsSi;
#endif
This diff is collapsed.
//////////////////////////////////////////////////////////////////////////////
// //
// This class is intended for ... //
// //
// It work like this... User may use such functions ... in such steps. //
//
// Keywords in parameter file and possible comments
//
// Something about order of keywords
//
// Example of parameter file (with explanations)
//
// energies 4 #number of energy points
// crystals 16 #number of crystals in detector
// files 4
// #fileID fileName
// #fileID not implemented yet
// data/csi_13_Ealpha16.root
// data/csi_13_Ealpha21.root
// data/csi_13_Ealpha26.root
// data/csi_13_Ealpha30.root
// #keyword detector particle
// detector SQ13 Alpha
// #keyword energy [MeV/A]
// energy 66.542
// #keyword; filename; number of cuts in file
// cutFile cuts/cutsSQ13Alpha.root 2
// cutsSQ13Alpha16
// cutSQ13Alpha16Amp
// #channel minimum maximum
// 0 650 830
// 1 920 1150
//\ ...
// 15 800 1000
// #CsI2, energy ~ 21 MeV/A, Alpha
// energy 85.437
// #keyword; filename; number of cuts in file
// cutFile cuts/cutsSQ13Alpha.root 2
// cutSQ13Alpha21
// cutSQ13Alpha21Amp
// #channel minimum maximum
// 0 1050 1200
//\ \...
// 15 1150 1350
// #CsI2, energy ~ 26 MeV/A, Alpha
// energy 105.5
// ...
//
//asdasd
//////////////////////////////////////////////////////////////////////////////
#pragma once
//#include "TObject.h"
//#include "TROOT.h"
#include <iostream>
#include <fstream>
//#include <vector>
#include "TFile.h"
#include "TTree.h"
//#include "TCanvas.h"
#include "TH1I.h"
#include "TGraphErrors.h"
//#include "TArrayD.h"
#include "TF1.h"
#include "./AculCalib.h"
using std::cout;
using std::endl;
//using std::vector;
class AculCalibScint : public AculCalib {
private:
//
//todo delete this strange double array somewhere
TFile **fInFiles; //! doc of class member
TTree **fTrees; //!
TFile *fCutFile;
vector< vector<TH1I*> > fHistFull;
vector< vector<TH1I*> > fHistCut;
//
vector< vector<Double_t> > fMeanPeakPos; //doc of class member
vector< vector<Double_t> > fMeanPeakRMS;
//
//todo make vector of graphs
TGraphErrors *gCal[16];
// TFile *fGraphs;
public:
AculCalibScint();
//default constructor
AculCalibScint(const char* parfile);
virtual ~AculCalibScint();
ClassDef (AculCalibScint,1); //decription right after ClassDef
virtual void Init();
void PrintTrees();
//Description of the function. I think it does not work.
void DrawVariable(const char* variable, Int_t treeID, TCanvas *canvas, Int_t lowRange = 0, Int_t upRange = 4096);
//Description of the function. I think it does not work.
void DrawBeam(TCanvas *canvas, Int_t file, const char* variable);
//One of the crucial function. It founds the mean of the peak related to our particle.
void GetPeakMean(const char* variable, Int_t treeID, TCanvas *canvas,
const char* beamcut, const Int_t nbins = 4096, Int_t lowRange = 0);
void Calibrate(TCanvas *canvas, Bool_t savefile = 0, const char* filename = "", const char* option = "READ");
void WriteClbParameters(const char* filename);
TTree* GetTree(Int_t treeID);
//private functions:
// void LoadCuts();
private:
void OpenFiles();
void LoadTrees();
void SaveClbGraphs(const char* filename, const char* option = "READ");
void FillGraph(TGraphErrors *g, Int_t npoints, /*Double_t *energies,*/ Int_t graphNumber, const char* option = "");
// void SetPars();
};
/*
* AculCalibSi.cpp
*
* Created on: Oct 26, 2016
* Author: vratik
*/
#include "AculCalibSi.h"
#include "AculCalParsSi.h"
ClassImp(AculCalibSi);
AculCalibSi::AculCalibSi() {
printf("AculCalibScint::Default constructor called.\n");
// fInFiles = 0;
// fTrees = 0;
// fCutFile = 0;
}
AculCalibSi::AculCalibSi(const char* parfile) {
printf("AculCalibScint::Constructor called.\n");
SetParFile(parfile);
Init();
}
AculCalibSi::~AculCalibSi() {
printf("AculCalibScint::Destructor called.\n");
}
void AculCalibSi::Init() {
fPars = new AculCalParsSi(fParFileName.Data());
}
/*
* AculCalibSi.h
*
* Created on: Oct 26, 2016
* Author: vratik
*/
#ifndef ACULCALIB_ACULCALIBSI_H_
#define ACULCALIB_ACULCALIBSI_H_
#include "AculCalib.h"
class AculCalibSi: public AculCalib {
private:
// Double_t something;
public:
AculCalibSi();
AculCalibSi(const char* parfile);
virtual ~AculCalibSi();
ClassDef(AculCalibSi, 1);
void Init();
// Bool_t CalculateCalibParameters(const char* inputfile, const char* block,
// const char* treename, Int_t lowerchannel = 0,
// Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0,
// Int_t uppersubaddress = ADDRESSNUMBER-1); //calculate calibration parameters for given block in given file
//function is not completely ready to use
//
//function for calculation of calibrate parameters for DAQ system based on "Go4"
//
// inputfile: root file with calibration spectra
// block: block name to be calibrated
// lowerchannel: minimal channel from which the spectrum will be analysed
// upperchannel: maximal channel up to which the spectrum will be analysed
// lowersubaddress: block subaddress
// uppersubaddress: block subbaddress
};
#endif /* ACULCALIB_ACULCALIBSI_H_ */
############################################################################
# CMakeLists.txt file for building AculCalib package
############################################################################
ROOT_STANDARD_LIBRARY_PACKAGE(AculCalib
HEADERS
AculCalib.h
AculCalibScint.h
AculCalibSi.h
AculCalPars.h
AculCalParsScintFile.h
AculCalParsScint.h
AculCalParsSi.h
SOURCES
AculCalib.cpp
# AculCalibDict.cpp
AculCalibScint.cpp
AculCalibSi.cpp
AculCalPars.cpp
AculCalParsScint.cpp
AculCalParsScintFile.cpp
AculCalParsSi.cpp
# DEPENDENCIES
# MathCore
# Matrix
# RIO
LINKDEF
AculCalibLinkDef.h
)
# ROOT_ADD_TEST_SUBDIRECTORY(test)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculCalib.cxx DESTINATION ${CMAKE_BINARY_DIR}/include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculCalib.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculCalib_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(TARGETS AculCalib LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib)
\ No newline at end of file
......@@ -44,8 +44,8 @@ private:
Int_t nCuts; //number of cuts
TClonesArray cutsCol;
TH1I *hfull[NOCALFILES][16];
TH1I *hcut[NOCALFILES][16];
TH1I *hfull[NOCALFILES][16]; //!
TH1I *hcut[NOCALFILES][16]; //!
Int_t peakMin[NOCALFILES][16];
Int_t peakMax[NOCALFILES][16];
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ private:
//these variables are the main for the class
TArrayD fA; //calibration parameter, f(x) = fA*x + fB
TArrayD fB; //calibration parameter, f(x) = fA*x + fB
TArrayD fB; //calibration parameter, f(x) = fA*x + fB
TArrayD fPeak; //v teto promenne je ulozena momentalni hodnota piku v kanalech, zejmena v jedne fci, mozno udelat ji jako lokalni, bude navratovou hodnotou fce PeaksFitting, predelat delku pole
......@@ -83,7 +83,7 @@ private:
TString fParFileName;
//it is very doubtful that we need this class variable
TFile *fCalInformation;
TFile *fCalInformation;
......@@ -144,7 +144,7 @@ public:
Bool_t CalculateCalibParameters(const char* inputfile, const char* block,
const char* treename, Int_t lowerchannel = 0,
Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0,
Int_t uppersubaddress = ADDRESSNUMBER-1); //calculate calibration parameters for given block in given file
Int_t uppersubaddress = ADDRESSNUMBER-1); //calculate calibration parameters for given block in given file
//function is not completely ready to use
//
......@@ -176,13 +176,13 @@ public:
void CalibrateRawSpectra(const char* inputfile, const char* block, const char* treename, Int_t lowerchannel = 0, Int_t upperchannel = 4095, Int_t nEBins = 1000, Int_t lowersubaddress = 0, Int_t uppersubaddress = ADDRESSNUMBER-1);
void FindEnergyPeaks(TCanvas *c1, const char* ifile, const char* outfile);
void FindEnergyPeaks(TCanvas *c1, const char* ifile, const char* outfile);
// Outputs calibrated energies for each channel in txt file
//
//
//
void FindAverageEnergies(const char* ifile, const char* outfile);
//
void FindAverageEnergies(const char* ifile, const char* outfile);
// Outputs average values of calibrated energies for the whole detector in txt file
//
//
......
......@@ -2,25 +2,25 @@
# AculData input with some variables
################################################################################
ACULDATALIBS := -lCore -lCint -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf -lSpectrum #-lTELoss
ACULDATALIBS := -lCore -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf -lSpectrum #-lTELoss
# Add inputs and outputs from these tool invocations to the build variables
ACULDATA_HEADERS += \
$(ACULDATA)/AculCalibration.h \
$(ACULDATA)/AculCalibCsI.h \
$(ACULDATA)/linkdef.h
$(ACULDATA)/AculDataLinkDef.h
ACULDATACPP_SRCS += \
$(ACULDATA)/AculCalibration.cpp \
$(ACULDATA)/AculCalibCsI.cpp \
$(ACULDATA)/AculDataCint.cpp
$(ACULDATA)/AculDataDict.cpp
ACULDATAOBJS += \
$(ACULDATA)/AculCalibration.o \
$(ACULDATA)/AculCalibCsI.o \
$(ACULDATA)/AculDataCint.o
$(ACULDATA)/AculDataDict.o
ACULDATACPP_DEPS += \
$(ACULDATA)/AculCalibration.d \
$(ACULDATA)/AculCalibCsI.d \
$(ACULDATA)/AculDataCint.d
\ No newline at end of file
$(ACULDATA)/AculDataDict.d
\ No newline at end of file
#ifdef __CINT__
#ifdef __CLING__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
......@@ -9,6 +9,4 @@
#pragma link C++ class AculCalibCsI;
//#pragma link C++ class ConfigDictionary;
#endif
#endif
\ No newline at end of file
############################################################################
# CMakeLists.txt file for building AculData package
############################################################################
ROOT_STANDARD_LIBRARY_PACKAGE(AculData
HEADERS
AculCalibCsI.h
AculCalibration.h
SOURCES
AculCalibCsI.cpp
AculCalibration.cpp
# DEPENDENCIES
# MathCore
# Matrix
# RIO
LINKDEF
AculDataLinkDef.h
)
# ROOT_ADD_TEST_SUBDIRECTORY(test)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION ${CMAKE_BINARY_DIR}/include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(TARGETS AculData LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib)
\ No newline at end of file
#ifndef CONFIGDICTIONARY_H
#define CONFIGDICTIONARY_H
#include "TObject.h"
#include "ReturnCodes.h"
#include "TStopwatch.h"
#include "TROOT.h"
#include <string>
#include <map>
#include <sstream>
#include "TLorentzVector.h"
#include <iostream>
#include "TMath.h"
#include "TString.h"
#include "TTree.h"
class ConfigDictionary{
public:
typedef std::map<std::string,std::string>::iterator CDIter;
ConfigDictionary();
ConfigDictionary(std::string);
virtual ~ConfigDictionary(){};//empty virtual destructor
ClassDef(ConfigDictionary,1);
std::string ToString();
void FromString(std::string);
//These throw errors if couldn't find key:
std::string GetString(std::string)throw(std::string);
int GetInt(std::string)throw(std::string);
double GetDouble(std::string)throw(std::string);
bool GetBool(std::string)throw(std::string);
//These will always set 'something' into map:
void SetString(std::string,std::string);
void SetDouble(std::string,double);
void SetInt(std::string,int);
void SetBool(std::string,bool);
CDIter Begin(){return configMap.begin();};
CDIter End(){return configMap.end();};
private:
std::map<std::string,std::string> configMap;
};
#endif
cmake_minimum_required(VERSION 3.0)
project(AculUtils)
# Find ROOT package
find_package(ROOT REQUIRED)
# Set installation prefix
# set(CMAKE_INSTALL_PREFIX "..")
# Set output directories for built targets
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY is: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # prevent mkdir races
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# message(STATUS "ROOT Configuration \n
# System ${CMAKE_SYSTEM}
# Processor ${PROCESSOR} (${CMAKE_SYSTEM_PROCESSOR})
# Build type ${CMAKE_BUILD_TYPE}
# Install path ${CMAKE_INSTALL_PREFIX}
# Compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}
# Compiler flags:
# C ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_BUILD_TYPE_UPPER}}
# C++ ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_BUILD_TYPE_UPPER}}
# Linker flags:
# Executable ${CMAKE_EXE_LINKER_FLAGS}
# Module ${CMAKE_MODULE_LINKER_FLAGS}
# Shared ${CMAKE_SHARED_LINKER_FLAGS}\n")
# Add include directories for ROOT
include_directories(${ROOT_INCLUDE_DIRS})
# Print the value of ROOT_INCLUDE_DIRS
message(STATUS "ROOT include directories: ${ROOT_INCLUDE_DIRS}")
message(STATUS "ROOT_GET_INSTALL_DIR: ${ROOT_GET_INSTALL_DIR}")
# ROOT_GET_INSTALL_DIR
ROOT_GET_INSTALL_DIR(shared_lib_install_dir)
# Add the subdirectories
add_subdirectory(TELoss)
add_subdirectory(AculCalib)
add_subdirectory(AculData)
add_subdirectory(Utilities)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION include)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData.rootmap DESTINATION lib)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData_rdict.pcm DESTINATION lib)
# install(TARGETS AculData LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
# Set the output directory for the dictionary files
# set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
# set(GEN_DICT_OUTPUT_DIR ${CMAKE_BINARY_DIR})
message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}")
message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}")
message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}")
message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
# message(STATUS "shared_lib_install_dir: ${shared_lib_install_dir}")
\ No newline at end of file
1) set path in makefile according to your operating system
Tested with
root_6.28_04 (precompiled binaries for Ubuntu 20.04)
root-6.22.08 (compiled from source at nra161: /LynxOS/mbsusr/mbsdaq/analysis/root/root-6.22.08)
I. Use with GNU make
1) set path in makefile according to your operating system
2) type in terminal:
......@@ -7,3 +13,23 @@
make install
3) add the install folder to LD_LIBRARY_PATH
II. Use with cmake
1) mkdir build
2) cd build
3) cmake ..
4) make install
III. Test of compiled libraries
1) cd macros
2) modify libraries paths in rootlogon.C if needed
3) rootlogon.C will automatically load compiled libraries libTELoss.so and libAculData.so, then
root -l testOfAculData.cxx
root -l testOfTELoss.cxx
\ No newline at end of file
############################################################################
# CMakeLists.txt file for building TELoss package
############################################################################
# include_directories(TELoss)
# Get the list of include directories
get_property(INCLUDE_DIRS DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
# Print the include directories
message(STATUS "Include directories: ${INCLUDE_DIRS}")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")
message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}")
# Add the source files specific to the TELoss module
set(SOURCES
TELoss.cpp
TELoss.h
TELossLinkDef.h
)
# Add the Fortran source file
set(FORTRAN_SOURCES
ELOSS.f90
)
# Generate dictionary for TELoss class
ROOT_GENERATE_DICTIONARY(
G__TELoss
${CMAKE_CURRENT_SOURCE_DIR}/TELoss.h
LINKDEF
${CMAKE_CURRENT_SOURCE_DIR}/TELossLinkDef.h)
# Add the dictionary source file to the sources list
list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/G__TELoss.cxx)
# Create a library target for the TELoss module
add_library(TELoss SHARED ${SOURCES} ${FORTRAN_SOURCES})
# Link against ROOT libraries
target_link_libraries(TELoss ${ROOT_LIBRARIES})
# Set compiler flags for Fortran source
enable_language(Fortran)
set_source_files_properties(${FORTRAN_SOURCES} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION ${CMAKE_BINARY_DIR}/include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libTELoss.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libTELoss_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(TARGETS TELoss LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib)
\ No newline at end of file
This diff is collapsed.
......@@ -2,19 +2,24 @@
# TELoss input with some variables
################################################################################
TELOSSLIBS := -lCore -lCint -lMathCore -lMatrix -lHist -lgfortran
# TELOSSLIBS := -lCore -lCint -lMathCore -lMatrix -lHist -lgfortran
TELOSSLIBS := -lCore -lMathCore -lMatrix -lHist -lgfortran
# Add inputs and outputs from these tool invocations to the build variables
TELOSS_HEADERS += \
$(TELOSS)/TELoss.h \
$(TELOSS)/TELossLinkDef.h
TELOSSCPP_SRCS += \
$(TELOSS)/TELoss.cpp \
$(TELOSS)/TELossCint.cpp
$(TELOSS)/TELossDict.cpp
TELOSSOBJS += \
$(TELOSS)/ELOSS.o \
$(TELOSS)/TELoss.o \
$(TELOSS)/TELossCint.o
$(TELOSS)/TELossDict.o
TELOSSCPP_DEPS += \
$(TELOSS)/TELoss.d \
$(TELOSS)/TELossCint.d
$(TELOSS)/TELossDict.d
#ifdef __CINT__
#ifdef __CLING__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TELoss;
#endif
\ No newline at end of file
############################################################################
# CMakeLists.txt file for building Utilities package
############################################################################
ROOT_STANDARD_LIBRARY_PACKAGE(Utilities
HEADERS
CalPars.h
ConfigDictionary.h
CsICalib.h
ReturnCodes.h
SOURCES
CalPars.cpp
ConfigDictionary.cpp
CsICalib.cpp
# DEPENDENCIES
# MathCore
# Matrix
# RIO
LINKDEF
UtilitiesLinkDef.h
)
# ROOT_ADD_TEST_SUBDIRECTORY(test)
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__Utilities.cxx DESTINATION ${CMAKE_BINARY_DIR}/include)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libUtilities.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libUtilities_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib)
install(TARGETS Utilities LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib)
\ No newline at end of file
#include "CalPars.h"
ClassImp(CalPars);
CalPars::CalPars(const char* clbfile) {
ReadParFile(clbfile);
}
CalPars::~CalPars() {
printf("CalPars::Destructor called.\n");
}
Double_t CalPars::GetA(Int_t i) {
if (i >= fA.GetSize()) {
return 0.;
}
return fA[i];
}
Double_t CalPars::GetB(Int_t i) {
if (i >= fB.GetSize()) {
return 0.;
}
return fB[i];
}
Double_t CalPars::GetC(Int_t i) {
if (i >= fC.GetSize()) {
return 0.;
}
return fC[i];
}
void CalPars::ReadParFile(const char* clbfile) {
clbFile = clbfile;
std::ifstream infile(clbfile);
if ( !infile.is_open() ) {
printf("CalPars::ReadParFile: File %s was not open.\n", clbfile);
printf("CalPars::ReadParFile: Calibration parameters are empty!!!\n");
return;
}
TString line;
Int_t nopars;
Double_t a, b;
Int_t c; //threshold
printf("CalPars::ReadParFile: File %s was open.\n", clbfile);
line.ReadLine(infile);
sscanf(line.Data(), "%*d %d", &nopars);
// Info("CalPars::ReadParFile", "%d calibration parameters will be loaded", nopars);
printf("CalPars::ReadParFile: %d calibration parameters will be loaded\n", nopars);
fA.Set(nopars);
fB.Set(nopars);
fC.Set(nopars);
for (Int_t i = 0; i <nopars; i++) {
line.ReadLine(infile);
// if ( line.BeginsWith("#") ) continue;
// cout << line.Data() << endl;
sscanf(line.Data(), "%lf %lf %d", &b, &a, &c);
fA[i] = a;
fB[i] = b;
fC[i] = c;
// printf("fA[%d]: %f,\tfB[%d]: %f\n", i, fA[i], i, fB[i]);
// printf("fA[%d]: %f,\tfB[%d]: %f\n\n", i, a, i, b);
}
}
void CalPars::PrintClbPars() {
printf("CalPars::PrintClbPars: %d calibration parameters from %s file.\n", fA.GetSize(), clbFile.Data());
for (Int_t i = 0; i<fA.GetSize(); i++) {
printf("%d\t%f\t%f\t%f\n", i, GetA(i), GetB(i), GetC(i));
}
}
#pragma once
#include <iostream>
#include <fstream>
#include "TArrayD.h"
#include "TArrayI.h"
#include "TString.h"
#include "TObject.h"
using std::cout;
using std::endl;
class CalPars /*: TObject*/ {
private:
TArrayD fA;
TArrayD fB;
TArrayI fC;
TString clbFile;
public:
CalPars() : fA(0), fB(0), fC(0) {};
CalPars(const char* clbfile);
virtual ~CalPars();
Double_t GetA(Int_t i);
Double_t GetB(Int_t i);
Double_t GetC(Int_t i);
void ReadParFile(const char* clbfile);
void PrintClbPars();
ClassDef(CalPars, 1);
};
......@@ -100,17 +100,24 @@ ClassImp(ConfigDictionary);
// Info("Some optional variables wasn't read!");
//}
//--------------------</pre>
//
// ADDED 21.03.2012:
//
// With use of templates, now ConfigDictionary can handle complex objects
// reading and writing instantly as long as proper >> and << operators are
// provided for an object initialization.
//
// END_HTML
//////////////////////////////////////////////////////////////////////////////
//_____________________________________________________________________________
ConfigDictionary::ConfigDictionary(){
//just empty map...
//Empty map...
}
//_____________________________________________________________________________
ConfigDictionary::ConfigDictionary(std::string params){
//Just creates dictionary using FromString method
//Creates dictionary using FromString method
FromString(params);
}
......@@ -154,63 +161,61 @@ void ConfigDictionary::FromString(std::string params){
}
//_____________________________________________________________________________
std::string ConfigDictionary::GetString(std::string key)throw(std::string){
std::string ConfigDictionary::GetString(std::string key){
//Extracts string from given key
//(if it exist, otherwise raises exception)
//This works also for long strings with white spaces in it!
if (configMap.find(key) == configMap.end()){
Error("ConfigDictionary::GetString",
"Couldn't find the key: %s!",key.c_str());
throw(key);
// throw(key);
throw std::runtime_error("Couldn't find the key: " + key);
}
return configMap[key];
}
//_____________________________________________________________________________
int ConfigDictionary::GetInt(std::string key)throw(std::string){
//Extracts integer from given key
//(if it exist, otherwise raises exception)
if (configMap.find(key) == configMap.end()){
Error("ConfigDictionary::GetInt",
"Couldn't find the key: %s!",key.c_str());
throw(key);
}
int returned=0;
//Convert string to int:
std::stringstream ss(configMap[key]);
ss>>returned;
return returned;
int ConfigDictionary::GetInt(std::string key) {
// Extracts integer from given key
// (if it exists, otherwise raises exception)
try {
return Get<int>(key);
} catch (const std::string& message) {
// Catch the exception thrown by Get<int> and re-throw it as std::runtime_error
throw std::runtime_error(message);
}
}
//_____________________________________________________________________________
double ConfigDictionary::GetDouble(std::string key)throw(std::string){
//Extracts integer from given key
double ConfigDictionary::GetDouble(std::string key){
//Extracts double precision floating number from given key
//(if it exist, otherwise raises exception)
if (configMap.find(key) == configMap.end()){
Error("ConfigDictionary::GetDouble",
"Couldn't find the key: %s!",key.c_str());
throw(key);
}
double returned=0.0;
//Convert string to double:
std::stringstream ss(configMap[key]);
ss>>returned;
return returned;
try
{
return Get<double>(key);
} catch (const std::string& message) {
// Catch the exception thrown by Get<int> and re-throw it as std::runtime_error
throw std::runtime_error(message);
}
}
//_____________________________________________________________________________
bool ConfigDictionary::GetBool(std::string key)throw(std::string){
bool ConfigDictionary::GetBool(std::string key){
//Extracts boolean from given key
//(if it exist, otherwise raises exception)
//Differs from template to make it more readable.
// Check if the key exists in the config map
if (configMap.find(key) == configMap.end()){
Error("ConfigDictionary::GetBool",
"Couldn't find the key: %s!",key.c_str());
throw(key);
throw std::runtime_error("Couldn't find the key: " + key);
}
//Convert string to bool:
if (configMap[key].compare("true") == 0)
return true;
else return false;
else
return false;
}
//_____________________________________________________________________________
......@@ -221,23 +226,19 @@ void ConfigDictionary::SetString(std::string key,std::string value){
//_____________________________________________________________________________
void ConfigDictionary::SetDouble(std::string key,double value){
//Sets value to key, converts double to string first
std::stringstream ss;
ss<<value;
configMap[key] = ss.str();
Set<double>(key,value);
}
//_____________________________________________________________________________
void ConfigDictionary::SetInt(std::string key,int value){
//Sets value to key, converts int to string first
std::stringstream ss;
ss<<value;
configMap[key] = ss.str();
Set<int>(key,value);
}
//_____________________________________________________________________________
void ConfigDictionary::SetBool(std::string key,bool value){
//Sets value to key, converts bool to string first
//Differs from template to make it more readable.
if (value == true) configMap[key] = "true";
else configMap[key] = "false";
}
#ifndef CONFIGDICTIONARY_H
#define CONFIGDICTIONARY_H
#include "TObject.h"
#include "ReturnCodes.h"
#include "TStopwatch.h"
#include "TROOT.h"
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include "TLorentzVector.h"
#include <iostream>
#include "TMath.h"
#include "TString.h"
#include "TTree.h"
#define ARRAY_DELIM '$'
class ConfigDictionary{
public:
typedef std::map<std::string,std::string>::iterator CDIter;
ConfigDictionary();
ConfigDictionary(std::string);
virtual ~ConfigDictionary(){};//empty virtual destructor
ClassDef(ConfigDictionary,1);
std::string ToString();
void FromString(std::string);
//These throw errors if couldn't find key:
//Most of methods below are just using templates to
//make them usable in Cint.
std::string GetString(std::string);
int GetInt(std::string);
double GetDouble(std::string);
bool GetBool(std::string);
//These will always set 'something' into map:
void SetString(std::string,std::string);
void SetDouble(std::string,double);
void SetInt(std::string,int);
void SetBool(std::string,bool);
CDIter Begin(){return configMap.begin();};
CDIter End(){return configMap.end();};
//_________________________________________________________________________
template <class T>
T Get(std::string key) {
//This method will get object of any class
//that was - presumably - stored before in string format in CD.
//Object needs to have proper >> operator.
//If operation fails, returned item should have default value
//depending on its empty constructor.
//For strings containing spaces it won't work properly, as it
//would extract only first space followed item!
if (configMap.find(key) == configMap.end()) {
Error( "ConfigDictionary::Get",
"Couldn't find the key: %s!",
key.c_str());
throw std::runtime_error("Couldn't find the key: " + key);
}
// Use std::istringstream to convert the string to the desired type
std::istringstream inStream(configMap[key]);
T item;
// Extract the value from the stringstream
inStream >> item;
// Check if extraction failed
if (inStream.fail()) {
// Throw std::runtime_error with an informative message
throw std::runtime_error("Failed to extract value for key: " + key);
}
// Return the extracted item
return item;
}
//_____________________________________________________________________________
template <class T>
void Set(std::string key,T value){
//Sets value to key, converts T to string first with << operator.
std::stringstream ss;
ss<<value;
configMap[key] = ss.str();
}
//_________________________________________________________________________
template <class T>
int GetArray(std::string key,std::vector<T> & output){
//Preconditions: T must have >> operator
//Effect: searches for key in map and pushes values stored in it into output vector
//Returns: number of elements pushed into vector
int retNumber = 0; // Counter for the number of elements pushed into the vector
// Check if the key exists in the config map
if (configMap.find(key) == configMap.end()){
Error( "ConfigDictionary::GetInt",
"Couldn't find the key: %s!",key.c_str());
throw std::runtime_error("Couldn't find the key: " + key);
}
// Create a string stream from the value associated with the key
std::istringstream arrayString(configMap[key]);
// Temporary string to hold each item from the string stream
std::string itemString;
//Dangerous - maybe? - exceptions for ss not handled...
// Loop to extract each item from the string stream
while (std::getline(arrayString,itemString,ARRAY_DELIM)){
std::stringstream itemStream(itemString); // Create a string stream from the item string
if (!itemString.empty()) { // Check if the item string is not empty
T item; // Temporary variable to hold the converted item
itemStream >> item; // Extract the item from the string stream
output.push_back(item); // Push the item into the output vector
retNumber++; // Increment the counter
}
}
// Return the number of elements pushed into the vector
return retNumber;
}
//_________________________________________________________________________
template <class T>
void SetArray(std::string key,std::vector<T> & input){
std::ostringstream arrayString;
for (unsigned int i=0;i<input.size();i++){
arrayString<<input[i]<<ARRAY_DELIM;
}
configMap[key] = arrayString.str();
}
private:
std::map<std::string,std::string> configMap;
};
#endif
This diff is collapsed.
#pragma once
//#include "TObject.h"
//#include "TROOT.h"
#include <iostream>
#include <fstream>
#include "TFile.h"
#include "TTree.h"
#include "TCutG.h"
#include "TCanvas.h"
#include "TClonesArray.h"
#include "TH1I.h"
#include "TGraphErrors.h"
#include "TArrayD.h"
#include "TF1.h"
#define NOCALFILES 5
using std::cout;
using std::endl;
class CsICalib {
private:
TString detName;
TString partName;
TClonesArray fr; //TFile
// TFile *fData;
TClonesArray tr;
TClonesArray colFiles;
TClonesArray colTrees;
Int_t nofiles;
TString fileNames[100];
TString cutNames[100];
Int_t energyPoints;
TArrayD fE;
TFile *fCuts;
TString cutsFileName;
Int_t nCuts; //number of cuts
TClonesArray cutsCol;
TH1I *hfull[NOCALFILES][16]; //!
TH1I *hcut[NOCALFILES][16]; //!
Int_t peakMin[NOCALFILES][16];
Int_t peakMax[NOCALFILES][16];
Double_t mean[NOCALFILES][16];
Double_t meanRMS[NOCALFILES][16];
TGraphErrors *gCal[16];
TFile *fGraphs;
TArrayD fA;
TArrayD fB;
public:
// CsICalib() : a(0), b(0), c(0), p(0){};
CsICalib();
CsICalib(const char* parfile);
virtual ~CsICalib();
void OpenTrees();
void LoadCuts();
void ReadParFile(const char* parfile);
void PrintParameters(const char* option = "");
void PrintPeakRanges();
void DrawVariable(const char* variable, Int_t tree, TCanvas *canvas, Int_t lowRange = 0, Int_t upRange = 4096);
void DrawBeam(TCanvas *canvas, Int_t files, const char* variable);
// void DrawdEE(const char* variable, Int_t tree, TCanvas *canvas);
void DrawVariableCut(const char* variable, Int_t tree, TCanvas *canvas, const char* cut1, const char* cut2 = "", Int_t lowRange = 0);
void GetPeakMean(const char* variable, Int_t tree, Int_t energy, TCanvas *canvas, const char* beamcut, const Int_t nbins = 4096, Int_t lowRange = 0);
void Calibrate(TCanvas *canvas, Bool_t savefile = 0, const char* filename = "", const char* option = "READ");
void FillGraph(TGraphErrors *g, Int_t npoints, Double_t *energies, Int_t graphNumber, const char* option = "");
void WriteClbParameters(const char* filename);
void SaveClbGraphs(const char* filename, const char* option = "READ");
void ReadClbParameters(const char* filename);
void DrawClbGraphs(const char* filename, const char* graphname, TCanvas *canvas);
void DrawEnergyDeposite(const char* variable, TCanvas *canvas, Int_t tree, const char* option = "");
void PrintTrees();
void PrintFiles();
void PrintCuts();
Double_t GetA(Int_t i) {return fA[i];};
Double_t GetB(Int_t i) {return fB[i];};
// Define the class for the cint dictionary
ClassDef (CsICalib,1);
};
################################################################################
# AculData input with some variables
################################################################################
# UTILITIESLIBS := -lCore -lCint -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf
UTILITIESLIBS := -lCore -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -lGpad -lGraf
#UTILITIESLIBS := -lGui -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -pthread -lm -ldl -rdynamic
# Add inputs and outputs from these tool invocations to the build variables
UTILITIES_HEADERS += \
$(UTILITIES)/CalPars.h \
$(UTILITIES)/CsICalib.h \
$(UTILITIES)/ConfigDictionary.h \
$(UTILITIES)/UtilitiesLinkDef.h
UTILITIESCPP_SRCS += \
$(UTILITIES)/CalPars.cpp \
$(UTILITIES)/CsICalib.cpp \
$(UTILITIES)/ConfigDictionary.cpp \
$(UTILITIES)/UtilitiesDict.cpp
UTILITIESOBJS += \
$(UTILITIES)/CalPars.o \
$(UTILITIES)/CsICalib.o \
$(UTILITIES)/ConfigDictionary.o \
$(UTILITIES)/UtilitiesDict.o
UTILITIESCPP_DEPS += \
$(UTILITIES)/CalPars.d \
$(UTILITIES)/CsICalib.d \
$(UTILITIES)/ConfigDictionary.d \
$(UTILITIES)/UtilitiesDict.d
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class CalPars;
#pragma link C++ class CsICalib;
#pragma link C++ class ConfigDictionary;
#endif
#include "THtml.h"
void htmldoc()
{
gSystem->Load("./libAculData.so");
gSystem->Load("./libTELoss.so");
gSystem->Load("./libAculCalib.so");
gSystem->Load("./libAculData.so");
THtml h;
h.SetInputDir(".");
h.SetOutputDir("htmldoc");
h.SetProductName("AculUtils");
h.MakeAll();
......
{
gSystem->Load("~/workspace/Utilities/libAculData.so");
gSystem->Load("libTELoss.so");
gSystem->Load("libAculData.so");
}
......@@ -33,8 +33,14 @@
// cal.DrawBeam(myCanv, 4, "SQ13");
//return;
// <<<<<<< HEAD
// cal.DrawVariableCut("SQ13", 0, c2, "cutsSQ13Alpha16");
// cal.DrawVariableCut("SQ13", 0, c2, "cutsSQ13Alpha16", "cutSQ13Alpha16Amp");
// =======
cal.DrawVariableCut("SQ13", 0, c1, "cutsSQ13Alpha16");
return;
cal.DrawVariableCut("SQ13", 0, c1, "cutsSQ13Alpha16", "cutSQ13Alpha16Amp");
// >>>>>>> newArch
//return;
// cal.DrawVariableCut("SQ13", 1, c2, "cutSQ13Alpha21", "cutSQ13Alpha21Amp");
// cal.DrawVariableCut("SQ13", 2, c3, "cutSQ13Alpha26", "cutSQ13Alpha26Amp");
......
energies 4 #number of energy points
crystals 16 #number of crystals in detector
files 4
#fileID fileName
#fileID not implemented yet
data/csi_13_Ealpha16.root
data/csi_13_Ealpha21.root
data/csi_13_Ealpha26.root
data/csi_13_Ealpha30.root
#keyword detector particle
detector SQ13 Alpha
#keyword energy [MeV/A]
energy 66.542
#keyword; filename; number of cuts in file
cutFile cuts/cutsSQ13Alpha.root 2
cutsSQ13Alpha16
cutSQ13Alpha16Amp
#channel minimum maximum
0 650 830
1 920 1150
2 850 1000
3 1200 1400
4 960 1100
5 700 850
6 650 800
7 1040 1240
8 850 1050
9 650 850
10 950 1200
11 900 1100
12 740 860
13 1140 1380
14 420 500
15 800 1000
#CsI2, energy ~ 21 MeV/A, Alpha
energy 85.437
#keyword; filename; number of cuts in file
cutFile cuts/cutsSQ13Alpha.root 2
cutSQ13Alpha21
cutSQ13Alpha21Amp
#channel minimum maximum
0 1050 1200
1 1350 1550
2 1190 1400
3 1650 1950
4 1300 1500
5 950 1100
6 900 1050
7 1450 1700
8 1150 1400
9 900 1100
10 1350 1600
11 1250 1500
12 950 1200
13 1600 1860
14 550 640
15 1150 1350
#CsI2, energy ~ 26 MeV/A, Alpha
energy 105.5
#keyword; filename; number of cuts in file
cutFile cuts/cutsSQ13Alpha.root 2
cutSQ13Alpha26
cutSQ13Alpha26Amp
#channel minimum maximum
0 1300 1600
1 1750 2050
2 1560 1800
3 2250 2500
4 1720 2000
5 1200 1450
6 1160 1400
7 1800 2200
8 1600 1850
9 1200 1400
10 1750 2100
11 1650 1900
12 1250 1600
13 2150 2450
14 690 900
15 1500 1700
#CsI2, energy ~ 30 MeV/A, Alpha
energy 119.54
#keyword; filename; number of cuts in file
cutFile cuts/cutsSQ13Alpha.root 2
cutSQ13Alpha30
cutSQ13Alpha30Amp
#channel minimum maximum
0 1450 1750
1 2200 2450
2 1900 2150
3 2590 3000
4 2100 2350
5 1500 1650
6 1400 1600
7 2250 2550
8 1900 2150
9 1400 1600
10 2050 2600
11 1950 2200
12 1580 1710
13 2550 2900
14 1100 1250
15 1800 2000
\ No newline at end of file
../calibration_CsI/cuts/
\ No newline at end of file
../calibration_CsI/data/
\ No newline at end of file
//#include "../../AculCalib/AculCalPars.h"
//#include "../../AculCalib/AculCalibScint.h"
//#include "../../AculCalib/AculCalibSi.h"
//#include "TSystem.h"
//#include <iostream>
//
using std::cout;
using std::endl;
void parTest()
{
gSystem->Load("../../libTELoss.so");
gSystem->Load("../../libAculCalib.so");
/* AculCalibSi ps;
ps.SetParFile("parforcal.par");
ps.Init();
ps.PrintParameters();
return;
*/
// AculCalParsScintFile pp;
// pp.SetNoCrystals(16);
// pp.Init();
// return;
cout << "-----------------------" << endl;
AculCalParsScint p;
p.SetParFile("SQ13Alpha.par");
p.Init();
// cout << p.GetFileName(0) << endl;
// cout << p.GetFileName(1) << endl;
// cout << p.GetFileName(2) << endl;
// cout << p.GetFileName(3) << endl;
// cout << p.GetFileName(4) << endl;
// p.PrintParameters("");
p.PrintParameters("all");
// return;
p.Reset();
// p.PrintParameters("");
// return;
cout << "-----------------------" << endl;
AculCalibScint c;
c.SetParFile("SQ13Alpha.par");
c.Init();
c.PrintParameters();
// return;
// c.PrintParameters("all");
// c.OpenFiles();
// c.LoadTrees();
c.PrintTrees();
TCanvas *c1 = new TCanvas("c1", "Plain");
TCanvas *c2 = new TCanvas("c2", "Plain");
TCanvas *c3 = new TCanvas("c3", "Plain");
TCanvas *c4 = new TCanvas("c4", "Plain");
// c.DrawVariable("SQ13", 2, c1);
// c.DrawBeam(c1, 4, "SQ13");
// c.GetPeakMean("SQ13", 0, c1, "cutSQ13Alpha16Amp", 256);
c.GetPeakMean("SQ13", 0, c1, "cutSQ13Ala16Amp", 256);
c.GetPeakMean("SQ13", 1, c2, "cutSQ13Alpha21Amp", 256);
c.GetPeakMean("SQ13", 2, c3, "cutSQ13Alpha26Amp", 256);
c.GetPeakMean("SQ13", 3, c4, "cutSQ13Alpha30Amp", 256);
//return;
// c.PrintFiles();
// c.PrintCuts();
// TCanvas *c1 = new TCanvas("c1", "Plain");
// c.GetPeakMean("SQ13", 0, 0, c1, "cutSQ13Alpha16Amp", 256);
TCanvas *cCal = new TCanvas("cCal", "calibration Alpha");
c.Calibrate(cCal);
return;
}
//226Ra
//relative units are normalized to 1
4 noPeaks //number of peaks// число пиков, по которым происходит калибровка
4.751 E1 //in MeV including dead layer of alpha source//энергии альфа источника
5.459 E2 //in MeV//
5.972 E3 //in MeV//
7.661 E4 //in MeV//
2.3 deadLayer
0 lowersubaddress
15 uppersubaddress
ANS block
AnalysisxTree treename
400 lowerChannel //in channels//каналы,
2000 upperChannel //in channels//каналы
0.5 lowerPeakHight //in relative units; minimal range of the peak//
0.5 upperPeakHight //in relative units; minimal range of the peak//
0.1 peakPositionTolerance //in relative units; for check of the peaks positions in channels//
2 fitFunctionLineWidth //integer 1 - 10; graphics//
20 minFitSigma //minimal sigma of the peaks to be fitted//
0.3 fitHightThreshold //in relative units; the minimal height of the treated peak//
{
TString pathToLibs = "../build/lib/";
// TString pathToLibs = "../";
TString pathToTELoss = pathToLibs + "libTELoss.so";
TString pathToAculData = pathToLibs + "libAculData.so";
TString pathToUtilities = pathToLibs + "libUtilities.so";
TString pathToAculCalib = pathToLibs + "libAculCalib.so";
//libTELoss.so loading
Int_t teloss = gSystem->Load(pathToTELoss);
if (teloss==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToTELoss.Data());
else Error("rootlogon.C", "Some error with %s loading", pathToTELoss.Data());
//libAculData.so loading
Int_t aculdata = gSystem->Load(pathToAculData);
if (aculdata==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToAculData.Data());
else Error("rootlogon.C", "Some error with %s loading", pathToAculData.Data());
//libUtilities.so loading
Int_t utilities = gSystem->Load(pathToUtilities);
if (utilities==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToUtilities.Data());
else Error("rootlogon.C", "Some error with %s loading", pathToUtilities.Data());
//libAculCalib.so loading
Int_t aculcalib = gSystem->Load(pathToAculCalib);
if (aculcalib==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToAculCalib.Data());
else Error("rootlogon.C", "Some error with %s loading", pathToAculCalib.Data());
}
\ No newline at end of file
#include "../AculData/AculCalibration.h"
void testOfAculData()
{
// gSystem->Load("/home/aculina/AculUt/libAculData.so");
// gSystem->Load("/home/aculina/AculUt/libTELoss.so");
AculCalibration cal;
cal.SetParFileName("./parforcal.par");
cal.Init(); //takes parameters from .par
cal.PrintInputParameters();
cal.PrintCalibrationParameters();
}
#include "TSystem.h"
#include "../TELoss/TELoss.h"
void testOfTELoss() {
//creating two object for combination particle-material
TELoss mSi_4He;
TELoss mSi_1H;
//setting tables for alphas in silicon
mSi_4He.SetEL(1, 2.321); //general properties of material (silicon)
mSi_4He.AddEL(14., 28.086, 1); //add Si element to material
mSi_4He.SetZP(2., 4.); //set 4He particles
mSi_4He.SetEtab(100000, 200.); //set table with ranges
mSi_4He.SetDeltaEtab(300); //some other table
//setting tables for protons in silicon
mSi_1H.SetEL(1, 2.321); //general properties of material (silicon)
mSi_1H.AddEL(14., 28.086, 1); //add Si element to material
mSi_1H.SetZP(1., 1.); //set 4He particles
mSi_1H.SetEtab(100000, 200.); //set table with ranges
mSi_1H.SetDeltaEtab(300); //some other table
cout << "Remaining energy of proton with energy of 20 MeV after penetration 1 mm of silicon is:" << endl;
cout << "expected (according to LISE++):\t14.604 MeV" << endl;
cout << "calculated:\t\t\t" << mSi_1H.GetE(20, 1000) << " MeV" << endl << endl;
cout << "Remaining energy of alpha with energy of 50 MeV after penetration 1 mm of silicon is:" << endl << endl;
cout << "expected (according to LISE++):\t5.447 MeV" << endl;
cout << "calculated:\t\t\t" << mSi_4He.GetE(50, 1000) << " MeV" << endl << endl;
cout << "Remaining energy of alpha with energy of 70 MeV after penetration 1 mm of silicon is:" << endl << endl;
cout << "expected (according to LISE++):\t45.076 MeV" << endl;
cout << "calculated:\t\t\t" << mSi_4He.GetE(70, 1000) << " MeV" << endl << endl;
}
\ No newline at end of file
......@@ -25,48 +25,99 @@ ROOTCFLAGS = $(shell root-config --cflags)
PWD = $(shell pwd)
#INSTALLFOLDER = $(HOME)/AculLib
UTILITIES = $(PWD)/Utilities
ACULDATA = $(PWD)/AculData
ACULCALIB = $(PWD)/AculCalib
TELOSS = $(PWD)/TELoss
-include $(UTILITIES)/Utilities.mk
-include $(ACULDATA)/AculData.mk
-include $(ACULCALIB)/AculCalib.mk
-include $(TELOSS)/TELoss.mk
all: libAculData.so \
all: libUtilities.so \
libAculData.so \
libAculCalib.so \
libTELoss.so
#ROOT html documentation, it will be done as a program which will be alsa compiled by this makefile, program will be as a last condition after all of the libraries
htmldoc: libAculData.so
htmldoc: libAculData.so libAculCalib.so libTELoss.so
-$(RM) htmldoc
root -l -q html.cxx
root -l -q htmldoc.cxx
clean_htmldoc:
-$(RM) htmldoc
-@echo ' '
clean:
-$(RM) $(UTILITIESOBJS) $(UTILITIESCPP_DEPS)
-$(RM) $(UTILITIES)/UtilitiesDict.* libUtilities.so $(UTILITIES)/*.pcm
-@echo ' '
-$(RM) $(ACULDATAOBJS) $(ACULDATACPP_DEPS)
-$(RM) $(ACULDATA)/AculDataCint.* libAculData.so
-$(RM) $(ACULDATA)/AculDataDict.* *.pcm $(ACULDATA)/*.pcm
-$(RM) libAculData.so
-@echo ' '
-$(RM) $(ACULCALIBOBJS) $(ACULCALIBCPP_DEPS)
-$(RM) $(ACULCALIB)/AculCalibDict.* libAculCalib.so $(ACULCALIB)/*.pcm
-@echo ' '
-$(RM) $(TELOSSOBJS) $(TELOSSCPP_DEPS)
-$(RM) $(TELOSS)/TELossCint.* libTELoss.so
-$(RM) $(TELOSS)/TELossDict.* *.pcm $(TELOSS)/*.pcm $(TELOSS)/*.pcm
-$(RM) libTELoss.so
-@echo ' '
-$(RM) htmldoc
-@echo ' '
# Those *Cint* files below need special treating:
$(ACULDATA)/AculDataCint.cpp:
-@echo 'Pre-building AculDataCint.cpp and AculDataCint.h files'
-rootcint -f $(ACULDATA)/AculDataCint.cpp -c -p $(ACULDATA_HEADERS)
# Those *Dictionary* files below need special treating:
$(UTILITIES)/UtilitiesDict.cpp:
-@echo 'Pre-building UtilitiesDict.cpp and UtilitiesDict.h files'
-rootcling -f $(UTILITIES)/UtilitiesDict.cpp -p $(UTILITIES_HEADERS)
-@echo 'Creating: link to UtilitiesDict_rdict.pcm'
-ln -s $(UTILITIES)/UtilitiesDict_rdict.pcm .
-@echo ' '
$(ACULDATA)/AculDataDict.cpp:
-@echo 'Pre-building AculDataDict.cpp and AculDataCint.h files'
-rootcling -f $(ACULDATA)/AculDataDict.cpp -p $(ACULDATA_HEADERS)
-@echo 'Creating: link to AculDataDict_rdict.pcm'
-ln -s $(ACULDATA)/AculDataDict_rdict.pcm .
-@echo ' '
$(ACULCALIB)/AculCalibDict.cpp:
-@echo 'Pre-building AculCalibDict.cpp and AculCalibDict.h files'
-rootcling -f $(ACULCALIB)/AculCalibDict.cpp -p $(ACULCALIB_HEADERS)
-@echo 'Creating: link to AculCalibDict_rdict.pcm'
-ln -s $(ACULCALIB)/AculCalibDict_rdict.pcm .
-@echo ' '
$(TELOSS)/TELossCint.cpp:
-@echo 'Pre-building TELossCint.cpp and TELossCint.h files'
-rootcint -f $(TELOSS)/TELossCint.cpp -c -p $(TELOSS)/TELoss.h $(TELOSS)/linkdef.h
$(TELOSS)/TELossDict.cpp:
-@echo 'Pre-building TELossDict.cpp and TELossDict_rdict.pcm files'
@echo
-rootcling -f $@ -c $(CXXFLAGS) -p $(TELOSS_HEADERS)
-@echo 'Creating: link to TELossDict_rdict.pcm'
-ln -s $(TELOSS)/TELossDict_rdict.pcm .
-@echo ' '
#*.so files
libUtilities.so: $(UTILITIESOBJS)
@echo 'Building target: $@'
@echo 'Invoking: $(CC) Linker'
$(CC) -L $(ROOTLIBS) -shared -o"libUtilities.so" $(UTILITIESOBJS) $(UTILITIESLIBS)
@echo 'Finished building target: $@'
@echo ' '
libAculData.so: libTELoss.so $(ACULDATAOBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
$(CC) -L . -L $(ROOTLIBS) -shared -o"libAculData.so" $(ACULDATAOBJS) $(ACULDATALIBS)
@echo 'Finished building target: $@'
@echo ' '
libAculCalib.so: libTELoss.so $(ACULCALIBOBJS)
@echo 'Building target: $@'
@echo 'Invoking: GCC C++ Linker'
$(CC) -L . -L $(ROOTLIBS) -shared -o"libAculCalib.so" $(ACULCALIBOBJS) $(ACULCALIBLIBS)
@echo 'Finished building target: $@'
@echo ' '
libTELoss.so: $(TELOSSOBJS)
@echo 'Building target: $@'
......@@ -83,7 +134,6 @@ libTELoss.so: $(TELOSSOBJS)
@echo 'Building file: $@'
@echo 'Invoking: $(CC) Compiler'
$(CC) -I$(ROOTINCS) -O0 -g3 -Wall -c -fmessage-length=0 -fPIC $(ROOTCFLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
# $(CC) -I$(ROOTINCS) -O2 -Wall -mmmx -msse -msse2 -msse3 -mfpmath=sse,387 -march=nocona -mtune=nocona -c -fmessage-length=0 -fPIC -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"$@" "$<"
@echo 'Finished building: $@'
@echo ' '
......