Skip to content

Commit f081113

Browse files
authored
Merge branch 'dev' into newtestoftracklabel
2 parents b8c526c + c036069 commit f081113

15 files changed

Lines changed: 386 additions & 177 deletions

File tree

Analysis/DataModel/src/dumpDataModel.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ edge[dir=back, arrowtail=empty]
115115
dumpTable<V0s>();
116116
dumpTable<Cascades>();
117117
dumpTable<Timeframes>();
118-
//dumpTable<SecVtx2Prong>();
118+
// dumpTable<SecVtx2Prong>();
119119
dumpTable<Cand2Prong>();
120120
fmt::printf("%s\n", R"(})");
121121
}

Analysis/Tasks/vertexerhf.cxx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ struct DecayVertexBuilder2Prong {
134134
struct CandidateBuildingDzero {
135135
Produces<aod::Cand2Prong> cand2prong;
136136
void process(aod::SecVtx2Prong const& secVtx2Prongs,
137-
soa::Join<aod::Tracks, aod::TracksCov,
138-
aod::TracksExtra> const& tracks)
137+
soa::Join<aod::Tracks, aod::TracksCov, aod::TracksExtra> const& tracks)
139138
{
140139
LOGF(info, "NEW EVENT");
141140

Detectors/EMCAL/workflow/include/EMCALWorkflow/CellConverterSpec.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <vector>
1212

1313
#include "DataFormatsEMCAL/Cell.h"
14+
#include "DataFormatsEMCAL/TriggerRecord.h"
1415
#include "Framework/DataProcessorSpec.h"
1516
#include "Framework/Task.h"
1617

@@ -59,14 +60,17 @@ class CellConverterSpec : public framework::Task
5960
///
6061
/// The following branches are linked:
6162
/// Input digits: {"EMC", "DIGITS", 0, Lifetime::Timeframe}
63+
/// Input trigers: {"EMC", "DIGITSTRGR", 0, Lifetime::Timeframe}
6264
/// Input MC-truth: {"EMC", "DIGITSMCTR", 0, Lifetime::Timeframe}
6365
/// Output cells: {"EMC", "CELLS", 0, Lifetime::Timeframe}
66+
/// Output trigers: {"EMC", "CELLSTRGR", 0, Lifetime::Timeframe}
6467
/// Output MC-truth: {"EMC", "CELLSMCTR", 0, Lifetime::Timeframe}
6568
void run(framework::ProcessingContext& ctx) final;
6669

6770
private:
68-
bool mPropagateMC = false; ///< Switch whether to process MC true labels
69-
std::vector<o2::emcal::Cell> mOutputCells; ///< Container with output cells
71+
bool mPropagateMC = false; ///< Switch whether to process MC true labels
72+
std::vector<o2::emcal::Cell> mOutputCells; ///< Container with output cells
73+
std::vector<o2::emcal::TriggerRecord> mOutputTriggers; ///< Container with output trigger records
7074
};
7175

7276
/// \brief Creating DataProcessorSpec for the EMCAL Cell Converter Spec

Detectors/EMCAL/workflow/include/EMCALWorkflow/DigitsPrinterSpec.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11+
#include <string>
1112
#include "Framework/DataProcessorSpec.h"
1213
#include "Framework/Task.h"
1314

@@ -29,6 +30,7 @@ namespace reco_workflow
2930
/// Example payload for workflows using o2::emcal::Digit as payload.
3031
/// Printing several digit-related information for each digit. Refer
3132
/// to run for the list of input spec to be specified.
33+
template <class InputType>
3234
class DigitsPrinterSpec : public framework::Task
3335
{
3436
public:
@@ -56,7 +58,10 @@ class DigitsPrinterSpec : public framework::Task
5658
///
5759
/// Refer to DigitsPrinterSpec::run for a list of input
5860
/// specs
59-
o2::framework::DataProcessorSpec getEmcalDigitsPrinterSpec();
61+
o2::framework::DataProcessorSpec getEmcalDigitsPrinterSpec(std::string inputtype);
62+
63+
//using DigitsPrinterSpecDigit = o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Digit>;
64+
//using DigitsPrinterSpecCell = o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Cell>;
6065
} // namespace reco_workflow
6166
} // namespace emcal
6267

Detectors/EMCAL/workflow/include/EMCALWorkflow/PublisherSpec.h

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11+
#include "DPLUtils/RootTreeReader.h"
1112
#include "Framework/DataProcessorSpec.h"
13+
#include "Framework/DataSpecUtils.h"
14+
#include "Framework/Output.h"
1215
#include "Framework/OutputSpec.h"
16+
#include "DataFormatsEMCAL/TriggerRecord.h"
1317
#include <string>
1418
#include <vector>
1519

