Skip to content

Commit 10318ba

Browse files
committed
Added some eff histograms
1 parent 14475d4 commit 10318ba

1 file changed

Lines changed: 94 additions & 58 deletions

File tree

PWGCF/EbyEFluctuations/Tasks/netchargeFluctuations.cxx

Lines changed: 94 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,12 @@ struct NetchargeFluctuations {
6262

6363
// Macro to define configurable parameters with default values and help text
6464

65-
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP};
65+
#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) \
66+
Configurable<TYPE> NAME{#NAME, (DEFAULT), (HELP)};
6667

6768
// Services for PDG and CCDB (Calibration and Condition Database)
68-
Service<o2::framework::O2DatabasePDG> pdgService; // Particle data group service
69-
Service<o2::ccdb::BasicCCDBManager> ccdb; // CCDB manager service
69+
Service<o2::framework::O2DatabasePDG> pdgService{}; // Particle data group service
70+
Service<o2::ccdb::BasicCCDBManager> ccdb{}; // CCDB manager service
7071

7172
// Random number generator for statistical fluctuations, initialized with seed 0
7273
TRandom3* fRndm = new TRandom3(0);
@@ -401,31 +402,30 @@ struct NetchargeFluctuations {
401402

402403
cfgFunCoeff.fMultPVT0CCutLow =
403404
new TF1("fMultPVT0CCutLow",
404-
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)",
405-
0, 100);
406-
cfgFunCoeff.fMultPVT0CCutLow->SetParameters(&(cfgFunCoeff.multPVT0CCutPars[0]));
405+
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)", 0, 100);
406+
cfgFunCoeff.fMultPVT0CCutLow->SetParameters(cfgFunCoeff.multPVT0CCutPars.data());
407407

408408
// Upper cut function: 4th-order polynomial plus 3.5 sigma deviation
409409
cfgFunCoeff.fMultPVT0CCutHigh =
410410
new TF1("fMultPVT0CCutHigh",
411411
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)",
412412
0, 100);
413-
cfgFunCoeff.fMultPVT0CCutHigh->SetParameters(&(cfgFunCoeff.multPVT0CCutPars[0]));
413+
cfgFunCoeff.fMultPVT0CCutHigh->SetParameters(cfgFunCoeff.multPVT0CCutPars.data());
414414

415415
// --- Initialize globalTracks vs FT0C multiplicity cut functions ---
416416
// Lower cut function
417417
cfgFunCoeff.fMultGlobalFT0CCutLow =
418418
new TF1("fMultGlobalFT0CCutLow",
419419
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x - 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)",
420420
0, 100);
421-
cfgFunCoeff.fMultGlobalFT0CCutLow->SetParameters(&(cfgFunCoeff.multGlobalFT0CPars[0]));
421+
cfgFunCoeff.fMultGlobalFT0CCutLow->SetParameters(cfgFunCoeff.multGlobalFT0CPars.data());
422422

423423
// Upper cut function
424424
cfgFunCoeff.fMultGlobalFT0CCutHigh =
425425
new TF1("fMultGlobalFT0CCutHigh",
426426
"[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x + 3.5*([5]+[6]*x+[7]*x*x+[8]*x*x*x+[9]*x*x*x*x)",
427427
0, 100);
428-
cfgFunCoeff.fMultGlobalFT0CCutHigh->SetParameters(&(cfgFunCoeff.multGlobalFT0CPars[0]));
428+
cfgFunCoeff.fMultGlobalFT0CCutHigh->SetParameters(cfgFunCoeff.multGlobalFT0CPars.data());
429429

