|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file FFitWeights.cxx |
| 13 | +/// \brief Implementation file for FFitWeights.h, see the header fore more information |
| 14 | +/// |
| 15 | +/// \author Joachim C. K. B. Hansen, Lund University |
| 16 | + |
| 17 | +#include "FFitWeights.h" |
| 18 | + |
| 19 | +// using std::complex; |
| 20 | +// using std::pair; |
| 21 | +// using std::string; |
| 22 | +// using std::vector; |
| 23 | + |
| 24 | +ClassImp(FFitWeights) |
| 25 | + |
| 26 | + FFitWeights::FFitWeights() : TNamed("", ""), |
| 27 | + fW_data{nullptr}, |
| 28 | + vGain{0}, |
| 29 | + CentBin{100}, |
| 30 | + ChIDBin{220}, |
| 31 | + sAmpl{nullptr}, |
| 32 | + sqVec{nullptr}, |
| 33 | + sqCorVec{nullptr} |
| 34 | +{ |
| 35 | +} |
| 36 | + |
| 37 | +FFitWeights::FFitWeights(const char* name) : TNamed(name, name), |
| 38 | + fW_data{nullptr}, |
| 39 | + vGain{0}, |
| 40 | + CentBin{100}, |
| 41 | + ChIDBin{220}, |
| 42 | + sAmpl{nullptr}, |
| 43 | + sqVec{nullptr}, |
| 44 | + sqCorVec{nullptr} {} |
| 45 | + |
| 46 | +FFitWeights::~FFitWeights() |
| 47 | +{ |
| 48 | + delete fW_data; |
| 49 | +}; |
| 50 | + |
| 51 | +void FFitWeights::Init() |
| 52 | +{ |
| 53 | + fW_data = new TObjArray(); |
| 54 | + fW_data->SetName("FFitWeights_Data"); |
| 55 | + fW_data->SetOwner(kTRUE); |
| 56 | + |
| 57 | + this->SetBinAxis(1000, 0, 5000, 0); |
| 58 | + this->SetBinAxis(250, -3500, 3500, 1); |
| 59 | + this->SetBinAxis(250, -250, 250, 2); |
| 60 | + |
| 61 | + const char* tnd = "FT0Ampl"; |
| 62 | + fW_data->Add(new TH2F(tnd, ";channel;amplitude", ChIDBin, 0, ChIDBin, sAmpl->GetNbins(), sAmpl->GetXmin(), sAmpl->GetXmax())); |
| 63 | + fW_data->Add(new TH2F(Form("%sCorr", tnd), ";channel;amplitude", ChIDBin, 0, ChIDBin, sAmpl->GetNbins(), sAmpl->GetXmin(), sAmpl->GetXmax())); |
| 64 | + |
| 65 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C", "x", 2), ";Centrality;Qx_{2}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 66 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C", "y", 2), ";Centrality;Qy_{2}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 67 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C", "x", 3), ";Centrality;Qx_{3}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 68 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C", "y", 3), ";Centrality;Qy_{3}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 69 | + |
| 70 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_Rec", "x", 2), ";Centrality;Qx_{2}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 71 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_Rec", "y", 2), ";Centrality;Qy_{2}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 72 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_Rec", "x", 3), ";Centrality;Qx_{3}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 73 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_Rec", "y", 3), ";Centrality;Qy_{3}", CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 74 | + |
| 75 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_RecTot", "x", 2), ";Centrality;Qx_{2}", CentBin, 0, CentBin, sqCorVec->GetNbins(), sqCorVec->GetXmin(), sqCorVec->GetXmax())); |
| 76 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_RecTot", "y", 2), ";Centrality;Qy_{2}", CentBin, 0, CentBin, sqCorVec->GetNbins(), sqCorVec->GetXmin(), sqCorVec->GetXmax())); |
| 77 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_RecTot", "x", 3), ";Centrality;Qx_{3}", CentBin, 0, CentBin, sqCorVec->GetNbins(), sqCorVec->GetXmin(), sqCorVec->GetXmax())); |
| 78 | + fW_data->Add(new TH2F(Form("hQ%s%i_FT0C_RecTot", "y", 3), ";Centrality;Qy_{3}", CentBin, 0, CentBin, sqCorVec->GetNbins(), sqCorVec->GetXmin(), sqCorVec->GetXmax())); |
| 79 | +}; |
| 80 | + |
| 81 | +void FFitWeights::FillFT0(std::size_t iCh, float amplitude, float GainCst) |
| 82 | +{ |
| 83 | + TObjArray* tar{nullptr}; |
| 84 | + |
| 85 | + tar = fW_data; |
| 86 | + if (!tar) |
| 87 | + return; |
| 88 | + |
| 89 | + TH2F* th2 = reinterpret_cast<TH2F*>(tar->FindObject("FT0Ampl")); |
| 90 | + if (!th2) { |
| 91 | + tar->Add(new TH2F("FT0Ampl", ";channel;amplitude", ChIDBin, 0, ChIDBin, sAmpl->GetNbins(), sAmpl->GetXmin(), sAmpl->GetXmax())); |
| 92 | + th2 = reinterpret_cast<TH2F*>(tar->At(tar->GetEntries() - 1)); |
| 93 | + } |
| 94 | + th2->Fill(iCh, amplitude); |
| 95 | + |
| 96 | + TH2F* th2Cor = reinterpret_cast<TH2F*>(tar->FindObject("FT0AmplCorr")); |
| 97 | + if (!th2Cor) { |
| 98 | + tar->Add(new TH2F("FT0AmplCorr", ";channel;amplitude", ChIDBin, 0, ChIDBin, sAmpl->GetNbins(), sAmpl->GetXmin(), sAmpl->GetXmax())); |
| 99 | + th2Cor = reinterpret_cast<TH2F*>(tar->At(tar->GetEntries() - 1)); |
| 100 | + } |
| 101 | + th2Cor->Fill(iCh, amplitude / GainCst); |
| 102 | +}; |
| 103 | + |
| 104 | +void FFitWeights::FillQ(float mult, float vec, int nHarm, const char* coord, const char* qType) |
| 105 | +{ |
| 106 | + TObjArray* tar{nullptr}; |
| 107 | + |
| 108 | + tar = fW_data; |
| 109 | + if (!tar) |
| 110 | + return; |
| 111 | + |
| 112 | + TH2F* th2 = reinterpret_cast<TH2F*>(tar->FindObject(Form("hQ%s%i_FT0C%s", coord, nHarm, qType))); |
| 113 | + if (!th2) { |
| 114 | + tar->Add(new TH2F(Form("hQ%s%i_FT0C%s", coord, nHarm, qType), Form(";Centrality;Q%s_{%i}", coord, nHarm), CentBin, 0, CentBin, sqVec->GetNbins(), sqVec->GetXmin(), sqVec->GetXmax())); |
| 115 | + th2 = reinterpret_cast<TH2F*>(tar->At(tar->GetEntries() - 1)); |
| 116 | + } |
| 117 | + th2->Fill(mult, vec); |
| 118 | +}; |
| 119 | + |
| 120 | +void FFitWeights::CreateGain() |
| 121 | +{ |
| 122 | + vGain.clear(); |
| 123 | + |
| 124 | + TH1D* h1; |
| 125 | + if (fW_data->GetEntries() < 1) |
| 126 | + return; |
| 127 | + |
| 128 | + TH2F* hGain = reinterpret_cast<TH2F*>(fW_data->At(0)->Clone("FT0Ampl")); |
| 129 | + double vMean{0}; // = hGain->GetMean(2); |
| 130 | + // c-side first bin ich: 97 (last 208)' |
| 131 | + // gain split for c-side 144 |
| 132 | + hGain->GetXaxis()->SetRangeUser(96, 144); |
| 133 | + float vMeanC_inner = hGain->GetMean(2); |
| 134 | + |
| 135 | + hGain->GetXaxis()->SetRangeUser(144, 208); |
| 136 | + float vMeanC_outer = hGain->GetMean(2); |
| 137 | + |
| 138 | + hGain->GetXaxis()->SetRangeUser(0, -1); |
| 139 | + |
| 140 | + for (int iCh{0}; iCh < hGain->GetNbinsX(); iCh++) { |
| 141 | + h1 = static_cast<TH1D*>(hGain->ProjectionY(Form("proj%i", iCh), iCh, iCh)); |
| 142 | + double mean = h1->GetMean(); |
| 143 | + double meanErr = h1->GetMeanError(); |
| 144 | + |
| 145 | + if (iCh > 95 && iCh < 144) |
| 146 | + vMean = vMeanC_inner; |
| 147 | + else if (iCh > 144) |
| 148 | + vMean = vMeanC_outer; |
| 149 | + double fWeight = mean / vMean; |
| 150 | + |
| 151 | + if (fWeight > 0) { |
| 152 | + vGain.push_back(fWeight); |
| 153 | + } else { |
| 154 | + vGain.push_back(1.0); |
| 155 | + } |
| 156 | + |
| 157 | + TObjArray* tar = fW_data; |
| 158 | + if (!tar) |
| 159 | + return; |
| 160 | + |
| 161 | + fW_data->Add(new TH1F("FT0MultCorr", ";channel", ChIDBin, 0, ChIDBin)); |
| 162 | + TH1F* htmp = reinterpret_cast<TH1F*>(tar->FindObject("FT0MultCorr")); |
| 163 | + if (!htmp) |
| 164 | + return; |
| 165 | + |
| 166 | + htmp->SetBinContent(iCh, mean); |
| 167 | + htmp->SetBinError(iCh, meanErr); |
| 168 | + } |
| 169 | + |
| 170 | + // note to self if FT0A is implemented this has to be done differently |
| 171 | +}; |
| 172 | + |
| 173 | +std::vector<float> FFitWeights::GetGain() |
| 174 | +{ |
| 175 | + return vGain; |
| 176 | +}; |
| 177 | + |
| 178 | +void FFitWeights::CreateRecenter(const char* xy) |
| 179 | +{ |
| 180 | + if (fW_data->GetEntries() < 1) |
| 181 | + return; |
| 182 | + |
| 183 | + TObjArray* tar{nullptr}; |
| 184 | + |
| 185 | + tar = fW_data; |
| 186 | + if (!tar) |
| 187 | + return; |
| 188 | + |
| 189 | + for (int nHarm{2}; nHarm <= 3; nHarm++) { |
| 190 | + fW_data->Add(new TH1F(Form("havgQ%s%i_FT0C", xy, nHarm), "", CentBin, 0, CentBin)); |
| 191 | + TH1F* hRec = reinterpret_cast<TH1F*>(tar->FindObject(Form("havgQ%s%i_FT0C", xy, nHarm))); |
| 192 | + if (!hRec) |
| 193 | + return; |
| 194 | + |
| 195 | + TH2F* hQ = reinterpret_cast<TH2F*>(fW_data->At(0)->Clone(Form("hQ%s%i_FT0C", xy, nHarm))); |
| 196 | + TH1D* h1; |
| 197 | + |
| 198 | + for (int i{1}; i < hQ->GetXaxis()->GetNbins() + 1; i++) { |
| 199 | + h1 = static_cast<TH1D*>(hQ->ProjectionY(Form("proj%i_Q%s%is", i, xy, nHarm), i, i)); |
| 200 | + |
| 201 | + double mean = h1->GetMean(); |
| 202 | + double meanErr = h1->GetMeanError(); |
| 203 | + int binc = hRec->GetXaxis()->GetBinCenter(i); |
| 204 | + |
| 205 | + hRec->SetBinContent(binc, mean); |
| 206 | + hRec->SetBinError(binc, meanErr); |
| 207 | + } |
| 208 | + } |
| 209 | +}; |
| 210 | + |
| 211 | +void FFitWeights::CreateRMS(const char* xy) |
| 212 | +{ |
| 213 | + if (fW_data->GetEntries() < 1) |
| 214 | + return; |
| 215 | + |
| 216 | + TObjArray* tar{nullptr}; |
| 217 | + |
| 218 | + tar = fW_data; |
| 219 | + if (!tar) |
| 220 | + return; |
| 221 | + |
| 222 | + for (int nHarm{2}; nHarm <= 3; nHarm++) { |
| 223 | + fW_data->Add(new TH1F(Form("hrmsQ%s%i_FT0C", xy, nHarm), "", CentBin, 0, CentBin)); |
| 224 | + TH1F* hRec = reinterpret_cast<TH1F*>(tar->FindObject(Form("hrmsQ%s%i_FT0C", xy, nHarm))); |
| 225 | + if (!hRec) |
| 226 | + return; |
| 227 | + |
| 228 | + TH2F* hQ = reinterpret_cast<TH2F*>(fW_data->At(0)->Clone(Form("hQ%s%i_FT0C", xy, nHarm))); |
| 229 | + TH1D* h1; |
| 230 | + |
| 231 | + for (int i{1}; i < hQ->GetXaxis()->GetNbins() + 1; i++) { |
| 232 | + h1 = static_cast<TH1D*>(hQ->ProjectionY(Form("proj%i_Q%s%is", i, xy, nHarm), i, i)); |
| 233 | + |
| 234 | + double mean = h1->GetRMS(); |
| 235 | + double meanErr = h1->GetRMSError(); |
| 236 | + int binc = hRec->GetXaxis()->GetBinCenter(i); |
| 237 | + |
| 238 | + hRec->SetBinContent(binc, mean); |
| 239 | + hRec->SetBinError(binc, meanErr); |
| 240 | + } |
| 241 | + } |
| 242 | +}; |
| 243 | + |
| 244 | +float FFitWeights::GetRecVal(int cent, const char* xy, const int nHarm) |
| 245 | +{ |
| 246 | + TObjArray* tar{nullptr}; |
| 247 | + |
| 248 | + tar = fW_data; |
| 249 | + if (!tar) |
| 250 | + return -999; |
| 251 | + |
| 252 | + TH1F* htmp = reinterpret_cast<TH1F*>(tar->FindObject(Form("havgQ%s%i_FT0C", xy, nHarm))); |
| 253 | + |
| 254 | + return htmp->GetBinContent(cent); |
| 255 | +}; |
| 256 | + |
| 257 | +float FFitWeights::GetRMSVal(int cent, const char* xy, const int nHarm) |
| 258 | +{ |
| 259 | + TObjArray* tar{nullptr}; |
| 260 | + |
| 261 | + tar = fW_data; |
| 262 | + if (!tar) |
| 263 | + return -999; |
| 264 | + |
| 265 | + TH1F* htmp = reinterpret_cast<TH1F*>(tar->FindObject(Form("hrmsQ%s%i_FT0C", xy, nHarm))); |
| 266 | + |
| 267 | + return htmp->GetBinContent(cent); |
| 268 | +}; |
| 269 | + |
| 270 | +TH1F* FFitWeights::GetRecHist(const char* xy, const int nHarm) |
| 271 | +{ |
| 272 | + TObjArray* tar{nullptr}; |
| 273 | + |
| 274 | + tar = fW_data; |
| 275 | + if (!tar) |
| 276 | + return nullptr; |
| 277 | + |
| 278 | + return reinterpret_cast<TH1F*>(tar->FindObject(Form("havgQ%s%i_FT0C", xy, nHarm))); |
| 279 | +}; |
| 280 | + |
| 281 | +TH1F* FFitWeights::GetRmsHist(const char* xy, const int nHarm) |
| 282 | +{ |
| 283 | + TObjArray* tar{nullptr}; |
| 284 | + |
| 285 | + tar = fW_data; |
| 286 | + if (!tar) |
| 287 | + return nullptr; |
| 288 | + |
| 289 | + return reinterpret_cast<TH1F*>(tar->FindObject(Form("hrmsQ%s%i_FT0C", xy, nHarm))); |
| 290 | +}; |
| 291 | + |
| 292 | +// float FFitWeights::EventPlane(const float& x, const float& y, const float& nHarm) { |
| 293 | +// return 1/nHarm * TMath::ATan2(y, x); |
| 294 | +// }; |
0 commit comments