Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CorrFitDumpedPairAnaHorizontal.cxx
1/*
2 * CorrFitDumpedPairAnaHorizontal.cxx
3 *
4 * Created on: 1 wrz 2022
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9#include "CorrFitDumpedPairAnaHorizontal.h"
10
11#include <TApplication.h>
12#include <TBranch.h>
13#include <TClonesArray.h>
14#include <TCollection.h>
15#include <TDirectoryFile.h>
16#include <TFile.h>
17#include <TKey.h>
18#include <TList.h>
19#include <TNamed.h>
20#include <TObjArray.h>
21#include <TSystem.h>
22#include <TTree.h>
23#include <cstdlib>
24#include <fstream>
25#include <string>
26
27#include "Array.h"
28#include "CorrFitDumpedPairAna.h"
29#include "CorrFitInfo.h"
30#include "CorrFitParamsSetup.h"
31#include "Cout.h"
32#include "Femto1DCF.h"
33#include "Femto3DCF.h"
34#include "FemtoConst.h"
35#include "FemtoCorrFunc.h"
36#include "FemtoCorrFuncSimple.h"
37#include "FemtoDumpPairAna.h"
38#include "FemtoFreezoutGenerator.h"
39#include "FemtoMiniPair.h"
40#include "FemtoPair.h"
41#include "FemtoSHCF.h"
42#include "FemtoSourceModel.h"
43#include "FemtoWeightGenerator.h"
44#include "FemtoWeightGeneratorLednicky.h"
45#include "XMLNode.h"
46
47namespace Hal {
48
49 CorrFitDumpedPairAnaHorizontal::CorrFitDumpedPairAnaHorizontal(Int_t jobid, Int_t maps_perAna) :
50 CorrFitDumpedPairAna(jobid, maps_perAna) {}
51
52 Bool_t CorrFitDumpedPairAnaHorizontal::Init() {
53 Bool_t preinit = CorrFitDumpedPairAna::Init();
54 return preinit;
55 }
56
57 void CorrFitDumpedPairAnaHorizontal::Finish() {
58 TObject* obj = nullptr;
59 for (int iJob = 0; iJob < fMultiplyJobs; iJob++) {
60 obj = fCF[iJob]->GetCF(0);
61 Bool_t exported = SaveAsRawArray(obj, iJob);
62 if (!exported) Cout::Text("Not supported CF", "L", kRed);
63 }
64 if (fJobId == 0) {
65 obj = fCF[0]->GetCF(0);
66 TFile* file = new TFile("files/config.root", "recreate");
67 CorrFitInfo* info = new CorrFitInfo();
68 // TODO don't forget about vertical flag !
69 std::ifstream macro;
70 macro.open("ana.C");
71 std::string line;
72 TString val = "";
73 while (std::getline(macro, line)) {
74 TString l = line;
75 l = l + "\n";
76 val = val + l;
77 }
78 macro.close();
79 info->SetMacroText(val);
80 info->SetPairFile(fPairFile);
81 info->SetCf(obj);
82 auto source = fGenerator[0]->GetSourceModel();
83 source->Print();
84 CorrFitParamsSetup* setup = new CorrFitParamsSetup("corrfit_conf.xml");
85 info->SetSetup(*setup);
86 info->Write();
87 file->Close();
88 }
89 }
90
91 void CorrFitDumpedPairAnaHorizontal::RunSignalPair() {
92 for (auto clones : fSignalClones) {
93 for (int jPair = 0; jPair < clones->GetEntriesFast(); jPair++) {
94 auto MiniPair = (FemtoMicroPair*) clones->UncheckedAt(jPair);
95 *fPair = *MiniPair;
96 for (int preMulti = 0; preMulti < fMultiplyPreprocess; preMulti++) {
97 PreprocessPair();
98 fPair->Compute();
99 fPairsProcessed++;
100 for (int nJobs = 0; nJobs < fMultiplyJobs; nJobs++) {
101 for (int weightMulti = 0; weightMulti < fMultiplyWeight; weightMulti++) {
102 fGenerator[nJobs]->GenerateFreezoutCooordinates(fPair);
103 fPair->SetWeight(fWeight->GenerateWeight(fPair));
104 fCF[nJobs]->FillNum(fPair);
105 fPair->SetWeight(1.0);
106 fCF[nJobs]->FillDenMixed(fPair);
107 }
108 }
109 }
110 }
111 }
112 }
113
114 void CorrFitDumpedPairAnaHorizontal::RunSignalBackgroundPair() {
115 for (auto clones : fSignalClones) {
116 for (int jSig = 0; jSig < clones->GetEntriesFast(); jSig++) {
117 auto MiniPair = (FemtoMicroPair*) clones->UncheckedAt(jSig);
118 *fPair = *MiniPair;
119 for (int preMulti = 0; preMulti < fMultiplyPreprocess; preMulti++) {
120 PreprocessPair();
121 fPair->Compute();
122 fPairsProcessed++;
123 for (int nJobs = 0; nJobs < fMultiplyJobs; nJobs++) {
124 for (int weightPair = 0; weightPair < fMultiplyWeight; weightPair++) {
125 fGenerator[nJobs]->GenerateFreezoutCooordinates(fPair);
126 fPair->SetWeight(fWeight->GenerateWeight(fPair));
127 fCF[nJobs]->FillNum(fPair);
128 }
129 }
130 }
131 }
132 }
133 for (auto clones : fBackgroundClones) {
134 for (int jSig = 0; jSig < clones->GetEntriesFast(); jSig++) {
135 auto MiniPair = (FemtoMicroPair*) clones->UncheckedAt(jSig);
136 *fPair = *MiniPair;
137 for (int preMulti = 0; preMulti < fMultiplyPreprocess; preMulti++) {
138 PreprocessPair();
139 fPair->Compute();
140 fPairsProcessed++;
141 for (int nJobs = 0; nJobs < fMultiplyJobs; nJobs++) {
142 fPair->SetWeight(1 * fMultiplyWeight);
143 fCF[nJobs]->FillNum(fPair);
144 }
145 }
146 }
147 }
148 }
149
150 void CorrFitDumpedPairAnaHorizontal::RunBackgroundPair() {
151 for (auto clones : fSignalClones) {
152 for (int jMix = 0; jMix < clones->GetEntriesFast(); jMix++) {
153 auto MiniPair = (FemtoMicroPair*) clones->UncheckedAt(jMix);
154 *fPair = *MiniPair;
155 for (int preMulti = 0; preMulti < fMultiplyPreprocess; preMulti++) {
156 PreprocessPair();
157 fPair->Compute();
158 fPairsProcessed++;
159 for (int nJobs = 0; nJobs < fMultiplyJobs; nJobs++) {
160 for (int weightPair = 0; weightPair < fMultiplyWeight; weightPair++) {
161 fGenerator[nJobs]->GenerateFreezoutCooordinates(fPair);
162 fPair->SetWeight(fWeight->GenerateWeight(fPair));
163 fCF[nJobs]->FillNum(fPair);
164 }
165 }
166 fPair->SetWeight(1.0 * fMultiplyJobs);
167 PreprocessMixedPair();
168 fPair->Compute();
169 for (int nJobs = 0; nJobs < fMultiplyJobs; nJobs++) {
170 fCF[nJobs]->FillDenMixed(fPair);
171 }
172 }
173 }
174 }
175 }
176
177 Bool_t CorrFitDumpedPairAnaHorizontal::InitGenerators(const std::vector<int>& dims,
178 XMLNode* parameters,
179 const CorrFitParamsSetup& setup) {
180 fGenerator.clear();
181 for (int j = 0; j < fMultiplyJobs; j++) {
182 fGenerator.push_back(fTempGenerator->MakeCopy());
183 FemtoSourceModel* freez = fGenerator[j]->GetSourceModel();
184 std::vector<int> arPos = Hal::Std::OneToMultiDimIndex(dims, fJobId * fMultiplyJobs + j);
185 for (int i = 0; i < parameters->GetNChildren(); i++) {
186 // XMLNode* parameter = parameters->GetChild(i);
187 Double_t val = setup.GetMin(i) + setup.GetStepSize(i) * ((Double_t) arPos[i]);
188 freez->SetParameterByName(setup.GetParName(i), val);
189 }
190 fGenerator[j]->Init();
191 }
192 return kTRUE;
193 }
194
195 Bool_t CorrFitDumpedPairAnaHorizontal::ConnectToData() {
196 Int_t bins;
197 Double_t min, max;
198 Hal::Std::GetAxisPar(*fCF[0]->GetCF(0)->GetNum(), bins, min, max, "x");
199 switch (fMode) {
200 case eDumpCalcMode::kSignalPairs: {
201 auto vec = fGrouping->GetBranchesByValue(min, max, true);
202 ConnectToSignal(vec);
203 } break;
204 case eDumpCalcMode::kBackgroundPairsOnly: {
205 auto vec = fGrouping->GetBranchesByValue(min, max, false);
206 ConnectToBackground(vec);
207 } break;
208 case eDumpCalcMode::kSignalBackgroundPairs: {
209 auto vec = fGrouping->GetBranchesByValue(min, max, false);
210 ConnectToBackground(vec);
211 vec = fGrouping->GetBranchesByValue(min, max, true);
212 ConnectToSignal(vec);
213 } break;
214 }
215 return kTRUE;
216 }
217
218 Bool_t CorrFitDumpedPairAnaHorizontal::InitCFs() {
219 for (int i = 0; i < fMultiplyJobs; i++) {
220 fCF.push_back((FemtoCorrFunc*) fTempCF->Clone());
221 }
222 if (fCF.size() != 0) return kTRUE;
223 return kFALSE;
224 }
225
226 CorrFitDumpedPairAnaHorizontal::~CorrFitDumpedPairAnaHorizontal() {
227 for (auto cf : fCF) {
228 delete cf;
229 }
230 }
231
232} /* namespace Hal */
void SetParameterByName(TString name, Double_t par)
Int_t GetNChildren() const
Definition XMLNode.h:104