Commit 1392b0e6 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬

Add option for setting minimum average Pz momentum and improve histograms

parent 9b7f2d96
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
Int_t esd_event_id = 0; // global variable to store unique event id Int_t esd_event_id = 0; // global variable to store unique event id
Double_t highAvgPz, lowAvgPz, highAvgPzEvent, lowAvgPzEvent; //variables to store info about highest and lowest <Pz> values
class AliAnalysisTaskMyTask; // your analysis class class AliAnalysisTaskMyTask; // your analysis class
using namespace std; // std namespace: so you can do things like 'cout' using namespace std; // std namespace: so you can do things like 'cout'
...@@ -91,7 +93,7 @@ void AliAnalysisTaskMyTask::UserCreateOutputObjects() ...@@ -91,7 +93,7 @@ void AliAnalysisTaskMyTask::UserCreateOutputObjects()
// your histogram in the output file, add it to the list! // your histogram in the output file, add it to the list!
// |<Pz>| histogram: absolute value of average Pz (or Pz per track) for each event // |<Pz>| histogram: absolute value of average Pz (or Pz per track) for each event
fHistAvgPz = new TH1F("fHistAvgPz", "fHistAvgPz", 100, 0, 0.1); // create histogram fHistAvgPz = new TH1F("fHistAvgPz", "fHistAvgPz", 100, 0, 10); // create histogram
fOutputList->Add(fHistAvgPz); fOutputList->Add(fHistAvgPz);
// my mass histogram // my mass histogram
...@@ -142,16 +144,16 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -142,16 +144,16 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
Double_t Vz = 0.01 * fESD->GetPrimaryVertex()->GetZ(); Double_t Vz = 0.01 * fESD->GetPrimaryVertex()->GetZ();
Double_t MagneticField = 0.1 * fESD->GetMagneticField(); // gets magnetic field, in TESLA Double_t MagneticField = 0.1 * fESD->GetMagneticField(); // gets magnetic field, in TESLA
/* /*
Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || Charge (* 1.6*10^-19 C) Assumed Units: Mass (GeV/c^2) || Energy (GeV) || Momentum (GeV/c) || Charge (* 1.6*10^-19 C)
*/ */
if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data
Double_t PzSum = 0; Double_t PzSum = 0;
Double_t absPzSum = 0;
for(Int_t i(0); i < iTracks; i++) { // loop over all these tracks for(Int_t i(0); i < iTracks; i++) { // loop over all these tracks
...@@ -168,6 +170,7 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -168,6 +170,7 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
Double_t Pz = track->Pz(); Double_t Pz = track->Pz();
PzSum += Pz/iTracks; // Pz sum for |<Pz>| histogram PzSum += Pz/iTracks; // Pz sum for |<Pz>| histogram
absPzSum += abs(Pz)/iTracks; //Remember: in C++, abs function overloads
Double_t Charge = track->Charge(); Double_t Charge = track->Charge();
...@@ -181,11 +184,29 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -181,11 +184,29 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
fHistMass->Fill(Mass); fHistMass->Fill(Mass);
} }
if(PzSum>0) {
fHistAvgPz->Fill(PzSum); if(absPzSum != 0) { // This will only fill |<Pz>| histogram for events with tracks (non-empty)
} else { fHistAvgPz->Fill(abs(PzSum));
fHistAvgPz->Fill(-PzSum); }
}
if(selectedEventID == 0) {
highAvgPzEvent = 0;
lowAvgPzEvent = 0;
highAvgPz = PzSum;
lowAvgPz = PzSum;
} else {
if(PzSum>highAvgPz) {
highAvgPz = PzSum;
highAvgPzEvent = selectedEventID;
}
if(PzSum<lowAvgPz) {
lowAvgPz = PzSum;
lowAvgPzEvent = selectedEventID;
}
}
} }
esd_detail.close(); esd_detail.close();
...@@ -215,5 +236,7 @@ void AliAnalysisTaskMyTask::Terminate(Option_t *) ...@@ -215,5 +236,7 @@ void AliAnalysisTaskMyTask::Terminate(Option_t *)
{ {
// terminate // terminate
// called at the END of the analysis (when all events are processed) // called at the END of the analysis (when all events are processed)
cout << endl << "Lowest Pz Mean (<Pz>) = " << lowAvgPz << " at Event " << lowAvgPzEvent;
cout << endl << "Highest Pz Mean (<Pz>) = " << highAvgPz << " at Event " << highAvgPzEvent << endl;
} }
//_____________________________________________________________________________ //_____________________________________________________________________________
...@@ -34,7 +34,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then ...@@ -34,7 +34,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
fi fi
OPTIONS=c:hdau:m:n:t:r: OPTIONS=c:hdau:m:n:t:r:
LONGOPTS=camera:,resolution:,fps:,transperency:,duration:,maxparticles:,minparticles:,numberofevents:,help,download,sample,url:,its,tpc,trd,emcal LONGOPTS=camera:,resolution:,fps:,transperency:,duration:,maxparticles:,minparticles:,numberofevents:,minavgpz:,help,download,sample,url:,its,tpc,trd,emcal
# -regarding ! and PIPESTATUS see above # -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors # -temporarily store output to be able to check for errors
...@@ -60,6 +60,7 @@ TRANSPERENCY=1 ...@@ -60,6 +60,7 @@ TRANSPERENCY=1
MAX_PARTICLES=1000 MAX_PARTICLES=1000
MIN_PARTICLES=0 MIN_PARTICLES=0
N_OF_EVENTS=10 N_OF_EVENTS=10
MIN_AVG_PZ=0
HELP=false HELP=false
DOWNLOAD=false DOWNLOAD=false
SAMPLE=false SAMPLE=false
...@@ -100,6 +101,10 @@ while true; do ...@@ -100,6 +101,10 @@ while true; do
N_OF_EVENTS="$2" N_OF_EVENTS="$2"
shift 2 shift 2
;; ;;
--minavgpz)
MIN_AVG_PZ="$2"
shift 2
;;
-t|--duration) -t|--duration)
DURATION="$2" DURATION="$2"
shift 2 shift 2
...@@ -165,11 +170,17 @@ Usage: ...@@ -165,11 +170,17 @@ Usage:
This should be in the format provided by http://opendata.cern.ch. This should be in the format provided by http://opendata.cern.ch.
See example below. See example below.
-m | --maxparticles VALUE -m | --maxparticles VALUE
Get only events for which its number of particles does not exceed VALUE. Get only events for which its number of particles does not
exceed VALUE.
--minparticles VALUE --minparticles VALUE
Get only events for which its number of particles is greater than or equal to VALUE. Get only events for which its number of particles is greater than
or equal to VALUE.
-n | --numberofevents VALUE -n | --numberofevents VALUE
Set number of events to be animated inside chosen ESD file. Set number of events to be animated inside chosen ESD file.
--minavgpz VALUE
Get only events for which its absolute value of average momentum in
the z direction is greater than or equal to VALUE. Useful for animating
events with 'boosts' of particles to the same side.
-t | --duration VALUE -t | --duration VALUE
Set the animation duration in seconds. Set the animation duration in seconds.
-r | --resolution VALUE -r | --resolution VALUE
...@@ -221,6 +232,7 @@ else ...@@ -221,6 +232,7 @@ else
echo "Max particles: ${MAX_PARTICLES}" echo "Max particles: ${MAX_PARTICLES}"
echo "Min particles: ${MIN_PARTICLES}" echo "Min particles: ${MIN_PARTICLES}"
echo "Number of events: ${N_OF_EVENTS}" echo "Number of events: ${N_OF_EVENTS}"
echo "Min Average Z Momentum: ${MIN_AVG_PZ}"
echo "Camera: $CAMERA" echo "Camera: $CAMERA"
echo "-----------------------------------" echo "-----------------------------------"
echo "------------ Detectors ------------" echo "------------ Detectors ------------"
...@@ -284,7 +296,7 @@ if [ "$SAMPLE" = "true" ]; then ...@@ -284,7 +296,7 @@ if [ "$SAMPLE" = "true" ]; then
############################## ##############################
pushd ${BLENDER_SCRIPT_DIR} pushd ${BLENDER_SCRIPT_DIR}
for type in $CAMERA; do for type in $CAMERA; do
echo "Preparing sample animation with $type Camera in Blender" echo "Preparing sample animation with $type in Blender"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="d-esd-detail.dat" -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="d-esd-detail.dat" -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL}
done done
popd popd
...@@ -365,19 +377,22 @@ elif [ "$SAMPLE" = "false" ]; then ...@@ -365,19 +377,22 @@ elif [ "$SAMPLE" = "false" ]; then
NUMBER_OF_PARTICLES=$(wc -l ${BLENDER_SCRIPT_DIR}/$LOCAL_FILE_WITH_DATA | \ NUMBER_OF_PARTICLES=$(wc -l ${BLENDER_SCRIPT_DIR}/$LOCAL_FILE_WITH_DATA | \
awk '{ print $1 }') awk '{ print $1 }')
echo "File $LOCAL_FILE_WITH_DATA has $NUMBER_OF_PARTICLES particles"
if [[ $NUMBER_OF_PARTICLES -lt $MAX_PARTICLES+1 && $NUMBER_OF_PARTICLES -gt $MIN_PARTICLES-1 && $EVENT_COUNTER -lt $N_OF_EVENTS ]]; then AVERAGE_PZ=$(awk 'BEGIN {pzsum=0;n=0} {pzsum+=$8;n++} END {print sqrt(pzsum*pzsum/n/n)}' ${BLENDER_SCRIPT_DIR}/${LOCAL_FILE_WITH_DATA})
echo "File $LOCAL_FILE_WITH_DATA has $NUMBER_OF_PARTICLES particles and average Z momentum $AVERAGE_PZ"
if [[ $NUMBER_OF_PARTICLES -le $MAX_PARTICLES && $NUMBER_OF_PARTICLES -ge $MIN_PARTICLES && $EVENT_COUNTER -lt $N_OF_EVENTS && $AVERAGE_PZ -ge $MIN_AVG_PZ ]]; then
# Increment event counter # Increment event counter
EVENT_COUNTER=$EVENT_COUNTER+1 EVENT_COUNTER=$EVENT_COUNTER+1
echo "Processing ${EVENT_UNIQUE_ID} ($NUMBER_OF_PARTICLES) in Blender" echo "Processing ${EVENT_UNIQUE_ID} ($NUMBER_OF_PARTICLES tracks) in Blender"
pushd ${BLENDER_SCRIPT_DIR} pushd ${BLENDER_SCRIPT_DIR}
for type in $CAMERA; do for type in $CAMERA; do
echo "Processing ${EVENT_UNIQUE_ID} with $type Camera in Blender" echo "Processing ${EVENT_UNIQUE_ID} with $type in Blender"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="${LOCAL_FILE_WITH_DATA}" -n_event=${EVENT_ID} -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="${EVENT_UNIQUE_ID}" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="${LOCAL_FILE_WITH_DATA}" -n_event=${EVENT_ID} -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="${EVENT_UNIQUE_ID}" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL}
# Move generated file to final location # Move generated file to final location
...@@ -396,8 +411,10 @@ elif [ "$SAMPLE" = "false" ]; then ...@@ -396,8 +411,10 @@ elif [ "$SAMPLE" = "false" ]; then
echo "Too little particles (minimum accepted is $MIN_PARTICLES). Continue." echo "Too little particles (minimum accepted is $MIN_PARTICLES). Continue."
elif [[ $NUMBER_OF_PARTICLES -gt $MAX_PARTICLES ]]; then elif [[ $NUMBER_OF_PARTICLES -gt $MAX_PARTICLES ]]; then
echo "Too many particles (maximum accepted is $MAX_PARTICLES). Continue." echo "Too many particles (maximum accepted is $MAX_PARTICLES). Continue."
else elif [[ $EVENT_COUNTER -ge $N_OF_EVENTS ]]; then
echo "Numbers of events set to be animated has already been reached." echo "Numbers of events set to be animated has already been reached. Continue."
elif [[ $AVERAGE_PZ -lt $MIN_AVG_PZ ]]; then
echo "Average Z Momentum too low (minimum accepted is $MIN_AVG_PZ). Continue."
fi fi
# Remove non-processed files # Remove non-processed files
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment