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

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 51 of file AFPToFMCDBCreate.py.

Constructor & Destructor Documentation

◆ __init__()

def AFPToFMCDBCreate.AFPDBDict.__init__ (   self,
  folderBlk 
)

Definition at line 53 of file AFPToFMCDBCreate.py.

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

Member Function Documentation

◆ append()

def AFPToFMCDBCreate.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 78 of file AFPToFMCDBCreate.py.

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

◆ savePayload()

def AFPToFMCDBCreate.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) is used.

Definition at line 116 of file AFPToFMCDBCreate.py.

116  def savePayload(self, folderBlk):
117  """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) is used."""
118 
119  # transform run nr. and LB to the right integers
120  since=runLBtoDB(0,0)
121  until=cool.ValidityKeyMax
122 
123  # provided set of constants have to be the right one for the provided specification
124  payload=cool.Record(folderBlk.spec)
125  # transform dictionary to JSON
126  payload["data"]=json.dumps(self.mydict, indent = 1)
127  # save everything (that "0" stands for channel nr. 0, there is only 1 real channel in the DB)
128  folderBlk.folder.storeObject(since,until,payload,0,folderBlk.tag)
129 
130 

Member Data Documentation

◆ mydict

AFPToFMCDBCreate.AFPDBDict.mydict

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