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

Public Member Functions

def __init__ (self, folderBlk)
 
def append (self, stationID, trainID=-1, barID=-1, barWeight=1.0, barTimeOffset=0.0, timeGlobalOffset=0.0, timeOffset=(0., 0., 0., 0.), timeSlope=(0., 0., 0., 0.), trainEdge=(0., 0., 0., 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 53 of file AFPToFDBCreate.py.

Constructor & Destructor Documentation

◆ __init__()

def AFPToFDBCreate.AFPDBDict.__init__ (   self,
  folderBlk 
)

Definition at line 55 of file AFPToFDBCreate.py.

55  def __init__ (self, folderBlk):
56  if(folderBlk.folderName=="/FWD/Onl/AFP/ToFParameters/Local"):
57  emptydict={"stationID":0, "trainID":-1, "barID":-1, "barWeight":1.0, "barTimeOffset":0.0}
58  nchannels=32
59  elif(folderBlk.folderName=="/FWD/Onl/AFP/ToFParameters/Vertex"):
60  emptydict={"stationID":0, "timeGlobalOffset":0.0, "timeOffset":(0.0,0.0,0.0,0.0), "timeSlope":(0.0,0.0,0.0,0.0), "trainEdge":(0.0,0.0,0.0,0.0,0.0)}
61  nchannels=2
62  else:
63  print ("unknown folder %s, please edit \"AFPDBDict\" class constructor, exiting now" % folderBlk.folderName)
64  sys.exit(1)
65 
66  self.mydict={"author":"Petr Balek",
67  "version":"AFP_DB_v2",
68  "nchannels":nchannels,
69  "data": dict.fromkeys(range(0, nchannels))}
70 
71  for i in range(0, nchannels):
72  self.mydict["data"][i]=copy.deepcopy(emptydict)
73  if(folderBlk.folderName=="/FWD/Onl/AFP/ToFParameters/Local"):
74  self.mydict["data"][i]["stationID"]=(i//16)*3
75  self.mydict["data"][i]["trainID"]=(i%16)//4
76  self.mydict["data"][i]["barID"]=i%4
77  if(folderBlk.folderName=="/FWD/Onl/AFP/ToFParameters/Vertex"):
78  self.mydict["data"][i]["stationID"]=i*3
79 

Member Function Documentation

◆ append()

def AFPToFDBCreate.AFPDBDict.append (   self,
  stationID,
  trainID = -1,
  barID = -1,
  barWeight = 1.0,
  barTimeOffset = 0.0,
  timeGlobalOffset = 0.0,
  timeOffset = (0.,0.,0.,0.),
  timeSlope = (0.,0.,0.,0.),
  trainEdge = (0.,0.,0.,0.,0.) 
)
A function that overwrites one slice of the ToF parameters in the dictionary. Local ToF parameters have to have both trainID and barID defined, Vertex ToF parameters neither.

Definition at line 80 of file AFPToFDBCreate.py.

80  def append(self, stationID, trainID=-1, barID=-1, barWeight=1.0, barTimeOffset=0.0, timeGlobalOffset=0.0, timeOffset=(0.,0.,0.,0.), timeSlope=(0.,0.,0.,0.), trainEdge=(0.,0.,0.,0.,0.)):
81  """A function that overwrites one slice of the ToF parameters in the dictionary. Local ToF parameters have to have both trainID and barID defined, Vertex ToF parameters neither."""
82 
83  # perform some simple check so basic mistakes are avoided
84  if(stationID!=0 and stationID!=3):
85  print ("cannot save payload, got stationID=%d, unknown" % stationID)
86  sys.exit(1)
87 
88  trainValid=True if 0<=trainID and trainID<4 else False
89  barValid = True if 0<=barID and barID<4 else False
90  if(trainValid!=barValid):
91  # a.k.a. "trainValid xor barValid"
92  print ("cannot save payload, got trainID=%d, barID=%d" % (trainID,barID))
93  sys.exit(1)
94 
95  if trainValid:
96  # local ToF parameters
97  # station 0 occupies channels 0-16, station 3 occupies channels 17-32
98  # train 0 occupies channels 0-3 / 17-20, train 1 occupies channels 4-7 / 21-24, ...
99  # bar 0 occupies the first channel of the train, bar 1 occupies the second channel of the train, ...
100  channel=(stationID//3)*16+trainID*4+barID
101 
102  # overwrite it
103  mydict_helper=self.mydict["data"][channel]
104  mydict_helper['stationID'], mydict_helper['trainID'], mydict_helper['barID'] = stationID, trainID, barID
105  mydict_helper['barWeight'], mydict_helper['barTimeOffset'] = barWeight, barTimeOffset
106  else:
107  # vertex ToF parameters
108  # station 0 occupies channel 0, station 3 occupies channels 1
109  channel=stationID//3
110 
111  # overwrite it
112  mydict_helper=self.mydict["data"][channel]
113  mydict_helper['stationID']=stationID
114  mydict_helper['timeGlobalOffset'], mydict_helper['timeOffset'] = timeGlobalOffset, timeOffset
115  mydict_helper['timeSlope'], mydict_helper['trainEdge'] = timeSlope, trainEdge
116 
117 

◆ savePayload()

def AFPToFDBCreate.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 118 of file AFPToFDBCreate.py.

118  def savePayload(self, folderBlk, fromRun=-2, fromLB=0):
119  """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."""
120 
121  # perform some simple check so basic mistakes are avoided
122  if(fromRun<=0):
123  print ("cannot save payload, got fromRun=%d, it has to be positive" % fromRun)
124  sys.exit(1)
125 
126  # transform run nr. and LB to the right integers
127  since=runLBtoDB(run=fromRun,lb=fromLB)
128  until=cool.ValidityKeyMax
129 
130  # provided set of constants have to be the right one for the provided specification
131  payload=cool.Record(folderBlk.spec)
132  # transform dictionary to JSON
133  payload["data"]=json.dumps(self.mydict, indent = 1)
134  # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
135  folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
136 
137 

Member Data Documentation

◆ mydict

AFPToFDBCreate.AFPDBDict.mydict

Definition at line 66 of file AFPToFDBCreate.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
AFPToFDBCreate.runLBtoDB
def runLBtoDB(run, lb)
Definition: AFPToFDBCreate.py:30