Experimental re-structure of TRestAnalysisPlot

I have updated the class TRestAnalysisPlot to make a better hierarchy of plot contents. As we agreed in

we are going to add a new definition “histo” under “plot” section, which draws multiple histogram onto a same pad, helping to compare observables from different files or under different cuts.

Therefore, we have a new base unit of the plot: histo. In the new design scheme of TRestAnalysisPlot, this class contains a vector of “plot” object. Each of them in turn contains a vector of “histo” object. TRestAnalysisPlot handles a TCanvas object. Then, the contained “plot” handles TPad objects inside TCanvas. Finally, the contained “histo” handles TH1/TH2 objects inside TPad.

I kept the old TRestAnalysisPlot rml definition and introduced new definition of multi-histo plot, for multi-cut plot, one can write like following.

    <plot name="Spectrum_CutImpact" title="Impact of cut on the spectrum" 
          xlabel="Threshold integral energy [ADC units]" ylabel="Counts" logscale="true"
          legend="on">

      <histo name="noCuts">
        <variable name="sAna_ThresholdIntegral" nbins="1000" />
        <parameter name="lineColor" value="1"/>
      </histo>

      <histo name="BaseLine">
        <variable name="sAna_ThresholdIntegral" nbins="1000" />
        <cut variable="sAna_BaseLineSigmaMean" condition="&lt;12" value="ON" />
        <parameter name="lineColor" value="2"/>
      </histo>

      <histo name="BaseLine+NSig">
        <variable name="sAna_ThresholdIntegral" nbins="1000" />
        <cut variable="sAna_BaseLineSigmaMean" condition="&lt;12" value="ON" />
        <cut variable="sAna_NumberOfGoodSignals" condition=">35" value="ON" />
        <parameter name="lineColor" value="3"/>
      </histo>
    </plot>

For different observable comparision, one can do:

<plot name="plotName" title="" xlabel="Z [mm]" ... >
     <histo name="R12">
         <variable name="tckBlob_2D_Qlow_X_R12" .... >
     </histo>
 
     <histo name="R15">
         <variable name="tckBlob_2D_Qlow_X_R15" .... >
     </histo>
 
     <histo name="R18">
         <variable name="tckBlob_2D_Qlow_X_R18" .... >
     </histo>
 </plot>

For different file plot:

    <plot name="ABC" title="" xlabel="Track energy ratio" legend="on" logy="on">
      <histo name="0vbb" fillColor="xxx" lineColor="xxx">
        <variable name="TrackEnergyRatio"/>
        <classify fRunTag="NLDBD"/>
      </histo>

      <histo name="micromegas Th232" fillColor="xxx" lineColor="xxx">
        <variable name="TrackEnergyRatio"/>
        <classify fRunTag="Th232"/>
      </histo>

      <histo name="micromegas U238" fillColor="xxx" lineColor="xxx">
        <variable name="TrackEnergyRatio"/>
        <classify fRunTag="U238"/>
      </histo>
    </plot>

For single histo plot, the variables can still be added directly inside “plot section”:

    <plot name="Baseline average" xlabel="Baseline [ADC units]" ylabel="Counts"
            logscale="false" value="ON" >
      <variable name="sAna_BaseLineMean" range="(200,600)" nbins="100" />
    </plot>

The change is:

  1. Line color/width, fill color, etc. options are now defined in histo level.
  2. “Classify” keyword now needs to be defined explicitly in histo level.

Now TRestAnalysisTree also supports non-REST file input. For example, we write

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<TRestManager name="SpecPlot" title="Example" verboseLevel="info" >

  <TRestRun name="SJTU_Proto" >
    <parameter name="runNumber" value="-1"/>//change this value to "auto" to enable database
    <parameter name="outputFile" value="null"/>//change this value to "auto" to enable database
  </TRestRun>

  <TRestAnalysisPlot name="restplot" title="Basic Plots" previewPlot="true">

    <variable name="energyStr" value="13.6e-3*(qS1/0.074+3.3*qS2Bottom*qS2/(qS2Bottom+qS2Top)/22.3/1.02)"/>
    <variable name="dt" value="tS2-tS1"/>
    <variable name="r2" value="xTopNN*xTopNN+yTopNN*yTopNN"/>

    <canvas size="(1000,800)" save="abc.pdf"/>
    
    <globalCut variable="${dt}" condition="&gt;140e3" value="ON" />
    <globalCut variable="${dt}" condition="&lt;350e3" value="ON" />
    <globalCut variable="${r2}" condition="&lt;8e4" value="ON" />

    <plot name="Spectrum_CutImpact" title="Using different Correction Map"
      xlabel="Energy [keV]" ylabel="Counts" logscale="false"
      legend="on">

      <histo name="164_NN" lineColor="1">
        <variable name="${energyStr}" range="(0,3000)" nbins="200" />
        <classify FileName="ana3_total_run25280_26262_164_NN.root"/>
      </histo>

      <histo name="Kr_PAF" lineColor="2">
        <variable name="${energyStr}" range="(0,3000)" nbins="200" />
        <classify FileName="ana3_total_run25280_26262_Kr_PAF.root"/>
      </histo>

    </plot>
    
  </TRestAnalysisPlot>

  <addTask command="restplot->PlotCombinedCanvas()" value="ON"/>

