New library PWG3muondep for classes which depend on MUON module (Gines) New classes...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Sep 2008 12:16:48 +0000 (12:16 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 2 Sep 2008 12:16:48 +0000 (12:16 +0000)
PWG3/Makefile
PWG3/PROOF-INF.PWG3muondep/BUILD.sh [new file with mode: 0755]
PWG3/PROOF-INF.PWG3muondep/SETUP.C [new file with mode: 0644]
PWG3/PWG3muondepLinkDef.h [new file with mode: 0644]
PWG3/libPWG3muondep.pkg [new file with mode: 0644]
PWG3/muondep/AliAnalysisTaskMuonTrackingEff.cxx [new file with mode: 0644]
PWG3/muondep/AliAnalysisTaskMuonTrackingEff.h [new file with mode: 0644]
PWG3/muondep/AliCheckMuonDetEltResponse.cxx [new file with mode: 0644]
PWG3/muondep/AliCheckMuonDetEltResponse.h [new file with mode: 0644]
PWG3/muondep/MuonTrackingEffAnalysis.C [new file with mode: 0644]
PWG3/muondep/RunMuonTrackingEffAnalysis.C [new file with mode: 0644]

index 8f0e4db..433c29e 100644 (file)
@@ -2,7 +2,7 @@
 
 include $(ROOTSYS)/test/Makefile.arch
 
-default-target: libPWG3base.so libPWG3muon libPWG3vertexingHF.so libPWG3vertexingOld.so 
+default-target: libPWG3base.so libPWG3muon.so libPWG3muondep.so libPWG3vertexingHF.so libPWG3vertexingOld.so 
 
 ALICEINC      = -I.
 
@@ -143,6 +143,29 @@ G__PWG3muon.cxx G__PWG3muon.h: $(HDRS_PWG3muon) $(DHDR_PWG3muon)
        @echo "Generating dictionary ..."
        rootcint -f $@ -c $(ALICEINC) $^
 
+## libPWG3muondep part
+##include libPWG3muondep.pkg
+
+DHDR_PWG3muondep := $(DHDR)
+HDRS_PWG3muondep := $(HDRS)
+SRCS_PWG3muondep := $(SRCS) G__PWG3muondep.cxx
+OBJS_PWG3muondep := $(SRCS_PWG3muondep:.cxx=.o)
+
+libPWG3muondep.so: $(OBJS_PWG3muondep)
+       @echo "Linking" $@ ...
+       @/bin/rm -f $@
+ifeq ($(ARCH),macosx)
+       @$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ -o $@
+else
+       @$(LD) $(SOFLAGS) $(LDFLAGS) $^ -o $@
+endif
+       @chmod a+x $@
+       @echo "done"
+
+G__PWG3muondep.cxx G__PWG3muondep.h: $(HDRS_PWG3muondep) $(DHDR_PWG3muondep)
+       @echo "Generating dictionary ..."
+       rootcint -f $@ -c $(ALICEINC) $^
+
 ## libPWG3vertexingHF part
 ##include libPWG3vertexingHF.pkg
 
diff --git a/PWG3/PROOF-INF.PWG3muondep/BUILD.sh b/PWG3/PROOF-INF.PWG3muondep/BUILD.sh
new file mode 100755 (executable)
index 0000000..63f8c74
--- /dev/null
@@ -0,0 +1,2 @@
+#! /bin/sh
+make libPWG3muondep.so
diff --git a/PWG3/PROOF-INF.PWG3muondep/SETUP.C b/PWG3/PROOF-INF.PWG3muondep/SETUP.C
new file mode 100644 (file)
index 0000000..c335480
--- /dev/null
@@ -0,0 +1,36 @@
+void SETUP()
+{
+    // Load some ROOT libraries
+    CheckLoadLibrary("libTree");
+    CheckLoadLibrary("libGeom");
+    CheckLoadLibrary("libVMC");
+
+    // Load the MUON libraries
+
+    // Load the ESD libraries
+    CheckLoadLibrary("libANALYSIS");
+    CheckLoadLibrary("libSTEERBase");
+    CheckLoadLibrary("libESD");
+    CheckLoadLibrary("libAOD");
+    CheckLoadLibrary("libANALYSISalice");
+    CheckLoadLibrary("libPWG3muondep");
+
+
+
+
+   // Set the include paths
+   gROOT->ProcessLine(".include PWG3muondep");
+
+   // Set our location, so that other packages can find us
+   gSystem->Setenv("PWG3muondep_INCLUDE", "PWG3muondep");
+}
+
+Int_t CheckLoadLibrary(const char* library)
+{
+  // checks if a library is already loaded, if not loads the library
+
+  if (strlen(gSystem->GetLibraries(Form("%s.so", library), "", kFALSE)) > 0)
+    return 1;
+
+  return gSystem->Load(library);
+}
diff --git a/PWG3/PWG3muondepLinkDef.h b/PWG3/PWG3muondepLinkDef.h
new file mode 100644 (file)
index 0000000..54c00f3
--- /dev/null
@@ -0,0 +1,11 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class AliAnalysisTaskMuonTrackingEff+;
+#pragma link C++ class AliCheckMuonDetEltResponse+;
+#endif
+
+
diff --git a/PWG3/libPWG3muondep.pkg b/PWG3/libPWG3muondep.pkg
new file mode 100644 (file)
index 0000000..d2dd140
--- /dev/null
@@ -0,0 +1,15 @@
+#-*- Mode: Makefile -*-
+
+SRCS:=  muondep/AliAnalysisTaskMuonTrackingEff.cxx \
+                 muondep/AliCheckMuonDetEltResponse.cxx 
+
+HDRS:= $(SRCS:.cxx=.h)
+
+DHDR:= PWG3muondepLinkDef.h
+
+EINCLUDE:= MUON MUON/mapping PWG3/base
+
+ifeq (win32gcc,$(ALICE_TARGET))
+PACKSOFLAGS:= $(SOFLAGS) -L$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET) -lSTEERBase \
+                         -lESD -lAOD -lANALYSIS -lANALYSISalice
+endif
diff --git a/PWG3/muondep/AliAnalysisTaskMuonTrackingEff.cxx b/PWG3/muondep/AliAnalysisTaskMuonTrackingEff.cxx
new file mode 100644 (file)
index 0000000..deefd02
--- /dev/null
@@ -0,0 +1,249 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//Class to calculate the intrinsic efficiency of the detection elements of the
+//MUON tracking chambers in function of the position in the detection element.
+//Author:  Nicolas LE BRIS - SUBATECH Nantes
+
+
+//ROOT includes
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TClonesArray.h>
+#include <TH2F.h>
+
+//ANALYSIS includes
+#include "AliAnalysisManager.h"
+#include "AliAnalysisTask.h"
+
+//STEER includes
+#include "AliESDEvent.h"
+#include "AliESDMuonTrack.h"
+#include "AliESDInputHandler.h"
+#include "AliMagFMaps.h"
+#include "AliTracker.h"
+#include "AliAnalysisManager.h"
+
+//PWG3/muon includes
+#include "AliAnalysisTaskMuonTrackingEff.h"
+#include "AliCheckMuonDetEltResponse.h"
+
+//MUON includes
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONTrackExtrap.h"
+
+ClassImp(AliAnalysisTaskMuonTrackingEff)
+
+const Int_t AliAnalysisTaskMuonTrackingEff::fTotNbrOfDetectionElt  = 156;
+
+//________________________________________________________________________
+AliAnalysisTaskMuonTrackingEff::AliAnalysisTaskMuonTrackingEff()
+    :
+    AliAnalysisTask(),
+    fTransformer(0x0),
+    fESD(0x0),
+    fDetEltEffHistList(0x0),
+    fDetEltTDHistList(0x0),
+    fDetEltTTHistList(0x0)
+{
+// Default constructor
+}
+
+
+
+//________________________________________________________________________
+AliAnalysisTaskMuonTrackingEff::AliAnalysisTaskMuonTrackingEff(const char* name,
+                                      const AliMUONGeometryTransformer* transformer)
+    :
+    AliAnalysisTask(name, "AnalysisTaskESD"),
+    fTransformer(transformer),
+    fESD(0x0),
+    fDetEltEffHistList(0x0),
+    fDetEltTDHistList(0x0),
+    fDetEltTTHistList(0x0)
+{
+//Constructor
+//-----------
+    
+//Define detection element efficiency histograms
+//----------------------------------------------
+
+    fDetEltEffHistList = new TClonesArray("TH2F",fTotNbrOfDetectionElt + 3); //!<+3 for: 1.the total efficiency chamber by chamber histogram.
+                                                                //!<        2.the total number of tracks detected by the tracking system.
+                                                                //!<        3.the number of track used for the efficiency calculation chamber by chamber
+    fDetEltTDHistList  = new TClonesArray("TH2F",fTotNbrOfDetectionElt + 1);
+    fDetEltTTHistList  = new TClonesArray("TH2F",fTotNbrOfDetectionElt + 1);
+
+    for (Int_t i = 0; i<fTotNbrOfDetectionElt; ++i)
+    {
+      Int_t iDetElt = 0;
+      if      (i<16) iDetElt = 100*(i/4+1)       + i -  int(i/4)*4;
+      else if (i<52) iDetElt = 100*((i-16)/18+5) + i - (int((i-16)/18)*18 + 16);
+      if      (i>51) iDetElt = 100*((i-52)/26+7) + i - (int((i-52)/26)*26 + 52); 
+
+      Char_t histName[255]; 
+      Char_t histTitle[255];
+
+      sprintf(histName,"Eff_detEltNbr%d",iDetElt);
+      sprintf(histTitle,"detEltNbr %d",iDetElt);
+      if(i<16) new((*fDetEltEffHistList)[i]) TH2F(histName,histTitle,12,-10,110,12,-10,110);//!<Stations 1 & 2.
+      else     new((*fDetEltEffHistList)[i]) TH2F(histName,histTitle,28,-140,140,8,-40,40); //!<Stations 3 -> 5.
+      
+      sprintf(histName,"TD_detEltNbr%d",iDetElt);
+      if(i<16) new((*fDetEltTDHistList)[i]) TH2F(histName,histTitle,12,-10,110,12,-10,110);//!<Stations 1 & 2.
+      else     new((*fDetEltTDHistList)[i]) TH2F(histName,histTitle,28,-140,140,8,-40,40); //!<Stations 3 -> 5.
+
+      sprintf(histName,"TT_detEltNbr%d",iDetElt);
+      if(i<16) new((*fDetEltTTHistList)[i]) TH2F(histName,histTitle,12,-10,110,12,-10,110); //!<Stations 1 & 2.
+      else     new((*fDetEltTTHistList)[i]) TH2F(histName,histTitle,28,-140,140,8,-40,40);  //!<Stations 3 -> 5.
+      
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetXaxis() -> SetTitle("X (cm)");
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetYaxis() -> SetTitle("Y (cm)");
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetZaxis() -> SetTitle("Efficiency (%)");  
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetXaxis() -> SetTitleOffset(1.8);
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetYaxis() -> SetTitleOffset(1.8); 
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> GetZaxis() -> SetTitleOffset(1.2); 
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i)) -> SetOption("LEGO");
+    }
+
+    new((*fDetEltTDHistList )[fTotNbrOfDetectionElt]) TH2F("TD_Chamber" ,"TD_Chamber" ,10,0,10,1,0,1); //!<Detected tracks.
+    new((*fDetEltTTHistList )[fTotNbrOfDetectionElt]) TH2F("TT_Chamber" ,"TT_Chamber" ,10,0,10,1,0,1); //!<Tracks total number.
+    new((*fDetEltEffHistList)[fTotNbrOfDetectionElt]) TH2F("fChamberEff","fChamberEff",10,0,10,1,0,1); //!<Chamber efficiency.
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetXaxis() -> SetTitle("Chamber number");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetYaxis() -> SetTitle("");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetZaxis() -> SetTitle("Efficiency (%)");  
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetXaxis() -> SetTitleOffset(1.8);
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetYaxis() -> SetTitleOffset(1.8); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> GetZaxis() -> SetTitleOffset(1.2); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt)) -> SetOption("LEGO");
+  
+    new((*fDetEltEffHistList)[157]) TH2F("TT_Chamber" ,"TT_Chamber" ,10,0,10,1,0,1); //!<Tracks total number by chamber.
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetXaxis() -> SetTitle("Chamber number");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetYaxis() -> SetTitle("");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetZaxis() -> SetTitle("Number of tracks");  
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetXaxis() -> SetTitleOffset(1.8);
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetYaxis() -> SetTitleOffset(1.8); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> GetZaxis() -> SetTitleOffset(1.2); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 1)) -> SetOption("LEGO");
+
+    new((*fDetEltEffHistList)[158]) TH2F("Total_Number_of_Tracks" ,"Total_Number_of_Tracks" ,1,0,1,1,0,1); //!<Tracks total number.
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetXaxis() -> SetTitle("");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetYaxis() -> SetTitle("");
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetZaxis() -> SetTitle("Number of tracks");  
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetXaxis() -> SetTitleOffset(1.8);
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetYaxis() -> SetTitleOffset(1.8); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> GetZaxis() -> SetTitleOffset(1.2); 
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(fTotNbrOfDetectionElt + 2)) -> SetOption("LEGO");    
+
+//Define input & output
+//---------------------
+
+// -Input slot 0 works with a TChain:
+    DefineInput(0, TChain::Class());
+
+// -Output slot 0 writes into a TClonesArray:
+    DefineOutput(0, TClonesArray::Class());
+}
+
+
+
+//______________________________________________________________________________
+AliAnalysisTaskMuonTrackingEff::~AliAnalysisTaskMuonTrackingEff()
+{
+// Destructor.
+    delete fDetEltEffHistList;
+    delete fDetEltTDHistList;
+    delete fDetEltTTHistList;
+}
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonTrackingEff::CreateOutputObjects()
+{
+    OpenFile(0);
+}
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonTrackingEff::ConnectInputData(Option_t */*option*/)
+
+{
+//Set mag field; waiting for mag field in CDB 
+//-------------------------------------------
+    AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
+    AliTracker::SetFieldMap(field, kFALSE);
+    
+//Set Field Map for track extrapolation
+//-------------------------------------
+    AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
+
+//Connect input
+    AliESDInputHandler* esdHandler = (AliESDInputHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
+    if (!esdHandler)
+    {
+      Printf("ERROR: Could not get ESDInputHandler");
+    } 
+    else fESD = esdHandler->GetEvent();
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonTrackingEff::Exec(Option_t */*option*/)
+{
+//Execute analysis for current event
+    
+   
+    AliCheckMuonDetEltResponse* chamberEff;
+    chamberEff = new AliCheckMuonDetEltResponse(fTransformer, fESD, fDetEltTDHistList, fDetEltTTHistList);
+    chamberEff->CheckDetEltResponse();
+
+
+    for( Int_t i = 0; i<156; ++i)
+    {
+      ((TH2F*) fDetEltEffHistList->UncheckedAt(i))-> Divide( (TH2F*) fDetEltTDHistList->UncheckedAt(i),
+                                                            (TH2F*) fDetEltTTHistList->UncheckedAt(i), 100., 1.); 
+    }
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(156))-> Divide( (TH2F*) fDetEltTDHistList->UncheckedAt(156),
+                                                            (TH2F*) fDetEltTTHistList->UncheckedAt(156), 100., 1.); 
+
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(157))-> Add   ( (TH2F*) fDetEltTTHistList ->UncheckedAt(156),
+                                                            (TH2F*) fDetEltEffHistList->UncheckedAt(157), 1., 0.); 
+
+
+    ((TH2F*) fDetEltEffHistList->UncheckedAt(158))-> Fill(0., 0., ((double_t)fESD -> GetNumberOfMuonTracks()));
+
+
+//Post the output data:
+    PostData(0, fDetEltEffHistList);  
+}
+
+
+
+//________________________________________________________________________
+void AliAnalysisTaskMuonTrackingEff::Terminate(Option_t */*option*/)
+{
+//Terminate analysis
+
+}
diff --git a/PWG3/muondep/AliAnalysisTaskMuonTrackingEff.h b/PWG3/muondep/AliAnalysisTaskMuonTrackingEff.h
new file mode 100644 (file)
index 0000000..65756e3
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef ALIANALYSISTASKMUONTRACKINGEFF_H
+#define ALIANALYSISTASKMUONTRACKINGEFF_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/// \ingroup base
+/// \class AliAnalysisTaskMuonTrackingEff
+/// \brief tracking chamber efficiency from data
+//Author: Nicolas LE BRIS - SUBATECH Nantes
+
+
+#include "AliAnalysisTask.h"
+#include "AliMUONGeometryTransformer.h"
+class AliESDEvent;
+class TClonesArray;
+class TH2F;
+
+class AliAnalysisTaskMuonTrackingEff : public AliAnalysisTask
+{
+ public:
+  AliAnalysisTaskMuonTrackingEff();
+  AliAnalysisTaskMuonTrackingEff(const char* name,
+                    const AliMUONGeometryTransformer* transformer);
+  virtual ~AliAnalysisTaskMuonTrackingEff();
+
+  // Implementation of interface methods
+  virtual void ConnectInputData(Option_t *option = "");
+  virtual void CreateOutputObjects();
+  virtual void Exec(Option_t *option);
+  virtual void Terminate(Option_t *option);
+
+  static const Int_t fTotNbrOfDetectionElt;    ///< The total number of detection element in the tracking system.
+
+ private:
+  const AliMUONGeometryTransformer* fTransformer;
+  AliESDEvent * fESD;               //!<ESD object
+
+  TClonesArray* fDetEltEffHistList; //!<Detetcion efficiencies histograms list. 
+  TClonesArray* fDetEltTDHistList;  //!<List of histograms of the tracks detected in the detection elements. 
+  TClonesArray* fDetEltTTHistList;  //!<List of histograms of the tracks which have passed through the detection elements. 
+
+  ClassDef(AliAnalysisTaskMuonTrackingEff, 1)
+};
+
+#endif
diff --git a/PWG3/muondep/AliCheckMuonDetEltResponse.cxx b/PWG3/muondep/AliCheckMuonDetEltResponse.cxx
new file mode 100644 (file)
index 0000000..3bcdaad
--- /dev/null
@@ -0,0 +1,465 @@
+/**************************************************************************
+ * 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.                  *
+ **************************************************************************/
+
+//Class to check the response of the detection elements of the  MUON tracking chambers 
+//in function of the position in the detection element.
+//Author:  Nicolas LE BRIS - SUBATECH Nantes
+
+//PWG3/muon:
+#include "AliAnalysisTaskMuonTrackingEff.h"
+#include "AliCheckMuonDetEltResponse.h"
+
+//include STEER:
+#include "AliLog.h"
+#include "AliESDEvent.h"
+#include "AliTracker.h"
+#include "AliESDMuonTrack.h"
+
+//include MUON:
+#include "AliMUONTrack.h"
+#include "AliMUONTrackParam.h"
+#include "AliMUONTrackExtrap.h"
+#include "AliMUONVCluster.h"
+#include "AliMUONConstants.h"
+#include "AliMUONGeometryTransformer.h"
+#include "AliMUONESDInterface.h"
+
+//include MUON/mapping:
+#include "mapping/AliMpDEManager.h"
+
+//include ROOT:
+#include <Riostream.h>
+#include <TMath.h>
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TH2F.h>
+#include <TClonesArray.h>
+#include <TPaveLabel.h>
+#include <TList.h>
+
+/// \cond CLASSIMP
+ClassImp(AliCheckMuonDetEltResponse)
+/// \endcond
+
+const Int_t AliCheckMuonDetEltResponse::fNbrOfChamber          = 10;
+const Int_t AliCheckMuonDetEltResponse::fNbrOfStation          = 5;
+const Int_t AliCheckMuonDetEltResponse::fNbrOfDetectionElt[10] = {4, 4, 4, 4, 18, 18, 26, 26, 26, 26};
+const Int_t AliCheckMuonDetEltResponse::fFirstDetectionElt[10] = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
+const Int_t AliCheckMuonDetEltResponse::fOffset                = 100;
+const Int_t AliCheckMuonDetEltResponse::fOverlapSize           = 15;
+const Int_t AliCheckMuonDetEltResponse::fYSlatSize             = 40;
+
+//_____________________________________________________________________________
+AliCheckMuonDetEltResponse::AliCheckMuonDetEltResponse() 
+
+: TObject(),
+  fTransformer(0x0),
+  fESD(0),
+  fTracksTotalNbr(0x0),
+  fTrackParams(0x0),
+  fTrackParam(0x0),
+  fCluster(0x0),
+  fDetEltTDHistList(0x0),
+  fDetEltTTHistList(0x0)
+{
+/// Default constructor
+
+    fNCh = AliCheckMuonDetEltResponse::fNbrOfChamber;
+    fNSt = AliCheckMuonDetEltResponse::fNbrOfStation;
+    fNDE = AliAnalysisTaskMuonTrackingEff::fTotNbrOfDetectionElt;
+
+    for (Int_t iCluster = 0; iCluster<fNCh; ++iCluster)
+    {
+      fNbrClustersCh[iCluster] = 0;
+    }  
+
+    for (Int_t i=0; i<2; ++i)
+    {
+      fGetDetElt[i] = 0;
+    }
+    for (Int_t i=0; i<fNCh; ++i)
+    {
+      fTrackFilter[i] = 0;
+    } 
+}
+
+
+
+//_____________________________________________________________________________
+AliCheckMuonDetEltResponse::AliCheckMuonDetEltResponse(const AliMUONGeometryTransformer* transformer,
+                                                      AliESDEvent* esd,
+                                                      TClonesArray* detEltTDHistList,
+                                                      TClonesArray* detEltTTHistList) 
+: TObject(),
+  fTransformer(transformer),
+  fESD(esd),
+  fTracksTotalNbr(0),
+  fTrackParams(0x0),
+  fTrackParam(0),
+  fCluster(0), 
+  fDetEltTDHistList(detEltTDHistList),
+  fDetEltTTHistList(detEltTTHistList)
+
+{
+/// Constructor
+
+    fNCh = AliCheckMuonDetEltResponse::fNbrOfChamber;
+    fNSt = AliCheckMuonDetEltResponse::fNbrOfStation;
+    fNDE = AliAnalysisTaskMuonTrackingEff::fTotNbrOfDetectionElt;
+
+    for (Int_t iCluster = 0; iCluster<fNCh; ++iCluster)
+    {
+      fNbrClustersCh[iCluster] = 0;
+    }
+
+    for (Int_t i = 0; i <2 ; ++i)
+    {
+      fGetDetElt[i] = 0;
+    }
+    for (Int_t i=0; i<fNCh; ++i)
+    {
+      fTrackFilter[i] = 0;
+    } 
+}
+
+
+//_____________________________________________________________________________
+AliCheckMuonDetEltResponse::~AliCheckMuonDetEltResponse()
+
+{
+/// Destructor
+    delete fTrackParams;
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::CheckDetEltResponse()
+{
+//
+//Cataloging positions (X,Y) of the clusters detected in the detection elements
+//(fDetEltTDHistList), and positions of crossing points between all the
+//tracks and the detection elements (fDetEltTTHistList).
+//Efficiency = 100 * fDetEltTDHistList / fDetEltTTHistList.
+
+//Loop on tracks
+//--------------
+    TrackLoop();
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::TrackLoop()
+{
+    AliESDMuonTrack* esdTrack;
+    AliMUONTrack track;
+    Int_t nTracks, iTrack;
+
+    nTracks = (Int_t)fESD -> GetNumberOfMuonTracks();
+    fTrackParams = new TClonesArray();
+ ///Begininig of the loop:
+    for (iTrack = 0; iTrack < nTracks; iTrack++)
+    {
+      esdTrack   = fESD -> GetMuonTrack(iTrack);
+  
+      if( esdTrack->ContainTrackerData() )
+      {
+       AliMUONESDInterface::ESDToMUON(*esdTrack, track);
+        fTrackParams = track.GetTrackParamAtCluster();
+       TrackParamLoop(); //!<Loop on trackParam.
+      }
+    }
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::TrackParamLoop()
+{
+    Int_t nTrackParams = (Int_t) fTrackParams->GetEntriesFast();  //!<Number of trackParams in the track.
+    Int_t iTrackParam = 0;                                        //!<Number of the trackParam of the track.
+    Int_t oldChamber = -1, newChamber = 0; //!<To check if there is 0, 1 or 2 (overlap cases) clusters in the same chamber for a track.                                      
+    Int_t detElt;                          //!<Detection element Id.
+  
+    for (Int_t ch = 0; ch < fNCh; ++ch)
+    {
+      fTrackFilter[ch] = 0;
+    }
+
+    Double_t posXL, posYL, posZL;          //!<Local positions.
+    Double_t posXG, posYG, posZG;          //!<Global. positions.
+    Int_t chamberResponse [10] = {0};      //!<1 if the chamber has responded; 0 if not
+
+    for (iTrackParam = 0; iTrackParam < nTrackParams; ++iTrackParam)
+    { 
+      fTrackParam = (AliMUONTrackParam*) fTrackParams->At(iTrackParam);
+      fCluster    = (AliMUONVCluster*  ) fTrackParam ->GetClusterPtr();    
+      fTrackFilter   [fCluster->GetChamberId()] = 1;
+      chamberResponse[fCluster->GetChamberId()] = 1;
+    }
+
+    for (Int_t station = 0; station < fNSt-1; ++station)
+    {
+      Int_t filter;                                                  //<!
+      Int_t ch1, ch2, ch3, ch4;                                      //<!
+      ch1 = 2*station;                                               //<!
+      ch2 = 2*station + 1;                                           //<!
+      ch3 = 2*station + 2;                                           //<!
+      ch4 = 2*station + 3;                                           //<!
+                                                                     //<!For the efficiency calculation the tracks
+      if (station < 3 )                                              //<!reconstructed must have responded to the
+      {                                                              //<!criteria of the tracking. 
+       filter            = fTrackFilter[ch1];                       //<!And that's why the tracks usable for the 
+       fTrackFilter[ch1] = fTrackFilter[ch2];                       //<!intrinsic efficiency calculation are
+       fTrackFilter[ch2] = filter;                                  //<!the tracks which have one or two clusters
+      }                                                              //<!in each station. So the case where a track
+                                                                     //<!hasn't a cluster in a station is not
+      else                                                           //<!taking into account.
+      {                                                              //<!This part solves the problem. See the ALICE 
+       if (chamberResponse[ch3]*chamberResponse[ch4] != 0)          //<!note of Diego STOCCO on the trigger efficiency
+       {                                                            //<!
+       filter            = fTrackFilter[ch1];                       //<!
+       fTrackFilter[ch1] = fTrackFilter[ch2];                       //<!
+       fTrackFilter[ch2] = filter;                                  //<!
+       }                                                            //<!
+       else                                                         //<!
+       {                                                            //<!
+       fTrackFilter[ch1] = 0;                                       //<!
+       fTrackFilter[ch2] = 0;                                       //<!
+       }                                                            //<!
+                                                                     //<!
+       if (chamberResponse[ch1]*chamberResponse[ch2] != 0)          //<!
+       {                                                            //<!
+       filter            = fTrackFilter[ch3];                       //<!
+       fTrackFilter[ch3] = fTrackFilter[ch4];                       //<!
+       fTrackFilter[ch4] = filter;                                  //<!
+       }                                                            //<!
+       else                                                         //<!
+       {                                                            //<!
+       fTrackFilter[ch3] = 0;                                       //<!
+       fTrackFilter[ch4] = 0;                                       //<!
+       }                                                            //<!
+      }                                                              //<!
+    }                                                                //<!
+
+    for (Int_t ch = 0; ch < fNCh; ++ch)
+    {
+      if (fTrackFilter[ch] == 1)
+      {
+       if ( chamberResponse[ch] != 0) ((TH2F*) fDetEltTDHistList->UncheckedAt(fNDE))->Fill(ch, 0);
+       ((TH2F*) fDetEltTTHistList->UncheckedAt(fNDE))->Fill(ch, 0);
+      }
+    } 
+
+ ///Begining of the loop:
+    for (iTrackParam = 0; iTrackParam < nTrackParams; ++iTrackParam)
+    {
+      fTrackParam = (AliMUONTrackParam*) fTrackParams->At(iTrackParam);
+      fCluster    = (AliMUONVCluster*  ) fTrackParam ->GetClusterPtr(); 
+      
+      newChamber  = fCluster->GetChamberId();
+      detElt      = fCluster->GetDetElemId();
+
+   ///Global and local positions calculation:
+      posXG = fTrackParam->GetNonBendingCoor(); 
+      posYG = fTrackParam->GetBendingCoor(); 
+      posZG = fTrackParam->GetZ(); 
+
+      fTransformer->Global2Local(detElt, posXG, posYG, posZG, posXL, posYL, posZL);  //!<Transfomation from global to local positions.
+   
+   ///Filling histograms of the cluster positions on the detection element of the TRACKS DETECTED (TD):
+      FillDetEltTDHisto(newChamber, detElt, posXL, posYL);
+
+   ///Filling histograms of the cluster positions on the detection element of ALL THE TRACKS (TT):
+      FillDetEltTTHisto(newChamber, detElt, posXG, posYG, posZG, posXL, posYL, posZL);
+
+      if (newChamber != oldChamber) 
+      {
+       if (newChamber > oldChamber + 1)                                 //!<Check if it doesn't miss a chamber.
+       {
+         Int_t nbrOfMissCh = newChamber - (oldChamber+1);                //!<Number of missing chambers.
+         CalculMissClusterParam(fTrackParam, oldChamber+1, nbrOfMissCh); //!<Calculation of the parameters of the missing cluster(s).
+       }
+       if ( iTrackParam == nTrackParams - 1 & newChamber != fNCh-1)           //!<Check if the last chamber, chamber 9 (from 0 to 9) has responded.
+       {
+         CalculMissClusterParam(fTrackParam, fNCh-1, 1);                      //!<Calculation of the parameters of the missing cluster(s) in the last chamber.
+       }
+      }
+      oldChamber = newChamber; 
+    }
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::FillDetEltTDHisto(Int_t chamber,
+                                                  Int_t detElt,
+                                                  Double_t posXL,
+                                                  Double_t posYL)
+{
+    if(fTrackFilter[chamber]== 1)
+    {
+      Int_t iDet = 0; //!<Position of the detection element in the histograms' list.
+      iDet = FromDetElt2iDet(chamber, detElt);
+      ((TH2F*) fDetEltTDHistList->UncheckedAt(iDet))->Fill(posXL, posYL);
+    }
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::FillDetEltTTHisto(Int_t chamber,
+                                                  Int_t detElt,
+                                                  Double_t posXG,
+                                                  Double_t posYG,
+                                                  Double_t posZG,
+                                                  Double_t posXL,
+                                                  Double_t posYL,
+                                                  Double_t posZL)
+{
+    if(fTrackFilter[chamber] == 1)
+    {
+      Int_t iDet = 0; //!<Position of the detection element in the histograms' list.
+      iDet = FromDetElt2iDet(chamber, detElt);
+      ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
+      
+      if(abs(posYL) > fOverlapSize) //!<It is an overlap area. It can have two clusters for this track in this chamber.
+      {
+       GetDetEltFromPosition(chamber, posXG, posYG, posZG);
+       if(fGetDetElt[1] != 0) //<!There is a second detection element for the same (X,Y) in this chamber (overlap).
+       {
+         if(fGetDetElt[1] != detElt)
+         {
+           fTransformer->Global2Local(fGetDetElt[1], posXG, posYG, posZG, posXL, posYL, posZL);  //!<Transfomation from global to local positions.
+           iDet = FromDetElt2iDet(chamber, fGetDetElt[1]);
+           ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
+         }
+         else
+         {
+           fTransformer->Global2Local(fGetDetElt[0], posXG, posYG, posZG, posXL, posYL, posZL);  //!<Transfomation from global to local positions.
+           iDet = FromDetElt2iDet(chamber, fGetDetElt[0]);
+           ((TH2F*) fDetEltTTHistList->UncheckedAt(iDet)) -> Fill(posXL, posYL);
+         }
+       }
+      }
+    }
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::CalculMissClusterParam(AliMUONTrackParam* extrapTrackParam,
+                                                       Int_t firstMissCh,
+                                                       Int_t nbrOfMissCh)
+{
+//Calculation of the cluster parameter which was not detect by
+//the chamber.
+
+    for (Int_t iCh = 0; iCh<nbrOfMissCh; ++iCh)
+    {
+      Double_t exTraXL, exTraYL, exTraZL;   //!<Extrapolated local positions.
+      Double_t exTraXG, exTraYG, exTraZG;   //!<Extrapolated global positions.
+      Int_t missChamber= firstMissCh + iCh; //!<The missing chamber.
+      Int_t missDetElt = 0;
+
+      exTraZG = AliMUONConstants::DefaultChamberZ(missChamber);
+      AliMUONTrackExtrap::ExtrapToZ(extrapTrackParam, exTraZG);      //!<Extrapolation to the missing chamber.
+      exTraXG = extrapTrackParam->GetNonBendingCoor();               //!<Global X position extrapolated to the missing chamber.
+      exTraYG = extrapTrackParam->GetBendingCoor();                  //!<Global Y position extrapolated to the missing chamber.
+
+      GetDetEltFromPosition(missChamber, exTraXG, exTraYG, exTraZG); //!<Gives the detection element (fGetDetElt) with the position.
+      missDetElt = fGetDetElt[0];
+
+      if( missDetElt != 0 ) //!<Check if the track has passed trough a detection area
+      {
+       fTransformer->Global2Local(missDetElt, exTraXG, exTraYG, exTraZG, exTraXL, exTraYL, exTraZL);  //!<Transfomation from global to local positions.
+       FillDetEltTTHisto(missChamber, missDetElt, exTraXG, exTraYG, exTraZG, exTraXL, exTraYL, exTraZL);
+      }
+    }
+}
+
+
+
+//_____________________________________________________________________________
+Int_t AliCheckMuonDetEltResponse::FromDetElt2iDet(Int_t chamber, 
+                                                 Int_t detElt)
+{
+///
+///Connexion between the detection element X and its position in the list of histograms iX.
+///
+
+    Int_t iDet = 0; //!<Position of the detection element (detElt) in the histograms' list.
+
+    if (chamber<4)             iDet = detElt-fOffset*(chamber+1)+ 4* chamber      ; 
+    if (chamber>3 & chamber<6) iDet = detElt-fOffset*(chamber+1)+18*(chamber-4)+16;
+    if (chamber>5)             iDet = detElt-fOffset*(chamber+1)+26*(chamber-6)+52;
+
+    return iDet;    
+}
+
+
+
+//_____________________________________________________________________________
+void AliCheckMuonDetEltResponse::GetDetEltFromPosition(Int_t chamber,
+                                                      Double_t posX,
+                                                      Double_t posY,
+                                                      Double_t posZ)
+{
+///
+///Gives the detetection element fGetDetElt[0] corresponding to the position. In the case 
+///of an overlap (two detection element with the same (X,Y)) fGetDetElt[1] is calculated.
+///
+
+    Int_t nbrOfDetElt =  AliMpDEManager::GetNofDEInChamber(chamber, kTRUE); //!<Number of detection elements in the chamber.
+    Int_t detElt = 0, lastDetElt = 0;
+
+    Double_t posXL, posYL, posZL; //!<Local positions.
+    posXL = posYL = posZL = 1000.;
+    fGetDetElt[0] = fGetDetElt[1] = 0;
+
+    if(chamber>3)
+    {
+      Int_t shift  = 0;                                                    //!<|
+      if(posX<0) shift =    nbrOfDetElt /4 + 1;                            //!<|Method to avoid the loop on all elements of
+      if(posX>0) shift = (3*nbrOfDetElt)/4 + 1;                            //!<|detection, and just loop through fourth chamber.
+                                                                           //!<|
+      detElt = fOffset*(chamber+1) + shift;                                //!<|
+      lastDetElt = fOffset*(chamber+1) +(shift+nbrOfDetElt/2)%nbrOfDetElt; //!<|
+      
+      Int_t nbr = 0;
+      while(detElt != lastDetElt) //!<Loop on fourth chamber.
+      {
+
+       fTransformer->Global2Local(detElt, posX, posY, posZ, posXL, posYL, posZL);  //!<Transfomation from global to local positions.
+
+       if(abs(posYL)< fYSlatSize) //!<If |posYL|<20 => the cluster is in the detection element (-20<Ylocal<20 for each slat).  
+       {
+         fGetDetElt[nbr] = detElt;  
+         ++nbr;
+       }       
+       shift  = (shift + 1)%nbrOfDetElt;
+       detElt = fOffset*(chamber+1) + shift;
+      }
+    }
+    
+    else //!<For the station 1 & 2 (4 detection elements in each chamber). 
+    {
+      if(posX>0 & posY>0) fGetDetElt[0] = fOffset*(chamber+1)    ;
+      if(posX<0 & posY>0) fGetDetElt[0] = fOffset*(chamber+1) + 1;
+      if(posX<0 & posY<0) fGetDetElt[0] = fOffset*(chamber+1) + 2;
+      if(posX>0 & posY<0) fGetDetElt[0] = fOffset*(chamber+1) + 3; 
+    }
+}
diff --git a/PWG3/muondep/AliCheckMuonDetEltResponse.h b/PWG3/muondep/AliCheckMuonDetEltResponse.h
new file mode 100644 (file)
index 0000000..14c778f
--- /dev/null
@@ -0,0 +1,90 @@
+#ifndef ALICHECKMUONDETELTRESPONSE_H 
+#define ALICHECKMUONDETELTRESPONSE_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/// \ingroup base
+/// \class AliCheckMuonDetEltResponse
+/// \brief tracking chamber efficiency from data
+//Author: Nicolas LE BRIS - SUBATECH Nantes
+
+#include <TH2F.h>
+#include <TObject.h>
+#include <TClonesArray.h>
+
+class AliMUONTrackParam;
+class AliMUONTrack;
+class AliMUONVCluster;
+class AliMUONGeometryTransformer;
+class AliESDEvent;
+
+class AliCheckMuonDetEltResponse : public TObject
+{
+public:
+
+//Default constructor:
+  AliCheckMuonDetEltResponse();
+
+//Constructor:
+  AliCheckMuonDetEltResponse(const AliMUONGeometryTransformer* transformer,
+                            AliESDEvent* esd,
+                            TClonesArray* detEltTDHistList,
+                            TClonesArray* detEltTTHistList);
+
+//Destructor:
+  virtual ~AliCheckMuonDetEltResponse();
+
+
+  void CheckDetEltResponse ();
+  void TrackLoop ();
+  void TrackParamLoop ();
+private:
+  
+  void FillDetEltTDHisto (Int_t chamber, Int_t detElt,
+                         Double_t posXL, Double_t posYL);
+
+  void FillDetEltTTHisto (Int_t chamber, Int_t detElt,
+                         Double_t posXG, Double_t posYG, Double_t posZG,
+                         Double_t posXL, Double_t posYL, Double_t posZL);
+
+  void CalculMissClusterParam (AliMUONTrackParam* extrapTrackParam,
+                              Int_t firstMissCh, Int_t nbrOfMissCh);
+
+  void GetDetEltFromPosition (Int_t chamber,
+                             Double_t posX, Double_t posY, Double_t posZ);
+
+
+  Int_t fNCh; //!<Number of tracking chamber.
+  Int_t fNSt; //!<Number of tracking station.
+  Int_t fNDE; //!<Number of detection element in the tracking system.
+
+  Int_t FromDetElt2iDet (Int_t chamber, Int_t detElt);
+
+  const AliMUONGeometryTransformer* fTransformer; //!<Geometry transformer
+
+  AliESDEvent* fESD;
+
+  Int_t fNbrClustersCh[10];      //!<Number of clusters in the chamber [fChamberNbr].
+  Int_t fTracksTotalNbr;         //!<Total number of tracks in the event.
+  Int_t fGetDetElt[2];           //!<Detection elemtents obtained from position(X,Y,Z). fGetDetElt[1] is for the case where there is an overlap.
+  Int_t fTrackFilter[10];        //!<To select track for the efficiency calculation.
+
+  TClonesArray     * fTrackParams;
+  AliMUONTrackParam* fTrackParam;
+  AliMUONVCluster  * fCluster;
+
+  TClonesArray* fDetEltTDHistList; //!<List of histograms of the tracks detected in the detection elements 
+  TClonesArray* fDetEltTTHistList; //!<List of histograms of the tracks which have passed through the detection elements
+
+  static const Int_t fNbrOfChamber;            ///< The total number of chamber in the tracking system.
+  static const Int_t fNbrOfStation;            ///< The total number of station in the tracking system.
+  static const Int_t fNbrOfDetectionElt[10];   ///< The total number of detection element in each chamber.
+  static const Int_t fFirstDetectionElt[10];   ///< The Id of the first detection element of each chamber.
+  static const Int_t fOffset;                  ///< fFirstDetectionElt[iChamber] = fOffset * (iChamber+1).
+  static const Int_t fOverlapSize;             ///< Average size (in cm) of the overlap area between two detection eltement.
+  static const Int_t fYSlatSize;               ///< Average size (in cm) of the overlap area between two detection eltement.
+
+  ClassDef(AliCheckMuonDetEltResponse, 0)
+};
+#endif
diff --git a/PWG3/muondep/MuonTrackingEffAnalysis.C b/PWG3/muondep/MuonTrackingEffAnalysis.C
new file mode 100644 (file)
index 0000000..fa4636f
--- /dev/null
@@ -0,0 +1,80 @@
+// 2008
+// Macro for the running of the AliAnalysisTaskMuonTrackingEff
+//
+
+// ROOT includes
+#include <TROOT.h>
+#include <TSystem.h>
+#include <TChain.h>
+#include <TFile.h>
+#include <TClonesArray.h>
+
+// PWG3 includes
+#include "AliAnalysisTaskMuonTrackingEff.h"
+
+// ANALYSIS includes
+#include "AliAnalysisManager.h"
+#include "AliAnalysisDataContainer.h"
+
+// STEER includes
+#include "AliESDInputHandler.h"
+#include "AliCDBManager.h"
+
+// MUON includes
+#include "AliMUONGeometryTransformer.h"
+
+
+
+void MuonTrackingEffAnalysis(const Bool_t alien = false, const Int_t run = 100, const char * fileName = "AliESDs.root", const char * geometryFileName = "geometry.root")
+{
+//Chain construction
+    TChain *chain = new TChain("esdTree");
+    chain->Add(fileName);
+
+//Load OCD
+    AliCDBManager* man = AliCDBManager::Instance();
+    TString ocdbPath;
+    if(alien)
+    {
+      ocdbPath = "alien://folder=/alice/data/2008/LHC08a/OCDB";
+    }
+    else
+    {
+      ocdbPath = "local://$ALICE_ROOT";
+    }
+
+    man->SetDefaultStorage(ocdbPath.Data());
+    man->SetSpecificStorage("MUON/Calib/Mapping",ocdbPath);
+    man->SetRun(run);
+//Load Geometry
+    AliMUONGeometryTransformer* transformer = new AliMUONGeometryTransformer();
+    transformer->LoadGeometryData(geometryFileName);
+
+
+//Make analysis manager:
+    AliAnalysisManager* mgr = new AliAnalysisManager("Manager", "Manager");  
+    AliAnalysisTaskMuonTrackingEff* ESDTask = new AliAnalysisTaskMuonTrackingEff("ESDTask", transformer);
+    AliESDInputHandler* inHandler = new AliESDInputHandler();
+
+    mgr->SetInputEventHandler  (inHandler );
+//     mgr->SetDebugLevel(10);
+    mgr->AddTask(ESDTask);
+
+//Create containers for input/output
+    AliAnalysisDataContainer* cinput1  =
+       mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
+    AliAnalysisDataContainer *coutput1 =
+       mgr->CreateContainer("chistlist1", TClonesArray::Class(),AliAnalysisManager::kOutputContainer, "MuonTrackingChamberEffHistos.root"); 
+
+//Connection
+    mgr->ConnectInput (ESDTask, 0, cinput1 );
+    mgr->ConnectOutput(ESDTask, 0, coutput1);
+   
+//Run analysis
+    if(mgr->InitAnalysis())
+    {
+      //mgr->PrintStatus();
+      mgr->StartAnalysis("Local", chain);
+    }
+} 
diff --git a/PWG3/muondep/RunMuonTrackingEffAnalysis.C b/PWG3/muondep/RunMuonTrackingEffAnalysis.C
new file mode 100644 (file)
index 0000000..4806689
--- /dev/null
@@ -0,0 +1,83 @@
+// 2008
+// Macro for the running of the AliAnalysisTaskMuonTrackingEff
+//
+
+void RunMuonTrackingEffAnalysis (Bool_t alien = false,
+                                const char * macroFileName = "$ALICE_ROOT/PWG3/muon/MuonTrackingEffAnalysis.C",
+                                const char * esdfileName = "AliESDs.root",
+                                const char * geometryFileName = "geometry.root",
+                                const char * analysisParFile = "ANALYSIS",
+                                const char * pwg3ParFile = "PWG3",
+                                const Int_t run = 100)
+{
+    if(alien)
+    {
+    //Grid connection    
+      printf("*** Connect to AliEn ***\n");
+      TGrid::Connect("alien://");
+      gSystem->Load("libProofPlayer.so");
+    }
+
+// //Load relevant libraries:
+//     gSystem->Load("libTree.so");
+//     gSystem->Load("libGeom.so");
+//     gSystem->Load("libSTEERBase.so");
+
+// //  setupPar("MUON");
+//     gSystem->Load("libMUONbase.so");
+//     gSystem->Load("libMUONgeometry.so");
+//     gSystem->Load("libMUONmapping.so");
+
+// //  setupPar("ESD");
+//     gSystem->Load("libESD.so");
+
+//  setupPar(analysisParFile);
+    gSystem->Load("libANALYSIS.so");
+    gSystem->Load("libANALYSISalice.so");
+//  setupPar(pwg3ParFile);
+    gSystem->Load("libPWG3muon.so");
+
+    char macro[1024];
+    sprintf(macro,"%s++",macroFileName);
+    gROOT->LoadMacro(macro);
+//     gROOT->LoadMacro("./BatchMuonTrackingEffAnalysis.C++");
+    MuonTrackingEffAnalysis(alien,run,esdfileName,geometryFileName);
+}
+
+
+
+Int_t setupPar(const char* pararchivename)
+{
+    //Setup PAR File
+    if (pararchivename) {
+      char processline[1024];
+      sprintf(processline,".! tar xvzf %s.par",pararchivename);
+      gROOT->ProcessLine(processline);
+      const char* ocwd = gSystem->WorkingDirectory();
+      gSystem->ChangeDirectory(pararchivename);
+      
+      // check for BUILD.sh and execute
+      if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+       printf("*******************************\n");
+       printf("*** Building PAR archive    ***\n");
+       printf("*******************************\n");
+      
+       if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+         Error("runAnalysis","Cannot Build the PAR Archive! - Abort!");
+         return -1;
+       }
+      }
+      // check for SETUP.C and execute
+      if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+       printf("*******************************\n");
+       printf("*** Setup PAR archive       ***\n");
+       printf("*******************************\n");
+       gROOT->Macro("PROOF-INF/SETUP.C");
+      }
+      
+      gSystem->ChangeDirectory("../");
+    }                                                                                                                                               
+    return 1;
+}