1818#include " ALICE3/Core/Decayer.h"
1919#include " ALICE3/Core/OTFParticle.h"
2020#include " ALICE3/Core/TrackUtilities.h"
21- #include " ALICE3/DataModel/OTFMCParticle .h"
21+ #include " ALICE3/DataModel/tracksAlice3 .h"
2222
2323#include < Framework/AnalysisDataModel.h>
2424#include < Framework/AnalysisHelpers.h>
4040#include < array>
4141#include < cmath>
4242#include < cstdlib>
43- #include < map>
4443#include < string>
4544#include < vector>
4645
@@ -67,12 +66,18 @@ static const std::vector<int> pdgCodes{PDG_t::kK0Short,
6766 PDG_t::kOmegaMinus ,
6867 PDG_t::kOmegaPlusBar };
6968
69+ namespace o2 ::aod
70+ {
71+ O2ORIGIN (" TMP" );
72+ }
73+
7074struct OnTheFlyDecayer {
71- Produces<aod::McPartWithDaus> tableMcParticlesWithDau;
75+ Produces<aod::McCollisions_001> tableMcCollisions;
76+ Produces<aod::StoredMcParticles_001> tableMcParticles;
77+ Produces<aod::OTFDecayerBits> tableOTFDecayerBits;
7278
7379 o2::upgrade::Decayer decayer;
7480 Service<o2::framework::O2DatabasePDG> pdgDB;
75- std::map<int , std::vector<o2::upgrade::OTFParticle>> mDecayDaughters ;
7681 HistogramRegistry histos{" histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
7782
7883 Configurable<int > seed{" seed" , 0 , " Set seed for particle decayer" };
@@ -117,18 +122,18 @@ struct OnTheFlyDecayer {
117122 void decayParticles (const int start, const int stop)
118123 {
119124 int ndau = 0 ;
120- for (int i = start; i < stop; i++ ) {
125+ for (int i = start; i < stop; ++i ) {
121126 o2::upgrade::OTFParticle& particle = allParticles[i];
122127 if (particle.isFromMcParticles ()) {
123- particle.setIsPrimary ( true );
124- particle.setIsAlive ( true );
128+ particle.setBitOn (o2::upgrade::DecayerBits::IsPrimary );
129+ particle.setBitOn (o2::upgrade::DecayerBits::IsAlive );
125130 }
126131
127132 if (!canDecay (particle)) {
128133 continue ;
129134 }
130135
131- particle.setIsAlive ( false );
136+ particle.setBitOff (o2::upgrade::DecayerBits::IsAlive );
132137 std::vector<o2::upgrade::OTFParticle> decayStack = decayer.decayParticle (pdgDB, particle);
133138 const float decayRadius = decayer.getDecayRadius ();
134139 const float trackVelocity = o2::upgrade::computeParticleVelocity (particle.p (), pdgDB->GetParticle (particle.pdgCode ())->Mass ());
@@ -150,8 +155,8 @@ struct OnTheFlyDecayer {
150155 for (o2::upgrade::OTFParticle daughter : decayStack) {
151156 daughter.setIndicesMother (i, i);
152157 daughter.setCollisionId (mCollisionId );
153- daughter.setIsAlive ( true );
154- daughter.setIsPrimary ( false );
158+ daughter.setBitOn (o2::upgrade::DecayerBits::IsAlive );
159+ daughter.setBitOff (o2::upgrade::DecayerBits::IsPrimary );
155160 daughter.setProductionTime (trackTimeNS);
156161 allParticles.push_back (daughter);
157162 ndau++;
@@ -165,42 +170,54 @@ struct OnTheFlyDecayer {
165170 decayParticles (stop, stop + ndau);
166171 }
167172
168- void process (aod::McCollision const & collision, aod::McParticles const & mcParticles)
173+ void process (aod::McCollisions_001From<aod::Hash< " TMP " _h>>::iterator const & collision, aod::McParticles_001From<aod::Hash< " TMP " _h>> const & mcParticles)
169174 {
170- mCollisionId = collision.globalIndex ();
171175 allParticles.clear ();
172176
177+ // Reproduce collision table to have AOD origin
178+ mCollisionId = collision.globalIndex ();
179+ tableMcCollisions (collision.bcId (),
180+ collision.generatorsID (),
181+ collision.posX (),
182+ collision.posY (),
183+ collision.posZ (),
184+ collision.t (),
185+ collision.weight (),
186+ collision.impactParameter (),
187+ collision.eventPlaneAngle ());
188+
173189 // First we copy the particles from the table into a vector that is extendable
174- for (int index{0 }; index < static_cast <int >(mcParticles.size ()); ++index) {
175- const auto & mcParticle = mcParticles.rawIteratorAt (index);
176- allParticles.push_back (o2::upgrade::OTFParticle{mcParticle});
190+ for (const auto & particle : mcParticles) {
191+ allParticles.emplace_back (o2::upgrade::OTFParticle{particle});
177192 }
178193
179194 // Do all decays
180195 decayParticles (0 , allParticles.size ());
181196
182197 // Fill output table
183- for (int index{0 }; index < static_cast <int >(allParticles.size ()); ++index) {
184- const auto & otfParticle = allParticles[index];
185-
198+ for (const auto & otfParticle : allParticles) {
186199 if (otfParticle.hasNaN ()) {
187200 histos.fill (HIST (" hNaNBookkeeping" ), 1 );
188201 } else {
189202 histos.fill (HIST (" hNaNBookkeeping" ), 0 );
190203 }
191204
192- // todo: status codes
193- tableMcParticlesWithDau (otfParticle.collisionId (), otfParticle.pdgCode (), otfParticle.statusCode (),
194- otfParticle.flags (), otfParticle.getMotherSpan (), otfParticle.getDaughters ().data (), otfParticle.weight (),
195- otfParticle.px (), otfParticle.py (), otfParticle.pz (), otfParticle.e (),
196- otfParticle.vx (), otfParticle.vy (), otfParticle.vz (), otfParticle.vt (),
197- otfParticle.phi (), otfParticle.eta (), otfParticle.pt (), otfParticle.p (), otfParticle.y (),
198- otfParticle.isAlive (), otfParticle.isPrimary ());
205+ tableOTFDecayerBits (otfParticle.getBitsValue ());
206+ tableMcParticles (otfParticle.collisionId (), otfParticle.pdgCode (), otfParticle.statusCode (), otfParticle.flags (),
207+ otfParticle.getMotherSpan (), otfParticle.getDaughters ().data (), otfParticle.weight (),
208+ otfParticle.px (), otfParticle.py (), otfParticle.pz (), otfParticle.e (),
209+ otfParticle.vx (), otfParticle.vy (), otfParticle.vz (), otfParticle.vt ());
199210 }
200211 }
201212};
202213
214+ struct OnTheFlyDecayerExtensionSpawner {
215+ Spawns<aod::McParticles_001Extension> spawnMcParticlesExtensions;
216+ void init (o2::framework::InitContext&) {}
217+ };
218+
203219WorkflowSpec defineDataProcessing (ConfigContext const & cfgc)
204220{
205- return WorkflowSpec{adaptAnalysisTask<OnTheFlyDecayer>(cfgc)};
221+ return WorkflowSpec{adaptAnalysisTask<OnTheFlyDecayer>(cfgc),
222+ adaptAnalysisTask<OnTheFlyDecayerExtensionSpawner>(cfgc)};
206223}
0 commit comments