Update of the class ESDMuonFilter. New marcros for creating AOD with muon information...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 May 2008 09:57:02 +0000 (09:57 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 6 May 2008 09:57:02 +0000 (09:57 +0000)
PWG3/muon/AliAnalysisTaskESDMuonFilter.cxx
PWG3/muon/AliAnalysisTaskESDMuonFilter.h
PWG3/muon/AnalysisTrainMuonCAF.C [new file with mode: 0644]
PWG3/muon/AnalysisTrainMuonLocal.C [new file with mode: 0644]

index b89e039..d43a3ff 100644 (file)
-/**************************************************************************
- * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                                                        *
- * Author: The ALICE Off-line Project.                                    *
- * Contributors are mentioned in the code where appropriate.              *
- *                                                                        *
- * Permission to use, copy, modify and distribute this software and its   *
- * documentation strictly for non-commercial purposes is hereby granted   *
- * without fee, provided that the above copyright notice appears in all   *
- * copies and that both the copyright notice and this permission notice   *
- * appear in the supporting documentation. The authors make no claims     *
- * about the suitability of this software for any purpose. It is          *
- * provided "as is" without express or implied warranty.                  *
- **************************************************************************/
-
-/* $Id: AliAnalysisTaskESDMuonFilter.cxx 24535 2008-03-16 22:43:30Z fca $ */
-#include <TChain.h>
-#include <TFile.h>
-
-#include "AliAnalysisTaskESDMuonFilter.h"
-#include "AliAnalysisManager.h"
-#include "AliESDEvent.h"
-#include "AliAODEvent.h"
-#include "AliESDInputHandler.h"
-#include "AliAODHandler.h"
-#include "AliAnalysisFilter.h"
-#include "AliESDtrack.h"
-#include "AliESDMuonTrack.h"
-#include "AliESDVertex.h"
-#include "AliMultiplicity.h"
-#include "AliLog.h"
-
-ClassImp(AliAnalysisTaskESDMuonFilter)
-
-////////////////////////////////////////////////////////////////////////
-
-AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter():
-    AliAnalysisTaskSE(),
-    fTrackFilter(0x0)
-{
-  // Default constructor
-}
-
-AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter(const char* name):
-    AliAnalysisTaskSE(name),
-    fTrackFilter(0x0)
-{
-  // Constructor
-}
-
-void AliAnalysisTaskESDMuonFilter::UserCreateOutputObjects()
-{
-// Create the output container
-    OutputTree()->GetUserInfo()->Add(fTrackFilter);
-}
-
-void AliAnalysisTaskESDMuonFilter::Init()
-{
-    // Initialization
-    if (fDebug > 1) AliInfo("Init() \n");
-    // Call configuration file
-}
-
-
-void AliAnalysisTaskESDMuonFilter::UserExec(Option_t */*option*/)
-{
-// Execute analysis for current event
-//                                         
-  Long64_t ientry = Entry();
-  printf("Filter: Analysing event # %5d\n", (Int_t) ientry);
-
-  ConvertESDtoAOD();
-}
-
-void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD() {
-    // ESD Filter analysis task executed for each event
-    AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
-    AliESD* old = esd->GetAliESDOld();
-    
-    // set arrays and pointers
-    Double_t pos[3];
-    Double_t p[3];
-    Double_t covVtx[6];
-    Double_t covTr[21];
-    Double_t pid[10];
-
-    for (Int_t i = 0; i < 6; i++)  covVtx[i] = 0.;
-    for (Int_t i = 0; i < 21; i++) covTr [i] = 0.;
-
-    
-  // loop over events and fill them
-  
-  // Multiplicity information needed by the header (to be revised!)
-    Int_t nTracks    = esd->GetNumberOfTracks();
-    Int_t nPosTracks = 0;
-    for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) 
-       if (esd->GetTrack(iTrack)->GetSign()> 0) nPosTracks++;
-    
-    // Update the header
-
-    AliAODHeader* header = AODEvent()->GetHeader();
-    header->SetRunNumber(esd->GetRunNumber());
-    if (old) {
-       header->SetBunchCrossNumber(0);
-       header->SetOrbitNumber(0);
-       header->SetPeriodNumber(0);
-       header->SetEventType(0);
-       header->SetMuonMagFieldScale(-999.); // FIXME
-       header->SetCentrality(-999.);        // FIXME
-    } else {
-       header->SetBunchCrossNumber(esd->GetBunchCrossNumber());
-       header->SetOrbitNumber(esd->GetOrbitNumber());
-       header->SetPeriodNumber(esd->GetPeriodNumber());
-       header->SetEventType(esd->GetEventType());
-       header->SetMuonMagFieldScale(-999.); // FIXME
-       header->SetCentrality(-999.);        // FIXME
-    }
-    
-    header->SetTriggerMask(esd->GetTriggerMask()); 
-    header->SetTriggerCluster(esd->GetTriggerCluster());
-    header->SetMagneticField(esd->GetMagneticField());
-    header->SetZDCN1Energy(esd->GetZDCN1Energy());
-    header->SetZDCP1Energy(esd->GetZDCP1Energy());
-    header->SetZDCN2Energy(esd->GetZDCN2Energy());
-    header->SetZDCP2Energy(esd->GetZDCP2Energy());
-    header->SetZDCEMEnergy(esd->GetZDCEMEnergy(0),esd->GetZDCEMEnergy(1));
-    header->SetRefMultiplicity(nTracks);
-    header->SetRefMultiplicityPos(nPosTracks);
-    header->SetRefMultiplicityNeg(nTracks - nPosTracks);
-//
-//    
-    Int_t nV0s      = esd->GetNumberOfV0s();
-    Int_t nCascades = esd->GetNumberOfCascades();
-    Int_t nKinks    = esd->GetNumberOfKinks();
-    Int_t nVertices = nV0s + 2*nCascades /*could lead to two vertices, one V0 and the Xi */+ nKinks + 1 /* = prim. vtx*/;    
-    Int_t nJets     = 0;
-    Int_t nCaloClus = esd->GetNumberOfCaloClusters();
-    Int_t nFmdClus  = 0;
-    Int_t nPmdClus  = esd->GetNumberOfPmdTracks();
-    
-    printf("   NV0=%d  NCASCADES=%d  NKINKS=%d\n", nV0s, nCascades, nKinks);
-
-    AODEvent()->ResetStd(nTracks, nVertices, nV0s+nCascades, nJets, nCaloClus, nFmdClus, nPmdClus);
-
-    AliAODTrack *aodTrack = 0x0;
-    
-    // Access to the AOD container of vertices
-    TClonesArray &vertices = *(AODEvent()->GetVertices());
-    Int_t jVertices=0;
-    
-    // Access to the AOD container of tracks
-    TClonesArray &tracks = *(AODEvent()->GetTracks());
-    Int_t jTracks=0; 
-    
-    // Add primary vertex. 
-    const AliESDVertex *vtx = esd->GetPrimaryVertex();
-    
-    vtx->GetXYZ(pos); // position
-    vtx->GetCovMatrix(covVtx); //covariance matrix
-    
-    AliAODVertex * primary = new(vertices[jVertices++])
-       AliAODVertex(pos, covVtx, vtx->GetChi2toNDF(), NULL, AliAODVertex::kPrimary);
-    primary->Print();
-    
-    // muon tracks
-    Int_t nMuTracks = esd->GetNumberOfMuonTracks();
-    
-    printf("Number of Muon Tracks=%d\n",nMuTracks);
-    
-    for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {
-       
-       AliESDMuonTrack *esdMuTrack = esd->GetMuonTrack(nMuTrack); 
-           
-       p[0] = esdMuTrack->Px(); 
-       p[1] = esdMuTrack->Py(); 
-       p[2] = esdMuTrack->Pz();
-       pos[0] = primary->GetX(); 
-       pos[1] = primary->GetY(); 
-       pos[2] = primary->GetZ();
-       
-       // has to be changed once the muon pid is provided by the ESD
-       for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.;
-       
-//     primary->AddDaughter(
-       primary->AddDaughter(aodTrack =
-           new(tracks[jTracks++]) AliAODTrack(0, // no ID provided
-                                              0, // no label provided
-                                              p,
-                                              kTRUE,
-                                              pos,
-                                              kFALSE,
-                                              NULL, // no covariance matrix provided
-                                              (Short_t)-99, // no charge provided
-                                              0, // no ITSClusterMap
-                                              pid,
-                                              primary,
-                                              kTRUE,  // check if this is right
-                                              kTRUE,  // not used for vertex fit
-                                              AliAODTrack::kPrimary)
-           );
-  
-       aodTrack->ConvertAliPIDtoAODPID();  
-       aodTrack->SetHitsPatternInTrigCh(esdMuTrack->GetHitsPatternInTrigCh());
-       Int_t track2Trigger = esdMuTrack->GetMatchTrigger();
-       aodTrack->SetMatchTrigger(track2Trigger);
-       if (track2Trigger) 
-         aodTrack->SetChi2MatchTrigger(esdMuTrack->GetChi2MatchTrigger());
-       else 
-         aodTrack->SetChi2MatchTrigger(0.);
-    }
-        
-    tracks.Expand(jTracks); // remove 'empty slots' due to unwritten tracks
-  
-
-    return;
-}
-
-void AliAnalysisTaskESDMuonFilter::Terminate(Option_t */*option*/)
-{
-// Terminate analysis
-//
-    if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");
-}
+/**************************************************************************\r
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ *                                                                        *\r
+ * Author: The ALICE Off-line Project.                                    *\r
+ * Contributors are mentioned in the code where appropriate.              *\r
+ *                                                                        *\r
+ * Permission to use, copy, modify and distribute this software and its   *\r
+ * documentation strictly for non-commercial purposes is hereby granted   *\r
+ * without fee, provided that the above copyright notice appears in all   *\r
+ * copies and that both the copyright notice and this permission notice   *\r
+ * appear in the supporting documentation. The authors make no claims     *\r
+ * about the suitability of this software for any purpose. It is          *\r
+ * provided "as is" without express or implied warranty.                  *\r
+ **************************************************************************/\r
+\r
+// Add the muon tracks to the generic AOD track branch during the \r
+// filtering of the ESD - R. Arnaldi 5/5/08\r
\r
+#include <TChain.h>\r
+#include <TFile.h>\r
+\r
+#include "AliAnalysisTaskESDMuonFilter.h"\r
+#include "AliAnalysisManager.h"\r
+#include "AliESDEvent.h"\r
+#include "AliAODEvent.h"\r
+#include "AliESDInputHandler.h"\r
+#include "AliAODHandler.h"\r
+#include "AliAnalysisFilter.h"\r
+#include "AliESDtrack.h"\r
+#include "AliESDMuonTrack.h"\r
+#include "AliESDVertex.h"\r
+#include "AliMultiplicity.h"\r
+#include "AliLog.h"\r
+\r
+ClassImp(AliAnalysisTaskESDMuonFilter)\r
+\r
+////////////////////////////////////////////////////////////////////////\r
+\r
+AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter():\r
+    AliAnalysisTaskSE(),\r
+    fTrackFilter(0x0)\r
+{\r
+  // Default constructor\r
+}\r
+\r
+AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter(const char* name):\r
+    AliAnalysisTaskSE(name),\r
+    fTrackFilter(0x0)\r
+{\r
+  // Constructor\r
+}\r
+\r
+void AliAnalysisTaskESDMuonFilter::UserCreateOutputObjects()\r
+{\r
+  // Create the output container\r
+    OutputTree()->GetUserInfo()->Add(fTrackFilter);\r
+}\r
+\r
+void AliAnalysisTaskESDMuonFilter::Init()\r
+{\r
+  // Initialization\r
+    if (fDebug > 1) AliInfo("Init() \n");\r
+}\r
+\r
+\r
+void AliAnalysisTaskESDMuonFilter::UserExec(Option_t */*option*/)\r
+{\r
+  // Execute analysis for current event                                            \r
+  Long64_t ientry = Entry();\r
+  printf("Muon Filter: Analysing event # %5d\n", (Int_t) ientry);\r
+\r
+  ConvertESDtoAOD();\r
+}\r
+\r
+void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD() \r
+{\r
+  // ESD Muon Filter analysis task executed for each event\r
+  AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());\r
\r
+  // Define arrays for muons\r
+  Double_t pos[3];\r
+  Double_t p[3];\r
+  Double_t pid[10];\r
\r
+  AliAODHeader* header = AODEvent()->GetHeader();\r
+  AliAODTrack *aodTrack = 0x0;\r
\r
+  // Access to the AOD container of tracks\r
+  TClonesArray &tracks = *(AODEvent()->GetTracks());\r
+  Int_t jTracks = header->GetRefMultiplicity();\r
+  \r
+  // Read primary vertex from AOD event \r
+  AliAODVertex * primary = AODEvent()->GetPrimaryVertex();\r
+  primary->Print();\r
\r
+  // Loop on muon tracks to fill the AOD track branch\r
+  Int_t nMuTracks = esd->GetNumberOfMuonTracks();\r
+  printf("Number of Muon Tracks=%d\n",nMuTracks);\r
\r
+  for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {\r
+\r
+       AliESDMuonTrack *esdMuTrack = esd->GetMuonTrack(nMuTrack); \r
+        \r
+       p[0] = esdMuTrack->Px(); \r
+       p[1] = esdMuTrack->Py(); \r
+       p[2] = esdMuTrack->Pz();\r
+       pos[0] = primary->GetX(); \r
+       pos[1] = primary->GetY(); \r
+       pos[2] = primary->GetZ();\r
+\r
+       // has to be changed once the muon pid is provided by the ESD\r
+       for (Int_t i = 0; i < 10; pid[i++] = 0.); pid[AliAODTrack::kMuon]=1.;\r
+       primary->AddDaughter(aodTrack =\r
+         new(tracks[jTracks++]) AliAODTrack(0, // no ID provided\r
+                                            0, // no label provided\r
+                                            p,\r
+                                            kTRUE,\r
+                                            pos,\r
+                                            kFALSE,\r
+                                            NULL, // no covariance matrix provided\r
+                                            (Short_t)-99, // no charge provided\r
+                                            0, // no ITSClusterMap\r
+                                            pid,\r
+                                            primary,\r
+                                            kTRUE,  // check if this is right\r
+                                            kTRUE,  // not used for vertex fit\r
+                                            AliAODTrack::kPrimary)\r
+        );\r
+\r
+     aodTrack->ConvertAliPIDtoAODPID();  \r
+     aodTrack->SetHitsPatternInTrigCh(esdMuTrack->GetHitsPatternInTrigCh());\r
+     Int_t track2Trigger = esdMuTrack->GetMatchTrigger();\r
+     aodTrack->SetMatchTrigger(track2Trigger);\r
+     if (track2Trigger) \r
+       aodTrack->SetChi2MatchTrigger(esdMuTrack->GetChi2MatchTrigger());\r
+     else \r
+       aodTrack->SetChi2MatchTrigger(0.);\r
+ }\r
+\r
+    return;\r
+}\r
+\r
+void AliAnalysisTaskESDMuonFilter::Terminate(Option_t */*option*/)\r
+{\r
+// Terminate analysis\r
+//\r
+    if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");\r
+}\r
index 3aef5a4..0565975 100644 (file)
@@ -1,39 +1,38 @@
-#ifndef ALIANALYSISTASKESDMUONFILTER_H
-#define ALIANALYSISTASKESDMUONFILTER_H
-/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- * See cxx source for full Copyright notice                               */
-
-/* $Id: AliAnalysisTaskESDMuonFilter.h 24429 2008-03-12 10:27:50Z jgrosseo $ */
-
-#include <TList.h> 
-#include "AliAnalysisTaskSE.h"
-
-class AliAnalysisFilter;
-
-class AliAnalysisTaskESDMuonFilter : public AliAnalysisTaskSE
-{
- public:
-    AliAnalysisTaskESDMuonFilter();
-    AliAnalysisTaskESDMuonFilter(const char* name);
-    virtual ~AliAnalysisTaskESDMuonFilter() {;}
-    // Implementation of interface methods
-    virtual void UserCreateOutputObjects();
-    virtual void Init();
-    virtual void LocalInit() {Init();}
-    virtual void UserExec(Option_t *option);
-    virtual void Terminate(Option_t *option);
-
-    virtual void ConvertESDtoAOD();
-
-    // Setters
-    virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;}
-
- private:
-    AliAnalysisTaskESDMuonFilter(const AliAnalysisTaskESDMuonFilter&);
-    AliAnalysisTaskESDMuonFilter& operator=(const AliAnalysisTaskESDMuonFilter&);
-    AliAnalysisFilter* fTrackFilter; //  Track Filter
-    ClassDef(AliAnalysisTaskESDMuonFilter, 1); // Analysis task for standard ESD filtering
-};
-#endif
+#ifndef ALIANALYSISTASKESDMUONFILTER_H\r
+#define ALIANALYSISTASKESDMUONFILTER_H\r
\r
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+ * See cxx source for full Copyright notice                               */\r
+\r
+#include <TList.h> \r
+#include "AliAnalysisTaskSE.h"\r
+\r
+class AliAnalysisFilter;\r
+\r
+class AliAnalysisTaskESDMuonFilter : public AliAnalysisTaskSE\r
+{\r
+ public:\r
+    AliAnalysisTaskESDMuonFilter();\r
+    AliAnalysisTaskESDMuonFilter(const char* name);\r
+    virtual ~AliAnalysisTaskESDMuonFilter() {;}\r
+    // Implementation of interface methods\r
+    virtual void UserCreateOutputObjects();\r
+    virtual void Init();\r
+    virtual void LocalInit() {Init();}\r
+    virtual void UserExec(Option_t *option);\r
+    virtual void Terminate(Option_t *option);\r
+\r
+    virtual void ConvertESDtoAOD();\r
+\r
+    // Setters\r
+    virtual void SetTrackFilter(AliAnalysisFilter* trackF) {fTrackFilter = trackF;}\r
+\r
+ private:\r
+    AliAnalysisTaskESDMuonFilter(const AliAnalysisTaskESDMuonFilter&);\r
+    AliAnalysisTaskESDMuonFilter& operator=(const AliAnalysisTaskESDMuonFilter&);\r
+    AliAnalysisFilter* fTrackFilter; //  Track Filter\r
+    ClassDef(AliAnalysisTaskESDMuonFilter, 1); // Analysis task for standard ESD filtering\r
+\r
+};\r
\r
+#endif\r
diff --git a/PWG3/muon/AnalysisTrainMuonCAF.C b/PWG3/muon/AnalysisTrainMuonCAF.C
new file mode 100644 (file)
index 0000000..01db2fd
--- /dev/null
@@ -0,0 +1,124 @@
+void AnalysisTrainMuonCAF(char* fileout = "AliAOD.root", char *datasetname = "myDataSet", Int_t nev=1234567890)\r
+{\r
+// Macro to produce a generic AOD starting from an ESD file. \r
+// The AOD is filled with two tasks: \r
+// 1- with the first one (AliAnalysisTaskESDfilter), \r
+//    all the branches of the AOD are filled apart from the muons. \r
+// 2- with the second task (AliAnalysisTaskESDMuonFilter) \r
+//    muons tracks are added to the tracks branch \r
+// This macro works on the CAF\r
+// R. Arnaldi 4/5/08\r
+\r
+  gSystem->Load("libTree.so");\r
+  gSystem->Load("libGeom.so");\r
+  gSystem->Load("libVMC.so");\r
+  gSystem->Load("libPhysics.so");\r
+    \r
+  // Reset user processes if CAF if not responding anymore\r
+  // TProof::Reset("lxb6046");\r
+\r
+  // Connect to proof\r
+  TProof::Open("lxb6046"); // may be username@lxb6046 if user not the same as on local\r
+\r
+  // Clear packages if changing ROOT version on CAF or local\r
+  // gProof->ClearPackages();\r
+  // Enable proof debugging if needed\r
+  // gProof->SetLogLevel(5);\r
+\r
+  // Common packages\r
+  gProof->UploadPackage("STEERBase.par");\r
+  gProof->EnablePackage("STEERBase");\r
+  gProof->UploadPackage("ESD.par");\r
+  gProof->EnablePackage("ESD");\r
+  gProof->UploadPackage("AOD.par");\r
+  gProof->EnablePackage("AOD");\r
+  gProof->UploadPackage("ANALYSIS.par");\r
+  gProof->EnablePackage("ANALYSIS");\r
+  gProof->UploadPackage("ANALYSISalice.par");\r
+  gProof->EnablePackage("ANALYSISalice");\r
+  // Analysis-specific\r
+  // --- Enable the PWG3base Package\r
+  gProof->UploadPackage("PWG3muon.par");\r
+  gProof->EnablePackage("PWG3muon");\r
+\r
+  // Chain from files staged on CAF\r
+  // gROOT->LoadMacro("CreateESDChain.C");\r
+  // TChain* chain = CreateESDChain("ESD1503X_v1.txt",3);\r
+  // TChain* chain = CreateESDChain("ESD82XX_30Kshort.txt", 10);\r
+  \r
+  // Chain from datasets\r
+  gROOT->LoadMacro("CreateChainFromDataSet.C");\r
+  ds = gProof->GetDataSet(datasetname)->GetStagedSubset();\r
+  chain = CreateChainFromDataSet(ds, "esdTree");   \r
+  \r
+  // Make the analysis manager\r
+  AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Analysis train");\r
+  \r
+  // ESD input handler\r
+  AliESDInputHandler *esdHandler = new AliESDInputHandler();\r
+  esdHandler->SetInactiveBranches("FMD CaloCluster");\r
+  // AOD output handler\r
+  AliAODHandler* aodHandler   = new AliAODHandler();\r
+  //aodHandler->SetOutputFileName(fileout);\r
+  aodHandler->SetOutputFileName("AOD.root");\r
+\r
+  mgr->SetInputEventHandler(esdHandler);\r
+  mgr->SetOutputEventHandler(aodHandler);\r
+  \r
+  // Set of cuts plugged into the ESD filter\r
+  // \r
+  // standard\r
+  AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");\r
+  esdTrackCutsL->SetMinNClustersTPC(50);\r
+  esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);\r
+  esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
+  esdTrackCutsL->SetRequireTPCRefit(kTRUE);\r
+  esdTrackCutsL->SetMinNsigmaToVertex(3);\r
+  esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);\r
+  esdTrackCutsL->SetAcceptKingDaughters(kFALSE);\r
+  //\r
+  // hard\r
+  AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard");\r
+  esdTrackCutsH->SetMinNClustersTPC(100);\r
+  esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0);\r
+  esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
+  esdTrackCutsH->SetRequireTPCRefit(kTRUE);\r
+  esdTrackCutsH->SetMinNsigmaToVertex(2);\r
+  esdTrackCutsH->SetRequireSigmaToVertex(kTRUE);\r
+  esdTrackCutsH->SetAcceptKingDaughters(kFALSE);\r
+  //\r
+  AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");\r
+  trackFilter->AddCuts(esdTrackCutsL);\r
+  trackFilter->AddCuts(esdTrackCutsH);\r
+\r
+  // ESD filter task putting standard info to output generic AOD \r
+  AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");\r
+  //esdfilter->SetTrackFilter(trackFilter);\r
+  esdfilter->SetDebugLevel(10);\r
+  mgr->AddTask(esdfilter);\r
+  \r
+  // ESD filter task putting muon info to output generic AOD \r
+  AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");\r
+  mgr->AddTask(esdmuonfilter);\r
+\r
+  // Containers for input/output\r
+  AliAnalysisDataContainer *cin_esd = mgr->CreateContainer("cESD",TChain::Class(), AliAnalysisManager::kInputContainer);\r
+  // Output AOD container. \r
+  AliAnalysisDataContainer *cout_aod = mgr->CreateContainer("cAOD", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");\r
+                                                           \r
+  // Connect containers to tasks slots\r
+  mgr->ConnectInput  (esdfilter,  0, cin_esd  );\r
+  mgr->ConnectOutput (esdfilter,  0, cout_aod );\r
+\r
+  mgr->ConnectInput  (esdmuonfilter,  0, cin_esd);\r
+  mgr->ConnectOutput (esdmuonfilter,  0, cout_aod );\r
+\r
+  //\r
+  // Run the analysis\r
+  //   \r
+  if (mgr->InitAnalysis()) {\r
+      mgr->PrintStatus();\r
+      mgr->StartAnalysis("proof",chain,nev);\r
+  }   \r
+}\r
+\r
diff --git a/PWG3/muon/AnalysisTrainMuonLocal.C b/PWG3/muon/AnalysisTrainMuonLocal.C
new file mode 100644 (file)
index 0000000..72b9f28
--- /dev/null
@@ -0,0 +1,138 @@
+void AnalysisTrainMuonLocal(char* filein = "AliESDs.root", char* fileout = "AliAOD.root")\r
+\r
+// Macro to produce a generic AOD starting from an ESD file. \r
+// The AOD is filled with two tasks: \r
+// 1- with the first one (AliAnalysisTaskESDfilter), \r
+//    all the branches of the AOD are filled apart from the muons. \r
+// 2- with the second task (AliAnalysisTaskESDMuonFilter) \r
+//    muons tracks are added to the tracks branch \r
+// This macro works locally\r
+// R. Arnaldi 5/5/08\r
+\r
+{\r
+    gSystem->Load("libTree.so");\r
+    gSystem->Load("libGeom.so");\r
+    gSystem->Load("libVMC.so");\r
+    gSystem->Load("libPhysics.so");\r
+\r
+    // If analysis is .par based:\r
+\r
+    // Common packages\r
+    SetupPar("STEERBase");\r
+    SetupPar("ESD");\r
+    SetupPar("AOD");\r
+    SetupPar("ANALYSIS");\r
+    SetupPar("ANALYSISalice");\r
+    // Analysis-specific packages\r
+    SetupPar("PWG3muon");      \r
+  \r
+    // Input ESD file\r
+    TChain* chain = new TChain("esdTree");  \r
+    chain->Add(filein);\r
+   \r
+    // Define the analysis manager\r
+    AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Analysis train");\r
+    \r
+    // ESD input handler\r
+    AliESDInputHandler *esdHandler = new AliESDInputHandler();\r
+    esdHandler->SetInactiveBranches("FMD CaloCluster");\r
+    \r
+    // AOD output handler\r
+    AliAODHandler* aodHandler   = new AliAODHandler();\r
+    aodHandler->SetOutputFileName(fileout);\r
+\r
+    mgr->SetInputEventHandler(esdHandler);\r
+    mgr->SetOutputEventHandler(aodHandler);\r
+    \r
+    // Set of cuts for the ESD filter\r
+    // \r
+    // standard cuts\r
+    AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");\r
+    esdTrackCutsL->SetMinNClustersTPC(50);\r
+    esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);\r
+    esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
+    esdTrackCutsL->SetRequireTPCRefit(kTRUE);\r
+    esdTrackCutsL->SetMinNsigmaToVertex(3);\r
+    esdTrackCutsL->SetRequireSigmaToVertex(kTRUE);\r
+    esdTrackCutsL->SetAcceptKingDaughters(kFALSE);\r
+    //\r
+    // hard cuts\r
+    AliESDtrackCuts* esdTrackCutsH = new AliESDtrackCuts("AliESDtrackCuts", "Hard");\r
+    esdTrackCutsH->SetMinNClustersTPC(100);\r
+    esdTrackCutsH->SetMaxChi2PerClusterTPC(2.0);\r
+    esdTrackCutsH->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);\r
+    esdTrackCutsH->SetRequireTPCRefit(kTRUE);\r
+    esdTrackCutsH->SetMinNsigmaToVertex(2);\r
+    esdTrackCutsH->SetRequireSigmaToVertex(kTRUE);\r
+    esdTrackCutsH->SetAcceptKingDaughters(kFALSE);\r
+    //\r
+    AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");\r
+    trackFilter->AddCuts(esdTrackCutsL);\r
+    trackFilter->AddCuts(esdTrackCutsH);\r
+\r
+    // ESD filter task putting standard info in the output generic AOD \r
+    AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");\r
+    //esdfilter->SetTrackFilter(trackFilter);\r
+    esdfilter->SetDebugLevel(10);\r
+    mgr->AddTask(esdfilter);\r
+    \r
+    // ESD filter task putting muon info in the output generic AOD \r
+    AliAnalysisTaskESDMuonFilter *esdmuonfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");\r
+    mgr->AddTask(esdmuonfilter);\r
+\r
+    // Containers for input/output\r
+    AliAnalysisDataContainer *cin_esd = mgr->CreateContainer("cESD",TChain::Class(), \r
+                                                            AliAnalysisManager::kInputContainer);\r
+    // Output AOD container. \r
+    AliAnalysisDataContainer *cout_aod = mgr->CreateContainer("cAOD", TTree::Class(),\r
+                                                             AliAnalysisManager::kOutputContainer, "default");\r
+                                                             \r
+    // Connect containers to tasks slots\r
+    mgr->ConnectInput  (esdfilter,  0, cin_esd  );\r
+    mgr->ConnectOutput (esdfilter,  0, cout_aod );\r
+\r
+    mgr->ConnectInput  (esdmuonfilter,  0, cin_esd);\r
+    mgr->ConnectOutput (esdmuonfilter,  0, cout_aod );\r
\r
+    //\r
+    // Run the analysis\r
+    //    \r
+    if (mgr->InitAnalysis()) {\r
+        mgr->PrintStatus();\r
+        mgr->StartAnalysis("local",chain);\r
+    }   \r
+}\r
+\r
+//______________________________________________________________________________\r
+void SetupPar(char* pararchivename)\r
+{\r
+    if (pararchivename) {\r
+       char processline[1024];\r
+       sprintf(processline,".! tar xvzf %s.par",pararchivename);\r
+       gROOT->ProcessLine(processline);\r
+       TString ocwd = gSystem->WorkingDirectory();\r
+       gSystem->ChangeDirectory(pararchivename);\r
+       \r
+       // check for BUILD.sh and execute\r
+       if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {\r
+           printf("*******************************\n");\r
+           printf("*** Building PAR archive    ***\n");\r
+           printf("*******************************\n");\r
+           \r
+           if (gSystem->Exec("PROOF-INF/BUILD.sh")) {\r
+               Error("runProcess","Cannot Build the PAR Archive! - Abort!");\r
+               return -1;\r
+           }\r
+       }\r
+       // check for SETUP.C and execute\r
+       if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {\r
+           printf("*******************************\n");\r
+           printf("*** Setup PAR archive       ***\n");\r
+           printf("*******************************\n");\r
+           gROOT->Macro("PROOF-INF/SETUP.C");\r
+       }\r
+       \r
+       gSystem->ChangeDirectory(ocwd.Data());\r
+   printf("Current dir: %s\n", ocwd.Data());\r
+    } \r
+}\r