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

Generate text files for different number of tracks range

parent e6fcd0dd
......@@ -34,7 +34,9 @@
Int_t esd_event_id = 0; // global variable to store unique event id
Int_t EventID = 0; // is equal to esd-event-id until the selected event (one with an appropriate number of tracks) is reached
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
......@@ -118,15 +120,17 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Int_t Event=0;
Int_t TrigEvent=0;
ofstream detail;
detail.open ("esd-detail.dat",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 way
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
......@@ -145,40 +149,66 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
*/
if(EventID == esd_event_id) {
if(iTracks >= 15 && iTracks <= 30) {EventID = -1;}
else {EventID++;}
} else {EventID = -2;}
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(EventID == -1) { // when we get to the selected event, fill histograms and write data
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();
AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(i)); // get a track (type AliESDtrack) from the event
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(!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.
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();
fHistPt->Fill(Pt); // plot the pt value of the track in a histogram
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
detail << Vx << " " << Vy << " " << Vz << " ";
detail << Mass << " " << Charge << " ";
detail << Px << " " << Py << " " << Pz << endl;
fHistMass->Fill(Mass);
}
fHistPt->Fill(Pt); // plot the pt value of the track in a histogram
fHistMass->Fill(Mass);
}
}
}
......@@ -186,7 +216,9 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
Event++;
esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event);
detail.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
......
void runAnalysis()
{
// Erase output txt files
ofstream detail;
ofstream s_detail, m_detail, l_detail;
detail.open ("esd-detail.dat");
detail << " " << endl;
detail.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");
......
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