13 <output>overlayPlots.root</output>
14 <contact>marko.staric@ijs.si</contact>
15 <description>Runs BG overlay and makes validation histograms</description>
20from simulation
import add_simulation
23from ROOT
import Belle2
24from ROOT
import TH1F, TFile, TNamed, TNtuple
28b2.set_random_seed(123452)
34 Make validation histograms for BG overlay.
35 This validation assumes that all channels are active
36 (no masked strip, dead pixels, ...)
40 ''' Initialize the Module: book histograms and set descriptions and checks'''
44 self.
hist.append(TH1F(
'PXDDigits',
'PXDDigits (no data reduction)',
46 self.
hist.append(TH1F(
'SVDShaperDigits',
'SVDShaperDigits', 100, 0, 10000))
47 self.
hist.append(TH1F(
'SVDShaperDigitsZS5',
'ZS5 SVDShaperDigits', 100, 0, 8000))
48 self.
hist.append(TH1F(
'CDCHits',
'CDCHits above threshold', 100, 0, 6000))
49 self.
hist.append(TH1F(
'TOPDigits',
'TOPDigits', 100, 0, 2000))
50 self.
hist.append(TH1F(
'ARICHDigits',
'ARICHDigits', 100, 0, 300))
51 self.
hist.append(TH1F(
'ECLDigits',
'ECLDigits, m_Amp > 500 (roughly 25 MeV)',
53 self.
hist.append(TH1F(
'KLMDigits',
'KLMDigits', 150, 0, 150))
57 self.
hist2.append(TH1F(
'PXDL1Occupancy',
'PXD L1 Occupancy', 100, 0, 4))
58 self.
hist2.append(TH1F(
'PXDL2Occupancy',
'PXD L2 Occupancy', 100, 0, 4))
59 self.
hist2.append(TH1F(
'PXDOccupancy',
'PXD Occupancy', 100, 0, 4))
60 self.
hist2.append(TH1F(
'SVDOccupancy',
'SVD L3 Occupancy', 100, 0, 15))
61 self.
hist2.append(TH1F(
'CDCInnerHitRate',
'CDC Hit Rate per wire for the Inner layers', 100, 0, 1000))
62 self.
hist2.append(TH1F(
'CDCOuterHitRate',
'CDC Hit Rate per wire for the Outer layers', 100, 0, 1000))
63 self.
hist2.append(TH1F(
'CDCHitRate',
'CDC Hit Rate per wire', 100, 0, 1000))
64 self.
hist2.append(TH1F(
"TOPHitTime",
"TOP Hit Time Distribution; time [ns]", 300, -150, 150))
76 if len(sys.argv) == 3
and int(sys.argv[2]) == 1003:
77 self.
nPXDL2 = 250*768*2 * 2
89 self.
nCDCout = 160*6 + 192*6 + 224*6 + 256*6 + 288*6 + 320*6 + 352*6 + 384 * 6
97 if h.GetName() ==
'PXDOccupancy':
98 h.SetXTitle(
'PXD occupancy [%]')
102 'PXD L1+L2 Occupancy per event - no data reduction (with BG overlay only and no event generator)')
103 elif h.GetName() ==
'PXDL1Occupancy':
104 h.SetXTitle(
'PXD L1 occupancy [%]')
108 'PXD L1 Occupancy per event - no data reduction (with BG overlay only and no event generator)')
109 elif h.GetName() ==
'PXDL2Occupancy':
110 h.SetXTitle(
'PXD L2 occupancy [%]')
114 'PXD L2 Occupancy per event - no data reduction (with BG overlay only and no event generator)')
115 elif h.GetName() ==
'SVDOccupancy':
116 h.SetXTitle(
'SVD L3 ZS5 occupancy - average u,v [%]')
120 'SVD ZS5 L3 Occupancy per event average u,v (with BG overlay only and no event generator)')
121 elif h.GetName() ==
'CDCHitRate':
122 h.SetXTitle(
'CDC Hit Rate [kHz/wire]')
126 'CDC Hit Rate, averaged inner/outer wires (with BG overlay only and no event generator)')
127 elif h.GetName() ==
'CDCInnerHitRate':
128 h.SetXTitle(
'CDC Hit Rate for Inner Layers [kHz/wire]')
132 'CDC Hit Rate per wire, for the Inner layers (with BG overlay only and no event generator)')
133 elif h.GetName() ==
'CDCOuterHitRate':
134 h.SetXTitle(
'CDC Hit Rate for Outer Layers [kHz/wire]')
138 'CDC Hit Rate per wire, for the Outer layers (with BG overlay only and no event generator)')
140 h.SetXTitle(
'number of digits in event')
142 descr = TNamed(
'Description',
'Number of background ' + h.GetName() +
143 ' per event (with BG overlay only and no event generator)')
145 if h.GetName() ==
'PXDDigits':
147 elif h.GetName() ==
'SVDShaperDigits':
149 elif h.GetName() ==
'SVDShaperDigitsZS5':
151 elif h.GetName() ==
'CDCHits':
153 elif h.GetName() ==
'TOPHitTime':
156 h.SetYTitle(
'entries per bin')
157 h.GetListOfFunctions().Add(descr)
158 check = TNamed(
'Check',
'Distribution must agree with its reference')
159 h.GetListOfFunctions().Add(check)
160 contact = TNamed(
'Contact',
'marko.staric@ijs.si')
161 h.GetListOfFunctions().Add(contact)
162 options = TNamed(
'MetaOptions', option)
163 h.GetListOfFunctions().Add(options)
165 ntplvar =
"PXDL1_occupancy:PXDL2_occupancy:PXD_occupancy:SVDL3ZS5_occupancy"
166 ntplvar +=
":CDCInner_hitRate:CDCOuter_hitRate:CDC_hitRate:TOP_hitRate"
169 self.
ntpl = TNtuple(
"ntpl",
"Average Background Levels", (ntplvar))
172 ''' Event processor: fill histograms '''
176 if h.GetName() ==
'CDCHits':
178 if h.GetName() ==
'ECLDigits':
181 if digit.getAmp() > 500:
185 h.Fill(digits.getEntries())
189 self.
hist2[2].Fill(pxdDigits.getEntries()/self.
nPXD * 100)
192 for pxdDigit
in pxdDigits:
193 if pxdDigit.getSensorID().getLayerNumber() == 1:
203 for svdDigit
in svdDigits:
204 if svdDigit.getSensorID().getLayerNumber() == 3:
212 for cdcHit
in cdcHits:
213 if cdcHit.getISuperLayer() == 0
and cdcHit.getADCCount() > 15:
215 if cdcHit.getISuperLayer() != 0
and cdcHit.getADCCount() > 18:
220 self.
hist[3].Fill(nCDC_in+nCDC_out)
225 if TOPDigit.getHitQuality() != Belle2.TOPDigit.c_Good:
227 self.
hist2[7].Fill(TOPDigit.getTime())
236 """ Write histograms to file."""
238 TOPbg = self.
hist2[7].Integral(101, 150)/self.
nTOPev/50e-3/16/32
241 values = [self.
hist2[0].GetMean(), self.
hist2[1].GetMean(), self.
hist2[2].GetMean(),
242 self.
hist2[3].GetMean(), self.
hist2[4].GetMean(), self.
hist2[5].GetMean(),
243 self.
hist2[6].GetMean(), float(TOPbg)]
245 self.
ntpl.Fill(array.array(
"f", values),)
246 tfile = TFile(
'overlayPlots.root',
'recreate')
255if len(sys.argv) == 3:
256 b2.B2INFO(
'Using background samples for experiment ' + sys.argv[2] +
' at ' + sys.argv[1])
257 bg = glob.glob(str(sys.argv[1]) +
'/*.root')
258 exp = int(sys.argv[2])
259elif 'BELLE2_BACKGROUND_DIR' in os.environ:
260 bg = glob.glob(os.environ[
'BELLE2_BACKGROUND_DIR'] +
'/*.root')
262 b2.B2FATAL(
'No beam background samples found in folder ' +
263 os.environ[
'BELLE2_BACKGROUND_DIR'])
264 b2.B2INFO(
'Using background samples from ' + os.environ[
'BELLE2_BACKGROUND_DIR'])
266 b2.B2FATAL(
'variable BELLE2_BACKGROUND_DIR is not set')
269main = b2.create_path()
272eventinfosetter = b2.register_module(
'EventInfoSetter')
273eventinfosetter.param({
'evtNumList': [1000],
'runList': [1],
'expList': [exp]})
274main.add_module(eventinfosetter)
277add_simulation(main, bkgfiles=bg, bkgOverlay=
True, usePXDDataReduction=
False, forceSetPXDDataReduction=
True,
278 simulateT0jitter=
False)
282 'SVDZeroSuppressionEmulator',
284 ShaperDigits=
'SVDShaperDigits',
285 ShaperDigitsIN=
'SVDShaperDigitsZS5',
292main.add_module(
'Progress')
A (simplified) python wrapper for StoreArray.
int nSVDL3
number of L3 strips (u+v)
ntpl
ntuple to store background levels
minTOPTime
min TOP hit time
int nPXDL1
number of PXD pixels (L1)
int nPXDL2
number of PXD pixels (L2)
int nCDCin
number of inner CDC wires
float CDCITout
integration time of the outer CDC layers [ms]
list allh
merged list of all histograms
float CDCITIn
integration time of the inner CDC layers [ms]
list hist
list of digits histograms
int nCDCout
number of outer CDC wires
maxTOPTime
max TOP hit time
int nPXD
number of PXD pixels (L1+L2)
list hist2
list of occupancy-like histograms
int nTOPev
number of events