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(),
51 fPhiMax(TMath::Pi() * 2),
60 fPtPhiEvPlDistribution(0),
64 fFlowFluctuations(kFALSE),
79 fOutMCParticlesMap(0),
85 // Default constructor.
92 //________________________________________________________________________
93 AliJetModelBaseTask::AliJetModelBaseTask(const char *name, Bool_t drawqa) :
94 AliAnalysisTaskSE(name),
96 fTracksName("PicoTracks"),
97 fOutTracksName("PicoTracksEmbedded"),
98 fCaloName("CaloClustersCorr"),
99 fOutCaloName("CaloClustersCorrEmbedded"),
102 fMCParticlesName(""),
103 fOutMCParticlesName(""),
106 fSuffix("Processed"),
110 fPhiMax(TMath::Pi() * 2),
119 fPtPhiEvPlDistribution(0),
123 fFlowFluctuations(kFALSE),
138 fOutMCParticlesMap(0),
144 // Standard constructor.
147 DefineOutput(1, TList::Class());
155 //________________________________________________________________________
156 AliJetModelBaseTask::~AliJetModelBaseTask()
161 //________________________________________________________________________
162 void AliJetModelBaseTask::UserCreateOutputObjects()
164 // Create user output.
169 fOutput = new TList();
172 PostData(1, fOutput);
175 //________________________________________________________________________
176 void AliJetModelBaseTask::UserExec(Option_t *)
178 // Execute per event.
181 fIsInit = ExecOnce();
190 const AliVVertex *vert = InputEvent()->GetPrimaryVertex();
192 vert->GetXYZ(fVertex);
196 fOutTracks->Delete();
198 fOutClusters->Delete();
200 fOutMCParticles->Delete();
203 if (fDensitySpectrum) {
204 fNTracks = TMath::Nint(fDensitySpectrum->GetRandom());
205 fNCells = TMath::Nint(fDensitySpectrum->GetRandom());
206 fNClusters = TMath::Nint(fDensitySpectrum->GetRandom());
210 if (fOutMCParticlesMap)
211 fOutMCParticlesMap->Clear();
213 AliVCaloCells *tempCaloCells = 0;
218 tempCaloCells = fCaloCells;
219 fCaloCells = static_cast<AliVCaloCells*>(tempCaloCells->Clone(Form("%s_old",fCaloCells->GetName())));
223 if (fPtPhiEvPlDistribution || fAddV2)
224 fPsi = gRandom->Rndm() * TMath::Pi();
228 if (fCaloCells && !fCopyArray) {
230 fCaloCells = tempCaloCells;
234 //________________________________________________________________________
235 Bool_t AliJetModelBaseTask::ExecOnce()
240 gRandom = new TRandom3(0);
242 fEsdMode = InputEvent()->InheritsFrom("AliESDEvent");
244 if (fPtMax < fPtMin) {
245 AliWarning (Form("PtMax (%f) < PtMin (%f), setting PtMax = PtMin = %f", fPtMax, fPtMin, fPtMin));
249 if (fEtaMax < fEtaMin) {
250 AliWarning (Form("EtaMax (%f) < EtaMin (%f), setting EtaMax = EtaMin = %f", fEtaMax, fEtaMin, fEtaMin));
254 if (fPhiMax < fPhiMin) {
255 AliWarning (Form("PhiMax (%f) < PhiMin (%f), setting PhiMax = PhiMin = %f", fPhiMax, fPhiMin, fPhiMin));
259 if (!fCellsName.IsNull()) {
260 fCaloCells = dynamic_cast<AliVCaloCells*>(InputEvent()->FindListObject(fCellsName));
262 AliWarning(Form("%s: Couldn't retrieve calo cells with name %s!", GetName(), fCellsName.Data()));
264 else if (!fCaloCells->InheritsFrom("AliVCaloCells")) {
265 AliError(Form("%s: Collection %s does not contain a AliVCaloCells object!", GetName(), fCellsName.Data()));
270 if (!fOutCaloCells) {
271 fOutCellsName = fCellsName;
273 fOutCellsName += fSuffix;
274 if (fCopyArray || !fCaloCells) {
276 fOutCaloCells = new AliESDCaloCells(fOutCellsName,fOutCellsName);
278 fOutCaloCells = new AliAODCaloCells(fOutCellsName,fOutCellsName);
280 if (InputEvent()->FindListObject(fOutCellsName)) {
281 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutCellsName.Data()));
285 InputEvent()->AddObject(fOutCaloCells);
289 fOutCaloCells = fCaloCells;
294 if (!fTracksName.IsNull()) {
295 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fTracksName));
297 AliWarning(Form("%s: Couldn't retrieve tracks with name %s!", GetName(), fTracksName.Data()));
299 else if (!fTracks->GetClass()->GetBaseClass("AliPicoTrack")) {
300 AliError(Form("%s: Collection %s does not contain AliPicoTrack objects!", GetName(), fTracksName.Data()));
306 fOutTracksName = fTracksName;
308 fOutTracksName += fSuffix;
309 if (fCopyArray || !fTracks) {
310 fOutTracks = new TClonesArray("AliPicoTrack");
311 fOutTracks->SetName(fOutTracksName);
312 if (InputEvent()->FindListObject(fOutTracksName)) {
313 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutTracksName.Data()));
317 InputEvent()->AddObject(fOutTracks);
321 fOutTracks = fTracks;
326 if(fAddV2 && (!fDifferentialV2)) {
327 AliWarning(Form("%s: Cannot add v2 without diffential v2!", GetName()));
330 if (!fCaloName.IsNull()) {
331 fClusters = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fCaloName));
334 AliWarning(Form("%s: Couldn't retrieve clusters with name %s!", GetName(), fCaloName.Data()));
336 else if (!fClusters->GetClass()->GetBaseClass("AliVCluster")) {
337 AliError(Form("%s: Collection %s does not contain AliVCluster objects!", GetName(), fCaloName.Data()));
343 fOutCaloName = fCaloName;
345 fOutCaloName += fSuffix;
348 className = fClusters->GetClass()->GetName();
350 className = "AliESDCaloCluster";
352 className = "AliAODCaloCluster";
354 if (fCopyArray || !fClusters) {
355 fOutClusters = new TClonesArray(className.Data());
356 fOutClusters->SetName(fOutCaloName);
357 if (InputEvent()->FindListObject(fOutCaloName)) {
358 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutCaloName.Data()));
362 InputEvent()->AddObject(fOutClusters);
366 fOutClusters = fClusters;
371 if (!fMCParticlesName.IsNull()) {
372 fMCParticles = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fMCParticlesName));
374 AliWarning(Form("%s: Couldn't retrieve MC particles with name %s!", GetName(), fMCParticlesName.Data()));
377 if (!fMCParticles->GetClass()->GetBaseClass("AliAODMCParticle")) {
378 AliError(Form("%s: Collection %s does not contain AliAODMCParticle objects!", GetName(), fMCParticlesName.Data()));
383 fMCParticlesMap = dynamic_cast<AliNamedArrayI*>(InputEvent()->FindListObject(fMCParticlesName + "_Map"));
385 if (!fMCParticlesMap) {
386 AliWarning(Form("%s: Could not retrieve map for MC particles %s! Will assume MC labels consistent with indexes...", GetName(), fMCParticlesName.Data()));
387 fMCParticlesMap = new AliNamedArrayI(fMCParticlesName + "_Map", 99999);
388 for (Int_t i = 0; i < 99999; i++) {
389 fMCParticlesMap->AddAt(i,i);
394 if (!fOutMCParticles) {
395 fOutMCParticlesName = fMCParticlesName;
397 fOutMCParticlesName += fSuffix;
398 if (fCopyArray || !fMCParticles) {
400 fOutMCParticles = new TClonesArray("AliAODMCParticle");
401 fOutMCParticles->SetName(fOutMCParticlesName);
402 if (InputEvent()->FindListObject(fOutMCParticlesName)) {
403 AliFatal(Form("%s: Collection %s is already present in the event!", GetName(), fOutMCParticlesName.Data()));
407 InputEvent()->AddObject(fOutMCParticles);
410 fOutMCParticlesMap = new AliNamedArrayI(fOutMCParticlesName + "_Map",99999);
411 if (InputEvent()->FindListObject(fOutMCParticlesName + "_Map")) {
412 AliFatal(Form("%s: Map %s_Map is already present in the event!", GetName(), fOutMCParticlesName.Data()));
416 InputEvent()->AddObject(fOutMCParticlesMap);
420 fOutMCParticles = fMCParticles;
421 fOutMCParticlesMap = fMCParticlesMap;
427 if (fGeomName.Length() > 0) {
428 fGeom = AliEMCALGeometry::GetInstance(fGeomName);
430 AliFatal(Form("Could not get geometry with name %s!", fGeomName.Data()));
434 fGeom = AliEMCALGeometry::GetInstance();
436 AliFatal("Could not get default geometry!");
445 //________________________________________________________________________
446 Int_t AliJetModelBaseTask::SetNumberOfOutCells(Int_t n)
448 if (fOutCaloCells->GetNumberOfCells() < n) {
449 fOutCaloCells->DeleteContainer();
450 fOutCaloCells->CreateContainer(n);
453 fOutCaloCells->SetNumberOfCells(n);
461 //________________________________________________________________________
462 Int_t AliJetModelBaseTask::AddCell(Double_t e, Double_t eta, Double_t phi)
464 // Add a cell to the event.
467 if (eta < -100 || phi < 0) {
468 GetRandomCell(eta, phi, absId);
471 fGeom->EtaPhiFromIndex(absId, eta, phi);
475 AliWarning(Form("Unable to embed cell in eta = %f, phi = %f!"
476 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
477 eta, phi, fEtaMin, fEtaMax, fPhiMin, fPhiMax));
482 Double_t pt = GetRandomPt();
483 TLorentzVector nPart;
484 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
488 return AddCell(e, absId);
491 //________________________________________________________________________
492 Int_t AliJetModelBaseTask::AddCell(Double_t e, Int_t absId, Double_t time, Int_t label)
494 // Add a cell to the event.
499 label += fMarkMC + fMCLabelShift;
503 pos = fCaloCells->GetCellPosition(absId);
506 Bool_t increaseOnSuccess = kFALSE;
509 increaseOnSuccess = kTRUE;
513 Short_t cellNumber = -1;
515 Double_t old_time = 0;
517 Double_t old_efrac = 0;
518 fOutCaloCells->GetCell(pos, cellNumber, old_e, old_time, old_label, old_efrac);
520 efrac = e / (old_e + e);
522 if (old_label > 0 && e < old_efrac * old_e) {
531 Bool_t r = fOutCaloCells->SetCell(pos, absId, e, time, label, efrac);
534 if (increaseOnSuccess)
542 //________________________________________________________________________
543 AliVCluster* AliJetModelBaseTask::AddCluster(AliVCluster *oc)
545 // Add a cluster to the event.
547 const Int_t nClusters = fOutClusters->GetEntriesFast();
548 AliVCluster *dc = static_cast<AliVCluster*>(fOutClusters->New(nClusters));
549 dc->SetType(AliVCluster::kEMCALClusterv1);
551 Float_t pos[3] = {0};
552 oc->GetPosition(pos);
553 dc->SetPosition(pos);
554 dc->SetNCells(oc->GetNCells());
555 dc->SetCellsAbsId(oc->GetCellsAbsId());
556 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
557 dc->SetID(oc->GetID());
558 dc->SetDispersion(oc->GetDispersion());
559 dc->SetEmcCpvDistance(-1);
561 dc->SetTOF(oc->GetTOF()); //time-of-flight
562 dc->SetNExMax(oc->GetNExMax()); //number of local maxima
563 dc->SetM02(oc->GetM02());
564 dc->SetM20(oc->GetM20());
565 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
568 UInt_t nlabels = oc->GetNLabels();
569 Int_t *labels = oc->GetLabels();
571 if (nlabels != 0 && labels)
572 parents.Set(nlabels, labels);
579 if (fMarkMC+fMCLabelShift != 0) {
580 for (UInt_t i = 0; i < nlabels; i++) {
581 parents[i] += fMarkMC+fMCLabelShift;
585 AliESDCaloCluster *esdClus = dynamic_cast<AliESDCaloCluster*>(dc);
587 esdClus->AddLabels(parents);
590 AliAODCaloCluster *aodClus = dynamic_cast<AliAODCaloCluster*>(dc);
592 aodClus->SetLabel(parents.GetArray(), nlabels);
598 //________________________________________________________________________
599 AliVCluster* AliJetModelBaseTask::AddCluster(Double_t e, Double_t eta, Double_t phi, Int_t label)
601 // Add a cluster to the event.
604 if (eta < -100 || phi < 0) {
605 GetRandomCell(eta, phi, absId);
608 fGeom->EtaPhiFromIndex(absId, eta, phi);
612 AliWarning(Form("Unable to embed cluster in eta = %f, phi = %f!"
613 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
614 eta, phi, fEtaMin, fEtaMax, fPhiMin, fPhiMax));
619 Double_t pt = GetRandomPt();
620 TLorentzVector nPart;
621 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
625 return AddCluster(e, absId, label);
628 //________________________________________________________________________
629 AliVCluster* AliJetModelBaseTask::AddCluster(Double_t e, Int_t absId, Int_t label)
631 // Add a cluster to the event.
633 const Int_t nClusters = fOutClusters->GetEntriesFast();
635 TClonesArray digits("AliEMCALDigit", 1);
637 AliEMCALDigit *digit = static_cast<AliEMCALDigit*>(digits.New(0));
639 digit->SetIndexInList(0);
640 digit->SetType(AliEMCALDigit::kHG);
641 digit->SetAmplitude(e);
643 AliEMCALRecPoint recPoint("");
644 recPoint.AddDigit(*digit, e, kFALSE);
645 recPoint.EvalGlobalPosition(0, &digits);
648 recPoint.GetGlobalPosition(gpos);
652 AliVCluster *cluster = static_cast<AliVCluster*>(fOutClusters->New(nClusters));
653 cluster->SetType(AliVCluster::kEMCALClusterv1);
654 cluster->SetE(recPoint.GetEnergy());
655 cluster->SetPosition(g);
656 cluster->SetNCells(1);
657 UShort_t shortAbsId = absId;
658 cluster->SetCellsAbsId(&shortAbsId);
659 Double32_t fract = 1;
660 cluster->SetCellsAmplitudeFraction(&fract);
661 cluster->SetID(nClusters);
662 cluster->SetEmcCpvDistance(-1);
668 label += fMarkMC+fMCLabelShift;
671 AliESDCaloCluster *esdClus = static_cast<AliESDCaloCluster*>(cluster);
672 TArrayI parents(1, &label);
673 esdClus->AddLabels(parents);
676 AliAODCaloCluster *aodClus = static_cast<AliAODCaloCluster*>(cluster);
677 aodClus->SetLabel(&label, 1);
683 //________________________________________________________________________
684 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)
686 // Add a track to the event.
688 if (pt < 0 && eta < -100 && phi < 0) {
689 GetRandomParticle(pt,eta,phi);
695 eta = GetRandomEta();
697 phi = GetRandomPhi(pt);
701 label += fMarkMC+fMCLabelShift;
703 label -= fMarkMC+fMCLabelShift;
705 if(fAddV2) AddV2(phi, pt);
707 const Int_t nTracks = fOutTracks->GetEntriesFast();
709 AliPicoTrack *track = new ((*fOutTracks)[nTracks]) AliPicoTrack(pt,
724 //________________________________________________________________________
725 AliAODMCParticle* AliJetModelBaseTask::AddMCParticle(AliAODMCParticle *part, Int_t origIndex)
727 const Int_t nPart = fOutMCParticles->GetEntriesFast();
729 AliAODMCParticle *aodpart = new ((*fOutMCParticles)[nPart]) AliAODMCParticle(*part);
731 if (origIndex + fMCLabelShift >= fOutMCParticlesMap->GetSize())
732 fOutMCParticlesMap->Set((origIndex + fMCLabelShift)*2);
734 fOutMCParticlesMap->AddAt(nPart, origIndex + fMCLabelShift);
735 AliDebug(2, Form("Setting bin %d to %d (fMCLabelShift=%d, origIndex=%d)",
736 origIndex + fMCLabelShift, fOutMCParticlesMap->At(origIndex + fMCLabelShift), fMCLabelShift, origIndex));
741 //_____________________________________________________________________________
742 void AliJetModelBaseTask::AddV2(Double_t &phi, Double_t &pt) const
744 // similar to AliFlowTrackSimple::AddV2, except for the flow fluctuations
745 Double_t phi0(phi), v2(0.), f(0.), fp(0.), phiprev(0.);
746 if(fDifferentialV2) v2 = fDifferentialV2->Eval(pt);
747 if(TMath::AreEqualAbs(v2, 0, 1e-5)) return;
748 // introduce flow fluctuations (gaussian)
749 if(fFlowFluctuations) v2 += TMath::Sqrt(2*(v2*.25)*(v2*.25))*TMath::ErfInverse(2*(gRandom->Uniform(0, fFlowFluctuations))-1);
750 for (Int_t i(0); i < 100; i++) {
751 phiprev=phi; //store last value for comparison
752 f = phi-phi0+v2*TMath::Sin(2.*(phi-fPsi));
753 fp = 1.0+2.0*v2*TMath::Cos(2.*(phi-fPsi)); //first derivative
755 if (TMath::AreEqualAbs(phiprev, phi, 1e-10)) break;
759 //_____________________________________________________________________________
760 void AliJetModelBaseTask::CopyCells()
767 for (Short_t i = 0; i < fCaloCells->GetNumberOfCells(); i++) {
771 Short_t cellNum = -1;
774 fCaloCells->GetCell(i, cellNum, amp, time, mclabel, efrac);
779 fOutCaloCells->SetCell(i, cellNum, amp, time, mclabel, efrac);
783 AliDebug(2, Form("%d cells from the current event", fAddedCells));
786 //________________________________________________________________________
787 void AliJetModelBaseTask::CopyClusters()
789 // Copy all the clusters in the new collection
793 const Int_t nClusters = fClusters->GetEntriesFast();
794 Int_t nCopiedClusters = 0;
797 for (Int_t i = 0; i < nClusters; ++i) {
798 AliESDCaloCluster *esdcluster = static_cast<AliESDCaloCluster*>(fClusters->At(i));
799 if (!esdcluster || !esdcluster->IsEMCAL())
801 AliESDCaloCluster *clus = new ((*fOutClusters)[nCopiedClusters]) AliESDCaloCluster(*esdcluster);
803 TArrayI *labels = clus->GetLabelsArray();
811 for (Int_t i = 0; i < nClusters; ++i) {
812 AliAODCaloCluster *aodcluster = static_cast<AliAODCaloCluster*>(fClusters->At(i));
813 if (!aodcluster || !aodcluster->IsEMCAL())
815 AliAODCaloCluster *clus = new ((*fOutClusters)[nCopiedClusters]) AliAODCaloCluster(*aodcluster);
823 //________________________________________________________________________
824 void AliJetModelBaseTask::CopyTracks()
826 // Copy all the tracks in the new collection
831 const Int_t nTracks = fTracks->GetEntriesFast();
832 Int_t nCopiedTracks = 0;
833 for (Int_t i = 0; i < nTracks; ++i) {
834 AliPicoTrack *picotrack = static_cast<AliPicoTrack*>(fTracks->At(i));
837 AliPicoTrack *track = new ((*fOutTracks)[nCopiedTracks]) AliPicoTrack(*picotrack);
838 if (!fIsMC && track->GetLabel() != 0)
844 //________________________________________________________________________
845 void AliJetModelBaseTask::CopyMCParticles()
847 // Copy all the MC particles in the new collection
852 const Int_t nPart = fMCParticles->GetEntriesFast();
853 Int_t nCopiedPart = 0;
854 for (Int_t i = 0; i < nPart; ++i) {
855 AliAODMCParticle *part = static_cast<AliAODMCParticle*>(fMCParticles->At(i));
858 new ((*fOutMCParticles)[nCopiedPart]) AliAODMCParticle(*part);
863 if (!fMCParticlesMap || !fOutMCParticlesMap)
866 if (fOutMCParticlesMap->GetSize() < fMCParticlesMap->GetSize())
867 fOutMCParticlesMap->Set(fMCParticlesMap->GetSize() * 2);
869 for (Int_t i = 0; i < fMCParticlesMap->GetSize(); i++) {
870 fOutMCParticlesMap->AddAt(fMCParticlesMap->At(i), i);
871 if (fMCParticlesMap->At(i) >= 0)
875 AliDebug(2,Form("MC particles copied. fMCLabelShift=%d",fMCLabelShift));
878 //________________________________________________________________________
879 void AliJetModelBaseTask::GetRandomCell(Double_t &eta, Double_t &phi, Int_t &absId)
884 Double_t rndEta = eta;
885 Double_t rndPhi = phi;
888 rndEta = GetRandomEta(kTRUE);
890 rndPhi = GetRandomPhi(kTRUE);
891 fGeom->GetAbsCellIdFromEtaPhi(rndEta, rndPhi, absId);
893 } while (absId == -1 && repeats < 100);
896 AliWarning(Form("Could not extract random cluster! Random eta-phi extracted more than 100 times!\n"
897 "eta [%f, %f], phi [%f, %f]\n", fEtaMin, fEtaMax, fPhiMin, fPhiMax));
905 //________________________________________________________________________
906 Double_t AliJetModelBaseTask::GetRandomEta(Bool_t emcal)
910 Double_t etamax = fEtaMax;
911 Double_t etamin = fEtaMin;
914 const Double_t EmcalMinEta = fGeom->GetArm1EtaMin();
915 const Double_t EmcalMaxEta = fGeom->GetArm1EtaMax();
917 if (etamax > EmcalMaxEta) etamax = EmcalMaxEta;
918 if (etamax < EmcalMinEta) etamax = EmcalMinEta;
919 if (etamin > EmcalMaxEta) etamin = EmcalMaxEta;
920 if (etamin < EmcalMinEta) etamin = EmcalMinEta;
923 return gRandom->Rndm() * (etamax - etamin) + etamin;
926 //________________________________________________________________________
927 Double_t AliJetModelBaseTask::GetRandomPhi(Bool_t emcal)
931 Double_t phimax = fPhiMax;
932 Double_t phimin = fPhiMin;
935 const Double_t EmcalMinPhi = fGeom->GetArm1PhiMin() * TMath::DegToRad();
936 const Double_t EmcalMaxPhi = fGeom->GetArm1PhiMax() * TMath::DegToRad();
938 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
939 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
940 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
941 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
944 Double_t result = gRandom->Rndm() * (phimax - phimin) + phimin;
949 //________________________________________________________________________
950 Double_t AliJetModelBaseTask::GetRandomPt()
955 return fPtSpectrum->GetRandom();
957 return gRandom->Rndm() * (fPtMax - fPtMin) + fPtMin;
960 //________________________________________________________________________
961 void AliJetModelBaseTask::GetRandomParticle(Double_t &pt, Double_t &eta, Double_t &phi, Bool_t emcal)
963 // Get a random particle.
965 eta = GetRandomEta(emcal);
967 if (fPtPhiEvPlDistribution) {
968 Double_t phimax = fPhiMax;
969 Double_t phimin = fPhiMin;
972 const Double_t EmcalMinPhi = fGeom->GetArm1PhiMin() * TMath::DegToRad();
973 const Double_t EmcalMaxPhi = fGeom->GetArm1PhiMax() * TMath::DegToRad();
975 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
976 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
977 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
978 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
981 if (fPtPhiEvPlDistribution->GetXmin() > phimax || fPtPhiEvPlDistribution->GetXmax() < phimin) {
982 AliWarning(Form("The hisogram %s does not overlap with the EMCal acceptance limits. It will be ignored.",fPtPhiEvPlDistribution->GetName()));
984 phi = GetRandomPhi(emcal);
988 fPtPhiEvPlDistribution->GetRandom2(pt,phi);
990 if (phi > TMath::Pi() * 2) phi -= TMath::Pi() * 2;
991 } while (phi > phimax || phi < phimin);
996 phi = GetRandomPhi(emcal);
1000 //________________________________________________________________________
1001 void AliJetModelBaseTask::Run()