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 **************************************************************************/
20 #include <TParticle.h>
22 #include "AliAnalysisTaskESDMCLabelAddition.h"
23 #include "AliAnalysisManager.h"
24 #include "AliESDEvent.h"
25 #include "AliAODEvent.h"
26 #include "AliESDInputHandler.h"
27 #include "AliAODHandler.h"
28 #include "AliAnalysisFilter.h"
29 #include "AliESDtrack.h"
30 #include "AliESDMuonTrack.h"
31 #include "AliESDMuonCluster.h"
32 #include "AliESDVertex.h"
33 #include "AliMultiplicity.h"
36 #include "AliMCEvent.h"
37 #include "AliMCEventHandler.h"
38 #include "AliAODMCParticle.h"
40 #include "AliMUONRecoCheck.h"
41 #include "AliMUONESDInterface.h"
42 #include "AliMUONTrack.h"
43 #include "AliMUONTrackParam.h"
44 #include "AliMUONVTrackStore.h"
45 #include "AliMUONVCluster.h"
46 #include "AliMUONVClusterStore.h"
48 ClassImp(AliAnalysisTaskESDMCLabelAddition)
50 // sigma cut applied to match a reconstructed cluster with a trackref
51 const Double_t AliAnalysisTaskESDMCLabelAddition::fgkSigmaCut = 10.;
53 //----------------------------------------------------------------------
54 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition():
57 // Default constructor
61 //----------------------------------------------------------------------
62 AliAnalysisTaskESDMCLabelAddition::AliAnalysisTaskESDMCLabelAddition(const char* name):
63 AliAnalysisTaskSE(name)
69 //----------------------------------------------------------------------
70 void AliAnalysisTaskESDMCLabelAddition::UserCreateOutputObjects()
75 //----------------------------------------------------------------------
76 void AliAnalysisTaskESDMCLabelAddition::Init()
78 AliDebug(2, "Init()");
82 //----------------------------------------------------------------------
83 void AliAnalysisTaskESDMCLabelAddition::UserExec(Option_t */*option*/)
85 // Execute analysis for current event
86 Long64_t ientry = Entry();
87 AliDebug(1, Form("MCLabel Addition: Analysing event # %5d\n",(Int_t) ientry));
92 //----------------------------------------------------------------------
93 void AliAnalysisTaskESDMCLabelAddition::AddMCLabel()
96 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
98 AliError("Cannot get input event");
103 AliMCEventHandler *mcH = 0;
104 if(MCEvent()) mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
106 // Get reference tracks
107 AliMUONRecoCheck rc(esd,mcH);
108 AliMUONVTrackStore* trackRefStore = rc.TrackRefs(-1);
110 // Loop over reconstructed tracks
111 AliESDMuonTrack *esdTrack = 0x0;
112 Int_t nMuTracks = esd->GetNumberOfMuonTracks();
113 for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack) {
115 esdTrack = esd->GetMuonTrack(nMuTrack);
118 if (!esdTrack->ContainTrackerData()) continue;
120 // convert ESD track to MUON track (without recomputing track parameters at each clusters)
121 AliMUONTrack muonTrack;
122 AliMUONESDInterface::ESDToMUON(*esdTrack, muonTrack, kFALSE);
124 // try to match the reconstructed track with a simulated one
125 Int_t nMatchClusters = 0;
126 AliMUONTrack* matchedTrackRef = rc.FindCompatibleTrack(muonTrack, *trackRefStore, nMatchClusters, kFALSE, fgkSigmaCut);
129 if (matchedTrackRef) esdTrack->SetLabel(matchedTrackRef->GetUniqueID());
130 else esdTrack->SetLabel(-1);
137 //----------------------------------------------------------------------
138 void AliAnalysisTaskESDMCLabelAddition::Terminate(Option_t */*option*/)
140 // Terminate analysis
142 AliDebug(2, "Terminate()");