1 /*************************************************************************
2 * Copyright(c) 1998-2009, 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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Dielectron TrackRotator //
26 ///////////////////////////////////////////////////////////////////////////
29 #include <TObjArray.h>
30 #include <AliAODTrack.h>
31 #include <AliESDtrack.h>
34 #include "AliDielectronTrackRotator.h"
36 ClassImp(AliDielectronTrackRotator)
38 AliDielectronTrackRotator::AliDielectronTrackRotator() :
41 fRotationType(kRotateBothRandom),
42 fStartAnglePhi(TMath::Pi()),
43 fConeAnglePhi(TMath::Pi()/6.),
53 // Default Constructor
58 //______________________________________________
59 AliDielectronTrackRotator::AliDielectronTrackRotator(const char* name, const char* title) :
62 fRotationType(kRotateBothRandom),
63 fStartAnglePhi(TMath::Pi()),
64 fConeAnglePhi(TMath::Pi()/6.),
79 //______________________________________________
80 AliDielectronTrackRotator::~AliDielectronTrackRotator()
88 //______________________________________________
89 void AliDielectronTrackRotator::Reset()
92 // Reset the current iterators
99 //______________________________________________
100 Bool_t AliDielectronTrackRotator::NextCombination()
103 // Perform track rotation of the tracks in the track arrays as long as there are possible combinations
105 if (!fkArrTracksP || !fkArrTracksP) {
110 Int_t nP=fkArrTracksP->GetEntriesFast();
111 Int_t nN=fkArrTracksN->GetEntriesFast();
117 if (fCurrentIteration==fIterations){
122 if (fCurrentTackP==nP){
127 if (fCurrentTackN==nN){
132 if (!RotateTracks()){
141 //______________________________________________
142 Bool_t AliDielectronTrackRotator::RotateTracks()
145 // Actual track rotation
146 // Find out particle type and perform the rotation
149 const AliVTrack *trackP=dynamic_cast<AliVTrack*>(fkArrTracksP->UncheckedAt(fCurrentTackP));
150 const AliVTrack *trackN=dynamic_cast<AliVTrack*>(fkArrTracksP->UncheckedAt(fCurrentTackN));
151 if (!trackP||!trackN) return kFALSE;
154 Double_t angle = fStartAnglePhi+(2*gRandom->Rndm()-1)*fConeAnglePhi;
155 Int_t charge = TMath::Nint(gRandom->Rndm());
157 if (trackP->IsA()==AliESDtrack::Class()) {
160 fTrackP=new AliESDtrack;
161 fTrackN=new AliESDtrack;
164 trackP->Copy(*fTrackP);
165 trackN->Copy(*fTrackN);
167 if (fRotationType==kRotatePositive||(fRotationType==kRotateBothRandom&&charge==0)){
168 ((AliESDtrack*)fTrackP)->Rotate(angle);
171 if (fRotationType==kRotateNegative||(fRotationType==kRotateBothRandom&&charge==1)){
172 ((AliESDtrack*)fTrackN)->Rotate(angle);
175 } else if (trackP->IsA()==AliAODTrack::Class()) {
178 fTrackP=new AliAODTrack;
179 fTrackN=new AliAODTrack;
182 (*(AliAODTrack*)fTrackP)=(*(AliAODTrack*)trackP);
183 (*(AliAODTrack*)fTrackN)=(*(AliAODTrack*)trackN);
185 if (fRotationType==kRotatePositive||(fRotationType==kRotateBothRandom&&charge==0)){
186 Double_t phi=fTrackP->Phi()+angle;
187 if (phi>2*TMath::Pi()) phi-=2*TMath::Pi();
188 ((AliAODTrack*)fTrackP)->SetPhi(phi);
191 if (fRotationType==kRotateNegative||(fRotationType==kRotateBothRandom&&charge==1)){
192 Double_t phi=fTrackN->Phi()+angle;
193 if (phi>2*TMath::Pi()) phi-=2*TMath::Pi();
194 ((AliAODTrack*)fTrackN)->SetPhi(phi);