3 // Emcal physics selection class.
7 #include "AliEmcalPhysicsSelection.h"
8 #include "AliAODEvent.h"
9 #include "AliESDEvent.h"
12 ClassImp(AliEmcalPhysicsSelection)
14 AliEmcalPhysicsSelection::AliEmcalPhysicsSelection() :
15 AliPhysicsSelection(),
28 fMinCellTrackScale(-1),
29 fMaxCellTrackScale(-1),
37 // Default constructor.
40 //__________________________________________________________________________________________________
41 UInt_t AliEmcalPhysicsSelection::GetSelectionMask(const TObject* obj)
43 // Calculate selection mask.
45 const AliVEvent *ev = dynamic_cast<const AliVEvent*>(obj);
49 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
52 const AliESDEvent *eev = dynamic_cast<const AliESDEvent*>(obj);
53 const AliAODEvent *aev = 0;
55 am->LoadBranch("AliESDHeader.");
56 am->LoadBranch("AliESDRun.");
57 TString title(eev->GetHeader()->GetTitle());
58 if (1&&(title.Length()>0)) {
59 res = ((AliVAODHeader*)eev->GetHeader())->GetUniqueID();
62 res = IsCollisionCandidate(eev);
65 aev = dynamic_cast<const AliAODEvent*>(obj);
66 res = ((AliVAODHeader*)aev->GetHeader())->GetOfflineTrigger();
69 // return 0, if 0 found
73 // return 0, if ptrs are not set
74 if ((eev==0) && (aev==0))
77 if (fTriggers) { // only process given triggers
78 if ((res & fTriggers) == 0)
83 fIsGoodEvent = kFALSE;
89 if ((res & AliVEvent::kAnyINT) ||
90 (res & AliVEvent::kSemiCentral) ||
91 (res & AliVEvent::kCentral) ||
92 (res & AliVEvent::kEMC1) ||
93 (res & AliVEvent::kEMC7) ||
94 (res & AliVEvent::kEMCEJE) ||
95 (res & AliVEvent::kEMCEGA))
101 if (fZvertexDiff || (fZvertex>0)) {
102 Double_t vzPRI = +999;
103 Double_t vzSPD = -999;
104 const AliVVertex *pv = 0;
106 am->LoadBranch("PrimaryVertex.");
107 pv = eev->GetPrimaryVertex();
109 pv = aev->GetPrimaryVertex();
111 if (pv && pv->GetNContributors()>0) {
114 const AliVVertex *sv = 0;
116 am->LoadBranch("SPDVertex.");
117 sv = eev->GetPrimaryVertexSPD();
119 sv = aev->GetPrimaryVertexSPD();
121 if (sv && sv->GetNContributors()>0) {
124 Double_t dvertex = TMath::Abs(vzPRI-vzSPD);
125 // skip events with dvertex>1mm if requested
126 // https://indico.cern.ch/getFile.py/access?contribId=4&resId=0&materialId=slides&confId=189624
127 // also check on vertex z if requested
128 if (fZvertexDiff && (dvertex>0.1))
129 fIsGoodEvent = kFALSE;
130 if ((fZvertex>0) && (TMath::Abs(vzPRI)>fZvertex))
131 fIsGoodEvent = kFALSE;
134 if ((fCentMin>-1) && (fCentMax>-1)) {
135 Double_t v0mcent = -1;
136 AliCentrality *centin = 0;
138 TTree *tree = am->GetTree();
139 if (tree->GetBranch("Centrality."))
140 am->LoadBranch("Centrality.");
141 centin = dynamic_cast<AliCentrality*>(eev->FindListObject("Centrality"));
143 centin = const_cast<AliAODEvent*>(aev)->GetCentrality();
146 v0mcent = centin->GetCentralityPercentileUnchecked("V0M");
147 if ((v0mcent<fCentMin) || (v0mcent>fCentMax))
148 fIsGoodEvent = kFALSE;
151 AliVCaloCells *cells = ev->GetEMCALCells();
152 const Short_t nCells = cells->GetNumberOfCells();
154 // mark LHC11a fast only partition if requested
155 if (res & AliVEvent::kFastOnly) {
157 if (fMarkFastOnly||fSkipFastOnly) {
159 AliFatal(Form("Number of cells %d, even though EMCAL should not be in fast only partition.",nCells));
161 fIsGoodEvent = kFALSE;
167 am->LoadBranch("EMCALCells.");
168 for(Int_t iCell=0; iCell<nCells; ++iCell) {
169 Short_t cellId = cells->GetCellNumber(iCell);
170 Double_t cellE = cells->GetCellAmplitude(cellId);
178 am->LoadBranch("CaloClusters");
180 const Int_t nCaloClusters = ev->GetNumberOfCaloClusters();
181 for(Int_t iClus = 0; iClus<nCaloClusters; ++iClus) {
182 AliVCluster *cl = ev->GetCaloCluster(iClus);
185 Double_t e = cl->E();
191 TClonesArray *trks = 0;
194 if (fTrackMinPt>0 || fMinCellTrackScale > 0 || fMaxCellTrackScale > 0) {
196 am->LoadBranch("PicoTracks");
197 trks = dynamic_cast<TClonesArray*>(eev->FindListObject("PicoTracks"));
199 am->LoadBranch("Tracks");
200 trks = dynamic_cast<TClonesArray*>(eev->FindListObject("Tracks"));
203 trks = dynamic_cast<TClonesArray*>(aev->FindListObject("tracks"));
206 Ntracks = trks->GetEntriesFast();
209 Int_t nAccTracks = 0;
211 if (fTrackMinPt>0 || fMinCellTrackScale > 0 || fMaxCellTrackScale > 0) {
212 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
213 AliVTrack *track = static_cast<AliVTrack*>(trks->At(iTracks));
216 if (aev) { // a bit ugly since cuts are hard coded for now
217 AliAODTrack *aodtrack = static_cast<AliAODTrack*>(track);
218 if (!aodtrack->TestFilterBit(256) && !aodtrack->TestFilterBit(512))
222 Double_t pt = track->Pt();
228 if (fMinCellTrackScale > 0 || fMaxCellTrackScale > 0) {
229 if (nCells < fMinCellTrackScale * nAccTracks || nCells > fMaxCellTrackScale * nAccTracks)
230 fIsGoodEvent = kFALSE;
233 // bad cell criterion for LHC11a from
234 // https://indico.cern.ch/materialDisplay.py?contribId=4&materialId=slides&confId=147067
235 const Int_t runN = ev->GetRunNumber();
236 if ((runN>=144871) && (runN<=146860)) {
239 am->LoadBranch("EMCALCells.");
241 // count cells above threshold
242 Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
243 for(Int_t iCell=0; iCell<nCells; ++iCell) {
244 Short_t cellId = cells->GetCellNumber(iCell);
245 Double_t cellE = cells->GetCellAmplitude(cellId);
246 Int_t sm = cellId / (24*48);
251 if (nCellCount[4] > 100)
254 if ((runN>=146858) && (runN<=146860)) {
255 if ((res&AliVEvent::kMB) && (nCellCount[3]>=21))
257 else if ((res&AliVEvent::kEMC1) && (nCellCount[3]>=35))
262 fIsGoodEvent = kFALSE;
267 // Check for trigger patches with 1024 bug
268 // event declared bad if at least one found
269 AliVCaloTrigger *emcaltriggers = ev->GetCaloTrigger(eev == NULL ? "EMCALTrigger" : "emcalTrigger");
271 emcaltriggers->Reset();
273 Bool_t isBad = false;
274 while(emcaltriggers->Next()){
275 emcaltriggers->GetL1TimeSum(adc);
277 // check for multiples of 1024
278 for(int i = 1; i < 20; i++){
285 fIsGoodEvent = kFALSE;
293 if (fCellMaxE>fCellMinE)
295 if ((fClusMaxE>fClusMinE) || (fTrackMaxPt>fTrackMinPt))
300 if ((fSkipLedEvent && fIsLedEvent) ||
301 (fSkipFastOnly && fIsFastOnly))