ATLAS Offline Software
dumpNswErrorDb.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 import logging
3 import json
4 from itertools import product
6  from argparse import ArgumentParser
7 
8  parser = ArgumentParser()
9  parser.add_argument("--outFilePreFix", help="Output JSON file",
10  default="NswUncerts")
11  parser.add_argument("--scaleError", help="Scale the uncertainties of the MM",type=float, default = 5.)
12  parser.add_argument("--addErrorMMClusterTime", help="add fixed error to the uncertainties of the MM",type=float, default = 0.)
13  return parser
14 
15 if __name__ == "__main__":
17 
18  dbEntriesMMASide = []
19  dbEntriesMMCSide = []
20 
21  for stationName, stationEta, stationPhi, multilayer, gasGap, author in product([ "MMS", "MML"], [-2,-1,1,2], range(1,9), [1,2],range(1,5), [0,65]):
22  constant = args.scaleError * 0.0815
23  linear = args.scaleError * 0.0
24  quad = args.scaleError * 1.56
25 
26  minStrip = 1
27  maxStrip = (5 if abs(stationEta)==1 else 3)*1024
28 
29  calibEntry = dict({"station": stationName, "eta":stationEta, "phi": stationPhi, "multilayer": multilayer, "gasGap": gasGap, "minStrip": minStrip,"maxStrip": maxStrip, "modelName":"tanThetaPolynomial" ,"modelPars": [constant, linear, quad], "clusterAuthor": author})
30  logging.debug(calibEntry)
31  if(stationEta<0):
32  dbEntriesMMCSide.append(calibEntry)
33  else:
34  dbEntriesMMASide.append(calibEntry)
35 
36 
37  for stationName, stationEta, stationPhi, multilayer, gasGap, author in product([ "MMS", "MML"], [-2,-1,1,2], range(1,9), [1,2],range(1,5), [66]):
38  constant = args.scaleError* 0.0615 + args.addErrorMMClusterTime
39  linear = args.scaleError * 0
40  quad = args.scaleError * 0.275
41 
42  minStrip = 1
43  maxStrip = (5 if abs(stationEta)==1 else 3)*1024
44 
45  calibEntry = dict({"station": stationName, "eta":stationEta, "phi": stationPhi, "multilayer": multilayer, "gasGap": gasGap, "minStrip": minStrip,"maxStrip": maxStrip, "modelName":"tanThetaPolynomial" ,"modelPars": [constant, linear, quad], "clusterAuthor": author})
46  logging.debug(calibEntry)
47  if(stationEta<0):
48  dbEntriesMMCSide.append(calibEntry)
49  else:
50  dbEntriesMMCSide.append(calibEntry)
51 
52 
53  dbEntriessTGCASide = []
54  dbEntriessTGCCSide = []
55  maxStripStgc = dict({"QL1": 408 ,"QL2": 366,"QL3": 353,"QS1": 406, "QS2": 365, "QS3": 307})
56  for stationName, stationEta, stationPhi, multilayer, gasGap in product([ "STL", "STS"], [-3, -2,-1,1,2,3], range(1,9), [1,2],range(1,5)):
57  chamberKey = f"Q{stationName[2]}{abs(stationEta)}"
58  minStrip = 1
59  maxStrip = maxStripStgc[chamberKey]
60 
61  const = args.scaleError * 0.151
62  linear = args.scaleError * 0
63  quad = args.scaleError * 0.201
64 
65  author = 3 # centroid
66  calibEntry = dict({"station": stationName, "eta":stationEta, "phi": stationPhi, "multilayer": multilayer, "gasGap": gasGap, "minStrip": minStrip,"maxStrip": maxStrip, "modelName":"tanThetaPolynomial" ,"modelPars": [const, linear, quad], "clusterAuthor": author})
67  logging.debug(calibEntry)
68  if(stationEta<0):
69  dbEntriessTGCCSide.append(calibEntry)
70  else:
71  dbEntriessTGCASide.append(calibEntry)
72 
73  author = 4 #caruana
74  const = args.scaleError * 0.175
75  linear = args.scaleError * 0
76  quad = args.scaleError * 0.201
77  calibEntry = dict({"station": stationName, "eta":stationEta, "phi": stationPhi, "multilayer": multilayer, "gasGap": gasGap, "minStrip": minStrip,"maxStrip": maxStrip, "modelName": "tanThetaPolynomial" ,"modelPars": [const, linear, quad], "clusterAuthor": author})
78  logging.debug(calibEntry)
79  if(stationEta<0):
80  dbEntriessTGCCSide.append(calibEntry)
81  else:
82  dbEntriessTGCASide.append(calibEntry)
83 
84 
85 
86  outFileName = f"{args.outFilePreFix}_scale_x{args.scaleError}_mmConstOffset_{args.addErrorMMClusterTime}.json"
87  with open(outFileName,'w') as outStream:
88  json.dump(dbEntriesMMASide + dbEntriesMMCSide +dbEntriessTGCASide + dbEntriessTGCCSide, outStream)
89 
90 
91  outFileName = f"{args.outFilePreFix}_MMonly_ASide_scale_x{args.scaleError}_mmConstOffset_{args.addErrorMMClusterTime}.json"
92  with open(outFileName,'w') as outStream:
93  json.dump(dbEntriesMMASide, outStream)
94 
95  outFileName = f"{args.outFilePreFix}_MMonly_CSide_scale_x{args.scaleError}_mmConstOffset_{args.addErrorMMClusterTime}.json"
96  with open(outFileName,'w') as outStream:
97  json.dump(dbEntriesMMCSide, outStream)
98 
99  outFileName = f"{args.outFilePreFix}_sTGConly_ASide_scale_x{args.scaleError}.json"
100  with open(outFileName,'w') as outStream:
101  json.dump(dbEntriessTGCASide, outStream)
102 
103  outFileName = f"{args.outFilePreFix}_sTGConly_CSide_scale_x{args.scaleError}.json"
104  with open(outFileName,'w') as outStream:
105  json.dump(dbEntriessTGCCSide, outStream)
dumpNswErrorDb.setupArgParser
def setupArgParser()
Definition: dumpNswErrorDb.py:5
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Trk::open
@ open
Definition: BinningType.h:40
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
confTool.parse_args
def parse_args()
Definition: confTool.py:35