Skip to content

Commit e566a5c

Browse files
authored
[PWGHF/HFL] Add software trigger selection in the W/Z task (#11158)
1 parent ff2a5fc commit e566a5c

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

PWGHF/HFL/Tasks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
o2physics_add_dpl_workflow(task-electron-weak-boson
1313
SOURCES taskElectronWeakBoson.cxx
14-
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore
14+
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore O2Physics::EventFilteringUtils
1515
COMPONENT_NAME Analysis)
1616

1717
o2physics_add_dpl_workflow(task-muon-charm-beauty-separation

PWGHF/HFL/Tasks/taskElectronWeakBoson.cxx

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
/// \brief task for WeakBoson (W/Z) based on electron in mid-rapidity
1414
/// \author S. Sakai & S. Ito (Univ. of Tsukuba)
1515
#include <vector>
16+
#include <string>
17+
18+
#include "CCDB/BasicCCDBManager.h"
1619

1720
#include "Framework/runDataProcessing.h"
1821
#include "Framework/AnalysisTask.h"
@@ -30,6 +33,8 @@
3033
#include "Common/DataModel/TrackSelectionTables.h"
3134
#include "Common/DataModel/PIDResponse.h"
3235

36+
#include "EventFiltering/Zorro.h"
37+
3338
#include "PWGJE/DataModel/EMCALClusters.h"
3439
#include "PWGHF/Core/HfHelper.h"
3540

@@ -76,6 +81,14 @@ struct HfTaskElectronWeakBoson {
7681
Configurable<float> energyIsolationMax{"energyIsolationMax", 0.1, "isolation cut on energy"};
7782
Configurable<int> trackIsolationMax{"trackIsolationMax", 3, "Maximum number of tracks in isolation cone"};
7883

84+
// Skimmed dataset processing configurations
85+
Configurable<bool> cfgSkimmedProcessing{"cfgSkimmedProcessing", true, "Enables processing of skimmed datasets"};
86+
Configurable<std::string> cfgTriggerName{"cfgTriggerName", "fGammaHighPtEMCAL", "Trigger of interest (comma separated for multiple)"};
87+
88+
// CCDB service object
89+
Configurable<std::string> cfgCCDBPath{"cfgCCDBPath", "Users/m/mpuccio/EventFiltering/OTS/", "Path to CCDB for trigger data"};
90+
Service<o2::ccdb::BasicCCDBManager> ccdb;
91+
7992
struct HfElectronCandidate {
8093
float pt, eta, phi, energy;
8194
int charge;
@@ -112,8 +125,23 @@ struct HfTaskElectronWeakBoson {
112125
// Histogram registry: an object to hold your registrygrams
113126
HistogramRegistry registry{"registry"};
114127

128+
// Zorro objects for skimmed data processing
129+
Zorro zorro;
130+
OutputObj<ZorroSummary> zorroSummary{"zorroSummary"};
131+
115132
void init(InitContext const&)
116133
{
134+
// Configure CCDB
135+
ccdb->setURL("http://alice-ccdb.cern.ch");
136+
ccdb->setCaching(true);
137+
ccdb->setLocalObjectValidityChecking();
138+
// CCDB path for debug
139+
LOGF(info, "CCDB path for Zorro: %s", cfgCCDBPath.value.c_str());
140+
141+
// Setup Zorro Summary
142+
if (cfgSkimmedProcessing) {
143+
zorroSummary.setObject(zorro.getZorroSummary());
144+
}
117145

118146
// define axes you want to use
119147
const AxisSpec axisZvtx{400, -20, 20, "Zvtx"};
@@ -135,9 +163,11 @@ struct HfTaskElectronWeakBoson {
135163
const AxisSpec axisIsoTrack{20, -0.5, 19.5, "Isolation Track"};
136164
const AxisSpec axisInvMassZ{200, 0, 200, "M_{ee} (GeV/c^{2})"};
137165
const AxisSpec axisInvMassDy{200, 0, 2, "M_{ee} (GeV/c^{2})"};
166+
const AxisSpec axisTrigger{3, 0, 2, "Trigger status of zorro"};
138167

139168
// create registrygrams
140169
registry.add("hZvtx", "Z vertex", kTH1F, {axisZvtx});
170+
registry.add("hEventCounterInit", "hEventCounterInit", kTH1F, {axisCounter});
141171
registry.add("hEventCounter", "hEventCounter", kTH1F, {axisCounter});
142172
registry.add("hITSchi2", "ITS #chi^{2}", kTH1F, {axisChi2});
143173
registry.add("hTPCchi2", "TPC #chi^{2}", kTH1F, {axisChi2});
@@ -163,7 +193,11 @@ struct HfTaskElectronWeakBoson {
163193
registry.add("hIsolationTrack", "Isolation Track", kTH2F, {{axisE}, {axisIsoTrack}});
164194
registry.add("hInvMassZeeLs", "invariant mass for Z LS pair", kTH2F, {{axisPt}, {axisInvMassZ}});
165195
registry.add("hInvMassZeeUls", "invariant mass for Z ULS pair", kTH2F, {{axisPt}, {axisInvMassZ}});
196+
197+
// hisotgram for EMCal trigger
198+
registry.add("hEMCalTrigger", "EMCal trigger", kTH1F, {axisTrigger});
166199
}
200+
167201
bool isIsolatedCluster(const o2::aod::EMCALCluster& cluster,
168202
const SelectedClusters& clusters)
169203
{
@@ -226,10 +260,54 @@ struct HfTaskElectronWeakBoson {
226260
}
227261

228262
void process(soa::Filtered<aod::Collisions>::iterator const& collision,
263+
aod::BCsWithTimestamps const&,
229264
SelectedClusters const& emcClusters,
230265
TrackEle const& tracks,
231266
o2::aod::EMCALMatchedTracks const& matchedtracks)
232267
{
268+
registry.fill(HIST("hEventCounterInit"), 0.5);
269+
270+
// Get BC for this collision
271+
auto bc = collision.bc_as<aod::BCsWithTimestamps>();
272+
uint64_t globalBC = bc.globalBC();
273+
int runNumber = bc.runNumber();
274+
275+
// Initialize Zorro for the first event (once per run)
276+
static bool isFirstEvent = true;
277+
static int lastRunNumber = -1;
278+
279+
if ((isFirstEvent || runNumber != lastRunNumber) && cfgSkimmedProcessing) {
280+
LOGF(info, "Initializing Zorro for run %d", runNumber);
281+
uint64_t currentTimestamp = bc.timestamp();
282+
283+
// add configurable for CCDB path
284+
zorro.setBaseCCDBPath(cfgCCDBPath.value);
285+
286+
// debug for timestamp
287+
LOGF(info, "Using CCDB path: %s, timestamp: %llu", cfgCCDBPath.value.c_str(), currentTimestamp);
288+
289+
// initialize Zorro
290+
zorro.initCCDB(ccdb.service, runNumber, currentTimestamp, cfgTriggerName);
291+
isFirstEvent = false;
292+
lastRunNumber = runNumber;
293+
}
294+
295+
// Check if this is a triggered event using Zorro
296+
bool isTriggered = true;
297+
if (cfgSkimmedProcessing) {
298+
isTriggered = zorro.isSelected(globalBC);
299+
registry.fill(HIST("hEMCalTrigger"), isTriggered ? 1 : 0);
300+
301+
// Skip event if not triggered and we're processing skimmed data
302+
if (!isTriggered && cfgSkimmedProcessing) {
303+
return;
304+
}
305+
}
306+
307+
// initialze for inclusive-electron
308+
selectedElectronsIso.clear();
309+
selectedElectronsAss.clear();
310+
233311
registry.fill(HIST("hEventCounter"), 0.5);
234312

235313
// LOGF(info, "Collision index : %d", collision.index());

0 commit comments

Comments
 (0)