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

MahiDebugger Run 3 config #36143

Merged
merged 3 commits into from Nov 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,4 +7,5 @@
meanTime = method2.m2Parameters.meanTime,
mseidel42 marked this conversation as resolved.
Show resolved Hide resolved
timeSigmaHPD = method2.m2Parameters.timeSigmaHPD,
timeSigmaSiPM = method2.m2Parameters.timeSigmaSiPM),
mahi.mahiParameters)
mahi.mahiParameters,
recoLabel = cms.InputTag('hbheprereco@cpu'))
mseidel42 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion RecoLocalCalo/HcalRecAlgos/test/MahiDebugger.cc
Expand Up @@ -202,7 +202,7 @@ MahiDebugger::MahiDebugger(const edm::ParameterSet& iConfig)
deltaChiSqThresh_,
nnlsThresh_);

token_ChannelInfo_ = consumes<HBHEChannelInfoCollection>(edm::InputTag("hbheprereco", ""));
token_ChannelInfo_ = consumes<HBHEChannelInfoCollection>(iConfig.getParameter<edm::InputTag>("recoLabel"));
}

MahiDebugger::~MahiDebugger() {}
Expand Down Expand Up @@ -355,6 +355,7 @@ void MahiDebugger::endJob() {}
void MahiDebugger::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;

desc.add<edm::InputTag>("recoLabel");
desc.add<bool>("dynamicPed");
desc.add<bool>("calculateArrivalTime");
desc.add<double>("ts4Thresh");
Expand Down
104 changes: 104 additions & 0 deletions RecoLocalCalo/HcalRecAlgos/test/plotMahi.py
@@ -0,0 +1,104 @@
#!/usr/bin/env python

# Plot MAHI multi-pulse fit results
import ROOT
ROOT.gStyle.SetOptStat(0)
c = ROOT.TCanvas('c','c',500,500)
c.cd()
c.SetRightMargin(0.05)
c.SetLeftMargin(0.12)
c.SetTopMargin(0.1)
c.SetTopMargin(0.05)

color = [ROOT.kAzure+3, ROOT.kAzure+2, ROOT.kAzure+1, ROOT.kYellow-7, ROOT.kRed+1, ROOT.kRed+2, ROOT.kRed+3, ROOT.kRed+4]

import os
plotdir = 'plotMahi'
if not os.path.exists(plotdir):
os.mkdir(plotdir)

# Parameters for Run 3 HBHE
nTS = 10 # number of TS to plot
nOOT = 7 # number of OOT samples
offset = 3 # soi

hists = {}
hists['digi'] = ROOT.TH1D('digi', ';TS;E [GeV]', nTS, -0.5, nTS-0.5)
hists['digi'].SetMarkerStyle(20)
for i in range(nOOT+1):
hists[i] = ROOT.TH1D('bx%i' % (i-3), ';TS;E [GeV]', nTS, -0.5, nTS-0.5)
hists[i].SetFillColor(color[i])
hists[i].SetLineColor(ROOT.kBlack)

tags = ['']#, '_shape206', '_timeslew', '_mt6', '_qcd', '_qcdnopu']

from tqdm import tqdm

for tag in tags:
tree = ROOT.TChain('mahiDebugger/HcalTree')
tree.Add('mahidebugger%s.root' % tag)
count = 0
for rh in tqdm(tree):
if abs(rh.ieta) > 16:
continue
soiEnergy = rh.mahiEnergy*rh.inGain
if soiEnergy < 1:
continue

energy = {}
soi = rh.soi
assert soi == offset

for i in range(nTS-1):
hists['digi'].SetBinContent(i+1, rh.inputTS[i]*rh.inGain)
hists[soi].SetBinContent(i+1, rh.itPulse[i]*rh.mahiEnergy*rh.inGain)
energy[soi] = soiEnergy

for o in range(nOOT):
oh = o+1 if o>=soi else o
ootPulse = []
for i in range(nTS*o, nTS*(o+1)):
ootPulse.append(rh.ootPulse[i])

for i in range(nTS):
hists[oh].SetBinContent(i+1, max(0, ootPulse[i]*rh.ootEnergy[o]*rh.inGain))
energy[oh] = rh.ootEnergy[o]*rh.inGain

stack = ROOT.THStack('stack', '')
for i in range(nOOT+1):
stack.Add(hists[i])

hists['digi'].GetXaxis().SetRangeUser(-0.5, 7.5)
hists['digi'].GetYaxis().SetRangeUser(0, hists['digi'].GetBinContent(4)*1.5)
hists['digi'].Draw('P0')
stack.Draw('same')
hists['digi'].Draw('P0,same')

