MUON task for the analysis train to fill the muon information in the generic AODs...
authormartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Apr 2008 13:32:08 +0000 (13:32 +0000)
committermartinez <martinez@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 11 Apr 2008 13:32:08 +0000 (13:32 +0000)
PWG3/AliAnalysisTaskESDMuonFilter.cxx [new file with mode: 0644]
PWG3/AliAnalysisTaskESDMuonFilter.h [new file with mode: 0644]
PWG3/PWG3baseLinkDef.h
PWG3/READMEmuon
PWG3/RunESDMuonFilter.C [new file with mode: 0644]
PWG3/libPWG3base.pkg

diff --git a/PWG3/AliAnalysisTaskESDMuonFilter.cxx b/PWG3/AliAnalysisTaskESDMuonFilter.cxx
new file mode 100644 (file)
index 0000000..0eb3b32
--- /dev/null
@@ -0,0 +1,226 @@
+/**************************************************************************
+ * 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 p_pos[3];
+    Double_t p_neg[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");
+}
diff --git a/PWG3/AliAnalysisTaskESDMuonFilter.h b/PWG3/AliAnalysisTaskESDMuonFilter.h
new file mode 100644 (file)
index 0000000..33c7466
--- /dev/null
@@ -0,0 +1,44 @@
+#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 "/n60raid3/alice/roberta/Trunk/AliRoot/ANALYSIS/AliAnalysisTaskSE.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;}
+    virtual void SetKinkFilter (AliAnalysisFilter*  KinkF) {fKinkFilter  =  KinkF;}
+    virtual void SetV0Filter   (AliAnalysisFilter*    V0F) {fV0Filter    =    V0F;}
+
+ private:
+    AliAnalysisTaskESDMuonFilter(const AliAnalysisTaskESDMuonFilter&);
+    AliAnalysisTaskESDMuonFilter& operator=(const AliAnalysisTaskESDMuonFilter&);
+    AliAnalysisFilter* fTrackFilter; //  Track Filter
+    AliAnalysisFilter* fKinkFilter;  //  Kink  Filter
+    AliAnalysisFilter* fV0Filter;    //  V0    Filter    
+    ClassDef(AliAnalysisTaskESDMuonFilter, 1); // Analysis task for standard ESD filtering
+};
+#endif
index f0bd794..d7a4e82 100644 (file)
@@ -21,6 +21,7 @@
 #pragma link C++ class AliAnalysisTaskMuonAODfromGeneral+;
 #pragma link C++ class AliAnalysisTaskSingleMu+;
 #pragma link C++ class AliAnalysisTaskLUT+;
+#pragma link C++ class AliAnalysisTaskESDMuonFilter+;
 #endif
 
 
index 5604afa..98afc1a 100644 (file)
@@ -1,3 +1,18 @@
+---------------------------------------------------------------
+ ESDMuonFilter task for filling the muon iformation in the AOD from the ESD
+ Roberta ARNALDI, Torino
+---------------------------------------------------------------
+
+1)  RunESDMuonFilter.C --> macro to run locally the AliAnalysisTaskESDMuonFilter
+2) AliAnalysisTaskESDMuonFilter.h  --> analysis task to produce the Muon AOD from ESD
+3) AliAnalysisTaskESDMuonFilter.cxx --> analysis task to produce the Muon AOD from ESD
+4) libPWG3base.pkg
+5) PWG3baseLinkDef.h 
+
+---------------------------------------------------------------
+ Calculation of the LUT 
+ Bogdan VULPESCU, Clermont
+---------------------------------------------------------------
 Analysis task for the calculation of the Look-up-Tables used by the MUON
 trigger algorithm
 
@@ -22,5 +37,5 @@ runCreateLUTNT.C         - macro for setting the libraries environment and
 analysisTaskLUTNT.C      - main macro for the analysis
 
 createLUTNT.jdl          - JDL file
-
+---------------------------------------------------------------
 
diff --git a/PWG3/RunESDMuonFilter.C b/PWG3/RunESDMuonFilter.C
new file mode 100644 (file)
index 0000000..4a34ab3
--- /dev/null
@@ -0,0 +1,89 @@
+// Macro to run AliAnalysisTaskESDMuonFilter
+//
+
+void RunESDMuonFilter(char* filein = "AliESDs.root", char* fileout = "AliMuonAOD.root" ){
+     
+    gSystem->Load("libTree.so"); 
+    gSystem->Load("libGeom.so");
+    gSystem->Load("libVMC.so");
+    gSystem->Load("libPhysics");
+    
+    // for analysis .par file based
+    
+    setupPar("STEERBase");
+    setupPar("ESD");
+    setupPar("AOD");
+    setupPar("ANALYSIS");
+    setupPar("ANALYSISalice");
+    setupPar("PWG3base");
+    
+    // Input ESD file
+    TChain* chain = new TChain("esdTree");  
+    chain->Add(filein);
+    AliESDInputHandler* esdHandler = new AliESDInputHandler();
+
+    // Make aod output handler
+    AliAODHandler* aodHandler = new AliAODHandler();
+    aodHandler->SetOutputFileName(fileout);
+    
+    // Make the analysis manager
+    AliAnalysisManager *mgr  = new AliAnalysisManager("Muon AOD Manager", "Muon AOD Manager");
+    mgr->SetInputEventHandler(esdHandler);
+    mgr->SetOutputEventHandler(aodHandler);
+    mgr-> SetDebugLevel(10);
+    
+    // Task for MUON AOD generation 
+    AliAnalysisTaskESDMuonFilter *esdfilter = new AliAnalysisTaskESDMuonFilter("ESD Muon Filter");
+    mgr->AddTask(esdfilter);
+  
+    // Create containers for input/output
+    AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cESD",TChain::Class(), 
+                                                            AliAnalysisManager::kInputContainer);
+    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("cAOD", TTree::Class(),
+                                                             AliAnalysisManager::kOutputContainer, "default");
+
+    mgr->ConnectInput  (esdfilter,  0, cinput1  );
+    mgr->ConnectOutput (esdfilter,  0, coutput1 );
+    
+    // Run the analysis    
+    mgr->InitAnalysis();
+    mgr->PrintStatus();
+    mgr->StartAnalysis("local",chain);
+}
+
+
+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;
+}
index 1d00846..7b71e87 100644 (file)
@@ -8,7 +8,7 @@ SRCS:= AliQuarkoniaAcceptance.cxx \
        AliAnalysisTaskSESelectHF.cxx \
        AliAODDimuon.cxx AliAODEventInfo.cxx \
        AliAnalysisTaskMuonAODfromGeneral.cxx AliAnalysisTaskSingleMu.cxx \
-       AliAnalysisTaskLUT.cxx
+       AliAnalysisTaskLUT.cxx AliAnalysisTaskESDMuonFilter.cxx
      
 HDRS:= $(SRCS:.cxx=.h)