Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to run pandora on tracks created from generator-level particles #43

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

giovannimarchiori
Copy link

@giovannimarchiori giovannimarchiori commented Jan 15, 2025

Started from Archil's implementation in https://github.com/Archil-AD/k4RecTracker/tree/pandora but

  1. changed name of algorithm, make it live in parallel to the transformed based one
  2. added the possibility to pass more than one collection of sim tracker hits in input, so that first hit can be calculated from vtx and last hit from wrapper
  3. add more debug information
  4. do not keep tracks without associated simtrackerhits

BEGINRELEASENOTES

  • Add a Gaudi::Algorithm to create tracks from generator-level particles with charge!=0 and number of simtrackerhits>0 (temporary work around needed because one can not use the edm4hep <--> lcio converters with IOSvc and functionals)
  • Track states at IP, first tracker hit, last tracker hit and extrapolation to calorimeter are calculated and saved by the algorithm
    ENDRELEASENOTES

Tagging @BrieucF - let's have a look at the code not just in terms of style but also at what it does so that we do things right. For instance might be things that need to be done a bit differently for tracks that point towards the ECAL endcap rather than the barrel. I will make it a draft while we iterate over it

@BrieucF
Copy link
Collaborator

BrieucF commented Jan 17, 2025

Hi Giovanni, can you add to the release note that this is a work around needed because currently one can not us the edm4hep <--> lcio converters when using functionals?

@giovannimarchiori
Copy link
Author

Done

Copy link
Collaborator

@BrieucF BrieucF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Giovanni! Here some comments

Comment on lines +54 to +56
Gaudi::Property<float> m_Bz{this, "Bz", 2., "Z component of the (assumed constant) magnetic field in Tesla."};
/// Inner radius of the ECAL
Gaudi::Property<float> m_RadiusAtCalo{this, "RadiusAtCalo", 2172.8, "Inner radius (in mm) of the calorimeter where the TrackState::AtCalorimeter should be defined."};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are modifying this anyway, shall we profit from the occasion to add GeoSvc here and retrieve the magnetic field from there + the inner calorimeter radius?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will try to have a look at this

Comment on lines +54 to +56
Gaudi::Property<float> m_Bz{this, "Bz", 2., "Z component of the (assumed constant) magnetic field in Tesla."};
/// Inner radius of the ECAL
Gaudi::Property<float> m_RadiusAtCalo{this, "RadiusAtCalo", 2172.8, "Inner radius (in mm) of the calorimeter where the TrackState::AtCalorimeter should be defined."};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what would this be called for the endcap? Lower z?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess for endcap we would need to know innerZ and also lowerR. But if we retrieve the info from GeoSvc, then we don't need to think about the name of these properties ;)

auto MCRecoTrackParticleAssociationCollection = new edm4hep::TrackMCParticleLinkCollection();

// loop over the gen particles, find charged ones, and create the corresponding reco particles
int iparticle = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this useful? If you want a unique identifier, what about genParticle.getObjectID() in the print below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iparticle is not to provide a unique identifier, just to print in the debug information the position in the MCParticle vector in case one would like to look at more details in the simulation file.

for (const auto& hit : *coll) {
const edm4hep::MCParticle particle = hit.getParticle();
std::array<double,6> ahit{hit.x(), hit.y(), hit.z(), hit.getMomentum()[0], hit.getMomentum()[1], hit.getMomentum()[2]};
if(particle.getVertex() == genParticle.getVertex() && particle.getMomentum() == genParticle.getMomentum()) trackHits.push_back(ahit);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not if(particle.getObjectID() == genParticle.getObjectID()?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was just copied over from Archil's code. I can replace it with your proposed change


if(!trackHits.empty())
{
// particles with at least one SimTrackerHit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there an indentation problem or just my display?

debug() << "Number of SimTrackerHits: " << trackHits.size() << endmsg;

// sort the hits according to radial distance from beam axis
// FIXME: does this work well also for tracks going to endcaps of vtx/wrapper?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have to go in Pandora to see how this should be defined for the endcap... It would likely become the "z" coordinate I guess. If yes, we have to add the GeoSvc and use the flags DETYPE_ENDCAP

Copy link
Author

@giovannimarchiori giovannimarchiori Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, one has to pass to pandora the latest track hit before the ECAL, so that is well defined, I'd say. It's just to think if sorting in radial distance is the most robust way to get the last hit for all tracks - probably in the endcap it will be the hits with largest |z| ?


// TrackState at First Hit
auto trackState_AtFirstHit = edm4hep::TrackState {};
auto firstHit = trackHits.front();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation?


// TrackState at Last Hit
auto trackState_AtLastHit = edm4hep::TrackState{};
auto lastHit = trackHits.back();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation?

trackState_AtFirstHit.omega = helixAtFirstHit.getOmega();
trackState_AtFirstHit.Z0 = helixAtFirstHit.getZ0();
trackState_AtFirstHit.tanLambda = helixAtFirstHit.getTanLambda();
trackState_AtFirstHit.referencePoint = edm4hep::Vector3f((float)posAtFirstHit[0],(float)posAtFirstHit[1],(float)posAtFirstHit[2]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Pandora expect this as the "real" first hit present in the track or is it rather a convention to define also the trackState at the first layer of the tracking system (regardless of whether there is an actual hit or not)? (possibly look at how they are defined for CLD)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same question holds for the other trackStates

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be investigated. Anyway for truth primary tracks and no detector inefficiency the two things are more or less the same (things differ from secondaries of course..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants