ATLAS Offline Software
Functions
python.addL1 Namespace Reference

Functions

def modify (event)
 
def CTPreco (input_file, output_file)
 

Function Documentation

◆ CTPreco()

def python.addL1.CTPreco (   input_file,
  output_file 
)

Definition at line 108 of file addL1.py.

108 def CTPreco(input_file,output_file):
109  input = eformat.istream([input_file])
110  dr=EventStorage.pickDataReader(input_file)
111  output = eformat.ostream(core_name="subset",
112  run_number=dr.runNumber(),
113  trigger_type=dr.triggerType(),
114  detector_mask=dr.detectorMask(),
115  beam_type=dr.beamType(),
116  beam_energy=dr.beamEnergy())
117  for event in input:
118  new_event = modify(event)
119  if not new_event:
120  continue
121  else:
122  output.write(new_event)
123  tmp_file_name = output.last_filename()
124  del output
125  os.rename(tmp_file_name,output_file)
126 
127 
128 

◆ modify()

def python.addL1.modify (   event)
Fills in the L1R from the most appropriate source (L1/ROS or Dummy).

Definition at line 28 of file addL1.py.

28 def modify(event):
29  """Fills in the L1R from the most appropriate source (L1/ROS or Dummy)."""
30 
31  map=[[eformat.helper.SubDetector.TDAQ_CTP,0,1],
32  [eformat.helper.SubDetector.TDAQ_MUON_CTP_INTERFACE,0,1],
33  [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,136,168],
34  [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,137,169],
35  [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,138,170],
36  [eformat.helper.SubDetector.TDAQ_CALO_CLUSTER_PROC_ROI,139,171],
37  [eformat.helper.SubDetector.TDAQ_CALO_JET_PROC_ROI,140,172],
38  [eformat.helper.SubDetector.TDAQ_CALO_JET_PROC_ROI,141,173]]
39 
40  DaqRobs=[None]*len(map)
41  L2Robs=[None]*len(map)
42 
43 
44  for rob in event:
45  cnt=0
46  for match in map:
47  if rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[1]):
48  DaqRobs[cnt]=rob
49  elif rob.source_id()==eformat.helper.SourceIdentifier(match[0],match[2]):
50  L2Robs[cnt]=rob
51  cnt+=1
52 
53  # There are no CTP ROBs, event can not be recovered and should be skipped
54  if (not DaqRobs[0]) and (not L2Robs[0]):
55  logging.warning(' Plugin "addL1": No DAQ CTP fragment. Event can not be recovered. Event will be skipped. L1 id = %d, Global id = %d ', event.lvl1_id(), event.global_id())
56  return False
57 
58  # Workaround for corrupted events
59  new_event=eformat.write.FullEventFragment()
60  new_event.copy_header(event)
61  for rob in event:
62  new_event.append_unchecked(rob)
63 
64  for idx in range(len(map)):
65  if L2Robs[idx]:
66  pass
67  elif DaqRobs[idx]:
68 
69  rob=eformat.write.ROBFragment(DaqRobs[idx])
70  rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
71 
72  daq_data = [r for r in rob.rod_data()]
73 
74  if idx==0: #CTP DAQ ROD
75  # offset to triggered bunch trigger words
76  offset = CTPdataformat.NumberTimeWords + CTPfragment.lvl1AcceptBunch(rob)*CTPdataformat.DAQwordsPerBunch
77  # Copy leading words (once per fragment)
78  data = daq_data[:CTPdataformat.NumberTimeWords]
79  # Copy per bunch words
80  data += daq_data[offset : offset+CTPdataformat.DAQwordsPerBunch]
81  # Copy extra payload
82  data += daq_data[-CTPfragment.numberExtraPayloadWords(rob):]
83  rob.rod_data(data)
84 
85  elif idx==1: #MuCTPi DAQ ROB
86  data=[]
87  if len(DaqRobs[idx].rod_data()) > 0:
88  muctpBC=(DaqRobs[idx].rod_data()[0]>>18)&7
89  for word in DaqRobs[idx].rod_data()[1:]:
90  if (word>>14)&7==muctpBC and (word>>26)&1:
91  data+=[(word&0x3fff)|(((word>>17)&0x1ff)<<14)]
92 
93  if len(data)==0:
94  rob=eformat.write.ROBFragment()
95  rob.copy_header(DaqRobs[idx])
96  rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
97  else:
98  rob.rod_data(data)
99 
100  new_event.append(rob)
101  else:
102  rob=eformat.write.ROBFragment()
103  rob.source_id(eformat.helper.SourceIdentifier(map[idx][0],map[idx][2]))
104  new_event.append(rob)
105 
106  return new_event.readonly()
107 
python.addL1.CTPreco
def CTPreco(input_file, output_file)
Definition: addL1.py:108
python.addL1.modify
def modify(event)
Definition: addL1.py:28
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195