Skip to content

Instantly share code, notes, and snippets.

@gadamc
Created June 4, 2011 06:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadamc/1007648 to your computer and use it in GitHub Desktop.
Save gadamc/1007648 to your computer and use it in GitHub Desktop.
create a tgraph for the mean amplitude versus time and correlated with temperature
#!/usr/bin/env python
from ROOT import *
import os, sys
import numpy as np
def main(*args):
runFile = os.path.join('/sps/edelweis/kdata/data/current/raw', os.path.basename(args[0]))
boloName = args[1]
f = KDataReader(runFile)
e = f.GetEvent()
ff = TFile(os.path.join('$HOME/analysis/tempVtime/tempPlots', 'tempPlots' + boloName + '_'+ os.path.basename(runFile)), 'recreate')
gTemperature = TGraph(1)
gResolution = TGraph(1)
gCorrelation = TGraph(1)
tPoint = 0
rPoint = 0
cPoint = 0
for i in range(f.GetEntries()):
f.GetEntry(i)
for j in range(e.GetNumBolos()):
b = e.GetBolo(j)
if b.GetDetectorName() == boloName:
s = b.GetSambaRecord()
gTemperature.SetPoint(tPoint, s.GetNtpDateSec(), s.GetTemperature())
tPoint += 1
for n in range(b.GetNumPulseRecords()):
p = b.GetPulseRecord(n)
if p.GetIsHeatPulse():
trace = np.array(p.GetTrace()[:200])
mean = trace.mean()
gResolution.SetPoint(rPoint, s.GetNtpDateSec(), mean)
rPoint += 1
gCorrelation.SetPoint(cPoint, mean, s.GetTemperature())
cPoint += 1
ff.cd()
gTemperature.SetName('temp')
gTemperature.Write()
gResolution.SetName('meanamp')
gResolution.Write()
gCorrelation.SetName('cor')
gCorrelation.Write()
ff.Close()
f.Close()
if __name__ == '__main__':
main(*sys.argv[1:])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment