Skip to content
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

Avoid TColor warning #43

Merged
merged 1 commit into from
Apr 29, 2024
Merged

Conversation

dudarboh
Copy link
Member

@dudarboh dudarboh commented Apr 27, 2024

BEGINRELEASENOTES

  • Avoid the TColor warning when retrieving existing colours.

ENDRELEASENOTES

This should fix the lengthy warnings like the one below when using event display:

Warning in <TColor::TColor>: color 1279 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 4 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1264 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1264 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1267 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1267 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1267 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1279 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1279 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1270 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1270 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1276 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1256 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1256 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1221 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 1273 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 4 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 4 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 2 already defined
[ VERBOSE "BohdanAna"] 
Warning in <TColor::TColor>: color 3 already defined
[ VERBOSE "BohdanAna"] 

@dudarboh
Copy link
Member Author

dudarboh commented Apr 27, 2024

I could not build locally to test because it picks up old GSL 1.15 for some reason.

-- Check for GSL (1.15)
-- Check for GSL_LIBRARIES: gsl;gslcblas
-- Check for GSL_GSL_LIBRARY: /usr/lib64/libgsl.so -- ok
-- Check for GSL_GSLCBLAS_LIBRARY: /usr/lib64/libgslcblas.so -- ok

even if I have in LD_LIBRARY_PATH:

echo $LD_LIBRARY_PATH  | sed "s/:/\n/g" | grep gsl
/cvmfs/sw-nightlies.hsf.org/key4hep/releases/2024-03-08/x86_64-centos7-gcc12.2.0-opt/gsl/2.7.1-pyledp/lib/root

When compiling with old gsl, there is off-by-one warning here for index i:

double thph_dmat [2][3];
for ( int i =0 ; i < 3 ; i++ ) {
for ( int j=0 ; j < 2 ; j++ ) {
thph_dmat [i][j] = 0. ;

@tmadlener
Copy link
Contributor

The GSL issue should be fixed by iLCSoft/iLCUtil#20 (however that might take a bit to land). In the meantime I am updating the CI to have that working again.

Copy link
Contributor

@tmadlener tmadlener left a comment

Choose a reason for hiding this comment

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

The previous version also seems to have defined / registered non-existant TColors with ROOT. Are all the colors already known to ROOT?

@dudarboh
Copy link
Member Author

As far as I understand, the previous version defined only one non-existent TColor with dummy RGB values (1,1,1) if the colour index is not known by ROOT.

If a colour with index idx is already defined, the constructor gets the existing colour, and the RGB arguments 1, 1, 1 are ignored.

If a colour with index idx is not defined, the constructor creates a new colour.
But it always creates it with RGB values 1, 1, 1.

// Trying to creating colour with index 2, just reads ROOT default Red. 42 arguments are not used
root [0] TColor* test = new TColor(2, 42, 42, 42)
Warning in <TColor::TColor>: color 2 already defined
(TColor *) 0x3eb2050
root [1] test->GetRed()
(float) 1.00000f
root [2] test->GetGreen()
(float) 0.00000f
root [3] test->GetBlue()
(float) 0.00000f
// Creating colour with index 12345.
root [4] TColor* test_new = new TColor(12345, 42, 42, 42)
(TColor *) 0x3f06350
root [8] test_new->GetRed()
(float) 42.0000f
root [9] test_new->GetGreen()
(float) 42.0000f
root [10] test_new->GetBlue()
(float) 42.0000f

@tmadlener
Copy link
Contributor

What I meant was not how the TColor constructor works, but rather the fact that previously in this code it was called and now it no longer is. So previously, if you called it with an index that was not yet known to ROOT, you implicitly defined that index (and made it possible to use it downstream). It wouldn't be really useful, because it would effectively by black (or white 🤔), but someone else could try and use that color (index) after this. Now this is no longer possible, because the implicit definition of the color is gone.

@dudarboh
Copy link
Member Author

I see.
I am not sure.
Doesn't delete c delete the colour together with a pointer?

I am testing in ROOT and:

TColor* c = new TColor(12345, 42, 42, 42); // 0x3390540
TColor* test_get1 = gROOT->GetColor(12345); // 0x3390540
test_get1->GetRed() // (float) 42.0000f
delete c;
test_get1->GetRed() // (float) 0.0000f
TColor* test_get2 = gROOT->GetColor(12345); // (TColor *) nullptr

@tmadlener
Copy link
Contributor

Thanks for checking, I wasn't aware of that. In that case, I think case the behavior is the same as before.

@tmadlener tmadlener merged commit 08faa43 into iLCSoft:master Apr 29, 2024
8 checks passed
@dudarboh dudarboh deleted the fix_color_warning branch April 29, 2024 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants