Commit 598c9220 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬

Add selected event as input argument of runAnalysis.C

parent 3a2f7ea6
......@@ -54,22 +54,16 @@ aliBuild build AliPhysics --defaults user -z aliroot5
```bash
alienv enter AliPhysics/latest-aliroot5-user
```
6) Run the macro
6) Run the macro with number of ESD event as an input
```bash
cd ~/alice/alice-blender-animation/aliRoot
aliroot runAnalysis.C
aliroot -q -b "runAnalysis.C(7)"
```
Number seven is just an example. An empty input will do the analysis on event number 0.
With the last step, ESD analysis results will be saved on three text files:
- `s-esd-detail.dat`, for an event with a 'small' number of tracks (between 15 and 30 tracks);
- `m-esd-detail.dat`, for an event with a 'medium' number of tracks (between 100 and 300 tracks);
- `l-esd-detail.dat`, for an event with a 'very large' number of tracks (between 5000 and 50000 tracks).
You must then move those three files into the 'animate' folder, where the Blender scripts are.
With the last step, ESD analysis results will be saved on a text file called `esd-detail.dat`. You must then move this file into the 'animate' folder, where the Blender scripts are.
## Step 3 - Generating animation
......@@ -83,7 +77,7 @@ cd ~/alice/alice-blender-animation/animate
Run the python script `animate_particles.py` as in the example below:
```bash
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=10 -camera="BarrelCamera" -datafile="s-esd-detail.dat" -simulated_t=0.02 -fps=24 -resolution=100
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=10 -camera="OverviewCamera" -datafile="esd-detail.dat" -simulated_t=0.02 -fps=24 -resolution=100
```
where everything that follows the double dashes are input arguments for generating the animation. Here is what each argument means:
......@@ -105,7 +99,7 @@ defines animation point of view; must be a string; available options: "OverviewC
-datafile:
filename for event data file; must be a string; must be one of your text files: "s-esd-detail.dat", "m-esd-detail.dat", "l-esd-detail.dat"
filename for event data file; must be a string; must the name your text file: "esd-detail.dat"
-simulated_t:
......
......@@ -120,10 +120,15 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Int_t Event=0;
Int_t TrigEvent=0;
ofstream s_detail, m_detail, l_detail;
s_detail.open ("s-esd-detail.dat",std::ofstream::app);
m_detail.open ("m-esd-detail.dat",std::ofstream::app);
l_detail.open ("l-esd-detail.dat",std::ofstream::app);
Int_t selectedEventID;
ifstream s_event;
s_event.open ("s-event.dat",std::ifstream::in);
s_event >> selectedEventID;
s_event.close();
ofstream esd_detail;
esd_detail.open ("esd-detail.dat",std::ofstream::app);
fESD = dynamic_cast<AliESDEvent*>(InputEvent()); // get an event (called fESD) from the input file
......@@ -149,66 +154,34 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
*/
if(smallEventID == esd_event_id) {
if(iTracks >= 15 && iTracks <= 30) {smallEventID = -1;}
else {smallEventID++;}
} else {smallEventID = -2;}
if(mediumEventID == esd_event_id) {
if(iTracks >= 100 && iTracks <= 300) {mediumEventID = -1;}
else {mediumEventID++;}
} else {mediumEventID = -2;}
if(largeEventID == esd_event_id) {
if(iTracks >= 5000 && iTracks <= 50000) {largeEventID = -1;}
else {largeEventID++;}
} else {largeEventID = -2;}
for(Int_t i(0); i < iTracks; i++) { // loop over all these tracks
if(smallEventID == -1 || mediumEventID == -1 || largeEventID == -1) { // when we get to the selected event, fill histograms and write data
AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(i)); // get a track (type AliESDtrack) from the event
if(!track) continue; // if we failed, skip this track
if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data
Double_t Mass = track->M(); // returns the pion mass, if the particle can't be identified properly
Double_t Energy = track->E(); // Returns the energy of the particle given its assumed mass, but assumes the pion mass if the particle can't be identified properly.
for(Int_t i(0); i < iTracks; i++) { // loop over all these tracks
Double_t Px = track->Px();
Double_t Py = track->Py();
Double_t Pt = track->Pt(); // transversal momentum, in case we need it
Double_t Pz = track->Pz();
AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(i)); // get a track (type AliESDtrack) from the event
Double_t Charge = track->Charge();
if(!track) continue; // if we failed, skip this track
if (smallEventID == -1) {
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
s_detail << Vx << " " << Vy << " " << Vz << " ";
s_detail << Mass << " " << Charge << " ";
s_detail << Px << " " << Py << " " << Pz << endl;
}
Double_t Mass = track->M(); // returns the pion mass, if the particle can't be identified properly
Double_t Energy = track->E(); // Returns the energy of the particle given its assumed mass, but assumes the pion mass if the particle can't be identified properly.
if (mediumEventID == -1) {
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
m_detail << Vx << " " << Vy << " " << Vz << " ";
m_detail << Mass << " " << Charge << " ";
m_detail << Px << " " << Py << " " << Pz << endl;
}
Double_t Px = track->Px();
Double_t Py = track->Py();
Double_t Pt = track->Pt(); // transversal momentum, in case we need it
Double_t Pz = track->Pz();
if (largeEventID == -1) {
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
l_detail << Vx << " " << Vy << " " << Vz << " ";
l_detail << Mass << " " << Charge << " ";
l_detail << Px << " " << Py << " " << Pz << endl;
Double_t Charge = track->Charge();
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
esd_detail << Vx << " " << Vy << " " << Vz << " ";
esd_detail << Mass << " " << Charge << " ";
esd_detail << Px << " " << Py << " " << Pz << endl;
fHistPt->Fill(Pt); // plot the pt value of the track in a histogram
fHistPt->Fill(Pt); // plot the pt value of the track in a histogram
fHistMass->Fill(Mass);
}
fHistMass->Fill(Mass);
}
}
}
......@@ -216,9 +189,7 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
Event++;
esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event);
s_detail.close();
m_detail.close();
l_detail.close();
esd_detail.close();
// continue until all the tracks are processed
PostData(1, fOutputList); // stream the results the analysis of this event to
......
void runAnalysis()
// Run:
//
// $ aliroot -q -b "runAnalysis.C(selected-event)"
//
// 'selected-event' is the desired event number inside the ESD file
// Leaving it blank will select event 0
//
int runAnalysis(int selected_event=0)
{
// Erase output txt files
ofstream s_detail, m_detail, l_detail;
ofstream esd_detail, s_event;
s_detail.open ("s-esd-detail.dat");
s_detail.close();
s_event.open ("s-event.dat");
s_event << selected_event;
s_event.close();
m_detail.open ("m-esd-detail.dat");
m_detail.close();
l_detail.open ("l-esd-detail.dat");
l_detail.close();
esd_detail.open ("esd-detail.dat");
esd_detail.close();
// since we will compile a class, tell root where to look for headers
gROOT->ProcessLine(".include $ROOTSYS/include");
......@@ -46,6 +52,7 @@ void runAnalysis()
// start the analysis locally, reading the events from the tchain
mgr->StartAnalysis("local", chain);
remove("s-event.dat");
exit();
}
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