20 #include <TClonesArray.h>
22 #include <TObjArray.h>
26 #include "AliAnalysisUtils.h"
27 #include "AliAODEvent.h"
28 #include "AliAODMCParticle.h"
29 #include "AliAODTrack.h"
30 #include "AliCentrality.h"
31 #include "AliESDEvent.h"
32 #include "AliESDtrack.h"
33 #include "AliInputEventHandler.h"
35 #include "AliMCEvent.h"
36 #include "AliPicoTrack.h"
38 #include "AliVCluster.h"
39 #include "AliVTrack.h"
40 #include "AliVVertex.h"
41 #include "AliEmcalTriggerPatchInfo.h"
54 ClassImp(HighPtTracks::AliReducedTrackSelectionContainer)
55 ClassImp(HighPtTracks::AliReducedHighPtEventCreator)
58 namespace HighPtTracks {
63 AliReducedHighPtEventCreator::AliReducedHighPtEventCreator():
64 AliAnalysisTaskEmcal(),
67 fTrackSelections(NULL),
68 fSwapTriggerThresholds(kFALSE),
75 fCentralityMethod(
"V0A"),
76 fMinBiasSelection(AliVEvent::kINT7)
85 AliReducedHighPtEventCreator::AliReducedHighPtEventCreator(
const char* name):
86 AliAnalysisTaskEmcal(name, kTRUE),
89 fTrackSelections(NULL),
90 fSwapTriggerThresholds(kFALSE),
97 fCentralityMethod(
"V0A"),
98 fMinBiasSelection(AliVEvent::kINT7)
100 DefineOutput(2, TTree::Class());
102 fTrackSelections =
new TObjArray;
103 fTrackSelections->SetOwner(kTRUE);
109 AliReducedHighPtEventCreator::~AliReducedHighPtEventCreator() {
110 if(fTrackSelections)
delete fTrackSelections;
116 void AliReducedHighPtEventCreator::UserCreateOutputObjects() {
117 AliAnalysisTaskEmcal::UserCreateOutputObjects();
120 fOutputTree =
new TTree(
"ReducedEvent",
"A simple reduced event");
121 fOutputEvent =
new AliReducedHighPtEvent();
122 fOutputTree->Branch(
"ReducedEvent",
"AliReducedHighPtEvent", fOutputEvent, 128000, 0);
124 PostData(1, fOutput);
125 PostData(2, fOutputTree);
138 Bool_t AliReducedHighPtEventCreator::Run() {
140 AliError(
"Cluster container missing");
144 AliError(
"Track container missing");
147 if(!SelectEvent(fInputEvent))
return kFALSE;
148 new(fOutputEvent) AliReducedHighPtEvent(kTRUE);
151 fOutputEvent->SetVertexZ(fInputEvent->GetPrimaryVertex()->GetZ());
152 AliCentrality *centralityHandler = fInputEvent->GetCentrality();
153 if(centralityHandler) fOutputEvent->SetCentralityPercentile(centralityHandler->GetCentralityPercentile(fCentralityMethod.Data()));
154 ConvertTriggerPatches(fTriggerPatchInfo, fOutputEvent->GetPatchContainer());
155 TString triggerString(fInputEvent->GetFiredTriggerClasses());
156 fOutputEvent->SetDecisionFromTriggerString(triggerString.Contains(
"EG1"), triggerString.Contains(
"EG2"), triggerString.Contains(
"EJ1"), triggerString.Contains(
"EJ2"));
157 fOutputEvent->SetMinBiasEvent(fInputHandler->IsEventSelected() & fMinBiasSelection);
158 fOutputEvent->SetRunNumber(fInputEvent->GetRunNumber());
160 std::map<int, int> mcindexmap;
163 AliReducedMCHeader *mcheader =
new AliReducedMCHeader();
165 mcheader->SetCrossSection(fXsection);
166 mcheader->SetNumberOfTrials(fNTrials);
167 mcheader->SetPtHard(fPtHard);
169 fOutputEvent->SetMonteCarloHeader(mcheader);
172 AliMCEvent *mcev = MCEvent();
174 for(Int_t ipart = 0; ipart < mcev->GetNumberOfTracks(); ipart++){
175 AliVParticle *part = mcev->GetTrack(ipart);
176 Double_t pt(TMath::Abs(part->Pt())), eta(part->Eta());
177 if(pt < fMinPt || pt > fMaxPt)
continue;
178 if(eta < fMinEta || eta > fMaxEta)
continue;
179 if(!part->Charge())
continue;
180 if(part->IsA() == AliAODMCParticle::Class()){
181 AliAODMCParticle *aodpart =
static_cast<AliAODMCParticle *
>(part);
182 if(!aodpart->IsPhysicalPrimary())
continue;
185 if(!mcev->Stack()->IsPhysicalPrimary(ipart))
continue;
188 AliReducedGeneratedParticle *reducedgen =
new AliReducedGeneratedParticle(npart, part->PdgCode(), part->Px(), part->Py(), part->Pz(), part->E());
189 fOutputEvent->AddReducedGeneratedParticle(reducedgen);
190 mcindexmap.insert(std::pair<int,int>(ipart, npart));
196 std::map<int, int> clusterindexmap;
198 Double_t vtxpos[3];fInputEvent->GetPrimaryVertex()->GetXYZ(vtxpos);
199 for(TIter cliter = TIter(fCaloClusters).Begin(); cliter != TIter::End(); ++cliter){
200 AliVCluster *incluster =
static_cast<AliVCluster *
>(*cliter);
201 if(!SelectCluster(incluster))
continue;
202 TLorentzVector clustervec;
203 incluster->GetMomentum(clustervec, vtxpos);
204 AliReducedEmcalCluster *redcluster =
new AliReducedEmcalCluster(ncluster, incluster->E(), clustervec.Eta(), clustervec.Phi(), incluster->GetM02(), incluster->GetM20());
206 TArrayD cellEnergies;
207 GetCellEnergies(incluster, cellEnergies);
208 TArrayI indices(cellEnergies.GetSize());
209 TMath::Sort(cellEnergies.GetSize(), cellEnergies.GetArray(), indices.GetArray(), kTRUE);
210 redcluster->SetLeadingCellEnergies(
211 cellEnergies[indices[0]],
212 cellEnergies.GetSize() > 1 ? cellEnergies[indices[1]] : 0,
213 cellEnergies.GetSize() > 2 ? cellEnergies[indices[2]] : 0
217 for(Int_t ilab = 0; ilab < incluster->GetNLabels(); ilab++){
218 AliVParticle *assigned = MCEvent()->GetTrack(TMath::Abs(incluster->GetLabels()[ilab]));
219 if(!assigned)
continue;
220 redcluster->AddTrueContributor(assigned->PdgCode(), assigned->Px(), assigned->Py(), assigned->Pz(), assigned->E());
223 fOutputEvent->AddReducedCluster(redcluster);
224 clusterindexmap.insert(std::pair<int,int>(incluster->GetID(), ncluster));
229 for(TIter trkiter = TIter(fTracks).Begin(); trkiter != TIter::End(); ++trkiter){
230 AliVTrack *trackRaw =
static_cast<AliVTrack *
>(*trkiter), *trackToCheck(NULL);
232 if(trackRaw->IsA() == AliPicoTrack::Class()){
233 AliPicoTrack *picotrack =
static_cast<AliPicoTrack *
>(trackRaw);
234 trackToCheck = picotrack->GetTrack();
236 trackToCheck = trackRaw;
238 FixTrackInputEvent(trackToCheck);
240 if(!SelectTrack(trackToCheck,cutIndices))
continue;
241 AliReducedReconstructedTrack *rectrack =
new AliReducedReconstructedTrack;
243 trackToCheck->GetPxPyPz(pvec);
244 rectrack->SetMomentumVector(pvec[0], pvec[1], pvec[2]);
245 rectrack->SetCharge(static_cast<Char_t>(trackToCheck->Charge()));
246 for(Int_t icut = 0; icut < cutIndices.GetSize(); icut++) rectrack->SetTrackCuts(cutIndices[icut]);
249 Int_t label = TMath::Abs(trackToCheck->GetLabel());
250 if(label < fMCEvent->GetNumberOfTracks()){
251 std::map<int,int>::iterator found = mcindexmap.find(label);
252 if(found != mcindexmap.end()){
253 rectrack->SetMatchedParticleIndex(found->second);
255 if(label >= 0) rectrack->SetGoodTrackLabel(kTRUE);
256 rectrack->SetTPCClusters(trackToCheck->GetTPCNcls());
257 rectrack->SetTPCCrossedRows(GetTPCCrossedRows(trackToCheck));
258 rectrack->SetTPCSharedClusters(trackToCheck->GetTPCSharedMapPtr()->CountBits());
259 rectrack->SetTPCFindableClusters(trackToCheck->GetTPCNclsF());
263 Int_t clusterIndex = trackToCheck->GetEMCALcluster();
264 if(clusterIndex >= 0 && clusterIndex < fCaloClusters->GetEntries()){
265 std::map<int,int>::iterator found = clusterindexmap.find(clusterIndex);
266 if(found != clusterindexmap.end()){
267 rectrack->SetMatchedClusterIndex(found->second);
270 fOutputEvent->AddReducedReconstructedParticle(rectrack);
274 PostData(2, fOutputTree);
283 void AliReducedHighPtEventCreator::AddVirtualTrackSelection(
285 fTrackSelections->Add(
new AliReducedTrackSelectionContainer(cutindex, sel));
293 Bool_t AliReducedHighPtEventCreator::SelectEvent(AliVEvent* event)
const {
294 const AliVVertex *primvtx =
event->GetPrimaryVertex();
295 if(!primvtx || !primvtx->GetNContributors())
return kFALSE;
296 if(TMath::Abs(primvtx->GetZ()) > 10.)
return kFALSE;
297 if(event->IsPileupFromSPD(3, 0.8, 3., 2., 5.))
return kFALSE;
298 AliAnalysisUtils eventSelUtil;
299 if(!eventSelUtil.IsVertexSelected2013pA(event))
return kFALSE;
308 Bool_t AliReducedHighPtEventCreator::SelectCluster(
const AliVCluster* clust)
const {
309 if(!clust->IsEMCAL())
return kFALSE;
310 if(clust->E() < fMinClusterE || clust->E() > fMaxClusterE)
return kFALSE;
320 Int_t AliReducedHighPtEventCreator::SelectTrack(AliVTrack* track, TArrayI& cutindices)
const {
321 std::vector<int> selected;
323 double pt = TMath::Abs(track->Pt()), eta = track->Eta();
324 if(pt < fMinPt || pt > fMaxPt)
return 0;
325 if(eta < fMinEta || eta > fMaxEta)
return 0;
327 for(TIter cutiter = TIter(fTrackSelections).Begin(); cutiter != TIter::End(); ++cutiter){
328 AliReducedTrackSelectionContainer *mycut =
static_cast<AliReducedTrackSelectionContainer *
>(*cutiter);
329 if(!mycut->GetTrackSelection()->IsTrackAccepted(track))
continue;
330 selected.push_back(mycut->GetIndex());
332 if(!selected.size())
return 0;
333 cutindices.Set(selected.size());
335 for(std::vector<int>::iterator inditer = selected.begin(); inditer != selected.end(); ++inditer){
336 cutindices[counter++] = *inditer;
338 return selected.size();
346 Int_t AliReducedHighPtEventCreator::GetTPCCrossedRows(
const AliVTrack* trk)
const {
347 if(trk->IsA() == AliESDtrack::Class()){
348 return (static_cast<const AliESDtrack *>(trk))->GetTPCCrossedRows();
349 }
else if(trk->IsA() == AliAODTrack::Class()){
350 return (static_cast<const AliAODTrack *>(trk))->GetTPCNCrossedRows();
360 void AliReducedHighPtEventCreator::GetCellEnergies(AliVCluster* emccluster, TArrayD& energies)
const {
361 if(!fInputEvent->GetEMCALCells()) {
362 AliError(
"No EMCAL cells");
365 AliDebug(2, Form(
"Number of cells: %d, array: %p", emccluster->GetNCells(), emccluster->GetCellsAbsId()));
366 energies.Set(emccluster->GetNCells());
367 for(
int icell = 0; icell < emccluster->GetNCells(); icell++){
369 energies[icell] = fInputEvent->GetEMCALCells()->GetCellAmplitude(emccluster->GetCellsAbsId()[icell]);
378 void AliReducedHighPtEventCreator::ConvertTriggerPatches(TClonesArray* patches,
379 AliReducedPatchContainer* cont) {
381 AliError(
"Trigger patch container not found\n");
384 for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
385 AliEmcalTriggerPatchInfo *mypatch =
static_cast<AliEmcalTriggerPatchInfo *
>(*patchIter);
386 if(!mypatch->IsOfflineSimple() && mypatch->IsLevel0())
continue;
388 Bool_t isDefined(kFALSE);
389 if(mypatch->IsOfflineSimple()){
395 AliDebug(2,
"Unknown offline patch type");
398 AliDebug(2, Form(
"Adding offline patch of type %d",
int(triggertype)));
399 cont->AddTriggerPatch(kTRUE, triggertype, mypatch->GetPatchE(), mypatch->GetADCAmp(), mypatch->GetEtaGeo(), mypatch->GetPhiGeo());
406 AliDebug(2,
"Unknown online patch type");
409 AliDebug(2, Form(
"Adding online patch of type %d",
int(triggertype)));
410 cont->AddTriggerPatch(kFALSE, triggertype, mypatch->GetPatchE(), mypatch->GetADCAmp(), mypatch->GetEtaGeo(), mypatch->GetPhiGeo());
420 void AliReducedHighPtEventCreator::FixTrackInputEvent(AliVTrack* trk) {
421 if(!trk->GetEvent()){
422 if(trk->IsA() == AliESDtrack::Class())
423 (static_cast<AliESDtrack *>(trk))->SetESDEvent(static_cast<AliESDEvent *>(fInputEvent));
424 else if(trk->IsA() == AliAODTrack::Class())
425 (static_cast<AliAODTrack *>(trk))->SetAODEvent(static_cast<AliAODEvent *>(fInputEvent));
426 else if(trk->IsA() == AliPicoTrack::Class()){
427 AliPicoTrack *mytrk =
static_cast<AliPicoTrack *
>(trk);
428 if(!mytrk->GetEvent()){
429 if(mytrk->GetTrack()->IsA() == AliESDtrack::Class())
430 (static_cast<AliESDtrack *>(mytrk->GetTrack()))->SetESDEvent(static_cast<AliESDEvent *>(fInputEvent));
432 (static_cast<AliAODTrack *>(mytrk->GetTrack()))->SetAODEvent(static_cast<AliAODEvent *>(fInputEvent));
441 AliReducedTrackSelectionContainer::AliReducedTrackSelectionContainer():
443 fTrackSelection(NULL)
452 AliReducedTrackSelectionContainer::AliReducedTrackSelectionContainer(
462 AliReducedTrackSelectionContainer::~AliReducedTrackSelectionContainer() {
463 if(fTrackSelection)
delete fTrackSelection;
Reduced event structure for high- analysis.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Jet trigger, low threshold.
Interface for virtual track selection.
Declaration of class AliReducedHighPtEventCreator and AliReducedTrackSelectionContainer.
Declaration of class AlliReducedPatchInfo.
Declaration of class AliReducedPatchContainer, a container for reduced trigger patches.
Declaration of class AliReducedGeneratedParticle.
Gamma trigger, low threshold.
Reduced information about reconstructed EMCAL clusters.
Jet trigger, high threshold.
Declartion of class AliEMCalPtTaskVTrackSelection.
Gamma trigger, high threshold.