Skip to content

Commit 7c29f36

Browse files
ffiondaalibuild
andauthored
[PWGDQ] Fix for tableReader_withAss_direct task (Zorro and CCDB paths)+minor fix in dqEff-direct task (#15094)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 15fca28 commit 7c29f36

File tree

3 files changed

+173
-16
lines changed

3 files changed

+173
-16
lines changed

PWGDQ/Tasks/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ o2physics_add_dpl_workflow(table-reader-with-assoc
2121

2222
o2physics_add_dpl_workflow(table-reader-with-assoc-direct
2323
SOURCES tableReader_withAssoc_direct.cxx
24-
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGDQCore O2Physics::MLCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2::DetectorsVertexing
24+
PUBLIC_LINK_LIBRARIES O2::Framework O2::DetectorsBase O2Physics::AnalysisCore O2Physics::AnalysisCCDB O2Physics::PWGDQCore O2Physics::MLCore O2::ReconstructionDataFormats O2::DetectorsCommonDataFormats O2::DetectorsVertexing O2Physics::EventFilteringUtils
2525
COMPONENT_NAME Analysis)
2626

2727
o2physics_add_dpl_workflow(efficiency

PWGDQ/Tasks/dqEfficiency_withAssoc_direct.cxx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,13 @@ struct AnalysisTrackSelection {
733733
trackSel(0);
734734
continue;
735735
}
736+
///
737+
auto track = tracks.rawIteratorAt(assoc.trackId());
738+
auto evFromTrack = events.rawIteratorAt(track.collisionId());
739+
if (!evFromTrack.isEventSelected_bit(0)) {
740+
trackSel(0);
741+
continue;
742+
}
736743

737744
// cout << "Processing association: event global index " << event.globalIndex() << endl;
738745
VarManager::ResetValues(VarManager::kNTFWiseVariables, VarManager::kNBarrelTrackVariables);
@@ -743,10 +750,10 @@ struct AnalysisTrackSelection {
743750
}
744751
// cout << "Filled event observables for association" << endl;
745752

746-
auto track = tracks.rawIteratorAt(assoc.trackId());
747753
VarManager::FillTrack<TTrackFillMap>(track);
748754
// compute quantities which depend on the associated collision, such as DCA
749-
VarManager::FillTrackCollision<TTrackFillMap>(track, event);
755+
if (track.collisionId() != event.globalIndex())
756+
VarManager::FillTrackCollision<TTrackFillMap>(track, event);
750757
// cout << "Filled track observables for association" << endl;
751758

752759
bool isCorrectAssoc = false;

PWGDQ/Tasks/tableReader_withAssoc_direct.cxx

Lines changed: 163 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
#include "PWGDQ/Core/VarManager.h"
2323
#include "PWGDQ/DataModel/ReducedInfoTables.h"
2424

25+
#include "Common/CCDB/TriggerAliases.h"
26+
#include "Common/CCDB/ctpRateFetcher.h"
2527
#include "Common/Core/PID/PIDTOFParamService.h"
2628
#include "Common/Core/TableHelper.h"
29+
#include "Common/Core/Zorro.h"
2730
#include "Common/DataModel/CollisionAssociationTables.h"
2831
#include "Common/DataModel/EventSelection.h"
2932
#include "Common/DataModel/McCollisionExtra.h"
@@ -70,6 +73,8 @@ using namespace o2::framework;
7073
using namespace o2::framework::expressions;
7174
using namespace o2::aod;
7275

76+
Zorro zorro;
77+
7378
// Some definitions
7479
namespace o2::aod
7580
{
@@ -233,10 +238,17 @@ void PrintBitMap(TMap map, int nbits)
233238
}
234239
}
235240

241+
// Enum containing the ordering of statistics histograms to be written in the QA file
242+
enum ZorroStatHist {
243+
kStatsZorroInfo = 0,
244+
kStatsZorroSel
245+
};
246+
236247
struct AnalysisEventSelection {
237248
Produces<aod::EventCuts> eventSel;
238249
Produces<aod::MixingHashes> hash;
239250
OutputObj<THashList> fOutputList{"output"};
251+
OutputObj<TList> fStatsList{"Statistics"};
240252
Configurable<std::string> fConfigMixingVariables{"cfgMixingVars", "", "Mixing configs separated by a comma, default no mixing"};
241253
Configurable<std::string> fConfigEventCuts{"cfgEventCuts", "eventStandard", "Event selection"};
242254
Configurable<std::string> fConfigEventCutsJSON{"cfgEventCutsJSON", "", "Additional event cuts specified in JSON format"};
@@ -248,14 +260,55 @@ struct AnalysisEventSelection {
248260
Configurable<unsigned int> fConfigSplitCollisionsDeltaBC{"cfgSplitCollisionsDeltaBC", 100, "maximum delta-BC between two collisions to consider them as split candidates; do not apply if value is negative"};
249261
Configurable<bool> fConfigCheckSplitCollisions{"cfgCheckSplitCollisions", false, "If true, run the split collision check and fill histograms"};
250262

251-
Configurable<std::string> fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
252-
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
263+
// Zorro selection
264+
struct : ConfigurableGroup {
265+
Configurable<bool> fConfigRunZorro{"cfgRunZorro", false, "Enable event selection with zorro"};
266+
Configurable<std::string> fConfigZorroTrigMask{"cfgZorroTriggerMask", "fDiMuon", "DQ Trigger masks: fSingleE,fLMeeIMR,fLMeeHMR,fDiElectron,fSingleMuLow,fSingleMuHigh,fDiMuon"};
267+
Configurable<bool> fConfigRunZorroSel{"cfgRunZorroSel", false, "Select events with trigger mask"};
268+
Configurable<uint64_t> fBcTolerance{"cfgBcTolerance", 100, "Number of BCs of margin for software triggers"};
269+
Configurable<std::string> fConfigCcdbPathZorro{"ccdb-path-zorro", "/Users/m/mpuccio/EventFiltering/OTS/Chunked/", "base path to the ccdb object for zorro"};
270+
} fConfigZorro;
271+
272+
// RCT selection
273+
struct : ConfigurableGroup {
274+
Configurable<bool> fConfigUseRCT{"cfgUseRCT", false, "Enable event selection with RCT flags"};
275+
Configurable<std::string> fConfigRCTLabel{"cfgRCTLabel", "CBT", "RCT flag labels : CBT, CBT_hadronPID, CBT_electronPID, CBT_calo, CBT_muon, CBT_muon_glo"};
276+
} fConfigRCT;
277+
278+
// CCDB connection configurables
279+
struct : ConfigurableGroup {
280+
Configurable<std::string> fConfigCcdbUrl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
281+
Configurable<std::string> fConfigCcdbPathTPC{"ccdb-path-tpc", "Users/z/zhxiong/TPCPID/PostCalib", "base path to the ccdb object"};
282+
Configurable<int64_t> fConfigNoLaterThan{"ccdb-no-later-than", std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(), "latest acceptable timestamp of creation for the object"};
283+
Configurable<std::string> fConfigGeoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
284+
Configurable<std::string> fConfigGrpMagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
285+
Configurable<std::string> fZShiftPath{"zShiftPath", "Users/m/mcoquet/ZShift", "CCDB path for z shift to apply to forward tracks"};
286+
Configurable<std::string> fConfigGrpMagPathRun2{"grpmagPathRun2", "GLO/GRP/GRP", "CCDB path of the GRPObject (Usage for Run 2)"};
287+
} fConfigCCDB;
288+
289+
// TPC postcalibration related options
290+
struct : ConfigurableGroup {
291+
Configurable<bool> fConfigComputeTPCpostCalib{"cfgTPCpostCalib", false, "If true, compute TPC post-calibrated n-sigmas(electrons, pions, protons)"};
292+
Configurable<int> fConfigTPCpostCalibType{"cfgTPCpostCalibType", 1, "1: (TPCncls,pIN,eta) calibration typically for pp, 2: (eta,nPV,nLong,tLong) calibration typically for PbPb"};
293+
Configurable<bool> fConfigTPCuseInterpolatedCalib{"cfgTPCpostCalibUseInterpolation", true, "If true, use interpolated calibration values (default: true)"};
294+
Configurable<bool> fConfigComputeTPCpostCalibKaon{"cfgTPCpostCalibKaon", false, "If true, compute TPC post-calibrated n-sigmas for kaons"};
295+
Configurable<bool> fConfigIsOnlyforMaps{"cfgIsforMaps", false, "If true, run for postcalibration maps only"};
296+
Configurable<bool> fConfigSaveElectronSample{"cfgSaveElectronSample", false, "If true, only save electron sample"};
297+
} fConfigPostCalibTPC;
298+
299+
Configurable<bool> fIsRun2{"cfgIsRun2", false, "Whether we analyze Run-2 or Run-3 data"};
300+
301+
// RCT flag checker
302+
o2::aod::rctsel::RCTFlagsChecker rctChecker{"CBT"};
253303

254304
HistogramManager* fHistMan = nullptr;
255305
MixingHandler* fMixHandler = nullptr;
256306

257307
AnalysisCompositeCut* fEventCut;
258308

309+
o2::parameters::GRPObject* fGrpMagRun2 = nullptr; // for run 2, we access the GRPObject from GLO/GRP/GRP
310+
o2::parameters::GRPMagField* fGrpMag = nullptr; // for run 3, we access GRPMagField from GLO/Config/GRPMagField
311+
259312
Service<o2::ccdb::BasicCCDBManager> fCCDB;
260313
o2::ccdb::CcdbApi fCCDBApi;
261314

@@ -304,6 +357,16 @@ struct AnalysisEventSelection {
304357
fOutputList.setObject(fHistMan->GetMainHistogramList());
305358
}
306359

360+
// Zorro information: kStatsZorroInfo
361+
// Zorro trigger selection: kStatsZorroSel
362+
fStatsList.setObject(new TList());
363+
fStatsList->SetOwner(kTRUE);
364+
TH2D* histZorroInfo = new TH2D("ZorroInfo", "Zorro information", 1, -0.5, 0.5, 1, -0.5, 0.5);
365+
fStatsList->AddAt(histZorroInfo, kStatsZorroInfo);
366+
367+
TH2D* histZorroSel = new TH2D("ZorroSel", "trigger of interested", 1, -0.5, 0.5, 1, -0.5, 0.5);
368+
fStatsList->AddAt(histZorroSel, kStatsZorroSel);
369+
307370
TString mixVarsString = fConfigMixingVariables.value;
308371
std::unique_ptr<TObjArray> objArray(mixVarsString.Tokenize(","));
309372
if (objArray->GetEntries() > 0) {
@@ -315,25 +378,78 @@ struct AnalysisEventSelection {
315378
}
316379

317380
fCurrentRun = -1;
318-
fCCDB->setURL(fConfigCcdbUrl.value);
381+
fCCDB->setURL(fConfigCCDB.fConfigCcdbUrl.value);
319382
fCCDB->setCaching(true);
320383
fCCDB->setLocalObjectValidityChecking();
321-
fCCDB->setCreatedNotAfter(fConfigNoLaterThan.value);
322-
fCCDBApi.init(fConfigCcdbUrl.value);
384+
fCCDB->setCreatedNotAfter(fConfigCCDB.fConfigNoLaterThan.value);
385+
fCCDBApi.init(fConfigCCDB.fConfigCcdbUrl.value);
386+
387+
if (!o2::base::GeometryManager::isGeometryLoaded()) {
388+
fCCDB->get<TGeoManager>(fConfigCCDB.fConfigGeoPath.value);
389+
}
390+
391+
if (fConfigRCT.fConfigUseRCT.value) {
392+
rctChecker.init(fConfigRCT.fConfigRCTLabel);
393+
}
394+
323395
cout << "AnalysisEventSelection::init() completed" << endl;
324396
}
325397

326398
template <uint32_t TEventFillMap, typename TEvents>
327399
void runEventSelection(TEvents const& events, BCsWithTimestamps const& bcs)
328400
{
329401
cout << "AnalysisEventSelection::runEventSelection() called with " << events.size() << " events and " << bcs.size() << " BCs" << endl;
330-
if (bcs.size() > 0 && bcs.begin().runNumber() != fCurrentRun) {
402+
403+
if (bcs.size() > 0 && fCurrentRun != bcs.begin().runNumber()) {
404+
if (fConfigPostCalibTPC.fConfigComputeTPCpostCalib) {
405+
auto calibList = fCCDB->getForTimeStamp<TList>(fConfigCCDB.fConfigCcdbPathTPC.value, bcs.begin().timestamp());
406+
VarManager::SetCalibrationObject(VarManager::kTPCElectronMean, calibList->FindObject("mean_map_electron"));
407+
VarManager::SetCalibrationObject(VarManager::kTPCElectronSigma, calibList->FindObject("sigma_map_electron"));
408+
VarManager::SetCalibrationObject(VarManager::kTPCPionMean, calibList->FindObject("mean_map_pion"));
409+
VarManager::SetCalibrationObject(VarManager::kTPCPionSigma, calibList->FindObject("sigma_map_pion"));
410+
VarManager::SetCalibrationObject(VarManager::kTPCProtonMean, calibList->FindObject("mean_map_proton"));
411+
VarManager::SetCalibrationObject(VarManager::kTPCProtonSigma, calibList->FindObject("sigma_map_proton"));
412+
if (fConfigPostCalibTPC.fConfigComputeTPCpostCalibKaon) {
413+
VarManager::SetCalibrationObject(VarManager::kTPCKaonMean, calibList->FindObject("mean_map_kaon"));
414+
VarManager::SetCalibrationObject(VarManager::kTPCKaonSigma, calibList->FindObject("sigma_map_kaon"));
415+
}
416+
if (fConfigPostCalibTPC.fConfigTPCpostCalibType == 2) {
417+
VarManager::SetCalibrationObject(VarManager::kTPCElectronStatus, calibList->FindObject("status_map_electron"));
418+
VarManager::SetCalibrationObject(VarManager::kTPCPionStatus, calibList->FindObject("status_map_pion"));
419+
VarManager::SetCalibrationObject(VarManager::kTPCProtonStatus, calibList->FindObject("status_map_proton"));
420+
if (fConfigPostCalibTPC.fConfigComputeTPCpostCalibKaon) {
421+
VarManager::SetCalibrationObject(VarManager::kTPCKaonStatus, calibList->FindObject("status_map_kaon"));
422+
}
423+
}
424+
VarManager::SetCalibrationType(fConfigPostCalibTPC.fConfigTPCpostCalibType, fConfigPostCalibTPC.fConfigTPCuseInterpolatedCalib);
425+
}
426+
if (fIsRun2 == true) {
427+
fGrpMagRun2 = fCCDB->getForTimeStamp<o2::parameters::GRPObject>(fConfigCCDB.fConfigGrpMagPathRun2, bcs.begin().timestamp());
428+
if (fGrpMagRun2 != nullptr) {
429+
o2::base::Propagator::initFieldFromGRP(fGrpMagRun2);
430+
}
431+
} else {
432+
fGrpMag = fCCDB->getForTimeStamp<o2::parameters::GRPMagField>(fConfigCCDB.fConfigGrpMagPath, bcs.begin().timestamp());
433+
auto* fZShift = fCCDB->getForTimeStamp<std::vector<float>>(fConfigCCDB.fZShiftPath, bcs.begin().timestamp());
434+
if (fGrpMag != nullptr) {
435+
o2::base::Propagator::initFieldFromGRP(fGrpMag);
436+
VarManager::SetMagneticField(fGrpMag->getNominalL3Field());
437+
}
438+
if (fZShift != nullptr && !fZShift->empty()) {
439+
VarManager::SetZShift((*fZShift)[0]);
440+
}
441+
/*if (fConfigVariousOptions.fPropMuon) {
442+
VarManager::SetupMuonMagField();
443+
}*/
444+
}
331445
std::map<std::string, std::string> metadataRCT, header;
332446
header = fCCDBApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", bcs.begin().runNumber()), metadataRCT, -1);
333447
uint64_t sor = std::atol(header["SOR"].c_str());
334448
uint64_t eor = std::atol(header["EOR"].c_str());
335449
VarManager::SetSORandEOR(sor, eor);
336-
}
450+
451+
fCurrentRun = bcs.begin().runNumber();
452+
} // end updating the CCDB quantities at change of run
337453

338454
cout << "Filling TimeFrame statistics histograms" << endl;
339455
VarManager::ResetValues(0, VarManager::kNEventWiseVariables);
@@ -358,12 +474,33 @@ struct AnalysisEventSelection {
358474
if (fConfigQA) {
359475
fHistMan->FillHistClass("Event_BeforeCuts", VarManager::fgValues);
360476
}
361-
if (fEventCut->IsSelected(VarManager::fgValues)) {
362-
if (fConfigQA) {
363-
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
477+
478+
if (fConfigZorro.fConfigRunZorro) {
479+
zorro.setBaseCCDBPath(fConfigZorro.fConfigCcdbPathZorro.value);
480+
zorro.setBCtolerance(fConfigZorro.fBcTolerance);
481+
zorro.initCCDB(fCCDB.service, fCurrentRun, bc.timestamp(), fConfigZorro.fConfigZorroTrigMask.value);
482+
zorro.populateExternalHists(fCurrentRun, reinterpret_cast<TH2D*>(fStatsList->At(kStatsZorroInfo)), reinterpret_cast<TH2D*>(fStatsList->At(kStatsZorroSel)));
483+
484+
if (!fEventCut->IsSelected(VarManager::fgValues) || (fConfigRCT.fConfigUseRCT.value && !rctChecker(event))) {
485+
continue;
486+
}
487+
488+
bool zorroSel = zorro.isSelected(bc.globalBC(), fConfigZorro.fBcTolerance, reinterpret_cast<TH2D*>(fStatsList->At(kStatsZorroSel)));
489+
if (fConfigZorro.fConfigRunZorroSel && (!zorroSel)) {
490+
continue;
364491
}
365-
decision = true;
492+
} else {
493+
494+
if (!fEventCut->IsSelected(VarManager::fgValues) || (fConfigRCT.fConfigUseRCT.value && !rctChecker(event))) {
495+
continue;
496+
}
497+
}
498+
499+
decision = true;
500+
if (fConfigQA) {
501+
fHistMan->FillHistClass("Event_AfterCuts", VarManager::fgValues);
366502
}
503+
367504
fSelMap[event.globalIndex()] = decision;
368505
if (fBCCollMap.find(bc.globalBC()) == fBCCollMap.end()) {
369506
std::vector<int64_t> evIndices = {event.globalIndex()};
@@ -616,14 +753,22 @@ struct AnalysisTrackSelection {
616753
continue;
617754
}
618755

756+
///
757+
auto track = tracks.rawIteratorAt(assoc.trackId());
758+
auto evFromTrack = events.rawIteratorAt(track.collisionId());
759+
if (!evFromTrack.isEventSelected_bit(0)) {
760+
trackSel(0);
761+
continue;
762+
}
763+
619764
VarManager::ResetValues(VarManager::kNTFWiseVariables, VarManager::kNBarrelTrackVariables);
620765
// fill event information which might be needed in histograms/cuts that combine track and event properties
621766
VarManager::FillEvent<TEventFillMap>(event);
622767

623-
auto track = tracks.rawIteratorAt(assoc.trackId());
624768
VarManager::FillTrack<TTrackFillMap>(track);
625769
// compute quantities which depend on the associated collision, such as DCA
626-
VarManager::FillTrackCollision<TTrackFillMap>(track, event);
770+
if (track.collisionId() != event.globalIndex())
771+
VarManager::FillTrackCollision<TTrackFillMap>(track, event);
627772

628773
if (fConfigQA)
629774
fHistMan->FillHistClass("AssocsBarrel_BeforeCuts", VarManager::fgValues);
@@ -946,6 +1091,7 @@ struct AnalysisSameEventPairing {
9461091
Configurable<std::string> track{"cfgTrackCuts", "jpsiO2MCdebugCuts2", "Comma separated list of barrel track cuts"};
9471092
Configurable<std::string> muon{"cfgMuonCuts", "", "Comma separated list of muon cuts"};
9481093
Configurable<std::string> pair{"cfgPairCuts", "", "Comma separated list of pair cuts, !!! Use only if you know what you are doing, otherwise leave empty"};
1094+
Configurable<bool> collSplitting{"cfgRemoveCollSplittingCandidates", false, "If true, remove collision splitting candidates as determined by the event selection task upstream"};
9491095
Configurable<bool> fConfigQA{"cfgQA", false, "If true, fill QA histograms"};
9501096
Configurable<std::string> fConfigAddSEPHistogram{"cfgAddSEPHistogram", "", "Comma separated list of histograms"};
9511097
Configurable<std::string> fConfigAddJSONHistograms{"cfgAddJSONHistograms", "", "Histograms in JSON format"};
@@ -1356,6 +1502,10 @@ struct AnalysisSameEventPairing {
13561502
if (!event.isEventSelected_bit(0))
13571503
continue;
13581504

1505+
if (fConfigOptions.collSplitting && event.isEventSelected_bit(2)) {
1506+
continue;
1507+
}
1508+
13591509
VarManager::ResetValues(0, VarManager::kNVars);
13601510
VarManager::FillEvent<TEventFillMap>(event, VarManager::fgValues);
13611511

0 commit comments

Comments
 (0)