Skip to content

Conversation

@Jjm321814
Copy link

Added CAFMaker interface to add blips to CAF files.
This PR must not be approved until SBNSoftware/sbnobj#155 and SBNSoftware/sbnanaobj#173 are approved/released.
Working on estimating the file size change now.

@Jjm321814 Jjm321814 self-assigned this Nov 13, 2025
@Jjm321814
Copy link
Author

Adding a comment to each of these to track all 4 related PR.
sbncode: #603
sbndcode: SBNSoftware/sbndcode#871
sbnobj: SBNSoftware/sbnobj#155
sbnanaobj: SBNSoftware/sbnanaobj#173

The changes to sbnobj, and sbnanaobj are fully independent of any other changes, so they can be approved first.

sbndcode changes rely on sbnobj, so it will have to wait for the first approval. A later simple PR will delete the (now duplicated) class files in the BlipUtils folder here

sbncode changes rely on both sbnobj and sbnanaobj, so that will have to wait for both of the first two approvals.

@Jjm321814
Copy link
Author

Pushed all the fcl changes needed to run CAF on data and MC.
Have only tested on data. We see a 19% increase in the size of a standard CAF data file (3.7 MB to 4.4 MB) because of blips
image

Copy link

@JosiePaton JosiePaton left a comment

Choose a reason for hiding this comment

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

Assuming reasonable file size change result!

int fGenieEvtRec_brStdHepLd [250] = {0}; ////< Last daughter
int fGenieEvtRec_brStdHepFm [250] = {0}; ////< First mother
int fGenieEvtRec_brStdHepLm [250] = {0}; ////< Last mother
//std::string fBlipTag;
Copy link
Member

Choose a reason for hiding this comment

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

Can you remove old commented code?

"cvn"
};
Atom<std::string> fBlipTag { Name("BlipTag"),
Comment("Provide a string to label the blip input"), "reco2:Blip:BlipReco"
Copy link
Member

Choose a reason for hiding this comment

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

This should be the producer that made the blips.

Is that not defined as blipreco here?

Copy link
Author

Choose a reason for hiding this comment

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

Yes that is what it should be. I thought it would be the whole LArSoft label, so guessed this version. Its wrong and I am happy to update it to blipreco

Comment on lines 66 to 72
CAF_Blip.clusters[iPlane].ID = LarBlip.clusters[iPlane].ID;
CAF_Blip.clusters[iPlane].isValid = LarBlip.clusters[iPlane].isValid;
CAF_Blip.clusters[iPlane].CenterChan = LarBlip.clusters[iPlane].CenterChan;
CAF_Blip.clusters[iPlane].CenterWire = LarBlip.clusters[iPlane].CenterWire;
CAF_Blip.clusters[iPlane].isTruthMatched = LarBlip.clusters[iPlane].isTruthMatched;
CAF_Blip.clusters[iPlane].isMerged = LarBlip.clusters[iPlane].isMerged;
CAF_Blip.clusters[iPlane].isMatched = LarBlip.clusters[iPlane].isMatched;
Copy link
Member

Choose a reason for hiding this comment

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

In general there are quite a few indentation inconsistencies across these PRs. It's often different editors and how they treat tabs, there are normally ways to untabify though.

@@ -0,0 +1,104 @@
#include "sbncode/CAFMaker/FillBlip.h"
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for putting in a separate file, FillReco is getting unwieldy.

@Jjm321814
Copy link
Author

Just noting on this PR as well that the above Henry comments should all be addressed.

Copy link
Member

@PetrilloAtWork PetrilloAtWork left a comment

Choose a reason for hiding this comment

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

A few things need to be changed (redundant headers, missing const parameters), others are recommended to.
Details in the comments.

Comment on lines +1926 to +1930
//for(int i=0; i<int(*(blipHandle)->size()); i++)
// {
// auto LarBlips = (*(blipHandle))[i];
// FillBlip( (LarBlips) , srblips);
// }
Copy link
Member

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:

Suggested change
//for(int i=0; i<int(*(blipHandle)->size()); i++)
// {
// auto LarBlips = (*(blipHandle))[i];
// FillBlip( (LarBlips) , srblips);
// }

std::vector<caf::SRBlip> srblips;
if(evt.getByLabel( fParams.fBlipTag(), blipHandle)) //fill SR blips
{
FillBlip( (*blipHandle), srblips);
Copy link
Member

Choose a reason for hiding this comment

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

Parentheses are redundant here. Just saying.

Suggested change
FillBlip( (*blipHandle), srblips);
FillBlip( *blipHandle, srblips);

(this is a suggestion)

sbnobj::Common_Trigger
sbnobj::SBND_CRT
sbnobj::SBND_Timing
sbndobj_BlipDataTypes
Copy link
Member

Choose a reason for hiding this comment

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

Please fix the alignment. My suggestion is to copy the line above, to make sure the same indentation characters are use.

Comment on lines +625 to +627
Atom<std::string> fBlipTag { Name("BlipTag"),
Comment("Provide a string to label the blip input"), "blipreco"
};
Copy link
Member

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]).

Comment on lines +7 to +10
int NBlips = LarBlips.size();
for(int iBlip=0; iBlip<NBlips; iBlip++)
{
blip::Blip CurrentBlip = LarBlips[iBlip];
Copy link
Member

Choose a reason for hiding this comment

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

I think this is equivalent to using a range-for loop:

Suggested change
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.


void FillBlipRealtedHitCluster(blip::Blip& LarBlip, caf::SRBlip &CAF_Blip)
{
int NumPlanes = sizeof(LarBlip.clusters)/sizeof(LarBlip.clusters[0]);
Copy link
Member

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.

Comment on lines 97 to 98
//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);
Copy link
Member

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():

Suggested change
//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:

Suggested change
//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:

Suggested change
//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.

@@ -0,0 +1,17 @@
#ifndef CAF_FILLBLIP_H
#define CAF_FILLBLIP_H
#include<iostream>
Copy link
Member

Choose a reason for hiding this comment

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

Unused header:

Suggested change
#include<iostream>

Comment on lines +13 to +14
void FillMCTruthBlip(blip::Blip& LarBlip, caf::SRBlip& CAF_Blip );
void FillBlipRealtedHitCluster(blip::Blip& LarBlip, caf::SRBlip& CAF_Blip);
Copy link
Member

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.

@@ -0,0 +1,17 @@
#ifndef CAF_FILLBLIP_H
Copy link
Member

Choose a reason for hiding this comment

The 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
#ifndef CAF_FILLBLIP_H
/**
* @file sbncode/CAFMaker/FillBlip.h
* @brief CAFMaker utilities for filling "blip" objects into CAF.
* @author Jacob McLaughlin (jmclaughlin2@illinoistech.edu)
/
#ifndef CAF_FILLBLIP_H

The same holds for the .cxx file and, in fact, all other headers and source files. This is not often done in SBN repositories, and it would be better if it were.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Open pull requests

Development

Successfully merging this pull request may close these issues.

5 participants