@@ -31,12 +35,55 @@ struct PublisherConf {
3135
std::string processName;
3236
std::string defaultTreeName;
3337
BranchOptionConfig databranch;
38+
BranchOptionConfig triggerrecordbranch;
3439
BranchOptionConfig mcbranch;
3540
OutputSpec dataoutput;
41+
OutputSpec triggerrecordoutput;
3642
OutputSpec mcoutput;
3743
};
3844

39-
framework::DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC = true);
45+
template <typename T = void>
46+
framework::DataProcessorSpec getPublisherSpec(PublisherConf const& config, bool propagateMC = true)
47+
{
48+
using Reader = o2::framework::RootTreeReader;
49+
using Output = o2::framework::Output;
50+
using TriggerInputType = std::vector<o2::emcal::TriggerRecord>;
51+
auto dto = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.dataoutput);
52+
auto tro = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.triggerrecordoutput);
53+
auto mco = o2::framework::DataSpecUtils::asConcreteDataTypeMatcher(config.mcoutput);
54+
55+
// a creator callback for the actual reader instance
56+
auto creator = [dto, tro, mco, propagateMC](const char* treename, const char* filename, int nofEvents, Reader::PublishingMode publishingMode, const char* branchname, const char* triggerbranchname, const char* mcbranchname) {
57+
constexpr auto persistency = o2::framework::Lifetime::Timeframe;
58+
if (propagateMC) {
59+
return std::make_shared<Reader>(treename,
60+
filename,
61+
nofEvents,
62+
publishingMode,
63+
Output{mco.origin, mco.description, 0, persistency},
64+
mcbranchname,
65+
Reader::BranchDefinition<T>{Output{dto.origin, dto.description, 0, persistency}, branchname},
66+
Reader::BranchDefinition<TriggerInputType>{Output{tro.origin, tro.description, 0, persistency}, triggerbranchname});
67+
} else {
68+
return std::make_shared<Reader>(treename,
69+
filename,
70+
nofEvents,
71+
publishingMode,
72+
Reader::BranchDefinition<T>{Output{dto.origin, dto.description, 0, persistency}, branchname},
73+
Reader::BranchDefinition<TriggerInputType>{Output{tro.origin, tro.description, 0, persistency}, triggerbranchname});
74+
}
75+
};
76+
77+
return createPublisherSpec(config, propagateMC, creator);
78+
}
79+
80+
namespace workflow_reader
81+
{
82+
using Reader = o2::framework::RootTreeReader;
83+
using Creator = std::function<std::shared_ptr<Reader>(const char*, const char*, int, Reader::PublishingMode, const char*, const char*, const char*)>;
84+
} // namespace workflow_reader
85+
86+
framework::DataProcessorSpec createPublisherSpec(PublisherConf const& config, bool propagateMC, workflow_reader::Creator creator);
4087

4188
} // namespace emcal
4289
} // end namespace o2

Detectors/EMCAL/workflow/src/CellConverterSpec.cxx

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// In applying this license CERN does not waive the privileges and immunities
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
10+
#include <gsl/span>
1011
#include "FairLogger.h"
1112

1213
#include "DataFormatsEMCAL/Digit.h"
@@ -35,22 +36,37 @@ void CellConverterSpec::run(framework::ProcessingContext& ctx)
3536
}
3637

