ATLAS Offline Software
checkNSWValTree.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # this script can be used to check the output ntuples of NSWPRDValAlg
4 
5 from __future__ import print_function
6 import os, sys, ROOT, argparse
7 
8 if __name__ == "__main__":
9  parser = argparse.ArgumentParser(prog='checkNSWValTree', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
10  parser.add_argument('-i', '--inputFile', help='choose input ROOT file', default='NSWPRDValAlg.digi.ntuple.root', type=str)
11  parser.add_argument('--checkPRD', help='check also the RPDs (for reco validation only)', action='store_true', default=False)
12  parser.add_argument('--checkHits', help='check also the Hits (Hits are skimmed out after Digitisation step!)', action='store_true', default=False)
13  parser.add_argument('--checkDigits', help='check also the Digits (Hits are skimmed out after Digitisation step!)', action='store_true', default=False)
14  parser.add_argument('--checkSDO', help='check also the SDO (Hits are skimmed out after Digitisation step!)', action='store_true', default=False)
15  Options = parser.parse_args()
16 
17  ROOT.gROOT.SetBatch(True)
18 
19  if not os.path.exists(Options.inputFile):
20  print ('ERROR: File %s does not exist'%Options.inputFile)
21  sys.exit(1)
22 
23  inputFile = ROOT.TFile(Options.inputFile, "READ")
24  if not inputFile:
25  print ('ERROR: Failed to open file %s'%Options.inputFile)
26  sys.exit(1)
27  inputTree = inputFile.Get("NSWValTree")
28  if not inputTree:
29  print ('ERROR: NSWValTree does not exist in file %s'%Options.inputFile)
30  sys.exit(1)
31 
32  nEntries = inputTree.GetEntries()
33  if nEntries==0:
34  print ('ERROR: NSWValTree of file %s has 0 entries'%Options.inputFile)
35  sys.exit(1)
36 
37  nHitsMM = 0
38  nHitsSTGC = 0
39  nDigitsMM = 0
40  nDigitsSTGC = 0
41  nSDOMM = 0
42  nSDOSTGC = 0
43  nRDOMM = 0
44  nRDOSTGC = 0
45  nPRDMM = 0
46  nPRDSTGC = 0
47  for i in range(nEntries):
48  inputTree.GetEntry(i)
49  nRDOMM += inputTree.N_RDO_MM
50  nRDOSTGC += inputTree.N_RDO_sTGC
51 
52  if Options.checkPRD:
53  nPRDMM += inputTree.N_PRD_MM
54  nPRDSTGC += inputTree.N_PRD_sTGC
55 
56  if Options.checkHits:
57  nHitsMM += inputTree.Hits_MM_nHits
58  nHitsSTGC += inputTree.Hits_sTGC_nHits
59 
60  if Options.checkHits:
61  nDigitsMM += inputTree.N_Digits_MM
62  nDigitsSTGC += inputTree.N_Digits_sTGC
63 
64  if Options.checkSDO:
65  nSDOMM += inputTree.nSDO_MM
66  nSDOSTGC += inputTree.nSDO_sTGC
67 
68  if Options.checkHits and nHitsMM==0:
69  print ('ERROR: NSWValTree of file %s has 0 MM Hits'%Options.inputFile)
70  sys.exit(1)
71  elif Options.checkHits and nHitsSTGC==0:
72  print ('ERROR: NSWValTree of file %s has 0 STGC Hits'%Options.inputFile)
73  sys.exit(1)
74  elif Options.checkDigits and nDigitsMM==0:
75  print ('ERROR: NSWValTree of file %s has 0 MM Digits'%Options.inputFile)
76  sys.exit(1)
77  elif Options.checkDigits and nDigitsSTGC==0:
78  print ('ERROR: NSWValTree of file %s has 0 STGC Digits'%Options.inputFile)
79  sys.exit(1)
80  elif Options.checkSDO and nSDOMM==0:
81  print ('ERROR: NSWValTree of file %s has 0 MM SDOs'%Options.inputFile)
82  sys.exit(1)
83  elif Options.checkSDO and nSDOSTGC==0:
84  print ('ERROR: NSWValTree of file %s has 0 STGC SDOs'%Options.inputFile)
85  sys.exit(1)
86  elif nRDOMM==0:
87  print ('ERROR: NSWValTree of file %s has 0 MM RDOs'%Options.inputFile)
88  sys.exit(1)
89  elif nRDOSTGC==0:
90  print ('ERROR: NSWValTree of file %s has 0 STGC RDOs'%Options.inputFile)
91  sys.exit(1)
92  elif Options.checkPRD and nPRDMM==0:
93  print ('ERROR: NSWValTree of file %s has 0 MM PRDs'%Options.inputFile)
94  sys.exit(1)
95  elif Options.checkPRD and nPRDSTGC==0:
96  print ('ERROR: NSWValTree of file %s has 0 STGC PRDs'%Options.inputFile)
97  sys.exit(1)
98 
99  print ('INFO: All fine with file %s'%Options.inputFile)
100 
101  if Options.checkHits:
102  print ('INFO: Number of found MM hits:\t\t%i'%nHitsMM)
103  print ('INFO: Number of found STGC hits:\t%i'%nHitsSTGC)
104 
105  if Options.checkDigits:
106  print ('INFO: Number of found MM digits:\t%i'%nDigitsMM)
107  print ('INFO: Number of found STGC digits:\t%i'%nDigitsSTGC)
108 
109  if Options.checkSDO:
110  print ('INFO: Number of found MM SDOs:\t\t%i'%nSDOMM)
111  print ('INFO: Number of found STGC SDOs:\t%i'%nSDOSTGC)
112 
113  print ('INFO: Number of found MM RDOs:\t\t%i'%nRDOMM)
114  print ('INFO: Number of found STGC RDOs:\t%i'%nRDOSTGC)
115 
116  if Options.checkPRD:
117  print ('INFO: Number of found MM PRDs:\t\t%i'%nPRDMM)
118  print ('INFO: Number of found STGC PRDs:\t%i'%nPRDSTGC)
119 
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195