5     '''Function to configure LVL1 Gfex simulation comparison algorithm in the monitoring system.''' 
    8     from AthenaConfiguration.ComponentFactory 
import CompFactory
 
    9     from TrigT1CaloMonitoring.LVL1CaloMonitoringConfig 
import L1CaloMonitorCfgHelper
 
   10     helper = L1CaloMonitorCfgHelper(flags,CompFactory.GfexSimMonitorAlgorithm,
'GfexSimMonAlg')
 
   12     helper.defineDQAlgorithm(
"L1CaloMismatchRate",
 
   13                              hanConfig={
"libname":
"libdqm_summaries.so",
"name":
"Bins_GreaterThan_Threshold",
"BinThreshold":
"0.9"}, 
 
   14                              thresholdConfig={
"NBins":[0,10]}, 
 
   17     helper.defineHistogram(
'LBN,Signature;h_mismatched_SimReady',
 
   18                            fillGroup=
"mismatches",
 
   19                            paths=[
'Shifter/Sim'],
 
   20                            hanConfig={
"algorithm":
"Histogram_Empty",
"description":
"Number of events with a mismatch, per LB (x-axis), per signature (y-axis) for signatures that are deemed simulation-ready",
"display":
"SetPalette(55)"},
 
   21                            type=
'TH2I', cutmask=
'SimulationReadyMismatch',
 
   22                            title=
'Mismatched Simulation-Ready Events;LB;Signature;Events',
 
   23                            xbins=1,xmin=0,xmax=1,
 
   24                            ylabels=[
"gJ",
"gLJ",
"jJ",
"jTAU",
"jEM",
"jXE",
"jTE",
"eTAU",
"eEM"],
 
   25                            opt=[
'kAddBinsDynamically',
'kCanRebin',
'kAlwaysCreate'],merge=
'merge')
 
   26     helper.defineHistogram(
'LBN,Signature,tobMismatched;h_mismatched_SimReadyRate',
 
   27                            fillGroup=
"mismatches",
 
   29                            hanConfig={
"algorithm":
"L1CaloMismatchRate",
"description":
"Mismatch rate, per LB (x-axis), per signature (y-axis) for signatures that are deemed simulation-ready - should not be high rate (see DQ algo)",
"display":
"SetPalette(55)"},
 
   30                            type=
'TProfile2D', cutmask=
'SimulationReady',
 
   31                            title=
'Mismatched Rate for Simulation-Ready Signatures;LB;Signature;Event Rate (%)',
 
   32                            xbins=1,xmin=0,xmax=1,
 
   33                            ylabels=[
"gJ",
"gLJ",
"jJ",
"jTAU",
"jEM",
"jXE",
"jTE",
"eTAU",
"eEM"],
 
   34                            opt=[
'kAddBinsDynamically',
'kCanRebin',
'kAlwaysCreate'],merge=
'merge')
 
   35     helper.defineHistogram(
'EventType,Signature,tobMismatched;h_simSummary',title=
'Sim-HW Mismatches (percentage);Event Type;Signature',
 
   36                            fillGroup=
"mismatches",
 
   37                            path=
'Expert/Sim/detail', 
 
   38                            hanConfig={
"display":
"SetPalette(87),Draw=COLZTEXT"},
 
   40                            xlabels=[
"DataTowers",
"EmulatedTowers"],
 
   41                            ymin=0,ymax=len(L1CaloMonitorCfgHelper.SIGNATURES),ylabels=L1CaloMonitorCfgHelper.SIGNATURES,
 
   42                            opt=[
'kCanRebin',
'kAlwaysCreate'],merge=
"merge")
 
   44     for sig 
in [
"gJ",
"gLJ"]:
 
   45         helper.defineHistogram(
"LBN,locIdx;h_"+sig+
"_mismatches_posLbnMap", title = 
"Mismatched " + sig + 
" [DataTower evts];LB;Position (iEta:iPhi);TOBs",
 
   46                                fillGroup = 
"mismatches"+ sig,
 
   48                                path=
"Expert/Sim/detail",
 
   50                                    "display":
"SetPalette(87)",
 
   51                                    "description":
"Location of mismatched " + sig + 
" TOBs. Use this plot to identify any localized gFEX issues. N.B. this plot is only created if there are mismatches."},
 
   52                                xbins=1,xmin=0,xmax=1,
 
   53                                ybins=1,ymin=0,ymax=1,
 
   54                                opt=[
'kAddBinsDynamically'])
 
   57     helper.defineTree(
'LBN,Signature,LBNString,L1ID,EventNumber,dataEtas,dataPhis,dataEts,dataWord0s,simEtas,simPhis,simEts,simWord0s;mismatched_jet',
 
   58                       "lbn/l:Signature/string:lbnString/string:L1ID/i:eventNumber/l:dataEtas/vector<float>:dataPhis/vector<float>:dataEts/vector<int>:dataWord0s/vector<unsigned int>:simEtas/vector<float>:simPhis/vector<float>:simEts/vector<int>:simWord0s/vector<unsigned int>",
 
   59                       title=
"mismatched;LBN;Signature",fillGroup=
"mismatches", cutmask=
'FillJetTree')
 
   61     helper.defineTree(
'LBN,Signature,LBNString,L1ID,EventNumber,dataTOB1,dataTOB2,dataWord0s,simTOB1,simTOB2,simWord0s;mismatched_global',
 
   62                       "lbn/l:Signature/string:lbnString/string:L1ID/i:eventNumber/l:dataTOB1/vector<float>:dataTOB2/vector<float>:dataWord0s/vector<unsigned int>:simTOB1/vector<float>:simTOB2/vector<float>:simWord0s/vector<unsigned int>",
 
   63                       title=
"mismatched;LBN;Signature",fillGroup=
"mismatches", cutmask=
'FillGlobalTree')
 
   67     return helper.result()