def run(): """ Run the macro """ # This input generates empty spills, to be filled by the beam maker later on my_input = MAUS.InputCppRootData() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # Global my_map.append(MAUS.MapCppGlobalReconImport()) my_map.append(MAUS.MapCppGlobalTrackMatching()) my_reduce = MAUS.ReducePyDoNothing() # Then construct a MAUS output component - filename comes from datacards my_output = MAUS.OutputCppRoot() # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, my_reduce, my_output, datacards)
def run(): """ Run the macro """ # This input generates empty spills, to be filled by the beam maker later on my_input = MAUS.InputPySpillGenerator() # my_input = MAUS.InputCppRoot() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() my_map.append(MAUS.MapPyBeamMaker()) # beam construction my_map.append(MAUS.MapCppSimulation()) # geant4 simulation # my_map.append(MAUS.MapCppTrackerMCNoise()) # SciFi noise my_map.append(MAUS.MapCppTrackerMCDigitization()) # SciFi electronics my_map.append(MAUS.MapCppTrackerRecon()) # SciFi recon # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # reducer = MAUS.ReduceCppPatternRecognition() # Turn on event display reducer = MAUS.ReducePyDoNothing() # Then construct a MAUS output component - filename comes from datacards # my_output = MAUS.OutputPyJSON() my_output = MAUS.OutputCppRoot() # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, reducer, my_output, datacards)
def run(): """ Run the macro """ my_input = MAUS.InputPySpillGenerator() my_map = MAUS.MapPyGroup() my_map.append(MAUS.MapPyBeamMaker()) # beam construction my_map.append(MAUS.MapCppSimulation()) # geant4 simulation my_map.append( MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model my_map.append(MAUS.MapCppTrackerClusterRecon()) # SciFi channel clustering my_map.append( MAUS.MapCppTrackerSpacePointRecon()) # SciFi spacepoint recon my_map.append( MAUS.MapCppTrackerPatternRecognition()) # SciFi track finding my_map.append(MAUS.MapCppTrackerTrackFit()) # SciFi track fit datacards = io.StringIO(u"") # reducer = MAUS.ReduceCppPatternRecognition() reducer = MAUS.ReducePyDoNothing() # my_output = MAUS.OutputPyJSON() my_output = MAUS.OutputCppRoot() MAUS.Go(my_input, my_map, reducer, my_output, datacards)
def run(): """ Run the macro """ # This input generates empty spills, to be filled by the beam maker later on my_input = MAUS.InputPySpillGenerator() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # GEANT4 my_map.append(MAUS.MapPyBeamMaker()) # beam construction my_map.append(MAUS.MapCppSimulation()) # geant4 simulation # Pre detector set up my_map.append(MAUS.MapCppMCReconSetup()) # geant4 simulation # SciFi my_map.append(MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model my_map.append(MAUS.MapCppTrackerClusterRecon()) # SciFi channel clustering my_map.append(MAUS.MapCppTrackerSpacePointRecon()) # SciFi spacepoint recon my_map.append(MAUS.MapCppTrackerPatternRecognition()) # SciFi track finding my_map.append(MAUS.MapCppTrackerTrackFit()) # SciFi track fit # Then construct a MAUS output component - filename comes from datacards my_output = MAUS.OutputCppRoot() # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, MAUS.ReducePyDoNothing(), my_output, datacards)
def setUp(self): # pylint: disable=C0103, C0202 """ Define cards and initialise Output """ self.output = MAUS.OutputCppRoot() self.outdir = os.environ["MAUS_ROOT_DIR"]+"/tmp/test_output_cpp_root/" self.outfile = self.outdir+"test_outputCppRoot.root" try: os.mkdir(self.outdir) except OSError: pass try: os.mkdir(self.outdir+"/end_of_run/") except OSError: pass self.on_error_standard = ErrorHandler.DefaultHandler().on_error #ref = {"$ref":"#test_branch/double_by_value"} self.test_data = { "scalars":{}, "spill_number":1, "run_number":1, "daq_event_type":"physics_event", "recon_events":[], "mc_events":[], "maus_event_type":"Spill", } self.test_job_header = { "start_of_job":{"date_time":"1976-04-04T00:00:00.000000"}, "bzr_configuration":"", "bzr_revision":"", "bzr_status":"", "maus_version":"", "json_configuration":"output cpp root test", "maus_event_type":"JobHeader", } self.test_run_header = { "run_number":1, "maus_event_type":"RunHeader" } self.test_run_footer = { "run_number":-1, "maus_event_type":"RunFooter" } self.test_job_footer = { "end_of_job":{"date_time":"1977-04-04T00:00:00.000000"}, "maus_event_type":"JobFooter", } self.cards = Configuration.Configuration().getConfigJSON() self.cards = json.loads(self.cards) self.cards["output_root_file_name"] = self.outfile self.cards["output_root_file_mode"] = "one_big_file" self.cards["end_of_run_output_root_directory"] = \ self.outdir+"/end_of_run/" self.cards["verbose_level"] = 2 self.cards = json.dumps(self.cards) if maus_cpp.globals.has_instance(): maus_cpp.globals.death() maus_cpp.globals.birth(self.cards) self.output.birth(self.cards)
def run(): """ Run the macro """ # Use the G4BL JSON chunks as an input to the simulation my_input = MAUS.InputPyJSON() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # No need for the beam maker, as we use G4BL chunks # my_map.append(MAUS.MapPyBeamMaker()) # beam construction # Run the GEANT4 simulation my_map.append(MAUS.MapCppSimulation()) # geant4 simulation # Pre detector set up my_map.append(MAUS.MapCppMCReconSetup()) # geant4 simulation # TOF my_map.append(MAUS.MapCppTOFMCDigitizer()) # TOF MC Digitizer my_map.append(MAUS.MapCppTOFSlabHits()) # TOF MC Slab Hits my_map.append(MAUS.MapCppTOFSpacePoints()) # TOF Space Points # KL my_map.append(MAUS.MapCppKLMCDigitizer()) # KL MC Digitizer my_map.append(MAUS.MapCppKLCellHits()) # KL CellHit Reco # SciFi my_map.append( MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model my_map.append(MAUS.MapCppTrackerClusterRecon()) # SciFi channel clustering my_map.append( MAUS.MapCppTrackerSpacePointRecon()) # SciFi spacepoint recon my_map.append( MAUS.MapCppTrackerPatternRecognition()) # SciFi track finding my_map.append(MAUS.MapCppTrackerPRSeed()) # Set the Seed from PR my_map.append(MAUS.MapCppTrackerTrackFit()) # SciFi track fit # EMR my_map.append(MAUS.MapCppEMRMCDigitization()) # EMR MC Digitization my_map.append(MAUS.MapCppEMRSpacePoints()) # EMR MC Digitization my_map.append(MAUS.MapCppEMRRecon()) # EMR Recon # Ckov my_map.append(MAUS.MapCppCkovMCDigitizer()) # Global Digits - post detector digitisation # Then construct a MAUS output component - filename comes from datacards my_output = MAUS.OutputCppRoot() # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, MAUS.ReducePyDoNothing(), my_output, datacards)
def run(): """ Analyze data from the MICE experiment This reads in and processes data taken from the MICE experiment. """ # Set up data cards. data_cards_list = [] # batch mode = runs ROOT in batch mode so that canvases are not displayed # 1 = True, Batch Mode # 0 = False, Interactive Mode # setting it to false/0 will cause canvases to pop up on screen and # will get refreshed every N spills set by the refresh_rate data # card. data_cards_list.append("root_batch_mode='%d'\n" % 1) # refresh_rate = once in how many spills should canvases be updated data_cards_list.append("refresh_rate='%d'\n" % 1) # Add auto-numbering to the image tags. If False then each # histogram output for successive spills will have the same tag # so there are no spill-specific histograms. This is the # recommended use for online reconstruction. data_cards_list.append("histogram_auto_number=%s\n" % False) # Default image type is eps. For online use, use PNG. data_cards_list.append("histogram_image_type=\"png\"\n") # Directory for images. Default: $MAUS_WEB_MEDIA_RAW if set # else the current directory is used. # Uncomment and change the following if you want to hard # code a different default path. # data_cards_list.append("image_directory='%s'\n" % os.getcwd()) # set the TDC conversion factor such that time is in picosec data_cards_list.append("TOFtdcConversionFactor='%d'\n" % 25) # Convert data_cards to string. data_cards = io.StringIO(unicode("".join(data_cards_list))) # Set up the input that reads from DAQ my_input = MAUS.InputCppDAQOnlineData() # pylint: disable = E1101 # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() my_map.append(MAUS.MapCppTOFDigits()) my_map.append(MAUS.MapCppTOFSlabHits()) # my_map.append(MAUS.MapCppTOFSpacePoints()) # Calib reducer. # The C++ reducer crashes somewhere related to swig # The Python reducer works OK reducer = MAUS.ReducePyTofCalib() #reducer = MAUS.ReduceCppTofCalib() # Save output ROOT file output_worker = MAUS.OutputCppRoot() # Run the workflow. MAUS.Go(my_input, my_map, reducer, output_worker, data_cards)
def run(): """Run the macro""" # This generates events (usually spills) from a json-formatted ascii file my_input = MAUS.InputPyJSON() # This outputs events (usually spills) to a root-formatted binary file my_output = MAUS.OutputCppRoot() # Execute inputter and outputter # Mapper and Reducer does nothing MAUS.Go(my_input, MAUS.MapPyDoNothing(), MAUS.ReducePyDoNothing(), \ my_output, io.StringIO(u""))
def run(): """ Run the macro """ # This input generates empty spills, to be filled by the beam maker later on my_input = MAUS.InputPySpillGenerator() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # GEANT4 my_map.append(MAUS.MapPyBeamMaker()) # beam construction my_map.append(MAUS.MapCppSimulation()) # geant4 simulation # Pre detector set up # my_map.append(MAUS.MapPyMCReconSetup()) # geant4 simulation my_map.append(MAUS.MapCppMCReconSetup()) # geant4 simulation # TOF my_map.append(MAUS.MapCppTOFMCDigitizer()) # TOF MC Digitizer my_map.append(MAUS.MapCppTOFSlabHits()) # TOF MC Slab Hits my_map.append(MAUS.MapCppTOFSpacePoints()) # TOF Space Points # KL my_map.append(MAUS.MapCppKLMCDigitizer()) # KL MC Digitizer my_map.append(MAUS.MapCppKLCellHits()) # KL CellHit Reco # SciFi my_map.append( MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model my_map.append(MAUS.MapCppTrackerRecon()) # SciFi Recon # EMR my_map.append(MAUS.MapCppEMRMCDigitization()) # EMR MC Digitizer my_map.append(MAUS.MapCppEMRSpacePoints()) # EMR Space Points my_map.append(MAUS.MapCppEMRRecon()) # EMR Recon # Ckov my_map.append(MAUS.MapCppCkovMCDigitizer()) # Global Digits - post detector digitisation # Then construct a MAUS output component - filename comes from datacards my_output = MAUS.OutputCppRoot() # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, MAUS.ReducePyDoNothing(), my_output, datacards)
def test_end_of_run_file_per_run(self): """ test_OutputCppRoot.test_one_file_per_run: end_of_run_file_per_run option """ my_output = MAUS.OutputCppRoot() cards_py = json.loads(self.cards) cards_py["output_root_file_mode"] = "end_of_run_file_per_run" cards_py["output_root_file_name"] = "test_outputCppRoot.root" cards_py["end_of_run_output_root_directory"] = \ self.outdir+"/end_of_run/" self.cards = json.dumps(cards_py) my_output.birth(self.cards) self.test_data["run_number"] = 10 self.test_run_header["run_number"] = 10 for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_data) )) for i in range(2): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_run_header) )) for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_data) )) self.test_run_header["run_number"] = 9 for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_run_header) )) self.assertTrue(my_output.save( json.dumps(self.test_job_footer) )) self.test_run_footer["run_number"] = 9 self.assertTrue(my_output.save( json.dumps(self.test_run_footer) )) for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_job_header) )) my_output.death() self.__check_job_header("output cpp root test", 3, 0, self.outdir+"/end_of_run/0/test_outputCppRoot.root") self.__check_run_header(10, 2, 0, self.outdir+"/end_of_run/10/test_outputCppRoot.root") self.__check_run_header(9, 3, 0, self.outdir+"/end_of_run/9/test_outputCppRoot.root") self.__check_job_footer("1977-04-04T00:00:00.000000", 1, 0, self.outdir+"/end_of_run/0/test_outputCppRoot.root")
def run(): """ Analyze data from the MICE experiment """ # Set up the input that reads from DAQ my_input = MAUS.InputCppDAQOfflineData() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # Trigger my_map.append(MAUS.MapCppReconSetup()) # Detectors my_map.append(MAUS.MapCppTOFDigits()) my_map.append(MAUS.MapCppTOFSlabHits()) my_map.append(MAUS.MapCppTOFSpacePoints()) my_map.append(MAUS.MapCppCkovDigits()) my_map.append(MAUS.MapCppKLDigits()) my_map.append(MAUS.MapCppKLCellHits()) my_map.append(MAUS.MapCppTrackerDigits()) # SciFi real data digitization my_map.append(MAUS.MapCppTrackerClusterRecon()) # SciFi channel clustering my_map.append(MAUS.MapCppTrackerSpacePointRecon()) # SciFi spacepoint recon my_map.append(MAUS.MapCppTrackerPatternRecognition()) # SciFi track finding my_map.append(MAUS.MapCppTrackerPRSeed()) # Set the Seed from PR my_map.append(MAUS.MapCppTrackerTrackFit()) # SciFi track fit my_map.append(MAUS.MapCppEMRPlaneHits()) my_map.append(MAUS.MapCppEMRSpacePoints()) my_map.append(MAUS.MapCppEMRRecon()) my_reduce = MAUS.ReducePyDoNothing() # The Go() drives all the components you pass in then put all the output # into a file called 'mausput' MAUS.Go(my_input, my_map, my_reduce, MAUS.OutputCppRoot())
def run(): """ Run the macro """ my_input = MAUS.InputCppDAQOfflineData() # my_input = MAUS.InputPyJSON() my_map = MAUS.MapPyGroup() my_map.append(MAUS.MapCppTrackerDigits()) my_map.append(MAUS.MapCppTrackerRecon()) # SciFi recon datacards = io.StringIO(u"") # my_output = MAUS.OutputPyJSON() my_output = MAUS.OutputCppRoot() # my_reduce = MAUS.ReducePyDoNothing() my_reduce = MAUS.ReduceCppPatternRecognition() MAUS.Go(my_input, my_map, my_reduce, my_output, datacards)
def test_one_file_per_run(self): """ test_OutputCppRoot.test_one_file_per_run: one_file_per_run option """ my_output = MAUS.OutputCppRoot() cards_py = json.loads(self.cards) cards_py["output_root_file_mode"] = "one_file_per_run" self.cards = json.dumps(cards_py) my_output.birth(self.cards) self.test_data["run_number"] = 10 self.test_run_header["run_number"] = 10 for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_data) )) for i in range(2): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_run_header) )) for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_data) )) self.test_run_header["run_number"] = 9 for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_run_header) )) for i in range(3): # pylint: disable = W0612 self.assertTrue(my_output.save( json.dumps(self.test_job_header) )) my_output.death() self.__check_job_header("output cpp root test", 3, 0, self.outdir+"test_outputCppRoot_0.root") self.__check_run_header(10, 2, 0, self.outdir+"test_outputCppRoot_10.root") self.__check_run_header(9, 3, 0, self.outdir+"test_outputCppRoot_9.root")
def test_birth_death(self): """ Check that we can birth and death properly """ an_output = MAUS.OutputCppRoot() # for now this does NOT return an exception... looks like it is caught # by the API... set ErrorHandler.on_error to 'raise' and we raise a # std::exception killing the tests (oops) an_output.birth(json.dumps({})) an_output.birth(json.dumps({'output_root_file_name':'', 'output_root_file_mode':'one_big_file', 'end_of_run_output_root_directory':'tmp'})) an_output.birth(json.dumps({'output_root_file_name':'test.root', 'output_root_file_mode':'', 'end_of_run_output_root_directory':'tmp'})) an_output.birth(json.dumps({'output_root_file_name':'test.root', 'output_root_file_mode':'one', 'end_of_run_output_root_directory':'tmp'})) # this is okay (dir can just be '') an_output.birth(json.dumps({'output_root_file_name':'test.root', 'output_root_file_mode':'one_big_file', 'end_of_run_output_root_directory':''})) an_output.birth(self.cards) an_output.death()
def run(): """ Analyze data from the MICE experiment """ # Set up the input that reads from DAQ my_input = MAUS.InputCppDAQOnlineData() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # Trigger my_map.append(MAUS.MapCppReconSetup()) # Detectors my_map.append(MAUS.MapCppTOFDigits()) my_map.append(MAUS.MapCppTOFSlabHits()) my_map.append(MAUS.MapCppTOFSpacePoints()) my_map.append(MAUS.MapCppCkovDigits()) my_map.append(MAUS.MapCppKLDigits()) my_map.append(MAUS.MapCppKLCellHits()) my_map.append(MAUS.MapCppTrackerDigits()) my_map.append(MAUS.MapCppTrackerRecon()) my_map.append(MAUS.MapCppEMRPlaneHits()) my_map.append(MAUS.MapCppEMRRecon()) my_reduce = MAUS.ReducePyDoNothing() # The Go() drives all the components you pass in then put all the output # into a file called 'mausput' MAUS.Go(my_input, my_map, my_reduce, MAUS.OutputCppRoot())
def run(): """ Run the macro """ # This input generates empty spills, to be filled by the beam maker later on my_input = MAUS.InputPySpillGenerator() # Create an empty array of mappers, then populate it # with the functionality you want to use. my_map = MAUS.MapPyGroup() # G4beamline my_map.append(MAUS.MapPyBeamlineSimulation()) # GEANT4 # my_map.append(MAUS.MapPyBeamMaker()) # beam construction my_map.append(MAUS.MapCppSimulation()) # geant4 simulation # Pre detector set up my_map.append(MAUS.MapPyMCReconSetup()) # geant4 simulation # TOF my_map.append(MAUS.MapCppTOFMCDigitizer()) # TOF MC Digitizer my_map.append(MAUS.MapCppTOFSlabHits()) # TOF MC Slab Hits my_map.append(MAUS.MapCppTOFSpacePoints()) # TOF Space Points # KL my_map.append(MAUS.MapCppKLMCDigitizer()) # KL MC Digitizer my_map.append(MAUS.MapCppKLCellHits()) # KL CellHit Reco # SciFi # MAUS 2.5.0 #my_map.append(MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model #my_map.append(MAUS.MapCppTrackerRecon()) # SciFi Recon my_map.append( MAUS.MapCppTrackerMCDigitization()) # SciFi electronics model my_map.append(MAUS.MapCppTrackerClusterRecon()) # SciFi channel clustering my_map.append( MAUS.MapCppTrackerSpacePointRecon()) # SciFi spacepoint recon my_map.append( MAUS.MapCppTrackerPatternRecognition()) # SciFi track finding my_map.append(MAUS.MapCppTrackerPRSeed()) # Set the Seed from PR my_map.append(MAUS.MapCppTrackerTrackFit()) # SciFi track fit my_map.append( MAUS.MapCppTrackerTOFReFit()) # SciFi track refit based on TOF # EMR my_map.append(MAUS.MapCppEMRMCDigitization()) # EMR MC Digitizer my_map.append(MAUS.MapCppEMRSpacePoints()) # EMR Space Points my_map.append(MAUS.MapCppEMRRecon()) # EMR Recon # Global my_map.append(MAUS.MapCppGlobalReconImport()) my_map.append(MAUS.MapCppGlobalTrackMatching()) # Then construct a MAUS output component - filename comes from datacards my_output = MAUS.OutputCppRoot() # can specify datacards here or by using appropriate command line calls datacards = io.StringIO(u"") # The Go() drives all the components you pass in, then check the file # (default simulation.out) for output MAUS.Go(my_input, my_map, MAUS.ReducePyDoNothing(), my_output, datacards)