Skip to content

Commit 0c09759

Browse files
committed
PWGEM/Dilepton: update trigger analyses
1 parent c001880 commit 0c09759

File tree

8 files changed

+173
-273
lines changed

8 files changed

+173
-273
lines changed

PWGEM/Dilepton/Core/Dilepton.h

Lines changed: 34 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "Common/CCDB/RCTSelectionFlags.h"
3333
#include "Common/Core/RecoDecay.h"
34+
#include "Common/Core/Zorro.h"
3435
#include "Common/Core/trackUtilities.h"
3536
#include "Tools/ML/MlResponse.h"
3637

@@ -48,7 +49,6 @@
4849
#include "MathUtils/Utils.h"
4950

5051
#include "Math/Vector4D.h"
51-
#include "TH1D.h"
5252
#include "TString.h"
5353

5454
#include <algorithm>
@@ -73,9 +73,6 @@ using namespace o2::aod::pwgem::dilepton::utils::pairutil;
7373
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec>;
7474
using MyCollision = MyCollisions::iterator;
7575

76-
using MyCollisionsWithSWT = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec, aod::EMSWTriggerBits>;
77-
using MyCollisionWithSWT = MyCollisionsWithSWT::iterator;
78-
7976
using MyElectrons = soa::Join<aod::EMPrimaryElectrons, aod::EMPrimaryElectronEMEventIds, aod::EMAmbiguousElectronSelfIds, aod::EMPrimaryElectronsPrefilterBit, aod::EMPrimaryElectronsPrefilterBitDerived>;
8077
using MyElectron = MyElectrons::iterator;
8178
using FilteredMyElectrons = soa::Filtered<MyElectrons>;
@@ -116,7 +113,6 @@ struct Dilepton {
116113
ConfigurableAxis ConfCentBins{"ConfCentBins", {VARIABLE_WIDTH, 0.0f, 5.0f, 10.0f, 20.0f, 30.0f, 40.0f, 50.0f, 60.0f, 70.0f, 80.0f, 90.0f, 100.f, 999.f}, "Mixing bins - centrality"};
117114
ConfigurableAxis ConfEPBins{"ConfEPBins", {16, -M_PI / 2, +M_PI / 2}, "Mixing bins - event plane angle"};
118115
ConfigurableAxis ConfOccupancyBins{"ConfOccupancyBins", {VARIABLE_WIDTH, -1, 1e+10}, "Mixing bins - occupancy"};
119-
Configurable<std::string> cfg_swt_name{"cfg_swt_name", "fHighTrackMult", "desired software trigger name"}; // 1 trigger name per 1 task. fHighTrackMult, fHighFt0Mult
120116
// Configurable<uint16_t> cfgNumContribMin{"cfgNumContribMin", 0, "min. numContrib"};
121117
// Configurable<uint16_t> cfgNumContribMax{"cfgNumContribMax", 65000, "max. numContrib"};
122118
Configurable<bool> cfgApplyWeightTTCA{"cfgApplyWeightTTCA", false, "flag to apply weighting by 1/N"};
@@ -294,9 +290,17 @@ struct Dilepton {
294290
Configurable<std::vector<int>> requiredMFTDisks{"requiredMFTDisks", std::vector<int>{0}, "hit map on MFT disks [0,1,2,3,4]. logical-OR of each double-sided disk"};
295291
} dimuoncuts;
296292

293+
struct : ConfigurableGroup {
294+
std::string prefix = "zorroGroup";
295+
Configurable<std::string> cfg_swt_name{"cfg_swt_name", "fLMeeIMR", "desired software trigger name"}; // 1 trigger per 1 task
296+
o2::framework::Configurable<std::string> ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "EventFiltering/Zorro/", "ccdb path for ZORRO objects"};
297+
Configurable<uint64_t> bcMarginForSoftwareTrigger{"bcMarginForSoftwareTrigger", 100, "Number of BCs of margin for software triggers"};
298+
} zorroGroup;
299+
297300
o2::aod::rctsel::RCTFlagsChecker rctChecker;
298301
// o2::ccdb::CcdbApi ccdbApi;
299302
Service<o2::ccdb::BasicCCDBManager> ccdb;
303+
Zorro zorro;
300304
int mRunNumber;
301305
float d_bz;
302306

