]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/AliFemto/AliFemtoSpherocityEventCut.cxx
Merge branch 'master_patch'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemto / AliFemtoSpherocityEventCut.cxx
1 ////////////////////////////////////////////////////////////////////////////////
2 //                                                                            //
3 // AliFemtoSpherocityEventCut - the basic cut for events.                     //
4 // Only cuts on event multiplicity, z-vertex position and                     //
5 // transverse spherocity are accepted.                                        //
6 //                                                                            //
7 ////////////////////////////////////////////////////////////////////////////////
8
9 #include "AliFemtoSpherocityEventCut.h"
10 //#include <cstdio>
11
12 #ifdef __ROOT__
13 ClassImp(AliFemtoSpherocityEventCut)
14 #endif
15
16 AliFemtoSpherocityEventCut::AliFemtoSpherocityEventCut() :
17   AliFemtoEventCut(),
18   fEventMult(),
19   fVertZPos(),
20   fAcceptBadVertex(false), 
21   fNEventsPassed(0), 
22   fNEventsFailed(0),
23   fAcceptOnlyPhysics(0),
24   fSoCutMin(0.0),
25   fSoCutMax(1.0),
26   fSelectTrigger(0)
27 {
28   // Default constructor
29   fEventMult[0] = 0;
30   fEventMult[1] = 100000;
31   fVertZPos[0] = -100.0;
32   fVertZPos[1] = 100.0;
33   fPsiEP[0] = -1000.0;
34   fPsiEP[1] = 1000.0;
35
36 //------------------------------
37 AliFemtoSpherocityEventCut::~AliFemtoSpherocityEventCut(){
38   // Default destructor
39 }
40 //------------------------------
41 bool AliFemtoSpherocityEventCut::Pass(const AliFemtoEvent* event){  
42
43   // Pass events if they fall within the multiplicity and z-vertex
44   // position range. Fail otherwise
45   //  int mult =  event->NumberOfTracks();
46   int mult = (int) event->UncorrectedNumberOfPrimaries();
47   double vertexZPos = event->PrimVertPos().z();
48   double spherocity=-10;
49   int MULT=0;
50  
51
52    AliFemtoTrackCollection * tracks = event->TrackCollection(); 
53   for (AliFemtoTrackIterator iter=tracks->begin();iter!=tracks->end();iter++){
54   
55     Double_t NewPt =  (*iter)->Pt();
56     Double_t NewEta = (*iter)->P().PseudoRapidity();    
57     if(TMath::Abs(NewEta)>0.8 || NewPt<0.5){continue;}
58     
59      MULT++;
60   
61   }     
62     //if(SumPt==0){return kFALSE;}
63       if(MULT<3){return kFALSE;}
64  
65         Double_t *pxA=new Double_t[MULT];
66         Double_t *pyA=new Double_t[MULT];
67         Double_t sumapt=0;
68         Int_t counter=0;
69   
70    AliFemtoTrackCollection * tracks2 = event->TrackCollection(); 
71   for (AliFemtoTrackIterator iter2=tracks2->begin();iter2!=tracks2->end();iter2++){
72   
73     Double_t NewPt2 =  (*iter2)->Pt();
74     Double_t NewPhi2 = (*iter2)->P().Phi();
75     Double_t NewEta2 = (*iter2)->P().PseudoRapidity();
76     if(TMath::Abs(NewEta2)>0.8 || NewPt2<0.5){continue;}
77     
78     Double_t Px;
79     Double_t Py;
80     
81     Px= NewPt2 * TMath::Cos(NewPhi2);
82     Py= NewPt2 * TMath::Sin(NewPhi2);
83     
84     
85     pxA[counter]=Px;
86     pyA[counter]=Py;
87     sumapt+=NewPt2;
88     counter++;
89   
90   } 
91   
92   Double_t pFull = 0;
93   Double_t Spherocity = 2;
94   //Getting thrust
95   for(Int_t i = 0; i < 360; ++i){
96     Double_t numerador = 0;
97     Double_t phiparam  = 0;
98     Double_t nx = 0;
99     Double_t ny = 0;
100     phiparam=((TMath::Pi()) * i) / 180;   // parametrization of the angle
101     nx = TMath::Cos(phiparam);            // x component of an unitary vector n
102     ny = TMath::Sin(phiparam);            // y component of an unitary vector n
103     for(Int_t i1 = 0; i1 < MULT; ++i1){
104       numerador += TMath::Abs(ny * pxA[i1] - nx * pyA[i1]);//product between momentum proyection in XY plane and the unitari vector.
105     }
106     pFull=TMath::Power( (numerador / sumapt),2 );
107     if(pFull < Spherocity)//maximization of pFull
108       {Spherocity = pFull;}
109   }
110
111   
112     spherocity=((Spherocity)*TMath::Pi()*TMath::Pi())/4.0;
113
114   if(pxA){// clean up array memory used for TMath::Sort
115     delete[] pxA;
116     pxA=0;
117   }
118   if(pyA){// clean up array memory used for TMath::Sort
119     delete[] pyA;
120     pyA=0;
121   }
122
123   if(spherocity>fSoCutMax || spherocity<fSoCutMin){
124           //cout<<" Event kicked out !"<<"SoCutMax= "<<fSoCutMax<<"  SoCutMin= "<<fSoCutMin<<endl;
125           return kFALSE;}  
126   
127   double epvzero = event->ReactionPlaneAngle();
128
129   // cout << "AliFemtoSpherocityEventCut:: epvzero:       " << fPsiEP[0] << " < " << epvzero << " < " << fPsiEP[1] << endl;
130 //   cout << "AliFemtoSpherocityEventCut:: mult:       " << fEventMult[0] << " < " << mult << " < " << fEventMult[1] << endl;
131 //   cout << "AliFemtoSpherocityEventCut:: VertexZPos: " << fVertZPos[0] << " < " << vertexZPos << " < " << fVertZPos[1] << endl;
132 //   cout << "AliFemtoSpherocityEventCut:: VertexZErr: " << event->PrimVertCov()[4] << endl;
133
134   // cout << "AliFemtoSpherocityEventCut:: MagneticField: " << event->MagneticField() << endl;
135   // cout << "AliFemtoSpherocityEventCut:: IsCollisionCandidate: " << event->IsCollisionCandidate() << endl;
136   // cout << "AliFemtoSpherocityEventCut:: TriggerCluster: " << event->TriggerCluster() << endl;
137   // cout << "AliFemtoSpherocityEventCut:: fSelectTrigger: " << fSelectTrigger << endl;
138   // cout << "AliFemtoSpherocityEventCut:: " << endl;
139   bool goodEvent =
140     ((mult >= fEventMult[0]) && 
141      (mult <= fEventMult[1]) && 
142      (vertexZPos > fVertZPos[0]) &&
143      (vertexZPos < fVertZPos[1]) &&
144      (epvzero > fPsiEP[0]) &&
145      (epvzero < fPsiEP[1]) &&
146      ((!fAcceptBadVertex) || (event->ZDCParticipants() > 1.0)) &&
147       ((!fSelectTrigger) || (event->TriggerCluster() == fSelectTrigger))
148 );
149
150   // cout << "AliFemtoSpherocityEventCut:: goodEvent" <<goodEvent << endl;
151
152   goodEvent ? fNEventsPassed++ : fNEventsFailed++ ;
153   // cout << "AliFemtoSpherocityEventCut:: return : " << goodEvent << endl;
154 //     (fAcceptBadVertex || (event->PrimVertCov()[4] > -1000.0)) &&
155
156   return (goodEvent);
157 }
158 //------------------------------
159 AliFemtoString AliFemtoSpherocityEventCut::Report(){
160   // Prepare report
161   string stemp;
162   char ctemp[100];
163   snprintf(ctemp , 100, "\nMultiplicity:\t %d-%d",fEventMult[0],fEventMult[1]);
164   stemp = ctemp;
165   snprintf(ctemp , 100, "\nVertex Z-position:\t %E-%E",fVertZPos[0],fVertZPos[1]);
166   stemp += ctemp;
167   snprintf(ctemp , 100, "\nNumber of events which passed:\t%ld  Number which failed:\t%ld",fNEventsPassed,fNEventsFailed);
168   stemp += ctemp;
169   AliFemtoString returnThis = stemp;
170   return returnThis;
171 }
172 void AliFemtoSpherocityEventCut::SetAcceptBadVertex(bool b)
173 {
174   fAcceptBadVertex = b;
175 }
176 bool AliFemtoSpherocityEventCut::GetAcceptBadVertex()
177 {
178   return fAcceptBadVertex;
179 }