Commit 759970d8 authored by Rafael Peretti Pezzi's avatar Rafael Peretti Pezzi

Improving documentation on README.md and additional comments

parent 4669fd83
...@@ -28,17 +28,10 @@ ...@@ -28,17 +28,10 @@
#include "AliESDInputHandler.h" #include "AliESDInputHandler.h"
#include "AliAnalysisTaskMyTask.h" #include "AliAnalysisTaskMyTask.h"
#include "AliESDtrack.h" #include "AliESDtrack.h"
//From Javier Task
#include "AliVEvent.h"
#include "TLorentzVector.h"
#include "TParticle.h"
#include "AliESDtrack.h"
#include "AliAODTrack.h"
#include "Riostream.h" #include "Riostream.h"
Int_t esd_event_id = 0; Int_t esd_event_id = 0; // global variable to store unique event id
class AliAnalysisTaskMyTask; // your analysis class class AliAnalysisTaskMyTask; // your analysis class
...@@ -130,18 +123,23 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -130,18 +123,23 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
if(!fESD) return; // if the pointer to the event is empty (getting it failed) skip this event if(!fESD) return; // if the pointer to the event is empty (getting it failed) skip this event
// example part: i'll show how to loop over the tracks in an event // example part: i'll show how to loop over the tracks in an event
// and extract some information from them which we'll store in a histogram // and extract some information from them which we'll store in a histogram
Int_t iTracks(fESD->GetNumberOfTracks()); // see how many tracks there are in the event Int_t iTracks(fESD->GetNumberOfTracks()); // see how many tracks there are in the event
// Add Event details to summaryfile and eventsdetail
summaryfile << " Event " << esd_event_id << ": iTracks = " << iTracks << endl; summaryfile << " Event " << esd_event_id << ": iTracks = " << iTracks << endl;
eventsdetail << "********** Event " << esd_event_id << ": iTracks = " << iTracks << " **********" << endl; eventsdetail << "********** Event " << esd_event_id << ": iTracks = " << iTracks << " **********" << endl;
for(Int_t i(0); i < iTracks; i++) { // loop ove rall these tracks for(Int_t i(0); i < iTracks; i++) { // loop ove rall these tracks
AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(i)); // get a track (type AliESDtrack) from the event 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(!track) continue; // if we failed, skip this track
// Add track number and corresponting pt to eventsdetail txt file
eventsdetail << esd_event_id << " " << i << " " << track->Pt() << endl; eventsdetail << esd_event_id << " " << i << " " << track->Pt() << endl;
fHistPt->Fill(track->Pt()); // plot the pt value of the track in a histogram fHistPt->Fill(track->Pt()); // plot the pt value of the track in a histogram
} }
Event++; Event++;
esd_event_id++; esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event); fHistEvents->Fill(Event);
summaryfile.close(); summaryfile.close();
eventsdetail.close(); eventsdetail.close();
......
# Sample macros for processing AliESDs from CERN Open Data Portal # Sample macros for processing AliESDs from CERN Open Data Portal
Execute with aliroot (root5) ## Requirements
`$ aliroot runAnalysis.C`
Execute with aliroot5. Place `AliESDs.root` files in reach of the `chain->Add("AliESDs.root");` line on `runAnalysis.C` and execute.
## Instructions
1) Install aliBuild. Follow instructions on https://alice-doc.github.io/alice-analysis-tutorial/building/custom.html
2) Initialize AliPhysics
```bash
mkdir -p ~/alice
cd ~/alice
aliBuild init AliPhysics@master
```
3) Verify dependencies (Optional)
```bash
$ aliDoctor AliPhysics
```
4) Build AliPhysics with aliroot5 (this may take a long time)
```bash
aliBuild build AliPhysics --defaults user -z aliroot5
```
5) Enter AliPhysics environment
```bash
alienv enter AliPhysics/latest-aliroot5-user
```
6) Run the macro
```bash
aliroot runAnalysis.C
```
Results will be saved on two text files: `events_summary.txt` and `events_detail.txt`.
## Credits ## Credits
This example was based on works by Redmer A. Bertens (Analysis tutorial) This example is based on the ALICE analysis tutorial by Redmer A. Bertens.
void runAnalysis() void runAnalysis()
{ {
// Erase output txt files
ofstream summaryfile, eventsdetail; ofstream summaryfile, eventsdetail;
summaryfile.open ("events_summary.txt"); summaryfile.open ("events_summary.txt");
summaryfile << " " << endl; summaryfile << " " << endl;
......
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