@@ -423,15 +427,6 @@ struct Dilepton {
423427
fRegistry.addClone("Event/before/hCollisionCounter", "Event/norm/hCollisionCounter");
424428
fRegistry.add("Event/norm/hZvtx", "hZvtx;Z_{vtx} (cm)", kTH1D, {{100, -50, +50}}, false);
425429
}
426-
if (doprocessTriggerAnalysis) {
427-
LOGF(info, "Trigger analysis is enabled. Desired trigger name = %s", cfg_swt_name.value.data());
428-
fRegistry.add("NormTrigger/hInspectedTVX", "inspected TVX;run number;N_{TVX}", kTProfile, {{80000, 520000.5, 600000.5}}, true);
429-
fRegistry.add("NormTrigger/hScalers", "trigger counter before DS;run number;counter", kTProfile, {{80000, 520000.5, 600000.5}}, true);
430-
fRegistry.add("NormTrigger/hSelections", "trigger counter after DS;run number;counter", kTProfile, {{80000, 520000.5, 600000.5}}, true);
431-
auto hTriggerCounter = fRegistry.add<TH2>("NormTrigger/hTriggerCounter", Form("trigger counter of %s;run number;", cfg_swt_name.value.data()), kTH2D, {{80000, 520000.5, 600000.5}, {2, -0.5, 1.5}}, false);
432-
hTriggerCounter->GetYaxis()->SetBinLabel(1, "Analyzed Trigger");
433-
hTriggerCounter->GetYaxis()->SetBinLabel(2, "Analyzed TOI");
434-
}
435430
if (doprocessBC) {
436431
auto hTVXCounter = fRegistry.add<TH1>("BC/hTVXCounter", "TVX counter", kTH1D, {{6, -0.5f, 5.5f}});
437432
hTVXCounter->GetXaxis()->SetBinLabel(1, "TVX");
@@ -443,7 +438,7 @@ struct Dilepton {
443438
}
444439
}
445440

