CMS 3D CMS Logo

allPlotsResiduals.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 from __future__ import print_function
3 import ROOT
4 import optparse
5 import re
6 import os
7 
8 def main():
9  parser = optparse.OptionParser()
10  (options, args) = parser.parse_args()
11  ROOT.gROOT.SetBatch(True)
12  for filename in args:
13  if "vDrift_segment_" in filename:
14  #name="DQM"
15  m=re.search("vDrift_segment_(\d*)",filename)
16  run=m.group(1)
17 
18  #path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation"
19 
20  f = open('dtVDriftAnalyzer_cfg.py','w')
21  print("from CalibMuon.DTCalibration.Workflow.addPoolDBESSource import addPoolDBESSource", file=f)
22  print("from CalibMuon.DTCalibration.dtVDriftAnalyzer_cfg import process", file=f)
23  print("addPoolDBESSource(process = process, moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift', connect = 'sqlite_file:"+filename+"')", file=f)
24  print("process.dtVDriftAnalyzer.rootFileName = 'dtVDriftAnalyzer_dtVDriftCalibration"+run+".root'", file=f)
25  f.close()
26  os.system("cmsRun dtVDriftAnalyzer_cfg.py")
27  name="vdrift"
28  runvdrift(name, run, "dtVDriftAnalyzer_dtVDriftCalibration"+run+".root")
29 
30  if "vDrift_meantimer_" in filename:
31  #name="DQM"
32  m=re.search("vDrift_meantimer_(\d*)",filename)
33  run=m.group(1)
34 
35  #path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation"
36 
37  f = open('dtVDriftAnalyzer_cfg.py','w')
38  print("from CalibMuon.DTCalibration.Workflow.addPoolDBESSource import addPoolDBESSource", file=f)
39  print("from CalibMuon.DTCalibration.dtVDriftAnalyzer_cfg import process", file=f)
40  print("addPoolDBESSource(process = process, moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift', connect = 'sqlite_file:"+filename+"')", file=f)
41  print("process.dtVDriftAnalyzer.rootFileName = 'dtVDriftAnalyzer_dtVDriftCalibration"+run+".root'", file=f)
42  f.close()
43  os.system("cmsRun dtVDriftAnalyzer_cfg.py")
44  name="vdrift"
45  runvdrift(name, run, "dtVDriftAnalyzer_dtVDriftCalibration"+run+".root")
46 
47  elif "DQM" in filename:
48  name="DQM"
49  m=re.search("R000(\d*)__",filename)
50  run=m.group(1)
51  path="DQMData/Run "+run+"/DT/Run summary/DTCalibValidation"
52  runttrig(name, filename, path, run)
53  elif "TestPulses" in filename:
54  name="T0"
55  runt0(name,filename,123456)
56  else:
57  name="DTRV"
58  m=re.search("DTResidualValidation_(\d*)\.root",filename)
59  run=m.group(1)
60  path="DTResiduals"
61  runttrig(name, filename, path, run)
62 
63 def runttrig(name, filename, path, run):
64  from CalibMuon.DTCalibration.PlottingTools.plotResiduals import *
65  for SL in [1,2,3]:
66  mean,sigma = plot(filename, SL,dir=path)
67  mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf")
68  mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root")
69  sigma[0].Print(name+run+"-SL"+str(SL)+"-sigma.pdf")
70  sigma[0].SaveAs(name+run+"-SL"+str(SL)+"-sigma.root")
71 def runvdrift(name, run, filename):
72  from CalibMuon.DTCalibration.PlottingTools.plotVDriftFromHistos import *
73  for SL in [1,2,3]:
74  mean = plot(filename, SL)
75  mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf")
76  mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root")
77  #sigma[0].Print(name+run+"-SL"+str(SL)+"-sigma.pdf")
78 
79  #plot("DTResidualValidation_210614.root", 1,dir="DTResiduals")
80  #plot("DQM_V0001_R000210634__StreamExpress__HIRun2013-DtCalib-Express-v1-dtTtrigCalibrationFromResiduals-NEW-usedb-rev1__ALCARECO.root", 1,dir="DQMData/Run 210634/DT/Run summary/DTCalibValidation")
81 def runt0(name,filename,run):
82  from CalibMuon.DTCalibration.PlottingTools.plotT0FromHistos import *
83  for SL in [1,2,3]:
84  mean = plot(filename, SL ,run)
85  mean[0].Print(name+run+"-SL"+str(SL)+"-mean.pdf")
86  mean[0].SaveAs(name+run+"-SL"+str(SL)+"-mean.root")
87 
88 if __name__=="__main__":
89  main()
def runvdrift(name, run, filename)
def runt0(name, filename, run)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Definition: main.py:1
def runttrig(name, filename, path, run)
#define str(s)