Skip to content

Commit cb09203

Browse files
Fixes + new structs for v0 grouping
1 parent 5d140bc commit cb09203

File tree

2 files changed

+248
-17
lines changed

2 files changed

+248
-17
lines changed

PWGLF/TableProducer/QC/sigma0QC.cxx

Lines changed: 123 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ struct sigma0Sorted {
6666
ctpRateFetcher rateFetcher;
6767

6868
// Load configurables and the sigma0 module, please
69+
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
6970
o2::pwglf::sigma0::evselConfigurables evselOpts;
7071
o2::pwglf::sigma0::lambdaselConfigurables lambdaselOpts;
7172
o2::pwglf::sigma0::photonselConfigurables photonselOpts;
7273
o2::pwglf::sigma0::sigma0selConfigurables sigma0selOpts;
7374
o2::pwglf::sigma0::pi0selConfigurables pi0selOpts;
74-
o2::pwglf::sigma0::axisConfigurables axisOpts;
75+
o2::pwglf::sigma0::axisConfigurables axisOpts;
7576

7677
o2::pwglf::sigma0::Sigma0BuilderModule sigma0Module;
7778

@@ -81,7 +82,6 @@ struct sigma0Sorted {
8182

8283
// Histogram registry
8384
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
84-
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
8585

8686
void init(InitContext const&)
8787
{
@@ -101,7 +101,7 @@ struct sigma0Sorted {
101101
void processRealData(StraColls const& collisions, V0StandardDerivedDatas const& fullV0s, dauTracks const&){
102102
auto start = std::chrono::high_resolution_clock::now();
103103

104-
sigma0Module.process(collisions, fullV0s, histos, cache, ccdb, rateFetcher);
104+
sigma0Module.processSlicing(collisions, fullV0s, perCollisionSTDDerived, histos, ccdb, rateFetcher);
105105

106106
auto end = std::chrono::high_resolution_clock::now();
107107
std::chrono::duration<double> elapsed = end - start;
@@ -117,12 +117,13 @@ struct sigma0Unsorted {
117117
ctpRateFetcher rateFetcher;
118118

119119
// Load configurables and the sigma0 module, please
120+
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
120121
o2::pwglf::sigma0::evselConfigurables evselOpts;
121122
o2::pwglf::sigma0::lambdaselConfigurables lambdaselOpts;
122123
o2::pwglf::sigma0::photonselConfigurables photonselOpts;
123124
o2::pwglf::sigma0::sigma0selConfigurables sigma0selOpts;
124125
o2::pwglf::sigma0::pi0selConfigurables pi0selOpts;
125-
o2::pwglf::sigma0::axisConfigurables axisOpts;
126+
o2::pwglf::sigma0::axisConfigurables axisOpts;
126127

127128
o2::pwglf::sigma0::Sigma0BuilderModule sigma0Module;
128129

@@ -131,8 +132,7 @@ struct sigma0Unsorted {
131132
PresliceUnsorted<V0StandardDerivedDatas> perCollisionSTDDerived = o2::aod::v0data::straCollisionId;
132133

133134
// Histogram registry
134-
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
135-
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
135+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
136136

137137
void init(InitContext const&)
138138
{
@@ -152,20 +152,134 @@ struct sigma0Unsorted {
152152
void processRealData(StraColls const& collisions, V0StandardDerivedDatas const& fullV0s, dauTracks const&){
153153
auto start = std::chrono::high_resolution_clock::now();
154154

155-
sigma0Module.process(collisions, fullV0s, histos, cache, ccdb, rateFetcher);
155+
sigma0Module.processSlicing(collisions, fullV0s, perCollisionSTDDerived, histos, ccdb, rateFetcher);
156156

157157
auto end = std::chrono::high_resolution_clock::now();
158158
std::chrono::duration<double> elapsed = end - start;
159159

160-
if (fverbose) LOGF(info, "[Process function call, Sorted] N. Collisions: %i, N. V0s: %i, Processing time (s): %lf", collisions.size(), fullV0s.size(), elapsed.count());
160+
if (fverbose) LOGF(info, "[Process function call, Unsorted] N. Collisions: %i, N. V0s: %i, Processing time (s): %lf", collisions.size(), fullV0s.size(), elapsed.count());
161161
}
162162

163163
PROCESS_SWITCH(sigma0Unsorted, processRealData, "process run 3 real data", true);
164164
};
165165

166+
struct sigma0Iterator {
167+
Service<o2::ccdb::BasicCCDBManager> ccdb;
168+
ctpRateFetcher rateFetcher;
169+
170+
// Load configurables and the sigma0 module, please
171+
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
172+
o2::pwglf::sigma0::evselConfigurables evselOpts;
173+
o2::pwglf::sigma0::lambdaselConfigurables lambdaselOpts;
174+
o2::pwglf::sigma0::photonselConfigurables photonselOpts;
175+
o2::pwglf::sigma0::sigma0selConfigurables sigma0selOpts;
176+
o2::pwglf::sigma0::pi0selConfigurables pi0selOpts;
177+
o2::pwglf::sigma0::axisConfigurables axisOpts;
178+
179+
o2::pwglf::sigma0::Sigma0BuilderModule sigma0Module;
180+
181+
// Histogram registry
182+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
183+
uint64_t CollIDBuffer = 0;
184+
std::chrono::high_resolution_clock::time_point start{};
185+
std::chrono::high_resolution_clock::time_point end{};
186+
void init(InitContext const&)
187+
{
188+
// setting CCDB service
189+
ccdb->setURL("http://alice-ccdb.cern.ch");
190+
ccdb->setCaching(true);
191+
ccdb->setLocalObjectValidityChecking();
192+
ccdb->setFatalWhenNull(false);
193+
194+
// Initialize task
195+
sigma0Module.init(histos, evselOpts, lambdaselOpts, photonselOpts, sigma0selOpts, pi0selOpts, axisOpts);
196+
}
197+
198+
// Dummy process function
199+
void process(V0StandardDerivedDatas const&){}
200+
201+
void processCheckIndexOrdered(V0StandardDerivedDatas const& fullV0s){
202+
CollIDBuffer=0;
203+
for (const auto& v0 : fullV0s) {
204+
const uint64_t v0collidx = v0.straCollisionId();
205+
if (v0collidx < CollIDBuffer)
206+
LOGF(fatal, "V0 -> stracollision: index unsorted! Previous index: %i, current index: %i", CollIDBuffer, v0collidx);
207+
CollIDBuffer = v0collidx;
208+
}
209+
}
210+
void processTI(StraColls const&){
211+
start = std::chrono::high_resolution_clock::now();
212+
}
213+
214+
void processRealData(StraColls::iterator const& collision, V0StandardDerivedDatas const& fullV0s, dauTracks const&){
215+
sigma0Module.processIterator(collision, fullV0s, histos, ccdb, rateFetcher);
216+
}
217+
218+
void processTF(StraColls const& collisions, V0StandardDerivedDatas const& fullV0s){
219+
end = std::chrono::high_resolution_clock::now();
220+
std::chrono::duration<double> elapsed = end - start;
221+
222+
if (fverbose) LOGF(info, "[Process function call, Iterator] N. Collisions: %i, N. V0s: %i, Processing time (s): %lf", collisions.size(), fullV0s.size(), elapsed.count());
223+
}
224+
225+
PROCESS_SWITCH(sigma0Iterator, processCheckIndexOrdered, "check ordering", true);
226+
PROCESS_SWITCH(sigma0Iterator, processTI, "Initial setup", true);
227+
PROCESS_SWITCH(sigma0Iterator, processRealData, "process data", true);
228+
PROCESS_SWITCH(sigma0Iterator, processTF, "Printouts", true);
229+
};
230+
231+
struct sigma0CustomGrouping {
232+
Service<o2::ccdb::BasicCCDBManager> ccdb;
233+
ctpRateFetcher rateFetcher;
234+
235+
// Load configurables and the sigma0 module, please
236+
Configurable<bool> fverbose{"fverbose", true, "QA printout."};
237+
o2::pwglf::sigma0::evselConfigurables evselOpts;
238+
o2::pwglf::sigma0::lambdaselConfigurables lambdaselOpts;
239+
o2::pwglf::sigma0::photonselConfigurables photonselOpts;
240+
o2::pwglf::sigma0::sigma0selConfigurables sigma0selOpts;
241+
o2::pwglf::sigma0::pi0selConfigurables pi0selOpts;
242+
o2::pwglf::sigma0::axisConfigurables axisOpts;
243+
244+
o2::pwglf::sigma0::Sigma0BuilderModule sigma0Module;
245+
246+
// Histogram registry
247+
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
248+
249+
void init(InitContext const&)
250+
{
251+
// setting CCDB service
252+
ccdb->setURL("http://alice-ccdb.cern.ch");
253+
ccdb->setCaching(true);
254+
ccdb->setLocalObjectValidityChecking();
255+
ccdb->setFatalWhenNull(false);
256+
257+
// Initialize task
258+
sigma0Module.init(histos, evselOpts, lambdaselOpts, photonselOpts, sigma0selOpts, pi0selOpts, axisOpts);
259+
}
260+
261+
// Dummy process function
262+
void process(StraColls const&){}
263+
264+
void processRealData(StraColls const& collisions, V0StandardDerivedDatas const& fullV0s, dauTracks const&){
265+
auto start = std::chrono::high_resolution_clock::now();
266+
267+
sigma0Module.processCustomGrouping(collisions, fullV0s, histos, ccdb, rateFetcher);
268+
269+
auto end = std::chrono::high_resolution_clock::now();
270+
std::chrono::duration<double> elapsed = end - start;
271+
272+
if (fverbose) LOGF(info, "[Process function call, Custom] N. Collisions: %i, N. V0s: %i, Processing time (s): %lf", collisions.size(), fullV0s.size(), elapsed.count());
273+
}
274+
275+
PROCESS_SWITCH(sigma0CustomGrouping, processRealData, "process run 3 real data", true);
276+
};
277+
166278
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
167279
{
168280
return WorkflowSpec{
169281
adaptAnalysisTask<sigma0Sorted>(cfgc),
170-
adaptAnalysisTask<sigma0Unsorted>(cfgc)};
282+
adaptAnalysisTask<sigma0Unsorted>(cfgc),
283+
adaptAnalysisTask<sigma0Iterator>(cfgc),
284+
adaptAnalysisTask<sigma0CustomGrouping>(cfgc)};
171285
}

PWGLF/Utils/sigma0BuilderHelper.h

Lines changed: 125 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -474,27 +474,94 @@ class Sigma0BuilderModule
474474

475475
// ______________________________________________________
476476
// Real data processing - no MC subscription
477-
template <typename TCollision, typename TV0s, typename THistoRegistry, typename TSlicecache, typename TCCDB, typename TRateFetcher>
478-
void process(TCollision const& collisions, TV0s const& fullV0s, THistoRegistry& histos, TSlicecache& cache, TCCDB const& ccdb, TRateFetcher& rateFetcher)
477+
template <typename TCollision, typename TV0s, typename TSlicer, typename THistoRegistry, typename TCCDB, typename TRateFetcher>
478+
void processSlicing(TCollision const& collisions, TV0s const& fullV0s, TSlicer& slicer, THistoRegistry& histos, TCCDB const& ccdb, TRateFetcher& rateFetcher)
479479
{
480480
uint64_t CollIDBuffer = 0;
481481
for (const auto& coll : collisions) {
482482
if (!IsEventAccepted(coll, histos, ccdb, rateFetcher))
483483
continue;
484484

485485
const uint64_t collIdx = coll.globalIndex();
486-
if (collIdx < CollIDBuffer)
487-
LOGF(fatal, "Collision table unsorted! Previous index: %i, current index: %i", CollIDBuffer, collIdx);
488-
489-
CollIDBuffer = collIdx;
490486

491487
//_______________________________________________
492488
// V0s loop
493489
std::vector<int> bestGammasArray;
494490
std::vector<int> bestLambdasArray;
495491

496-
auto V0s = fullV0s.sliceByCached(o2::aod::v0data::straCollisionId, collIdx, cache);
492+
auto V0s = fullV0s.sliceBy(slicer, collIdx);
497493
for (auto& v0 : V0s) {
494+
const uint64_t v0collidx = v0.straCollisionId();
495+
if (v0collidx < CollIDBuffer)
496+
LOGF(fatal, "Collision table unsorted! Previous index: %i, current index: %i", CollIDBuffer, v0collidx);
497+
498+
if (processPhotonCandidate(v0, coll, histos)) // selecting photons
499+
bestGammasArray.push_back(v0.globalIndex()); // Save indices of best gamma candidates
500+
501+
if (processLambdaCandidate(v0, coll, histos)) // selecting lambdas
502+
bestLambdasArray.push_back(v0.globalIndex()); // Save indices of best lambda candidates
503+
504+
CollIDBuffer = v0collidx;
505+
}
506+
507+
508+
//_______________________________________________
509+
// Pi0 optional loop
510+
if (pi0selOpts.doPi0QA) {
511+
for (size_t i = 0; i < bestGammasArray.size(); ++i) {
512+
auto gamma1 = fullV0s.rawIteratorAt(bestGammasArray[i]);
513+
for (size_t j = i + 1; j < bestGammasArray.size(); ++j) {
514+
auto gamma2 = fullV0s.rawIteratorAt(bestGammasArray[j]);
515+
runPi0QA(gamma1, gamma2, coll, histos);
516+
}
517+
}
518+
}
519+
520+
//_______________________________________________
521+
// Sigma0 nested loop
522+
for (size_t i = 0; i < bestGammasArray.size(); ++i) {
523+
auto gamma = fullV0s.rawIteratorAt(bestGammasArray[i]);
524+
525+
for (size_t j = 0; j < bestLambdasArray.size(); ++j) {
526+
auto lambda = fullV0s.rawIteratorAt(bestLambdasArray[j]);
527+
528+
// Building sigma0 candidate
529+
if (!buildSigma0(lambda, gamma, coll, histos))
530+
continue;
531+
}
532+
}
533+
}
534+
} // end processSlicing
535+
536+
// ______________________________________________________
537+
// Real data processing - no MC subscription
538+
template <typename TCollision, typename TV0s, typename THistoRegistry, typename TCCDB, typename TRateFetcher>
539+
void processCustomGrouping(TCollision const& collisions, TV0s const& fullV0s, THistoRegistry& histos, TCCDB const& ccdb, TRateFetcher& rateFetcher)
540+
{
541+
uint64_t CollIDBuffer = 0;
542+
// brute force grouped index construction
543+
std::vector<std::vector<int>> v0grouped(collisions.size());
544+
545+
for (const auto& v0 : fullV0s) {
546+
v0grouped[v0.straCollisionId()].push_back(v0.globalIndex());
547+
548+
const uint64_t v0collidx = v0.straCollisionId();
549+
if (v0collidx < CollIDBuffer)
550+
LOGF(fatal, "V0 -> stracollision: index unsorted! Previous index: %i, current index: %i", CollIDBuffer, v0collidx);
551+
CollIDBuffer = v0collidx;
552+
}
553+
554+
for (const auto& coll : collisions) {
555+
if (!IsEventAccepted(coll, histos, ccdb, rateFetcher))
556+
continue;
557+
558+
//_______________________________________________
559+
// V0s loop
560+
std::vector<int> bestGammasArray;
561+
std::vector<int> bestLambdasArray;
562+
563+
for (size_t i = 0; i < v0grouped[coll.globalIndex()].size(); i++) {
564+
auto v0 = fullV0s.rawIteratorAt(v0grouped[coll.globalIndex()][i]);
498565
if (processPhotonCandidate(v0, coll, histos)) // selecting photons
499566
bestGammasArray.push_back(v0.globalIndex()); // Save indices of best gamma candidates
500567

@@ -529,7 +596,57 @@ class Sigma0BuilderModule
529596
}
530597
}
531598
}
532-
} // end process
599+
} // end processCustomGrouping
600+
601+
// ______________________________________________________
602+
// Real data processing - no MC subscription
603+
template <typename TCollision, typename TV0s, typename THistoRegistry, typename TCCDB, typename TRateFetcher>
604+
void processIterator(TCollision const& coll, TV0s const& fullV0s, THistoRegistry& histos, TCCDB const& ccdb, TRateFetcher& rateFetcher)
605+
{
606+
if (!IsEventAccepted(coll, histos, ccdb, rateFetcher))
607+
return;
608+
609+
//_______________________________________________
610+
// V0s loop
611+
std::vector<int> bestGammasArray;
612+
std::vector<int> bestLambdasArray;
613+
614+
for (auto& v0 : fullV0s) {
615+
if (processPhotonCandidate(v0, coll, histos)) // selecting photons
616+
bestGammasArray.push_back(v0.globalIndex() - fullV0s.offset()); // Save indices of best gamma candidates
617+
618+
if (processLambdaCandidate(v0, coll, histos)) // selecting lambdas
619+
bestLambdasArray.push_back(v0.globalIndex() - fullV0s.offset()); // Save indices of best lambda candidates
620+
}
621+
622+
//_______________________________________________
623+
// Pi0 optional loop
624+
if (pi0selOpts.doPi0QA) {
625+
for (size_t i = 0; i < bestGammasArray.size(); ++i) {
626+
auto gamma1 = fullV0s.rawIteratorAt(bestGammasArray[i]);
627+
for (size_t j = i + 1; j < bestGammasArray.size(); ++j) {
628+
auto gamma2 = fullV0s.rawIteratorAt(bestGammasArray[j]);
629+
runPi0QA(gamma1, gamma2, coll, histos);
630+
}
631+
}
632+
}
633+
634+
//_______________________________________________
635+
// Sigma0 nested loop
636+
for (size_t i = 0; i < bestGammasArray.size(); ++i) {
637+
auto gamma = fullV0s.rawIteratorAt(bestGammasArray[i]);
638+
639+
for (size_t j = 0; j < bestLambdasArray.size(); ++j) {
640+
auto lambda = fullV0s.rawIteratorAt(bestLambdasArray[j]);
641+
642+
// Building sigma0 candidate
643+
if (!buildSigma0(lambda, gamma, coll, histos))
644+
continue;
645+
}
646+
}
647+
648+
} // end processIterator
649+
533650
}; // end Sigma0BuilderModule
534651

535652
} // namespace sigma0

0 commit comments

Comments
 (0)