1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 #include <TParticle.h>
20 #include "AliAnalysisTaskESDMCLabelAddition.h"
21 #include "AliAnalysisManager.h"
22 #include "AliESDEvent.h"
23 #include "AliAODEvent.h"
24 #include "AliESDInputHandler.h"
25 #include "AliAODHandler.h"
26 #include "AliAnalysisFilter.h"
27 #include "AliESDtrack.h"
28 #include "AliESDMuonTrack.h"
29 #include "AliESDMuonCluster.h"
30 #include "AliESDVertex.h"
31 #include "AliMultiplicity.h"
34 #include "AliMCEvent.h"
35 #include "AliMCEventHandler.h"
36 #include "AliAODMCParticle.h"
38 #include "AliMUONRecoCheck.h"
39 #include "AliMUONESDInterface.h"
40 #include "AliMUONTrack.h"
41 #include "AliMUONTrackParam.h"
42 #include "AliMUONVTrackStore.h"
43 #include "AliMUONVCluster.h"
44 #include "AliMUONVClusterStore.h"
46 ClassImp(AliAnalysisTaskESDMCLabelAddition)
48 // sigma cut applied to match a reconstructed cluster with a trackref
49 const Double_t AliAnalysisTaskESDMCLabelAddition::fgkSigmaCut = 10.;
51 //----------------------------------------------------------------------
52 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition():
55 // Default constructor
59 //----------------------------------------------------------------------
60 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition(const char* name):
61 AliAnalysisTaskSE(name)
67 //----------------------------------------------------------------------
68 void AliAnalysisTaskESDMCLabelAddition::UserCreateOutputObjects()
73 //----------------------------------------------------------------------
74 void AliAnalysisTaskESDMCLabelAddition::Init()
76 AliDebug(2, "Init()");
80 //----------------------------------------------------------------------
81 void AliAnalysisTaskESDMCLabelAddition::UserExec(Option_t */*option*/)
83 // Execute analysis for current event
84 Long64_t ientry = Entry();
85 AliDebug(1, Form("MCLabel Addition: Analysing event # %5d\n",(Int_t) ientry));
90 //----------------------------------------------------------------------
91 void AliAnalysisTaskESDMCLabelAddition::AddMCLabel()
94 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
97 AliMCEventHandler *mcH = 0;
98 if(MCEvent()) mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
100 // Get reference tracks
101 AliMUONRecoCheck rc(esd,mcH);
102 AliMUONVTrackStore* trackRefStore = rc.TrackRefs(-1);
104 // Loop over reconstructed tracks
105 AliESDMuonTrack *esdTrack = 0x0;
106 Int_t nMuTracks = esd->GetNumberOfMuonTracks();
107 for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {
109 esdTrack = esd->GetMuonTrack(nMuTrack);
112 if (!esdTrack->ContainTrackerData()) continue;
114 // convert ESD track to MUON track (without recomputing track parameters at each clusters)
115 AliMUONTrack muonTrack;
116 AliMUONESDInterface::ESDToMUON(*esdTrack, muonTrack, kFALSE);
118 // try to match the reconstructed track with a simulated one
119 Int_t nMatchClusters = 0;
120 AliMUONTrack* matchedTrackRef = rc.FindCompatibleTrack(muonTrack, *trackRefStore, nMatchClusters, kFALSE, fgkSigmaCut);
123 if (matchedTrackRef) esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
124 else esdTrack->SetLabel(-1);
131 //----------------------------------------------------------------------
132 void AliAnalysisTaskESDMCLabelAddition::Terminate(Option_t */*option*/)
134 // Terminate analysis
136 AliDebug(2, "Terminate()");