Skip to content

Commit

Permalink
Add description of the various steps (AliceO2Group#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
ginnocen authored Feb 22, 2020
1 parent 4fb9500 commit a69c8a4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
33 changes: 31 additions & 2 deletions tpcwithdnn/dnnoptimiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from fluctuationDataGenerator import fluctuationDataGenerator
from utilitiesdnn import UNet

# pylint: disable=too-many-instance-attributes, too-many-statements
# pylint: disable=too-many-instance-attributes, too-many-statements, fixme, pointless-string-statement
class DnnOptimiser:
#Class Attribute
species = "dnnoptimiser"
Expand Down Expand Up @@ -61,6 +61,26 @@ def __init__(self, data_param, case):
self.use_scaler, self.distortion_type)

def get_fluctuation(self, indexev):
#FIXME
""" Here we define the functionalties to load the files from the input
directory which is set in the database. Here below the description of
the input files:
- 0-vecZPos.npy, 0-vecRPos.npy, 0-vecPhiPos.npy contains the
position of the FIXME. There is only one of these files for each
folder, therefore for each bunch of events
Input features for training:
- vecMeanSC.npy: average space charge in each bin of r, rphi and z.
- vecRandomSC.npy: fluctuation of the space charge.
Output from the numberical calculations:
- vecMeanDistR.npy average distorsion along the R axis in the same
grid. It represents the expected distorsion that an electron
passing by that region would have as a consequence of the IBF.
- vecRandomDistR.npy are the correponding fluctuations.
- All the distorsions along the other directions have a consistent
naming choice.
"""

vecZPosFile = self.dirinput + str(0) + '-vecZPos.npy'
scMeanFile = self.dirinput + str(indexev) + '-vecMeanSC.npy'
scRandomFile = self.dirinput + str(indexev) + '-vecRandomSC.npy'
Expand All @@ -79,6 +99,14 @@ def get_fluctuation(self, indexev):
vecRandomDistRPhi = np.load(distRPhiRandomFile)
vecMeanDistZ = np.load(distZMeanFile)
vecRandomDistZ = np.load(distZRandomFile)

#FIXME: wrong selection?
"""What is the meaning of splitting along the z axis. Why dont we split
along other axes? In the previous version of this code, there was a
selection over the z-axis hardcoded. Is there a reason for that? I
currently have included all the three options, namely <,>, no choice.
"""
if self.side == 0:
vecFluctuationSC = vecMeanSC[vecZPos >= 0] - vecRandomSC[vecZPos >= 0]
vecFluctuationDistR = vecMeanDistR[vecZPos >= 0] - vecRandomDistR[vecZPos >= 0]
Expand All @@ -97,6 +125,7 @@ def get_fluctuation(self, indexev):
return [vecFluctuationSC, vecFluctuationDistR, vecFluctuationDistRPhi, vecFluctuationDistZ]

def train(self):
#FIXME: missing random extraction for training and testing events?
partition = {'train': np.arange(self.rangeevent_train[1]),
'validation': np.arange(self.rangeevent_test[0], self.rangeevent_test[1])}
training_generator = fluctuationDataGenerator(partition['train'], **self.params)
Expand Down Expand Up @@ -155,7 +184,7 @@ def apply(self):
distortionPredict_flatm = distortionPredict_group.reshape(-1, 1)
distortionPredict_flata = distortionPredict_group.flatten()

#FIXME I AM HARDCODING THIS SHIT HERE FIXME PLEASE
#FIXME HARDCODED distorsions only along R are considered
distortionNumeric_flata = vecFluctDistR_flata
distortionNumeric_flatm = distortionNumeric_flata.reshape(-1, 1)

Expand Down
4 changes: 3 additions & 1 deletion tpcwithdnn/fluctuationDataGenerator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# pylint: disable=line-too-long, invalid-name, too-many-instance-attributes, too-many-arguments
# pylint: disable=line-too-long, invalid-name, too-many-instance-attributes,
# pylint: disable=fixme, pointless-string-statement, too-many-arguments
import numpy as np
import keras
from sklearn.externals import joblib

#https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly
class fluctuationDataGenerator(keras.utils.Sequence):

def __init__(self, list_IDs, batch_size=32, phi_slice=180, r_row=129, z_col=129, \
Expand Down

0 comments on commit a69c8a4

Please sign in to comment.