- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33
Feature/sungbino likepid into cafmaker #593
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
base: develop
Are you sure you want to change the base?
Feature/sungbino likepid into cafmaker #593
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine to me! Thanks @sungbinoh.
One small q.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | srlikepid.lambda_muon = 0.; | ||
| srlikepid.lambda_pion = 0.; | ||
| srlikepid.lambda_proton = 0.; | ||
| srlikepid.pid_ndof = 0; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we change from the previous defaults here?
The object fills the defaults as -5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @henrylay97 ,
Thank you for the review!
That is a good catch. I did kind of no-brain copy of chi2pid part.
I agree that the default value should be distinguishable from the actual values.
Updating default values for lambdas to -9999. and ndof to -5!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Sungbin. Another comment on defaults (sorry!). Also not sure that this will run currently? Looks like we're passing a SRTrack rather than an SRTrkLikelihoodPID to the function?
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | srlikepid.lambda_pion = -9999.; | ||
| srlikepid.lambda_proton = -9999.; | ||
| srlikepid.pid_ndof = -5; | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this completely.
The values will be set to be the defaults by the default constructor anyway so let's avoid multiple points of maintenance. (See my comment here for more thoughts SBNSoftware/sbnanaobj#168 (comment))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @henrylay97 , I've removed these lines following your comment in the SBNSoftware/sbnanaobj#168 (comment). Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for responding so quick. I'm happy with this now 😀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left some coding comments.
The changes to avoid copies are required, while the coding style ones are up to you.
        
          
                sbncode/CAFMaker/FillReco.h
              
                Outdated
          
        
      | caf::SRTrack& srtrack, | ||
| bool allowEmpty = false); | ||
| void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid); | ||
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>> particleIDs, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forgot the reference:
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>> particleIDs, | |
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>>& particleIDs, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added &.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | } | ||
| } | ||
|  | ||
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>> particleIDs, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass the particle ID pointer objects by reference ([CF-112]):
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>> particleIDs, | |
| void FillTrackLikePID(const std::vector<art::Ptr<anab::ParticleID>>& particleIDs, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added &.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | for (unsigned i = 0; i < particleIDs.size(); i++) { | ||
| const anab::ParticleID &particle_id = *particleIDs[i]; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can compact this avoiding i:
| for (unsigned i = 0; i < particleIDs.size(); i++) { | |
| const anab::ParticleID &particle_id = *particleIDs[i]; | |
| for (art::Ptr<anab::ParticleID> const& pidPtr: particleIDs) { | |
| const anab::ParticleID &particle_id = *pidPtr; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to the suggested change.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | // Loop over algorithm scores and extract the ones we want. | ||
| // Get the ndof from any likelihood pid algorithm | ||
|  | ||
| std::vector<anab::sParticleIDAlgScores> AlgScoresVec = particle_id.ParticleIDAlgScores(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capture it by reference, avoid copies ([CF-111]):
| std::vector<anab::sParticleIDAlgScores> AlgScoresVec = particle_id.ParticleIDAlgScores(); | |
| std::vector<anab::sParticleIDAlgScores> const& AlgScoresVec = particle_id.ParticleIDAlgScores(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to the suggested change.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | for (size_t i_algscore=0; i_algscore<AlgScoresVec.size(); i_algscore++){ | ||
| anab::sParticleIDAlgScores AlgScore = AlgScoresVec.at(i_algscore); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid copying the objects, and also compact the notation:
| for (size_t i_algscore=0; i_algscore<AlgScoresVec.size(); i_algscore++){ | |
| anab::sParticleIDAlgScores AlgScore = AlgScoresVec.at(i_algscore); | |
| for (anab::sParticleIDAlgScores const& AlgScore: AlgScoresVec){ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to the suggested change.
        
          
                sbncode/CAFMaker/FillReco.cxx
              
                Outdated
          
        
      | if (TMath::Abs(AlgScore.fAssumedPdg) == 13) { // lambda_mu | ||
| srlikepid.lambda_muon = AlgScore.fValue; | ||
| srlikepid.pid_ndof = AlgScore.fNdf; | ||
| } | ||
| else if (TMath::Abs(AlgScore.fAssumedPdg) == 211) { // lambda_pi | ||
| srlikepid.lambda_pion = AlgScore.fValue; | ||
| srlikepid.pid_ndof = AlgScore.fNdf; | ||
| } | ||
| else if (TMath::Abs(AlgScore.fAssumedPdg) == 2212) { // lambda_pr | ||
| srlikepid.lambda_proton = AlgScore.fValue; | ||
| srlikepid.pid_ndof = AlgScore.fNdf; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the cases are known integral numbers, it's more efficient to use switch:
| if (TMath::Abs(AlgScore.fAssumedPdg) == 13) { // lambda_mu | |
| srlikepid.lambda_muon = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| } | |
| else if (TMath::Abs(AlgScore.fAssumedPdg) == 211) { // lambda_pi | |
| srlikepid.lambda_pion = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| } | |
| else if (TMath::Abs(AlgScore.fAssumedPdg) == 2212) { // lambda_pr | |
| srlikepid.lambda_proton = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| } | |
| switch (std::abs(AlgScore.fAssumedPdg)) { | |
| case 13: // lambda_mu | |
| srlikepid.lambda_muon = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| break; | |
| case 211: // lambda_pi | |
| srlikepid.lambda_pion = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| break; | |
| case 2212: // lambda_pr | |
| srlikepid.lambda_proton = AlgScore.fValue; | |
| srlikepid.pid_ndof = AlgScore.fNdf; | |
| break; | |
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to the suggested change.
| Hi @PetrilloAtWork , thanks a lot for your review! For default values for the  | 
Description
Updating CAF making codes to add likelihood-based PID variables.
sbncode/CAFMaker/CAFMakerParams.h: a new labelTrackLikePidLabelsbncode/CAFMaker/FillReco.cxx/h: addingFillTrackLikePIDandFillPlaneLikePID. They have almost the same shape withFillTrackChi2PIDandFillPlaneChi2PIDbut usesLikelihood(larana link) as input andSRTrkLikePID(sbnanaobj PR link) as output.sbncode/CAFMaker/CAFMaker_module.cc: addingart::FindManyP<anab::ParticleID> fmLikePIDand callingFillTrackLikePIDPlease note that
Reconstruction related fcl files should be updated for each of
icaruscodeandsbndcodeto measure likelihood PID variables. Examples insbndcodecan be found in PR849.Cafmaker fcl files should be updated in either of
icaruscodeandsbndcodetoo to assign correctfmLikePID.Have you added a label? (bug/enhancement/physics etc.)
Have you assigned at least 1 reviewer?
Is this PR related to an open issue / project?
Does this PR affect CAF data format? If so, please assign a CAF maintainer as additional reviewer.
Does this PR require merging another PR in a different repository (such as sbnanobj/sbnobj etc.)? If so, please link it in the description.
Yes. PR 168 in
sbnanaobjshould be merged first.