ASImage2gif

Hi, When I made some picture with a script I always have this msg for all the pictures :
ASImage2gif():1137:<gifs/h_ele_foundHitsVsEta_Extended_pfx.gif> (null)
The pictures are correct, its only the msg I would like to disappear.

I use the following (simplified) commands :

    def createPicture2(self, histo1, histo2, scaled, err, filename, id):
        self.cnv = TCanvas(str(id), "canvas")

        histo2c = histo2.Clone()
        
        self.cnv.SetCanvasSize(960, 900)
        self.cnv.Clear()
        
        pad1 = ROOT.TPad(str(id), "pad1", 0, 0.25, 1.0, 1.0) # ,0,0,0
        pad1.Draw()
        pad1.cd()
               
        histo1.SetStats(1)
        histo1.Draw(newDrawOptions) # 

        gPad.Update()

        histo2c.Draw("sames hist")
        self.cnv.Update()
        newDrawOptions = "sames "
        histo1.Draw(newDrawOptions)
        histo2c.Draw("sames hist")
        
        self.cnv.Draw()
        self.cnv.Update()

        self.cnv.SaveAs(filename) --> histoName.gif
        
        return

Is there a solution to remove this msg ?

thanks.
Arnaud


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.32
Platform: lxplus
Compiler: Not Provided


Hi Arnaud,

Sorry to read the standard installation of ROOT does not work for you out of the box in this particular case.
I am adding in the loop @linev and @couet who might help in this situation.

Cheers,
D

Many thanks.
I can add that I tried some new tests with others extension such as jpg or png without any msg.
I redid it this morning with gif extension and I got the msg again.

Arnaud

I cannot reproduce your problem:

root [0] TH2F* h = new TH2F("h", "my histo;X;Y;Z", 10, 0, 10, 10, 0, 10);
root [1] h->Fill(3, 7, 5);
root [2] h->Draw("colz");
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [3] c1->Print("c1.gif")
Info in <TCanvas::Print>: GIF file c1.gif has been created
root [4] 

Hi, many thanks for the time.
I redid the tests with self.cnv.Print(filename) instead of self.cnv.SaveAs(filename) with the same results.
I will try to make a simple example to work on.

Arnaud

Update :
simple.tar.gz (1.6 MB)
with linux :
tar xvf simple.tar.gz
cd SIMPLE
python3 mainSimple.py

This is the output I get with your reproducer and 6.32.00 and Ubuntu 22:

begin to run
working in /tmp/SIMPLE

Validation_reference : 
web_repo : ['/tmp/SIMPLE', 'dev']
['GeV_1']
long rel : CMSSW_14_1_0_pre3
short rel : 14_1_0_pre3
rel extent : 2024
ref extent : 
choiceT : FullvsFull
web repo : ['/tmp/SIMPLE', 'dev']
relrefVT ['RECO', 'RECO']
config relExtent 2024
config refExtent 
there is 1 datasets : ['ZEE_14']

===== dataset : ZEE_14
len dataset : 1 - len relFile : 1 - len refFile : 1
dataset : ['ZEE_14']
relFile : ['DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root']
refFile : ['DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root']
tree path for target : ElectronMcSignalValidator
tree path for reference : ElectronMcSignalValidator
/tmp/SIMPLE/DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root
      h1 for dataset : ZEE_14
Name: ElectronMcSignalValidator Title: ElectronMcSignalValidator
/tmp/SIMPLE/DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root
input_rel_file = /tmp/SIMPLE/DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root

input_ref_file = /tmp/SIMPLE/DQM_V0001_R000000001__RelValZEE_14__CMSSW_14_1_0_pre3-140X_mcRun3_2024_realistic_v8_STD_2024_noPU-v1__DQMIO.root

      h2 for dataset : ZEE_14
positions ['h_ele_vertexEta', '1', '1', '1', '0']
PictureChoice : TH1F
total time to execute :   0.4311
end of run

I suggest you try with latest 6.32.04 version instead. It will force using the builtin asimage version in ROOT that has some patches, instead of the system-one that might be outdated.

Hi, thanks for your answer.

when I logged into lxplus, and launch ROOT, I get the 6.32.02 version.
using my script (python3 mainSimple.py), I got :

PYTHON version : 3.9.18 (main, Jul 3 2024, 00:00:00)
[GCC 11.4.1 20231218 (Red Hat 11.4.1-3)]
ROOT version : 6.32.02

How can I force the 6.32.04 version ?
I reply to myself :

source /cvmfs/sft.cern.ch/lcg/app/releases/ROOT/6.32.04/x86_64-almalinux9.4-gcc114-opt/bin/thisroot.sh

and with this version, I still have the notification (ASImage2gif():1137:GIFS/h_ele_vertexEta.gif> (null)) but not for all the pictures (i.e. some have and some have not).

            _, short_histo_names, histo_positions = shortHistoName('ElectronMcSignalValidator/h_ele_vertexEta              1 1 1 0')
            gif_name = "GIFS/" + short_histo_names[0] + ".gif"
            print('positions %s' % histo_positions)
            histo_1 = h1.Get(short_histo_names[0]) #
            histo_2 = h2.Get(short_histo_names[0]) #
            gr.PictureChoice(histo_1, histo_2, histo_positions[1], histo_positions[2], gif_name, 0) # 2

            
            _, short_histo_names, histo_positions = shortHistoName('ElectronMcSignalValidator/h_ele_mva_isolated_barrel    1 1 0 0')
            gif_name = "GIFS/" + short_histo_names[0] + ".gif"
            print('positions %s' % histo_positions)
            histo_1 = h1.Get(short_histo_names[0]) #
            histo_2 = h2.Get(short_histo_names[0]) #
            gr.PictureChoice(histo_1, histo_2, histo_positions[1], histo_positions[2], gif_name, 0) # 2

I got :

positions [‘h_ele_vertexEta’, ‘1’, ‘1’, ‘1’, ‘0’]
PictureChoice : TH1F
positions [‘h_ele_mva_isolated_barrel’, ‘1’, ‘1’, ‘0’, ‘0’]
PictureChoice : TH1F
ASImage2gif():1137:<GIFS/h_ele_mva_isolated_barrel.gif> (null)

I think this can come from the function I use for gif picture (createPicture2).

