8 #include <TClonesArray.h> 10 #include <TLorentzVector.h> 17 #include "AliVEvent.h" 18 #include "AliAODCaloCluster.h" 19 #include "AliESDCaloCluster.h" 20 #include "AliVCluster.h" 21 #include "AliEMCALDigit.h" 22 #include "AliEMCALRecPoint.h" 23 #include "AliESDCaloCells.h" 24 #include "AliAODCaloCells.h" 25 #include "AliAODMCParticle.h" 26 #include "AliVCaloCells.h" 28 #include "AliEMCALGeometry.h" 45 fOutMCParticlesName(),
52 fPhiMax(TMath::Pi() * 2),
62 fPtPhiEvPlDistribution(0),
66 fFlowFluctuations(kFALSE),
81 fOutMCParticlesMap(0),
90 fMassFromDistr(kFALSE),
104 fGeomName(
"EMCAL_COMPLETE12SMV1"),
105 fTracksName(
"PicoTracks"),
106 fOutTracksName(
"PicoTracksEmbedded"),
107 fCaloName(
"CaloClustersCorr"),
108 fOutCaloName(
"CaloClustersCorrEmbedded"),
111 fMCParticlesName(
""),
112 fOutMCParticlesName(
""),
115 fSuffix(
"Processed"),
119 fPhiMax(TMath::Pi() * 2),
129 fPtPhiEvPlDistribution(0),
133 fFlowFluctuations(kFALSE),
148 fOutMCParticlesMap(0),
157 fMassFromDistr(kFALSE),
164 DefineOutput(1, TList::Class());
180 Printf(
"Note: If the code changes this method could give a wrong result");
181 TString futurenamefOutputTrack;
184 return futurenamefOutputTrack;
198 fhpTEmb =
new TH1F(
"fhpTEmb",
"#it{p}_{T} distribution; #it{p}_{T}(GeV/c)", 120, 0., 120);
202 fhMEmb =
new TH1F(
"fhMEmb",
"Mass distribution; #it{M} (GeV)", 80, 0, 80.);
206 fhEtaEmb =
new TH1F(
"fhEtaEmb",
"#eta distribution; #eta", 100, -1, 1);
210 fhPhiEmb =
new TH1F(
"fhPhiEmb",
"#varphi distribution; #varphi", 100, (-1)*TMath::Pi(), TMath::Pi());
214 fhEvents =
new TH1I(
"fhEvents",
"Number of events", 3, 0, 2);
235 const AliVVertex *vert = InputEvent()->GetPrimaryVertex();
258 AliVCaloCells *tempCaloCells = 0;
264 fCaloCells =
static_cast<AliVCaloCells*
>(tempCaloCells->Clone(Form(
"%s_old",
fCaloCells->GetName())));
287 fEsdMode = InputEvent()->InheritsFrom(
"AliESDEvent");
290 AliWarning (Form(
"PtMax (%f) < PtMin (%f), setting PtMax = PtMin = %f",
fPtMax,
fPtMin,
fPtMin));
295 AliWarning (Form(
"EtaMax (%f) < EtaMin (%f), setting EtaMax = EtaMin = %f",
fEtaMax,
fEtaMin,
fEtaMin));
300 AliWarning (Form(
"PhiMax (%f) < PhiMin (%f), setting PhiMax = PhiMin = %f",
fPhiMax,
fPhiMin,
fPhiMin));
307 AliWarning(Form(
"%s: Couldn't retrieve calo cells with name %s!", GetName(),
fCellsName.Data()));
309 else if (!
fCaloCells->InheritsFrom(
"AliVCaloCells")) {
310 AliError(Form(
"%s: Collection %s does not contain a AliVCaloCells object!", GetName(),
fCellsName.Data()));
326 AliFatal(Form(
"%s: Collection %s is already present in the event!", GetName(),
fOutCellsName.Data()));
342 AliWarning(Form(
"%s: Couldn't retrieve tracks with name %s!", GetName(),
fTracksName.Data()));
344 else if (!
fTracks->GetClass()->GetBaseClass(
"AliPicoTrack")) {
345 AliError(Form(
"%s: Collection %s does not contain AliPicoTrack objects!", GetName(),
fTracksName.Data()));
354 fOutTracks =
new TClonesArray(
"AliPicoTrack");
358 AliFatal(Form(
"%s: Collection %s is already present in the event!", GetName(),
fOutTracksName.Data()));
374 AliWarning(Form(
"%s: Cannot add v2 without diffential v2!", GetName()));
381 AliWarning(Form(
"%s: Couldn't retrieve clusters with name %s!", GetName(),
fCaloName.Data()));
383 else if (!
fClusters->GetClass()->GetBaseClass(
"AliVCluster")) {
384 AliError(Form(
"%s: Collection %s does not contain AliVCluster objects!", GetName(),
fCaloName.Data()));
395 className =
fClusters->GetClass()->GetName();
397 className =
"AliESDCaloCluster";
399 className =
"AliAODCaloCluster";
405 AliFatal(Form(
"%s: Collection %s is already present in the event!", GetName(),
fOutCaloName.Data()));
421 AliWarning(Form(
"%s: Couldn't retrieve MC particles with name %s!", GetName(),
fMCParticlesName.Data()));
424 if (!
fMCParticles->GetClass()->GetBaseClass(
"AliAODMCParticle")) {
425 AliError(Form(
"%s: Collection %s does not contain AliAODMCParticle objects!", GetName(),
fMCParticlesName.Data()));
433 AliWarning(Form(
"%s: Could not retrieve map for MC particles %s! Will assume MC labels consistent with indexes...", GetName(),
fMCParticlesName.Data()));
435 for (
Int_t i = 0; i < 99999; i++) {
450 AliFatal(Form(
"%s: Collection %s is already present in the event!", GetName(),
fOutMCParticlesName.Data()));
459 AliFatal(Form(
"%s: Map %s_Map is already present in the event!", GetName(),
fOutMCParticlesName.Data()));
477 AliFatal(Form(
"Could not get geometry with name %s!",
fGeomName.Data()));
481 fGeom = AliEMCALGeometry::GetInstance();
483 AliFatal(
"Could not get default geometry!");
514 if (eta < -100 || phi < 0) {
518 fGeom->EtaPhiFromIndex(absId, eta, phi);
522 AliWarning(Form(
"Unable to embed cell in eta = %f, phi = %f!" 523 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
530 TLorentzVector nPart;
531 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
553 Bool_t increaseOnSuccess = kFALSE;
556 increaseOnSuccess = kTRUE;
565 fOutCaloCells->GetCell(pos, cellNumber, old_e, old_time, old_label, old_efrac);
567 efrac = e / (old_e + e);
569 if (old_label > 0 && e < old_efrac * old_e) {
581 if (increaseOnSuccess)
595 AliVCluster *dc =
static_cast<AliVCluster*
>(
fOutClusters->New(nClusters));
596 dc->SetType(AliVCluster::kEMCALClusterv1);
599 oc->GetPosition(pos);
600 dc->SetPosition(pos);
601 dc->SetNCells(oc->GetNCells());
602 dc->SetCellsAbsId(oc->GetCellsAbsId());
603 dc->SetCellsAmplitudeFraction(oc->GetCellsAmplitudeFraction());
604 dc->SetID(oc->GetID());
605 dc->SetDispersion(oc->GetDispersion());
606 dc->SetEmcCpvDistance(-1);
608 dc->SetTOF(oc->GetTOF());
609 dc->SetNExMax(oc->GetNExMax());
610 dc->SetM02(oc->GetM02());
611 dc->SetM20(oc->GetM20());
612 dc->SetDistanceToBadChannel(oc->GetDistanceToBadChannel());
615 UInt_t nlabels = oc->GetNLabels();
616 Int_t *labels = oc->GetLabels();
618 if (nlabels != 0 && labels)
619 parents.Set(nlabels, labels);
627 for (
UInt_t i = 0; i < nlabels; i++) {
632 AliESDCaloCluster *esdClus =
dynamic_cast<AliESDCaloCluster*
>(dc);
634 esdClus->AddLabels(parents);
637 AliAODCaloCluster *aodClus =
dynamic_cast<AliAODCaloCluster*
>(dc);
639 aodClus->SetLabel(parents.GetArray(), nlabels);
651 if (eta < -100 || phi < 0) {
655 fGeom->EtaPhiFromIndex(absId, eta, phi);
659 AliWarning(Form(
"Unable to embed cluster in eta = %f, phi = %f!" 660 " Maybe the eta-phi range is not inside the EMCal acceptance (eta = [%f, %f], phi = [%f, %f])",
667 TLorentzVector nPart;
668 nPart.SetPtEtaPhiM(pt, eta, phi, 0);
682 TClonesArray digits(
"AliEMCALDigit", 1);
684 AliEMCALDigit *digit =
static_cast<AliEMCALDigit*
>(digits.New(0));
686 digit->SetIndexInList(0);
687 digit->SetType(AliEMCALDigit::kHG);
688 digit->SetAmplitude(e);
690 AliEMCALRecPoint recPoint(
"");
691 recPoint.AddDigit(*digit, e, kFALSE);
692 recPoint.EvalGlobalPosition(0, &digits);
695 recPoint.GetGlobalPosition(gpos);
699 AliVCluster *cluster =
static_cast<AliVCluster*
>(
fOutClusters->New(nClusters));
700 cluster->SetType(AliVCluster::kEMCALClusterv1);
701 cluster->SetE(recPoint.GetEnergy());
702 cluster->SetPosition(g);
703 cluster->SetNCells(1);
705 cluster->SetCellsAbsId(&shortAbsId);
706 Double32_t fract = 1;
707 cluster->SetCellsAmplitudeFraction(&fract);
708 cluster->SetID(nClusters);
709 cluster->SetEmcCpvDistance(-1);
718 AliESDCaloCluster *esdClus =
static_cast<AliESDCaloCluster*
>(cluster);
720 esdClus->AddLabels(parents);
723 AliAODCaloCluster *aodClus =
static_cast<AliAODCaloCluster*
>(cluster);
724 aodClus->SetLabel(&label, 1);
731 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)
734 if (pt < 0 && eta < -100 && phi < -100 && mass < -100) {
737 if (pt < 0 && eta < -100 && phi < -100) {
778 AliAODMCParticle *aodpart =
new ((*fOutMCParticles)[nPart]) AliAODMCParticle(*part);
784 AliDebug(2, Form(
"Setting bin %d to %d (fMCLabelShift=%d, origIndex=%d)",
794 Double_t phi0(phi), v2(0.), f(0.), fp(0.), phiprev(0.);
796 if(TMath::AreEqualAbs(v2, 0, 1e-5))
return;
799 for (
Int_t i(0); i < 100; i++) {
801 f = phi-phi0+v2*TMath::Sin(2.*(phi-
fPsi));
802 fp = 1.0+2.0*v2*TMath::Cos(2.*(phi-
fPsi));
804 if (TMath::AreEqualAbs(phiprev, phi, 1e-10))
break;
823 fCaloCells->GetCell(i, cellNum, amp, time, mclabel, efrac);
828 fOutCaloCells->SetCell(i, cellNum, amp, time, mclabel, efrac);
832 AliDebug(2, Form(
"%d cells from the current event",
fAddedCells));
843 Int_t nCopiedClusters = 0;
846 for (
Int_t i = 0; i < nClusters; ++i) {
847 AliESDCaloCluster *esdcluster =
static_cast<AliESDCaloCluster*
>(
fClusters->At(i));
848 if (!esdcluster || !esdcluster->IsEMCAL())
850 AliESDCaloCluster *clus =
new ((*fOutClusters)[nCopiedClusters]) AliESDCaloCluster(*esdcluster);
852 TArrayI *labels = clus->GetLabelsArray();
860 for (
Int_t i = 0; i < nClusters; ++i) {
861 AliAODCaloCluster *aodcluster =
static_cast<AliAODCaloCluster*
>(
fClusters->At(i));
862 if (!aodcluster || !aodcluster->IsEMCAL())
864 AliAODCaloCluster *clus =
new ((*fOutClusters)[nCopiedClusters]) AliAODCaloCluster(*aodcluster);
881 Int_t nCopiedTracks = 0;
882 for (
Int_t i = 0; i < nTracks; ++i) {
902 Int_t nCopiedPart = 0;
903 for (
Int_t i = 0; i < nPart; ++i) {
904 AliAODMCParticle *part =
static_cast<AliAODMCParticle*
>(
fMCParticles->At(i));
907 new ((*fOutMCParticles)[nCopiedPart]) AliAODMCParticle(*part);
924 AliDebug(2,Form(
"MC particles copied. fMCLabelShift=%d",
fMCLabelShift));
940 fGeom->GetAbsCellIdFromEtaPhi(rndEta, rndPhi, absId);
942 }
while (absId == -1 && repeats < 100);
945 AliWarning(Form(
"Could not extract random cluster! Random eta-phi extracted more than 100 times!\n" 966 if (etamax > EmcalMaxEta) etamax = EmcalMaxEta;
967 if (etamax < EmcalMinEta) etamax = EmcalMinEta;
968 if (etamin > EmcalMaxEta) etamin = EmcalMaxEta;
969 if (etamin < EmcalMinEta) etamin = EmcalMinEta;
984 const Double_t EmcalMinPhi =
fGeom->GetArm1PhiMin() * TMath::DegToRad();
985 const Double_t EmcalMaxPhi =
fGeom->GetArm1PhiMax() * TMath::DegToRad();
987 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
988 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
989 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
990 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
1018 AliError(
"Template distribution for mass of track embedding not found, use 0");
1032 if(maxedgex < maxedgey)
1050 const Double_t EmcalMinPhi =
fGeom->GetArm1PhiMin() * TMath::DegToRad();
1051 const Double_t EmcalMaxPhi =
fGeom->GetArm1PhiMax() * TMath::DegToRad();
1053 if (phimax > EmcalMaxPhi) phimax = EmcalMaxPhi;
1054 if (phimax < EmcalMinPhi) phimax = EmcalMinPhi;
1055 if (phimin > EmcalMaxPhi) phimin = EmcalMaxPhi;
1056 if (phimin < EmcalMinPhi) phimin = EmcalMinPhi;
1060 AliWarning(Form(
"The hisogram %s does not overlap with the EMCal acceptance limits. It will be ignored.",
fPtPhiEvPlDistribution->GetName()));
1068 if (phi > TMath::Pi() * 2) phi -= TMath::Pi() * 2;
1069 }
while (phi > phimax || phi < phimin);
1109 AliError(
"Histograms not found, are the QA histograms active?");
1116 if(!trackEmb)
continue;
1133 AliError(
"Null histogram for mass distribution");
1138 AliInfo(
"Input mass distribution set");
1147 AliError(
"Null histogram for mass vs pt distribution");
1152 AliInfo(
"Input mass vs pt distribution set");
1176 if(filename.Contains(
"alien")) {
1177 TGrid::Connect(
"alien://");
1179 TFile *f = TFile::Open(filename);
1181 AliFatal(Form(
"File %s not found, cannot SetMassDistribution", filename.Data()));
1188 h =
dynamic_cast<TH1F*
> (f->Get(histoname));
1190 AliError(
"Input file for Mass not found");
1195 g =
dynamic_cast<TH2F*
> (f->Get(histoname));
1197 AliError(
"Input file for Mass not found");
TH1F * fDensitySpectrum
particle density spectrum to extract random density values
virtual void Run()
intialize task
TClonesArray * fClusters
! cluster collection
Double_t GetRandomPt()
generate a random phi value in the given range
void SetpTDistributionFromFile(TString filename, TString histoname)
TString fOutCellsName
name of output cells collection
Float_t fPtMin
pt minimum value
TList * fOutput
! output list for QA histograms
TClonesArray * fOutClusters
! output cluster collection
Int_t fMarkMC
which MC label is to be used (default=100)
TString fOutTracksName
name of output track collection
void SetMassDistribution(TH1F *hM)
void SetMassVsPtDistribution(TH2F *hmasspt)
Bool_t fIsInit
! =true if initialized
TString fMCParticlesName
name of MC particle collection
AliNamedArrayI * fMCParticlesMap
! MC particles mapping
void GetRandomMassiveParticle(Double_t &pt, Double_t &eta, Double_t &phi, Bool_t emcal, Double_t &m)
generate a particle with random eta,phi,pt values
Base class for embedding into an event.
TString GetOutTrackName() const
Bool_t fIsMC
whether the current event is MC or not
void UserCreateOutputObjects()
virtual ~AliJetModelBaseTask()
TString fCaloName
name of calo cluster collection
TString fCellsName
name of calo cells collection
AliVCaloCells * fCaloCells
! cells collection
Float_t fEtaMax
eta maximum value
TClonesArray * fOutTracks
! output track collection
TH1I * fhEvents
! store the number of events analysed
TClonesArray * fOutMCParticles
! output MC particles collection
Int_t fNTracks
how many tracks are being processed
Float_t fPhiMin
phi minimum value
Bool_t fEsdMode
! ESD/AOD mode
Bool_t fAddV2
add v2 sampled from a tf1
Double_t GetRandomM()
generate a random pt value in the given range
void GetRandomParticle(Double_t &pt, Double_t &eta, Double_t &phi, Bool_t emcal=kFALSE)
generate a random m value from a given distribution or take a fixed value
TString fTracksName
name of track collection
TH1F * fhpTEmb
! embedded tracks pT
void UserExec(Option_t *)
Bool_t fFlowFluctuations
introduce gaussian flow fluctuation
TString fOutMCParticlesName
name of output MC particle collection
void GetRandomCell(Double_t &eta, Double_t &phi, Int_t &absId)
TString fOutCaloName
name of output cluster collection
Int_t fNClusters
how many clusters are being processed
Int_t fMCLabelShift
! MC label shift
void SetLabel(Int_t label)
void SetDistributionFromFile(TString filename, TString histoname, Int_t type)
AliAODMCParticle * AddMCParticle(AliAODMCParticle *part, Int_t origIndex)
add a track; if values are -1 generate random parameters
AliVCaloCells * fOutCaloCells
! output cells collection
Bool_t fQAhistos
draw QA histograms
TString fSuffix
suffix to add in the name of new collections
TH1F * fhPhiEmb
! embedded tracks phi
Bool_t fCopyArray
whether or not the array will be copied to a new one before modelling
Int_t SetNumberOfOutCells(Int_t n)
void GetRandomMvsPt(Double_t &m, Double_t &pt)
generate a particle with random eta,phi,pt,mass values
TClonesArray * fMCParticles
! MC particles collection
Int_t AddCell(Double_t e=-1, Double_t eta=-999, Double_t phi=-1)
set the number of cells
Double_t GetRandomPhi(Bool_t emcal=kFALSE)
generate a random eta value in the given range
TH2F * fHMassPtDistrib
shape of mass vs pt distribution of embedded track
TF2 * fPtPhiEvPlDistribution
pt vs. (phi-psi) distribution to extract random pt/phi values
void FillHistograms()
do jet model action
AliNamedArrayI * fOutMCParticlesMap
! MC particles mapping
Int_t fAddedCells
! number of added cells
Double_t fPsi
! simmetry plane for the elliptic flow
TH1F * fhEtaEmb
! embedded tracks eta
AliVCluster * AddCluster(Double_t e=-1, Double_t eta=-999, Double_t phi=-1, Int_t label=0)
add a cell with given energy, position and times
TF1 * fDifferentialV2
v2 as function of pt
Bool_t fMassFromDistr
draw the particle mass from fHMassDistrib
TH1F * fhMEmb
! embedded tracks M
Float_t fEtaMin
eta minimum value
void Clear(Option_t *option="")
TH1F * fPtSpectrum
pt spectrum to extract random pt values
TString fGeomName
Fill QA histograms.
TH1F * fHMassDistrib
shape of mass distribution of embedded tracks
Double_t fVertex[3]
! event vertex
void AddV2(Double_t &phi, Double_t &pt) const
AliPicoTrack * AddTrack(Double_t pt=-999, Double_t eta=-999, Double_t phi=-999, Byte_t type=0, Double_t etaemc=0, Double_t phiemc=0, Double_t ptemc=0, Bool_t ise=kFALSE, Int_t label=0, Short_t charge=1, Double_t mass=0.1396)
add a cluster (copy)
void SetMassDistributionFromFile(TString filename, TString histoname)
Float_t fPhiMax
phi maximum value
void SetMassAndPtDistributionFromFile(TString filenameM, TString filenamepT, TString histonameM, TString histonamepT)
TClonesArray * fTracks
! track collection
void GetRandomMvsPtParticle(Double_t &pt, Double_t &m, Double_t &eta, Double_t &phi, Bool_t emcal=kFALSE)
generate 2 random values for pt and mass from a gived 2D distribution
AliEMCALGeometry * fGeom
! pointer to EMCal geometry
virtual Bool_t ExecOnce()
generate a particle with random eta,phi, and correlated pt,mass values
void SetPtSpectrum(TH1F *f)
Double_t GetRandomEta(Bool_t emcal=kFALSE)
generate a random cell in the calorimeter
Int_t fNCells
how many cells are being processed
TList * OpenFile(const char *fname)
void SetMassVsPtDistributionFromFile(TString filename, TString histoname)
Float_t fPtMax
pt maximum value