]>
Commit | Line | Data |
---|---|---|
9e7843aa | 1 | // ROOT |
2 | #include "TFile.h" | |
3 | #include "TList.h" | |
4 | #include "TObjArray.h" | |
5 | #include "TH1.h" | |
6 | #include "TH2.h" | |
7 | #include "TH3.h" | |
8 | #include "TRandom.h" | |
9 | ||
10 | // analysis framework | |
11 | #include "AliAnalysisManager.h" | |
12 | #include "AliInputEventHandler.h" | |
13 | #include "AliVEvent.h" | |
14 | #include "AliVTrdTrack.h" | |
15 | ||
16 | // MC stuff | |
17 | #include "AliMCEvent.h" | |
18 | #include "AliGenPythiaEventHeader.h" | |
19 | #include "AliTrackReference.h" | |
20 | ||
21 | // ESD stuff | |
22 | #include "AliESDEvent.h" | |
23 | #include "AliESDInputHandler.h" | |
24 | #include "AliESDtrack.h" | |
25 | #include "AliESDTrdTrack.h" | |
26 | #include "AliESDTrdTracklet.h" | |
27 | #include "AliESDTrdTrigger.h" | |
28 | ||
29 | // AOD stuff | |
30 | #include "AliAODEvent.h" | |
31 | #include "AliAODJet.h" | |
32 | #include "AliAODTrack.h" | |
33 | ||
34 | #include "AliTRDTriggerAnalysis.h" | |
35 | ||
36 | #include "AliAnalysisTaskTRDtriggerCheck.h" | |
37 | ||
38 | AliAnalysisTaskTRDtriggerCheck::AliAnalysisTaskTRDtriggerCheck(const char *name) : | |
39 | AliAnalysisTaskSE(name), | |
40 | fOutputList(), | |
41 | fHist(), | |
42 | fShortTaskId("trd_trg_check") | |
43 | { | |
44 | // default ctor | |
45 | ||
46 | DefineOutput(1, TList::Class()); | |
47 | } | |
48 | ||
49 | AliAnalysisTaskTRDtriggerCheck::~AliAnalysisTaskTRDtriggerCheck() | |
50 | { | |
51 | // dtor | |
52 | ||
53 | } | |
54 | ||
55 | void AliAnalysisTaskTRDtriggerCheck::UserCreateOutputObjects() | |
56 | { | |
57 | // create user output objects | |
58 | ||
59 | // setup list | |
60 | OpenFile(1); | |
61 | fOutputList = new TList(); | |
62 | fOutputList->SetOwner(); | |
63 | ||
64 | TH2 *h = AddHistogram(ID(kHistTrgStat), | |
65 | "trigger contributions", | |
66 | kTrgLast, -.5, kTrgLast - .5, | |
67 | kLastComb - 1, .5, kLastComb - .5); | |
68 | h->GetXaxis()->SetBinLabel(kTrgHCO + 1, "HCO"); | |
69 | h->GetXaxis()->SetBinLabel(kTrgHJT + 1, "HJT"); | |
70 | h->GetXaxis()->SetBinLabel(kTrgHSE + 1, "HSE"); | |
71 | h->GetXaxis()->SetBinLabel(kTrgHQU + 1, "HQU"); | |
72 | h->GetXaxis()->SetBinLabel(kTrgHEE + 1, "HEE"); | |
73 | h->GetYaxis()->SetBinLabel(ID(kNothing)); | |
74 | h->GetYaxis()->SetBinLabel(ID(kTriggered)); | |
75 | h->GetYaxis()->SetBinLabel(ID(kFired)); | |
76 | h->GetYaxis()->SetBinLabel(ID(kCondition)); | |
77 | h->GetYaxis()->SetBinLabel(ID(kTriggeredFired)); | |
78 | h->GetYaxis()->SetBinLabel(ID(kTriggeredCondition)); | |
79 | h->GetYaxis()->SetBinLabel(ID(kFiredCondition)); | |
80 | h->GetYaxis()->SetBinLabel(ID(kTriggeredFiredCondition)); | |
81 | ||
82 | h = AddHistogram(ID(kHistTrgStatSec), | |
83 | "SM header flag per sector;;global stack", | |
84 | kTrgLast + 1, -.5, kTrgLast + .5, | |
85 | 18, -.5, 17.5); | |
86 | h->GetXaxis()->SetBinLabel(kTrgHCO + 1, "HCO"); | |
87 | h->GetXaxis()->SetBinLabel(kTrgHJT + 1, "HJT"); | |
88 | h->GetXaxis()->SetBinLabel(kTrgHSE + 1, "HSE"); | |
89 | h->GetXaxis()->SetBinLabel(kTrgHQU + 1, "HQU"); | |
90 | h->GetXaxis()->SetBinLabel(kTrgHEE + 1, "HEE"); | |
91 | h->GetXaxis()->SetBinLabel(kTrgLast + 1, "TO"); | |
92 | ||
93 | h = AddHistogram(ID(kHistTrgStatStackCond), | |
94 | "condition per stack;;global stack", | |
95 | kTrgLast, -.5, kTrgLast - .5, | |
96 | 90, -.5, 89.5); | |
97 | h->GetXaxis()->SetBinLabel(kTrgHCO + 1, "HCO"); | |
98 | h->GetXaxis()->SetBinLabel(kTrgHJT + 1, "HJT"); | |
99 | h->GetXaxis()->SetBinLabel(kTrgHSE + 1, "HSE"); | |
100 | h->GetXaxis()->SetBinLabel(kTrgHQU + 1, "HQU"); | |
101 | h->GetXaxis()->SetBinLabel(kTrgHEE + 1, "HEE"); | |
102 | ||
103 | h = AddHistogram(ID(kHistTrgStatStackCondNotFired), | |
104 | "(condition + !fired) per stack;;global stack", | |
105 | kTrgLast, -.5, kTrgLast - .5, | |
106 | 90, -.5, 89.5); | |
107 | h->GetXaxis()->SetBinLabel(kTrgHCO + 1, "HCO"); | |
108 | h->GetXaxis()->SetBinLabel(kTrgHJT + 1, "HJT"); | |
109 | h->GetXaxis()->SetBinLabel(kTrgHSE + 1, "HSE"); | |
110 | h->GetXaxis()->SetBinLabel(kTrgHQU + 1, "HQU"); | |
111 | h->GetXaxis()->SetBinLabel(kTrgHEE + 1, "HEE"); | |
112 | ||
113 | PostData(1, fOutputList); | |
114 | } | |
115 | ||
116 | Bool_t AliAnalysisTaskTRDtriggerCheck::Notify() | |
117 | { | |
118 | // actions to be taken upon notification about input file change | |
119 | ||
120 | return AliAnalysisTaskSE::Notify(); | |
121 | } | |
122 | ||
123 | void AliAnalysisTaskTRDtriggerCheck::UserExec(Option_t * /* option */) | |
124 | { | |
125 | // actual work | |
126 | ||
127 | // setup pointers to input data (null if unavailable) | |
128 | // mcEvent: MC input | |
129 | // esdEvent: ESD input | |
130 | // outEvent: AOD output | |
131 | // aodEvent: AOD input if available, otherwise AOD output | |
132 | // AliMCEvent *mcEvent = this->MCEvent(); | |
133 | AliESDEvent *esdEvent = dynamic_cast<AliESDEvent*>(this->InputEvent()); // could also be AOD input | |
134 | // AliAODEvent* outEvent = this->AODEvent(); | |
135 | // AliAODEvent *aodEvent = outEvent; | |
136 | // if (dynamic_cast<AliAODEvent*>(this->InputEvent())) | |
137 | // aodEvent = (AliAODEvent*) (this->InputEvent()); | |
138 | ||
139 | if ((fDebug > 0) && esdEvent) | |
140 | printf("event: %s-%06i\n", CurrentFileName(), esdEvent->GetEventNumberInFile()); | |
141 | ||
9e7843aa | 142 | if (!InputEvent()->GetFiredTriggerClasses().Contains("WU")) { |
d3362e58 | 143 | if (fDebug > 0) |
144 | printf("no TRD, returning\n"); | |
9e7843aa | 145 | return; |
146 | } | |
147 | ||
148 | // reproduce hardware decision | |
149 | AliTRDTriggerAnalysis trgAnalysis; | |
d3362e58 | 150 | // trgAnalysis.SetVerbosity(1); |
9e7843aa | 151 | trgAnalysis.SetRequireInTime(kTRUE); |
152 | trgAnalysis.SetRequireMatchElectron(kFALSE); | |
153 | trgAnalysis.CalcTriggers(InputEvent()); | |
154 | ||
155 | // now what we rather want | |
156 | AliTRDTriggerAnalysis trgAnalysisGoal; | |
157 | trgAnalysisGoal.SetRequireInTime(kFALSE); | |
158 | trgAnalysisGoal.SetRequireMatchElectron(kTRUE); | |
159 | trgAnalysisGoal.CalcTriggers(InputEvent()); | |
160 | ||
161 | Int_t nTracks = InputEvent()->GetNumberOfTrdTracks(); | |
162 | for (Int_t iTrack = 0; iTrack < nTracks; ++iTrack) { | |
163 | AliVTrdTrack *trk = InputEvent()->GetTrdTrack(iTrack); | |
d3362e58 | 164 | if (fDebug > 0) |
165 | printf("trk %2i: %02i_%i - pt = %6.2f, PID = %3i, %10s, %11s\n", | |
166 | iTrack, trk->GetSector(), trk->GetStack(), | |
167 | trk->Pt(), trk->GetPID(), | |
168 | trk->GetTrackInTime() ? "in-time" : "not in-time", | |
169 | trk->GetTrackMatch() ? "matched" : "not matched"); | |
9e7843aa | 170 | } |
171 | ||
172 | const Int_t trgBits[] = { 0, 4, 5, 6, 1, 7 }; | |
173 | for (Int_t iSector = 0; iSector < 18; ++iSector) | |
174 | for (Int_t iTrg = 0; iTrg <= kTrgLast; ++iTrg) | |
175 | if (trgAnalysis.CheckTrgFlags(trgBits[iTrg], iSector)) | |
176 | FillH2(kHistTrgStatSec, iTrg, iSector); | |
177 | ||
178 | for (Int_t iTrg = 0; iTrg < kTrgLast; ++iTrg) { | |
179 | Bool_t trgd = trgAnalysis.HasTriggered((AliTRDTriggerAnalysis::TRDTrigger_t) iTrg); | |
180 | Bool_t fired = trgAnalysis.HasFired((AliTRDTriggerAnalysis::TRDTrigger_t) iTrg); | |
181 | Bool_t cond = trgAnalysis.CheckCondition((AliTRDTriggerAnalysis::TRDTrigger_t) iTrg); | |
d3362e58 | 182 | if (fDebug > 0) |
183 | printf("trigger %i: %10s %10s %10s\n", iTrg, | |
184 | trgd ? "triggered" : "", | |
185 | fired ? "fired" : "", | |
186 | cond ? "condition" : ""); | |
9e7843aa | 187 | |
188 | if (trgd && fired && cond) | |
189 | FillH2(kHistTrgStat, iTrg, kTriggeredFiredCondition); | |
190 | else if (trgd && fired && !cond) | |
191 | FillH2(kHistTrgStat, iTrg, kTriggeredFired); | |
192 | else if (trgd && !fired && cond) | |
193 | FillH2(kHistTrgStat, iTrg, kTriggeredCondition); | |
194 | else if (trgd && !fired && !cond) | |
195 | FillH2(kHistTrgStat, iTrg, kTriggered); | |
196 | else if (!trgd && fired && cond) | |
197 | FillH2(kHistTrgStat, iTrg, kFiredCondition); | |
198 | else if (!trgd && fired && !cond) | |
199 | FillH2(kHistTrgStat, iTrg, kFired); | |
200 | else if (!trgd && !fired && cond) | |
201 | FillH2(kHistTrgStat, iTrg, kCondition); | |
202 | else if (!trgd && !fired && !cond) | |
203 | FillH2(kHistTrgStat, iTrg, kNothing); | |
204 | ||
205 | for (Int_t iStack = 0; iStack < 90; ++iStack) { | |
206 | if (trgAnalysis.CheckCondition((AliTRDTriggerAnalysis::TRDTrigger_t) iTrg, iStack)) { | |
207 | FillH2(kHistTrgStatStackCond, iTrg, iStack); | |
208 | if (!fired) | |
209 | FillH2(kHistTrgStatStackCondNotFired, iTrg, iStack); | |
210 | } | |
211 | } | |
212 | } | |
213 | ||
214 | PostData(1, fOutputList); | |
215 | } | |
216 | ||
217 | void AliAnalysisTaskTRDtriggerCheck::Terminate(const Option_t * /* option */) | |
218 | { | |
219 | // actions at task termination | |
220 | } | |
221 | ||
222 | ||
223 | ||
224 | // ----- histogram management ----- | |
225 | TH1* AliAnalysisTaskTRDtriggerCheck::AddHistogram(Hist_t hist, const char *hid, TString title, | |
226 | Int_t xbins, Float_t xmin, Float_t xmax, | |
227 | Int_t binType) | |
228 | { | |
229 | TString hName; | |
230 | hName.Form("%s_%s", fShortTaskId, hid); | |
231 | hName.ToLower(); | |
232 | TH1 *h = 0x0; | |
233 | if (binType == 0) | |
234 | h = new TH1I(hName.Data(), title, | |
235 | xbins, xmin, xmax); | |
236 | else | |
237 | h = new TH1F(hName.Data(), title, | |
238 | xbins, xmin, xmax); | |
239 | GetHistogram(hist) = h; | |
240 | fOutputList->Add(h); | |
241 | return h; | |
242 | } | |
243 | ||
244 | TH2* AliAnalysisTaskTRDtriggerCheck::AddHistogram(Hist_t hist, const char *hid, TString title, | |
245 | Int_t xbins, Float_t xmin, Float_t xmax, | |
246 | Int_t ybins, Float_t ymin, Float_t ymax, | |
247 | Int_t binType) | |
248 | { | |
249 | TString hName; | |
250 | hName.Form("%s_%s", fShortTaskId, hid); | |
251 | hName.ToLower(); | |
252 | TH1 *h = 0x0; | |
253 | if (binType == 0) | |
254 | h = GetHistogram(hist) = new TH2I(hName.Data(), title, | |
255 | xbins, xmin, xmax, | |
256 | ybins, ymin, ymax); | |
257 | else | |
258 | h = GetHistogram(hist) = new TH2F(hName.Data(), title, | |
259 | xbins, xmin, xmax, | |
260 | ybins, ymin, ymax); | |
261 | fOutputList->Add(h); | |
262 | return (TH2*) h; | |
263 | } | |
264 | ||
265 | TH3* AliAnalysisTaskTRDtriggerCheck::AddHistogram(Hist_t hist, const char *hid, TString title, | |
266 | Int_t xbins, Float_t xmin, Float_t xmax, | |
267 | Int_t ybins, Float_t ymin, Float_t ymax, | |
268 | Int_t zbins, Float_t zmin, Float_t zmax, | |
269 | Int_t binType) | |
270 | { | |
271 | TString hName; | |
272 | hName.Form("%s_%s", fShortTaskId, hid); | |
273 | hName.ToLower(); | |
274 | TH1 *h = 0x0; | |
275 | if (binType == 0) | |
276 | h = GetHistogram(hist) = new TH3I(hName.Data(), title, | |
277 | xbins, xmin, xmax, | |
278 | ybins, ymin, ymax, | |
279 | zbins, zmin, zmax); | |
280 | else | |
281 | h = GetHistogram(hist) = new TH3F(hName.Data(), title, | |
282 | xbins, xmin, xmax, | |
283 | ybins, ymin, ymax, | |
284 | zbins, zmin, zmax); | |
285 | fOutputList->Add(h); | |
286 | return (TH3*) h; | |
287 | } |