]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGGA/EMCALTasks/AliEmcalPhysicsSelection.cxx
Transition PWG4 --> PWGGA
[u/mrichter/AliRoot.git] / PWGGA / EMCALTasks / AliEmcalPhysicsSelection.cxx
1 // $Id$
2 //
3 // Emcal physics selection class
4 //
5 //
6
7 #include "AliEmcalPhysicsSelection.h"
8 #include "AliESDEvent.h"
9 #include "AliLog.h"
10
11 ClassImp(AliEmcalPhysicsSelection)
12
13 AliEmcalPhysicsSelection::AliEmcalPhysicsSelection() : 
14   AliPhysicsSelection(), 
15   fMarkFastOnly(0), 
16   fMarkLedEvent(0),
17   fSkipFastOnly(0), 
18   fSkipLedEvent(0),
19   fCellMinE(2), 
20   fClusMinE(5), 
21   fIsFastOnly(0),
22   fIsLedEvent(0),
23   fIsGoodEvent(0),
24   fCellMaxE(0), 
25   fClusMaxE(0) 
26 {
27   // Default constructor.
28 }
29
30 //__________________________________________________________________________________________________
31 UInt_t AliEmcalPhysicsSelection::GetSelectionMask(const TObject* obj) 
32
33   const AliESDEvent *ev = static_cast<const AliESDEvent*>(obj);
34   UInt_t res = IsCollisionCandidate(ev); 
35
36   fIsFastOnly  = kFALSE;
37   fIsGoodEvent = kFALSE;
38   fIsLedEvent  = kFALSE;
39   fCellMaxE    = 0;
40   fClusMaxE    = 0;
41
42   if ((res & AliVEvent::kAnyINT) || 
43       (res & AliVEvent::kEMC1)   || 
44       (res & AliVEvent::kEMC7))
45     fIsGoodEvent = kTRUE;
46
47   AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
48   am->LoadBranch("EMCALCells.");
49   am->LoadBranch("CaloClusters");
50
51   AliESDCaloCells *cells = ev->GetEMCALCells();
52   const Short_t nCells   = cells->GetNumberOfCells();
53     
54   // mark LHC11a fast only partition if requested 
55   if (res & AliVEvent::kFastOnly) {
56     fIsFastOnly = kTRUE;
57     if (fMarkFastOnly||fSkipFastOnly) {
58       if (nCells>0) {
59         AliFatal(Form("Number of cells %d, even though EMCAL should not be in fast only partition.",nCells));
60       }
61       fIsGoodEvent = kFALSE;
62     }
63   }
64
65   // count cells above threshold
66   Int_t nCellCount[10] = {0,0,0,0,0,0,0,0,0,0};
67   for(Int_t iCell=0; iCell<nCells; ++iCell) {
68     Short_t cellId = cells->GetCellNumber(iCell);
69     Double_t cellE = cells->GetCellAmplitude(cellId);
70     Int_t sm       = cellId / (24*48);
71     if (cellE>0.1)
72       ++nCellCount[sm];
73     if (cellE>fCellMaxE)
74       fCellMaxE = cellE;
75   }
76   
77   const Int_t nCaloClusters = ev->GetNumberOfCaloClusters();
78   for(Int_t iClus = 0; iClus<nCaloClusters; ++iClus) {
79     AliESDCaloCluster *cl = ev->GetCaloCluster(iClus);
80     if (!cl->IsEMCAL()) 
81       continue;
82     Double_t e = cl->E();
83     if (e>fClusMaxE)
84       fClusMaxE = e;
85   }
86
87   // bad cell criterion for LHC11a from 
88   // https://indico.cern.ch/materialDisplay.py?contribId=4&materialId=slides&confId=147067
89   const Int_t runN = ev->GetRunNumber();
90   if ((runN>=144871) && (runN<=146860)) { 
91     if (nCellCount[4] > 100)
92       fIsLedEvent = kTRUE;
93     else {
94       if ((runN>=146858) && (runN<=146860)) {
95         if ((res&AliVEvent::kMB) && (nCellCount[3]>=21))
96           fIsLedEvent = kTRUE;
97         else if ((res&AliVEvent::kEMC1) && (nCellCount[3]>=35))
98           fIsLedEvent = kTRUE;
99       }
100     }
101     if (fIsLedEvent) {
102       fIsGoodEvent = kFALSE;
103     }
104   }
105
106   if (fCellMaxE>=fCellMinE)
107     res |= kEmcalHC;
108
109   if (fClusMaxE>=fClusMinE)
110     res |= kEmcalHT;
111
112   if (fIsGoodEvent)
113     res |= kEmcalOk;
114
115   if ((fSkipLedEvent && fIsLedEvent) ||
116       (fSkipFastOnly && fIsFastOnly))
117     res = 0;
118
119   return res;
120 }