</TRestManager>

We can get a plot for PandaX-II energy spectrum by calling restManager --c CompareSpec.rml --i "*.root"

Still, it would be good to be able to define a global default styles outside. As it was done with <style ...>.

I dont understand this exactly. What it is inside ana3_total_run25280.root? It is not a file containing a TRestAnalysisTree? qS1 it is extracted from a TTree?

Thanks for the updates to TRestAnalysisPlot I will test as soon as I can, probably 2nd half of next week.

I was also planning to work on evolution plots. I had in mind just to identify the x-label of the plot, and if it contains “date” or “time” in the string then produce different type of plots that evolve with time, using the fEventTimeStamp properly translated to time. Perhaps in that case the best is to use a TGraph, by getting an average in a period of time. Need to think about that.

This is enabled by TRestRun. Now TRestRun can open non-REST root files. In this case, it will find the first TTree object in the file as its fAnalysisTree

If we use the following rml to work with PandaX-II’s data, we can have the time evolution plot

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

<TRestManager name="SpecPlot" title="Example" verboseLevel="info" >

  <TRestRun name="SJTU_Proto" >
    <parameter name="runNumber" value="-1"/>//change this value to "auto" to enable database
    <parameter name="outputFile" value="null"/>//change this value to "auto" to enable database
  </TRestRun>

  <TRestAnalysisPlot name="restplot" title="Basic Plots" previewPlot="true">

    <variable name="energyStr" value="13.6e-3*(qS1/0.074+3.3*qS2Bottom*qS2/(qS2Bottom+qS2Top)/22.3/1.02)"/>
    <variable name="dt" value="tS2-tS1"/>
    <variable name="r2" value="xTopNN*xTopNN+yTopNN*yTopNN"/>

    <canvas size="(1000,800)" save="abc.pdf"/>

    <globalCut variable="${dt}" condition="&gt;140e3" value="ON" />
    <globalCut variable="${dt}" condition="&lt;350e3" value="ON" />
    <globalCut variable="${r2}" condition="&lt;8e4" value="ON" />

    <plot name="Spectrum Evolution"
      xlabel="Absolute Time" ylabel="Energy [keV]" logscale="false" logZ="ON"
      legend="off">

      <variable name="time" range="(1541.1e6,1542.3e6)" nbins="200" />
      <variable name="${energyStr}" range="(0,3000)" nbins="200" />


    </plot>

  </TRestAnalysisPlot>

  <addTask command="restplot->PlotCombinedCanvas()" value="ON"/>

</TRestManager>

This is a histogram, and I believe it is good enough to show time evolution. However, now we need to manually click “SetTimeDisplay” on the X-axis right menu, otherwise it shows the absolute time(1541.1e6). We can make is automatic. As you mentioned if the title contains “date” or “time”, we can set the axis to have time format.

Hi, I am testing now the new TRestAnalysisPlot structure.

I have a problem with the <cut definition here.

In the debug output I get the following

39

rawAna_NumberOfGoodSignals exists inside the analysisTree. Why and where in the code is identified as NO_SUCH_PARA?

OK. I finally identified the problem. It must be <cut variable=, and not <cut name=

Ok, I introduced an option at <plot definition. We can use timeDisplay="ON" to enable SetTimeDisplay on x-axis.

Also, I introduced automatic range definition on time in case range is not defined for time. If we don’t do that the range in Y is not working neither.

I have also introduced special keywords <<startTime>>, <<endTime>>, <<entries>>, <<runLength>>, <<meanRate>>, that can be used in the panel.