Page MenuHomeHEPForge

Alterations to allow Blatt-Weisskopf factor for parent to be created in a model with only a K-matrix
ClosedPublic

Authored by johndan on Feb 19 2021, 6:41 PM.

Details

Summary

Updates to LauBlattWeisskopfFactor and LauResonanceMaker to allow a model to be generated only containing a K-matrix (for visualisation purposes)

Test Plan

Visualising the K-matrix in B -> DDh Dalitz analyses

Diff Detail

Repository
rLAURA laura
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

johndan added inline comments.
inc/LauBlattWeisskopfFactor.hh
39

Needed, annoyingly, for the default argument assignment of "" to the TString parameter of setRadiusName.

121

This is the new function I had to introduce which doesn't expect a resInfo argument (since it's not needed in most cases for naming the Blatt-Weisskopf factor category)

src/LauBlattWeisskopfFactor.cc
63

Why was NEED_A_GOOD_NAME here?

94–121

This seems to be the only case in which resInfo is actually needed, so for all the others I just use a default argument of "" for the category name and then it is assigned in the old way. Passing around "" seems imperfect, and perhaps you'll have a smarter way to do this.

What I would rather do is modify the original
TString setRadiusName( const LauResonanceInfo& resInfo, const BlattWeisskopfCategory category );
function in order to swap the parameter ordering and give resInfo a default argument that can be overridden for the case of Indep category. But I was afraid to redefine setRadiusName because it's not private to the class (even if it is protected and I don't see any instances in Laura++ anywhere, so changing it would probably be safe).

173

I'm amazed that C++ doesn't have a mechanism to allow enum types to be converted to strings easily. I saw boost has a preprocessor library that can handle it, but managing it in C++ looks messy in the examples I've seen.

johndan marked an inline comment as not done.Feb 19 2021, 6:54 PM
tlatham changed the visibility from "All Users" to "Public (No Login Required)".Feb 23 2021, 10:28 PM
tlatham changed the edit policy from "All Users" to "Laura (Project)".
tlatham added a project: Laura.

Hi @johndan, thanks for this. Few comments inline.

src/LauBlattWeisskopfFactor.cc
63

I think it's just there as an explicit reminder that the name needs to be, and indeed is, updated in the function body.

94–121

An alternative way would be to have 3 functions:

TString setRadiusName( const LauResonanceInfo& resInfo, const BlattWeisskopfCategory category );
TString setRadiusName( const BlattWeisskopfCategory category );
TString setRadiusName( const TString& categoryName );

