68 def calcFromList(self,triggername,lblist):
69 """ Calculate the integrated luminosity for a list of LBs, returning
70 a list of (run,lb,lumiResult,evts) object tuples
71 (note, this is the only difference in functionality between coolLumiCalc and coolLumiResultsGetter)
75 triggerlevel=self.triggerLevel(triggername)
77 raise Exception(
"Please use a L1 trigger for this tool.")
84 folderLBCOUNTL1=self.cooldb.getFolder(
'/TRIGGER/LUMI/LVL1COUNTERS')
85 folderL1PRESCALE=self.cooldb.getFolder(
'/TRIGGER/LVL1/Prescales')
86 folderL1LB=self.cooldb.getFolder(
'/TRIGGER/LUMI/LBLB')
90 runstat,chainnums,hltprescale=self._getChains(lbinfo.run,triggername,triggerlevel)
92 print (
"L1 chain number", chainnums[0])
94 since,until=lbinfo.IOVRange()
96 if (self.detstatus!=
""):
98 print (lbinfo,
": Applying detector status cuts: %s" % self.detstatus)
99 gooddetstatus=
statusCutsToRange(self.detstatusdb,
'/GLOBAL/DETSTATUS/LBSUMM',since,until,self.detstatustag,self.detstatus)
101 gooddetstatus=RangeList(since,until)
103 if (self.loglevel>1):
104 print (
"LumiB L1-Acc L1-pre LiveTime MeanInts IntL/ub-1")
106 l1precache=IOVCache()
107 itr=folderL1PRESCALE.browseObjects(since,until-1,cool.ChannelSelection(chainnums[0]))
108 while (itr.goToNext()):
110 l1precache.add(obj.since(),obj.until(),obj.payload()[
'Lvl1Prescale'])
113 lumicache=self.getLumiMuCache(since,until)
117 l1countitr=folderLBCOUNTL1.browseObjects(since,until-1,cool.ChannelSelection(chainnums[0]))
118 l1lbiter=folderL1LB.browseObjects(since,until-1,cool.ChannelSelection(0))
119 while l1countitr.goToNext():
121 l1countobj=l1countitr.currentRef()
122 lb=l1countobj.since() & 0xFFFFFFFF
124 lblbobj=l1lbiter.currentRef()
125 if (lblbobj.since()!=l1countobj.since()):
126 raise Exception(
"L1 counter/lumiblock synchronisation error. Cannot get length of Lumiblocks!")
127 l1payload=l1countobj.payload()
128 lblbpayload =lblbobj.payload()
129 l1acc=l1payload[
'L1Accept']
130 l1dt=(lblbpayload[
'EndTime']-lblbpayload[
'StartTime'])*1.0e-09
131 l1tstart=lblbpayload[
'StartTime']
134 if (l1payload[
'AfterPrescale']>0):
135 livefrac=
float(l1payload[
'L1Accept'])/
float(l1payload[
'AfterPrescale'])
139 if (len(gooddetstatus.getAllowedRanges(l1countobj.since(),l1countobj.until()))>0):
145 (lumi,evtsbx)=lumicache.find(l1countobj.since())
147 if (self.lumimethod !=
'EXTERNAL'):
148 print (
"WARNING: No payload in", self.lumifoldername,
"for run", lbinfo.run,
"[", lb,
"]!")
152 l1prescale=l1precache.find(l1countobj.since())
153 if (lumi
is not None and l1prescale
is not None):
157 livetime=livefrac*l1dt
159 intlumi=(lumi*livetime)/(1.0 * l1prescale)
160 if not (intlumi >= 0):
161 print (
"WARNING:",lbinfo.run,
"[",lb,
"]: bad lumi, prescale or livetime found:(IL,LV):", lumi,livetime)
163 intlumi=(lumi*livetime)
164 if not (intlumi >= 0):
165 print (
"WARNING:",lbinfo.run,
"[",lb,
"]: bad lumi or livetime found:(IL,LV)", lumi,livetime)
167 if (self.loglevel>1):
168 print (
"%5i %7i %8i %8.2f %8.7f %10.1f" % (lb,l1acc,l1prescale,livetime,evtsbx,intlumi))
169 elif (lumi
is not None):
170 intlumi=(lumi*livetime)
171 if (self.loglevel>1):
172 print (
"%5i %7i %8i %8s %8.7f %10.if <missing prescale>" %(lb,l1acc,
"??",livetime,evtsbx,intlumi))
173 if not (intlumi >= 0):
174 print (
"WARNING:",lbinfo.run,
"[",lb,
"]: bad lumi or livetime found:(IL,LV)", lumi,livetime)
177 if (self.loglevel>1):
178 print (
"%5i %7i %8i %8s %8s %10s <missing prescale>" %(lb,l1acc,
"??",livetime,
"??",
"??"))
179 lumiResults.append( (lbinfo.run,
int(lb), lumiResult(intlumi,l1acc,0,0,livetime,1,0), evtsbx, l1tstart ) )
191 print (
"WARNING: Trigger not defined for run",lbinfo.run)
193 if (self.loglevel>0):
194 print (
"Running total after %24s:" % lbinfo,
" %7i events; %8.2f seconds; %10.1f (nb^-1)" % (totalacc[0],totaltime,totalL))