Skip to content

Commit

Permalink
[PWGDQ] Adding return from Dummy process functions (AliceO2Group#7786)
Browse files Browse the repository at this point in the history
* Adding exception to improve memory consumption

* Fix clang

---------

Co-authored-by: Lucamicheletti93 <[email protected]>
  • Loading branch information
lucamicheletti93 and lucamicheletti authored Sep 25, 2024
1 parent 1e6d3ef commit 236355d
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 37 deletions.
26 changes: 23 additions & 3 deletions PWGDQ/Tasks/dqEfficiency.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,12 @@ struct AnalysisEventSelection {
HistogramManager* fHistMan;
AnalysisCompositeCut* fEventCut;

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fEventCut = new AnalysisCompositeCut(true);
TString eventCutStr = fConfigEventCuts.value;
fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data()));
Expand Down Expand Up @@ -167,8 +171,12 @@ struct AnalysisTrackSelection {
std::vector<TString> fHistNamesReco;
std::vector<std::vector<TString>> fHistNamesMCMatched;

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

// Setting the cut names
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
Expand Down Expand Up @@ -327,8 +335,12 @@ struct AnalysisMuonSelection {
std::vector<TString> fHistNamesReco;
std::vector<std::vector<TString>> fHistNamesMCMatched;

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

// Setting the cut names
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
Expand Down Expand Up @@ -532,6 +544,10 @@ struct AnalysisSameEventPairing {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fCurrentRun = 0;

ccdb->setURL(ccdburl.value);
Expand Down Expand Up @@ -1046,6 +1062,10 @@ struct AnalysisDileptonTrack {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

TString sigNamesStr = fConfigMCRecSignals.value;
std::unique_ptr<TObjArray> objRecSigArray(sigNamesStr.Tokenize(","));
TString histNames;
Expand Down
34 changes: 29 additions & 5 deletions PWGDQ/Tasks/dqEfficiency_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,12 @@ struct AnalysisEventSelection {
std::map<string, string> fMetadataRCT, fHeader;
int fCurrentRun;

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fEventCut = new AnalysisCompositeCut(true);
TString eventCutStr = fConfigEventCuts.value;
fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data()));
Expand Down Expand Up @@ -361,8 +365,12 @@ struct AnalysisTrackSelection {
std::map<int64_t, std::vector<int64_t>> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting)
std::map<int64_t, std::vector<int64_t>> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup)

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fCurrentRun = 0;
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
Expand Down Expand Up @@ -637,8 +645,12 @@ struct AnalysisMuonSelection {
std::map<int64_t, std::vector<int64_t>> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting)
std::map<int64_t, std::vector<int64_t>> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup)

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fCurrentRun = 0;
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
Expand Down Expand Up @@ -884,8 +896,12 @@ struct AnalysisPrefilterSelection {

Preslice<aod::ReducedTracksAssoc> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId;

void init(o2::framework::InitContext& initContext)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

// get the list of track cuts to be prefiltered
TString trackCutsStr = fConfigTrackCuts.value;
TObjArray* objArrayTrackCuts = nullptr;
Expand All @@ -901,7 +917,7 @@ struct AnalysisPrefilterSelection {
fPrefilterMask = 0;
fPrefilterCutBit = -1;
string trackCuts;
getTaskOptionValue<string>(initContext, "analysis-track-selection", "cfgTrackCuts", trackCuts, false);
getTaskOptionValue<string>(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false);
TString allTrackCutsStr = trackCuts;
TString prefilterTrackCutStr = fConfigPrefilterTrackCut.value;
if (!trackCutsStr.IsNull()) {
Expand Down Expand Up @@ -1097,6 +1113,10 @@ struct AnalysisSameEventPairing {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fEnableBarrelHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithCollSkimmed");
fEnableMuonHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmed");
bool isDummy = context.mOptions.get<bool>("processDummy");
Expand Down Expand Up @@ -1810,6 +1830,10 @@ struct AnalysisDileptonTrack {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

bool isBarrel = context.mOptions.get<bool>("processBarrelSkimmed");
bool isMuon = context.mOptions.get<bool>("processMuonSkimmed");
bool isAnyProcessEnabled = isBarrel || isMuon;
Expand Down
57 changes: 28 additions & 29 deletions PWGDQ/Tasks/tableReader_withAssoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,12 @@ struct AnalysisEventSelection {
std::map<uint64_t, std::vector<int64_t>> fBCCollMap; // key: global BC, value: vector of reduced event global indices
int fCurrentRun;

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fEventCut = new AnalysisCompositeCut(true);
TString eventCutStr = fConfigEventCuts.value;
fEventCut->AddCut(dqcuts::GetAnalysisCut(eventCutStr.Data()));
Expand Down Expand Up @@ -371,10 +375,13 @@ struct AnalysisTrackSelection {
std::map<int64_t, std::vector<int64_t>> fNAssocsInBunch; // key: track global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting)
std::map<int64_t, std::vector<int64_t>> fNAssocsOutOfBunch; // key: track global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup)

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
fCurrentRun = 0;
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fCurrentRun = 0;
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
std::unique_ptr<TObjArray> objArray(cutNamesStr.Tokenize(","));
Expand Down Expand Up @@ -592,8 +599,12 @@ struct AnalysisMuonSelection {
std::map<int64_t, std::vector<int64_t>> fNAssocsInBunch; // key: muon global index, value: vector of global index for events associated in-bunch (events that have in-bunch pileup or splitting)
std::map<int64_t, std::vector<int64_t>> fNAssocsOutOfBunch; // key: muon global index, value: vector of global index for events associated out-of-bunch (events that have no in-bunch pileup)

void init(o2::framework::InitContext&)
void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fCurrentRun = 0;
TString cutNamesStr = fConfigCuts.value;
if (!cutNamesStr.IsNull()) {
Expand Down Expand Up @@ -775,12 +786,12 @@ struct AnalysisPrefilterSelection {

Preslice<aod::ReducedTracksAssoc> trackAssocsPerCollision = aod::reducedtrack_association::reducedeventId;

void init(o2::framework::InitContext& initContext)
void init(o2::framework::InitContext& context)
{
if (initContext.mOptions.get<bool>("processDummy")) {
LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl;
if (context.mOptions.get<bool>("processDummy")) {
return;
}

// get the list of track cuts to be prefiltered
TString trackCutsStr = fConfigTrackCuts.value;
TObjArray* objArrayTrackCuts = nullptr;
Expand All @@ -796,7 +807,7 @@ struct AnalysisPrefilterSelection {
fPrefilterMask = 0;
fPrefilterCutBit = -1;
string trackCuts;
getTaskOptionValue<string>(initContext, "analysis-track-selection", "cfgTrackCuts", trackCuts, false);
getTaskOptionValue<string>(context, "analysis-track-selection", "cfgTrackCuts", trackCuts, false);
TString allTrackCutsStr = trackCuts;
TString prefilterTrackCutStr = fConfigPrefilterTrackCut.value;
if (!trackCutsStr.IsNull()) {
Expand Down Expand Up @@ -986,19 +997,14 @@ struct AnalysisSameEventPairing {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

fEnableBarrelHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmed") || context.mOptions.get<bool>("processBarrelOnlyWithCollSkimmed") || context.mOptions.get<bool>("processBarrelOnlySkimmedNoCov");
fEnableBarrelMixingHistos = context.mOptions.get<bool>("processMixingAllSkimmed") || context.mOptions.get<bool>("processMixingBarrelSkimmed");
fEnableMuonHistos = context.mOptions.get<bool>("processAllSkimmed") || context.mOptions.get<bool>("processMuonOnlySkimmed");
fEnableMuonMixingHistos = context.mOptions.get<bool>("processMixingAllSkimmed");
bool isDummy = context.mOptions.get<bool>("processDummy");
if (isDummy) {
if (fEnableBarrelHistos || fEnableBarrelMixingHistos || fEnableMuonHistos || fEnableMuonMixingHistos) {
LOG(warning) << "The dummy process function is enabled while you have enabled normal process function. Check your configuration file!" << endl;
} else {
LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl;
return;
}
}

// Keep track of all the histogram class names to avoid composing strings in the pairing loop
TString histNames = "";
Expand Down Expand Up @@ -1729,9 +1735,7 @@ struct AnalysisAsymmetricPairing {

void init(o2::framework::InitContext& context)
{
bool isDummy = context.mOptions.get<bool>("processDummy");
if (isDummy) {
LOG(info) << "Dummy function enabled. Skipping the rest of init()" << endl;
if (context.mOptions.get<bool>("processDummy")) {
return;
}

Expand Down Expand Up @@ -2388,21 +2392,16 @@ struct AnalysisDileptonTrack {

void init(o2::framework::InitContext& context)
{
if (context.mOptions.get<bool>("processDummy")) {
return;
}

bool isBarrel = context.mOptions.get<bool>("processBarrelSkimmed");
bool isBarrelME = context.mOptions.get<bool>("processBarrelMixedEvent");
bool isBarrelAsymmetric = context.mOptions.get<bool>("processDstarToD0Pi");
bool isMuon = context.mOptions.get<bool>("processMuonSkimmed");
bool isMuonME = context.mOptions.get<bool>("processMuonMixedEvent");
bool isAnyProcessEnabled = isBarrel || isBarrelME || isMuon || isMuonME;
bool isDummy = context.mOptions.get<bool>("processDummy");
if (isDummy) {
if (isAnyProcessEnabled) {
LOG(warning) << "Dummy function is enabled even if there are normal process functions running! Fix your config!" << endl;
} else {
LOG(info) << "Dummy function is enabled. Skipping the rest of the init function" << endl;
return;
}
}

fCurrentRun = 0;
fValuesDilepton = new float[VarManager::kNVars];
Expand Down

0 comments on commit 236355d

Please sign in to comment.