]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FEMTOSCOPY/AliFemto/AliFemtoEventReaderKinematicsChain.cxx
Adding V0 femtoscopy analysis
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / AliFemto / AliFemtoEventReaderKinematicsChain.cxx
CommitLineData
76ce4b5b 1/////////////////////////////////////////////////////////////////////////////////////
2// //
3// AliFemtoEventReaderKinematicsChain - the reader class for the Alice ESD and //
4// the model Kinematics information tailored for the Task framework and the //
5// Reads in AliESDfriend to create shared hit/quality information //
6// Authors: Malgorzata Janik, Warsaw University of Technology, majanik@cern.ch //
7// Lukasz Graczykowski, Warsaw University of Technology, lgraczyk@cern.ch //
8// //
9/////////////////////////////////////////////////////////////////////////////////////
10
11#include "AliFemtoEventReaderKinematicsChain.h"
12
13#include "TFile.h"
14#include "TTree.h"
15#include "TList.h"
16
17#include "AliFmPhysicalHelixD.h"
18#include "AliFmThreeVectorF.h"
19
20#include "SystemOfUnits.h"
21
22#include "AliFemtoEvent.h"
23
24#include "TParticle.h"
25#include "AliStack.h"
26#include "TParticlePDG.h"
27#include "AliFemtoModelHiddenInfo.h"
28#include "AliFemtoModelGlobalHiddenInfo.h"
29#include "AliGenHijingEventHeader.h"
30#include "AliGenCocktailEventHeader.h"
31
32#include "AliVertexerTracks.h"
33
34ClassImp(AliFemtoEventReaderKinematicsChain)
35
36#if !(ST_NO_NAMESPACES)
37 using namespace units;
38#endif
39
40using namespace std;
41//____________________________
42AliFemtoEventReaderKinematicsChain::AliFemtoEventReaderKinematicsChain():
43 fFileName(" "),
44 fConstrained(true),
45 fNumberofEvent(0),
46 fCurEvent(0),
47 fCurFile(0),
48 fStack(0x0),
49 fGenHeader(0x0),
50 fRotateToEventPlane(0)
51{
52 //constructor with 0 parameters , look at default settings
53}
54
55//__________________
56AliFemtoEventReaderKinematicsChain::AliFemtoEventReaderKinematicsChain(const AliFemtoEventReaderKinematicsChain& aReader):
57 AliFemtoEventReader(aReader),
58 fFileName(" "),
59 fConstrained(true),
60 fNumberofEvent(0),
61 fCurEvent(0),
62 fCurFile(0),
63 fStack(0x0),
64 fGenHeader(0x0),
65 fRotateToEventPlane(0)
66{
67 // Copy constructor
68 fConstrained = aReader.fConstrained;
69 fNumberofEvent = aReader.fNumberofEvent;
70 fCurEvent = aReader.fCurEvent;
71 fCurFile = aReader.fCurFile;
72 fStack = aReader.fStack;
73 fRotateToEventPlane = aReader.fRotateToEventPlane;
74}
75//__________________
76AliFemtoEventReaderKinematicsChain::~AliFemtoEventReaderKinematicsChain()
77{
78 //Destructor
79 //delete fEvent;
80}
81
82//__________________
83AliFemtoEventReaderKinematicsChain& AliFemtoEventReaderKinematicsChain::operator=(const AliFemtoEventReaderKinematicsChain& aReader)
84{
85 // Assignment operator
86 if (this == &aReader)
87 return *this;
88
89 fConstrained = aReader.fConstrained;
90 fNumberofEvent = aReader.fNumberofEvent;
91 fCurEvent = aReader.fCurEvent;
92 fCurFile = aReader.fCurFile;
93 fStack = aReader.fStack;
94 fGenHeader = aReader.fGenHeader;
95 fRotateToEventPlane = aReader.fRotateToEventPlane;
96 return *this;
97}
98//__________________
99// Simple report
100AliFemtoString AliFemtoEventReaderKinematicsChain::Report()
101{
102 AliFemtoString temp = "\n This is the AliFemtoEventReaderKinematicsChain\n";
103 return temp;
104}
105
106//__________________
107void AliFemtoEventReaderKinematicsChain::SetConstrained(const bool constrained)
108{
109 // Select whether to read constrained or not constrained momentum
110 fConstrained=constrained;
111}
112//__________________
113bool AliFemtoEventReaderKinematicsChain::GetConstrained() const
114{
115 // Check whether we read constrained or not constrained momentum
116 return fConstrained;
117}
118//__________________
119AliFemtoEvent* AliFemtoEventReaderKinematicsChain::ReturnHbtEvent()
120{
121 // Get the event, read all the relevant information from the stack
122 // and fill the AliFemtoEvent class
123 // Returns a valid AliFemtoEvent
124 AliFemtoEvent *hbtEvent = 0;
125 string tFriendFileName;
126
127 cout << "AliFemtoEventReaderKinematlaicsChain::Starting to read event: "<<fCurEvent<<endl;
128
129 hbtEvent = new AliFemtoEvent;
130 //setting basic things
131 // hbtEvent->SetEventNumber(fEvent->GetEventNumber());
132 hbtEvent->SetRunNumber(0); //No Run number in Kinematics!
133 hbtEvent->SetMagneticField(0*kilogauss);//to check if here is ok
134 hbtEvent->SetZDCN1Energy(0);
135 hbtEvent->SetZDCP1Energy(0);
136 hbtEvent->SetZDCN2Energy(0);
137 hbtEvent->SetZDCP2Energy(0);
138 hbtEvent->SetZDCEMEnergy(0);
139 hbtEvent->SetZDCParticipants(0);
140 hbtEvent->SetTriggerMask(0);
141 hbtEvent->SetTriggerCluster(0);
142
143 //Vertex
144 double fV1[3] = {0.0,0.0,0.0};
145 double fVCov[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
146
147
148 AliFmThreeVectorF vertex(0,0,0);
149
150
151 hbtEvent->SetPrimVertPos(vertex);
152 hbtEvent->SetPrimVertCov(fVCov);
153
154 Double_t tReactionPlane = 0;
155
156 AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (fGenHeader);
157 if (!hdh) {
158 AliGenCocktailEventHeader *cdh = dynamic_cast<AliGenCocktailEventHeader *> (fGenHeader);
159 if (cdh) {
160 TList *tGenHeaders = cdh->GetHeaders();
161 for (int ihead = 0; ihead<tGenHeaders->GetEntries(); ihead++) {
162 hdh = dynamic_cast<AliGenHijingEventHeader *> (fGenHeader);
163 if (hdh) break;
164 }
165 }
166 }
167
168 if (hdh)
169 {
170 tReactionPlane = hdh->ReactionPlaneAngle();
171 cout << "Got reaction plane " << tReactionPlane << endl;
172 }
173
174 hbtEvent->SetReactionPlaneAngle(tReactionPlane);
175
176 //starting to reading tracks
177 int nofTracks=0; //number of all tracks in MC event
178 nofTracks=fStack->GetNtrack();
179 int realnofTracks=0;//number of track which we use in analysis
180
181
182 int tNormMult = 0;
183 for (int i=0;i<nofTracks;i++)
184 {
76ce4b5b 185 //take only primaries
186 if(!fStack->IsPhysicalPrimary(i)) {continue;}
187
188 AliFemtoTrack* trackCopy = new AliFemtoTrack();
189
190 //getting next track
191 TParticle *kinetrack= fStack->Particle(i);
192
193 //setting multiplicity
194 realnofTracks++;//real number of tracks (only primary particles)
195
196 //setting normalized multiplicity
197 if (kinetrack->Eta() < 0.9)
198 if(kinetrack->GetPDG()->Charge()/3!=0)
199 tNormMult++;
200
201
202 //charge
203 trackCopy->SetCharge((short)(fStack->Particle(i)->GetPDG()->Charge()/3));
204
205
206 //in aliroot we have AliPID
207 //0-electron 1-muon 2-pion 3-kaon 4-proton 5-photon 6-pi0 7-neutron 8-kaon0 9-eleCon
208 //we use only 5 first
209 double kinepid[5];
210 for(int pid_iter=0;pid_iter<5;pid_iter++)
211 kinepid[pid_iter]=0;
212
213 int pdgcode = kinetrack->GetPdgCode();
214 //proton
215 if(pdgcode==2212 || pdgcode==-2212)
216 kinepid[4]=1000;
217 //kaon
218 if(pdgcode==321 || pdgcode==-321 )
219 kinepid[3]=1000;
220 //pion
221 if( pdgcode==211 || pdgcode==-211)
222 kinepid[2]=1000;
223 //electron
224 if(pdgcode==11 || pdgcode==-11)
225 kinepid[0]=1000;
226 //muon
227 if(pdgcode==13 || pdgcode==-13)
228 kinepid[1]=1000;
229
230 trackCopy->SetPidProbElectron(kinepid[0]);
231 trackCopy->SetPidProbMuon(kinepid[1]);
232 trackCopy->SetPidProbPion(kinepid[2]);
233 trackCopy->SetPidProbKaon(kinepid[3]);
234 trackCopy->SetPidProbProton(kinepid[4]);
235
236
237 //Momentum
238 double pxyz[3];
239 double rxyz[3];
240
241 pxyz[0]=kinetrack->Px();
242 pxyz[1]=kinetrack->Py();
243 pxyz[2]=kinetrack->Pz();
244
245 rxyz[0]=kinetrack->Vx();
246 rxyz[1]=kinetrack->Vy();
247 rxyz[2]=kinetrack->Vz();
248
249 if (fRotateToEventPlane) {
250 double tPhi = TMath::ATan2(pxyz[1], pxyz[0]);
251 double tRad = TMath::Hypot(pxyz[0], pxyz[1]);
252
253 pxyz[0] = tRad*TMath::Cos(tPhi - tReactionPlane);
254 pxyz[1] = tRad*TMath::Sin(tPhi - tReactionPlane);
255 }
256
257 AliFemtoThreeVector v(pxyz[0],pxyz[1],pxyz[2]);
258 if (v.Mag() < 0.0001) {
973a91f8 259 //cout << "Found 0 momentum ???? " << pxyz[0] << " " << pxyz[1] << " " << pxyz[2] << endl;
76ce4b5b 260 delete trackCopy;
261 continue;
262 }
263
264 trackCopy->SetP(v);//setting momentum
265 trackCopy->SetPt(sqrt(pxyz[0]*pxyz[0]+pxyz[1]*pxyz[1]));
266 const AliFmThreeVectorD kP(pxyz[0],pxyz[1],pxyz[2]);
267 const AliFmThreeVectorD kOrigin(fV1[0],fV1[1],fV1[2]);
268
269 //label
973a91f8 270 trackCopy->SetLabel(i);
76ce4b5b 271
272
273 hbtEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis
973a91f8 274 //cout<<"Track added: "<<i<<endl;
76ce4b5b 275
276 }
277
278 hbtEvent->SetNumberOfTracks(realnofTracks);//setting number of track which we read in event
279 hbtEvent->SetNormalizedMult(tNormMult);
280 fCurEvent++;
281
973a91f8 282
283 //V0 analysis code - no V0 finder for Kinematics, we can only check if it is primary and if it has at least 2 daughters.
284
285 for (int i=0;i<nofTracks;i++)
286 {
287 //do not take primaries
288 if(!fStack->IsPhysicalPrimary(i)) {continue;}
289 //getting next track
290 TParticle *kinetrack= fStack->Particle(i);
291 if (!kinetrack) continue;
292
293 if(kinetrack->GetPDG()->Charge()!=0) continue; //charge - neutral
294 //if(kinetrack->GetPDG()->Stable()==1) continue; //particle is not stable
295 if(kinetrack->GetDaughter(0)<1) continue; //has 1'st daughter
296 if(kinetrack->GetDaughter(1)<1) continue; //has 2'nd daughter
297
298 //we want one positive, one negative particle. Or two neutral.
299 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()>=0)
300 // if((fStack->Particle(kinetrack->GetDaughter(1)))->GetPDG()->Charge()>0)
301 // continue;
302 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()<=0)
303 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()<0)
304 // continue;
305
306 if(kinetrack->Pt()<0.00001)
307 continue;
308
309 AliFemtoV0* trackCopyV0 = new AliFemtoV0();
310 CopyAODtoFemtoV0(kinetrack, trackCopyV0);
311 hbtEvent->V0Collection()->push_back(trackCopyV0);
312 //cout<<"Pushback v0 to v0collection"<<endl;
313 }
314
315
316 cout<<"Number of tracks: "<<realnofTracks<<endl;
317
76ce4b5b 318 return hbtEvent;
319}
320
321//___________________
322void AliFemtoEventReaderKinematicsChain::SetStackSource(AliStack *aStack)
323{
324 // The chain loads the stack for us
325 // You must provide the address where it can be found
326 fStack = aStack;
327}
328//___________________
329void AliFemtoEventReaderKinematicsChain::SetGenEventHeader(AliGenEventHeader *aGenHeader)
330{
331 // The chain loads the generator event header for us
332 // You must provide the address where it can be found
333 fGenHeader = aGenHeader;
334}
335
336//__________________
337void AliFemtoEventReaderKinematicsChain::SetRotateToEventPlane(short dorotate)
338{
339 fRotateToEventPlane=dorotate;
340}
341
342Float_t AliFemtoEventReaderKinematicsChain::GetSigmaToVertex(double *impact, double *covar)
343{
344 // Calculates the number of sigma to the vertex.
345
346 Float_t b[2];
347 Float_t bRes[2];
348 Float_t bCov[3];
349
350 b[0] = impact[0];
351 b[1] = impact[1];
352 bCov[0] = covar[0];
353 bCov[1] = covar[1];
354 bCov[2] = covar[2];
355
356 bRes[0] = TMath::Sqrt(bCov[0]);
357 bRes[1] = TMath::Sqrt(bCov[2]);
358
359 // -----------------------------------
360 // How to get to a n-sigma cut?
361 //
362 // The accumulated statistics from 0 to d is
363 //
364 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
365 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
366 //
367 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
368 // Can this be expressed in a different way?
369
370 if (bRes[0] == 0 || bRes[1] ==0)
371 return -1;
372
373 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
374
375 // stupid rounding problem screws up everything:
376 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
377 if (TMath::Exp(-d * d / 2) < 1e-10)
378 return 1000;
379
380 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
381 return d;
382}
973a91f8 383
384
385
386 void AliFemtoEventReaderKinematicsChain::CopyAODtoFemtoV0(TParticle *tv0, AliFemtoV0 *tFemtoV0 )
387{
388 tFemtoV0->SetEtaV0(tv0->Eta());
389 tFemtoV0->SetEtaV0(tv0->Phi());
390 tFemtoV0->SetptV0(tv0->Pt());
391 tFemtoV0->SetptotV0(tv0->P());
392
393 tFemtoV0->SetmomV0X(tv0->Px());
394 tFemtoV0->SetmomV0Y(tv0->Py());
395 tFemtoV0->SetmomV0Z(tv0->Pz());
396 AliFemtoThreeVector momv0(tv0->Px(),tv0->Py(),tv0->Pz());
397 tFemtoV0->SetmomV0(momv0);
398
399
400 TParticle *trackpos;
401 TParticle *trackneg;
402
403 //daughters
404 if(fStack->Particle(tv0->GetDaughter(0))->GetPDG()->Charge()>=0) //first positive, second negative
405 {
406 trackpos = (TParticle*)(fStack->Particle(tv0->GetDaughter(0)));
407 trackneg = (TParticle*)(fStack->Particle(tv0->GetDaughter(1)));
408 tFemtoV0->SetidPos(tv0->GetDaughter(0));
409 tFemtoV0->SetidNeg(tv0->GetDaughter(1));
410 }
411 else //first negative, second positive
412 {
413 trackpos = (TParticle*)(fStack->Particle(tv0->GetDaughter(1)));
414 trackneg = (TParticle*)(fStack->Particle(tv0->GetDaughter(0)));
415 tFemtoV0->SetidPos(tv0->GetDaughter(1));
416 tFemtoV0->SetidNeg(tv0->GetDaughter(0));
417 }
418
419 tFemtoV0->SetEtaPos(trackpos->Eta());
420 tFemtoV0->SetEtaNeg(trackneg->Eta());
421
422 tFemtoV0->SetptPos(trackpos->Pt());
423 tFemtoV0->SetptNeg(trackneg->Pt());
424
425 tFemtoV0->SetptotPos(trackpos->P());
426 tFemtoV0->SetptotNeg(trackneg->P());
427
428 tFemtoV0->SetmomPosX(trackpos->Px());
429 tFemtoV0->SetmomPosY(trackpos->Py());
430 tFemtoV0->SetmomPosZ(trackpos->Pz());
431 AliFemtoThreeVector mompos(trackpos->Px(),trackpos->Py(),trackpos->Pz());
432 tFemtoV0->SetmomPos(mompos);
433
434 tFemtoV0->SetmomNegX(trackneg->Px());
435 tFemtoV0->SetmomNegY(trackneg->Py());
436 tFemtoV0->SetmomNegZ(trackneg->Pz());
437 AliFemtoThreeVector momneg(trackneg->Px(),trackneg->Py(),trackneg->Pz());
438 tFemtoV0->SetmomNeg(momneg);
439
440
441 tFemtoV0->SetmassLambda(tv0->GetMass());
442 tFemtoV0->SetmassAntiLambda(tv0->GetMass());
443 tFemtoV0->SetmassK0Short(tv0->GetMass());
444
445 tFemtoV0->SetYV0(tv0->Y());
446
447 tFemtoV0->SetdecayVertexV0X(trackpos->Vx()); //vertex of the decay is set as the vertex of creation of daughters
448 tFemtoV0->SetdecayVertexV0Y(trackpos->Vy());
449 tFemtoV0->SetdecayVertexV0Z(trackpos->Vz());
450 AliFemtoThreeVector decayvertex(trackpos->Vx(),trackpos->Vy(),trackpos->Vz());
451 tFemtoV0->SetdecayVertexV0(decayvertex);
452
453 tFemtoV0->SetdcaV0Daughters(0);
454 tFemtoV0->SetCosPointingAngle(1);
455
456
457 tFemtoV0->SetStatusPos(1);
458 tFemtoV0->SetStatusNeg(1);
459
460
461 if(trackpos->GetPdgCode()==2212) //proton
462 {
463 tFemtoV0->SetPosNSigmaTPCK(1000);
464 tFemtoV0->SetPosNSigmaTPCPi(1000);
465 tFemtoV0->SetPosNSigmaTPCP(0);
466 }
467 if(trackneg->GetPdgCode()==-2212) //antiproton
468 {
469 tFemtoV0->SetNegNSigmaTPCK(1000);
470 tFemtoV0->SetNegNSigmaTPCPi(1000);
471 tFemtoV0->SetNegNSigmaTPCP(0);
472 }
473 if(trackpos->GetPdgCode()==211) //pion plus
474 {
475 tFemtoV0->SetPosNSigmaTPCK(1000);
476 tFemtoV0->SetPosNSigmaTPCPi(0);
477 tFemtoV0->SetPosNSigmaTPCP(1000);
478 }
479 if(trackneg->GetPdgCode()==-211) //pion minus
480 {
481 tFemtoV0->SetNegNSigmaTPCK(1000);
482 tFemtoV0->SetNegNSigmaTPCPi(0);
483 tFemtoV0->SetNegNSigmaTPCP(1000);
484 }
485 if(trackpos->GetPdgCode()==321) //K+
486 {
487 tFemtoV0->SetPosNSigmaTPCK(0);
488 tFemtoV0->SetPosNSigmaTPCPi(1000);
489 tFemtoV0->SetPosNSigmaTPCP(1000);
490 }
491 if(trackneg->GetPdgCode()==-321) //K-
492 {
493 tFemtoV0->SetNegNSigmaTPCK(0);
494 tFemtoV0->SetNegNSigmaTPCPi(1000);
495 tFemtoV0->SetNegNSigmaTPCP(1000);
496 }
497
498
499}