-
Couldn't load subscription status.
- Fork 33
Feature/aantonak crtveto caf #578
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?
Conversation
…how empty associations are handled.
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 this work Alex, very grateful this is making it to CAF now!
Looks like there are a few merge conflict resolutions have left a few missing curly brackets.
Also a couple of suggestions for cleaning up the main section that accesses the products. Arguably picky but it's better to make it resilient now.
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // And associated SpacePoint objects | ||
| art::FindManyP<sbnd::crt::CRTSpacePoint> spAssoc(sbndcrtveto_handle, evt, fParams.SBNDCRTVetoLabel()); |
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.
Sort indentation
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.
Code structure has changed a bit in the latest commit but I believe this issue is gone
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // Assume there is only one Veto per event | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> veto_sp_v(spAssoc.at(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.
I don't really like the hard-coded use of 0 as the key even if we know one is produced.
Would it be possible to check the size of the handle and then get the art::Ptr<> to the veto object and use the key from that?
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.
Is there only one associated pointer? then use art::FindOneP (CL-04); or art::FindOne if you don't care of the art pointer but only of the data product.
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.
In the latest commit I check the size of the veto vector and pass the key at index 0 from the vector of veto Ptrs. I stuck with FindManyP for the moment. Will FindOne or FindOneP work if there are multiple space points per veto? If so I can try to make that work but it seemed like it would grab just a single space point from my first attempt. Latest commit still uses FindManyP
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.
Yeah, FindOneP is indeed not appropriate here due to the 1-to-many relationship between CRTVeto and CRTSpacePoints. The handling of the single CRTVeto-per-event is now improved though, thank you!
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // TODO ? Need to decide how to handle this | ||
| // This version seems to work in skipping empty associations. It does break the rec.sbnd_crt_veto.sp_pe..length and | ||
| // rec.sbnd_crt_veto.sp_time..length branches? However, the rec.sbnd_crt_veto.sp_position..length still works and can be used? | ||
| std::cout << "No Veto Space Points" << std::endl; | ||
| //vetoSpacePoints.emplace_back(); // nullptr |
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 don't understand this - shouldn't need a special case, the vector branches should just be size 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.
Also in the final version remove the print statement :)
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.
Should be resolved. I have a few new debug statements momentarily that will be removed soon. I was testing the functionality of passing the vector of space point Ptrs directly. That block of code might change with new comments and I'll remove any print out statements after that
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| for (auto const& sp: veto_sp_v) { | ||
|
|
||
| vetoSpacePoints.push_back(*sp); | ||
|
|
||
| } |
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 need this? We can pass the vector of art::Ptr<>'s
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.
should be resolved
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| rec.ncrt_spacepoints = srcrtspacepoints.size(); | ||
| rec.sbnd_crt_tracks = srsbndcrttracks; | ||
| rec.nsbnd_crt_tracks = srsbndcrttracks.size(); | ||
| rec.sbnd_crt_veto = srsbndcrtveto; |
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.
This is me nit-picking but can you align = as all the others are ;P
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.
Yes of course, good catch thanks!
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.
should be resolved
sbncode/CAFMaker/FillReco.h
Outdated
| bool allowEmpty = false); | ||
|
|
||
| void FillSBNDCRTVeto(const sbnd::crt::CRTVeto &veto, | ||
| const std::vector<sbnd::crt::CRTSpacePoint> &points, |
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.
Indentation
…ecked the veto size is exactly 1 before passing index 0 to other parts of the code
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| if (spAssoc.isValid()) { | ||
| // There is one vector of SpacePoints per Veto --> can be empty if no veto condition was satisfied | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> veto_sp_v(spAssoc.at(vetoPtrs[0].key())); | ||
| FillSBNDCRTVeto(sbndcrtvetos[0], veto_sp_v, srsbndcrtveto); |
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.
Any reason why you can just pass vetoPtrs[0] here? Save having a vector of pointers and a vector of non-pointers?
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.
Yes, I was actually thinking the same thing but tried to make minimal changes first to see what feedback I would get. I will try to get this changed today, thanks Henry!
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // Assume there is only one Veto per event | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> veto_sp_v(spAssoc.at(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.
Yeah, FindOneP is indeed not appropriate here due to the 1-to-many relationship between CRTVeto and CRTSpacePoints. The handling of the single CRTVeto-per-event is now improved though, thank you!
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // And associated SpacePoint objects | ||
| art::FindManyP<sbnd::crt::CRTSpacePoint> spAssoc(sbndcrtveto_handle, evt, fParams.SBNDCRTVetoLabel()); | ||
| if (spAssoc.isValid()) { | ||
| // There is one vector of SpacePoints per Veto --> can be empty if no veto condition was satisfied |
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.
Across quite a few locations there are still quite a few indentation issues, this probably comes from tab size in the editor you are using - try and untabify to solve.
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 think you're right. I see something completely different on my end. The indentation shown here doesn't look like what's shown in my text editor (I've been using vim)
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.
Still needs resolving
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'm now happy with this subject to sorting indentation issues.
Thanks for working on the review comments @aantonakis!
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| // And associated SpacePoint objects | ||
| art::FindManyP<sbnd::crt::CRTSpacePoint> spAssoc(sbndcrtveto_handle, evt, fParams.SBNDCRTVetoLabel()); | ||
| if (spAssoc.isValid()) { | ||
| // There is one vector of SpacePoints per Veto --> can be empty if no veto condition was satisfied |
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.
Still needs resolving
|
|
||
| void FillSBNDCRTVeto(const art::Ptr<sbnd::crt::CRTVeto> &veto, | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> &points, | ||
| caf::SRSBNDCRTVeto &srsbndcrtveto, | ||
| bool allowEmpty = false); |
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.
More indentation
| void FillSBNDCRTVeto(const art::Ptr<sbnd::crt::CRTVeto> &veto, | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> &points, | ||
| caf::SRSBNDCRTVeto &srsbndcrtveto, | ||
| bool allowEmpty) |
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.
Indentation
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 request the removal of art::Ptr vector in the implementation.
Creating those vectors causes a overhead and in most of the cases is not necessary and then becomes a bad example (in fact, if you could tell where you have seen that used, we may also consider fixing the inspiring code as needed).
Also the indentation needs to be fixed, but @henrylay97 has already covered that.
| std::vector<art::Ptr<sbnd::crt::CRTVeto>> vetoPtrs; | ||
| // fill into event | ||
| if (sbndcrtveto_handle.isValid()) { | ||
| art::fill_ptr_vector(vetoPtrs, sbndcrtveto_handle); | ||
| // Only one valid veto per event | ||
| if (vetoPtrs.size() == 1) { |
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.
Please do not create art pointers unless they are really necessary.
Here:
| std::vector<art::Ptr<sbnd::crt::CRTVeto>> vetoPtrs; | |
| // fill into event | |
| if (sbndcrtveto_handle.isValid()) { | |
| art::fill_ptr_vector(vetoPtrs, sbndcrtveto_handle); | |
| // Only one valid veto per event | |
| if (vetoPtrs.size() == 1) { | |
| // fill into event | |
| if (sbndcrtveto_handle.isValid()) { | |
| // Only one valid veto per event | |
| if (sbndcrtveto_handle->size() == 1) { |
and then pass to the function a simple sbnd::crt::CRTVeto const* pointer (&sbndcrtveto_handle->front()) or, better, a reference sbnd::crt::CRTVeto const& (sbndcrtveto_handle->front()).
The reference is "better" than a pointer in that the latter would convey the message that the object could be absent (null pointer), which is not the case in your code.
sbncode/CAFMaker/CAFMaker_module.cc
Outdated
| art::FindManyP<sbnd::crt::CRTSpacePoint> spAssoc(sbndcrtveto_handle, evt, fParams.SBNDCRTVetoLabel()); | ||
| if (spAssoc.isValid()) { | ||
| // There is one vector of SpacePoints per Veto --> can be empty if no veto condition was satisfied | ||
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> veto_sp_v(spAssoc.at(vetoPtrs[0].key())); |
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 are asking the key() of the art pointer created from the first element of a data product. The value of such key is always 0.
Also, avoid copying the vector of space point pointers: use a reference.
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>> veto_sp_v(spAssoc.at(vetoPtrs[0].key())); | |
| const std::vector<art::Ptr<sbnd::crt::CRTSpacePoint>>& veto_sp_v(spAssoc.at(0)); |
| srsbndcrtveto.sp_time.emplace_back(sp->Ts0()); /// ns for SBND CRT SpacePoints | ||
| srsbndcrtveto.sp_pe.emplace_back(sp->PE()); |
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 suggest the use of good old push_back() when the purpose is just to copy the argument into the vector. emplace_back() works too, but it has the slightly different purpose of creating a new object into the vector rather than copying an existing one.
| srsbndcrtveto.sp_time.emplace_back(sp->Ts0()); /// ns for SBND CRT SpacePoints | |
| srsbndcrtveto.sp_pe.emplace_back(sp->PE()); | |
| srsbndcrtveto.sp_time.push_back(sp->Ts0()); /// ns for SBND CRT SpacePoints | |
| srsbndcrtveto.sp_pe.push_back(sp->PE()); |
Description
Please provide a detailed description of the changes this pull request introduces. If available, also link to a docdb link where the issue/change have been presented on/discussed.
This PR adds the SBND CRT Veto from reco2 to CAF. It needs a Standard Record CRT Veto class to propagate the Veto variables. This adds branches to the recTree that consist of boolean values at the Event level and limited information related to the CRT SpacePoints that were involved in triggering the analysis veto. Here is a link to the original PR for reco2: SBNSoftware/sbndcode#707
Additionally, here is a docdb entry: SBN Document 40318-v1
Checklist Items: