...
 
Commits (4)
......@@ -28,11 +28,15 @@
#include "AliESDInputHandler.h"
#include "AliAnalysisTaskMyTask.h"
#include "AliESDtrack.h"
#include "Riostream.h"
#include "AliESDVertex.h"
#include "AliVertex.h"
#include "Riostream.h"
Int_t esd_event_id = 0; // global variable to store unique event id
Int_t smallEventID = 0; // is equal to esd-event-id until the selected event (one with an appropriate number of tracks) is reached
Int_t mediumEventID = 0; // for events with ~200 tracks
Int_t largeEventID = 0; // for events with many many tracks
class AliAnalysisTaskMyTask; // your analysis class
......@@ -41,14 +45,14 @@ using namespace std; // std namespace: so you can do things like 'cou
ClassImp(AliAnalysisTaskMyTask) // classimp: necessary for root
AliAnalysisTaskMyTask::AliAnalysisTaskMyTask() : AliAnalysisTaskSE(),
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0)
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0), fHistMass(0)
{
// default constructor, don't allocate memory here!
// this is used by root for IO purposes, it needs to remain empty
}
//_____________________________________________________________________________
AliAnalysisTaskMyTask::AliAnalysisTaskMyTask(const char* name) : AliAnalysisTaskSE(name),
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0)
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0), fHistMass(0)
{
// constructor
DefineInput(0, TChain::Class()); // define the input of the analysis: in this case we take a 'chain' of events
......@@ -89,6 +93,12 @@ void AliAnalysisTaskMyTask::UserCreateOutputObjects()
fOutputList->Add(fHistPt); // don't forget to add it to the list! the list will be written to file, so if you want
// your histogram in the output file, add it to the list!
// my mass histogram
Double_t fHistMassEdges[12] = {0.0,0.0005,0.0405,0.08,0.12,0.13,0.17,0.48,0.52,0.92,0.96,1.0}; // 11 bins =>> has 11+1 = 12 edges
fHistMass = new TH1F("fHistMass","Particle Histogram;M_{particle}", 11, fHistMassEdges);
fOutputList->Add(fHistMass);
// Histograms for dimuons
fHistEvents = new TH1F("fHistEvents","fHistEvents;N_{events}",100,0.,10000.);
......@@ -110,44 +120,105 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Int_t Event=0;
Int_t TrigEvent=0;
ofstream summaryfile, eventsdetail;
summaryfile.open ("events_summary.txt",std::ofstream::app);
eventsdetail.open ("events_detail.txt",std::ofstream::app);
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);
fESD = dynamic_cast<AliESDEvent*>(InputEvent()); // get an event (called fESD) from the input file
// there's another event format (ESD) which works in a similar wya
// there's another event format (ESD) which works in a similar way
// but is more cpu/memory unfriendly. for now, we'll stick with aod's
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
// 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
Double_t vX = fESD->GetPrimaryVertex()->GetX();
Double_t vY = fESD->GetPrimaryVertex()->GetY();
Double_t vZ = fESD->GetPrimaryVertex()->GetZ();
Double_t Vx = 0.01 * fESD->GetPrimaryVertex()->GetX(); // gets vertexes from individual events, in METERS
Double_t Vy = 0.01 * fESD->GetPrimaryVertex()->GetY();
Double_t Vz = 0.01 * fESD->GetPrimaryVertex()->GetZ();
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)
*/
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
// Add Event details to summaryfile and eventsdetail
summaryfile << " Event " << esd_event_id << ": iTracks = " << iTracks << " Vertex: X = " << vX << " Y = " << vY << " Z = " << vZ << endl;
eventsdetail << "********** Event " << esd_event_id << ": iTracks = " << iTracks << " **********" << endl;
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
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.
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();
Double_t Charge = track->Charge();
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;
}
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;
}
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;
fHistPt->Fill(Pt); // plot the pt value of the track in a histogram
fHistMass->Fill(Mass);
}
}
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
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;
fHistPt->Fill(track->Pt()); // plot the pt value of the track in a histogram
}
Event++;
esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event);
summaryfile.close();
eventsdetail.close();
s_detail.close();
m_detail.close();
l_detail.close();
// continue until all the tracks are processed
PostData(1, fOutputList); // stream the results the analysis of this event to
......
......@@ -22,6 +22,7 @@ class AliAnalysisTaskMyTask : public AliAnalysisTaskSE
AliESDEvent* fESD; //! input event
TList* fOutputList; //! output list
TH1F* fHistPt; //! dummy histogram
TH1F* fHistMass; //! my particle histogram!! :D
TH1F* fHistEvents; // Number of events
AliAnalysisTaskMyTask(const AliAnalysisTaskMyTask&); // not implemented
......
# Project Description
This project has the purpose of generating a 3D animation of an ALICE particle collision event, inside the LHC, using data obtained from CERN's Open Data Portal, which makes ESDs - Event Summary Data files, that contain information about such events - open and available for analysis.
ESD files regarding the ALICE experiment can be found on http://opendata.cern.ch/search?page=1&size=20&experiment=ALICE, and they should be processed using the Aliroot software, as indicated by the Instructions section below
The software that makes the animation is Blender, which is free and open source. Blender's 2.79b version should be downloaded for this project, and can be found on https://www.blender.org/download/releases/2-79/
The animation making can be summarized in three basic steps:
1) Downloading of an ESD file (for example, any file on this list: http://opendata.cern.ch/record/1102);
2) Processing of ESD file using Aliroot macros (as indicated further);
3) Run code to generate Blender animation using the ESD processing results.
The code for step 3 can be found in the Blender_animation repository: https://git.cta.if.ufrgs.br/ALICE-open-data/alice-blender-animation/tree/ParticleTypes
# Sample macros for processing AliESDs from CERN Open Data Portal
## Requirements
......@@ -34,7 +51,7 @@ alienv enter AliPhysics/latest-aliroot5-user
```bash
aliroot runAnalysis.C
```
Results will be saved on two text files: `events_summary.txt` and `events_detail.txt`.
Results will be saved on three text files: `s-esd-detail.dat`, for an event with a 'small' number of tracks; `m-esd-detail.dat`, for an event with a medium number of tracks; `l-esd-detail.dat`, for an event with a very large number of tracks.
## Credits
......
void runAnalysis()
{
// Erase output txt files
ofstream summaryfile, eventsdetail;
summaryfile.open ("events_summary.txt");
summaryfile << " " << endl;
summaryfile.close();
ofstream s_detail, m_detail, l_detail;
eventsdetail.open ("events_detail.txt");
eventsdetail << " " << endl;
eventsdetail.close();
s_detail.open ("s-esd-detail.dat");
s_detail << " " << endl;
s_detail.close();
m_detail.open ("m-esd-detail.dat");
m_detail << " " << endl;
m_detail.close();
l_detail.open ("l-esd-detail.dat");
l_detail << " " << endl;
l_detail.close();
// since we will compile a class, tell root where to look for headers
gROOT->ProcessLine(".include $ROOTSYS/include");
......@@ -36,7 +39,9 @@ void runAnalysis()
// if you want to run locally, we need to define some input
TChain* chain = new TChain("esdTree");
// add a few files to the chain (change this so that your local files are added)
chain->Add("AliESDs.root");
chain->Add("AliESDs.root"); // Breno put it on the same directory that was cloned from Pezzi's // repository: AliESD_Example
chain->Add("AliESDs2.root");
//chain->Add("../root_files/AliAOD.Muons2.root");
//chain->Add("../root_files/AliAOD.Muons3.root");
//chain->Add("../root_files/AliAOD.Muons4.root");
......