25 from ROOT
import Belle2
29 def prepare_svd_overlay(path, inputFiles, outputFileTag="overlay"):
31 This function reads a list of input files and prepare them to be used in overlay_svd_data
32 @param inputFiles: list of input files to be processed
33 @param outputFileTag: tag added just before the .root
36 for inputfile
in inputFiles:
38 basf2.conditions.reset()
39 basf2.conditions.override_globaltags()
40 basf2.conditions.globaltags = [
'svd_basic',
"online"]
42 if(str(outputFileTag) ==
"ZS3"):
43 splittext = inputfile.split(
".root")
45 splittext = inputfile.split(
"_ZS3.root")
46 outputfile = splittext[0]+
"_"+str(outputFileTag)+
".root"
48 main.add_module(
"RootInput", inputFileNames=inputfile)
49 if(str(outputFileTag) ==
"ZS3"):
50 main.add_module(
"SVDUnpacker", svdShaperDigitListName=
"SVDShaperDigitsZS3")
53 if (str(outputFileTag) ==
"overlayZS5"):
56 if not (str(outputFileTag) ==
"ZS3"):
57 main.add_module(
"SVDZeroSuppressionEmulator",
59 ShaperDigits=
'SVDShaperDigitsZS3',
60 ShaperDigitsIN=
'SVDShaperDigits',
62 main.add_module(
"RootOutput", branchNames=[
"SVDEventInfo",
"SVDShaperDigitsZS3"], outputFileName=outputfile)
64 main.add_module(
"RootOutput", branchNames=[
"SVDShaperDigits"], outputFileName=outputfile)
69 def overlay_svd_data(path, datatype="randomTrigger", overlayfiles=""):
71 This function overlay events from data to the standard simulation
72 @param datatype: must be chosen among {xTalk, cosmics,randomTrigger, randomTriggerZS5, user-defined}
73 @param overlayfiles: if the datatype is user-defiled, the user can specify rootfiles to be overlaied to simulation
76 if not (str(datatype) ==
"xTalk" or str(datatype) ==
"cosmics" or str(datatype) ==
77 "randomTrigger" or str(datatype) ==
"randomTriggerZS5" or str(datatype) ==
"user-defined"):
78 print(
"ERROR in SVDOverlay: the specified datatype ("+str(datatype) +
79 ") is not recognized, choose among: xTalk, cosmics or user-defined")
82 overlayDir =
"/gpfs/fs02/belle2/group/detector/SVD/overlayFiles/"
84 if str(datatype) ==
"xTalk" or str(datatype) ==
"cosmics" or str(datatype) ==
"randomTrigger":
85 overlayfiles = str(overlayDir)+str(datatype)+
"/*_overlay.root"
87 if str(datatype) ==
"randomTriggerZS5":
88 overlayfiles = str(overlayDir)+
"randomTrigger/*_overlayZS5.root"
90 print(
" ** SVD OVERLAY UTIL CALLED **")
91 print(
" -> overlaying the following files to simulation: ")
92 print(str(overlayfiles))
94 bkginput = register_module(
'BGOverlayInput')
95 bkginput.set_name(
'BGOverlayInput_SVDOverlay')
96 bkginput.param(
'bkgInfoName',
'BackgroundInfoSVDOverlay')
97 bkginput.param(
'extensionName',
"_SVDOverlay")
98 bkginput.param(
'inputFileNames', overlayfiles)
99 path.add_module(bkginput)
101 bkgexecutor = register_module(
'BGOverlayExecutor')
102 bkgexecutor.set_name(
'BGOverlayExecutor_SVDOverlay')
103 bkgexecutor.param(
'bkgInfoName',
'BackgroundInfoSVDOverlay')
104 path.add_module(bkgexecutor)
106 path.add_module(
"SVDShaperDigitSorter")