Skip to content

Commit 5bf9a68

Browse files
authored
U
1 parent 676a1ce commit 5bf9a68

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

ALICE3/Core/DelphesO2LutWriter.cxx

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "TVectorD.h"
3434

3535
#include <cstdio>
36-
#include <iostream>
3736
#include <string>
3837

3938
// #define USE_FWD_PARAM
@@ -96,11 +95,11 @@ bool DelphesO2LutWriter::fatSolve(lutEntry_t& lutEntry,
9695
o2::track::TrackParCov trkOut;
9796
const int status = fat.FastTrack(trkIn, trkOut, nch);
9897
if (status <= mAtLeastHits) {
99-
Printf(" --- fatSolve: FastTrack failed --- \n");
98+
LOGF(info, " --- fatSolve: FastTrack failed --- \n");
10099
// tlv.Print();
101100
return false;
102101
}
103-
Printf(" --- fatSolve: FastTrack succeeded %d --- \n", status);
102+
LOGF(info, " --- fatSolve: FastTrack succeeded %d --- \n", status);
104103
// trkOut.print();
105104
lutEntry.valid = true;
106105
lutEntry.itof = fat.GetGoodHitProb(itof);
@@ -176,7 +175,7 @@ bool DelphesO2LutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, floa
176175
const double dcaz_ms = sigma_alpha * r0 * std::cosh(eta);
177176
const double dcaz2 = dca_pos * dca_pos + dcaz_ms * dcaz_ms;
178177

179-
const float Leta = 2.8 / sinh(eta) - 0.01 * r0; // m
178+
const float Leta = 2.8 / std::sinh(eta) - 0.01 * r0; // m
180179
const double relmomres_pos = 10e-6 * pt / 0.3 / Bfield / Leta / Leta * std::sqrt(720. / 15.);
181180

182181
const float relmomres_barrel = std::sqrt(covmbarrel[14]) * pt;
@@ -186,7 +185,7 @@ bool DelphesO2LutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, floa
186185

187186
// interpolate MS contrib (rel resolution 0.4 at eta = 4)
188187
const float relmomres_MS_eta4 = 0.4 / beta * 0.5 / Bfield;
189-
const float relmomres_MS = relmomres_MS_eta4 * pow(relmomres_MS_eta4 / relmomres_MS_barrel, (std::fabs(eta) - 4.) / (4. - etaMaxBarrel));
188+
const float relmomres_MS = relmomres_MS_eta4 * std::pow(relmomres_MS_eta4 / relmomres_MS_barrel, (std::fabs(eta) - 4.) / (4. - etaMaxBarrel));
190189
const float momres_tot = pt * std::sqrt(relmomres_pos * relmomres_pos + relmomres_MS * relmomres_MS); // total absolute mom reso
191190

192191
// Fill cov matrix diag
@@ -205,7 +204,7 @@ bool DelphesO2LutWriter::fwdPara(lutEntry_t& lutEntry, float pt, float eta, floa
205204
// Check that all numbers are numbers
206205
for (int i = 0; i < 15; ++i) {
207206
if (std::isnan(lutEntry.covm[i])) {
208-
Printf(" --- lutEntry.covm[%d] is NaN", i);
207+
LOGF(info, " --- lutEntry.covm[%d] is NaN", i);
209208
return false;
210209
}
211210
}
@@ -216,14 +215,14 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si
216215
{
217216

218217
if (useFlatDipole && useDipole) {
219-
Printf("Both dipole and dipole flat flags are on, please use only one of them");
218+
LOGF(info, "Both dipole and dipole flat flags are on, please use only one of them");
220219
return;
221220
}
222221

223222
// output file
224223
std::ofstream lutFile(filename, std::ofstream::binary);
225224
if (!lutFile.is_open()) {
226-
Printf("Did not manage to open output file!!");
225+
LOGF(info, "Did not manage to open output file!!");
227226
return;
228227
}
229228

@@ -234,7 +233,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si
234233
lutHeader.mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
235234
const int q = std::abs(TDatabasePDG::Instance()->GetParticle(pdg)->Charge()) / 3;
236235
if (q <= 0) {
237-
Printf("Negative or null charge (%f) for pdg code %i. Fix the charge!", TDatabasePDG::Instance()->GetParticle(pdg)->Charge(), pdg);
236+
LOGF(info, "Negative or null charge (%f) for pdg code %i. Fix the charge!", TDatabasePDG::Instance()->GetParticle(pdg)->Charge(), pdg);
238237
return;
239238
}
240239
lutHeader.field = field;
@@ -267,23 +266,23 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si
267266
int successfullCalls = 0;
268267
int failedCalls = 0;
269268
for (int inch = 0; inch < nnch; ++inch) {
270-
Printf(" --- writing nch = %d/%d", inch, nnch);
269+
LOGF(info, " --- writing nch = %d/%d", inch, nnch);
271270
auto nch = lutHeader.nchmap.eval(inch);
272271
lutEntry.nch = nch;
273272
fat.SetdNdEtaCent(nch);
274273
for (int irad = 0; irad < nrad; ++irad) {
275-
Printf(" --- writing irad = %d/%d", irad, nrad);
274+
LOGF(info, " --- writing irad = %d/%d", irad, nrad);
276275
for (int ieta = 0; ieta < neta; ++ieta) {
277-
Printf(" --- writing ieta = %d/%d", ieta, neta);
276+
LOGF(info, " --- writing ieta = %d/%d", ieta, neta);
278277
auto eta = lutHeader.etamap.eval(ieta);
279278
lutEntry.eta = lutHeader.etamap.eval(ieta);
280279
for (int ipt = 0; ipt < npt; ++ipt) {
281280
nCalls++;
282-
Printf(" --- writing ipt = %d/%d", ipt, npt);
281+
LOGF(info, " --- writing ipt = %d/%d", ipt, npt);
283282
lutEntry.pt = lutHeader.ptmap.eval(ipt);
284283
lutEntry.valid = true;
285284
if (std::fabs(eta) <= etaMaxBarrel) { // full lever arm ends at etaMaxBarrel
286-
Printf("Solving in the barrel");
285+
LOGF(info, "Solving in the barrel");
287286
// printf(" --- fatSolve: pt = %f, eta = %f, mass = %f, field=%f \n", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field);
288287
successfullCalls++;
289288
if (!fatSolve(lutEntry, lutEntry.pt, lutEntry.eta, lutHeader.mass, itof, otof, q)) {
@@ -298,7 +297,7 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si
298297
failedCalls++;
299298
}
300299
} else {
301-
Printf("Solving outside the barrel");
300+
LOGF(info, "Solving outside the barrel");
302301
// printf(" --- fwdSolve: pt = %f, eta = %f, mass = %f, field=%f \n", lutEntry.pt, lutEntry.eta, lutHeader.mass, lutHeader.field);
303302
lutEntry.eff = 1.;
304303
lutEntry.eff2 = 1.;
@@ -329,16 +328,16 @@ void DelphesO2LutWriter::lutWrite(const char* filename, int pdg, float field, si
329328
failedCalls++;
330329
}
331330
}
332-
Printf("Diagonalizing");
331+
LOGF(info, "Diagonalizing");
333332
diagonalise(lutEntry);
334-
Printf("Writing");
333+
LOGF(info, "Writing");
335334
lutFile.write(reinterpret_cast<char*>(&lutEntry), sizeof(lutEntry_t));
336335
}
337336
}
338337
}
339338
}
340-
Printf(" --- finished writing LUT file %s", filename);
341-
Printf(" --- successfull calls: %d/%d, failed calls: %d/%d", successfullCalls, nCalls, failedCalls, nCalls);
339+
LOGF(info, " --- finished writing LUT file %s", filename);
340+
LOGF(info, " --- successfull calls: %d/%d, failed calls: %d/%d", successfullCalls, nCalls, failedCalls, nCalls);
342341
lutFile.close();
343342
}
344343

@@ -409,52 +408,52 @@ TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int
409408
g->SetTitle(Form("LUT for %s, pdg %d, vs %d, what %d", filename, pdg, vs, what));
410409
switch (vs) {
411410
case kNch:
412-
Printf(" --- vs = kNch");
411+
LOGF(info, " --- vs = kNch");
413412
g->GetXaxis()->SetTitle("Nch");
414413
break;
415414
case kEta:
416-
Printf(" --- vs = kEta");
415+
LOGF(info, " --- vs = kEta");
417416
g->GetXaxis()->SetTitle("#eta");
418417
break;
419418
case kPt:
420-
Printf(" --- vs = kPt");
419+
LOGF(info, " --- vs = kPt");
421420
g->GetXaxis()->SetTitle("p_{T} (GeV/c)");
422421
break;
423422
default:
424-
Printf(" --- error: unknown vs %d", vs);
423+
LOGF(info, " --- error: unknown vs %d", vs);
425424
return nullptr;
426425
}
427426
switch (what) {
428427
case kEfficiency:
429-
Printf(" --- what = kEfficiency");
428+
LOGF(info, " --- what = kEfficiency");
430429
g->GetYaxis()->SetTitle("Efficiency (%)");
431430
break;
432431
case kEfficiency2:
433-
Printf(" --- what = kEfficiency2");
432+
LOGF(info, " --- what = kEfficiency2");
434433
g->GetYaxis()->SetTitle("Efficiency2 (%)");
435434
break;
436435
case kEfficiencyInnerTOF:
437-
Printf(" --- what = kEfficiencyInnerTOF");
436+
LOGF(info, " --- what = kEfficiencyInnerTOF");
438437
g->GetYaxis()->SetTitle("Inner TOF Efficiency (%)");
439438
break;
440439
case kEfficiencyOuterTOF:
441-
Printf(" --- what = kEfficiencyOuterTOF");
440+
LOGF(info, " --- what = kEfficiencyOuterTOF");
442441
g->GetYaxis()->SetTitle("Outer TOF Efficiency (%)");
443442
break;
444443
case kPtResolution:
445-
Printf(" --- what = kPtResolution");
444+
LOGF(info, " --- what = kPtResolution");
446445
g->GetYaxis()->SetTitle("p_{T} Resolution (%)");
447446
break;
448447
case kRPhiResolution:
449-
Printf(" --- what = kRPhiResolution");
448+
LOGF(info, " --- what = kRPhiResolution");
450449
g->GetYaxis()->SetTitle("R#phi Resolution (#mum)");
451450
break;
452451
case kZResolution:
453-
Printf(" --- what = kZResolution");
452+
LOGF(info, " --- what = kZResolution");
454453
g->GetYaxis()->SetTitle("Z Resolution (#mum)");
455454
break;
456455
default:
457-
Printf(" --- error: unknown what %d", what);
456+
LOGF(info, " --- error: unknown what %d", what);
458457
return nullptr;
459458
}
460459

@@ -475,7 +474,7 @@ TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int
475474
auto lutEntry = smearer.getLUTEntry(pdg, nch, radius, eta, pt, eff);
476475
if (!lutEntry->valid || lutEntry->eff == 0.) {
477476
if (!canBeInvalid) {
478-
Printf(" --- warning: it cannot be invalid");
477+
LOGF(info, " --- warning: it cannot be invalid");
479478
}
480479
continue;
481480
}
@@ -508,16 +507,16 @@ TGraph* DelphesO2LutWriter::lutRead(const char* filename, int pdg, int what, int
508507
val = lutEntry->otof * 100.; // efficiency (%)
509508
break;
510509
case kPtResolution:
511-
val = sqrt(lutEntry->covm[14]) * lutEntry->pt * 100.; // pt resolution (%)
510+
val = std::sqrt(lutEntry->covm[14]) * lutEntry->pt * 100.; // pt resolution (%)
512511
break;
513512
case kRPhiResolution:
514-
val = sqrt(lutEntry->covm[0]) * 1.e4; // rphi resolution (um)
513+
val = std::sqrt(lutEntry->covm[0]) * 1.e4; // rphi resolution (um)
515514
break;
516515
case kZResolution:
517-
val = sqrt(lutEntry->covm[1]) * 1.e4; // z resolution (um)
516+
val = std::sqrt(lutEntry->covm[1]) * 1.e4; // z resolution (um)
518517
break;
519518
default:
520-
Printf(" --- error: unknown what %d", what);
519+
LOGF(info, " --- error: unknown what %d", what);
521520
break;
522521
}
523522
g->AddPoint(cen, val);

ALICE3/Core/DelphesO2LutWriter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class DelphesO2LutWriter
4343
void setBinningEta(bool log, int nbins, float min, float max) { mEtaBinning = {log, nbins, min, max}; }
4444
void setBinningPt(bool log, int nbins, float min, float max) { mPtBinning = {log, nbins, min, max}; }
4545
void setEtaMaxBarrel(float eta) { etaMaxBarrel = eta; }
46-
void SetAtLeastHits(int n) { mAtLeastHits = n; }
47-
void SetAtLeastCorr(int n) { mAtLeastCorr = n; }
48-
void SetAtLeastFake(int n) { mAtLeastFake = n; }
46+
void setAtLeastHits(int n) { mAtLeastHits = n; }
47+
void setAtLeastCorr(int n) { mAtLeastCorr = n; }
48+
void setAtLeastFake(int n) { mAtLeastFake = n; }
4949
bool fatSolve(lutEntry_t& lutEntry,
5050
float pt = 0.1,
5151
float eta = 0.0,
@@ -55,7 +55,7 @@ class DelphesO2LutWriter
5555
int q = 1,
5656
const float nch = 1);
5757

58-
void Print() const;
58+
void print() const;
5959
bool fwdSolve(float* covm, float pt = 0.1, float eta = 0.0, float mass = 0.13957000);
6060
bool fwdPara(lutEntry_t& lutEntry, float pt = 0.1, float eta = 0.0, float mass = 0.13957000, float Bfield = 0.5);
6161
void lutWrite(const char* filename = "lutCovm.dat", int pdg = 211, float field = 0.2, size_t itof = 0, size_t otof = 0);

0 commit comments

Comments
 (0)