5 from __future__
import print_function
6 import os, sys, ROOT, argparse
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()
17 ROOT.gROOT.SetBatch(
True)
19 if not os.path.exists(Options.inputFile):
20 print (
'ERROR: File %s does not exist'%Options.inputFile)
23 inputFile = ROOT.TFile(Options.inputFile,
"READ")
25 print (
'ERROR: Failed to open file %s'%Options.inputFile)
27 inputTree = inputFile.Get(
"NSWValTree")
29 print (
'ERROR: NSWValTree does not exist in file %s'%Options.inputFile)
32 nEntries = inputTree.GetEntries()
34 print (
'ERROR: NSWValTree of file %s has 0 entries'%Options.inputFile)
47 for i
in range(nEntries):
49 nRDOMM += inputTree.N_RDO_MM
50 nRDOSTGC += inputTree.N_RDO_sTGC
53 nPRDMM += inputTree.N_PRD_MM
54 nPRDSTGC += inputTree.N_PRD_sTGC
57 nHitsMM += inputTree.Hits_MM_nHits
58 nHitsSTGC += inputTree.Hits_sTGC_nHits
61 nDigitsMM += inputTree.N_Digits_MM
62 nDigitsSTGC += inputTree.N_Digits_sTGC
65 nSDOMM += inputTree.nSDO_MM
66 nSDOSTGC += inputTree.nSDO_sTGC
68 if Options.checkHits
and nHitsMM==0:
69 print (
'ERROR: NSWValTree of file %s has 0 MM Hits'%Options.inputFile)
71 elif Options.checkHits
and nHitsSTGC==0:
72 print (
'ERROR: NSWValTree of file %s has 0 STGC Hits'%Options.inputFile)
74 elif Options.checkDigits
and nDigitsMM==0:
75 print (
'ERROR: NSWValTree of file %s has 0 MM Digits'%Options.inputFile)
77 elif Options.checkDigits
and nDigitsSTGC==0:
78 print (
'ERROR: NSWValTree of file %s has 0 STGC Digits'%Options.inputFile)
80 elif Options.checkSDO
and nSDOMM==0:
81 print (
'ERROR: NSWValTree of file %s has 0 MM SDOs'%Options.inputFile)
83 elif Options.checkSDO
and nSDOSTGC==0:
84 print (
'ERROR: NSWValTree of file %s has 0 STGC SDOs'%Options.inputFile)
87 print (
'ERROR: NSWValTree of file %s has 0 MM RDOs'%Options.inputFile)
90 print (
'ERROR: NSWValTree of file %s has 0 STGC RDOs'%Options.inputFile)
92 elif Options.checkPRD
and nPRDMM==0:
93 print (
'ERROR: NSWValTree of file %s has 0 MM PRDs'%Options.inputFile)
95 elif Options.checkPRD
and nPRDSTGC==0:
96 print (
'ERROR: NSWValTree of file %s has 0 STGC PRDs'%Options.inputFile)
99 print (
'INFO: All fine with file %s'%Options.inputFile)
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)
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)
110 print (
'INFO: Number of found MM SDOs:\t\t%i'%nSDOMM)
111 print (
'INFO: Number of found STGC SDOs:\t%i'%nSDOSTGC)
113 print (
'INFO: Number of found MM RDOs:\t\t%i'%nRDOMM)
114 print (
'INFO: Number of found STGC RDOs:\t%i'%nRDOSTGC)
117 print (
'INFO: Number of found MM PRDs:\t\t%i'%nPRDMM)
118 print (
'INFO: Number of found STGC PRDs:\t%i'%nPRDSTGC)