cms-mual / MuAlPhysicsValidation

Muon Alignment Physics Validation
0 stars 4 forks source link

Performance Plots 2.0 - 4 histograms fail on makeProfile() #9

Closed athompson-git closed 6 years ago

athompson-git commented 6 years ago

The histogram comparison

glb_sta_pt_v_ptRes_gaus_mean

fails to plot when running the ordinary workflow of performance plots. That is, by first using Step1_make_2d_plots.py to create ROOT files and then running Step2_makeProfiles.py to run the comparison, Step2_makeProfiles.py fails with the following stack trace:

cmsenv
python Step2_makeProfiles.py -b
[lots of stdout...]
Traceback (most recent call last):
  File "Step2_makeProfiles.py", line 67, in <module>
    make1D("TH1F_sta_trk_delta_phi")
  File "functions.py", line 170, in make1D
    TH1F_scaled.Scale(1./TH1F_scaled.GetEntries())
AttributeError: 'TObject' object has no attribute 'Scale'

The python also fails on TH1F_sta_trk_delta_phi_barrel, TH1F_sta_trk_delta_phi_endcap for the same reason. In addition, glb_sta_pt_v_ptRes also fails creation with the following trace:

Traceback (most recent call last):
  File "Step2_makeProfiles.py", line 85, in <module>
    makeProfile("glb_sta_pt_v_ptRes","res",nBins, "gaus", drawBinPlots,ptResMeanRange,ptResSigmaRange)
  File "functions.py", line 49, in makeProfile
    histoBounds = histo.GetXaxis().GetXmin(), histo.GetXaxis().GetXmax()
AttributeError: 'TObject' object has no attribute 'GetXaxis'

Additionally, if I try an alternate workflow of using Step1_make_2d_plots_histogrammar.py instead for Step 1, I don't run into any crashes but the plots that I get in the end show much different results than the workflow above. Everything from the means and widths of the distributions to the data ranges disagree, and the displays are nonsensical when compared with Step1_make_2d_plots.py which I have historically used.

demarley commented 6 years ago

hey @athompson-tamu it looks like the object TH1F_scaled doesn't point to an actual histogram. Can you check what it is pointing to and how it's created? I'm not familiar enough to answer this right now, but I can look into it in a few days

athompson-git commented 6 years ago

Taking a look - +@rymuelle if he's more familiar

athompson-git commented 6 years ago

Found the culprit for the first 3 errors. In Step2 the histograms are called by name to do the comparison, for example "TH1F_sta_trk_delta_phi", but the actual names of the 1D histograms in the input files are named with capital letters: "TH1F_sta_TRK_delta_phi". I think the best way to fix this is to conform to the all-lowercase convention, since most of the TH1F's use all-lowercase; this means changing TH1F_sta_trk_delta_phi* in histograms.py and recoMuonLoop.py (and anywhere else the capital TRK naming is used).

Full explanation for our edification:

TH1F_scaled gets called like this:

def make1D(TH1F_name):
...
TH1F_scaled = file.Get(TH1F_name)

where this particular name is passed from Step2_makeProfiles.py:

make1D("TH1F_sta_trk_delta_phi")

Each file is called from a fileList is eventually declared at the start of the file with the user inputs. The file inputs are declared from Step1_make_2d_plots.py, which has its histograms defined in histograms.py:

#phi TRK
TH1F_sta_TRK_delta_phi_barrel = TH1F("TH1F_sta_TRK_delta_phi_barrel", "(#phi_{TRK}-#phi_{STA})/#phi_{GLB Error}  |#eta| < 0.9; #delta #phi",phiResBins, phiResMin, phiResMax )

So the names that get called in make1D() need to inherit from the same names in histograms.py.

athompson-git commented 6 years ago

As for the last error, glb_sta_pt_v_ptRes is not found because it does not exist in histograms.py like its cousins glb_sta_phi_v_ptRes and glb_sta_eta_v_ptRes.

athompson-git commented 6 years ago

I can try to put in a PR to fix the issues above.

Going back to the other issue that I mentioned in post # 1, here's an example of how two of the same plots disagree between the Step1_make_2d_plots_histogrammar.py and Step1_make_2d_plots.py workflows, respectively: sta_glb_eta_hybridsta_mass_gaus_mean sta_glb_eta_hybridsta_mass_gaus_mean

athompson-git commented 6 years ago

Another example: glb_sta_eta_v_ptres_gaus_mean glb_sta_eta_v_ptres_gaus_mean

rymuelle commented 6 years ago

Which branch are you on?

athompson-git commented 6 years ago

FTR this is 10_0_X branch

demarley commented 6 years ago

is this fixed by #10 or are there are things that are still incorrect?

athompson-git commented 6 years ago

My PR was merged and addressed the crashes, but the second issue I mention is still open:

Additionally, if I try an alternate workflow of using Step1_make_2d_plots_histogrammar.py instead for Step 1, I don't run into any crashes but the plots that I get in the end show much different results than the workflow above. Everything from the means and widths of the distributions to the data ranges disagree, and the displays are nonsensical when compared with Step1_make_2d_plots.py which I have historically used.

(see plot comparisons in the above comments)

demarley commented 6 years ago

okay, so Step1_make_2d_plots_histogrammar.py is still producing something completely different from Step1_make_2d_plots.py, correct?

athompson-git commented 6 years ago

That's correct

rymuelle commented 6 years ago

Ok so, I am going to close this issue and reopen the second issue.