|
| 1 | +class SmearO2KineGenerator : public o2::eventgen::GeneratorFromO2Kine |
| 2 | +{ |
| 3 | + |
| 4 | +public: |
| 5 | + |
| 6 | + SmearO2KineGenerator(const char *name) : GeneratorFromO2Kine(name) { }; |
| 7 | + bool Init() override { |
| 8 | + auto retval = o2::eventgen::GeneratorFromO2Kine::Init(); |
| 9 | + setContinueMode(true); |
| 10 | + return retval; }; |
| 11 | + |
| 12 | + // bool importParticles() override { |
| 13 | + |
| 14 | +protected: |
| 15 | + |
| 16 | + |
| 17 | +}; |
| 18 | + |
| 19 | + |
| 20 | +void |
| 21 | +smear_o2_kine(const char *o2kinefilename) |
| 22 | +{ |
| 23 | + |
| 24 | + o2::delphes::TrackSmearer smearer; |
| 25 | + smearer.loadTable(11, "lutCovm.el.dat"); |
| 26 | + smearer.loadTable(13, "lutCovm.mu.dat"); |
| 27 | + smearer.loadTable(211, "lutCovm.pi.dat"); |
| 28 | + smearer.loadTable(321, "lutCovm.ka.dat"); |
| 29 | + smearer.loadTable(2212, "lutCovm.pr.dat"); |
| 30 | + |
| 31 | + auto gen = new SmearO2KineGenerator(o2kinefilename); |
| 32 | + gen->Init(); |
| 33 | + |
| 34 | + // loop over events |
| 35 | + while (gen->importParticles()) { |
| 36 | + auto particles = gen->getParticles(); |
| 37 | + |
| 38 | + // loop over particles |
| 39 | + for (auto & particle : particles) { |
| 40 | + |
| 41 | + // we did not transport them before, we do not smear them either |
| 42 | + if (std::fabs(particle.Eta()) > 1.0) continue; |
| 43 | + |
| 44 | + // only particles to be transported, which are flagged as status code = 1 |
| 45 | + // the particles that have been transported already have status code = 0 |
| 46 | + if (particle.GetStatusCode() != 1) continue; |
| 47 | + |
| 48 | + // only particles that we know how to smear |
| 49 | + // namely el, mu, pi, ka, pr |
| 50 | + auto pdg = std::abs(particle.GetPdgCode()); |
| 51 | + if (pdg != 11 && pdg != 13 && pdg != 211 && pdg != 321 && pdg != 2212) continue; |
| 52 | + |
| 53 | + // convert particle to o2 track and smear it |
| 54 | + O2Track o2track; |
| 55 | + o2::delphes::TrackUtils::convertTParticleToO2Track(particle, o2track); |
| 56 | + float nch = 1600.; |
| 57 | + o2track.print(); |
| 58 | + if (!smearer.smearTrack(o2track, pdg, nch)) continue; |
| 59 | + o2track.print(); |
| 60 | + |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | +} |
0 commit comments