Skip to main content

Dowling's integrated data analysis for DQ experiemnt setup. Include data analysis functions, csv saving tools, Particle ID model, DNN model frame for ID training and EMCal ploting tools

Project description

dwong, a package for DarkQuest data analysis.

dwong is a comprehensive Python package, created by student Dowling Wong, tailored for data analysis and neural network-based particle identification in the DarkQuest experiment. The aim of this project is to streamline DarkQuest's data analysis process by providing exemplary data-processing functions.

The package mainly contains four modules: dwong, dplot, dcsv and dkeras.

Contents and useful functions.

  • dwong
    • emcal_bytuple
    • multi_clusters
    • h4_bytuple
    • prepare_data_bytuple
  • dplot
    • emcal_evt(x, y, eng)
    • emcal_pdf(ntuple_name, fname, absolute_path)
  • dkeras
    • train_model(x, y)
    • save_model(model, fname)
    • load_model(mname)
    • plot_confusion_matrix(cm, names, title='Confusion matrix', cmap=plt.cm.Blues)
    • plot_roc(pred,y)
  • dcsv
    • gen_csv(filename)

scheme

Smaple of use.

dwong, main module for data analysis.

 import dwong
 
 dq_events = dwong.getData(filename, "Events") #data acquisition from n-tuple.
 (x, y, eng, labels, labels_decrease, seeds, seed_labels) = dwong.multi_clusters(dq_events)#here performed clustering
 (h4x, h4y) = h4_bytuple(dq_events)
 dq_st23 = dq_events["st23"]
 dq_track = dq_events["track"]
 gpz = dq_events["gen"]["pz"]
 trkls_coord = np.stack((dq_st23["x"], dq_st23["y"], dq_st23["z"], dq_st23["px"], dq_st23["py"], dq_st23["pz"]), axis=1)
 trkls_cal = np.stack((dq_st23["Cal_x"], dq_st23["Cal_y"]), axis=1)
 track_st3 = np.stack((dq_track["x"], dq_track["y"], dq_track["pz"]), axis=1)

 folded_list=dwong.prepare_data_bytuple(filename)#return a list of events, each event may contain multiple particles.   
 flat_list = [particle for event in folded_list for particle in event]
 labels = [0] * len(flat_list)
 labeled_flat_list = [[label, *particle] for label, particle in zip(labels, flat_list)]#list of particles, in a flat list.

dplot, plot module.

 import dwong
 from dwong import dplot

 dq_events = dwong.getData(filename, "Events") #data acquisition from n-tuple.
 (x, y, eng) = emcal_bytuple(dq_events)
 fig = emcal_evt(x, y, eng)
 #The emcal_evt will plot the emcal page in jupyter notebook, and if you have further consideration, it returns fig

 #save a pdf booklet for all the emcal plots for events in a root file
 if ntuple_name.endswith(".root")& (ntuple_name not in train):
        emcal_pdf(ntuple_name, fname, absolute_path)

 #or you can plot all n-tuple under a directory
 target_dir = os.listdir("/Users/dwong/Desktop/n-tuples/5_80_training/")
 for file_name in target_dir:
     os.chdir(taregt_dir)
     if file_name.endswith(".root")& (file_name not in train):
         emcal_pdf(ntuple_name, fname, absolute_path)
 

External Link

*DarkQuest Snowmass paper. *DarkQuest Collaboration code collection. *The source for this project is available here. *Dowling's code collection for data analysis, model training, particle ID and samples. *Analysis package dwong's Pypi page. *Dowling's personal website.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dwong-0.2.tar.gz (9.6 kB view hashes)

Uploaded Source

Built Distribution

dwong-0.2-py3-none-any.whl (14.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page