Generation of muon filtered AOD files from standard AOD files (Roberta)
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Oct 2009 07:14:52 +0000 (07:14 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Oct 2009 07:14:52 +0000 (07:14 +0000)
PWG3/CMake_libPWG3muon.txt
PWG3/PWG3muonLinkDef.h
PWG3/libPWG3muon.pkg
PWG3/muon/AddTaskMuonAODCreation.C [new file with mode: 0644]
PWG3/muon/AliAnalysisTaskMuonAODCreation.cxx [new file with mode: 0755]
PWG3/muon/AliAnalysisTaskMuonAODCreation.h [new file with mode: 0755]

index 6a2dbb1..5ee8273 100644 (file)
@@ -15,6 +15,7 @@ set(SRCS
                  muon/AliCFMuonResTask1.cxx
                  muon/AliEventPoolMuon.cxx
                  muon/AliAnalysisTaskCreateMixedDimuons.cxx
+                muon/AliAnalysisTaskMuonAODCreation.cxx
 )
 
 # fill list of header files from list of source files
index b93983e..c440df8 100644 (file)
@@ -18,6 +18,7 @@
 #pragma link C++ class AliCFMuonResTask1+;
 #pragma link C++ class AliEventPoolMuon+;
 #pragma link C++ class AliAnalysisTaskCreateMixedDimuons+;
+#pragma link C++ class AliAnalysisTaskMuonAODCreation+;
 #endif
 
 
index 15d0547..f5417c3 100644 (file)
@@ -13,7 +13,8 @@ SRCS:=         muon/AliAnalysisTaskESDMuonFilter.cxx \
                  muon/AliAnalysisTaskSingleMuESD.cxx \
                  muon/AliCFMuonResTask1.cxx \
                  muon/AliEventPoolMuon.cxx \
-                 muon/AliAnalysisTaskCreateMixedDimuons.cxx
+                 muon/AliAnalysisTaskCreateMixedDimuons.cxx \
+                muon/AliAnalysisTaskMuonAODCreation.cxx
 
 HDRS:= $(SRCS:.cxx=.h)
 
diff --git a/PWG3/muon/AddTaskMuonAODCreation.C b/PWG3/muon/AddTaskMuonAODCreation.C
new file mode 100644 (file)
index 0000000..8933132
--- /dev/null
@@ -0,0 +1,32 @@
+AliAnalysisTaskMuonAODCreation *AddTaskMuonAODCreation()
+{
+// Creates a filter task to copy muon tracks from the Standard AOD to the Muon AOD
+// R. Arnaldi - 6/10/09
+
+   // Get the pointer to the existing analysis manager via the static access method.
+   //==============================================================================
+   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+   if (!mgr) {
+      ::Error("AddTaskMuonAODCreation", "No analysis manager to connect to.");
+      return NULL;
+   }   
+   
+   // Get input handler
+   TString type = mgr->GetInputEventHandler()->GetDataType();
+
+   // Define output
+   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("chist0",TList::Class(),AliAnalysisManager::kOutputContainer,"MuonPlots.root");
+
+   // Create the task, add it to the manager and configure it.
+   //===========================================================================   
+   AliAnalysisTaskMuonAODCreation *muonAODtask = new AliAnalysisTaskMuonAODCreation("Muon AOD creation");
+   mgr->AddTask(muonAODtask);
+   
+   // Create ONLY the output containers for the data produced by the task.
+   // Get and connect other common input/output containers via the manager as below
+   //==============================================================================
+   mgr->ConnectInput  (muonAODtask,  0, mgr->GetCommonInputContainer());
+   mgr->ConnectOutput (muonAODtask,  0, mgr->GetCommonOutputContainer());
+   mgr->ConnectOutput (muonAODtask,  1, coutput1);
+   return muonAODtask;
+}   
diff --git a/PWG3/muon/AliAnalysisTaskMuonAODCreation.cxx b/PWG3/muon/AliAnalysisTaskMuonAODCreation.cxx
new file mode 100755 (executable)
index 0000000..1e54e33
--- /dev/null
@@ -0,0 +1,153 @@
+//#ifndef ALIANALYSISTASKMUONAODCREATION_CXX
+//#define ALIANALYSISTASKMUONAODCREATION_CXX
+
+#include <TChain.h>
+#include <TTree.h>
+#include <TList.h>
+#include <TCanvas.h>
+#include <TClonesArray.h>
+#include <TH1.h>
+
+#include "AliAnalysisTaskMuonAODCreation.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataSlot.h"
+#include "AliESDEvent.h"
+#include "AliESD.h"
+#include "AliAODEvent.h"
+#include "AliAODHeader.h"
+#include "AliVEvent.h"
+#include "AliAODHandler.h"
+#include "AliAODInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliInputEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+#include "AliLog.h"
+
+ClassImp(AliAnalysisTaskMuonAODCreation)
+
+//__________________________________________________________________________
+AliAnalysisTaskMuonAODCreation::AliAnalysisTaskMuonAODCreation() :
+  fOutput(0x0),
+  fTree(0x0),
+  fOutputAOD(0x0)
+{
+}
+//___________________________________________________________________________
+AliAnalysisTaskMuonAODCreation::AliAnalysisTaskMuonAODCreation(const Char_t* name) :
+  AliAnalysisTaskSE(name),
+  fOutput(0x0),
+  fTree(0x0),
+  fOutputAOD(0x0)
+{
+  // Constructor. Initialization of Inputs and Outputs
+  //
+    
+  DefineOutput(1,TList::Class());
+
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskMuonAODCreation& AliAnalysisTaskMuonAODCreation::operator=(const AliAnalysisTaskMuonAODCreation& c) 
+{
+  //
+  // Assignment operator
+  //
+  if (this!=&c) {
+    AliAnalysisTaskSE::operator=(c) ;
+  }
+  return *this;
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskMuonAODCreation::AliAnalysisTaskMuonAODCreation(const AliAnalysisTaskMuonAODCreation& c) :
+  AliAnalysisTaskSE(c),
+  fOutput(c.fOutput),
+  fTree(c.fTree),
+  fOutputAOD(c.fOutputAOD)
+ {
+  //
+  // Copy Constructor                                                                          
+  //
+}
+
+//___________________________________________________________________________
+AliAnalysisTaskMuonAODCreation::~AliAnalysisTaskMuonAODCreation() {
+  //
+  //destructor
+  //
+  Info("~AliAnalysisTaskMuonAODCreation","Calling Destructor");
+}
+
+//___________________________________________________________________________
+void AliAnalysisTaskMuonAODCreation::UserCreateOutputObjects(){
+       
+  AliAODHandler* handler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
+  fOutputAOD   = handler->GetAOD();
+  fTree = handler->GetTree();
+
+  fOutput = new TList();
+  fOutput->SetOwner(); 
+  TH1D *pt_alltracks    = new TH1D("pt_alltracks","pt_alltracks",10,0,20);     
+  TH1D *pt_muontracks    = new TH1D("pt_muontracks","pt_muontracks",10,0,20);  
+       
+  fOutput->Add(pt_alltracks);  
+  fOutput->Add(pt_muontracks);         
+  fOutput->ls(); 
+} 
+
+
+
+//_________________________________________________
+void AliAnalysisTaskMuonAODCreation::UserExec(Option_t *)
+{
+  
+  AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
+  
+  Int_t nMuons=0;
+  for (Int_t j = 0; j<aod->GetNumberOfTracks(); j++) { 
+    AliAODTrack *track = aod->GetTrack(j);
+    ((TH1D*)(fOutput->FindObject("pt_alltracks")))->Fill(track->Pt()); 
+    if(track->IsMuonTrack()) {
+      nMuons++;
+      ((TH1D*)(fOutput->FindObject("pt_muontracks")))->Fill(track->Pt()); 
+    }  
+  }
+         
+  AliAODHandler* outputHandler = (AliAODHandler*) 
+      ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());        
+   
+  outputHandler->SetFillAOD(kFALSE);
+   
+  if(nMuons>0) { 
+    outputHandler->SetFillAOD(kTRUE);
+   
+    PostData(0,fTree);
+    PostData(1,fOutput);
+  } else {
+    return;
+  }
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonAODCreation::Terminate(Option_t *) 
+{
+  TCanvas *c = new TCanvas("c","plots",20,20,600,600);
+  c->Divide(2,2);
+  
+  TH1D *h_pt_all = dynamic_cast<TH1D*> (fOutput->FindObject("pt_alltracks"));  
+  TH1D *h_pt_muons = dynamic_cast<TH1D*> (fOutput->FindObject("pt_muontracks"));  
+  c->cd(1);
+  h_pt_all->Draw();
+  c->cd(2);
+  h_pt_muons->Draw();
+  c->cd(3);
+  h_pt_all->Draw();
+  h_pt_muons->Draw("same");
+}
+
diff --git a/PWG3/muon/AliAnalysisTaskMuonAODCreation.h b/PWG3/muon/AliAnalysisTaskMuonAODCreation.h
new file mode 100755 (executable)
index 0000000..0c33a35
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef ALIANALYSISTASKMUONAODCREATION_H
+#define ALIANALYSISTASKMUONAODCREATION_H
+
+#include <TChain.h>
+#include <TTree.h>
+#include <TList.h>
+#include <TH1.h>
+#include <TClonesArray.h>
+
+#include "TMath.h"
+
+#include "AliAnalysisTaskMuonAODCreation.h"
+#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisManager.h"
+#include "AliAODEvent.h"
+#include "AliLog.h"
+#include "AliAODTrack.h"
+#include "AliAODInputHandler.h"
+#include "AliAODHeader.h"
+
+class AliAnalysisTaskMuonAODCreation : public AliAnalysisTaskSE {
+  public:
+
+  AliAnalysisTaskMuonAODCreation();
+  AliAnalysisTaskMuonAODCreation(const Char_t* name);
+  AliAnalysisTaskMuonAODCreation& operator= (const AliAnalysisTaskMuonAODCreation& c);
+  AliAnalysisTaskMuonAODCreation(const AliAnalysisTaskMuonAODCreation& c);
+  virtual ~AliAnalysisTaskMuonAODCreation();
+
+  // ANALYSIS FRAMEWORK STUFF to loop on data and fill output objects
+  void     UserExec(Option_t *option);
+  void     Terminate(Option_t *);
+  void     UserCreateOutputObjects();
+  
+ protected:
+  
+  TList  *fOutput;
+  TTree *fTree;           //  AOD output Tree
+  AliAODEvent *fOutputAOD;       //! AOD out 
+  
+  ClassDef(AliAnalysisTaskMuonAODCreation,1);
+};
+
+#endif