<commit_before>#!/usr/bin/python

import argparse
import sys
import os.path
import math
import array

from hic import flow
from hybrid_analysis.event_selection import centrality_filters as cf
from hybrid_analysis.file_reader import hybrid_reader as reader
from hybrid_analysis.multiplicity import distributions as mlt
from hybrid_analysis.v_n import cumulants as cumu
from hybrid_analysis.v_n import eventplane as ep

# Initialization
events = 0

# Integrated yields
# To be compared with PHOBOS data
# PRC75, 024910 (2007)
midy_min = -0.1
midy_max = 0.4
integrated_p = 0.0
integrated_pbar = 0.0

# pT spectra
# To be compared with PHOBOS data
# PRC75, 024910 (2007)
# Rapidity point
ypoint = 0.8
deltay = 0.1
spectraptpoints = [0.25, 0.30, 0.35, 0.40, 0.50, 0.55, 0.60, 0.70,
                   1.0, 1.2, 1.55, 1.85, 2.2]
spectraptbinw = 0.05
dndptsums = {}
particleidlist = [211, -211, 321, -321, 2212, -2212]
for particletype in particleidlist:
    dndptsum = [0.0] * len(spectraptpoints)
    dndptsums[particletype] = dndptsum

# Pseudorapidity distribution
# To be compared with PHOBOS data
# PRC83, 024913 (2011)
deltaeta = 0.2
etamin = -5.3
etabins = int(-2 * etamin / deltaeta + 0.5)
nchetapoints = [ (etamin + deltaeta * i) for i in range(0, etabins+1) ]
dndetasum = [0.0] * len(nchetapoints)

# Flow analysis
# To be compared with STAR data
# PRC86, 054908 (2012)
cumulant_etacut = 1.0
flowptpoints = [0.26, 0.44, 0.64, 0.84, 1.04, 1.24, 1.44, 1.64, 1.86, 2.19]
flowptbinw = 0.8
qcharges = {}
qphis = {}
for ptpoint in flowptpoints:
    qcharges[ptpoint] = []
    qphis[ptpoint] = []

vn_event_etacut = 0.1
vn_event_sums = array.array('d', [0.0]*8)

# parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--impact", type=float, nargs=2,
                    metavar=('bmin', 'bmax'),
                    help="impact parameter range")
parser.add_argument("-n", "--npart", type=int, nargs=2,
                    metavar=('nmin', 'nmax'),
                    help="participant range")
parser.add_argument("datapath",
                    help="path to datafiles")
args = parser.parse_args()

# Centrality filtering
datafiles = []
if args.impact:
    datafiles = cf.filter_events(args.datapath,
                                 b_min=args.impact[0],
                                 b_max=args.impact[1])
elif args.npart:
    datafiles = cf.filter_events(args.datapath,
                                 npart_min=npart[0],
                                 npart_max=npart[1])

# Data analysis
files = 0
for datafile in datafiles:
    if files%100 == 0:
        print "Files read:" ,files
    files += 1
    eventlist = reader.read_afterburner_output(datafile)
    if eventlist:
        events += len(eventlist)
        for particlelist in eventlist:
            integrated_p += sum([ 1 for x in particlelist
                                  if (x.ptype == 2212
                                      and x.rap > midy_min
                                      and x.rap < midy_max) ])
            integrated_pbar += sum([ 1 for x in particlelist
                                     if (x.ptype == -2212
                                         and x.rap > midy_min
                                         and x.rap < midy_max) ])
<commit_msg>Master script: Output centrality<commit_after>#!/usr/bin/python

import argparse
import sys
import os.path
import math
import array

from hic import flow
from hybrid_analysis.event_selection import centrality_filters as cf
from hybrid_analysis.file_reader import hybrid_reader as reader
from hybrid_analysis.multiplicity import distributions as mlt
from hybrid_analysis.v_n import cumulants as cumu
from hybrid_analysis.v_n import eventplane as ep

# Initialization
events = 0

# Integrated yields
# To be compared with PHOBOS data
# PRC75, 024910 (2007)
midy_min = -0.1
midy_max = 0.4
integrated_p = 0.0
integrated_pbar = 0.0

# pT spectra
# To be compared with PHOBOS data
# PRC75, 024910 (2007)
# Rapidity point
ypoint = 0.8
deltay = 0.1
spectraptpoints = [0.25, 0.30, 0.35, 0.40, 0.50, 0.55, 0.60, 0.70,
                   1.0, 1.2, 1.55, 1.85, 2.2]
spectraptbinw = 0.05
dndptsums = {}
particleidlist = [211, -211, 321, -321, 2212, -2212]
for particletype in particleidlist:
    dndptsum = [0.0] * len(spectraptpoints)
    dndptsums[particletype] = dndptsum

# Pseudorapidity distribution
# To be compared with PHOBOS data
# PRC83, 024913 (2011)
deltaeta = 0.2
etamin = -5.3
etabins = int(-2 * etamin / deltaeta + 0.5)
nchetapoints = [ (etamin + deltaeta * i) for i in range(0, etabins+1) ]
dndetasum = [0.0] * len(nchetapoints)

# Flow analysis
# To be compared with STAR data
# PRC86, 054908 (2012)
cumulant_etacut = 1.0
flowptpoints = [0.26, 0.44, 0.64, 0.84, 1.04, 1.24, 1.44, 1.64, 1.86, 2.19]
flowptbinw = 0.8
qcharges = {}
qphis = {}
for ptpoint in flowptpoints:
    qcharges[ptpoint] = []
    qphis[ptpoint] = []

vn_event_etacut = 0.1
vn_event_sums = array.array('d', [0.0]*8)

# parse command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("-b", "--impact", type=float, nargs=2,
                    metavar=('bmin', 'bmax'),
                    help="impact parameter range")
parser.add_argument("-n", "--npart", type=int, nargs=2,
                    metavar=('nmin', 'nmax'),
                    help="participant range")
parser.add_argument("datapath",
                    help="path to datafiles")
args = parser.parse_args()

# Centrality filtering
datafiles = []
if args.impact:
    print "Impact parameter range:", args.impact[0], args.impact[1]
    datafiles = cf.filter_events(args.datapath,
                                 b_min=args.impact[0],
                                 b_max=args.impact[1])
elif args.npart:
    print "Npart range:", args.npart[0], args.npart[1]
    datafiles = cf.filter_events(args.datapath,
                                 npart_min=npart[0],
                                 npart_max=npart[1])

# Data analysis
files = 0
for datafile in datafiles:
    if files%100 == 0:
        print "Files read:" ,files
    files += 1
    eventlist = reader.read_afterburner_output(datafile)
    if eventlist:
        events += len(eventlist)
        for particlelist in eventlist:
            integrated_p += sum([ 1 for x in particlelist
                                  if (x.ptype == 2212
                                      and x.rap > midy_min
                                      and x.rap < midy_max) ])
            integrated_pbar += sum([ 1 for x in particlelist
                                     if (x.ptype == -2212
                                         and x.rap > midy_min
                                         and x.rap < midy_max) ])

{'fraction_non_alphanumeric': 0.1106642835865356, 'fraction_numerical': 0.05838546321120048, 'mean_word_length': 2.2113821138211383, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '604562', 'n_tokens_mistral': 2533, 'n_tokens_neox': 2244, 'n_words': 596}