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

Plot histogram for absolute value of average Pz in each event

parent dca7a9c4
...@@ -42,14 +42,14 @@ using namespace std; // std namespace: so you can do things like 'cou ...@@ -42,14 +42,14 @@ using namespace std; // std namespace: so you can do things like 'cou
ClassImp(AliAnalysisTaskMyTask) // classimp: necessary for root ClassImp(AliAnalysisTaskMyTask) // classimp: necessary for root
AliAnalysisTaskMyTask::AliAnalysisTaskMyTask() : AliAnalysisTaskSE(), AliAnalysisTaskMyTask::AliAnalysisTaskMyTask() : AliAnalysisTaskSE(),
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0), fHistMass(0) fESD(0), fOutputList(0), fHistPt(0), fHistAvgPz(0), fHistMass(0)
{ {
// default constructor, don't allocate memory here! // default constructor, don't allocate memory here!
// this is used by root for IO purposes, it needs to remain empty // this is used by root for IO purposes, it needs to remain empty
} }
//_____________________________________________________________________________ //_____________________________________________________________________________
AliAnalysisTaskMyTask::AliAnalysisTaskMyTask(const char* name) : AliAnalysisTaskSE(name), AliAnalysisTaskMyTask::AliAnalysisTaskMyTask(const char* name) : AliAnalysisTaskSE(name),
fESD(0), fOutputList(0), fHistPt(0), fHistEvents(0), fHistMass(0) fESD(0), fOutputList(0), fHistPt(0), fHistAvgPz(0), fHistMass(0)
{ {
// constructor // constructor
DefineInput(0, TChain::Class()); // define the input of the analysis: in this case we take a 'chain' of events DefineInput(0, TChain::Class()); // define the input of the analysis: in this case we take a 'chain' of events
...@@ -86,22 +86,20 @@ void AliAnalysisTaskMyTask::UserCreateOutputObjects() ...@@ -86,22 +86,20 @@ void AliAnalysisTaskMyTask::UserCreateOutputObjects()
// if requested (dont worry about this now) // if requested (dont worry about this now)
// example of a histogram // example of a histogram
fHistPt = new TH1F("fHistPt", "fHistPt", 100, 0, 10); // create your histogra fHistPt = new TH1F("fHistPt", "fHistPt", 100, 0, 10); // create histogram
fOutputList->Add(fHistPt); // don't forget to add it to the list! the list will be written to file, so if you want 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! // your histogram in the output file, add it to the list!
// |<Pz>| histogram: absolute value of average Pz (or Pz per track) for each event
fHistAvgPz = new TH1F("fHistAvgPz", "fHistAvgPz", 100, 0, 0.1); // create histogram
fOutputList->Add(fHistAvgPz);
// my mass histogram // 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 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); fHistMass = new TH1F("fHistMass","Particle Histogram;M_{particle}", 11, fHistMassEdges);
fOutputList->Add(fHistMass); fOutputList->Add(fHistMass);
// Histograms for dimuons
fHistEvents = new TH1F("fHistEvents","fHistEvents;N_{events}",100,0.,10000.);
fOutputList->Add(fHistEvents);
PostData(1, fOutputList); // postdata will notify the analysis manager of changes / updates to the PostData(1, fOutputList); // postdata will notify the analysis manager of changes / updates to the
// fOutputList object. the manager will in the end take care of writing your output to file // fOutputList object. the manager will in the end take care of writing your output to file
// so it needs to know what's in the output // so it needs to know what's in the output
...@@ -118,8 +116,6 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -118,8 +116,6 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
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
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
...@@ -155,6 +151,8 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -155,6 +151,8 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data
Double_t PzSum = 0;
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
...@@ -169,6 +167,8 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -169,6 +167,8 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
Double_t Pt = track->Pt(); // transversal momentum, in case we need it Double_t Pt = track->Pt(); // transversal momentum, in case we need it
Double_t Pz = track->Pz(); Double_t Pz = track->Pz();
PzSum += Pz/iTracks; // Pz sum for |<Pz>| histogram
Double_t Charge = track->Charge(); Double_t Charge = track->Charge();
// Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file // Add VERTEX (x, y, z), MASS, CHARGE and MOMENTUM (x, y, z) to esd-detail.dat file
...@@ -181,7 +181,11 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven ...@@ -181,7 +181,11 @@ void AliAnalysisTaskMyTask::export_to_our_ESD_textual_format (Int_t selectedEven
fHistMass->Fill(Mass); fHistMass->Fill(Mass);
} }
if(PzSum>0) {
fHistAvgPz->Fill(PzSum);
} else {
fHistAvgPz->Fill(-PzSum);
}
} }
esd_detail.close(); esd_detail.close();
...@@ -201,8 +205,6 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -201,8 +205,6 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
esd_event_id++; // Increment global esd_event_id esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(esd_event_id);
// 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
// the output manager which will take care of writing // the output manager which will take care of writing
......
...@@ -22,9 +22,9 @@ class AliAnalysisTaskMyTask : public AliAnalysisTaskSE ...@@ -22,9 +22,9 @@ class AliAnalysisTaskMyTask : public AliAnalysisTaskSE
private: private:
AliESDEvent* fESD; //! input event AliESDEvent* fESD; //! input event
TList* fOutputList; //! output list TList* fOutputList; //! output list
TH1F* fHistPt; //! dummy histogram TH1F* fHistPt; //! Pt histogram
TH1F* fHistAvgPz; //! |<Pz>| histogram
TH1F* fHistMass; //! my particle histogram!! :D TH1F* fHistMass; //! my particle histogram!! :D
TH1F* fHistEvents; // Number of events
void export_to_our_ESD_textual_format (Int_t selectedEventID); void export_to_our_ESD_textual_format (Int_t selectedEventID);
AliAnalysisTaskMyTask(const AliAnalysisTaskMyTask&); // not implemented AliAnalysisTaskMyTask(const AliAnalysisTaskMyTask&); // not implemented
......
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