The first is modified as you've done except that in the Indep case you just call the 3rd one with the result of resInfo.getSanitisedName().
The second one just contains the switch on the rest of the categories (although I'd prefer to remove the default case and replace it with the two cases for Default and Indep), in each case just calling the 3rd on with the category name.
The third then would just be:

TString LauBlattWeisskopfFactor::setRadiusName( const TString& categoryName )
{
    TString name = "BarrierRadius_";
    name.Append(categoryName);
    radius_->name(name);
    return categoryName;
}

This avoids having any default arguments but does rather proliferate the number of functions.

I agree that these functions should be private, and have no objection to them being moved into that access category.
So then the protected category can go, and we could even declare the class as final and get rid of the virtual destructor.

173

Indeed, it is a bit surprising that this isn't easier to do. There are some clever tricks that can be done with macros to autogenerate this stuff but they're hard to read, so I prefer to keep it like this, at least for now.

src/LauResonanceMaker.cc
656

Could here create it with some hard-coded default, e.g. 4.0, for the radius and print a warning that it's being created with such a default value, instead of an error that you can't create it at all.

Similarly, should probably handle the case that you don't find the Parent category in the category information map, cf. lines 677-684.

johndan added inline comments.
src/LauBlattWeisskopfFactor.cc
94–121

Thanks for the detailed proposal!

So for the second one, and case Indep:, what does the action look like? You don't have the resInfo to get a name from... Also, what should the name be for the "Default" case? "Unknown", like before, or something else?

173

Yes, I entirely agree. The boost solution was the least messy of them all, but certainly not worth introducing dependencies to achieve this minor goal.

src/LauResonanceMaker.cc
656

Sure thing. Isn't Parent created by default in the constructor?

johndan added inline comments.
src/LauBlattWeisskopfFactor.cc
94–121

Also, why would the second one call the third one, since both have the same form. Why not just set the categoryName variable for the Indep and Default cases?

src/LauBlattWeisskopfFactor.cc
94–121

Apologies, I accidentally omitted a few details. To avoid further ambiguities, here's exactly what I had in mind. Hopefully this clarifies what I meant to the extent that all your questions are answered?

TString LauBlattWeisskopfFactor::setRadiusName( const LauResonanceInfo& resInfo, const BlattWeisskopfCategory category )
{
        switch (category) {
                case Indep :
                        return this->setRadiusName( resInfo.getSanitisedName() );
                        break;
                default :
                        return this->setRadiusName( category );
                        break;
        }   
}

TString LauBlattWeisskopfFactor::setRadiusName( const BlattWeisskopfCategory category )
{
                switch (category) {
                        case Default :
                        case Indep :
                                // We shouldn't ever end up here
                                return this->setRadiusName("Unknown");
                        case Parent :
                                return this->setRadiusName("Parent");
                        case Light :
                                return this->setRadiusName("Light");
                        case Kstar :
                                return this->setRadiusName("Kstar");
                        case Charm :
                                return this->setRadiusName("Charm");
                        case StrangeCharm :
                                return this->setRadiusName("StrangeCharm");
                        case Charmonium :
                                return this->setRadiusName("Charmonium");
                        case Beauty :
                                return this->setRadiusName("Beauty");
                        case StrangeBeauty :
                                return this->setRadiusName("StrangeBeauty");
                        case CharmBeauty :
                                return this->setRadiusName("CharmBeauty");
                        case Custom1 :
                                return this->setRadiusName("Custom1");
                        case Custom2 :
                                return this->setRadiusName("Custom2");
                        case Custom3 :
                                return this->setRadiusName("Custom3");
                        case Custom4 :
                                return this->setRadiusName("Custom4");
                }   

}

TString LauBlattWeisskopfFactor::setRadiusName( const TString& categoryName )
{
        TString name = "BarrierRadius_";
        name.Append(categoryName);

        radius_->name(name);

        return categoryName;
}
src/LauResonanceMaker.cc
656

Indeed, at the moment it is created on line 75. However, it's not impossible that that might be removed in future, so it seems prudent to handle the case where it isn't found.

johndan added inline comments.
src/LauBlattWeisskopfFactor.cc
94–121

Looks good. The compiler doesn't like the switch with no return outside:

/afs/cern.ch/user/j/johndan/ExternalSoftware/Laura++/laura/src/LauBlattWeisskopfFactor.cc: In member function 'TString LauBlattWeisskopfFactor::setRadiusName(LauBlattWeisskopfFactor::BlattWeisskopfCategory)':
/afs/cern.ch/user/j/johndan/ExternalSoftware/Laura++/laura/src/LauBlattWeisskopfFactor.cc:124:1: warning: control reaches end of non-void function [-Wreturn-type]
  124 | }
src/LauBlattWeisskopfFactor.cc
94–121

Oh yes, I'd forgotten about gcc's insistence that control can get beyond a switch on an enum that covers every case and returns from each (clang is happy that it can't).
I'd just add:

// We should never get here but gcc seems to think we can
return this->setRadiusName("Unknown");

at the end.

  • Add catch-all return and finish B-W updates
src/LauResonanceMaker.cc
666–667

I think this can be dropped now?
Otherwise it all looks good to me :)

  • Remove unnecessary error message

Thanks for checking through this, @tlatham !

Many thanks for taking care of all these extensions to the K-matrix @johndan !
Will land this now.

This revision is now accepted and ready to land.Mar 5 2021, 11:02 AM
This revision was automatically updated to reflect the committed changes.