430430
// --- Initialize globalTracks vs PV multiplicity cut functions ---
431431
// Lower cut: linear + cubic term minus 3.5 sigma
@@ -434,24 +434,24 @@ struct NetchargeFluctuations {
434434
new TF1("fMultGlobalPVCutLow",
435435
"[0]+[1]*x - 3.5*([2]+[3]*x+[4]*x*x+[5]*x*x*x)",
436436
0, 100);
437-
cfgFunCoeff.fMultGlobalPVCutLow->SetParameters(&(cfgFunCoeff.multGlobalPVCutPars[0]));
437+
cfgFunCoeff.fMultGlobalPVCutLow->SetParameters(cfgFunCoeff.multGlobalPVCutPars.data());
438438

439439
// Upper cut: linear + cubic term plus 3.5 sigma
440440
cfgFunCoeff.fMultGlobalPVCutHigh =
441441
new TF1("fMultGlobalPVCutHigh",
442442
"[0]+[1]*x + 3.5*([2]+[3]*x+[4]*x*x+[5]*x*x*x)",
443443
0, 100);
444-
cfgFunCoeff.fMultGlobalPVCutHigh->SetParameters(&(cfgFunCoeff.multGlobalPVCutPars[0]));
444+
cfgFunCoeff.fMultGlobalPVCutHigh->SetParameters(cfgFunCoeff.multGlobalPVCutPars.data());
445445

446446
// --- Load efficiency histogram from CCDB
447447
if (cfgLoadEff) {
448448
ccdb->setURL(cfgUrlCCDB.value);
449449
ccdb->setCaching(true);
450450
ccdb->setLocalObjectValidityChecking();
451451

452-
TList* list = ccdb->getForTimeStamp<TList>(cfgPathCCDB.value, 1);
453-
efficiencyPos = reinterpret_cast<TH2D*>(list->FindObject("efficiency_Pos"));
454-
efficiencyNeg = reinterpret_cast<TH2D*>(list->FindObject("efficiency_Neg"));
452+
auto* list = ccdb->getForTimeStamp<TList>(cfgPathCCDB.value, 1);
453+
efficiencyPos = static_cast<TH2D*>(list->FindObject("efficiency_Pos"));
454+
efficiencyNeg = static_cast<TH2D*>(list->FindObject("efficiency_Neg"));
455455
// Log fatal error if efficiency histogram is not found
456456
if (!efficiencyPos || !efficiencyNeg) {
457457
LOGF(info, "FATAL!! Could not find required histograms in CCDB");
@@ -682,8 +682,9 @@ struct NetchargeFluctuations {
682682
for (const auto& track : tracks) {
683683

684684
fillBeforeQA(track);
685-
if (!selTrack(track))
685+
if (!selTrack(track)) {
686686
continue;
687+
}
687688

688689
double eff = getEfficiency(track.pt(), track.eta(), track.sign());
689690
if (eff < threshold) {
@@ -781,8 +782,9 @@ struct NetchargeFluctuations {
781782

782783
for (const auto& track : inputTracks) {
783784
fillBeforeQA(track);
784-
if (!selTrack(track))
785+
if (!selTrack(track)) {
785786
continue;
787+
}
786788
nch += 1;
787789
fillAfterQA(track);
788790

@@ -806,8 +808,9 @@ struct NetchargeFluctuations {
806808
histogramRegistry.fill(HIST("QA/cent_hPt"), cent, track.pt());
807809

808810
double eff = getEfficiency(track.pt(), track.eta(), track.sign());
809-
if (eff < threshold)
811+
if (eff < threshold) {
810812
continue;
813+
}
811814
double weight = 1.0 / eff;
812815
histogramRegistry.fill(HIST("data/hPt_cor"), track.pt(), weight);
813816
histogramRegistry.fill(HIST("data/hEta_cor"), track.eta(), weight);
@@ -847,31 +850,37 @@ struct NetchargeFluctuations {
847850
int posGen = 0, negGen = 0, posNegGen = 0, termNGen = 0, termPGen = 0, nchGen = 0;
848851

849852
const auto& mccolgen = coll.template mcCollision_as<aod::McCollisions>();
850-
if (std::abs(mccolgen.posZ()) >= vertexZcut)
853+
if (std::abs(mccolgen.posZ()) >= vertexZcut) {
851854
return;
855+
}
852856
const auto& mcpartgen = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolgen.globalIndex(), cache);
853857
histogramRegistry.fill(HIST("gen/hVtxZ_after"), mccolgen.posZ());
854858
for (const auto& mcpart : mcpartgen) {
855-
if (std::fabs(mcpart.eta()) >= etaCut)
859+
if (std::fabs(mcpart.eta()) >= etaCut) {
856860
continue;
857-
if (!mcpart.isPhysicalPrimary())
861+
}
862+
if (!mcpart.isPhysicalPrimary()) {
858863
continue;
864+
}
859865
int pid = mcpart.pdgCode();
860-
auto sign = 0;
866+
int sign = 0;
861867
auto* pd = pdgService->GetParticle(pid);
862868
if (pd != nullptr) {
863-
sign = pd->Charge() / 3.;
869+
sign = pd->Charge() / 3;
864870
}
865-
if (sign == 0)
871+
if (sign == 0) {
866872
continue;
873+
}
867874
if (std::abs(pid) != kElectron &&
868875
std::abs(pid) != kMuonMinus &&
869876
std::abs(pid) != kPiPlus &&
870877
std::abs(pid) != kKPlus &&
871-
std::abs(pid) != kProton)
878+
std::abs(pid) != kProton) {
872879
continue;
873-
if (std::fabs(mcpart.eta()) >= etaCut)
880+
}
881+
if (std::fabs(mcpart.eta()) >= etaCut) {
874882
continue;
883+
}
875884
if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut)) {
876885
continue;
877886
}
@@ -935,16 +944,19 @@ struct NetchargeFluctuations {
935944
void calculationDeltaEta(C const& coll, T const& tracks, float deta1, float deta2)
936945
{
937946
float cent = -1, mult = -1;
938-
if (!selCollision<run>(coll, cent, mult))
947+
if (!selCollision<run>(coll, cent, mult)) {
939948
return;
949+
}
940950

941951
int globalNch = tracks.size();
942952
int pvTrack = coll.multNTracksPV();
943-
if (cfgEvSelMultCorrelation && !eventSelected(globalNch, pvTrack, cent))
953+
if (cfgEvSelMultCorrelation && !eventSelected(globalNch, pvTrack, cent)) {
944954
return;
955+
}
945956

946-
if (!(cent >= centMin && cent < centMax))
957+
if (!(cent >= centMin && cent < centMax)) {
947958
return;
959+
}
948960
histogramRegistry.fill(HIST("data/delta_eta_cent"), cent);
949961

950962
int fpos = 0, fneg = 0, termp = 0, termn = 0, posneg = 0;
@@ -957,16 +969,19 @@ struct NetchargeFluctuations {
957969

958970
for (const auto& track : tracks) {
959971

960-
if (!selTrack(track))
972+
if (!selTrack(track)) {
961973
continue;
974+
}
962975

963976
double eta = track.eta();
964-
if (eta < deta1 || eta > deta2)
977+
if (eta < deta1 || eta > deta2) {
965978
continue;
979+
}
966980

967981
double eff = getEfficiency(track.pt(), track.eta(), track.sign());
968-
if (eff < threshold)
982+
if (eff < threshold) {
969983
continue;
984+
}
970985

971986
double weight = 1.0 / eff;
972987

@@ -1046,20 +1061,24 @@ struct NetchargeFluctuations {
10461061
{
10471062
(void)mcCollisions;
10481063

1049-
if (!coll.has_mcCollision())
1064+
if (!coll.has_mcCollision()) {
10501065
return;
1066+
}
10511067

10521068
float cent = -1, mult = -1;
1053-
if (!selCollision<run>(coll, cent, mult))
1069+
if (!selCollision<run>(coll, cent, mult)) {
10541070
return;
1071+
}
10551072

10561073
int globalNch = inputTracks.size();
10571074
int pvTrack = coll.multNTracksPV();
1058-
if (cfgEvSelMultCorrelation && !eventSelected(globalNch, pvTrack, cent))
1075+
if (cfgEvSelMultCorrelation && !eventSelected(globalNch, pvTrack, cent)) {
10591076
return;
1077+
}
10601078

1061-
if (!(cent >= centMin && cent < centMax))
1079+
if (!(cent >= centMin && cent < centMax)) {
10621080
return;
1081+
}
10631082
histogramRegistry.fill(HIST("data/delta_eta_cent"), cent);
10641083

10651084
float deltaEtaWidth = deta2 - deta1 + 1e-5f;
@@ -1071,17 +1090,20 @@ struct NetchargeFluctuations {
10711090
double nchCor = 0.0, termpW = 0.0, termnW = 0.0, posnegW = 0.0;
10721091

10731092
for (const auto& track : inputTracks) {
1074-
if (!selTrack(track))
1093+
if (!selTrack(track)) {
10751094
continue;
1095+
}
10761096
double eta = track.eta();
1077-
if (eta < deta1 || eta > deta2)
1097+
if (eta < deta1 || eta > deta2) {
10781098
continue;
1099+
}
10791100

10801101
histogramRegistry.fill(HIST("data/delta_eta_eta"), eta);
10811102
double eff = getEfficiency(track.pt(), track.eta(), track.sign());
10821103

1083-
if (eff < threshold)
1104+
if (eff < threshold) {
10841105
continue;
1106+
}
10851107
double weight = 1.0 / eff;
10861108
nch += 1;
10871109
nchCor += weight;
@@ -1130,39 +1152,46 @@ struct NetchargeFluctuations {
11301152

11311153
const auto& mccolgen = coll.template mcCollision_as<aod::McCollisions>();
11321154

1133-
if (std::abs(mccolgen.posZ()) >= vertexZcut)
1155+
if (std::abs(mccolgen.posZ()) >= vertexZcut) {
11341156
return;
1157+
}
11351158

11361159
const auto& mcpartgen = mcParticles.sliceByCached(aod::mcparticle::mcCollisionId, mccolgen.globalIndex(), cache);
11371160

11381161
int posGen = 0, negGen = 0, posNegGen = 0, termNGen = 0, termPGen = 0, nchGen = 0;
11391162
for (const auto& mcpart : mcpartgen) {
1140-
if (!mcpart.isPhysicalPrimary())
1163+
if (!mcpart.isPhysicalPrimary()) {
11411164
continue;
1165+
}
11421166

11431167
int pid = mcpart.pdgCode();
11441168
auto sign = 0;
11451169
auto* pd = pdgService->GetParticle(pid);
11461170
if (pd != nullptr) {
1147-
sign = pd->Charge() / 3.;
1171+
sign = pd->Charge() / 3;
11481172
}
1149-
if (sign == 0)
1173+
if (sign == 0) {
11501174
continue;
1175+
}
11511176
if (std::abs(pid) != kElectron &&
11521177
std::abs(pid) != kMuonMinus &&
11531178
std::abs(pid) != kPiPlus &&
11541179
std::abs(pid) != kKPlus &&
1155-
std::abs(pid) != kProton)
1180+
std::abs(pid) != kProton) {
11561181
continue;
1182+
}
11571183

1158-
if (std::fabs(mcpart.eta()) >= etaCut)
1184+
if (std::fabs(mcpart.eta()) >= etaCut) {
11591185
continue;
1160-
if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut))
1186+
}
1187+
if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut)) {
11611188
continue;
1189+
}
11621190

11631191
double mcEta = mcpart.eta();
1164-
if (mcEta < deta1 || mcEta > deta2)
1192+
if (mcEta < deta1 || mcEta > deta2) {
11651193
continue;
1194+
}
11661195

11671196
histogramRegistry.fill(HIST("gen/delta_eta_eta"), mcpart.eta());
11681197

@@ -1268,7 +1297,7 @@ struct NetchargeFluctuations {
12681297
{
12691298
(void)collision;
12701299
int posGen = 0, negGen = 0, posNegGen = 0, termNGen = 0, termPGen = 0, nchGen = 0;
1271-
int cent = getCentrality(particles);
1300+
auto cent = getCentrality(particles);
12721301

12731302
if (cent < 0) {
12741303
return;
@@ -1283,16 +1312,18 @@ struct NetchargeFluctuations {
12831312
auto sign = 0;
12841313
auto* pd = pdgService->GetParticle(pid);
12851314
if (pd != nullptr) {
1286-
sign = pd->Charge() / 3.;
1315+
sign = pd->Charge() / 3;
12871316
}
1288-
if (sign == 0)
1317+
if (sign == 0) {
12891318
continue;
1319+
}
12901320
if (std::abs(pid) != kElectron &&
12911321
std::abs(pid) != kMuonMinus &&
12921322
std::abs(pid) != kPiPlus &&
12931323
std::abs(pid) != kKPlus &&
1294-
std::abs(pid) != kProton)
1324+
std::abs(pid) != kProton) {
12951325
continue;
1326+
}
12961327

12971328
if (std::fabs(mcpart.eta()) >= etaCut) {
12981329
continue;
@@ -1351,32 +1382,37 @@ struct NetchargeFluctuations {
13511382

13521383
int posGen = 0, negGen = 0, posNegGen = 0, termNGen = 0, termPGen = 0, nchGen = 0;
13531384
for (const auto& mcpart : particles) {
1354-
if (!mcpart.isPhysicalPrimary())
1385+
if (!mcpart.isPhysicalPrimary()) {
13551386
continue;
1356-
1387+
}
13571388
int pid = mcpart.pdgCode();
13581389
auto sign = 0;
13591390
auto* pd = pdgService->GetParticle(pid);
13601391
if (pd != nullptr) {
1361-
sign = pd->Charge() / 3.;
1392+
sign = pd->Charge() / 3;
13621393
}
1363-
if (sign == 0)
1394+
if (sign == 0) {
13641395
continue;
1396+
}
13651397
if (std::abs(pid) != kElectron &&
13661398
std::abs(pid) != kMuonMinus &&
13671399
std::abs(pid) != kPiPlus &&
13681400
std::abs(pid) != kKPlus &&
1369-
std::abs(pid) != kProton)
1401+
std::abs(pid) != kProton) {
13701402
continue;
1403+
}
13711404

1372-
if (std::fabs(mcpart.eta()) >= etaCut)
1405+
if (std::fabs(mcpart.eta()) >= etaCut) {
13731406
continue;
1374-
if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut))
1407+
}
1408+
if ((mcpart.pt() <= ptMinCut) || (mcpart.pt() >= ptMaxCut)) {
13751409
continue;
1410+
}
13761411

13771412
double mcEta = mcpart.eta();
1378-
if (mcEta < deta1 || mcEta > deta2)
1413+
if (mcEta < deta1 || mcEta > deta2) {
13791414
continue;
1415+
}
13801416

13811417
histogramRegistry.fill(HIST("gen/delta_eta_eta"), mcpart.eta());
13821418

0 commit comments

Comments
 (0)