3939
4040#include < TPDGCode.h>
4141
42- #include < string>
4342#include < gsl/span>
4443#include < span>
44+ #include < string>
4545#include < vector>
4646
4747using namespace o2 ;
@@ -68,25 +68,24 @@ static const std::vector<int> pdgCodes{kK0Short,
6868
6969struct OnTheFlyDecayer {
7070 Produces<aod::McParticlesWithDau> tableMcParticlesWithDau;
71+
7172 o2::upgrade::Decayer decayer;
7273 Service<o2::framework::O2DatabasePDG> pdgDB;
73- HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
7474 std::map<int64_t , std::vector<o2::upgrade::OTFParticle>> mDecayDaughters ;
7575
7676 Configurable<int > seed{" seed" , 0 , " Set seed for particle decayer" };
7777 Configurable<float > magneticField{" magneticField" , 20 ., " Magnetic field (kG)" };
7878 Configurable<LabeledArray<int >> enabledDecays{" enabledDecays" ,
79- {defaultParameters[0 ], kNumDecays , kNumParameters , particleNames, parameterNames},
80- " Enable option for particle to be decayed: 0 - no, 1 - yes" };
81-
79+ {defaultParameters[0 ], kNumDecays , kNumParameters , particleNames, parameterNames},
80+ " Enable option for particle to be decayed: 0 - no, 1 - yes" };
8281
82+ HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
8383 ConfigurableAxis axisPt{" axisPt" , {VARIABLE_WIDTH, 0 .0f , 0 .1f , 0 .2f , 0 .3f , 0 .4f , 0 .5f , 0 .6f , 0 .7f , 0 .8f , 0 .9f , 1 .0f , 1 .1f , 1 .2f , 1 .3f , 1 .4f , 1 .5f , 1 .6f , 1 .7f , 1 .8f , 1 .9f , 2 .0f , 2 .2f , 2 .4f , 2 .6f , 2 .8f , 3 .0f , 3 .2f , 3 .4f , 3 .6f , 3 .8f , 4 .0f , 4 .4f , 4 .8f , 5 .2f , 5 .6f , 6 .0f , 6 .5f , 7 .0f , 7 .5f , 8 .0f , 9 .0f , 10 .0f , 11 .0f , 12 .0f , 13 .0f , 14 .0f , 15 .0f , 17 .0f , 19 .0f , 21 .0f , 23 .0f , 25 .0f , 30 .0f , 35 .0f , 40 .0f , 50 .0f }, " pt axis for QA histograms" };
8484
85-
8685 std::vector<int > mEnabledDecays ;
8786 void init (o2::framework::InitContext&)
8887 {
89- decayer.setSeed (seed);
88+ decayer.setSeed (seed);
9089 decayer.setBField (magneticField);
9190 for (int i = 0 ; i < kNumDecays ; ++i) {
9291 if (enabledDecays->get (particleNames[i].c_str (), " enable" )) {
@@ -106,7 +105,7 @@ struct OnTheFlyDecayer {
106105 bool canDecay (const int pdgCode)
107106 {
108107 return std::find (mEnabledDecays .begin (), mEnabledDecays .end (), pdgCode) != mEnabledDecays .end ();
109- }
108+ }
110109
111110 void process (aod::McCollision const &, aod::McParticles const & mcParticles)
112111 {
@@ -141,8 +140,7 @@ struct OnTheFlyDecayer {
141140 continue ;
142141 }
143142 }
144-
145-
143+
146144 if (particle.pdgCode () == kK0Short ) {
147145 histos.fill (HIST (" K0S/hGenK0S" ), particle.pt ());
148146 } else if (particle.pdgCode () == kLambda0 ) {
@@ -192,9 +190,9 @@ struct OnTheFlyDecayer {
192190
193191 // TODO: Particle status code
194192 // TODO: Expression columns
195- tableMcParticlesWithDau (particle.mcCollisionId (), particle.pdgCode (), particle.statusCode (),
193+ tableMcParticlesWithDau (particle.mcCollisionId (), particle.pdgCode (), particle.statusCode (),
196194 particle.flags (), motherSpan, daughtersIdSlice, particle.weight (),
197- particle.px (), particle.py (), particle.pz (), particle.e (),
195+ particle.px (), particle.py (), particle.pz (), particle.e (),
198196 particle.vx (), particle.vy (), particle.vz (), particle.vt (),
199197 phi, eta, pt, p, y);
200198 }
@@ -208,7 +206,7 @@ struct OnTheFlyDecayer {
208206 }
209207
210208 auto mother = mcParticles.iteratorAt (index);
211- std::vector<int > motherIds = { static_cast <int >(index) };
209+ std::vector<int > motherIds = {static_cast <int >(index)};
212210 std::span<const int > motherSpan (motherIds.data (), motherIds.size ());
213211
214212 float phi = o2::constants::math::PI + std::atan2 (-1 .0f * dau.py (), -1 .0f * dau.px ());
@@ -229,11 +227,11 @@ struct OnTheFlyDecayer {
229227 y = 0 .5f * std::log ((dau.e () + dau.pz ()) / (dau.e () - dau.pz ()));
230228 }
231229
232-
233230 // TODO: Particle status code
234231 // TODO: Expression columns
232+ // TODO: vt
235233 tableMcParticlesWithDau (mother.mcCollisionId (), dau.pdgCode (), 1 ,
236- mother.flags (), motherSpan, daughtersIdSlice, mother.weight (),
234+ mother.flags (), motherSpan, daughtersIdSlice, mother.weight (),
237235 dau.px (), dau.py (), dau.pz (), dau.e (),
238236 dau.vx (), dau.vy (), dau.vz (), mother.vt (),
239237 phi, eta, pt, p, y);
@@ -242,8 +240,7 @@ struct OnTheFlyDecayer {
242240 }
243241};
244242
245-
246243WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
247244{
248245 return WorkflowSpec{adaptAnalysisTask<OnTheFlyDecayer>(cfgc)};
249- }
246+ }
0 commit comments