diff --git a/Control/CalypsoExample/Digitization/scripts/faser_digi.py b/Control/CalypsoExample/Digitization/scripts/faser_digi.py index 6cd1f1b13700cfa43987fb90fdc0afb885394c3f..e2e60f568520c0b7580568bd4eec293d114f8488 100755 --- a/Control/CalypsoExample/Digitization/scripts/faser_digi.py +++ b/Control/CalypsoExample/Digitization/scripts/faser_digi.py @@ -181,6 +181,14 @@ acc.merge(CaloWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, Advance from ScintDigiAlgs.ScintDigiAlgsConfig import ScintWaveformDigitizationCfg acc.merge(ScintWaveformDigitizationCfg(configFlags, digiTag=args.digiTag, AdvancedTiming=(not args.simpleTiming))) +#add beam truth event +from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg +# acc = ComponentAccumulator() +ItemList = ["McEventCollection#BeamTruthEvent"] +acc.merge(OutputStreamCfg(configFlags, "RDO", ItemList)) + + + # Configure verbosity if args.verbose: acc.foreach_component("*").OutputLevel = VERBOSE diff --git a/Control/CalypsoExample/Generation/python/faser_parser.py b/Control/CalypsoExample/Generation/python/faser_parser.py index 7af8f3d219ce0095d580f92d98ddd9b1a52c3478..be0f1dcabe1ee30fbfb5984b11137ce2bf0e75b4 100644 --- a/Control/CalypsoExample/Generation/python/faser_parser.py +++ b/Control/CalypsoExample/Generation/python/faser_parser.py @@ -24,7 +24,7 @@ def faser_pgparser(): parser.add_argument("--conf", action='append', help="Specify configuration file with default values") parser.add_argument("--geom", default="TI12MC", - help="Specify geomtery to simulation (default: TI12MC, alt: TestBeamMC)") + help="Specify geometry to simulation (default: TI12MC, alt: TestBeamMC)") parser.add_argument("--run", default=123456, type=int, help="Run number to generate") diff --git a/Control/CalypsoExample/Generation/scripts/faser_particlegun.py b/Control/CalypsoExample/Generation/scripts/faser_particlegun.py index 26996abe453e6e6da7787c806517d677c8896257..f711d7fdaa1c831ec06106a097d06085bd6baf4d 100755 --- a/Control/CalypsoExample/Generation/scripts/faser_particlegun.py +++ b/Control/CalypsoExample/Generation/scripts/faser_particlegun.py @@ -286,14 +286,6 @@ if __name__ == '__main__': from G4FaserAlg.G4FaserAlgConfig import G4FaserAlgCfg cfg.merge(G4FaserAlgCfg(configFlags)) -#Event Filtering? - if args.filter == 'muon_conversion': - import McParticleEvent.Pythonizations - from GeneratorUtils.MuonFilters import ConversionFilter - filt = ConversionFilter("MuonFilter") # , muonEnergyLoss = 5000, minConversionEnergy = 2000) # , muonEnergyLoss = 5000, maxRadius = 100) - cfg.addEventAlgo(filt, sequenceName = "AthAlgSeq") - OutputStreamHITS = cfg.getEventAlgo("OutputStreamHITS") - OutputStreamHITS.RequireAlgs = ["MuonFilter"] # # Output file # @@ -304,6 +296,27 @@ if __name__ == '__main__': # Add in-file MetaData from xAODMetaDataCnv.InfileMetaDataConfig import SetupMetaDataForStreamCfg cfg.merge(SetupMetaDataForStreamCfg(configFlags, "HITS", AcceptAlgs=AcceptAlgNames)) + + + +# +#Event Filtering? +# + if args.filter == 'muon_conversion': + + from GeneratorUtils.MuonFilters import ConversionFilter + import AthenaCommon.AppMgr as acam + import AthenaCommon.AlgSequence as acas + + from OutputStreamAthenaPool.OutputStreamConfig import outputStreamName + filt = ConversionFilter("MuonFilter") # , muonEnergyLoss = 5000, minConversionEnergy = 2000) # , muonEnergyLoss = 5000, maxRadius = 100) + cfg.addEventAlgo(filt) + cfg.getEventAlgo(outputStreamName("HITS")).WritingTool.ProcessingTag = "StreamHITS" + OutputStreamHITS = cfg.getEventAlgo(outputStreamName("HITS")) + OutputStreamHITS.RequireAlgs = ["MuonFilter"] +# + + # # Dump config # diff --git a/Generators/GeneratorUtils/python/MuonFilters.py b/Generators/GeneratorUtils/python/MuonFilters.py index 2540d3905ada00ccba8ffacf2f3f56e43d4b8248..15efe042f31716f8aa2ebb9693885ac0676afaee 100644 --- a/Generators/GeneratorUtils/python/MuonFilters.py +++ b/Generators/GeneratorUtils/python/MuonFilters.py @@ -26,8 +26,8 @@ class ConversionFilter(PyAthena.Alg): return def findConversionFromMuon(self, evt): - - for i, p in enumerate(evt.particles): + + for i, p in enumerate(evt.particles()): # Check incoming particle (muon) is within radius to # avoid those conversions from muons coming in to magnet @@ -47,7 +47,7 @@ class ConversionFilter(PyAthena.Alg): if ovtx.particles_out_size() != 2: continue # That are e+e- pair - children = list(ovtx.particles_out) + children = list(ovtx.particles_out()) if not (abs(children[0].pdg_id()) == 11 and children[0].pdg_id() == -children[1].pdg_id()): continue self.msg.debug("Found Photon conversion") @@ -55,7 +55,7 @@ class ConversionFilter(PyAthena.Alg): ivtx = p.production_vertex() if not ivtx: continue if ivtx.particles_in_size() != 1: continue - mother = list(ivtx.particles_in)[0] + mother = list(ivtx.particles_in())[0] # That is a muon (allowing for another photon inbetween) isFromMuon = False @@ -64,7 +64,7 @@ class ConversionFilter(PyAthena.Alg): elif abs(mother.pdg_id()) == 22: ivtx = mother.production_vertex() if ivtx and ivtx.particles_in_size() == 1: - gran = list(ivtx.particles_in)[0] + gran = list(ivtx.particles_in())[0] if abs(gran.pdg_id()) == 13: isFromMuon = True @@ -85,7 +85,7 @@ class ConversionFilter(PyAthena.Alg): lastMuonE = None firstMuonE = None - for p in evt.particles: + for p in evt.particles(): # Find muons if abs(p.pdg_id()) != 13: continue @@ -120,7 +120,30 @@ class ConversionFilter(PyAthena.Alg): self.msg.debug(f"Executing {self.getName()}") self.msg.debug(f"Reading {self.InputMCEventKey}") + mc = self.evtStore[self.InputMCEventKey] evt = self.evtStore[self.InputMCEventKey][0] + # print('****************EVT*************************') + # print(self.evtStore[self.InputMCEventKey]) + # print(len(evt.particles())) + # print(evt.particles()[0].momentum().px()) + # from PyDumper.Dumpers import toiter + # print("???????") + # print(evt.particles().begin()) + # print("???????") + + # particle_list = [] + # for p in toiter(evt.particles().begin(), + # evt.particles().end()): + # print(p) + # particle_list.append(p) + # evt.particle_list = particle_list + # print(evt.particle_list) + # # print("dir(evt):", dir(evt)) + # # print("dir(evt.particles):", dir(evt.particles)) + # print(mc.size()) + # print(dir(evt)) + # print(evt.__dict__) + # print('****************EVT*************************') self.setFilterPassed(False)