2 ***********************************************************
3 Implementation of reduced ESD information classes for
5 Contact: i.c.arsene@gsi.de, i.c.arsene@cern.ch
7 *********************************************************
10 #ifndef ALIREDUCEDEVENT_H
11 #include "AliReducedEvent.h"
15 #include <TClonesArray.h>
17 ClassImp(AliReducedTrack)
18 ClassImp(AliReducedPair)
19 ClassImp(AliReducedEvent)
20 ClassImp(AliReducedEventFriend)
21 ClassImp(AliReducedCaloCluster)
23 TClonesArray* AliReducedEvent::fgTracks = 0;
24 TClonesArray* AliReducedEvent::fgCandidates = 0;
25 TClonesArray* AliReducedEvent::fgCaloClusters = 0;
27 //_______________________________________________________________________________
28 AliReducedTrack::AliReducedTrack() :
59 fDCA[0] = 0.0; fDCA[1]=0.0;
60 for(Int_t i=0; i<4; ++i) {fTPCnSig[i]=-999.; fTOFnSig[i]=-999.;}
61 for(Int_t i=0; i<3; ++i) {fBayesPID[i]=-999.;}
62 fTRDpid[0]=-999.; fTRDpid[1]=-999.;
66 //_______________________________________________________________________________
67 AliReducedTrack::~AliReducedTrack()
75 //_______________________________________________________________________________
76 AliReducedPair::AliReducedPair() :
93 fLegIds[0] = -1; fLegIds[1] = -1;
94 fMass[0]=-999.; fMass[1]=-999.; fMass[2]=-999.;
98 //_______________________________________________________________________________
99 AliReducedPair::AliReducedPair(const AliReducedPair &c) :
101 fCandidateId(c.CandidateId()),
102 fPairType(c.PairType()),
110 fOpeningAngle(c.OpeningAngle()),
111 //fOnTheFly(c.IsOnTheFly()),
117 fLegIds[0] = c.LegId(0);
118 fLegIds[1] = c.LegId(1);
119 fMass[0] = c.Mass(0); fMass[1] = c.Mass(1); fMass[2] = c.Mass(2);
123 //_______________________________________________________________________________
124 AliReducedPair::~AliReducedPair() {
130 //____________________________________________________________________________
131 AliReducedEvent::AliReducedEvent() :
136 fIsPhysicsSelection(kTRUE),
138 fNVtxContributors(0),
140 fNVtxTPCContributors(0),
144 fNDielectronCandidates(0),
158 for(Int_t i=0; i<3; ++i) {fVtx[i]=-999.; fVtxTPC[i]=-999.;}
159 for(Int_t i=0; i<4; ++i) fCentrality[i]=-1.;
160 fNV0candidates[0]=0; fNV0candidates[1]=0;
161 fNtracks[0]=0; fNtracks[1]=0;
162 for(Int_t i=0; i<64; ++i) fVZEROMult[i] = 0.0;
163 for(Int_t i=0; i<8; ++i) fZDCnEnergy[i]=0.0;
167 //____________________________________________________________________________
168 AliReducedEvent::AliReducedEvent(const Char_t* /*name*/) :
173 fIsPhysicsSelection(kTRUE),
175 fNVtxContributors(0),
177 fNVtxTPCContributors(0),
181 fNDielectronCandidates(0),
195 for(Int_t i=0; i<3; ++i) {fVtx[i]=-999.; fVtxTPC[i]=-999.;}
196 for(Int_t i=0; i<4; ++i) fCentrality[i]=-1.;
197 fNV0candidates[0]=0; fNV0candidates[1]=0;
198 fNtracks[0]=0; fNtracks[1]=0;
199 for(Int_t i=0; i<64; ++i) fVZEROMult[i] = 0.0;
200 for(Int_t i=0; i<8; ++i) fZDCnEnergy[i]=0.0;
202 if(!fgTracks) fgTracks = new TClonesArray("AliReducedTrack", 100000);
204 if(!fgCandidates) fgCandidates = new TClonesArray("AliReducedPair", 100000);
205 fCandidates = fgCandidates;
206 if(!fgCaloClusters) fgCaloClusters = new TClonesArray("AliReducedCaloCluster", 50000);
207 fCaloClusters = fgCaloClusters;
211 //____________________________________________________________________________
212 AliReducedEvent::~AliReducedEvent()
221 //____________________________________________________________________________
222 Float_t AliReducedEvent::MultVZEROA() const
225 // Total VZERO multiplicity in A side
228 for(Int_t i=32;i<64;++i)
229 mult += fVZEROMult[i];
234 //____________________________________________________________________________
235 Float_t AliReducedEvent::MultVZEROC() const
238 // Total VZERO multiplicity in C side
241 for(Int_t i=0;i<32;++i)
242 mult += fVZEROMult[i];
247 //____________________________________________________________________________
248 Float_t AliReducedEvent::MultVZERO() const
251 // Total VZERO multiplicity
253 return MultVZEROA()+MultVZEROC();
257 //____________________________________________________________________________
258 Float_t AliReducedEvent::MultRingVZEROA(Int_t ring) const
261 // VZERO multiplicity in a given ring on A side
263 if(ring<0 || ring>3) return -1.0;
266 for(Int_t i=32+8*ring; i<32+8*(ring+1); ++i)
267 mult += fVZEROMult[i];
272 //____________________________________________________________________________
273 Float_t AliReducedEvent::MultRingVZEROC(Int_t ring) const
276 // VZERO multiplicity in a given ring on C side
278 if(ring<0 || ring>3) return -1.0;
281 for(Int_t i=8*ring; i<8*(ring+1); ++i)
282 mult += fVZEROMult[i];
286 //_____________________________________________________________________________
287 void AliReducedEvent::ClearEvent() {
291 if(fTracks) fTracks->Clear("C");
292 if(fCandidates) fCandidates->Clear("C");
293 if(fCaloClusters) fCaloClusters->Clear("C");
297 fIsPhysicsSelection = kTRUE;
299 fNV0candidates[0] = 0; fNV0candidates[1] = 0;
300 fNDielectronCandidates = 0;
301 fNtracks[0] = 0; fNtracks[1] = 0;
302 for(Int_t i=0; i<3; ++i) {fVtx[i]=-999.; fVtxTPC[i]=-999.; fCentrality[i]=-1.;}
303 for(Int_t i=0; i<64; ++i) fVZEROMult[i] = 0.0;
304 for(Int_t i=0; i<8; ++i) fZDCnEnergy[i]=0.0;
308 //_______________________________________________________________________________
309 AliReducedEventFriend::AliReducedEventFriend() :
314 // default constructor
316 for(Int_t idet=0; idet<kNdetectors; ++idet) {
317 for(Int_t ih=0; ih<fgkNMaxHarmonics; ++ih) {
318 fEventPlaneStatus[idet][ih] = 0;
319 for(Int_t ic=0; ic<2; ++ic)
320 fQvector[idet][ih][ic] = 0.0;
326 //____________________________________________________________________________
327 AliReducedEventFriend::~AliReducedEventFriend()
336 //_____________________________________________________________________________
337 void AliReducedEventFriend::ClearEvent() {
341 for(Int_t idet=0; idet<kNdetectors; ++idet) {
342 for(Int_t ih=0; ih<fgkNMaxHarmonics; ++ih) {
343 fEventPlaneStatus[idet][ih] = 0;
344 for(Int_t ic=0; ic<2; ++ic)
345 fQvector[idet][ih][ic] = 0.0;
351 //____________________________________________________________________________
352 void AliReducedEventFriend::CopyEvent(const AliReducedEventFriend* event) {
354 // copy information from another event to this one
356 for(Int_t idet=0; idet<kNdetectors; ++idet) {
357 for(Int_t ih=0; ih<fgkNMaxHarmonics; ++ih) {
358 fQvector[idet][ih][0] = event->Qx(idet, ih+1);
359 fQvector[idet][ih][1] = event->Qy(idet, ih+1);
360 fEventPlaneStatus[idet][ih] = event->GetEventPlaneStatus(idet, ih+1);
366 //_____________________________________________________________________________
367 AliReducedCaloCluster::AliReducedCaloCluster() :
374 // default constructor
379 //_____________________________________________________________________________
380 AliReducedCaloCluster::~AliReducedCaloCluster()
388 //_______________________________________________________________________________
389 void AliReducedEvent::GetQvector(Double_t Qvec[][2], Int_t det,
390 Float_t etaMin/*=-0.8*/, Float_t etaMax/*=+0.8*/,
391 Bool_t (*IsTrackSelected)(AliReducedTrack*)/*=NULL*/) {
393 // Get the event plane for a specified detector
395 if(det==AliReducedEventFriend::kTPC ||
396 det==AliReducedEventFriend::kTPCptWeights ||
397 det==AliReducedEventFriend::kTPCpos ||
398 det==AliReducedEventFriend::kTPCneg) {
399 GetTPCQvector(Qvec, det, etaMin, etaMax, IsTrackSelected);
402 if(det==AliReducedEventFriend::kVZEROA ||
403 det==AliReducedEventFriend::kVZEROC) {
404 GetVZEROQvector(Qvec, det);
407 if(det==AliReducedEventFriend::kZDCA ||
408 det==AliReducedEventFriend::kZDCC) {
409 GetZDCQvector(Qvec, det);
412 if(det==AliReducedEventFriend::kFMD) {
413 //TODO implementation
420 //_________________________________________________________________
421 Int_t AliReducedEvent::GetTPCQvector(Double_t Qvec[][2], Int_t det,
422 Float_t etaMin/*=-0.8*/, Float_t etaMax/*=+0.8*/,
423 Bool_t (*IsTrackSelected)(AliReducedTrack*)/*=NULL*/) {
425 // Construct the event plane using tracks in the barrel
427 if(!(det==AliReducedEventFriend::kTPC ||
428 det==AliReducedEventFriend::kTPCpos ||
429 det==AliReducedEventFriend::kTPCneg))
431 Int_t nUsedTracks = 0;
433 AliReducedTrack* track=0x0;
434 Double_t weight=0.0; Double_t absWeight = 0.0; Double_t x=0.0; Double_t y=0.0;
435 TIter nextTrack(fTracks);
436 while((track=static_cast<AliReducedTrack*>(nextTrack()))) {
437 if(track->Eta()<etaMin) continue;
438 if(track->Eta()>etaMax) continue;
439 charge = track->Charge();
440 if(det==AliReducedEventFriend::kTPCpos && charge<0) continue;
441 if(det==AliReducedEventFriend::kTPCneg && charge>0) continue;
443 if(IsTrackSelected && !IsTrackSelected(track)) continue;
445 if(det==AliReducedEventFriend::kTPCptWeights) {
446 absWeight = track->Pt();
447 if(absWeight>2.0) absWeight = 2.0; // pt is the weight used for the event plane
450 if(track->Eta()<0.0) weight *= -1.0;
453 x = TMath::Cos(track->Phi());
454 y = TMath::Sin(track->Phi());
456 Qvec[0][0] += weight*x;
457 Qvec[0][1] += weight*y;
459 Qvec[1][0] += absWeight*(2.0*TMath::Power(x,2.0)-1);
460 Qvec[1][1] += absWeight*(2.0*x*y);
462 Qvec[2][0] += weight*(4.0*TMath::Power(x,3.0)-3.0*x);
463 Qvec[2][1] += weight*(3.0*y-4.0*TMath::Power(y,3.0));
465 Qvec[3][0] += absWeight*(1.0-8.0*TMath::Power(x*y,2.0));
466 Qvec[3][1] += absWeight*(4.0*x*y-8.0*x*TMath::Power(y,3.0));
468 Qvec[4][0] += weight*(16.0*TMath::Power(x,5.0)-20.0*TMath::Power(x, 3.0)+5.0*x);
469 Qvec[4][1] += weight*(16.0*TMath::Power(y,5.0)-20.0*TMath::Power(y, 3.0)+5.0*y);
471 Qvec[5][0] += absWeight*(32.0*TMath::Power(x,6.0)-48.0*TMath::Power(x, 4.0)+18.0*TMath::Power(x, 2.0)-1.0);
472 Qvec[5][1] += absWeight*(x*y*(32.0*TMath::Power(y,4.0)-32.0*TMath::Power(y, 2.0)+6.0));
478 //____________________________________________________________________________
479 void AliReducedEvent::SubtractParticleFromQvector(
480 AliReducedTrack* particle, Double_t Qvec[][2], Int_t det,
481 Float_t etaMin/*=-0.8*/, Float_t etaMax/*=+0.8*/,
482 Bool_t (*IsTrackSelected)(AliReducedTrack*)/*=NULL*/) {
484 // subtract a particle from the event Q-vector
486 Float_t eta = particle->Eta();
487 if(eta<etaMin) return;
488 if(eta>etaMax) return;
490 Float_t charge = particle->Charge();
491 if(det==AliReducedEventFriend::kTPCpos && charge<0) return;
492 if(det==AliReducedEventFriend::kTPCneg && charge>0) return;
494 if(IsTrackSelected && !IsTrackSelected(particle)) return;
496 Double_t weight=0.0; Double_t absWeight = 0.0;
497 if(det==AliReducedEventFriend::kTPCptWeights) {
498 absWeight = particle->Pt();
499 if(absWeight>2.0) absWeight = 2.0;
502 if(eta<0.0) weight *= -1.0;
504 Float_t x = TMath::Cos(particle->Phi());
505 Float_t y = TMath::Sin(particle->Phi());
508 Qvec[0][0] -= weight*x;
509 Qvec[0][1] -= weight*y;
511 Qvec[1][0] -= absWeight*(2.0*TMath::Power(x,2.0)-1);
512 Qvec[1][1] -= absWeight*(2.0*x*y);
514 Qvec[2][0] -= weight*(4.0*TMath::Power(x,3.0)-3.0*x);
515 Qvec[2][1] -= weight*(3.0*y-4.0*TMath::Power(y,3.0));
517 Qvec[3][0] -= absWeight*(1.0-8.0*TMath::Power(x*y,2.0));
518 Qvec[3][1] -= absWeight*(4.0*x*y-8.0*x*TMath::Power(y,3.0));
520 Qvec[4][0] -= weight*(16.0*TMath::Power(x,5.0)-20.0*TMath::Power(x, 3.0)+5.0*x);
521 Qvec[4][1] -= weight*(16.0*TMath::Power(y,5.0)-20.0*TMath::Power(y, 3.0)+5.0*y);
523 Qvec[5][0] -= absWeight*(32.0*TMath::Power(x,6.0)-48.0*TMath::Power(x, 4.0)+18.0*TMath::Power(x, 2.0)-1.0);
524 Qvec[5][1] -= absWeight*(x*y*(32.0*TMath::Power(y,4.0)-32.0*TMath::Power(y, 2.0)+6.0));
530 //_________________________________________________________________
531 void AliReducedEvent::GetVZEROQvector(Double_t Qvec[][2], Int_t det) {
533 // Get the reaction plane from the VZERO detector for a given harmonic
535 GetVZEROQvector(Qvec, det, fVZEROMult);
539 //_________________________________________________________________
540 void AliReducedEvent::GetVZEROQvector(Double_t Qvec[][2], Int_t det, Float_t* vzeroMult) {
542 // Get the reaction plane from the VZERO detector for a given harmonic
544 // Q{x,y} = SUM_i mult(i) * {cos(n*phi_i), sin(n*phi_i)}
545 // phi_i - phi angle of the VZERO sector i
546 // Each sector covers 45 degrees(8 sectors per ring). Middle of sector 0 is at 45/2
551 // at the next ring continues the same
553 // channel 9: 22.5 + 45
555 if(!(det==AliReducedEventFriend::kVZEROA ||
556 det==AliReducedEventFriend::kVZEROC))
559 const Double_t kX[8] = {0.92388, 0.38268, -0.38268, -0.92388, -0.92388, -0.38268, 0.38268, 0.92388}; // cosines of the angles of the VZERO sectors (8 per ring)
560 const Double_t kY[8] = {0.38268, 0.92388, 0.92388, 0.38268, -0.38268, -0.92388, -0.92388, -0.38268}; // sines -- " --
563 for(Int_t iChannel=0; iChannel<64; ++iChannel) {
564 if(iChannel<32 && det==AliReducedEventFriend::kVZEROA) continue;
565 if(iChannel>=32 && det==AliReducedEventFriend::kVZEROC) continue;
568 Qvec[0][0] += vzeroMult[iChannel]*kX[phi];
569 Qvec[0][1] += vzeroMult[iChannel]*kY[phi];
571 Qvec[1][0] += vzeroMult[iChannel]*(2.0*TMath::Power(kX[phi],2.0)-1);
572 Qvec[1][1] += vzeroMult[iChannel]*(2.0*kX[phi]*kY[phi]);
574 Qvec[2][0] += vzeroMult[iChannel]*(4.0*TMath::Power(kX[phi],3.0)-3.0*kX[phi]);
575 Qvec[2][1] += vzeroMult[iChannel]*(3.0*kY[phi]-4.0*TMath::Power(kY[phi],3.0));
577 Qvec[3][0] += vzeroMult[iChannel]*(1.0-8.0*TMath::Power(kX[phi]*kY[phi],2.0));
578 Qvec[3][1] += vzeroMult[iChannel]*(4.0*kX[phi]*kY[phi]-8.0*kX[phi]*TMath::Power(kY[phi],3.0));
580 Qvec[4][0] += vzeroMult[iChannel]*(16.0*TMath::Power(kX[phi],5.0)-20.0*TMath::Power(kX[phi], 3.0)+5.0*kX[phi]);
581 Qvec[4][1] += vzeroMult[iChannel]*(16.0*TMath::Power(kY[phi],5.0)-20.0*TMath::Power(kY[phi], 3.0)+5.0*kY[phi]);
583 Qvec[5][0] += vzeroMult[iChannel]*(32.0*TMath::Power(kX[phi],6.0)-48.0*TMath::Power(kX[phi], 4.0)+18.0*TMath::Power(kX[phi], 2.0)-1.0);
584 Qvec[5][1] += vzeroMult[iChannel]*(kX[phi]*kY[phi]*(32.0*TMath::Power(kY[phi],4.0)-32.0*TMath::Power(kY[phi], 2.0)+6.0));
585 } // end loop over channels
589 //_________________________________________________________________
590 void AliReducedEvent::GetZDCQvector(Double_t Qvec[][2], Int_t det) const {
592 // Construct the event plane using the ZDC
593 // ZDC has 2 side (A and C) with 4 calorimeters on each side
594 // The XY position of each calorimeter is specified by the
595 // zdcNTowerCenters_x and zdcNTowerCenters_y arrays
596 if(!(det==AliReducedEventFriend::kZDCA ||
597 det==AliReducedEventFriend::kZDCC)) return; // bad detector option
598 const Float_t zdcTowerCenter = 1.75;
599 const Float_t zdcNTowerCentersX[4] = {-zdcTowerCenter, zdcTowerCenter, -zdcTowerCenter, zdcTowerCenter};
600 const Float_t zdcNTowerCentersY[4] = {-zdcTowerCenter, -zdcTowerCenter, zdcTowerCenter, zdcTowerCenter};
602 Qvec[0][0] = 0.0; Qvec[0][1] = 0.0; // first harmonic Q-vector
603 Float_t zdcNCentroidSum = 0;
604 Float_t zdcNalpha = 0.5;
606 for(Int_t i=0; i<4; ++i) {
607 if(fZDCnEnergy[i+(det==AliReducedEventFriend::kZDCA ? 4 : 0)]>0.0) {
608 Float_t zdcNenergyAlpha = TMath::Power(fZDCnEnergy[i+(det==AliReducedEventFriend::kZDCA ? 4 : 0)], zdcNalpha);
609 Qvec[0][0] += zdcNTowerCentersX[i-1]*zdcNenergyAlpha;
610 Qvec[0][1] += zdcNTowerCentersY[i-1]*zdcNenergyAlpha;
611 zdcNCentroidSum += zdcNenergyAlpha;
613 } // end loop over channels
615 if(zdcNCentroidSum>0.0) {
616 Qvec[0][0] /= zdcNCentroidSum;
617 Qvec[0][1] /= zdcNCentroidSum;