11from geometry
import is_detector_present
15lightPropSpeed = 12.9925
18run_range = {
'201607': [787, 833],
19 '201608a': [885, 896],
20 '201608b': [917, 924],
22 '201702': [1601, 9999],
23 'gcr2017': [3058, 100000],
24 'phase2': [0, 100000],
25 'phase3': [0, 100000],
29triggerSize = {
'201607': [20.0, 6.0, 10.0],
30 '201608a': [100.0, 8.0, 10.0],
31 '201608b': [100.0, 8.0, 10.0],
32 '201609': [100.0, 8.0, 10.0],
33 '201702': [100.0, 8.0, 10.0],
34 'gcr2017': [100, 0, 8.0, 10.0],
35 'phase2': [100, 0, 8.0, 10.0],
36 'phase3': [100, 0, 8.0, 10.0],
37 'normal': [100.0, 8.0, 10.0]
40triggerPosition = {
'201607': [0.3744, 0.0, -1.284],
41 '201608a': [-1.87, -1.25, 18.7],
42 '201608b': [-1.87, -1.25, 11.0],
43 '201609': [0, 0, 11.0],
44 '201702': [0., -1.5, 21.0],
45 'gcr2017': [0.0, 0.0, 0.0],
46 'phase2': [0.0, 0.0, 0.0],
47 'phase3': [0.0, 0.0, 0.0],
48 'normal': [0.0, 0.0, 0.0]
52triggerPlaneDirection = {
'201607': [1, -1, 0],
64pmtPosition = {
'201607': [0, 0, 0],
65 '201608a': [-1.87, 0, -25.0],
66 '201608b': [-1.87, 0, -42.0],
67 '201609': [0, 0, -42.0],
68 '201702': [0., -1.5, -31.0],
69 'gcr2017': [0.0, 0.0, -50.0],
70 'phase2': [0.0, 0.0, -50.0],
71 'phase3': [0.0, 0.0, -50.0],
72 'normal': [0, 0, -50.0]
76globalPhiRotation = {
'201607': 1.875,
87lengthOfCounter = 100.0
90normTriggerPlaneDirection = []
96def set_cdc_cr_parameters(period):
98 global lengthOfCounter
101 global normTriggerPlaneDirection
104 global cosmics_period
106 lengthOfCounter = triggerSize[period][0]
107 widthOfCounter = triggerSize[period][1]
108 triggerPos = triggerPosition[period]
109 normTriggerPlaneDirection = triggerPlaneDirection[period]
110 readOutPos = pmtPosition[period]
111 globalPhi = globalPhiRotation[period]
112 cosmics_period = period
115def add_cdc_cr_simulation(path,
121 generate_2nd_cdc_hits=False,
124 Add CDC CR simulation.
131 bkginput = b2.register_module(
'BGOverlayInput')
132 bkginput.param(
'inputFileNames', bkgfiles)
133 path.add_module(bkginput)
135 bkgmixer = b2.register_module(
'BeamBkgMixer')
136 bkgmixer.param(
'backgroundFiles', bkgfiles)
138 bkgmixer.param(
'components', bkgcomponents)
141 bkgmixer.param(
'components', components)
142 bkgmixer.param(
'overallScaleFactor', bkgscale)
143 path.add_module(bkgmixer)
146 if 'Gearbox' not in path:
147 gearbox = b2.register_module(
'Gearbox')
148 path.add_module(gearbox)
151 if 'Geometry' not in path:
152 geometry = b2.register_module(
'Geometry', useDB=
True)
154 geometry.param(
'components', components)
155 path.add_module(geometry)
158 if 'FullSim' not in path:
159 g4sim = b2.register_module(
'FullSim',
160 ProductionCut=1000000.)
161 path.add_module(g4sim)
166 if is_detector_present(
"CDC", components):
167 cdc_digitizer = b2.register_module(
'CDCDigitizer')
168 cdc_digitizer.param(
"Output2ndHit", generate_2nd_cdc_hits)
169 path.add_module(cdc_digitizer)
172 if is_detector_present(
"ECL", components):
173 ecl_digitizer = b2.register_module(
'ECLDigitizer')
174 if bkgfiles
is not None:
175 ecl_digitizer.param(
'Background', 1)
176 path.add_module(ecl_digitizer)
179def add_cdc_cr_reconstruction(path, eventTimingExtraction=True,
183 Add CDC CR reconstruction
187 add_cdc_cr_track_finding(path, merge_tracks=
False)
190 path.add_module(
"SetupGenfitExtrapolation")
193 path.add_module(
"PlaneTriggerTrackTimeEstimator",
194 pdgCodeToUseForEstimation=13,
195 triggerPlanePosition=triggerPos,
196 triggerPlaneDirection=normTriggerPlaneDirection,
197 useFittedInformation=
False)
200 path.add_module(
"DAFRecoFitter",
202 pdgCodesToUseForFitting=13,
206 path.add_module(
"PlaneTriggerTrackTimeEstimator",
207 pdgCodeToUseForEstimation=13,
208 triggerPlanePosition=triggerPos,
209 triggerPlaneDirection=normTriggerPlaneDirection,
210 useFittedInformation=
True,
211 useReadoutPosition=topInCounter,
212 readoutPosition=readOutPos,
213 readoutPositionPropagationSpeed=lightPropSpeed
217 path.add_module(
"DAFRecoFitter",
218 probCut=pval2ndTrial,
219 pdgCodesToUseForFitting=13
222 if eventTimingExtraction
is True:
224 path.add_module(
"FullGridChi2TrackTimeExtractor",
225 RecoTracksStoreArrayName=
"RecoTracks",
226 GridMaximalT0Value=40,
227 GridMinimalT0Value=-40,
232 path.add_module(
"DAFRecoFitter",
233 probCut=pval2ndTrial,
234 pdgCodesToUseForFitting=13
238 path.add_module(
'TrackCreator',
240 useClosestHitToIP=
True,
245def add_cdc_reconstruction(path, eventTimingExtraction=True,
248 Add CDC CR reconstruction
252 add_cdc_track_finding(path)
255 path.add_module(
'SetupGenfitExtrapolation',
256 energyLossBrems=
False, noiseBrems=
False)
259 path.add_module(
"IPTrackTimeEstimator",
261 useFittedInformation=
False)
263 path.add_module(
"DAFRecoFitter",
267 path.add_module(
"IPTrackTimeEstimator",
269 useFittedInformation=
True)
272 path.add_module(
"DAFRecoFitter",
273 probCut=pval2ndTrial,
276 if eventTimingExtraction
is True:
278 path.add_module(
"FullGridChi2TrackTimeExtractor",
279 RecoTracksStoreArrayName=
"RecoTracks",
280 GridMaximalT0Value=40,
281 GridMinimalT0Value=-40,
286 path.add_module(
"DAFRecoFitter",
287 probCut=pval2ndTrial,
291 path.add_module(
'TrackCreator',
292 pdgCodes=[211, 321, 2212])
295def getExpRunNumber(fname):
297 Get expperimental number and run number from file name.
299 f = ROOT.TFile(fname)
303 exp = e.getExperiment()
309def getRunNumber(fname):
311 Get run number from file name.
313 f = ROOT.TFile(fname)
322def getDataPeriod(exp=0, run=0):
324 Get data period from run number
325 It should be replaced the argument from run to (exp, run)!
344 for key
in run_range:
345 if run_range[key][0] <= run <= run_range[key][1]:
347 print(
"Data period : " + key)
351 b2.B2WARNING(
"No valid data period is specified.")
352 b2.B2WARNING(
"Default configuration is loaded.")
362def getMapperAngle(exp=1, run=3118):
364 Get B field mapper angle from exp and run number.
375def getTriggerType(exp=1, run=3118):
377 Get trigger type from exp and run number.
380 if run >= 3100
and run <= 3600:
382 elif run >= 3642
and run <= 4018:
390def add_GCR_Trigger_simulation(path, backToBack=False, skipEcl=True):
392 function to simulate trigger for GCR cosmics 2017. use CDC+ECL trigger
393 :param path: path want to add trigger simulation
394 :param backToBack: if true back to back TSF2; if false single TSF2
395 :param skipEcl: ignore ECL in trigger, just use CDC TSF2
397 empty_path = b2.create_path()
398 path.add_module(
'CDCTriggerTSF',
402 path.add_module(
'TRGECLFAM',
408 path.add_module(
'TRGECL',
415 TSF = path.add_module(
'TRGGDLCosmicRun',
416 BackToBack=backToBack,
418 TSF.if_false(empty_path)
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...