446-
template <typename TCollision>
441+
template <bool isTriggerAnalysis, typename TCollision>
447442
void initCCDB(TCollision const& collision)
448443
{
449444
if (mRunNumber == collision.runNumber()) {
@@ -482,6 +477,15 @@ struct Dilepton {
482477
d_bz = std::lround(5.f * grpmag->getL3Current() / 30000.f);
483478
LOG(info) << "Retrieved GRP for timestamp " << run3grp_timestamp << " with magnetic field of " << d_bz << " kG";
484479
}
480+
481+
// zorro
482+
if constexpr (isTriggerAnalysis) {
483+
zorro.setCCDBpath(zorroGroup.ccdbPathSoftwareTrigger);
484+
zorro.setBCtolerance(zorroGroup.bcMarginForSoftwareTrigger); // this does nothing.
485+
zorro.initCCDB(ccdb.service, collision.runNumber(), collision.timestamp(), zorroGroup.cfg_swt_name.value);
486+
zorro.populateHistRegistry(fRegistry, collision.runNumber());
487+
}
488+
485489
mRunNumber = collision.runNumber();
486490
fDielectronCut.SetTrackPhiPositionRange(dielectroncuts.cfg_min_phiposition_track, dielectroncuts.cfg_max_phiposition_track, dielectroncuts.cfgRefR, d_bz, dielectroncuts.cfg_mirror_phi_track);
487491

@@ -1152,19 +1156,14 @@ struct Dilepton {
11521156
void runPairing(TCollisions const& collisions, TLeptons const& posTracks, TLeptons const& negTracks, TPresilce const& perCollision, TCut const& cut, TAllTracks const& tracks)
11531157
{
11541158
for (const auto& collision : collisions) {
1155-
initCCDB(collision);
1159+
initCCDB<isTriggerAnalysis>(collision);
1160+
11561161
const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()};
11571162
float centrality = centralities[cfgCentEstimator];
11581163
if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) {
11591164
continue;
11601165
}
11611166

1162-
if constexpr (isTriggerAnalysis) {
1163-
if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) {
1164-
continue;
1165-
}
1166-
}
1167-
11681167
std::array<float, 2> q2ft0m = {collision.q2xft0m(), collision.q2yft0m()};
11691168
std::array<float, 2> q2ft0a = {collision.q2xft0a(), collision.q2yft0a()};
11701169
std::array<float, 2> q2ft0c = {collision.q2xft0c(), collision.q2yft0c()};
@@ -1210,6 +1209,12 @@ struct Dilepton {
12101209
continue;
12111210
}
12121211

1212+
if constexpr (isTriggerAnalysis) {
1213+
if (!zorro.isSelected(collision.globalBC(), zorroGroup.bcMarginForSoftwareTrigger)) { // triggered event
1214+
continue;
1215+
}
1216+
}
1217+
12131218
if (nmod == 2) {
12141219
o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, 2>(&fRegistry, collision);
12151220
} else if (nmod == 3) {
@@ -1403,17 +1408,17 @@ struct Dilepton {
14031408
passed_pairIds.reserve(posTracks.size() * negTracks.size());
14041409

14051410
for (const auto& collision : collisions) {
1406-
initCCDB(collision);
1411+
initCCDB<isTriggerAnalysis>(collision);
14071412
const float centralities[3] = {collision.centFT0M(), collision.centFT0A(), collision.centFT0C()};
14081413
if (centralities[cfgCentEstimator] < cfgCentMin || cfgCentMax < centralities[cfgCentEstimator]) {
14091414
continue;
14101415
}
14111416

1412-
if constexpr (isTriggerAnalysis) {
1413-
if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) {
1414-
continue;
1415-
}
1416-
}
1417+
// if constexpr (isTriggerAnalysis) { // don't call this here. this causes double counting.
1418+
// if (!zorro.isSelected(collision.globalBC(), zorroGroup.bcMarginForSoftwareTrigger)) { // triggered event
1419+
// continue;
1420+
// }
1421+
// }
14171422

14181423
std::array<float, 2> q2ft0m = {collision.q2xft0m(), collision.q2yft0m()};
14191424
std::array<float, 2> q2ft0a = {collision.q2xft0a(), collision.q2yft0a()};
@@ -1522,8 +1527,7 @@ struct Dilepton {
15221527
}
15231528
PROCESS_SWITCH(Dilepton, processAnalysis, "run dilepton analysis", true);
15241529

1525-
using FilteredMyCollisionsWithSWT = soa::Filtered<MyCollisionsWithSWT>;
1526-
void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args)
1530+
void processTriggerAnalysis(FilteredMyCollisions const& collisions, Types const&... args)
15271531
{
15281532
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
15291533
auto electrons = std::get<0>(std::tie(args...));
@@ -1540,25 +1544,6 @@ struct Dilepton {
15401544
}
15411545
map_weight.clear();
15421546
ndf++;
1543-
1544-
// for nomalization
1545-
int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value);
1546-
for (const auto& counter : countersAT) {
1547-
if (counter.isAnalyzed_bit(emswtId)) {
1548-
fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0);
1549-
}
1550-
}
1551-
for (const auto& counter : countersTOI) {
1552-
if (counter.isAnalyzedToI_bit(emswtId)) {
1553-
fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1);
1554-
}
1555-
}
1556-
1557-
for (const auto& info : cefpinfos) {
1558-
fRegistry.fill(HIST("NormTrigger/hInspectedTVX"), info.runNumber(), info.nInspectedTVX());
1559-
fRegistry.fill(HIST("NormTrigger/hScalers"), info.runNumber(), info.nScalers()[emswtId]);
1560-
fRegistry.fill(HIST("NormTrigger/hSelections"), info.runNumber(), info.nSelections()[emswtId]);
1561-
}
15621547
}
15631548
PROCESS_SWITCH(Dilepton, processTriggerAnalysis, "run dilepton analysis on triggered data", false);
15641549

