+ // class is not empty
+ if( caloTrigger->GetEntries() > 0 )
+ {
+ // must reset before usage, or the class will fail
+ caloTrigger->Reset();
+
+ // go throuth the trigger channels
+ while( caloTrigger->Next() )
+ {
+ // get position in global 2x2 tower coordinates
+ caloTrigger->GetPosition( globCol, globRow );
+
+ //L0
+ if(IsEventEMCALL0())
+ {
+ // get dimension of time arrays
+ caloTrigger->GetNL0Times( ntimes );
+
+ // no L0s in this channel
+ // presence of the channel in the iterator still does not guarantee that L0 was produced!!
+ if( ntimes < 1 )
+ continue;
+
+ // get timing array
+ caloTrigger->GetL0Times( trigtimes );
+ //printf("Get L0 patch : n times %d - trigger time window %d - %d\n",ntimes, tmin,tmax);
+
+ // go through the array
+ for( i = 0; i < ntimes; i++ )
+ {
+ // check if in cut - 8,9 shall be accepted in 2011
+ if( trigtimes[i] >= tmin && trigtimes[i] <= tmax )
+ {
+ //printf("Accepted trigger time %d \n",trigtimes[i]);
+ //if(nTrig > 99) continue;
+ GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol,globRow, absId);
+ //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
+ patches.Set(nPatch+1);
+ patches.AddAt(absId,nPatch++);
+ }
+ } // trigger time array
+ }//L0
+ else if(IsEventEMCALL1()) // L1
+ {
+ Int_t bit = 0;
+ caloTrigger->GetTriggerBits(bit);
+
+ Int_t sum = 0;
+ caloTrigger->GetL1TimeSum(sum);
+
+ Bool_t isEGA1 = ((bit >> fBitEGA ) & 0x1) && IsEventEMCALL1Gamma1() ;
+ Bool_t isEGA2 = ((bit >> (fBitEGA+1)) & 0x1) && IsEventEMCALL1Gamma2() ;
+ Bool_t isEJE1 = ((bit >> fBitEJE ) & 0x1) && IsEventEMCALL1Jet1 () ;
+ Bool_t isEJE2 = ((bit >> (fBitEJE+1)) & 0x1) && IsEventEMCALL1Jet2 () ;
+
+ if(!isEGA1 && !isEJE1 && !isEGA2 && !isEJE2) continue;
+
+ Int_t patchsize = -1;
+ if (isEGA1 || isEGA2) patchsize = 2;
+ else if (isEJE1 || isEJE2) patchsize = 16;
+
+ //printf("**** Get L1 Patch: Bit %x, sum %d, patchsize %d, EGA1 %d, EGA2 %d, EJE1 %d, EJE2 %d, EGA bit %d, EJE bit %d, Trigger Gamma %d, Trigger Jet %d\n",
+ // bit,sum,patchsize,isEGA1,isEGA2,isEJE1,isEJE2,fBitEGA,fBitEJE,IsEventEMCALL1Gamma(),IsEventEMCALL1Jet());
+
+
+ // add 2x2 (EGA) or 16x16 (EJE) patches
+ for(Int_t irow=0; irow < patchsize; irow++)
+ {
+ for(Int_t icol=0; icol < patchsize; icol++)
+ {
+ GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol+icol,globRow+irow, absId);
+ //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
+ patches.Set(nPatch+1);
+ patches.AddAt(absId,nPatch++);
+ }
+ }
+
+ } // L1
+
+ } // trigger iterator
+ } // go through triggers
+
+ if(patches.GetSize()<=0) printf("AliCaloTrackReader::GetTriggerPatches() - No patch found! for triggers: %s and selected <%s>\n",
+ GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
+ //else printf(">>>>> N patches %d, test %d,first %d, last %d\n",patches.GetSize(), nPatch, patches.At(0), patches.At(patches.GetSize()-1));
+
+ return patches;
+}
+
+//______________________________________________________________________
+void AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
+{
+ // Finds the cluster that triggered
+
+ // Init info from previous event
+ fTriggerClusterIndex = -1;
+ fTriggerClusterId = -1;
+ fTriggerClusterBC = -10000;
+ fIsExoticEvent = kFALSE;
+ fIsBadCellEvent = kFALSE;
+ fIsBadMaxCellEvent = kFALSE;
+
+ fIsTriggerMatch = kFALSE;
+ fIsTriggerMatchOpenCut[0] = kFALSE;
+ fIsTriggerMatchOpenCut[1] = kFALSE;
+ fIsTriggerMatchOpenCut[2] = kFALSE;
+
+ // Do only analysis for triggered events
+ if(!IsEventEMCALL1() && !IsEventEMCALL0())
+ {
+ fTriggerClusterBC = 0;
+ return;
+ }
+
+ //printf("***** Try to match trigger to cluster %d **** L0 %d, L1 %d\n",fTriggerPatchClusterMatch,IsEventEMCALL0(),IsEventEMCALL1());
+
+ //Recover the list of clusters
+ TClonesArray * clusterList = 0;
+ if (fInputEvent->FindListObject(fEMCALClustersListName))
+ {
+ clusterList = dynamic_cast<TClonesArray*> (fInputEvent->FindListObject(fEMCALClustersListName));
+ }
+ else if(fOutputEvent)
+ {
+ clusterList = dynamic_cast<TClonesArray*> (fOutputEvent->FindListObject(fEMCALClustersListName));
+ }
+
+ // Get number of clusters and of trigger patches
+ Int_t nclusters = fInputEvent->GetNumberOfCaloClusters();
+ if(clusterList)
+ nclusters = clusterList->GetEntriesFast();
+
+ Int_t nPatch = patches.GetSize();
+ Float_t exoDiffTime = GetCaloUtils()->GetEMCALRecoUtils()->GetExoticCellDiffTimeCut();
+
+ //Init some variables used in the cluster loop
+ Float_t tofPatchMax = 100000;
+ Float_t ePatchMax =-1;
+
+ Float_t tofMax = 100000;
+ Float_t eMax =-1;
+
+ Int_t clusMax =-1;
+ Int_t idclusMax =-1;
+ Bool_t badClMax = kFALSE;
+ Bool_t badCeMax = kFALSE;
+ Bool_t exoMax = kFALSE;
+// Int_t absIdMaxTrig= -1;
+ Int_t absIdMaxMax = -1;
+
+ Int_t nOfHighECl = 0 ;
+
+ Float_t minE = fTriggerEventThreshold / 2.;
+ // This method is not really suitable for JET trigger
+ // but in case, reduce the energy cut since we do not trigger on high energy particle
+ if(IsEventEMCALL1Jet() || minE < 1) minE = 1;
+
+ //printf("Min trigger Energy threshold %f\n",minE);
+
+ // Loop on the clusters, check if there is any that falls into one of the patches
+ for (Int_t iclus = 0; iclus < nclusters; iclus++)
+ {
+ AliVCluster * clus = 0;
+ if(clusterList) clus = (AliVCluster*) clusterList->At(iclus);
+ else clus = fInputEvent->GetCaloCluster(iclus);
+
+ if ( !clus ) continue ;
+
+ if ( !IsEMCALCluster(clus)) continue ;
+
+ //Skip clusters with too low energy to be triggering
+ if ( clus->E() < minE ) continue ;
+
+ Float_t frac = -1;
+ Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(fInputEvent->GetEMCALCells(), clus,frac);
+
+ Bool_t badCluster = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),
+ clus->GetCellsAbsId(),clus->GetNCells());
+ UShort_t cellMax[] = {(UShort_t) absIdMax};
+ Bool_t badCell = GetCaloUtils()->GetEMCALRecoUtils()->ClusterContainsBadChannel(GetCaloUtils()->GetEMCALGeometry(),cellMax,1);
+
+ // if cell is bad, it can happen that time calibration is not available,
+ // when calculating if it is exotic, this can make it to be exotic by default
+ // open it temporarily for this cluster
+ if(badCell)
+ GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(10000000);
+
+ Bool_t exotic = GetCaloUtils()->GetEMCALRecoUtils()->IsExoticCluster(clus, fInputEvent->GetEMCALCells());
+
+ // Set back the time cut on exotics
+ if(badCell)
+ GetCaloUtils()->GetEMCALRecoUtils()->SetExoticCellDiffTimeCut(exoDiffTime);
+
+ // Energy threshold for exotic Ecross typically at 4 GeV,
+ // for lower energy, check that there are more than 1 cell in the cluster
+ if(!exotic && clus->GetNCells() < 2) exotic = kTRUE;
+
+ Float_t energy = clus->E();
+ Int_t idclus = clus->GetID();
+
+ Double_t tof = clus->GetTOF();
+ if(GetCaloUtils()->GetEMCALRecoUtils()->IsTimeRecalibrationOn() && fTriggerClusterTimeRecal)
+ GetCaloUtils()->GetEMCALRecoUtils()->RecalibrateCellTime(absIdMax,fInputEvent->GetBunchCrossNumber(),tof);
+ tof *=1.e9;
+
+ //printf("cluster %d, ID %d, E %2.2f, tof %2.2f, AbsId max %d, exotic %d, bad Cluster %d, bad Cell %d\n",
+ // iclus,idclus, energy,tof,absIdMax, exotic, badCluster,badCell);
+
+ // Find the highest energy cluster, avobe trigger threshold
+ // in the event in case no match to trigger is found
+ if( energy > eMax )
+ {
+ tofMax = tof;
+ eMax = energy;
+ badClMax = badCluster;
+ badCeMax = badCell;
+ exoMax = exotic;
+ clusMax = iclus;
+ idclusMax = idclus;
+ absIdMaxMax = absIdMax;
+ }
+
+ // count the good clusters in the event avobe the trigger threshold
+ // to check the exotic events
+ if(!badCluster && !exotic)
+ nOfHighECl++;
+
+ // Find match to trigger
+ if(fTriggerPatchClusterMatch && nPatch>0)
+ {
+ for(Int_t iabsId =0; iabsId < nPatch; iabsId++)
+ {
+ Int_t absIDCell[4];
+ GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patches.At(iabsId), absIDCell);
+ //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
+ // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
+
+ for(Int_t ipatch = 0; ipatch < 4; ipatch++)
+ {
+ if(absIdMax == absIDCell[ipatch])
+ {
+ //printf("*** Patches : absId %d, E %2.1f, tof %f \n",absIdMax,clus->E(), tof);
+ if(energy > ePatchMax)
+ {
+ tofPatchMax = tof;
+ ePatchMax = energy;
+ fIsBadCellEvent = badCluster;
+ fIsBadMaxCellEvent = badCell;
+ fIsExoticEvent = exotic;
+ fTriggerClusterIndex = iclus;
+ fTriggerClusterId = idclus;
+ fIsTriggerMatch = kTRUE;
+// absIdMaxTrig = absIdMax;
+ }
+ }
+ }// cell patch loop
+ }// trigger patch loop
+ } // Do trigger patch matching
+
+ }// Cluster loop
+
+ // If there was no match, assign as trigger
+ // the highest energy cluster in the event
+ if(!fIsTriggerMatch)
+ {
+ tofPatchMax = tofMax;
+ ePatchMax = eMax;
+ fIsBadCellEvent = badClMax;
+ fIsBadMaxCellEvent = badCeMax;
+ fIsExoticEvent = exoMax;
+ fTriggerClusterIndex = clusMax;
+ fTriggerClusterId = idclusMax;
+ }
+
+ Double_t tofPatchMaxUS = TMath::Abs(tofPatchMax);
+
+ if (tofPatchMaxUS < 28 ) fTriggerClusterBC = 0 ;
+ else if(tofPatchMaxUS < 75 ) fTriggerClusterBC = 1 ;
+ else if(tofPatchMaxUS < 125) fTriggerClusterBC = 2 ;
+ else if(tofPatchMaxUS < 175) fTriggerClusterBC = 3 ;
+ else if(tofPatchMaxUS < 225) fTriggerClusterBC = 4 ;
+ else if(tofPatchMaxUS < 275) fTriggerClusterBC = 5 ;
+ else
+ {
+ //printf("AliCaloTrackReader::MatchTriggerCluster() - Large BC - tof %2.3f - Index %d\n",tofPatchMaxUS,fTriggerClusterIndex);
+ if(fTriggerClusterIndex >= 0) fTriggerClusterBC = 6 ;
+ else
+ {
+ fTriggerClusterIndex = -2;
+ fTriggerClusterId = -2;
+ }
+ }
+
+ if(tofPatchMax < 0) fTriggerClusterBC*=-1;
+
+
+ // printf("AliCaloTrackReader::MatchTriggerCluster(TArrayI patches) - Trigger cluster: index %d, ID %d, E = %2.2f, tof = %2.2f (BC = %d), bad cluster? %d, bad cell? %d, exotic? %d, patch match? %d, n High E cluster %d, absId Max %d\n",
+ // fTriggerClusterIndex, fTriggerClusterId,ePatchMax, tofPatchMax,
+ // fTriggerClusterBC, fIsBadCellEvent,fIsBadMaxCellEvent,fIsExoticEvent, fIsTriggerMatch, nOfHighECl,absIdMaxMax);
+ //
+ // if(!fIsTriggerMatch) printf("\t highest energy cluster: index %d, ID %d, E = %2.2f, tof = %2.2f, bad cluster? %d, bad cell? %d, exotic? %d\n",
+ // clusMax, idclusMax, eMax,tofMax, badClMax, badCeMax,exoMax);
+
+ //Redo matching but open cuts
+ if(!fIsTriggerMatch && fTriggerClusterId >= 0)
+ {
+ // Open time patch time
+ TArrayI patchOpen = GetTriggerPatches(7,10);
+
+
+ Int_t patchAbsIdOpenTime = -1;
+ for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
+ {
+ Int_t absIDCell[4];
+ patchAbsIdOpenTime = patchOpen.At(iabsId);
+ GetCaloUtils()->GetEMCALGeometry()->GetCellIndexFromFastORIndex(patchAbsIdOpenTime, absIDCell);
+ //if(tof > 75 ) printf("E %2.2f TOF %2.2f Trigger patch %d, cells : %d, %d, %d, %d\n",
+ // clus->E(),tof,patches.At(iabsId), absIDCell[0],absIDCell[1],absIDCell[2],absIDCell[3]);
+
+ for(Int_t ipatch = 0; ipatch < 4; ipatch++)
+ {
+ if(absIdMaxMax == absIDCell[ipatch])
+ {
+ fIsTriggerMatchOpenCut[0] = kTRUE;
+ break;
+ }
+ }// cell patch loop
+ }// trigger patch loop
+
+ // Check neighbour patches
+ Int_t patchAbsId = -1;
+ Int_t globalCol = -1;
+ Int_t globalRow = -1;
+ GetCaloUtils()->GetEMCALGeometry()->GetFastORIndexFromCellIndex(absIdMaxMax, patchAbsId);
+ GetCaloUtils()->GetEMCALGeometry()->GetPositionInEMCALFromAbsFastORIndex(patchAbsId,globalCol,globalRow);
+
+ // Check patches with strict time cut
+ Int_t patchAbsIdNeigh = -1;
+ for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
+ {
+ if(icol < 0 || icol > 47) continue;
+
+ for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
+ {
+ if(irow < 0 || irow > 63) continue;
+
+ GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeigh);
+
+ if ( patchAbsIdNeigh < 0 ) continue;
+
+ for(Int_t iabsId =0; iabsId < patches.GetSize(); iabsId++)
+ {
+ if(patchAbsIdNeigh == patches.At(iabsId))
+ {
+ fIsTriggerMatchOpenCut[1] = kTRUE;
+ break;
+ }
+ }// trigger patch loop
+
+ }// row
+ }// col
+
+ // Check patches with open time cut
+ Int_t patchAbsIdNeighOpenTime = -1;
+ for(Int_t icol = globalCol-1; icol <= globalCol+1; icol++)
+ {
+ if(icol < 0 || icol > 47) continue;
+
+ for(Int_t irow = globalRow; irow <= globalRow+1; irow++)
+ {
+ if(irow < 0 || irow > 63) continue;
+
+ GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, patchAbsIdNeighOpenTime);
+
+ if ( patchAbsIdNeighOpenTime < 0 ) continue;
+
+ for(Int_t iabsId =0; iabsId < patchOpen.GetSize(); iabsId++)
+ {
+ if(patchAbsIdNeighOpenTime == patchOpen.At(iabsId))
+ {
+ fIsTriggerMatchOpenCut[2] = kTRUE;
+ break;
+ }
+ }// trigger patch loop
+
+ }// row
+ }// col
+
+ // printf("No match, new match: Open time %d-%d, open Neigh %d-%d, both open %d-%d\n",fIsTriggerMatchOpenCut[0],patchAbsIdOpenTime,
+ // fIsTriggerMatchOpenCut[1],patchAbsIdNeigh,
+ // fIsTriggerMatchOpenCut[2],patchAbsIdNeighOpenTime);
+
+ patchOpen.Reset();
+
+ }// No trigger match found
+ //printf("Trigger BC %d, Id %d, Index %d\n",fTriggerClusterBC,fTriggerClusterId,fTriggerClusterIndex);
+
+}
+
+//________________________________________________________
+void AliCaloTrackReader::Print(const Option_t * opt) const
+{
+
+ //Print some relevant parameters set for the analysis
+ if(! opt)
+ return;
+
+ printf("***** Print: %s %s ******\n", GetName(), GetTitle() ) ;
+ printf("Task name : %s\n", fTaskName.Data()) ;
+ printf("Data type : %d\n", fDataType) ;
+ printf("CTS Min pT : %2.1f GeV/c\n", fCTSPtMin) ;
+ printf("EMCAL Min pT : %2.1f GeV/c\n", fEMCALPtMin) ;
+ printf("PHOS Min pT : %2.1f GeV/c\n", fPHOSPtMin) ;
+ printf("CTS Max pT : %2.1f GeV/c\n", fCTSPtMax) ;
+ printf("EMCAL Max pT : %2.1f GeV/c\n", fEMCALPtMax) ;
+ printf("PHOS Max pT : %2.1f GeV/c\n", fPHOSPtMax) ;
+ printf("EMCAL Time Cut: %3.1f < TOF < %3.1f\n", fEMCALTimeCutMin, fEMCALTimeCutMax);
+ printf("Use CTS = %d\n", fFillCTS) ;
+ printf("Use EMCAL = %d\n", fFillEMCAL) ;
+ printf("Use PHOS = %d\n", fFillPHOS) ;
+ printf("Use EMCAL Cells = %d\n", fFillEMCALCells) ;
+ printf("Use PHOS Cells = %d\n", fFillPHOSCells) ;
+ printf("Track status = %d\n", (Int_t) fTrackStatus) ;
+ printf("AODs Track filter mask = %d or hybrid %d (if filter bit comp %d), select : SPD hit %d, primary %d\n",
+ (Int_t) fTrackFilterMask, fSelectHybridTracks, (Int_t) fTrackFilterMaskComplementary, fSelectSPDHitTracks,fSelectPrimaryTracks) ;
+ printf("Track Mult Eta Cut = %d\n", (Int_t) fTrackMultEtaCut) ;
+ printf("Write delta AOD = %d\n", fWriteOutputDeltaAOD) ;
+ printf("Recalculate Clusters = %d, E linearity = %d\n", fRecalculateClusters, fCorrectELinearity) ;
+
+ printf("Use Triggers selected in SE base class %d; If not what Trigger Mask? %d; MB Trigger Mask for mixed %d \n",
+ fEventTriggerAtSE, fEventTriggerMask,fMixEventTriggerMask);
+
+ if(fComparePtHardAndClusterPt)
+ printf("Compare jet pt and pt hard to accept event, factor = %2.2f",fPtHardAndJetPtFactor);
+
+ if(fComparePtHardAndClusterPt)
+ printf("Compare cluster pt and pt hard to accept event, factor = %2.2f",fPtHardAndClusterPtFactor);
+
+ printf("Read Kine from, stack? %d, AOD ? %d \n", fReadStack, fReadAODMCParticles) ;
+ printf("Delta AOD File Name = %s\n", fDeltaAODFileName.Data()) ;
+ printf("Centrality: Class %s, Option %d, Bin [%d,%d] \n", fCentralityClass.Data(),fCentralityOpt,fCentralityBin[0], fCentralityBin[1]) ;
+
+ printf(" \n") ;
+
+}
+
+//__________________________________________
+Bool_t AliCaloTrackReader::RejectLEDEvents()
+{
+ // LED Events in period LHC11a contaminated sample, simple method
+ // to reject such events
+
+ // Count number of cells with energy larger than 0.1 in SM3, cut on this number
+ Int_t ncellsSM3 = 0;
+ for(Int_t icell = 0; icell < fInputEvent->GetEMCALCells()->GetNumberOfCells(); icell++)
+ {
+ Int_t absID = fInputEvent->GetEMCALCells()->GetCellNumber(icell);
+ Int_t sm = GetCaloUtils()->GetEMCALGeometry()->GetSuperModuleNumber(absID);
+ if(fInputEvent->GetEMCALCells()->GetAmplitude(icell) > 0.1 && sm==3) ncellsSM3++;
+ }
+
+ Int_t ncellcut = 21;
+ if(GetFiredTriggerClasses().Contains("EMC")) ncellcut = 35;
+
+ if(ncellsSM3 >= ncellcut)
+ {
+ if(fDebug > 0)
+ printf(" AliCaloTrackReader::FillInputEvent() - reject event with ncells in SM3 %d, cut %d, trig %s\n",
+ ncellsSM3,ncellcut,GetFiredTriggerClasses().Data());
+ return kTRUE;
+ }
+
+ return kFALSE;
+
+}
+
+//_________________________________________________________
+void AliCaloTrackReader::RemapMCLabelForAODs(Int_t & label)
+{
+ // MC label for Cells not remapped after ESD filtering, do it here.
+
+ if(label < 0) return ;
+
+ AliAODEvent * evt = dynamic_cast<AliAODEvent*> (fInputEvent) ;
+ if(!evt) return ;
+
+ TClonesArray * arr = dynamic_cast<TClonesArray*>(evt->FindListObject("mcparticles")) ;
+ if(!arr) return ;
+
+ if(label < arr->GetEntriesFast())
+ {
+ AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(label));
+ if(!particle) return ;
+
+ if(label == particle->Label()) return ; // label already OK
+ //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d - AOD stack %d \n",label, particle->Label());
+ }
+ //else printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label %d > AOD labels %d \n",label, arr->GetEntriesFast());
+
+ // loop on the particles list and check if there is one with the same label
+ for(Int_t ind = 0; ind < arr->GetEntriesFast(); ind++ )
+ {
+ AliAODMCParticle * particle = dynamic_cast<AliAODMCParticle *>(arr->At(ind));
+ if(!particle) continue ;
+
+ if(label == particle->Label())
+ {
+ label = ind;
+ //printf("AliAnalysisTaskEMCALClusterize::RemapMCLabelForAODs() - New Label Index %d \n",label);
+ return;
+ }
+ }
+
+ label = -1;
+
+ //printf("AliCaloTrackReader::RemapMCLabelForAODs() - Label not found set to -1 \n");
+
+}
+
+
+//___________________________________
+void AliCaloTrackReader::ResetLists()
+{
+ // Reset lists, called by the analysis maker
+
+ if(fCTSTracks) fCTSTracks -> Clear();
+ if(fEMCALClusters) fEMCALClusters -> Clear("C");
+ if(fPHOSClusters) fPHOSClusters -> Clear("C");
+
+ fV0ADC[0] = 0; fV0ADC[1] = 0;
+ fV0Mul[0] = 0; fV0Mul[1] = 0;
+
+ if(fNonStandardJets) fNonStandardJets -> Clear("C");
+ fBackgroundJets->Reset();
+
+}
+
+//___________________________________________
+void AliCaloTrackReader::SetEventTriggerBit()
+{
+ // Tag event depeding on trigger name
+
+ fEventTrigMinBias = kFALSE;
+ fEventTrigCentral = kFALSE;
+ fEventTrigSemiCentral = kFALSE;
+ fEventTrigEMCALL0 = kFALSE;
+ fEventTrigEMCALL1Gamma1 = kFALSE;
+ fEventTrigEMCALL1Gamma2 = kFALSE;
+ fEventTrigEMCALL1Jet1 = kFALSE;
+ fEventTrigEMCALL1Jet2 = kFALSE;
+
+ if(fDebug > 0)
+ printf("AliCaloTrackReader::SetEventTriggerBit() - Select trigger mask bit %d - Trigger Event %s - Select <%s>\n",
+ fEventTriggerMask,GetFiredTriggerClasses().Data(),fFiredTriggerClassName.Data());
+
+ if(fEventTriggerMask <=0 )// in case no mask set
+ {
+ // EMC triggered event? Which type?
+ if( GetFiredTriggerClasses().Contains("-B-") || GetFiredTriggerClasses().Contains("-S-") || GetFiredTriggerClasses().Contains("-I-") )
+ {
+ if ( GetFiredTriggerClasses().Contains("EGA" ) ||
+ GetFiredTriggerClasses().Contains("EG1" ) )
+ {
+ fEventTrigEMCALL1Gamma1 = kTRUE;
+ if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
+ }
+ else if( GetFiredTriggerClasses().Contains("EG2" ) )
+ {
+ fEventTrigEMCALL1Gamma2 = kTRUE;
+ if( !fFiredTriggerClassName.Contains("EG2") ) fEventTrigEMCALL1Gamma2 = kFALSE;
+ }
+ else if( GetFiredTriggerClasses().Contains("EJE" ) ||
+ GetFiredTriggerClasses().Contains("EJ1" ) )
+ {
+ fEventTrigEMCALL1Jet1 = kTRUE;
+ if( GetFiredTriggerClasses().Contains("EJ1" ) && !fFiredTriggerClassName.Contains("EJ1") )
+ fEventTrigEMCALL1Jet1 = kFALSE;
+ }
+ else if( GetFiredTriggerClasses().Contains("EJ2" ) )
+ {
+ fEventTrigEMCALL1Jet2 = kTRUE;
+ if( !fFiredTriggerClassName.Contains("EJ2") ) fEventTrigEMCALL1Jet2 = kFALSE;
+ }
+ else if( GetFiredTriggerClasses().Contains("CEMC") &&
+ !GetFiredTriggerClasses().Contains("EGA" ) &&
+ !GetFiredTriggerClasses().Contains("EJE" ) &&
+ !GetFiredTriggerClasses().Contains("EG1" ) &&
+ !GetFiredTriggerClasses().Contains("EJ1" ) &&
+ !GetFiredTriggerClasses().Contains("EG2" ) &&
+ !GetFiredTriggerClasses().Contains("EJ2" ) )
+ {
+ fEventTrigEMCALL0 = kTRUE;
+ }
+
+ //Min bias event trigger?
+ if (GetFiredTriggerClasses().Contains("CCENT_R2-B-NOPF-ALLNOTRD"))
+ {
+ fEventTrigCentral = kTRUE;
+ }
+ else if(GetFiredTriggerClasses().Contains("CSEMI_R1-B-NOPF-ALLNOTRD"))
+ {
+ fEventTrigSemiCentral = kTRUE;
+ }
+ else if((GetFiredTriggerClasses().Contains("CINT") || GetFiredTriggerClasses().Contains("CPBI2_B1") ) &&
+ GetFiredTriggerClasses().Contains("-NOPF-ALLNOTRD") )
+ {
+ fEventTrigMinBias = kTRUE;
+ }
+ }
+ }
+ else
+ {
+ // EMC L1 Gamma
+ if ( fEventTriggerMask & AliVEvent::kEMCEGA )
+ {
+ //printf("EGA trigger bit\n");
+ if (GetFiredTriggerClasses().Contains("EG"))
+ {
+ if (GetFiredTriggerClasses().Contains("EGA")) fEventTrigEMCALL1Gamma1 = kTRUE;
+ else
+ {
+ if(GetFiredTriggerClasses().Contains("EG1")) fEventTrigEMCALL1Gamma1 = kTRUE;
+ if(GetFiredTriggerClasses().Contains("EG2")) fEventTrigEMCALL1Gamma2 = kTRUE;
+ }
+ }
+ }
+ // EMC L1 Jet
+ else if( fEventTriggerMask & AliVEvent::kEMCEJE )
+ {
+ //printf("EGA trigger bit\n");
+ if (GetFiredTriggerClasses().Contains("EJ"))
+ {
+ if (GetFiredTriggerClasses().Contains("EJE")) fEventTrigEMCALL1Jet1 = kTRUE;
+ else
+ {
+ if(GetFiredTriggerClasses().Contains("EJ1")) fEventTrigEMCALL1Jet1 = kTRUE;
+ if(GetFiredTriggerClasses().Contains("EJ2")) fEventTrigEMCALL1Jet2 = kTRUE;
+ }
+ }
+ }
+ // EMC L0
+ else if((fEventTriggerMask & AliVEvent::kEMC7) ||
+ (fEventTriggerMask & AliVEvent::kEMC1) )
+ {
+ //printf("L0 trigger bit\n");
+ fEventTrigEMCALL0 = kTRUE;
+ }
+ // Min Bias Pb-Pb
+ else if( fEventTriggerMask & AliVEvent::kCentral )
+ {
+ //printf("MB semi central trigger bit\n");
+ fEventTrigSemiCentral = kTRUE;
+ }
+ // Min Bias Pb-Pb
+ else if( fEventTriggerMask & AliVEvent::kSemiCentral )
+ {
+ //printf("MB central trigger bit\n");
+ fEventTrigCentral = kTRUE;
+ }
+ // Min Bias pp, PbPb, pPb
+ else if((fEventTriggerMask & AliVEvent::kMB ) ||
+ (fEventTriggerMask & AliVEvent::kINT7) ||
+ (fEventTriggerMask & AliVEvent::kINT8) ||
+ (fEventTriggerMask & AliVEvent::kAnyINT) )
+ {
+ //printf("MB trigger bit\n");
+ fEventTrigMinBias = kTRUE;
+ }
+ }
+
+ if(fDebug > 0 )
+ printf("AliCaloTrackReader::SetEventTriggerBit() - Event bits: \n \t MB %d, Cen %d, Sem %d, L0 %d, L1G1 %d, L1G2 %d, L1J1 %d, L1J2 %d \n",
+ fEventTrigMinBias, fEventTrigCentral, fEventTrigSemiCentral,
+ fEventTrigEMCALL0 , fEventTrigEMCALL1Gamma1, fEventTrigEMCALL1Gamma2,
+ fEventTrigEMCALL1Jet1 , fEventTrigEMCALL1Jet2);
+
+ if(fBitEGA == 0 && fBitEJE ==0)
+ {
+ // Init the trigger bit once, correct depending on AliESDAODCaloTrigger header version
+ // Old values
+ fBitEGA = 4;
+ fBitEJE = 5;
+
+ TFile* file = AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile();
+
+ const TList *clist = file->GetStreamerInfoCache();
+
+ if(clist)
+ {
+ TStreamerInfo *cinfo = (TStreamerInfo*)clist->FindObject("AliESDCaloTrigger");
+ Int_t verid = 5; // newer ESD header version
+ if(!cinfo)
+ {
+ cinfo = (TStreamerInfo*)clist->FindObject("AliAODCaloTrigger");
+ verid = 2; // newer AOD header version
+ }
+ if(cinfo)
+ {
+ Int_t classversionid = cinfo->GetClassVersion();
+ //printf("********* Header class version %d *********** \n",classversionid);
+
+ if (classversionid >= verid)
+ {
+ fBitEGA = 6;
+ fBitEJE = 8;
+ }
+ } else printf("AliCaloTrackReader()::SetEventTriggerBit() - Streamer info for trigger class not available, bit not changed\n");
+ } else printf("AliCaloTrackReader::SetEventTriggerBit() - Streamer list not available!, bit not changed\n");
+
+ } // set once the EJE, EGA trigger bit
+
+}
+
+//____________________________________________________________
+void AliCaloTrackReader::SetInputEvent(AliVEvent* const input)
+{
+ fInputEvent = input;
+ fMixedEvent = dynamic_cast<AliMixedEvent*>(GetInputEvent()) ;
+ if (fMixedEvent)
+ fNMixedEvent = fMixedEvent->GetNumberOfEvents() ;
+
+ //Delete previous vertex
+ if(fVertex)
+ {
+ for (Int_t i = 0; i < fNMixedEvent; i++)
+ {
+ delete [] fVertex[i] ;
+ }
+ delete [] fVertex ;
+ }
+
+ fVertex = new Double_t*[fNMixedEvent] ;
+ for (Int_t i = 0; i < fNMixedEvent; i++)
+ {
+ fVertex[i] = new Double_t[3] ;
+ fVertex[i][0] = 0.0 ;
+ fVertex[i][1] = 0.0 ;
+ fVertex[i][2] = 0.0 ;
+ }
+}
+
+//____________________________________________________________
+void AliCaloTrackReader::SetTrackCuts(AliESDtrackCuts * cuts)
+{
+ // Set Track cuts
+
+ if(fESDtrackCuts) delete fESDtrackCuts ;
+
+ fESDtrackCuts = cuts ;
+
+}
+
+//_________________________________________________________________________
+void AliCaloTrackReader::SetTrackComplementaryCuts(AliESDtrackCuts * cuts)
+{
+ // Set Track cuts for complementary tracks (hybrids)
+
+ if(fESDtrackComplementaryCuts) delete fESDtrackComplementaryCuts ;
+
+ fESDtrackComplementaryCuts = cuts ;
+
+}
+