5 // Author: S.Aiola, C.Loizides
7 #include "AliJetModelBaseTask.h"
9 #include <TClonesArray.h>
11 #include <TLorentzVector.h>
16 #include "AliVEvent.h"
17 #include "AliAODCaloCluster.h"
18 #include "AliESDCaloCluster.h"
19 #include "AliVCluster.h"
20 #include "AliEMCALDigit.h"
21 #include "AliEMCALRecPoint.h"
22 #include "AliESDCaloCells.h"
23 #include "AliAODCaloCells.h"
24 #include "AliAODMCParticle.h"
25 #include "AliVCaloCells.h"
26 #include "AliPicoTrack.h"
27 #include "AliEMCALGeometry.h"
29 #include "AliNamedArrayI.h"
31 ClassImp(AliJetModelBaseTask)
33 //________________________________________________________________________
34 AliJetModelBaseTask::AliJetModelBaseTask() :
35 AliAnalysisTaskSE("AliJetModelBaseTask"),
44 fOutMCParticlesName(),
50 fPhiMax(TMath::Pi() * 2),
59 fPtPhiEvPlDistribution(0),
63 fFlowFluctuations(kFALSE),
78 fOutMCParticlesMap(0),
83 // Default constructor.
90 //________________________________________________________________________
91 AliJetModelBaseTask::AliJetModelBaseTask(const char *name, Bool_t drawqa) :
92 AliAnalysisTaskSE(name),
94 fTracksName("PicoTracks"),
95 fOutTracksName("PicoTracksEmbedded"),
96 fCaloName("CaloClustersCorr"),
97 fOutCaloName("CaloClustersCorrEmbedded"),
100 fMCParticlesName(""),
101 fOutMCParticlesName(""),
103 fSuffix("Processed"),
107 fPhiMax(TMath::Pi() * 2),
116 fPtPhiEvPlDistribution(0),
120 fFlowFluctuations(kFALSE),
135 fOutMCParticlesMap(0),
140 // Standard constructor.
143 DefineOutput(1, TList::Class());
151 //________________________________________________________________________
152 AliJetModelBaseTask::~AliJetModelBaseTask()
157 //________________________________________________________________________
158 void AliJetModelBaseTask::UserCreateOutputObjects()
160 // Create user output.
165 fOutput = new TList();
168 PostData(1, fOutput);
171 //________________________________________________________________________
172 void AliJetModelBaseTask::UserExec(Option_t *)
174 // Execute per event.
177 fIsInit = ExecOnce();
186 const AliVVertex *vert = InputEvent()->GetPrimaryVertex();
188 vert->GetXYZ(fVertex);
192 fOutTracks->Delete();
194 fOutClusters->Delete();
196 fOutMCParticles->Delete();
199 if (fDensitySpectrum) {
200 fNTracks = TMath::Nint(fDensitySpectrum->GetRandom());
201 fNCells = TMath::Nint(fDensitySpectrum->GetRandom());
202 fNClusters = TMath::Nint(fDensitySpectrum->GetRandom());
206 if (fOutMCParticlesMap)
207 fOutMCParticlesMap->Clear();
209 AliVCaloCells *tempCaloCells = 0;
214 tempCaloCells = fCaloCells;
215 fCaloCells = static_cast<AliVCaloCells*>(tempCaloCells->Clone(Form("%s_old",fCaloCells->GetName())));
219 if (fPtPhiEvPlDistribution || fAddV2)
220 fPsi = gRandom->Rndm() * TMath::Pi();
224 if (fCaloCells && !fCopyArray) {
226 fCaloCells = tempCaloCells;
230 //________________________________________________________________________
231 Bool_t AliJetModelBaseTask::ExecOnce()
236 gRandom = new TRandom3(0);
238 fEsdMode = InputEvent()->InheritsFrom("AliESDEvent");
240 if (fPtMax < fPtMin) {
241 AliWarning (Form("PtMax (%f) < PtMin (%f), setting PtMax = PtMin = %f", fPtMax, fPtMin, fPtMin));
245 if (fEtaMax < fEtaMin) {
246 AliWarning (Form("EtaMax (%f) < EtaMin (%f), setting EtaMax = EtaMin = %f", fEtaMax, fEtaMin, fEtaMin));
250 if (fPhiMax < fPhiMin) {
251 AliWarning (Form("PhiMax (%f) < PhiMin (%f), setting PhiMax = PhiMin = %f", fPhiMax, fPhiMin, fPhiMin));
255 if (!fCellsName.IsNull()) {
256 fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCellsName));
258 AliWarning(Form("%s: Couldn't retrieve calo cells with name %s!", GetName(), fCellsName.Data()));
260 else if (!fCaloCells->InheritsFrom("AliVCaloCells")) {
261 AliError(Form("%s: Collection %s does not contain a AliVCaloCells object!", GetName(), fCellsName.Data()));
266 if (!fOutCaloCells) {
267 fOutCellsName = fCellsName;
269 fOutCellsName += fSuffix;
270 if (fCopyArray || !fCaloCells) {
272 fOutCaloCells = new AliESDCaloCells(fOutCellsName,fOutCellsName);
274 fOutCaloCells = new AliAODCaloCells(fOutCellsName,fOutCellsName);
276 if (InputEvent()->FindListObject(fOutCellsName)) {
277 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutCellsName.Data()));
281 InputEvent()->AddObject(fOutCaloCells);
285 fOutCaloCells = fCaloCells;
290 if (!fTracksName.IsNull()) {
291 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName));
293 AliWarning(Form("%s: Couldn't retrieve tracks with name %s!", GetName(), fTracksName.Data()));
295 else if (!fTracks->GetClass()->GetBaseClass("AliPicoTrack")) {
296 AliError(Form("%s: Collection %s does not contain AliPicoTrack objects!", GetName(), fTracksName.Data()));
302 fOutTracksName = fTracksName;
304 fOutTracksName += fSuffix;
305 if (fCopyArray || !fTracks) {
306 fOutTracks = new TClonesArray("AliPicoTrack");
307 fOutTracks->SetName(fOutTracksName);
308 if (InputEvent()->FindListObject(fOutTracksName)) {
309 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutTracksName.Data()));
313 InputEvent()->AddObject(fOutTracks);
317 fOutTracks = fTracks;
322 if(fAddV2 && (!fDifferentialV2)) {
323 AliWarning(Form("%s: Cannot add v2 without diffential v2!", GetName()));
326 if (!fCaloName.IsNull()) {
327 fClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName));
330 AliWarning(Form("%s: Couldn't retrieve clusters with name %s!", GetName(), fCaloName.Data()));
332 else if (!fClusters->GetClass()->GetBaseClass("AliVCluster")) {
333 AliError(Form("%s: Collection %s does not contain AliVCluster objects!", GetName(), fCaloName.Data()));
339 fOutCaloName = fCaloName;
341 fOutCaloName += fSuffix;
344 className = fClusters->GetClass()->GetName();
346 className = "AliESDCaloCluster";
348 className = "AliAODCaloCluster";
350 if (fCopyArray || !fClusters) {
351 fOutClusters = new TClonesArray(className.Data());
352 fOutClusters->SetName(fOutCaloName);
353 if (InputEvent()->FindListObject(fOutCaloName)) {
354 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutCaloName.Data()));
358 InputEvent()->AddObject(fOutClusters);
362 fOutClusters = fClusters;
367 if (!fMCParticlesName.IsNull()) {
368 fMCParticles = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCParticlesName));
370 AliWarning(Form("%s: Couldn't retrieve MC particles with name %s!", GetName(), fMCParticlesName.Data()));
373 if (!fMCParticles->GetClass()->GetBaseClass("AliAODMCParticle")) {
374 AliError(Form("%s: Collection %s does not contain AliAODMCParticle objects!", GetName(), fMCParticlesName.Data()));
379 fMCParticlesMap = dynamic_cast<AliNamedArrayI*>(InputEvent()->FindListObject(fMCParticlesName + "_Map"));
381 if (!fMCParticlesMap) {
382 AliWarning(Form("%s: Could not retrieve map for MC particles %s! Will assume MC labels consistent with indexes...", GetName(), fMCParticlesName.Data()));
383 fMCParticlesMap = new AliNamedArrayI(fMCParticlesName + "_Map", 99999);
384 for (Int_t i = 0; i < 99999; i++) {
385 fMCParticlesMap->AddAt(i,i);
390 if (!fOutMCParticles) {
391 fOutMCParticlesName = fMCParticlesName;
393 fOutMCParticlesName += fSuffix;
394 if (fCopyArray || !fMCParticles) {
396 fOutMCParticles = new TClonesArray("AliAODMCParticle");
397 fOutMCParticles->SetName(fOutMCParticlesName);
398 if (InputEvent()->FindListObject(fOutMCParticlesName)) {
399 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutMCParticlesName.Data()));
403 InputEvent()->AddObject(fOutMCParticles);
406 fOutMCParticlesMap = new AliNamedArrayI(fOutMCParticlesName + "_Map",99999);
407 if (InputEvent()->FindListObject(fOutMCParticlesName + "_Map")) {
408 AliFatal(Form("%s: Map %s_Map is already present in the event!", GetName(), fOutMCParticlesName.Data()));
412 InputEvent()->AddObject(fOutMCParticlesMap);
416 fOutMCParticles = fMCParticles;
417 fOutMCParticlesMap = fMCParticlesMap;
423 if (fGeomName.Length() > 0) {
424 fGeom = AliEMCALGeometry::GetInstance(fGeomName);
426 AliFatal(Form("Could not get geometry with name %s!", fGeomName.Data()));
430 fGeom = AliEMCALGeometry::GetInstance();
432 AliFatal("Could not get default geometry!");
441 //________________________________________________________________________
442 Int_t AliJetModelBaseTask::SetNumberOfOutCells(Int_t n)
444 if (fOutCaloCells->GetNumberOfCells() < n) {
445 fOutCaloCells->DeleteContainer();
446 fOutCaloCells->CreateContainer(n);
449 fOutCaloCells->SetNumberOfCells(n);
457 //________________________________________________________________________
458 Int_t AliJetModelBaseTask::AddCell(Double_t e, Double_t eta, Double_t phi)
460 // Add a cell to the event.
463 if (eta < -100 || phi < 0) {
464 GetRandomCell(eta, phi, absId);
467 fGeom->EtaPhiFromIndex(absId, eta, phi);
471 AliWarning(Form("Unable to embed cell in eta = %f, phi = %f!"
472 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
473 eta, phi, fEtaMin, fEtaMax, fPhiMin, fPhiMax));
478 Double_t pt = GetRandomPt();
479 TLorentzVector nPart;
480 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
484 return AddCell(e, absId);
487 //________________________________________________________________________
488 Int_t AliJetModelBaseTask::AddCell(Double_t e, Int_t absId, Double_t time, Int_t label)
490 // Add a cell to the event.
495 label += fMarkMC + fMCLabelShift;
499 pos = fCaloCells->GetCellPosition(absId);
502 Bool_t increaseOnSuccess = kFALSE;
505 increaseOnSuccess = kTRUE;
509 Short_t cellNumber = -1;
511 Double_t old_time = 0;
513 Double_t old_efrac = 0;
514 fOutCaloCells->GetCell(pos, cellNumber, old_e, old_time, old_label, old_efrac);
516 efrac = e / (old_e + e);
518 if (old_label > 0 && e < old_efrac * old_e) {
527 Bool_t r = fOutCaloCells->SetCell(pos, absId, e, time, label, efrac);
530 if (increaseOnSuccess)
538 //________________________________________________________________________
539 AliVCluster* AliJetModelBaseTask::AddCluster(AliVCluster *oc)
541 // Add a cluster to the event.
543 const Int_t nClusters = fOutClusters->GetEntriesFast();
544 AliVCluster *dc = static_cast<AliVCluster*>(fOutClusters->New(nClusters));
545 dc->SetType(AliVCluster::kEMCALClusterv1);
547 Float_t pos[3] = {0};
548 oc->GetPosition(pos);
549 dc->SetPosition(pos);
550 dc->SetNCells(oc->GetNCells());
551 dc->SetCellsAbsId(oc->GetCellsAbsId());
552 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
553 dc->SetID(oc->GetID());
554 dc->SetDispersion(oc->GetDispersion());
555 dc->SetEmcCpvDistance(-1);
557 dc->SetTOF(oc->GetTOF()); //time-of-flight
558 dc->SetNExMax(oc->GetNExMax()); //number of local maxima
559 dc->SetM02(oc->GetM02());
560 dc->SetM20(oc->GetM20());
561 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
564 UInt_t nlabels = oc->GetNLabels();
565 Int_t *labels = oc->GetLabels();
567 if (nlabels != 0 && labels)
568 parents.Set(nlabels, labels);
575 if (fMarkMC+fMCLabelShift != 0) {
576 for (UInt_t i = 0; i < nlabels; i++) {
577 parents[i] += fMarkMC+fMCLabelShift;
581 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(dc);
583 esdClus->AddLabels(parents);
586 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(dc);
588 aodClus->SetLabel(parents.GetArray(), nlabels);
594 //________________________________________________________________________
595 AliVCluster* AliJetModelBaseTask::AddCluster(Double_t e, Double_t eta, Double_t phi, Int_t label)
597 // Add a cluster to the event.
600 if (eta < -100 || phi < 0) {
601 GetRandomCell(eta, phi, absId);
604 fGeom->EtaPhiFromIndex(absId, eta, phi);
608 AliWarning(Form("Unable to embed cluster in eta = %f, phi = %f!"
609 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
610 eta, phi, fEtaMin, fEtaMax, fPhiMin, fPhiMax));
615 Double_t pt = GetRandomPt();
616 TLorentzVector nPart;
617 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
621 return AddCluster(e, absId, label);
624 //________________________________________________________________________
625 AliVCluster* AliJetModelBaseTask::AddCluster(Double_t e, Int_t absId, Int_t label)
627 // Add a cluster to the event.
629 const Int_t nClusters = fOutClusters->GetEntriesFast();
631 TClonesArray digits("AliEMCALDigit", 1);
633 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(digits.New(0));
635 digit->SetIndexInList(0);
636 digit->SetType(AliEMCALDigit::kHG);
637 digit->SetAmplitude(e);
639 AliEMCALRecPoint recPoint("");
640 recPoint.AddDigit(*digit, e, kFALSE);
641 recPoint.EvalGlobalPosition(0, &digits);
644 recPoint.GetGlobalPosition(gpos);
648 AliVCluster *cluster = static_cast<AliVCluster*>(fOutClusters->New(nClusters));
649 cluster->SetType(AliVCluster::kEMCALClusterv1);
650 cluster->SetE(recPoint.GetEnergy());
651 cluster->SetPosition(g);
652 cluster->SetNCells(1);
653 UShort_t shortAbsId = absId;
654 cluster->SetCellsAbsId(&shortAbsId);
655 Double32_t fract = 1;
656 cluster->SetCellsAmplitudeFraction(&fract);
657 cluster->SetID(nClusters);
658 cluster->SetEmcCpvDistance(-1);
664 label += fMarkMC+fMCLabelShift;
667 AliESDCaloCluster *esdClus = static_cast<AliESDCaloCluster*>(cluster);
668 TArrayI parents(1, &label);
669 esdClus->AddLabels(parents);
672 AliAODCaloCluster *aodClus = static_cast<AliAODCaloCluster*>(cluster);
673 aodClus->SetLabel(&label, 1);
679 //________________________________________________________________________
680 AliPicoTrack* AliJetModelBaseTask::AddTrack(Double_t pt, Double_t eta, Double_t phi, Byte_t type, Double_t etaemc, Double_t phiemc, Double_t ptemc, Bool_t ise, Int_t label, Short_t charge, Double_t mass)
682 // Add a track to the event.
684 if (pt < 0 && eta < -100 && phi < 0) {
685 GetRandomParticle(pt,eta,phi);
691 eta = GetRandomEta();
693 phi = GetRandomPhi(pt);
697 label += fMarkMC+fMCLabelShift;
699 label -= fMarkMC+fMCLabelShift;
701 if(fAddV2) AddV2(phi, pt);
703 const Int_t nTracks = fOutTracks->GetEntriesFast();
705 AliPicoTrack *track = new ((*fOutTracks)[nTracks]) AliPicoTrack(pt,
720 //________________________________________________________________________
721 AliAODMCParticle* AliJetModelBaseTask::AddMCParticle(AliAODMCParticle *part, Int_t origIndex)
723 const Int_t nPart = fOutMCParticles->GetEntriesFast();
725 AliAODMCParticle *aodpart = new ((*fOutMCParticles)[nPart]) AliAODMCParticle(*part);
727 if (origIndex + fMCLabelShift >= fOutMCParticlesMap->GetSize())
728 fOutMCParticlesMap->Set((origIndex + fMCLabelShift)*2);
730 fOutMCParticlesMap->AddAt(nPart, origIndex + fMCLabelShift);
731 AliDebug(2, Form("Setting bin %d to %d (fMCLabelShift=%d, origIndex=%d)",
732 origIndex + fMCLabelShift, fOutMCParticlesMap->At(origIndex + fMCLabelShift), fMCLabelShift, origIndex));
737 //_____________________________________________________________________________
738 void AliJetModelBaseTask::AddV2(Double_t &phi, Double_t &pt) const
740 // similar to AliFlowTrackSimple::AddV2, except for the flow fluctuations
741 Double_t phi0(phi), v2(0.), f(0.), fp(0.), phiprev(0.);
742 if(fDifferentialV2) v2 = fDifferentialV2->Eval(pt);
743 if(TMath::AreEqualAbs(v2, 0, 1e-5)) return;
744 // introduce flow fluctuations (gaussian)
745 if(fFlowFluctuations) v2 += TMath::Sqrt(2*(v2*.25)*(v2*.25))*TMath::ErfInverse(2*(gRandom->Uniform(0, fFlowFluctuations))-1);
746 for (Int_t i(0); i < 100; i++) {
747 phiprev=phi; //store last value for comparison
748 f = phi-phi0+v2*TMath::Sin(2.*(phi-fPsi));
749 fp = 1.0+2.0*v2*TMath::Cos(2.*(phi-fPsi)); //first derivative
751 if (TMath::AreEqualAbs(phiprev, phi, 1e-10)) break;
755 //_____________________________________________________________________________
756 void AliJetModelBaseTask::CopyCells()
763 for (Short_t i = 0; i < fCaloCells->GetNumberOfCells(); i++) {
767 Short_t cellNum = -1;
770 fCaloCells->GetCell(i, cellNum, amp, time, mclabel, efrac);
775 fOutCaloCells->SetCell(i, cellNum, amp, time, mclabel, efrac);
779 AliDebug(2, Form("%d cells from the current event", fAddedCells));
782 //________________________________________________________________________
783 void AliJetModelBaseTask::CopyClusters()
785 // Copy all the clusters in the new collection
789 const Int_t nClusters = fClusters->GetEntriesFast();
790 Int_t nCopiedClusters = 0;
793 for (Int_t i = 0; i < nClusters; ++i) {
794 AliESDCaloCluster *esdcluster = static_cast<AliESDCaloCluster*>(fClusters->At(i));
795 if (!esdcluster || !esdcluster->IsEMCAL())
797 AliESDCaloCluster *clus = new ((*fOutClusters)[nCopiedClusters]) AliESDCaloCluster(*esdcluster);
799 TArrayI *labels = clus->GetLabelsArray();
807 for (Int_t i = 0; i < nClusters; ++i) {
808 AliAODCaloCluster *aodcluster = static_cast<AliAODCaloCluster*>(fClusters->At(i));
809 if (!aodcluster || !aodcluster->IsEMCAL())
811 AliAODCaloCluster *clus = new ((*fOutClusters)[nCopiedClusters]) AliAODCaloCluster(*aodcluster);
819 //________________________________________________________________________
820 void AliJetModelBaseTask::CopyTracks()
822 // Copy all the tracks in the new collection
827 const Int_t nTracks = fTracks->GetEntriesFast();
828 Int_t nCopiedTracks = 0;
829 for (Int_t i = 0; i < nTracks; ++i) {
830 AliPicoTrack *picotrack = static_cast<AliPicoTrack*>(fTracks->At(i));
833 AliPicoTrack *track = new ((*fOutTracks)[nCopiedTracks]) AliPicoTrack(*picotrack);
834 if (!fIsMC && track->GetLabel() != 0)
840 //________________________________________________________________________
841 void AliJetModelBaseTask::CopyMCParticles()
843 // Copy all the MC particles in the new collection
848 const Int_t nPart = fMCParticles->GetEntriesFast();
849 Int_t nCopiedPart = 0;
850 for (Int_t i = 0; i < nPart; ++i) {
851 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fMCParticles->At(i));
854 new ((*fOutMCParticles)[nCopiedPart]) AliAODMCParticle(*part);
859 if (!fMCParticlesMap || !fOutMCParticlesMap)
862 if (fOutMCParticlesMap->GetSize() < fMCParticlesMap->GetSize())
863 fOutMCParticlesMap->Set(fMCParticlesMap->GetSize() * 2);
865 for (Int_t i = 0; i < fMCParticlesMap->GetSize(); i++) {
866 fOutMCParticlesMap->AddAt(fMCParticlesMap->At(i), i);
867 if (fMCParticlesMap->At(i) >= 0)
871 AliDebug(2,Form("MC particles copied. fMCLabelShift=%d",fMCLabelShift));
874 //________________________________________________________________________
875 void AliJetModelBaseTask::GetRandomCell(Double_t &eta, Double_t &phi, Int_t &absId)
880 Double_t rndEta = eta;
881 Double_t rndPhi = phi;
884 rndEta = GetRandomEta(kTRUE);
886 rndPhi = GetRandomPhi(kTRUE);
887 fGeom->GetAbsCellIdFromEtaPhi(rndEta, rndPhi, absId);
889 } while (absId == -1 && repeats < 100);
892 AliWarning(Form("Could not extract random cluster! Random eta-phi extracted more than 100 times!\n"
893 "eta [%f, %f], phi [%f, %f]\n", fEtaMin, fEtaMax, fPhiMin, fPhiMax));
901 //________________________________________________________________________
902 Double_t AliJetModelBaseTask::GetRandomEta(Bool_t emcal)
906 Double_t etamax = fEtaMax;
907 Double_t etamin = fEtaMin;
910 const Double_t EmcalMinEta = fGeom->GetArm1EtaMin();
911 const Double_t EmcalMaxEta = fGeom->GetArm1EtaMax();
913 if (etamax > EmcalMaxEta) etamax = EmcalMaxEta;
914 if (etamax < EmcalMinEta) etamax = EmcalMinEta;
915 if (etamin > EmcalMaxEta) etamin = EmcalMaxEta;
916 if (etamin < EmcalMinEta) etamin = EmcalMinEta;
919 return gRandom->Rndm() * (etamax - etamin) + etamin;
922 //________________________________________________________________________
923 Double_t AliJetModelBaseTask::GetRandomPhi(Bool_t emcal)
927 Double_t phimax = fPhiMax;
928 Double_t phimin = fPhiMin;
931 const Double_t EmcalMinPhi = fGeom->GetArm1PhiMin() * TMath::DegToRad();
932 const Double_t EmcalMaxPhi = fGeom->GetArm1PhiMax() * TMath::DegToRad();
934 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
935 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
936 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
937 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
940 Double_t result = gRandom->Rndm() * (phimax - phimin) + phimin;
945 //________________________________________________________________________
946 Double_t AliJetModelBaseTask::GetRandomPt()
951 return fPtSpectrum->GetRandom();
953 return gRandom->Rndm() * (fPtMax - fPtMin) + fPtMin;
956 //________________________________________________________________________
957 void AliJetModelBaseTask::GetRandomParticle(Double_t &pt, Double_t &eta, Double_t &phi, Bool_t emcal)
959 // Get a random particle.
961 eta = GetRandomEta(emcal);
963 if (fPtPhiEvPlDistribution) {
964 Double_t phimax = fPhiMax;
965 Double_t phimin = fPhiMin;
968 const Double_t EmcalMinPhi = fGeom->GetArm1PhiMin() * TMath::DegToRad();
969 const Double_t EmcalMaxPhi = fGeom->GetArm1PhiMax() * TMath::DegToRad();
971 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
972 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
973 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
974 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
977 if (fPtPhiEvPlDistribution->GetXmin() > phimax || fPtPhiEvPlDistribution->GetXmax() < phimin) {
978 AliWarning(Form("The hisogram %s does not overlap with the EMCal acceptance limits. It will be ignored.",fPtPhiEvPlDistribution->GetName()));
980 phi = GetRandomPhi(emcal);
984 fPtPhiEvPlDistribution->GetRandom2(pt,phi);
986 if (phi > TMath::Pi() * 2) phi -= TMath::Pi() * 2;
987 } while (phi > phimax || phi < phimin);
992 phi = GetRandomPhi(emcal);
996 //________________________________________________________________________
997 void AliJetModelBaseTask::Run()