def createPicture2(self, histo1, histo2, scaled, err, filename, id):
    new_entries = histo1.GetEntries() # ttl # of bins (9000 in general)
    ref_entries = histo2.GetEntries()
    self.cnv = TCanvas(str(id), "canvas")

    histo2c = histo2.Clone()
    histo3 = histo1.Clone("histo3")
    if ((scaled =="1") and (new_entries != 0) and (ref_entries != 0)):
        rescale_factor = new_entries / ref_entries
        histo2c.Scale(rescale_factor)
    if (histo2c.GetMaximum() > histo1.GetMaximum()):
        histo1.SetMaximum(histo2c.GetMaximum() * 1.1)
    
    self.cnv.SetCanvasSize(960, 900)
    self.cnv.Clear()
    self.cnv.SetFillColor(10)
    self.cnv.SetBorderMode(1)
    
    pad1 = ROOT.TPad(str(id), "pad1", 0, 0.25, 1.0, 1.0) # ,0,0,0
    pad1.SetBottomMargin(0.05)
    pad1.Draw()
    pad1.cd()
    
    if err == "1":
        newDrawOptions ="E1 P"
    else:
        newDrawOptions = "hist"
    
    histo1.SetStats(1)
    histo1.Draw(newDrawOptions) # 
    histo1.SetLineStyle(0)
    histo1.SetLineWidth(2)

    self.RenderHisto(histo1)
    if ("ELE_LOGY" in histo1.GetOption() and histo1.GetMaximum() > 0):
        if (re.search('etaEff_all', filename) or re.search('ptEff_all', filename)):
            print('accord')
            pad1.SetLogy(0)
        else:
            pad1.SetLogy(1)
    gPad.Update()
    
    statBox1 = histo1.GetListOfFunctions().FindObject("stats")
    statBox1.SetTextColor(kRed)
    statBox1.SetBorderSize(2)
    statBox1.SetFillColorAlpha(18, 0.35) # https://root.cern.ch/doc/master/classTAttFill.html
    statBox1.SetY2NDC(0.995)
    statBox1.SetY1NDC(0.755)
    statBox1.SetX2NDC(0.995)
    statBox1.SetX1NDC(0.795)

    gPad.Update()
    histo2c.Draw("sames hist") # ""  same
    histo2c.SetStats(1)
    self.RenderHisto(histo2c)
    if ("ELE_LOGY" in histo2c.GetOption() and histo2c.GetMaximum() > 0):
        if (re.search('etaEff_all', filename) or re.search('ptEff_all', filename)):
            print('accord')
            pad1.SetLogy(0)
        else:
            pad1.SetLogy(1)
    self.cnv.Update()
    statBox2 = histo2c.GetListOfFunctions().FindObject("stats")
    statBox2.SetTextColor(kBlue)
    y1 = statBox1.GetY1NDC()
    y2 = statBox1.GetY2NDC()
    statBox2.SetY1NDC(2*y1-y2)
    statBox2.SetY2NDC(y1)
    statBox2.SetBorderSize(2)
    statBox2.SetFillColorAlpha(18, 0.35)
    statBox2.SetX2NDC(0.995)
    statBox2.SetX1NDC(0.795)

    newDrawOptions = "sames "
    if err == "1":
        newDrawOptions += "E1 P"
    else:
        newDrawOptions += "hist"
    histo1.Draw(newDrawOptions)
    histo2c.Draw("sames hist")
    
    self.cnv.cd()
    pad2 = ROOT.TPad(str(id), "pad2", 0, 0.05, 1.00, 0.26) # ,0,0,0
    pad2.SetTopMargin(0.025)
    pad2.SetBottomMargin(0.3)
    pad2.SetBorderMode(0)
    pad2.SetGridy()
    pad2.Draw()
    pad2.cd()
    
    histo3.Divide(histo2c) # divide by the scaled nb of events
    histo3.SetLineColor(kBlack)
    histo3.SetMaximum(2.)
    histo3.SetMinimum(0.)
    histo3.SetStats(0)
    histo3.Sumw2() 
    histo3.SetMarkerStyle(21)
    histo3.Draw("ep")
    
    histo1.SetMarkerColor(kRed)
    histo1.SetLineWidth(3) 
    histo1.SetLineColor(kRed)
    histo1.GetYaxis().SetTitleSize(25)
    histo1.GetYaxis().SetTitleFont(43)
    histo1.GetYaxis().SetTitleOffset(2.00)
    histo1.GetZaxis().SetTitleSize(0.05)
    histo1.SetMarkerStyle(21)
    histo1.SetMarkerSize(0.8)
    
    histo2c.SetLineColor(kBlue)
    histo2c.SetMarkerColor(kBlue)
    histo2c.SetLineWidth(3)
    
    histo3.SetTitle("")
    # Y axis ratio plot settings
    histo3.GetYaxis().SetTitle("ratio h1/h2 ")
    histo3.GetYaxis().SetNdivisions(505)
    histo3.GetYaxis().SetTitleSize(20)
    histo3.GetYaxis().SetTitleFont(43)
    histo3.GetYaxis().SetTitleOffset(1.55)
    histo3.GetYaxis().SetLabelFont(43) # Absolute font size in pixel (precision 3)
    histo3.GetYaxis().SetLabelSize(15)
    # X axis ratio plot settings
    histo3.GetXaxis().SetTitleSize(20)
    histo3.GetXaxis().SetTitleFont(43)
    histo3.GetXaxis().SetLabelFont(43) # Absolute font size in pixel (precision 3)
    histo3.GetXaxis().SetLabelSize(15)

    self.cnv.Draw()
    self.cnv.Update()

    #self.cnv.SaveAs(filename)
    self.cnv.Print(filename)
    self.cnv.Close()
    
    return

Arnaud

I am not on lxplus, so not sure. You can always download the binary from the website.

Weird. Maybe some problem with folder write permission or so?

If you don’t call Close at the end, does the error disappear?

it has no effect.
if I use saveAs(filename) I get 2 notifications.
if I use Print(filename) I get only one notification on the second picture.

Update :
Using the following function for the picture creation :

def createPicture2b(self, histo1, histo2, filename, id):
    self.cnv = TCanvas(str(id), "canvas")

    self.cnv.SetCanvasSize(960, 900)
    self.cnv.Clear()
    self.cnv.SetFillColor(10)

    pad1 = ROOT.TPad(str(id), "pad1", 0, 0.25, 1.0, 1.0)
    pad1.SetBottomMargin(0.05)
    pad1.Draw()
    pad1.cd()
    
    self.cnv.Draw()
    self.cnv.Update()

    self.cnv.SaveAs(filename)
    self.cnv.Close()
    return

leads to new results : most of the notifications have disappeared.
but, when launching many the same script, a notification appears again.

A more simple function leads to the same result :

def createPicture2b(self, histo1, histo2, filename, id):
self.cnv = TCanvas(str(id), “canvas”)

    self.cnv.SetCanvasSize(960, 900)
    self.cnv.Clear()
    self.cnv.SetFillColor(10)

    self.cnv.Draw()
    self.cnv.Update()

    self.cnv.Print(filename)
    
    return