1 /////////////////////////////////////////////////////////////////////////////////////
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 //
9 /////////////////////////////////////////////////////////////////////////////////////
11 #include "AliFemtoEventReaderKinematicsChain.h"
17 #include "AliFmPhysicalHelixD.h"
18 #include "AliFmThreeVectorF.h"
20 #include "SystemOfUnits.h"
22 #include "AliFemtoEvent.h"
24 #include "TParticle.h"
26 #include "TParticlePDG.h"
27 #include "AliFemtoModelHiddenInfo.h"
28 #include "AliFemtoModelGlobalHiddenInfo.h"
29 #include "AliGenHijingEventHeader.h"
30 #include "AliGenCocktailEventHeader.h"
32 #include "AliVertexerTracks.h"
34 ClassImp(AliFemtoEventReaderKinematicsChain)
36 #if !(ST_NO_NAMESPACES)
37 using namespace units;
41 //____________________________
42 AliFemtoEventReaderKinematicsChain::AliFemtoEventReaderKinematicsChain():
50 fEstEventMult(kGlobalCount),
51 fRotateToEventPlane(0)
53 //constructor with 0 parameters , look at default settings
57 AliFemtoEventReaderKinematicsChain::AliFemtoEventReaderKinematicsChain(const AliFemtoEventReaderKinematicsChain& aReader):
58 AliFemtoEventReader(aReader),
66 fEstEventMult(kGlobalCount),
67 fRotateToEventPlane(0)
70 fConstrained = aReader.fConstrained;
71 fNumberofEvent = aReader.fNumberofEvent;
72 fCurEvent = aReader.fCurEvent;
73 fCurFile = aReader.fCurFile;
74 fStack = aReader.fStack;
75 fEstEventMult = aReader.fEstEventMult;
76 fRotateToEventPlane = aReader.fRotateToEventPlane;
79 AliFemtoEventReaderKinematicsChain::~AliFemtoEventReaderKinematicsChain()
86 AliFemtoEventReaderKinematicsChain& AliFemtoEventReaderKinematicsChain::operator=(const AliFemtoEventReaderKinematicsChain& aReader)
88 // Assignment operator
92 fConstrained = aReader.fConstrained;
93 fNumberofEvent = aReader.fNumberofEvent;
94 fCurEvent = aReader.fCurEvent;
95 fCurFile = aReader.fCurFile;
96 fStack = aReader.fStack;
97 fGenHeader = aReader.fGenHeader;
98 fEstEventMult = aReader.fEstEventMult;
99 fRotateToEventPlane = aReader.fRotateToEventPlane;
104 AliFemtoString AliFemtoEventReaderKinematicsChain::Report()
106 AliFemtoString temp = "\n This is the AliFemtoEventReaderKinematicsChain\n";
111 void AliFemtoEventReaderKinematicsChain::SetConstrained(const bool constrained)
113 // Select whether to read constrained or not constrained momentum
114 fConstrained=constrained;
117 bool AliFemtoEventReaderKinematicsChain::GetConstrained() const
119 // Check whether we read constrained or not constrained momentum
123 AliFemtoEvent* AliFemtoEventReaderKinematicsChain::ReturnHbtEvent()
125 // Get the event, read all the relevant information from the stack
126 // and fill the AliFemtoEvent class
127 // Returns a valid AliFemtoEvent
128 AliFemtoEvent *hbtEvent = 0;
129 string tFriendFileName;
131 cout << "AliFemtoEventReaderKinematlaicsChain::Starting to read event: "<<fCurEvent<<endl;
133 hbtEvent = new AliFemtoEvent;
134 //setting basic things
135 // hbtEvent->SetEventNumber(fEvent->GetEventNumber());
136 hbtEvent->SetRunNumber(0); //No Run number in Kinematics!
137 hbtEvent->SetMagneticField(0*kilogauss);//to check if here is ok
138 hbtEvent->SetZDCN1Energy(0);
139 hbtEvent->SetZDCP1Energy(0);
140 hbtEvent->SetZDCN2Energy(0);
141 hbtEvent->SetZDCP2Energy(0);
142 hbtEvent->SetZDCEMEnergy(0);
143 hbtEvent->SetZDCParticipants(0);
144 hbtEvent->SetTriggerMask(0);
145 hbtEvent->SetTriggerCluster(0);
148 double fV1[3] = {0.0,0.0,0.0};
149 double fVCov[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
152 AliFmThreeVectorF vertex(0,0,0);
155 hbtEvent->SetPrimVertPos(vertex);
156 hbtEvent->SetPrimVertCov(fVCov);
158 Double_t tReactionPlane = 0;
160 AliGenHijingEventHeader *hdh = dynamic_cast<AliGenHijingEventHeader *> (fGenHeader);
162 AliGenCocktailEventHeader *cdh = dynamic_cast<AliGenCocktailEventHeader *> (fGenHeader);
164 TList *tGenHeaders = cdh->GetHeaders();
165 for (int ihead = 0; ihead<tGenHeaders->GetEntries(); ihead++) {
166 hdh = dynamic_cast<AliGenHijingEventHeader *> (fGenHeader);
174 tReactionPlane = hdh->ReactionPlaneAngle();
175 cout << "Got reaction plane " << tReactionPlane << endl;
178 hbtEvent->SetReactionPlaneAngle(tReactionPlane);
180 //starting to reading tracks
181 int nofTracks=0; //number of all tracks in MC event
182 nofTracks=fStack->GetNtrack();
183 int realnofTracks=0;//number of track which we use in analysis
187 int tV0direction = 0;
188 for (int i=0;i<nofTracks;i++)
190 //take only primaries
191 if(!fStack->IsPhysicalPrimary(i)) {continue;}
193 AliFemtoTrack* trackCopy = new AliFemtoTrack();
196 TParticle *kinetrack= fStack->Particle(i);
198 //setting multiplicity
199 realnofTracks++;//real number of tracks (only primary particles)
201 //setting normalized multiplicity
203 if(kinetrack->GetPDG()->Charge()/3!=0)
204 if (kinetrack->Pt() > 0.15 && kinetrack->Pt() < 20)
205 if (kinetrack->Eta() < 0.8)
208 //counting particles that go into direction of VZERO detector
209 if(kinetrack->Eta() > 2.8 && kinetrack->Eta() < 5.1) //VZERO-A
211 if(kinetrack->Eta() > -3.7 && kinetrack->Eta() < -1.7)//VZERO-C
215 trackCopy->SetCharge((short)(fStack->Particle(i)->GetPDG()->Charge()/3));
218 //in aliroot we have AliPID
219 //0-electron 1-muon 2-pion 3-kaon 4-proton 5-photon 6-pi0 7-neutron 8-kaon0 9-eleCon
220 //we use only 5 first
222 for(int pid_iter=0;pid_iter<5;pid_iter++)
225 int pdgcode = kinetrack->GetPdgCode();
227 if(pdgcode==2212 || pdgcode==-2212)
230 else if(pdgcode==321 || pdgcode==-321 )
233 else if( pdgcode==211 || pdgcode==-211)
236 else if(pdgcode==11 || pdgcode==-11)
239 else if(pdgcode==13 || pdgcode==-13)
243 trackCopy->SetPidProbElectron(kinepid[0]);
244 trackCopy->SetPidProbMuon(kinepid[1]);
245 trackCopy->SetPidProbPion(kinepid[2]);
246 trackCopy->SetPidProbKaon(kinepid[3]);
247 trackCopy->SetPidProbProton(kinepid[4]);
254 pxyz[0]=kinetrack->Px();
255 pxyz[1]=kinetrack->Py();
256 pxyz[2]=kinetrack->Pz();
258 // rxyz[0]=kinetrack->Vx();
259 // rxyz[1]=kinetrack->Vy();
260 // rxyz[2]=kinetrack->Vz();
262 if (fRotateToEventPlane) {
263 double tPhi = TMath::ATan2(pxyz[1], pxyz[0]);
264 double tRad = TMath::Hypot(pxyz[0], pxyz[1]);
266 pxyz[0] = tRad*TMath::Cos(tPhi - tReactionPlane);
267 pxyz[1] = tRad*TMath::Sin(tPhi - tReactionPlane);
270 AliFemtoThreeVector v(pxyz[0],pxyz[1],pxyz[2]);
271 if (v.Mag() < 0.0001) {
272 //cout << "Found 0 momentum ???? " << pxyz[0] << " " << pxyz[1] << " " << pxyz[2] << endl;
277 trackCopy->SetP(v);//setting momentum
278 trackCopy->SetPt(sqrt(pxyz[0]*pxyz[0]+pxyz[1]*pxyz[1]));
279 const AliFmThreeVectorD kP(pxyz[0],pxyz[1],pxyz[2]);
280 const AliFmThreeVectorD kOrigin(fV1[0],fV1[1],fV1[2]);
283 trackCopy->SetLabel(i);
286 hbtEvent->TrackCollection()->push_back(trackCopy);//adding track to analysis
287 //cout<<"Track added: "<<i<<endl;
291 hbtEvent->SetNumberOfTracks(realnofTracks);//setting number of track which we read in event
292 if (fEstEventMult == kGlobalCount)
293 hbtEvent->SetNormalizedMult(tNormMult);
294 else if(fEstEventMult == kVZERO)
295 hbtEvent->SetNormalizedMult(tV0direction);
299 //V0 analysis code - no V0 finder for Kinematics, we can only check if it is primary and if it has at least 2 daughters.
301 for (int i=0;i<nofTracks;i++)
303 //do not take primaries
304 if(!fStack->IsPhysicalPrimary(i)) {continue;}
306 TParticle *kinetrack= fStack->Particle(i);
307 if (!kinetrack) continue;
309 if(kinetrack->GetPDG()->Charge()!=0) continue; //charge - neutral
310 //if(kinetrack->GetPDG()->Stable()==1) continue; //particle is not stable
311 if(kinetrack->GetDaughter(0)<1) continue; //has 1'st daughter
312 if(kinetrack->GetDaughter(1)<1) continue; //has 2'nd daughter
314 //we want one positive, one negative particle. Or two neutral.
315 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()>=0)
316 // if((fStack->Particle(kinetrack->GetDaughter(1)))->GetPDG()->Charge()>0)
318 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()<=0)
319 // if((fStack->Particle(kinetrack->GetDaughter(0)))->GetPDG()->Charge()<0)
322 if(kinetrack->Pt()<0.00001)
325 AliFemtoV0* trackCopyV0 = new AliFemtoV0();
326 CopyAODtoFemtoV0(kinetrack, trackCopyV0);
327 hbtEvent->V0Collection()->push_back(trackCopyV0);
328 //cout<<"Pushback v0 to v0collection"<<endl;
332 cout<<"Number of tracks: "<<realnofTracks<<endl;
337 //___________________
338 void AliFemtoEventReaderKinematicsChain::SetStackSource(AliStack *aStack)
340 // The chain loads the stack for us
341 // You must provide the address where it can be found
344 //___________________
345 void AliFemtoEventReaderKinematicsChain::SetGenEventHeader(AliGenEventHeader *aGenHeader)
347 // The chain loads the generator event header for us
348 // You must provide the address where it can be found
349 fGenHeader = aGenHeader;
353 void AliFemtoEventReaderKinematicsChain::SetRotateToEventPlane(short dorotate)
355 fRotateToEventPlane=dorotate;
358 void AliFemtoEventReaderKinematicsChain::SetUseMultiplicity(EstEventMult aType)
360 fEstEventMult = aType;
363 Float_t AliFemtoEventReaderKinematicsChain::GetSigmaToVertex(double *impact, double *covar)
365 // Calculates the number of sigma to the vertex.
377 bRes[0] = TMath::Sqrt(bCov[0]);
378 bRes[1] = TMath::Sqrt(bCov[2]);
380 // -----------------------------------
381 // How to get to a n-sigma cut?
383 // The accumulated statistics from 0 to d is
385 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
386 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
388 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
389 // Can this be expressed in a different way?
391 if (bRes[0] == 0 || bRes[1] ==0)
394 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
396 // stupid rounding problem screws up everything:
397 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
398 if (TMath::Exp(-d * d / 2) < 1e-10)
401 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
407 void AliFemtoEventReaderKinematicsChain::CopyAODtoFemtoV0(TParticle *tv0, AliFemtoV0 *tFemtoV0 )
409 tFemtoV0->SetEtaV0(tv0->Eta());
410 tFemtoV0->SetEtaV0(tv0->Phi());
411 tFemtoV0->SetptV0(tv0->Pt());
412 tFemtoV0->SetptotV0(tv0->P());
414 tFemtoV0->SetmomV0X(tv0->Px());
415 tFemtoV0->SetmomV0Y(tv0->Py());
416 tFemtoV0->SetmomV0Z(tv0->Pz());
417 AliFemtoThreeVector momv0(tv0->Px(),tv0->Py(),tv0->Pz());
418 tFemtoV0->SetmomV0(momv0);
425 if(fStack->Particle(tv0->GetDaughter(0))->GetPDG()->Charge()>=0) //first positive, second negative
427 trackpos = (TParticle*)(fStack->Particle(tv0->GetDaughter(0)));
428 trackneg = (TParticle*)(fStack->Particle(tv0->GetDaughter(1)));
429 tFemtoV0->SetidPos(tv0->GetDaughter(0));
430 tFemtoV0->SetidNeg(tv0->GetDaughter(1));
432 else //first negative, second positive
434 trackpos = (TParticle*)(fStack->Particle(tv0->GetDaughter(1)));
435 trackneg = (TParticle*)(fStack->Particle(tv0->GetDaughter(0)));
436 tFemtoV0->SetidPos(tv0->GetDaughter(1));
437 tFemtoV0->SetidNeg(tv0->GetDaughter(0));
440 tFemtoV0->SetEtaPos(trackpos->Eta());
441 tFemtoV0->SetEtaNeg(trackneg->Eta());
443 tFemtoV0->SetptPos(trackpos->Pt());
444 tFemtoV0->SetptNeg(trackneg->Pt());
446 tFemtoV0->SetptotPos(trackpos->P());
447 tFemtoV0->SetptotNeg(trackneg->P());
449 tFemtoV0->SetmomPosX(trackpos->Px());
450 tFemtoV0->SetmomPosY(trackpos->Py());
451 tFemtoV0->SetmomPosZ(trackpos->Pz());
452 AliFemtoThreeVector mompos(trackpos->Px(),trackpos->Py(),trackpos->Pz());
453 tFemtoV0->SetmomPos(mompos);
455 tFemtoV0->SetmomNegX(trackneg->Px());
456 tFemtoV0->SetmomNegY(trackneg->Py());
457 tFemtoV0->SetmomNegZ(trackneg->Pz());
458 AliFemtoThreeVector momneg(trackneg->Px(),trackneg->Py(),trackneg->Pz());
459 tFemtoV0->SetmomNeg(momneg);
462 tFemtoV0->SetmassLambda(tv0->GetMass());
463 tFemtoV0->SetmassAntiLambda(tv0->GetMass());
464 tFemtoV0->SetmassK0Short(tv0->GetMass());
466 tFemtoV0->SetYV0(tv0->Y());
468 tFemtoV0->SetdecayVertexV0X(trackpos->Vx()); //vertex of the decay is set as the vertex of creation of daughters
469 tFemtoV0->SetdecayVertexV0Y(trackpos->Vy());
470 tFemtoV0->SetdecayVertexV0Z(trackpos->Vz());
471 AliFemtoThreeVector decayvertex(trackpos->Vx(),trackpos->Vy(),trackpos->Vz());
472 tFemtoV0->SetdecayVertexV0(decayvertex);
474 tFemtoV0->SetdcaV0Daughters(0);
475 tFemtoV0->SetCosPointingAngle(1);
478 tFemtoV0->SetStatusPos(1);
479 tFemtoV0->SetStatusNeg(1);
482 if(trackpos->GetPdgCode()==2212) //proton
484 tFemtoV0->SetPosNSigmaTPCK(1000);
485 tFemtoV0->SetPosNSigmaTPCPi(1000);
486 tFemtoV0->SetPosNSigmaTPCP(0);
488 if(trackneg->GetPdgCode()==-2212) //antiproton
490 tFemtoV0->SetNegNSigmaTPCK(1000);
491 tFemtoV0->SetNegNSigmaTPCPi(1000);
492 tFemtoV0->SetNegNSigmaTPCP(0);
494 if(trackpos->GetPdgCode()==211) //pion plus
496 tFemtoV0->SetPosNSigmaTPCK(1000);
497 tFemtoV0->SetPosNSigmaTPCPi(0);
498 tFemtoV0->SetPosNSigmaTPCP(1000);
500 if(trackneg->GetPdgCode()==-211) //pion minus
502 tFemtoV0->SetNegNSigmaTPCK(1000);
503 tFemtoV0->SetNegNSigmaTPCPi(0);
504 tFemtoV0->SetNegNSigmaTPCP(1000);
506 if(trackpos->GetPdgCode()==321) //K+
508 tFemtoV0->SetPosNSigmaTPCK(0);
509 tFemtoV0->SetPosNSigmaTPCPi(1000);
510 tFemtoV0->SetPosNSigmaTPCP(1000);
512 if(trackneg->GetPdgCode()==-321) //K-
514 tFemtoV0->SetNegNSigmaTPCK(0);
515 tFemtoV0->SetNegNSigmaTPCPi(1000);
516 tFemtoV0->SetNegNSigmaTPCP(1000);