setter to assume pion mass for clusters
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / AliJetModelMergeBranches.cxx
CommitLineData
5bed89d0 1// $Id$
2//
3// Jet model task to merge to existing branches
4// only implemented for track branches
5//
6// Author: M. Verweij
7
8#include "AliJetModelMergeBranches.h"
9
10#include <TClonesArray.h>
11#include <TFolder.h>
12#include <TLorentzVector.h>
13#include <TParticle.h>
14#include <TParticlePDG.h>
15#include <TRandom3.h>
16#include <TProfile.h>
17#include "AliAnalysisManager.h"
18#include "AliEMCALDigit.h"
19#include "AliEMCALGeometry.h"
20#include "AliEMCALRecPoint.h"
21#include "AliGenerator.h"
22#include "AliHeader.h"
23#include "AliLog.h"
24#include "AliPicoTrack.h"
25#include "AliRun.h"
26#include "AliRunLoader.h"
27#include "AliStack.h"
28#include "AliStack.h"
29#include "AliVCluster.h"
30#include "AliVEvent.h"
31
32ClassImp(AliJetModelMergeBranches)
33
34//________________________________________________________________________
35AliJetModelMergeBranches::AliJetModelMergeBranches() :
36 AliJetModelBaseTask("AliJetModelMergeBranches"),
37 fTracksMergeName(),
38 fTracksMerge(0)
39{
40 // Default constructor.
41 SetSuffix("Merged");
42 SetCopyArray(kTRUE);
43}
44
45//________________________________________________________________________
46AliJetModelMergeBranches::AliJetModelMergeBranches(const char *name) :
47 AliJetModelBaseTask(name),
48 fTracksMergeName(),
49 fTracksMerge(0)
50{
51 // Standard constructor.
52 SetSuffix("Merged");
53 SetCopyArray(kTRUE);
54}
55
56//________________________________________________________________________
57AliJetModelMergeBranches::~AliJetModelMergeBranches()
58{
59 // Destructor
60}
61
62//________________________________________________________________________
63Bool_t AliJetModelMergeBranches::ExecOnce()
64{
65 // Exec only once.
66
67 AliJetModelBaseTask::ExecOnce();
68
69 if (!fTracksMergeName.IsNull()) {
70 fTracksMerge = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksMergeName));
71 if (!fTracksMerge) {
72 AliWarning(Form("%s: Couldn't retrieve tracks with name %s!", GetName(), fTracksMergeName.Data()));
73 }
74 else if (!fTracksMerge->GetClass()->GetBaseClass("AliPicoTrack")) {
75 AliError(Form("%s: Collection %s does not contain AliPicoTrack objects!", GetName(), fTracksMergeName.Data()));
76 fTracksMerge = 0;
77 return kFALSE;
78 }
79 }
80
81 return kTRUE;
82}
83
84//________________________________________________________________________
85void AliJetModelMergeBranches::Run()
86{
87 // Merge two branches into a new one
88
89 CopyTracks();
90 MergeTracks();
91}
92
93//________________________________________________________________________
94void AliJetModelMergeBranches::MergeTracks()
95{
96 // Copy all the tracks in the new collection
97
98 if (!fTracksMerge)
99 return;
100
101 const Int_t nTracks = fTracksMerge->GetEntriesFast();
102 Int_t nCopiedTracks = fOutTracks->GetEntriesFast();
103 for (Int_t i = 0; i < nTracks; ++i) {
104 AliPicoTrack *picotrack = static_cast<AliPicoTrack*>(fTracksMerge->At(i));
105 if (!picotrack)
106 continue;
107 AliPicoTrack *track = new ((*fOutTracks)[nCopiedTracks]) AliPicoTrack(*picotrack);
255670f9 108 track->SetBit(TObject::kBitMask,1);
5bed89d0 109 nCopiedTracks++;
110 }
111}