]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/dielectron/AliDielectronTrackRotator.cxx
Add fast merging option (Diego)
[u/mrichter/AliRoot.git] / PWG3 / dielectron / AliDielectronTrackRotator.cxx
CommitLineData
2a14a7b1 1/*************************************************************************
2* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16///////////////////////////////////////////////////////////////////////////
17// Dielectron TrackRotator //
18// //
19// //
20/*
21Detailed description
22
23
24*/
25// //
26///////////////////////////////////////////////////////////////////////////
27
28#include <TMath.h>
2a14a7b1 29#include <TRandom3.h>
1201a1a9 30#include <TObjArray.h>
31
32#include <AliVTrack.h>
33
34#include "AliDielectronHelper.h"
2a14a7b1 35
36#include "AliDielectronTrackRotator.h"
37
38ClassImp(AliDielectronTrackRotator)
39
40AliDielectronTrackRotator::AliDielectronTrackRotator() :
41 TNamed(),
42 fIterations(1),
43 fRotationType(kRotateBothRandom),
44 fStartAnglePhi(TMath::Pi()),
45 fConeAnglePhi(TMath::Pi()/6.),
46 fkArrTracksP(0x0),
47 fkArrTracksN(0x0),
48 fCurrentIteration(0),
49 fCurrentTackP(0),
50 fCurrentTackN(0),
1201a1a9 51 fEvent(0x0),
52 fTrackP(),
53 fTrackN(),
54 fVTrackP(0x0),
55 fVTrackN(0x0),
56 fPdgLeg1(-11),
57 fPdgLeg2(11)
2a14a7b1 58{
59 //
60 // Default Constructor
61 //
62 gRandom->SetSeed();
63}
64
65//______________________________________________
66AliDielectronTrackRotator::AliDielectronTrackRotator(const char* name, const char* title) :
67 TNamed(name, title),
68 fIterations(1),
69 fRotationType(kRotateBothRandom),
70 fStartAnglePhi(TMath::Pi()),
71 fConeAnglePhi(TMath::Pi()/6.),
72 fkArrTracksP(0x0),
73 fkArrTracksN(0x0),
74 fCurrentIteration(0),
75 fCurrentTackP(0),
76 fCurrentTackN(0),
1201a1a9 77 fEvent(0x0),
78 fTrackP(),
79 fTrackN(),
80 fVTrackP(0x0),
81 fVTrackN(0x0),
82 fPdgLeg1(-11),
83 fPdgLeg2(11)
2a14a7b1 84{
85 //
86 // Named Constructor
87 //
88 gRandom->SetSeed();
89}
90
91//______________________________________________
92AliDielectronTrackRotator::~AliDielectronTrackRotator()
93{
94 //
95 // Default Destructor
96 //
97
98}
99
100//______________________________________________
101void AliDielectronTrackRotator::Reset()
102{
103 //
104 // Reset the current iterators
105 //
106 fCurrentIteration=0;
107 fCurrentTackP=0;
108 fCurrentTackN=0;
109}
110
111//______________________________________________
112Bool_t AliDielectronTrackRotator::NextCombination()
113{
114 //
115 // Perform track rotation of the tracks in the track arrays as long as there are possible combinations
116 //
117 if (!fkArrTracksP || !fkArrTracksP) {
118 Reset();
119 return kFALSE;
120 }
121
122 Int_t nP=fkArrTracksP->GetEntriesFast();
123 Int_t nN=fkArrTracksN->GetEntriesFast();
124 if (nP==0||nN==0){
125 Reset();
126 return kFALSE;
127 }
128
129 if (fCurrentIteration==fIterations){
130 fCurrentIteration=0;
131 ++fCurrentTackP;
132 }
133
134 if (fCurrentTackP==nP){
135 ++fCurrentTackN;
136 fCurrentTackP=0;
137 }
138
139 if (fCurrentTackN==nN){
140 Reset();
141 return kFALSE;
142 }
143
144 if (!RotateTracks()){
145 Reset();
146 return kFALSE;
147 }
148
149 ++fCurrentIteration;
150 return kTRUE;
151}
152
153//______________________________________________
154Bool_t AliDielectronTrackRotator::RotateTracks()
155{
156 //
157 // Actual track rotation
158 // Find out particle type and perform the rotation
159 //
ffbede40 160
1201a1a9 161 AliVTrack *trackP=dynamic_cast<AliVTrack*>(fkArrTracksP->UncheckedAt(fCurrentTackP));
162 AliVTrack *trackN=dynamic_cast<AliVTrack*>(fkArrTracksN->UncheckedAt(fCurrentTackN));
163 fTrackP.Initialize();
164 fTrackN.Initialize();
165 fVTrackP=0x0;
166 fVTrackN=0x0;
2a14a7b1 167 if (!trackP||!trackN) return kFALSE;
1201a1a9 168 fTrackP+=AliKFParticle(*trackP,fPdgLeg1);
169 fTrackN+=AliKFParticle(*trackN,fPdgLeg2);
2a14a7b1 170
1201a1a9 171 fVTrackP=trackP;
172 fVTrackN=trackN;
2a14a7b1 173
174 Double_t angle = fStartAnglePhi+(2*gRandom->Rndm()-1)*fConeAnglePhi;
175 Int_t charge = TMath::Nint(gRandom->Rndm());
176
1201a1a9 177 if (fRotationType==kRotatePositive||(fRotationType==kRotateBothRandom&&charge==0)){
178 AliDielectronHelper::RotateKFParticle(&fTrackP, angle, fEvent);
179 }
180
181 if (fRotationType==kRotateNegative||(fRotationType==kRotateBothRandom&&charge==1)){
182 AliDielectronHelper::RotateKFParticle(&fTrackN, angle, fEvent);
2a14a7b1 183 }
184
185 return kTRUE;
186}