ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
AFPAlignMCDBCreate.AFPDBDict Class Reference
Collaboration diagram for AFPAlignMCDBCreate.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)
 

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 59 of file AFPAlignMCDBCreate.py.

Constructor & Destructor Documentation

◆ __init__()

def AFPAlignMCDBCreate.AFPDBDict.__init__ (   self,
  folderBlk 
)

Definition at line 61 of file AFPAlignMCDBCreate.py.

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

Member Function Documentation

◆ append()

def AFPAlignMCDBCreate.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 86 of file AFPAlignMCDBCreate.py.

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

◆ savePayload()

def AFPAlignMCDBCreate.AFPDBDict.savePayload (   self,
  folderBlk 
)
A function to transform the dictionary to JSON and save it in IOV from 0 to infinity; technically, upper limits are undefined and the maximum value (until beginning of a next entry) would be used.

Definition at line 140 of file AFPAlignMCDBCreate.py.

140  def savePayload(self, folderBlk):
141  """A function to transform the dictionary to JSON and save it in IOV from 0 to infinity; technically, upper limits are undefined and the maximum value (until beginning of a next entry) would be used."""
142 
143  # transform run nr. and LB to the right integers
144  since=runLBtoDB(0,0)
145  until=cool.ValidityKeyMax
146 
147  # provided set of constants have to be the right one for the provided specification
148  payload=cool.Record(folderBlk.spec)
149  # transform dictionary to JSON
150  payload["data"]=json.dumps(self.mydict, indent = 1)
151  # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
152  folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
153 
154 

Member Data Documentation

◆ mydict

AFPAlignMCDBCreate.AFPDBDict.mydict

Definition at line 70 of file AFPAlignMCDBCreate.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
AFPAlignMCDBCreate.runLBtoDB
def runLBtoDB(run, lb)
Definition: AFPAlignMCDBCreate.py:36
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567