3738
mOutputCells.clear();
38-
auto digits = ctx.inputs().get<std::vector<o2::emcal::Digit>>("digits");
39-
LOG(DEBUG) << "[EMCALCellConverter - run] Received " << digits.size() << " digits ...";
40-
for (const auto& dig : digits) {
41-
ChannelType_t chantype;
42-
if (dig.getHighGain())
43-
chantype = ChannelType_t::HIGH_GAIN;
44-
else if (dig.getLowGain())
45-
chantype = ChannelType_t::LOW_GAIN;
46-
else if (dig.getTRU())
47-
chantype = ChannelType_t::TRU;
48-
else if (dig.getLEDMon())
49-
chantype = ChannelType_t::LEDMON;
50-
mOutputCells.emplace_back(dig.getTower(), dig.getEnergy(), dig.getTimeStamp(), chantype);
39+
mOutputTriggers.clear();
40+
auto digitsAll = ctx.inputs().get<gsl::span<o2::emcal::Digit>>("digits");
41+
auto triggers = ctx.inputs().get<gsl::span<o2::emcal::TriggerRecord>>("triggers");
42+
LOG(DEBUG) << "[EMCALCellConverter - run] Received " << digitsAll.size() << " digits from " << triggers.size() << " trigger ...";
43+
int currentstart = mOutputCells.size(), ncellsTrigger = 0;
44+
for (const auto& trg : triggers) {
45+
if (!trg.getNumberOfObjects()) {
46+
mOutputTriggers.emplace_back(trg.getBCData(), currentstart, ncellsTrigger);
47+
continue;
48+
}
49+
gsl::span<const o2::emcal::Digit> digits(digitsAll.data() + trg.getFirstEntry(), trg.getNumberOfObjects());
50+
for (const auto& dig : digits) {
51+
ChannelType_t chantype;
52+
if (dig.getHighGain())
53+
chantype = ChannelType_t::HIGH_GAIN;
54+
else if (dig.getLowGain())
55+
chantype = ChannelType_t::LOW_GAIN;
56+
else if (dig.getTRU())
57+
chantype = ChannelType_t::TRU;
58+
else if (dig.getLEDMon())
59+
chantype = ChannelType_t::LEDMON;
60+
mOutputCells.emplace_back(dig.getTower(), dig.getEnergy(), dig.getTimeStamp(), chantype);
61+
ncellsTrigger++;
62+
}
63+
mOutputTriggers.emplace_back(trg.getBCData(), currentstart, ncellsTrigger);
64+
currentstart = mOutputCells.size();
65+
ncellsTrigger = 0;
5166
}
5267
LOG(DEBUG) << "[EMCALCellConverter - run] Writing " << mOutputCells.size() << " cells ...";
5368
ctx.outputs().snapshot(o2::framework::Output{"EMC", "CELLS", 0, o2::framework::Lifetime::Timeframe}, mOutputCells);
69+
ctx.outputs().snapshot(o2::framework::Output{"EMC", "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe}, mOutputTriggers);
5470
if (mPropagateMC) {
5571
// copy mc truth container without modification
5672
// as indexing doesn't change
@@ -64,7 +80,9 @@ o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getCellConverterSpec(
6480
std::vector<o2::framework::InputSpec> inputs;
6581
std::vector<o2::framework::OutputSpec> outputs;
6682
inputs.emplace_back("digits", o2::header::gDataOriginEMC, "DIGITS", 0, o2::framework::Lifetime::Timeframe);
83+
inputs.emplace_back("triggers", "EMC", "DIGITSTRGR", 0, o2::framework::Lifetime::Timeframe);
6784
outputs.emplace_back("EMC", "CELLS", 0, o2::framework::Lifetime::Timeframe);
85+
outputs.emplace_back("EMC", "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe);
6886
if (propagateMC) {
6987
inputs.emplace_back("digitsmctr", "EMC", "DIGITSMCTR", 0, o2::framework::Lifetime::Timeframe);
7088
outputs.emplace_back("EMC", "CELLSMCTR", 0, o2::framework::Lifetime::Timeframe);

Detectors/EMCAL/workflow/src/DigitsPrinterSpec.cxx

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,87 @@
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
1010

11-
#include <vector>
1211
#include <iostream>
12+
#include <vector>
13+
#include <type_traits>
14+
#include <gsl/span>
1315

1416
#include "FairLogger.h"
1517

1618
#include "Framework/ControlService.h"
1719
#include "Framework/DataRefUtils.h"
1820
#include "DataFormatsEMCAL/EMCALBlockHeader.h"
21+
#include "DataFormatsEMCAL/Cell.h"
1922
#include "DataFormatsEMCAL/Digit.h"
23+
#include "DataFormatsEMCAL/TriggerRecord.h"
2024
#include "EMCALWorkflow/DigitsPrinterSpec.h"
2125

2226
using namespace o2::emcal::reco_workflow;
2327

24-
void DigitsPrinterSpec::init(framework::InitContext& ctx)
28+
template <class InputType>
29+
void DigitsPrinterSpec<InputType>::init(o2::framework::InitContext& ctx)
2530
{
2631
}
2732

28-
void DigitsPrinterSpec::run(framework::ProcessingContext& pc)
33+
template <class InputType>
34+
void DigitsPrinterSpec<InputType>::run(framework::ProcessingContext& pc)
2935
{
3036
// Get the EMCAL block header and check whether it contains digits
3137
LOG(DEBUG) << "[EMCALDigitsPrinter - process] called";
32-
auto dataref = pc.inputs().get("digits");
38+
std::string objectbranch;
39+
if constexpr (std::is_same<InputType, o2::emcal::Digit>::value)
40+
objectbranch = "digits";
41+
else if constexpr (std::is_same<InputType, o2::emcal::Cell>::value)
42+
objectbranch = "cells";
43+
else {
44+
LOG(ERROR) << "Unsupported input type ... ";
45+
return;
46+
}
47+
auto dataref = pc.inputs().get(objectbranch);
3348
auto const* emcheader = o2::framework::DataRefUtils::getHeader<o2::emcal::EMCALBlockHeader*>(dataref);
3449
if (!emcheader->mHasPayload) {
3550
LOG(DEBUG) << "[EMCALDigitsPrinter - process] No more digits" << std::endl;
3651
pc.services().get<o2::framework::ControlService>().readyToQuit(framework::QuitRequest::Me);
3752
return;
3853
}
3954

40-
auto digits = pc.inputs().get<std::vector<o2::emcal::Digit>>("digits");
41-
std::cout << "[EMCALDigitsPrinter - process] receiveed " << digits.size() << " digits ..." << std::endl;
42-
if (digits.size()) {
43-
for (const auto& d : digits) {
44-
std::cout << "[EMCALDigitsPrinter - process] Channel: " << d.getTower() << std::endl;
45-
std::cout << "[EMCALDigitsPrinter - process] Energy: " << d.getEnergy() << std::endl;
46-
//std::cout << d << std::endl;
55+
auto objects = pc.inputs().get<gsl::span<InputType>>(objectbranch);
56+
auto triggerrecords = pc.inputs().get<gsl::span<o2::emcal::TriggerRecord>>("triggerrecord");
57+
std::cout << "[EMCALDigitsPrinter - process] receiveed " << objects.size() << " digits from " << triggerrecords.size() << " triggers ..." << std::endl;
58+
if (triggerrecords.size()) {
59+
for (const auto& trg : triggerrecords) {
60+
if (!trg.getNumberOfObjects()) {
61+
std::cout << "[EMCALDigitsPrinter - process] Trigger does not contain " << objectbranch << ", skipping ..." << std::endl;
62+
continue;
63+
}
64+
std::cout << "[EMCALDigitsPrinter - process] Trigger has " << trg.getNumberOfObjects() << " " << objectbranch << " ..." << std::endl;
65+
gsl::span<const InputType> objectsTrigger(objects.data() + trg.getFirstEntry(), trg.getNumberOfObjects());
66+
for (const auto& d : objectsTrigger) {
67+
std::cout << "[EMCALDigitsPrinter - process] Channel: " << d.getTower() << std::endl;
68+
std::cout << "[EMCALDigitsPrinter - process] Energy: " << d.getEnergy() << std::endl;
69+
//std::cout << d << std::endl;
70+
}
4771
}
4872
}
4973
}
5074

51-
o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getEmcalDigitsPrinterSpec()
75+
o2::framework::DataProcessorSpec o2::emcal::reco_workflow::getEmcalDigitsPrinterSpec(std::string inputtype)
5276
{
53-
54-
return o2::framework::DataProcessorSpec{"EMCALDigitsPrinter",
55-
{{"digits", o2::header::gDataOriginEMC, "DIGITS", 0, o2::framework::Lifetime::Timeframe}},
56-
{},
57-
o2::framework::adaptFromTask<o2::emcal::reco_workflow::DigitsPrinterSpec>()};
77+
if (inputtype == "digits") {
78+
return o2::framework::DataProcessorSpec{"EMCALDigitsPrinter",
79+
{{"digits", o2::header::gDataOriginEMC, "DIGITS", 0, o2::framework::Lifetime::Timeframe},
80+
{"triggerrecord", o2::header::gDataOriginEMC, "DIGITSTRGR", 0, o2::framework::Lifetime::Timeframe}},
81+
{},
82+
o2::framework::adaptFromTask<o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Digit>>()};
83+
} else if (inputtype == "cells") {
84+
return o2::framework::DataProcessorSpec{"EMCALDigitsPrinter",
85+
{{"cells", o2::header::gDataOriginEMC, "CELLS", 0, o2::framework::Lifetime::Timeframe},
86+
{"triggerrecord", o2::header::gDataOriginEMC, "CELLSTRGR", 0, o2::framework::Lifetime::Timeframe}},
87+
{},
88+
o2::framework::adaptFromTask<o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Cell>>()};
89+
}
90+
throw std::runtime_error("Input type not supported");
5891
}
92+
93+
//template class o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Digit>;
94+
//template class o2::emcal::reco_workflow::DigitsPrinterSpec<o2::emcal::Cell>;

0 commit comments

Comments
 (0)