-
Notifications
You must be signed in to change notification settings - Fork 35
Feature/adding blip to caf #603
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?
Changes from 11 commits
18b28ec
daa5c8e
8dfaab0
23c5909
6ec65f7
3812b04
f830082
e4cc10e
0c62419
97b9db8
44e03a4
a44f4c6
b6b0f4f
ddda71a
05878a3
3b3e41b
fe6e410
19f6c92
bd6ecab
271cf7b
5062c12
221712e
41428d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |||||||||||
| #include "sbncode/CAFMaker/FillExposure.h" | ||||||||||||
| #include "sbncode/CAFMaker/FillTrigger.h" | ||||||||||||
| #include "sbncode/CAFMaker/Utils.h" | ||||||||||||
| #include "sbncode/CAFMaker/FillBlip.h" | ||||||||||||
|
|
||||||||||||
| // C/C++ includes | ||||||||||||
| #include <fenv.h> | ||||||||||||
|
|
@@ -1916,6 +1917,18 @@ void CAFMaker::produce(art::Event& evt) noexcept { | |||||||||||
| } | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| //Fill blips. art::handle for blips and then call fill blips for each one. Make a vector to hold all of them. I handle for loop in Fill blip | ||||||||||||
| art::Handle<std::vector<blip::Blip>> blipHandle; | ||||||||||||
| std::vector<caf::SRBlip> srblips; | ||||||||||||
| if(evt.getByLabel( fParams.fBlipTag(), blipHandle)) //fill SR blips | ||||||||||||
| { | ||||||||||||
| FillBlip( (*blipHandle), srblips); | ||||||||||||
|
||||||||||||
| FillBlip( (*blipHandle), srblips); | |
| FillBlip( *blipHandle, srblips); |
(this is a suggestion)
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.
Removed from here
Outdated
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 remove obsolete, commented out code:
| //for(int i=0; i<int(*(blipHandle)->size()); i++) | |
| // { | |
| // auto LarBlips = (*(blipHandle))[i]; | |
| // FillBlip( (LarBlips) , srblips); | |
| // } |
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.
Gone
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,9 +39,11 @@ art_make_library( LIBRARY_NAME sbncode_CAFMaker | |
| sbnobj::Common_Trigger | ||
| sbnobj::SBND_CRT | ||
| sbnobj::SBND_Timing | ||
| sbndobj_BlipDataTypes | ||
|
||
| lardataalg::DetectorInfo | ||
| art::Framework_Services_System_TriggerNamesService_service | ||
| sbncode_Metadata_MetadataSBN_service | ||
| #sbndcode_BlipUtils | ||
| larsim::Utils | ||
| larevt::SpaceCharge | ||
| systematicstools::interface | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,104 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #include "sbncode/CAFMaker/FillBlip.h" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for putting in a separate file, FillReco is getting unwieldy. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| namespace caf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void FillBlip( const std::vector<blip::Blip>& LarBlips, std::vector<caf::SRBlip>& CAF_Blips) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int NBlips = LarBlips.size(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| for(int iBlip=0; iBlip<NBlips; iBlip++) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| blip::Blip CurrentBlip = LarBlips[iBlip]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| int NBlips = LarBlips.size(); | |
| for(int iBlip=0; iBlip<NBlips; iBlip++) | |
| { | |
| blip::Blip CurrentBlip = LarBlips[iBlip]; | |
| for(blip::Blip const& CurrentBlip: LarBlips) | |
| { |
This avoids copies (blip::Blip CurrentBlip = LarBlips[iBlip] copies) and the definition of two variables that are not used anywhere else.
I recommend to adopt the suggested syntax.
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 it
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.
Swapped loop structure
Outdated
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.
LarBlip is not modified, so it needs to be declared constant:
| void FillMCTruthBlip( blip::Blip& LarBlip, caf::SRBlip &CAF_Blip ) | |
| void FillMCTruthBlip( blip::Blip const& LarBlip, caf::SRBlip &CAF_Blip ) |
Also, since the function is dealing only with LarBlip.truth and CAF_Blip.truthBlip, the arguments should be these two rather than LarBlip and CAF_Blip.
Same argument name comment as above, too.
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 this and hitCluster functions
Outdated
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.
Remove obsolete, commented out code.
| //CAF_Blip.truthBlip = LarBlip.truth; |
Outdated
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 use consistent spacing:
| CAF_Blip.truthBlip.Cryostat =LarBlip.truth.Cryostat; | |
| CAF_Blip.truthBlip.TPC =LarBlip.truth.TPC; | |
| CAF_Blip.truthBlip.Time =LarBlip.truth.Time; | |
| CAF_Blip.truthBlip.TimeTick =LarBlip.truth.TimeTick; | |
| CAF_Blip.truthBlip.DriftTime =LarBlip.truth.DriftTime; | |
| CAF_Blip.truthBlip.Energy =LarBlip.truth.Energy; | |
| CAF_Blip.truthBlip.DepElectrons =LarBlip.truth.DepElectrons; | |
| CAF_Blip.truthBlip.NumElectrons =LarBlip.truth.NumElectrons; | |
| CAF_Blip.truthBlip.LeadG4ID =LarBlip.truth.LeadG4ID; | |
| CAF_Blip.truthBlip.LeadG4Index =LarBlip.truth.LeadG4Index; | |
| CAF_Blip.truthBlip.LeadG4PDG =LarBlip.truth.LeadG4PDG; | |
| CAF_Blip.truthBlip.LeadCharge =LarBlip.truth.LeadCharge; | |
| CAF_Blip.truthBlip.Position =LarBlip.truth.Position; | |
| CAF_Blip.truthBlip.Cryostat = LarBlip.truth.Cryostat; | |
| CAF_Blip.truthBlip.TPC = LarBlip.truth.TPC; | |
| CAF_Blip.truthBlip.Time = LarBlip.truth.Time; | |
| CAF_Blip.truthBlip.TimeTick = LarBlip.truth.TimeTick; | |
| CAF_Blip.truthBlip.DriftTime = LarBlip.truth.DriftTime; | |
| CAF_Blip.truthBlip.Energy = LarBlip.truth.Energy; | |
| CAF_Blip.truthBlip.DepElectrons = LarBlip.truth.DepElectrons; | |
| CAF_Blip.truthBlip.NumElectrons = LarBlip.truth.NumElectrons; | |
| CAF_Blip.truthBlip.LeadG4ID = LarBlip.truth.LeadG4ID; | |
| CAF_Blip.truthBlip.LeadG4Index = LarBlip.truth.LeadG4Index; | |
| CAF_Blip.truthBlip.LeadG4PDG = LarBlip.truth.LeadG4PDG; | |
| CAF_Blip.truthBlip.LeadCharge = LarBlip.truth.LeadCharge; | |
| CAF_Blip.truthBlip.Position = LarBlip.truth.Position; |
Outdated
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 also go
| CAF_Blip.truthBlip.Energy = CAF_Blip.truthBlip.Energy/1000.; //convert to GeV | |
| CAF_Blip.truthBlip.Energy /= 1000.; //convert to GeV |
Outdated
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 clusters to this function rather than the full blip objects, since clusters are the only object this function concerns with.
I also suggest that this function be changed to operate on a single cluster, and the loop be moved to the caller.
Outdated
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 you defined a kNplanes constant, you can use that one directly.
Or, if you have adopted the suggestion of replacing the C array with a std::array, you do have LarBlip.clusters.size(). Both are more readable than the (functionally correct) code in this line.
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.
Replaced with the kNplanes variable
Outdated
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 recommend to use the appropriate std::vector member function, assign():
| //These are sets that need to become vectors so we need to do some loops | |
| for(auto HitID : LarBlip.clusters[iPlane].HitIDs) CAF_Blip.clusters[iPlane].HitIDs.push_back(HitID); | |
| // These are sets that need to become vectors | |
| CAF_Blip.clusters[iPlane].HitIDs.assign(begin(LarBlip.clusters[iPlane].HitIDs), end(LarBlip.clusters[iPlane].HitIDs)); |
If this function is changed as recommended above to work on a single cluster, this becomes less wordy and more readable:
| //These are sets that need to become vectors so we need to do some loops | |
| for(auto HitID : LarBlip.clusters[iPlane].HitIDs) CAF_Blip.clusters[iPlane].HitIDs.push_back(HitID); | |
| // These are sets that need to become vectors | |
| CAFcluster.HitIDs.assign(begin(LArCluster.HitIDs), end(LArCluster.HitIDs)); |
same for the next three lines; in fact, you could even write a specific function and use it repeatedly:
| //These are sets that need to become vectors so we need to do some loops | |
| for(auto HitID : LarBlip.clusters[iPlane].HitIDs) CAF_Blip.clusters[iPlane].HitIDs.push_back(HitID); | |
| // These are sets that need to become vectors | |
| auto copyToVector = [](auto& dest, auto const& src) | |
| { dest.assign(begin(src), end(src)); }; | |
| copyToVector(CAF_Blip.clusters[iPlane].HitIDs, LarBlip.clusters[iPlane].HitIDs); |
etc.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,17 @@ | ||||||||||||||||||
| #ifndef CAF_FILLBLIP_H | ||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to add a standard header with file name, brief description and author identification, like in:
Suggested change
The same holds for the |
||||||||||||||||||
| #define CAF_FILLBLIP_H | ||||||||||||||||||
| #include<iostream> | ||||||||||||||||||
|
||||||||||||||||||
| #include<iostream> |
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.
Removed
Outdated
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 both these functions one of the operands (the first one, I'd wage) must be declared const.
Also, it seems that the only function needed externally (by CAFMaker module) is the first one; the other two do not need to be publicly visible in the header, and their declaration can be either omitted or moved out of the header into the implementation (.cxx) file.
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.
Conform to the existing alignment (
[CO-02]).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 consistent indent