PWGEM/Dilepton/Core/DileptonHadronMPC.h

Lines changed: 22 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
#include "Common/CCDB/RCTSelectionFlags.h"
3434
#include "Common/Core/RecoDecay.h"
35+
#include "Common/Core/Zorro.h"
3536
#include "Common/Core/trackUtilities.h"
3637
#include "Tools/ML/MlResponse.h"
3738

@@ -49,7 +50,6 @@
4950
#include "MathUtils/Utils.h"
5051

5152
#include "Math/Vector4D.h"
52-
#include "TH1D.h"
5353
#include "TString.h"
5454

5555
#include <algorithm>
@@ -74,9 +74,6 @@ using namespace o2::aod::pwgem::dilepton::utils::pairutil;
7474
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent>;
7575
using MyCollision = MyCollisions::iterator;
7676

77-
using MyCollisionsWithSWT = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMSWTriggerBits>;
78-
using MyCollisionWithSWT = MyCollisionsWithSWT::iterator;
79-
8077
using MyElectrons = soa::Join<aod::EMPrimaryElectrons, aod::EMPrimaryElectronEMEventIds, aod::EMAmbiguousElectronSelfIds, aod::EMPrimaryElectronsPrefilterBit, aod::EMPrimaryElectronsPrefilterBitDerived>;
8178
using MyElectron = MyElectrons::iterator;
8279
using FilteredMyElectrons = soa::Filtered<MyElectrons>;
@@ -290,12 +287,20 @@ struct DileptonHadronMPC {
290287
Configurable<uint16_t> cfg_track_bits{"cfg_track_bits", 5765, "required track bits"}; // default:645, loose:0, tight:778
291288
} trackcuts;
292289

290+
struct : ConfigurableGroup {
291+
std::string prefix = "zorroGroup";
292+
Configurable<std::string> cfg_swt_name{"cfg_swt_name", "fLMeeIMR", "desired software trigger name"}; // 1 trigger per 1 task
293+
o2::framework::Configurable<std::string> ccdbPathSoftwareTrigger{"ccdbPathSoftwareTrigger", "EventFiltering/Zorro/", "ccdb path for ZORRO objects"};
294+
Configurable<uint64_t> bcMarginForSoftwareTrigger{"bcMarginForSoftwareTrigger", 100, "Number of BCs of margin for software triggers"};
295+
} zorroGroup;
296+
293297
o2::aod::rctsel::RCTFlagsChecker rctChecker;
294-
o2::ccdb::CcdbApi ccdbApi;
298+
// o2::ccdb::CcdbApi ccdbApi;
295299
Service<o2::ccdb::BasicCCDBManager> ccdb;
296300
int mRunNumber;
297301
float d_bz;
298302
o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE;
303+
Zorro zorro;
299304

300305
HistogramRegistry fRegistry{"output", {}, OutputObjHandlingPolicy::AnalysisObject, false, false};
301306
static constexpr std::string_view event_cut_types[2] = {"before/", "after/"};
@@ -442,10 +447,12 @@ struct DileptonHadronMPC {
442447
}
443448
mRunNumber = collision.runNumber();
444449

450+
// zorro
445451
if constexpr (isTriggerAnalysis) {
446-
LOGF(info, "Trigger analysis is enabled. Desired trigger name = %s", cfg_swt_name.value);
447-
// LOGF(info, "total inspected TVX events = %d in run number %d", collision.nInspectedTVX(), collision.runNumber());
448-
// fRegistry.fill(HIST("Event/hNInspectedTVX"), collision.runNumber(), collision.nInspectedTVX());
452+
zorro.setCCDBpath(zorroGroup.ccdbPathSoftwareTrigger);
453+
zorro.setBCtolerance(zorroGroup.bcMarginForSoftwareTrigger); // this does nothing.
454+
zorro.initCCDB(ccdb.service, collision.runNumber(), collision.timestamp(), zorroGroup.cfg_swt_name.value);
455+
zorro.populateHistRegistry(fRegistry, collision.runNumber());
449456
}
450457
}
451458

@@ -1038,12 +1045,6 @@ struct DileptonHadronMPC {
10381045
continue;
10391046
}
10401047

1041-
if constexpr (isTriggerAnalysis) {
1042-
if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) {
1043-
continue;
1044-
}
1045-
}
1046-
10471048
o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<0, -1>(&fRegistry, collision);
10481049

10491050
if (!fEMEventCut.IsSelected(collision)) {
@@ -1053,6 +1054,12 @@ struct DileptonHadronMPC {
10531054
continue;
10541055
}
10551056

1057+
if constexpr (isTriggerAnalysis) {
1058+
if (!zorro.isSelected(collision.globalBC(), zorroGroup.bcMarginForSoftwareTrigger)) { // triggered event
1059+
continue;
1060+
}
1061+
}
1062+
10561063
o2::aod::pwgem::dilepton::utils::eventhistogram::fillEventInfo<1, -1>(&fRegistry, collision);
10571064
fRegistry.fill(HIST("Event/before/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted
10581065
fRegistry.fill(HIST("Event/after/hCollisionCounter"), o2::aod::pwgem::dilepton::utils::eventhistogram::nbin_ev); // accepted
@@ -1297,12 +1304,6 @@ struct DileptonHadronMPC {
12971304
continue;
12981305
}
12991306

1300-
if constexpr (isTriggerAnalysis) {
1301-
if (!collision.swtalias_bit(o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value))) {
1302-
continue;
1303-
}
1304-
}
1305-
13061307
if (!fEMEventCut.IsSelected(collision)) {
13071308
continue;
13081309
}
@@ -1385,8 +1386,7 @@ struct DileptonHadronMPC {
13851386
}
13861387
PROCESS_SWITCH(DileptonHadronMPC, processAnalysis, "run dilepton analysis", true);
13871388

1388-
using FilteredMyCollisionsWithSWT = soa::Filtered<MyCollisionsWithSWT>;
1389-
void processTriggerAnalysis(FilteredMyCollisionsWithSWT const& collisions, FilteredRefTracks const& refTracks, aod::EMSWTriggerInfos const& cefpinfos, aod::EMSWTriggerATCounters const& countersAT, aod::EMSWTriggerTOICounters const& countersTOI, Types const&... args)
1389+
void processTriggerAnalysis(FilteredMyCollisions const& collisions, FilteredRefTracks const& refTracks, Types const&... args)
13901390
{
13911391
if constexpr (pairtype == o2::aod::pwgem::dilepton::utils::pairutil::DileptonPairType::kDielectron) {
13921392
auto electrons = std::get<0>(std::tie(args...));
@@ -1403,25 +1403,6 @@ struct DileptonHadronMPC {
14031403
}
14041404
map_weight.clear();
14051405
ndf++;
1406-
1407-
// for nomalization
1408-
int emswtId = o2::aod::pwgem::dilepton::swt::aliasLabels.at(cfg_swt_name.value);
1409-
for (const auto& counter : countersAT) {
1410-
if (counter.isAnalyzed_bit(emswtId)) {
1411-
fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 0);
1412-
}
1413-
}
1414-
for (const auto& counter : countersTOI) {
1415-
if (counter.isAnalyzedToI_bit(emswtId)) {
1416-
fRegistry.fill(HIST("NormTrigger/hTriggerCounter"), mRunNumber, 1);
1417-
}
1418-
}
1419-
1420-
for (const auto& info : cefpinfos) {
1421-
fRegistry.fill(HIST("NormTrigger/hInspectedTVX"), info.runNumber(), info.nInspectedTVX());
1422-
fRegistry.fill(HIST("NormTrigger/hScalers"), info.runNumber(), info.nScalers()[emswtId]);
1423-
fRegistry.fill(HIST("NormTrigger/hSelections"), info.runNumber(), info.nSelections()[emswtId]);
1424-
}
14251406
}
14261407
PROCESS_SWITCH(DileptonHadronMPC, processTriggerAnalysis, "run dilepton analysis on triggered data", false);
14271408

0 commit comments

Comments
 (0)