legend = ROOT.TLegend(0.6,0.5,0.93,0.93)
legend.SetLineWidth(0)
legend.SetFillStyle(0)
legend.AddEntry(hists['digi'], 'Digi', 'P')
for i in range(nOOT+1):
legend.AddEntry(hists[i], 'BX %+i, E = %.1f GeV' % (i-offset, energy[i]), 'F')

tex = ROOT.TLatex()
tex.SetTextSize(0.025)
tex.DrawLatexNDC(0.15, 0.90, 'run:'+str(rh.run)+' evt:'+str(rh.evt))
tex.DrawLatexNDC(0.15, 0.85, 'ieta:'+str(rh.ieta)+' iphi:'+str(rh.iphi)+' depth:'+str(rh.depth))
tex.DrawLatexNDC(0.15, 0.80, '#chi^{2} = %.1f, TDC=%i, mahiTime=%.1f' % (rh.chiSq, rh.inputTDC[3], rh.arrivalTime))

wTime = 0.
sumEn = 0.
for i in range(len(energy)):
thisEnergy = rh.inputTS[i]*rh.inGain
wTime += thisEnergy * i
sumEn += thisEnergy
if sum(energy) > 0:
wTime /= sumEn
tex.DrawLatexNDC(0.15, 0.75, 'Mean time = %.1f TS' % (wTime))

legend.Draw()

c.Print(plotdir+'/'+str(rh.run)+'_'+str(rh.evt)+'_'+str(rh.ieta)+'_'+str(rh.iphi)+'_'+str(rh.depth)+tag+'.pdf')
c.Print(plotdir+'/'+str(rh.run)+'_'+str(rh.evt)+'_'+str(rh.ieta)+'_'+str(rh.iphi)+'_'+str(rh.depth)+tag+'.png')
count += 1
mseidel42 marked this conversation as resolved.
Show resolved Hide resolved
77 changes: 77 additions & 0 deletions RecoLocalCalo/HcalRecAlgos/test/run_mahidebugger_run3data_cfg.py
@@ -0,0 +1,77 @@
import FWCore.ParameterSet.Config as cms

from Configuration.StandardSequences.Eras import eras

process = cms.Process('TEST',eras.Run3)

# import of standard configurations
process.load('Configuration.StandardSequences.Services_cff')
process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.MessageLogger.cerr.threshold = ''
process.MessageLogger.cerr.FwkReport.reportEvery = 100
process.options = cms.untracked.PSet(
wantSummary = cms.untracked.bool(True),
SkipEvent = cms.untracked.vstring('ProductNotFound')
)


process.load('Configuration.EventContent.EventContent_cff')
process.load("Configuration.StandardSequences.GeometryDB_cff")
process.load('Configuration.StandardSequences.MagneticField_AutoFromDBCurrent_cff')
process.load('Configuration.StandardSequences.RawToDigi_Data_cff')
process.load('Configuration.StandardSequences.L1Reco_cff')
process.load('Configuration.StandardSequences.Reconstruction_Data_cff')
process.load('Configuration.StandardSequences.EndOfProcess_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(-1)
)

# Input source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring('file:/eos/cms/tier0/store/data/Commissioning2021/ZeroBias/RAW/v1/000/346/512/00000/f87a2268-8f93-4389-b708-98a42a50c3e8.root'),
secondaryFileNames = cms.untracked.vstring()
)

process.options = cms.untracked.PSet(

)

# Output definition
process.RECOoutput = cms.OutputModule("PoolOutputModule",
dataset = cms.untracked.PSet(
dataTier = cms.untracked.string('RECO'),
filterName = cms.untracked.string('')
),
fileName = cms.untracked.string('file:step3.root'),
outputCommands = process.RECOEventContent.outputCommands,
splitLevel = cms.untracked.int32(0)
)

process.TFileService = cms.Service("TFileService",
fileName = cms.string("mahidebugger.root")
)

# Additional output definition

# Other statements
process.load("Configuration.StandardSequences.FrontierConditions_GlobalTag_cff")
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run3_data', '')

process.hbheprereco.cpu.saveInfos = cms.bool(True)

process.load("RecoLocalCalo.HcalRecAlgos.mahiDebugger_cfi")

# Path and EndPath definitions
process.raw2digi_step = cms.Path(process.hcalDigis)
process.reconstruction_step = cms.Path(process.hbheprereco)
process.flat_step = cms.Path(process.mahiDebugger)
process.RECOoutput_step = cms.EndPath(process.RECOoutput)
process.endjob_step = cms.EndPath(process.endOfProcess)

# Schedule definition
process.schedule = cms.Schedule(process.raw2digi_step,process.reconstruction_step,process.flat_step)