10#include "CorrFitParamsSetup.h"
13#include <TApplication.h>
18#include <TSQLResult.h>
20#include <TSQLServer.h>
21#include <TSQLStatement.h>
26#include "CorrFitDumpedPairAna.h"
28#include "FemtoCorrFuncSimple.h"
29#include "FemtoFreezoutGenerator.h"
30#include "FemtoPairKinematics.h"
31#include "FemtoSourceModel.h"
32#include "FemtoWeightGenerator.h"
33#include "FemtoWeightGeneratorLednicky.h"
38 CorrFitParamsSetup::CorrFitParamsSetup(Int_t params) : fSize(params) {
39 fMin.MakeBigger(fSize);
40 fMax.MakeBigger(fSize);
41 fNpoints.MakeBigger(fSize);
42 fNames =
new TString[fSize];
45 CorrFitParamsSetup::CorrFitParamsSetup(TString xmlFile) {
46 XMLFile file(xmlFile);
47 XMLNode* root = file.GetRootNode();
48 XMLNode* parameters = root->GetChild(
"Parameters");
49 fSize = parameters->GetNChildren();
50 fMin.MakeBigger(fSize);
51 fMax.MakeBigger(fSize);
52 fNpoints.MakeBigger(fSize);
53 fNames =
new TString[fSize];
54 for (
int i = 0; i < fSize; i++) {
55 XMLNode* par = parameters->GetChild(i);
56 fMin[i] = par->GetAttrib(
"min")->GetValue().Atof();
57 fMax[i] = par->GetAttrib(
"max")->GetValue().Atof();
58 double step = par->GetAttrib(
"step")->GetValue().Atof();
59 fNpoints[i] = TMath::Ceil((fMax[i] - fMin[i]) /
double(step)) + 1;
60 fMax[i] = fMin[i] + double(fNpoints[i] - 1) * step;
61 fNames[i] = par->GetAttrib(
"name")->GetValue();
65 Int_t CorrFitParamsSetup::GetNJobs()
const {
67 for (
int i = 0; i < GetNParams(); i++) {
68 jobs = jobs * GetNPoints(i);
73 std::vector<int> CorrFitParamsSetup::GetDimensions()
const {
74 std::vector<int> dims(fSize);
75 for (
int i = 0; i < fSize; i++) {
76 dims[i] = fNpoints.Get(i);
81 void CorrFitParamsSetup::SetParameter(Int_t par_id, Double_t min, Double_t max, Int_t points, TString name) {
82 if (par_id >= fSize) {
83 Int_t old_size = fSize;
85 fMin.MakeBigger(fSize);
86 fMax.MakeBigger(fSize);
87 fNpoints.MakeBigger(fSize);
88 TString* temp = fNames;
89 fNames =
new TString[fSize];
90 for (
int i = 0; i < old_size; i++)
96 fNpoints[par_id] = points;
97 fNames[par_id] = name;
100 CorrFitParamsSetup::CorrFitParamsSetup(
const CorrFitParamsSetup& other) :
101 TObject(other), fSize(other.fSize), fMin(other.fMin), fMax(other.fMax), fNpoints(other.fNpoints) {
102 fNames =
new TString[fSize];
103 for (
int i = 0; i < fSize; i++)
104 fNames[i] = other.fNames[i];
107 CorrFitParamsSetup& CorrFitParamsSetup::operator=(
const CorrFitParamsSetup& rhs) {
108 if (&rhs ==
this)
return *
this;
112 fNpoints = rhs.fNpoints;
113 if (fNames)
delete[] fNames;
114 fNames =
new TString[fSize];
115 for (
int i = 0; i < fSize; i++) {
116 fNames[i] = rhs.fNames[i];
121 Double_t CorrFitParamsSetup::GetStepSize(Int_t par_id)
const {
122 Double_t steps = fNpoints.Get(par_id) - 1.0;
123 if (steps == 0)
return 0;
124 return (fMax.Get(par_id) - fMin.Get(par_id)) / steps;
127 void CorrFitParamsSetup::Print(Option_t* )
const {
128 Cout::Text(
"CorrFitDbParamsSetup",
"L", kWhite);
129 for (
int i = 0; i < GetNParams(); i++) {
130 TString name = Form(
"%s min: %4.2f max: %4.2f steps %i", GetParName(i).Data(), GetMin(i), GetMax(i), GetNSteps(i));
131 Cout::Text(name,
"L", kWhite);
135 Bool_t CorrFitParamsSetup::TestMapFile(Int_t jobId) {
136 TString name = Form(
"files/corrfit_map_%i.root", jobId);
137 std::ifstream testFile;
139 if (!testFile.good()) {
144 TFile* f =
new TFile(name);
147 gSystem->Exec(Form(
"rm %s", name.Data()));
150 TTree* t = (TTree*) f->Get(
"map");
153 gSystem->Exec(Form(
"rm %s", name.Data()));
160 Int_t CorrFitParamsSetup::GetParId(TString name)
const {
161 for (
int i = 0; i < fSize; i++) {
162 if (fNames[i] == name)
return i;