ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
AFPAlignDBCreate.AFPDBDict Class Reference
Collaboration diagram for AFPAlignDBCreate.AFPDBDict:

Public Member Functions

def __init__ (self, folderBlk)
 
def append (self, stationID, layerID=-1, alignType="None", shiftX=0.0, shiftY=0.0, shiftZ=0.0, alpha=0.0, beta=0.0, gamma=0.0)
 
def savePayload (self, folderBlk, fromRun=-2, fromLB=0)
 

Public Attributes

 mydict
 

Detailed Description

A class to create a dictionary, fill it with zeros in the constructor and to overwrite zeros later

Definition at line 58 of file AFPAlignDBCreate.py.

Constructor & Destructor Documentation

◆ __init__()

def AFPAlignDBCreate.AFPDBDict.__init__ (   self,
  folderBlk 
)

Definition at line 60 of file AFPAlignDBCreate.py.

60  def __init__ (self, folderBlk):
61  if(folderBlk.folderName=="/FWD/Onl/AFP/Align/Local"):
62  emptydict={"stationID":0, "layerID":-1, "shiftX":0.0, "shiftY":0.0, "shiftZ":0.0, "alpha":0.0, "beta":0.0, "gamma":0.0}
63  elif(folderBlk.folderName=="/FWD/Onl/AFP/Align/Global"):
64  emptydict={"stationID":0, "alignType":"None", "shiftX":0.0, "shiftY":0.0, "shiftZ":0.0, "alpha":0.0, "beta":0.0, "gamma":0.0}
65  else:
66  print ("unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
67  sys.exit(1)
68 
69  self.mydict={"author":"Petr Balek",
70  "version":"AFP_DB_v2",
71  "nchannels":16,
72  "data": dict.fromkeys(range(0, 16))}
73 
74  for i in range(0, 16):
75  self.mydict["data"][i]=copy.deepcopy(emptydict)
76  self.mydict["data"][i]["stationID"]=i//4
77  if(folderBlk.folderName=="/FWD/Onl/AFP/Align/Local"):
78  self.mydict["data"][i]["layerID"]=i%4
79  if(folderBlk.folderName=="/FWD/Onl/AFP/Align/Global"):
80  if i%4==0: self.mydict["data"][i]["alignType"]="tracker"
81  if i%4==1: self.mydict["data"][i]["alignType"]="beam"
82  if i%4==2: self.mydict["data"][i]["alignType"]="RP"
83  if i%4==3: self.mydict["data"][i]["alignType"]="correction"
84 

Member Function Documentation

◆ append()

def AFPAlignDBCreate.AFPDBDict.append (   self,
  stationID,
  layerID = -1,
  alignType = "None",
  shiftX = 0.0,
  shiftY = 0.0,
  shiftZ = 0.0,
  alpha = 0.0,
  beta = 0.0,
  gamma = 0.0 
)
A function that overwrites one slice of the alignment constants in the dictionary. Local constants have to have layerID defined, while alignType is undefined. Global constants have to have alignType defined (tracker/RP/beam/correction) and layerID undefined.

Definition at line 85 of file AFPAlignDBCreate.py.

85  def append(self, stationID, layerID=-1, alignType="None", shiftX=0.0, shiftY=0.0, shiftZ=0.0, alpha=0.0, beta=0.0, gamma=0.0):
86  """A function that overwrites one slice of the alignment constants in the dictionary. Local constants have to have layerID defined, while alignType is undefined. Global constants have to have alignType defined (tracker/RP/beam/correction) and layerID undefined."""
87 
88  # perform some simple check so basic mistakes are avoided
89  if(layerID==-1 and alignType=="None"):
90  print ("cannot save payload, got layerID=%d and alignType=%s; one of them has to be specified" % layerID, alignType)
91  sys.exit(1)
92  elif(layerID!=-1 and alignType!="None"):
93  print ("cannot save payload, got layerID=%d and alignType=%s; one of them should not be specified" % layerID, alignType)
94  sys.exit(1)
95 
96  if(stationID<0 or stationID>=4):
97  print ("cannot save payload, got stationID=%d, unknown" % stationID)
98  sys.exit(1)
99 
100  channel=0
101  # station 0 occupies channels 0-3, station 1 occupies channels 4-7, ..., and station 3 occupies channels 12-15
102  # if you are insterested in e.g. "beam" constants, look at channels 1, 5, 9, and 13
103  if(alignType!="None"):
104  channel=stationID*4
105  if(alignType=="tracker"):
106  channel+=0
107  elif(alignType=="beam"):
108  channel+=1
109  elif(alignType=="RP"):
110  channel+=2
111  elif(alignType=="correction"):
112  channel+=3
113  else:
114  print ("cannot save payload, got alignType=%s, unknown" % alignType)
115  sys.exit(1)
116 
117  # overwrite it
118  self.mydict["data"][channel]['alignType']=alignType
119 
120  # station 0 again occupies channels 0-3 etc.
121  if(layerID!=-1):
122  channel=stationID*4
123  if(0<=layerID and layerID<4):
124  channel+=layerID
125  else:
126  print ("cannot save payload, got layerID=%d, unknown" % layerID)
127  sys.exit(1)
128 
129  # overwrite it
130  self.mydict["data"][channel]['layerID']=layerID
131 
132  # overwrite it
133  mydict_helper=self.mydict["data"][channel]
134  mydict_helper['shiftX'], mydict_helper['shiftY'], mydict_helper['shiftZ'] = shiftX, shiftY, shiftZ
135  mydict_helper['alpha'], mydict_helper['beta'], mydict_helper['gamma'] = alpha, beta, gamma
136  mydict_helper['stationID']=stationID
137 
138 

◆ savePayload()

def AFPAlignDBCreate.AFPDBDict.savePayload (   self,
  folderBlk,
  fromRun = -2,
  fromLB = 0 
)
A function to transform the dictionary to JSON and save it in IOV from a given run and LB; upper limits are undefined and the maximum value (until beginning of a next entry) is used.

Definition at line 139 of file AFPAlignDBCreate.py.

139  def savePayload(self, folderBlk, fromRun=-2, fromLB=0):
140  """A function to transform the dictionary to JSON and save it in IOV from a given run and LB; upper limits are undefined and the maximum value (until beginning of a next entry) is used."""
141 
142  # perform some simple check so basic mistakes are avoided
143  if(fromRun<=0):
144  print ("cannot save payload, got fromRun=%d, it has to be positive" % fromRun)
145  sys.exit(1)
146 
147  # transform run nr. and LB to the right integers
148  since=runLBtoDB(run=fromRun,lb=fromLB)
149  until=cool.ValidityKeyMax
150 
151  # provided set of constants have to be the right one for the provided specification
152  payload=cool.Record(folderBlk.spec)
153  # transform dictionary to JSON
154  payload["data"]=json.dumps(self.mydict, indent = 1)
155  # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
156  folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
157 
158 

Member Data Documentation

◆ mydict

AFPAlignDBCreate.AFPDBDict.mydict

Definition at line 69 of file AFPAlignDBCreate.py.


The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
AFPAlignDBCreate.runLBtoDB
def runLBtoDB(run, lb)
Definition: AFPAlignDBCreate.py:35