@@ -408,35 +408,222 @@ struct TauEventTableProducer {
408408 PROCESS_SWITCH (TauEventTableProducer, processDataSG, " Iterate UD tables with measured data created by SG-Candidate-Producer." , false );
409409
410410 PresliceUnsorted<aod::UDMcParticles> partPerMcCollision = aod::udmcparticle::udMcCollisionId;
411+ // PresliceUnsorted<UDMcParticlesWithUDTracks> partWtrkPerMcCollision = aod::udmcparticle::udMcCollisionId;
411412 PresliceUnsorted<FullMCSGUDCollisions> colPerMcCollision = aod::udcollision::udMcCollisionId;
412- // PresliceUnsorted<FullUDTracks> trackPerMcParticle = aod::udmctracklabel::udMcParticleId;
413+ PresliceUnsorted<FullMCUDTracks> trackPerMcParticle = aod::udmctracklabel::udMcParticleId;
414+ PresliceUnsorted<FullMCUDTracks> trackPerCollision = aod::udtrack::udCollisionId;
413415
414- void processMonteCarlo (UDMcCollisionsWithUDCollisions const & mccollisions,
416+ void processMonteCarlo (aod::UDMcCollisions const & mccollisions,
417+ aod::UDMcParticles const & parts,
415418 FullMCSGUDCollisions const & recolls,
416- FullUDTracks const & tracks,
417- aod::UDMcParticles const & parts)
419+ FullMCUDTracks const & trks)
418420 {
419421
420422 for (const auto & mccoll : mccollisions){
421- if (mccoll.has_udcollisions ()) {
422- auto const & collFromMcColl = mccoll.udcollisions_as <FullMCSGUDCollisions>();
423- LOGF (info, " collision size %i " , collFromMcColl.size ());
424- // auto const& partsFromMcColl = mccoll.udmcparticles_as<aod::UDMcParticles>();
423+
424+ int32_t runNumber = -999 ;
425+ int bc = -999 ;
426+ int nTrks[3 ] = {-999 ,-999 ,-999 };// totalTracks, numContrib, globalNonPVtracks
427+ float vtxPos[3 ] = {-999 .,-999 .,-999 .};
428+ int recoMode = -999 ;
429+ int occupancy = -999 .;
430+ double hadronicRate = -999 .;
431+ int bcSels[8 ] = {-999 ,-999 ,-999 ,-999 ,-999 ,-999 ,-999 ,-999 };
432+ float amplitudesFIT[3 ] = {-999 .,-999 .,-999 .};// FT0A, FT0C, FV0
433+ float timesFIT[3 ] = {-999 .,-999 .,-999 .};// FT0A, FT0C, FV0
434+
435+ float px[2 ] = {-999 ., -999 .};
436+ float py[2 ] = {-999 ., -999 .};
437+ float pz[2 ] = {-999 ., -999 .};
438+ int sign[2 ] = {-999 , -999 };
439+ float dcaxy[2 ] = {-999 ., -999 .};
440+ float dcaz[2 ] = {-999 ., -999 .};
441+ float trkTimeRes[2 ] = {-999 ., -999 .};
442+ uint32_t itsClusterSizesTrk1 = 4294967295 ;
443+ uint32_t itsClusterSizesTrk2 = 4294967295 ;
444+ float tpcSignal[2 ] = {-999 , -999 };
445+ float tpcEl[2 ] = {-999 , -999 };
446+ float tpcMu[2 ] = {-999 , -999 };
447+ float tpcPi[2 ] = {-999 , -999 };
448+ float tpcKa[2 ] = {-999 , -999 };
449+ float tpcPr[2 ] = {-999 , -999 };
450+ float tpcIP[2 ] = {-999 , -999 };
451+ float tofSignal[2 ] = {-999 , -999 };
452+ float tofEl[2 ] = {-999 , -999 };
453+ float tofMu[2 ] = {-999 , -999 };
454+ float tofPi[2 ] = {-999 , -999 };
455+ float tofKa[2 ] = {-999 , -999 };
456+ float tofPr[2 ] = {-999 , -999 };
457+ float tofEP[2 ] = {-999 , -999 };
458+
459+ int trueChannel = -1 ;
460+ bool trueHasRecoColl = false ;
461+ float trueTauX[2 ] = {-999 ., -999 .};
462+ float trueTauY[2 ] = {-999 ., -999 .};
463+ float trueTauZ[2 ] = {-999 ., -999 .};
464+ float trueDaugX[2 ] = {-999 ., -999 .};
465+ float trueDaugY[2 ] = {-999 ., -999 .};
466+ float trueDaugZ[2 ] = {-999 ., -999 .};
467+ int trueDaugPdgCode[2 ] = {-999 ,-999 };
468+
469+ auto const & collFromMcColls = recolls.sliceBy (colPerMcCollision, mccoll.globalIndex ());
470+ // if (mccoll.has_udcollisions()) {
471+ if (collFromMcColls.size () > 0 ) {
472+ trueHasRecoColl = true ;
473+ // auto const& collFromMcColls = mccoll.udcollisions_as<FullMCSGUDCollisions>();
474+ if (collFromMcColls.size () > 1 ) {
475+ printLargeMessage (" Truth collision has more than 1 reco collision. Skipping this event." );
476+ continue ;
477+ }
478+ auto const & collFromMcColl = collFromMcColls.iteratorAt (0 );
479+ auto const & trksFromColl = trks.sliceBy (trackPerCollision, collFromMcColl.globalIndex ());
480+ int countTracksPerCollision = 0 ;
481+ int countGoodNonPVtracks = 0 ;
482+ for (auto const & trkFromColl : trksFromColl){
483+ countTracksPerCollision++;
484+ if (!trkFromColl.isPVContributor ()) {
485+ countGoodNonPVtracks++;
486+ continue ;
487+ }
488+ }
489+
490+ runNumber = collFromMcColl.runNumber ();
491+ bc = collFromMcColl.globalBC ();
492+ nTrks[0 ] = countTracksPerCollision;
493+ nTrks[1 ] = collFromMcColl.numContrib ();
494+ nTrks[2 ] = countGoodNonPVtracks;
495+ vtxPos[0 ] = collFromMcColl.posX ();
496+ vtxPos[1 ] = collFromMcColl.posY ();
497+ vtxPos[2 ] = collFromMcColl.posZ ();
498+ recoMode = collFromMcColl.flags ();
499+ occupancy = collFromMcColl.occupancyInTime ();
500+ hadronicRate = collFromMcColl.hadronicRate ();
501+ bcSels[0 ] = collFromMcColl.trs ();
502+ bcSels[1 ] = collFromMcColl.trofs ();
503+ bcSels[2 ] = collFromMcColl.hmpr ();
504+ bcSels[3 ] = collFromMcColl.tfb ();
505+ bcSels[4 ] = collFromMcColl.itsROFb ();
506+ bcSels[5 ] = collFromMcColl.sbp ();
507+ bcSels[6 ] = collFromMcColl.zVtxFT0vPV ();
508+ bcSels[7 ] = collFromMcColl.vtxITSTPC ();
509+ amplitudesFIT[0 ] = collFromMcColl.totalFT0AmplitudeA ();
510+ amplitudesFIT[1 ] = collFromMcColl.totalFT0AmplitudeC ();
511+ amplitudesFIT[2 ] = collFromMcColl.totalFV0AmplitudeA ();
512+ timesFIT[0 ] = collFromMcColl.timeFT0A ();
513+ timesFIT[1 ] = collFromMcColl.timeFT0C ();
514+ timesFIT[2 ] = collFromMcColl.timeFV0A ();
515+
425516 auto const & partsFromMcColl = parts.sliceBy (partPerMcCollision, mccoll.globalIndex ());
426- LOGF (info, " partsFromMcColl size %i " , partsFromMcColl. size ()) ;
517+ int countMothers = 0 ;
427518 for (const auto & particle : partsFromMcColl) {
428519 if (particle.has_mothers ())
429520 continue ;
430- LOGF (info, " no mother pdg %i" , particle.pdgCode ());
521+ countMothers++;
522+ if (countMothers > 2 ) {
523+ printLargeMessage (" Truth collision has more than 2 no mother particles. Breaking the particle loop." );
524+ break ;
525+ }
526+ trueTauX[countMothers-1 ] = particle.px ();
527+ trueTauY[countMothers-1 ] = particle.py ();
528+ trueTauZ[countMothers-1 ] = particle.pz ();
529+
431530 const auto & daughters = particle.daughters_as <aod::UDMcParticles>();
432- LOGF (info, " daughters size %i " , daughters. size ()) ;
531+ int countDaughters = 0 ;
433532 for (const auto & daughter : daughters){
434- LOGF (info, " daughters pdg %i" , daughter.pdgCode ());
533+ // check if it is the charged particle (= no pi0 or neutrino)
534+ if (enumMyParticle (daughter.pdgCode ()) == -1 )
535+ continue ;
536+ countDaughters++;
537+ if (countDaughters > 2 ) {
538+ printLargeMessage (" Truth collision has more than 2 charged daughters of no mother particles. Breaking the daughter loop." );
539+ break ;
540+ }
541+ trueDaugX[countDaughters-1 ] = daughter.px ();
542+ trueDaugY[countDaughters-1 ] = daughter.py ();
543+ trueDaugZ[countDaughters-1 ] = daughter.pz ();
544+ trueDaugPdgCode[countDaughters-1 ] = daughter.pdgCode ();
545+
546+ // const auto& tracksFromDaughter = daughter.udtracks_as<FullMCUDTracks>();
547+ auto const & tracksFromDaughter = trks.sliceBy (trackPerMcParticle, daughter.globalIndex ());
548+ if (tracksFromDaughter.size () > 1 ) {
549+ printLargeMessage (" Daughter has more than 1 associated track. Skipping this daughter." );
550+ continue ;
551+ }
552+ const auto & trk = tracksFromDaughter.iteratorAt (0 );
553+ px[countDaughters-1 ] = trk.px ();
554+ py[countDaughters-1 ] = trk.py ();
555+ pz[countDaughters-1 ] = trk.pz ();
556+ sign[countDaughters-1 ] = trk.sign ();
557+ dcaxy[countDaughters-1 ] = trk.dcaXY ();
558+ dcaz[countDaughters-1 ] = trk.dcaZ ();
559+ trkTimeRes[countDaughters-1 ] = trk.trackTimeRes ();
560+ if (countDaughters == 1 ) {
561+ itsClusterSizesTrk1 = trk.itsClusterSizes ();
562+ } else {
563+ itsClusterSizesTrk2 = trk.itsClusterSizes ();
564+ }
565+ tpcSignal[countDaughters-1 ] = trk.tpcSignal ();
566+ tpcEl[countDaughters-1 ] = trk.tpcNSigmaEl ();
567+ tpcMu[countDaughters-1 ] = trk.tpcNSigmaMu ();
568+ tpcPi[countDaughters-1 ] = trk.tpcNSigmaPi ();
569+ tpcKa[countDaughters-1 ] = trk.tpcNSigmaKa ();
570+ tpcPr[countDaughters-1 ] = trk.tpcNSigmaPr ();
571+ tpcIP[countDaughters-1 ] = trk.tpcInnerParam ();
572+ tofSignal[countDaughters-1 ] = trk.tofSignal ();
573+ tofEl[countDaughters-1 ] = trk.tofNSigmaEl ();
574+ tofMu[countDaughters-1 ] = trk.tofNSigmaMu ();
575+ tofPi[countDaughters-1 ] = trk.tofNSigmaPi ();
576+ tofKa[countDaughters-1 ] = trk.tofNSigmaKa ();
577+ tofPr[countDaughters-1 ] = trk.tofNSigmaPr ();
578+ tofEP[countDaughters-1 ] = trk.tofExpMom ();
579+ }// daughters
580+ }// particles
581+ } else {
582+ auto const & partsFromMcColl = parts.sliceBy (partPerMcCollision, mccoll.globalIndex ());
583+ int countMothers = 0 ;
584+ for (const auto & particle : partsFromMcColl) {
585+ if (particle.has_mothers ())
586+ continue ;
587+ countMothers++;
588+ if (countMothers > 2 ) {
589+ printLargeMessage (" Truth collision has more than 2 no mother particles. Breaking the particle loop." );
590+ break ;
435591 }
592+ trueTauX[countMothers-1 ] = particle.px ();
593+ trueTauY[countMothers-1 ] = particle.py ();
594+ trueTauZ[countMothers-1 ] = particle.pz ();
595+
596+ const auto & daughters = particle.daughters_as <aod::UDMcParticles>();
597+ int countDaughters = 0 ;
598+ for (const auto & daughter : daughters){
599+ // check if it is the charged particle (= no pi0 or neutrino)
600+ if (enumMyParticle (daughter.pdgCode ()) == -1 )
601+ continue ;
602+ countDaughters++;
603+ if (countDaughters > 2 ) {
604+ printLargeMessage (" Truth collision has more than 2 charged daughters of no mother particles. Breaking the daughter loop." );
605+ break ;
606+ }
607+ trueDaugX[countDaughters-1 ] = daughter.px ();
608+ trueDaugY[countDaughters-1 ] = daughter.py ();
609+ trueDaugZ[countDaughters-1 ] = daughter.pz ();
610+ trueDaugPdgCode[countDaughters-1 ] = daughter.pdgCode ();
611+ }// daughters
436612 }// particles
437- // auto const& tracksFromColl = collFromMcColl.udtracks_as<FullUDTracks>();
438- // LOGF(info, "tracksFromColl size %i", tracksFromColl.size());
439- }// collisions
613+ }// collisions
614+
615+ trueTauTwoTracks (runNumber, bc, nTrks[0 ], nTrks[1 ], nTrks[2 ], vtxPos[0 ], vtxPos[1 ], vtxPos[2 ],
616+ recoMode, occupancy, hadronicRate, bcSels[0 ], bcSels[1 ], bcSels[2 ],
617+ bcSels[3 ], bcSels[4 ], bcSels[5 ], bcSels[6 ], bcSels[7 ],
618+ amplitudesFIT[0 ], amplitudesFIT[1 ], amplitudesFIT[2 ], -999 .,-999 .,
619+ timesFIT[0 ], timesFIT[1 ], timesFIT[2 ], -999 .,-999 .,
620+ px, py, pz, sign, dcaxy, dcaz, trkTimeRes,
621+ itsClusterSizesTrk1, itsClusterSizesTrk2,
622+ tpcSignal, tpcEl, tpcMu, tpcPi, tpcKa, tpcPr, tpcIP,
623+ tofSignal, tofEl, tofMu, tofPi, tofKa, tofPr, tofEP,
624+ trueChannel, trueHasRecoColl, mccoll.posX (), mccoll.posY (), mccoll.posZ (),
625+ trueTauX, trueTauY, trueTauZ, trueDaugX, trueDaugY, trueDaugZ, trueDaugPdgCode);
626+
440627
441628// auto colSlice = recolls.sliceBy(colPerMcCollision, mccoll.globalIndex());
442629// LOGF(info, "collision slice size %i ", colSlice.size());
0 commit comments