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 **************************************************************************/
19 // Implementation of a branch replicator
20 // to produce slim muon and dimuon aods.
22 // This replicator is in charge of replicating the tracks,vertices and dimuons
23 // branches of the standard AOD into muon AODs (AliAOD.Muons.root and
24 // AliAOD.Dimuons.root)
26 // The tracks are filtered so that only muon tracks (and only muon tracks
27 // that pass the trackCut if present) make it to the output aods
29 // The vertices are filtered so that only the primary vertices make it
30 // to the output aods.
32 // The dimuons are recreated here, according to the set of tracks
33 // that pass the trackCut (that set may be the same as the input set,
34 // but to be 100% safe, we always recreate the dimuons).
36 // Author: L. Aphecetche (Subatech)
38 #include "AliAODMuonReplicator.h"
39 #include "AliAnalysisCuts.h"
40 #include "AliAODEvent.h"
41 #include "AliAODTrack.h"
42 #include "AliAODDimuon.h"
45 ClassImp(AliAODMuonReplicator)
47 //_____________________________________________________________________________
48 AliAODMuonReplicator::AliAODMuonReplicator(const char* name, const char* title,
49 AliAnalysisCuts* trackCut,
50 AliAnalysisCuts* vertexCut)
51 : AliAODBranchReplicator(name,title),
52 fTrackCut(trackCut), fTracks(0x0),
53 fVertexCut(vertexCut), fVertices(0x0),
60 //_____________________________________________________________________________
61 AliAODMuonReplicator::~AliAODMuonReplicator()
69 //_____________________________________________________________________________
70 TList* AliAODMuonReplicator::GetList() const
72 // return (and build if not already done) our internal list of managed objects
75 fTracks = new TClonesArray("AliAODTrack",30);
76 fTracks->SetName("tracks");
78 fVertices = new TClonesArray("AliAODVertex",2);
79 fVertices->SetName("vertices");
81 fDimuons = new TClonesArray("AliAODDimuon",2);
82 fDimuons->SetName("dimuons");
85 fList->SetOwner(kTRUE);
88 fList->Add(fVertices);
94 //_____________________________________________________________________________
95 void AliAODMuonReplicator::ReplicateAndFilter(const AliAODEvent& source)
97 // Replicate (and filter if filters are there) the relevant parts we're interested in AODEvent
103 assert(fTracks!=0x0);
105 TIter next(source.GetTracks());
110 while ( ( t = static_cast<AliAODTrack*>(next()) ) )
112 if ( !fTrackCut || fTrackCut->IsSelected(t) )
114 new((*fTracks)[ntracks++]) AliAODTrack(*t);
118 assert(fVertices!=0x0);
119 fVertices->Clear("C");
120 TIter nextV(source.GetVertices());
124 while ( ( v = static_cast<AliAODVertex*>(nextV()) ) )
126 if ( !fVertexCut || fVertexCut->IsSelected(v) )
128 AliAODVertex* tmp = v->CloneWithoutRefs();
129 new((*fVertices)[nvertices++]) AliAODVertex(*tmp);
134 fDimuons->Clear("C");
136 // as there might be a track cut (different from the one of the main filtering),
137 // we must recreate the dimuon completely from scratch to be 100% safe...
141 for ( Int_t i = 0; i < ntracks; ++i )
143 for ( Int_t j = i+1; j < ntracks; ++j )
145 new((*fDimuons)[ndimuons++]) AliAODDimuon(fTracks->At(i),fTracks->At(j));
149 AliDebug(1,Form("n=%d tracks=%d vertices=%d ndimuons=%d",n,fTracks->GetEntries(),fVertices->GetEntries(),fDimuons->GetEntries()));