21 #include <TClonesArray.h> 23 #include <TObjArray.h> 28 #include "AliAnalysisUtils.h" 29 #include "AliAODEvent.h" 30 #include "AliAODMCParticle.h" 31 #include "AliAODTrack.h" 32 #include "AliCentrality.h" 33 #include "AliESDEvent.h" 34 #include "AliESDtrack.h" 36 #include "AliInputEventHandler.h" 38 #include "AliMCEvent.h" 41 #include "AliVCluster.h" 42 #include "AliVTrack.h" 43 #include "AliVVertex.h" 44 #include "AliEMCALTriggerPatchInfo.h" 56 ClassImp(HighPtTracks::AliReducedTrackSelectionContainer)
65 AliReducedHighPtEventCreator::AliReducedHighPtEventCreator():
69 fTrackSelections(NULL),
70 fEventSelectionBits(AliVEvent::kAny),
71 fSwapTriggerThresholds(kFALSE),
78 fKeepFractionEvents(1.),
79 fApplyCentralitySelection(kFALSE),
80 fCentralityMethod(
"V0A"),
81 fTriggerSetup(
"4classes"),
82 fMinBiasSelection(AliVEvent::kINT7)
84 fSelectCentralityRange[0] = 0.;
85 fSelectCentralityRange[1] = 100.;
92 AliReducedHighPtEventCreator::AliReducedHighPtEventCreator(
const char* name):
96 fTrackSelections(NULL),
97 fEventSelectionBits(AliVEvent::kAny),
98 fSwapTriggerThresholds(kFALSE),
105 fKeepFractionEvents(1.),
106 fApplyCentralitySelection(kFALSE),
107 fCentralityMethod(
"V0A"),
108 fTriggerSetup(
"4classes"),
109 fMinBiasSelection(AliVEvent::kINT7)
111 DefineOutput(2, TTree::Class());
113 fSelectCentralityRange[0] = 0.;
114 fSelectCentralityRange[1] = 100.;
117 fTrackSelections->SetOwner(kTRUE);
123 AliReducedHighPtEventCreator::~AliReducedHighPtEventCreator() {
124 if(fTrackSelections)
delete fTrackSelections;
130 void AliReducedHighPtEventCreator::UserCreateOutputObjects() {
134 fOutputTree =
new TTree(
"ReducedEvent",
"A simple reduced event");
136 fOutputTree->Branch(
"ReducedEvent",
"AliReducedHighPtEvent", fOutputEvent, 128000, 0);
138 PostData(1, fOutput);
139 PostData(2, fOutputTree);
152 Bool_t AliReducedHighPtEventCreator::Run() {
153 AliDebug(1,
"Starting creation of the reconstructed event");
155 AliError(
"Cluster container missing");
159 AliError(
"Track container missing");
162 if(!(this->fInputHandler->IsEventSelected() & fEventSelectionBits)){
163 AliDebug(1,
"Trigger not selected");
166 AliDebug(1,
"Trigger selected");
168 if(!SelectEvent(fInputEvent))
return kFALSE;
172 fOutputEvent->SetVertexZ(fInputEvent->GetPrimaryVertex()->GetZ());
173 AliCentrality *centralityHandler = fInputEvent->GetCentrality();
174 if(centralityHandler) fOutputEvent->SetCentralityPercentile(centralityHandler->GetCentralityPercentile(fCentralityMethod.Data()));
175 ConvertTriggerPatches(fTriggerPatchInfo, fOutputEvent->GetPatchContainer());
176 TString triggerString(fInputEvent->GetFiredTriggerClasses());
177 if(!fTriggerSetup.CompareTo(
"4classes"))
178 fOutputEvent->SetDecisionFromTriggerString(triggerString.Contains(
"EG1"), triggerString.Contains(
"EG2"), triggerString.Contains(
"EJ1"), triggerString.Contains(
"EJ2"));
180 fOutputEvent->SetDecisionFromTriggerString(triggerString.Contains(
"EGA"), kFALSE, triggerString.Contains(
"EJE"), kFALSE);
181 fOutputEvent->SetMinBiasEvent(fInputHandler->IsEventSelected() & fMinBiasSelection);
182 fOutputEvent->SetRunNumber(fInputEvent->GetRunNumber());
184 std::map<int, int> mcindexmap;
187 AliReducedMCHeader *mcheader =
new AliReducedMCHeader();
189 mcheader->SetCrossSection(fXsection);
190 mcheader->SetNumberOfTrials(fNTrials);
191 mcheader->SetPtHard(fPtHard);
193 fOutputEvent->SetMonteCarloHeader(mcheader);
196 AliMCEvent *mcev = MCEvent();
198 for(
Int_t ipart = 0; ipart < mcev->GetNumberOfTracks(); ipart++){
199 AliVParticle *
part = mcev->GetTrack(ipart);
200 Double_t pt(TMath::Abs(part->Pt())), eta(part->Eta());
201 if(pt < fMinPt || pt > fMaxPt)
continue;
202 if(eta < fMinEta || eta > fMaxEta)
continue;
203 if(!part->Charge())
continue;
204 if(part->IsA() == AliAODMCParticle::Class()){
205 AliAODMCParticle *aodpart =
static_cast<AliAODMCParticle *
>(
part);
206 if(!aodpart->IsPhysicalPrimary())
continue;
209 if(!mcev->Stack()->IsPhysicalPrimary(ipart))
continue;
212 AliReducedGeneratedParticle *reducedgen =
new AliReducedGeneratedParticle(npart, part->PdgCode(), part->Px(), part->Py(), part->Pz(), part->E());
213 fOutputEvent->AddReducedGeneratedParticle(reducedgen);
214 mcindexmap.insert(std::pair<int,int>(ipart, npart));
220 std::map<int, int> clusterindexmap;
222 Double_t vtxpos[3];fInputEvent->GetPrimaryVertex()->GetXYZ(vtxpos);
223 for(TIter cliter = TIter(fCaloClusters).Begin(); cliter != TIter::End(); ++cliter){
224 AliVCluster *incluster =
static_cast<AliVCluster *
>(*cliter);
225 if(!SelectCluster(incluster))
continue;
226 TLorentzVector clustervec;
227 incluster->GetMomentum(clustervec, vtxpos);
228 AliReducedEmcalCluster *redcluster =
new AliReducedEmcalCluster(ncluster, incluster->E(), clustervec.Eta(), clustervec.Phi(), incluster->GetM02(), incluster->GetM20());
231 GetCellEnergies(incluster, cellEnergies);
232 TArrayI indices(cellEnergies.GetSize());
233 TMath::Sort(cellEnergies.GetSize(), cellEnergies.GetArray(), indices.GetArray(), kTRUE);
234 redcluster->SetLeadingCellEnergies(
235 cellEnergies[indices[0]],
236 cellEnergies.GetSize() > 1 ? cellEnergies[indices[1]] : 0,
237 cellEnergies.GetSize() > 2 ? cellEnergies[indices[2]] : 0
241 for(
Int_t ilab = 0; ilab < incluster->GetNLabels(); ilab++){
242 AliVParticle *assigned = MCEvent()->GetTrack(TMath::Abs(incluster->GetLabels()[ilab]));
243 if(!assigned)
continue;
244 redcluster->AddTrueContributor(assigned->PdgCode(), assigned->Px(), assigned->Py(), assigned->Pz(), assigned->E());
247 fOutputEvent->AddReducedCluster(redcluster);
248 clusterindexmap.insert(std::pair<int,int>(incluster->GetID(), ncluster));
254 AliDebug(1, Form(
"Number of tracks in container: %d", fTracks->GetEntries()));
255 for(TIter trkiter = TIter(fTracks).Begin(); trkiter != TIter::End(); ++trkiter){
256 AliVTrack *trackRaw =
static_cast<AliVTrack *
>(*trkiter), *trackToCheck(NULL);
258 if(trackRaw->IsA() == AliPicoTrack::Class()){
260 trackToCheck = picotrack->
GetTrack();
262 trackToCheck = trackRaw;
264 FixTrackInputEvent(trackToCheck);
266 if(!SelectTrack(trackToCheck,cutIndices))
continue;
267 AliReducedReconstructedTrack *rectrack =
new AliReducedReconstructedTrack;
269 trackToCheck->GetPxPyPz(pvec);
270 rectrack->SetMomentumVector(pvec[0], pvec[1], pvec[2]);
271 rectrack->SetCharge(static_cast<Char_t>(trackToCheck->Charge()));
272 for(
Int_t icut = 0; icut < cutIndices.GetSize(); icut++) rectrack->SetTrackCuts(cutIndices[icut]);
275 Int_t label = TMath::Abs(trackToCheck->GetLabel());
276 if(label < fMCEvent->GetNumberOfTracks()){
277 std::map<int,int>::iterator found = mcindexmap.find(label);
278 if(found != mcindexmap.end()){
279 rectrack->SetMatchedParticleIndex(found->second);
281 if(label >= 0) rectrack->SetGoodTrackLabel(kTRUE);
282 rectrack->SetTPCClusters(trackToCheck->GetTPCNcls());
283 rectrack->SetTPCCrossedRows(GetTPCCrossedRows(trackToCheck));
284 rectrack->SetTPCSharedClusters(trackToCheck->GetTPCSharedMapPtr()->CountBits());
285 rectrack->SetTPCFindableClusters(trackToCheck->GetTPCNclsF());
289 Int_t clusterIndex = trackToCheck->GetEMCALcluster();
290 if(clusterIndex >= 0 && clusterIndex < fCaloClusters->GetEntries()){
291 std::map<int,int>::iterator found = clusterindexmap.find(clusterIndex);
292 if(found != clusterindexmap.end()){
293 rectrack->SetMatchedClusterIndex(found->second);
297 fOutputEvent->AddReducedReconstructedParticle(rectrack);
300 AliDebug(1, Form(
"Number of selected tracks :%d ", nsel ));
303 PostData(2, fOutputTree);
313 fTrackSelections->Add(
new AliReducedTrackSelectionContainer(cutindex, sel));
322 Bool_t AliReducedHighPtEventCreator::SelectEvent(AliVEvent* event)
const {
323 if(fApplyCentralitySelection && InputEvent()->GetCentrality()){
324 AliDebug(1, Form(
"Centrality selection applied in range %f - %f\n", fSelectCentralityRange[0], fSelectCentralityRange[1]));
325 Float_t centrality = InputEvent()->GetCentrality()->GetCentralityPercentile(fCentralityMethod.Data());
326 AliDebug(1, Form(
"Centrality before: %f, estimator %s\n", centrality, fCentralityMethod.Data()));
327 if(centrality < fSelectCentralityRange[0] || centrality > fSelectCentralityRange[1])
return kFALSE;
328 AliDebug(1,
"Centrality selected");
330 const AliVVertex *primvtx =
event->GetPrimaryVertex();
331 if(!primvtx || !primvtx->GetNContributors())
return kFALSE;
332 if(TMath::Abs(primvtx->GetZ()) > 10.)
return kFALSE;
333 if(event->IsPileupFromSPD(3, 0.8, 3., 2., 5.))
return kFALSE;
334 AliAnalysisUtils eventSelUtil;
335 if(!eventSelUtil.IsVertexSelected2013pA(event))
return kFALSE;
336 if(fKeepFractionEvents < (1. - FLT_EPSILON)){
339 if(choice > fKeepFractionEvents)
return kFALSE;
349 Bool_t AliReducedHighPtEventCreator::SelectCluster(
const AliVCluster* clust)
const {
350 if(!clust->IsEMCAL())
return kFALSE;
351 if(clust->E() < fMinClusterE || clust->E() > fMaxClusterE)
return kFALSE;
361 Int_t AliReducedHighPtEventCreator::SelectTrack(AliVTrack* track,
TArrayI& cutindices)
const {
362 std::vector<int> selected;
364 double pt = TMath::Abs(track->Pt()), eta = track->Eta();
365 if(pt < fMinPt || pt > fMaxPt)
return 0;
366 if(eta < fMinEta || eta > fMaxEta)
return 0;
368 for(TIter cutiter = TIter(fTrackSelections).Begin(); cutiter != TIter::End(); ++cutiter){
369 AliReducedTrackSelectionContainer *mycut =
static_cast<AliReducedTrackSelectionContainer *
>(*cutiter);
370 if(!mycut->GetTrackSelection()->IsTrackAccepted(track))
continue;
371 selected.push_back(mycut->GetIndex());
373 if(!selected.size())
return 0;
374 cutindices.Set(selected.size());
376 for(std::vector<int>::iterator inditer = selected.begin(); inditer != selected.end(); ++inditer){
377 cutindices[counter++] = *inditer;
379 return selected.size();
387 Int_t AliReducedHighPtEventCreator::GetTPCCrossedRows(
const AliVTrack* trk)
const {
388 if(trk->IsA() == AliESDtrack::Class()){
389 return (static_cast<const AliESDtrack *>(trk))->GetTPCCrossedRows();
390 }
else if(trk->IsA() == AliAODTrack::Class()){
391 return (static_cast<const AliAODTrack *>(trk))->GetTPCNCrossedRows();
401 void AliReducedHighPtEventCreator::GetCellEnergies(AliVCluster* emccluster,
TArrayD& energies)
const {
402 if(!fInputEvent->GetEMCALCells()) {
403 AliError(
"No EMCAL cells");
406 AliDebug(2, Form(
"Number of cells: %d, array: %p", emccluster->GetNCells(), emccluster->GetCellsAbsId()));
407 energies.Set(emccluster->GetNCells());
408 for(
int icell = 0; icell < emccluster->GetNCells(); icell++){
410 energies[icell] = fInputEvent->GetEMCALCells()->GetCellAmplitude(emccluster->GetCellsAbsId()[icell]);
419 void AliReducedHighPtEventCreator::ConvertTriggerPatches(TClonesArray* patches,
420 AliReducedPatchContainer* cont) {
422 AliError(
"Trigger patch container not found\n");
425 for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
426 AliEMCALTriggerPatchInfo *mypatch =
static_cast<AliEMCALTriggerPatchInfo *
>(*patchIter);
427 if(!mypatch->IsOfflineSimple() && mypatch->IsLevel0())
continue;
430 if(mypatch->IsOfflineSimple()){
436 AliDebug(2,
"Unknown offline patch type");
439 AliDebug(2, Form(
"Adding offline patch of type %d",
int(triggertype)));
440 cont->AddTriggerPatch(kTRUE, triggertype, mypatch->GetPatchE(), mypatch->GetADCAmp(), mypatch->GetEtaGeo(), mypatch->GetPhiGeo());
447 AliDebug(2,
"Unknown online patch type");
450 AliDebug(2, Form(
"Adding online patch of type %d",
int(triggertype)));
451 cont->AddTriggerPatch(kFALSE, triggertype, mypatch->GetPatchE(), mypatch->GetADCAmp(), mypatch->GetEtaGeo(), mypatch->GetPhiGeo());
461 void AliReducedHighPtEventCreator::FixTrackInputEvent(AliVTrack* trk) {
462 if(!trk->GetEvent()){
463 if(trk->IsA() == AliESDtrack::Class())
464 (static_cast<AliESDtrack *>(trk))->SetESDEvent(static_cast<AliESDEvent *>(fInputEvent));
465 else if(trk->IsA() == AliAODTrack::Class())
466 (static_cast<AliAODTrack *>(trk))->SetAODEvent(static_cast<AliAODEvent *>(fInputEvent));
467 else if(trk->IsA() == AliPicoTrack::Class()){
469 if(!mytrk->GetEvent()){
470 if(mytrk->
GetTrack()->IsA() == AliESDtrack::Class())
471 (static_cast<AliESDtrack *>(mytrk->
GetTrack()))->SetESDEvent(static_cast<AliESDEvent *>(fInputEvent));
473 (static_cast<AliAODTrack *>(mytrk->
GetTrack()))->SetAODEvent(static_cast<AliAODEvent *>(fInputEvent));
482 AliReducedTrackSelectionContainer::AliReducedTrackSelectionContainer():
484 fTrackSelection(NULL)
502 AliReducedTrackSelectionContainer::~AliReducedTrackSelectionContainer() {
503 if(fTrackSelection)
delete fTrackSelection;
Interface for virtual track selection.
Reduced event structure for high- analysis.
Jet trigger, low threshold.
Base task in the EMCAL framework.
Declaration of class AliReducedHighPtEventCreator and AliReducedTrackSelectionContainer.
Declaration of class AlliReducedPatchInfo.
Declaration of class AliReducedPatchContainer, a container for reduced trigger patches.
TString part
use mixed event to constrain combinatorial background
Namespace for classes creating trees of events with jets.
Declaration of class AliReducedGeneratedParticle.
AliReducedHighPtEvent(Bool_t doAlloc=kFALSE)
AliVTrack * GetTrack() const
Gamma trigger, low threshold.
Reduced information about reconstructed EMCAL clusters.
void UserCreateOutputObjects()
Main initialization function on the worker.
Jet trigger, high threshold.
Gamma trigger, high threshold.
TList * OpenFile(const char *fname)