Commit d0c379b0 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬
Browse files

Replace AliAnalysisTaskMyTask.cxx with standard example

parent 0cc6bcd6
...@@ -111,16 +111,17 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -111,16 +111,17 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Int_t Event=0; Int_t Event=0;
Int_t TrigEvent=0; Int_t TrigEvent=0;
ofstream summary, detail; ofstream summaryfile, eventsdetail, vertexdetail;
summary.open ("esd-summary.dat",std::ofstream::app); summaryfile.open ("events_summary.txt",std::ofstream::app);
detail.open ("esd-detail.dat",std::ofstream::app); eventsdetail.open ("events_detail.txt",std::ofstream::app);
fESD = dynamic_cast<AliESDEvent*>(InputEvent()); // get an event (called fESD) from the input file 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 way // 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 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
...@@ -132,7 +133,13 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -132,7 +133,13 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Double_t Vz = fESD->GetPrimaryVertex()->GetZ(); Double_t Vz = fESD->GetPrimaryVertex()->GetZ();
Double_t MagneticField = fESD->GetMagneticField(); Double_t MagneticField = fESD->GetMagneticField();
summary << iTracks << " " << Vx << " " << Vy << " " << Vz << " " << MagneticField << endl; // Add Event details to summaryfile and eventsdetail
summaryfile << " Event " << esd_event_id << ": iTracks = " << iTracks << endl;
summaryfile << " Magnetic Field: " << MagneticField << endl;
summaryfile << " Vertex: " << endl << " X = " << Vx << endl << " Y = " << Vy << endl << " Z = " << Vz << endl << endl;
eventsdetail << "\n" << "********** Event " << esd_event_id << ": iTracks = " << iTracks << " **********" << endl << endl;
eventsdetail << "Event\tTrack\tMass\t\tEnergy\t\tPx\t\tPy\t\tPt(file)\tPt(calculado)\tPz\t\tCharge" << endl << endl;
/* /*
...@@ -140,6 +147,9 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || ...@@ -140,6 +147,9 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
*/ */
vertexdetail << "********** Event " << esd_event_id << ": iTracks = " << iTracks << " **********" << endl << endl;
vertexdetail << "Event\tTrack\tGetY()\tGetZ()" << endl << endl;
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
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
...@@ -155,20 +165,24 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || ...@@ -155,20 +165,24 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
Double_t Pz = track->Pz(); Double_t Pz = track->Pz();
Double_t Charge = track->Charge(); Double_t Charge = track->Charge();
// Add MASS, CHARGE, MOMENTUM (x, y, z) to esd-detail.dat file // Add EVENT, TRACK NUMBER, MASS, ENERGY, corresponding MOMENTUM (x, y, transversal, z) and CHARGE to eventsdetail txt file
detail << fixed << Mass << " " << Charge << " "; eventsdetail << esd_event_id << "\t" << i << "\t";
detail << fixed << Px << " " << Py << " " << Pz << endl; eventsdetail << fixed << Mass << "\t" << Energy << "\t";
eventsdetail << fixed << Px << "\t" << Py << " \t " << Pt << " \t " << PtCal << " \t " << Pz << "\t" << Charge << endl;
//'fixed' fixes the number of decimal places so numbers are vertically aligned //'fixed' fixes the number of decimal places so numbers are vertically aligned
vertexdetail << esd_event_id << "\t" << i << "\t" << fixed << track->GetY() << "\t" << track->GetZ() << "\t" << 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++; // Increment global esd_event_id esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event); fHistEvents->Fill(Event);
summary.close(); summaryfile.close();
detail.close(); eventsdetail.close();
vertexdetail.close();
// continue until all the tracks are processed // continue until all the tracks are processed
PostData(1, fOutputList); // stream the results the analysis of this event to PostData(1, fOutputList); // stream the results the analysis of this event to
......
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